MediaWiki
master
|
The "stack of open elements" as defined in the HTML5 tree builder spec. More...
Public Member Functions | |
__construct () | |
Create a new BalanceStack with a single BalanceElement on it, representing the root <html> node. More... | |
__toString () | |
Return the contents of the open elements stack as a string for debugging. More... | |
adjustedCurrentNode ($fragmentContext) | |
Return the adjusted current node. More... | |
adoptionAgency ($tag, $afe) | |
Run the "adoption agency algoritm" (AAA) for the given subject tag name. More... | |
clearToContext ($set) | |
Pop elements off the stack not including the first element in the specified set. More... | |
generateImpliedEndTags ($butnot=null, $thorough=false) | |
Generate implied end tags. More... | |
getIterator () | |
Return an iterator over this stack which visits the current node first, and the root node last. More... | |
getOutput () | |
Return a string representing the output of the tree builder: all the children of the root <html> node. More... | |
inButtonScope ($tag) | |
Determine if the stack has $tag in button scope. More... | |
indexOf ($tag) | |
Return the position of the given BalanceElement, set, or HTML tag name string in the BalanceStack. More... | |
inListItemScope ($tag) | |
Determine if the stack has $tag in list item scope. More... | |
inScope ($tag) | |
Determine if the stack has $tag in scope. More... | |
inSelectScope ($tag) | |
Determine if the stack has $tag in select scope. More... | |
insertAfter (BalanceElement $a, BalanceElement $b) | |
Find $a in the BalanceStack and insert $b after it. More... | |
insertComment ($value) | |
Insert a comment at the appropriate place for inserting a node. More... | |
insertElement (BalanceElement $elt) | |
Insert an element at the appropriate place and push it on to the open elements stack. More... | |
insertForeignElement ($namespaceURI, $tag, $attribs) | |
Insert a BalanceElement at the appropriate place, pushing it on to the open elements stack. More... | |
insertHTMLElement ($tag, $attribs) | |
Insert an HTML element at the appropriate place, pushing it on to the open elements stack. More... | |
insertText ($value, $isComment=false) | |
Insert text at the appropriate place for inserting a node. More... | |
inSpecificScope ($tag, $set) | |
Determine if the stack has $tag in a specific scope, $set. More... | |
inTableScope ($tag) | |
Determine if the stack has $tag in table scope. More... | |
length () | |
Return the number of elements currently in the BalanceStack. More... | |
node ($idx) | |
Return the BalanceElement at the given position $idx, where position 0 represents the root element. More... | |
pop () | |
Remove the current node from the BalanceStack, flattening it in the process. More... | |
popTag ($tag) | |
Pop elements off the stack up to and including the first element with the specified HTML tagname (or matching the given set). More... | |
popTo ($idx) | |
Remove all nodes up to and including position $idx from the BalanceStack, flattening them in the process. More... | |
removeElement (BalanceElement $elt, $flatten=true) | |
Remove the given $elt from the BalanceStack, optionally flattening it in the process. More... | |
replaceAt ($idx, BalanceElement $elt) | |
Replace the element at position $idx in the BalanceStack with $elt. More... | |
Public Attributes | |
$currentNode | |
Reference to the current element. More... | |
$fosterParentMode = false | |
Foster parent mode determines how nodes are inserted into the stack. More... | |
$tidyCompat = false | |
Tidy compatibility mode, determines behavior of body/blockquote. More... | |
Private Member Functions | |
fosterParent ($elt) | |
Foster parent the given $elt in the stack of open elements. More... | |
Private Attributes | |
$elements = [] | |
Backing storage for the stack. More... | |
The "stack of open elements" as defined in the HTML5 tree builder spec.
This contains methods to ensure that content (start tags, text) are inserted at the correct place in the output string, and to flatten BalanceElements are they are closed to avoid holding onto a complete DOM tree for the document in memory.
The stack defines a PHP iterator to traverse it in "reverse order", that is, the most-recently-added element is visited first in a foreach loop.
Definition at line 650 of file Balancer.php.
MediaWiki\Tidy\BalanceStack::__construct | ( | ) |
Create a new BalanceStack with a single BalanceElement on it, representing the root <html> node.
Definition at line 676 of file Balancer.php.
References MediaWiki\Tidy\BalanceSets\HTML_NAMESPACE.
MediaWiki\Tidy\BalanceStack::__toString | ( | ) |
Return the contents of the open elements stack as a string for debugging.
Definition at line 1358 of file Balancer.php.
References as.
MediaWiki\Tidy\BalanceStack::adjustedCurrentNode | ( | $fragmentContext | ) |
Return the adjusted current node.
Definition at line 894 of file Balancer.php.
References MediaWiki\Tidy\BalanceStack\$currentNode.
MediaWiki\Tidy\BalanceStack::adoptionAgency | ( | $tag, | |
$afe | |||
) |
Run the "adoption agency algoritm" (AAA) for the given subject tag name.
string | $tag | The subject tag name. |
BalanceActiveFormattingElements | $afe | The current active formatting elements list. |
Definition at line 1141 of file Balancer.php.
References MediaWiki\Tidy\BalanceSets\$specialSet, MediaWiki\Tidy\BalanceSets\$tableSectionRowSet, $tag, MediaWiki\Tidy\BalanceStack\fosterParent(), MediaWiki\Tidy\BalanceStack\indexOf(), MediaWiki\Tidy\BalanceStack\inScope(), MediaWiki\Tidy\BalanceStack\insertAfter(), MediaWiki\Tidy\BalanceStack\length(), MediaWiki\Tidy\BalanceStack\node(), MediaWiki\Tidy\BalanceStack\pop(), MediaWiki\Tidy\BalanceStack\popTag(), MediaWiki\Tidy\BalanceStack\removeElement(), and MediaWiki\Tidy\BalanceStack\replaceAt().
MediaWiki\Tidy\BalanceStack::clearToContext | ( | $set | ) |
Pop elements off the stack not including the first element in the specified set.
BalanceElement | array | string | $set |
Definition at line 1010 of file Balancer.php.
References MediaWiki\Tidy\BalanceStack\pop().
|
private |
Foster parent the given $elt in the stack of open elements.
BalanceElement | string | $elt |
Definition at line 1079 of file Balancer.php.
References MediaWiki\Tidy\BalanceSets\$tidyPWrapSet, MediaWiki\Tidy\BalanceStack\indexOf(), MediaWiki\Tidy\BalanceStack\insertHTMLElement(), MediaWiki\Tidy\BalanceStack\insertText(), and MediaWiki\Tidy\BalanceElement\isHtmlNamed().
Referenced by MediaWiki\Tidy\BalanceStack\adoptionAgency(), MediaWiki\Tidy\BalanceStack\insertElement(), and MediaWiki\Tidy\BalanceStack\insertText().
MediaWiki\Tidy\BalanceStack::generateImpliedEndTags | ( | $butnot = null , |
|
$thorough = false |
|||
) |
Generate implied end tags.
string | $butnot | |
bool | $thorough | True if we should generate end tags thoroughly. |
Definition at line 876 of file Balancer.php.
References MediaWiki\Tidy\BalanceSets\$impliedEndTagsSet, MediaWiki\Tidy\BalanceSets\$thoroughImpliedEndTagsSet, and MediaWiki\Tidy\BalanceStack\pop().
MediaWiki\Tidy\BalanceStack::getIterator | ( | ) |
Return an iterator over this stack which visits the current node first, and the root node last.
Definition at line 904 of file Balancer.php.
MediaWiki\Tidy\BalanceStack::getOutput | ( | ) |
Return a string representing the output of the tree builder: all the children of the root <html> node.
Definition at line 690 of file Balancer.php.
MediaWiki\Tidy\BalanceStack::inButtonScope | ( | $tag | ) |
Determine if the stack has $tag in button scope.
BalanceElement | array | string | $tag |
Definition at line 807 of file Balancer.php.
References $tag, MediaWiki\Tidy\BalanceSets\inButtonScopeSet(), and MediaWiki\Tidy\BalanceStack\inSpecificScope().
MediaWiki\Tidy\BalanceStack::indexOf | ( | $tag | ) |
Return the position of the given BalanceElement, set, or HTML tag name string in the BalanceStack.
BalanceElement | array | string | $tag |
Definition at line 944 of file Balancer.php.
References $tag.
Referenced by MediaWiki\Tidy\BalanceStack\adoptionAgency(), MediaWiki\Tidy\BalanceStack\fosterParent(), and MediaWiki\Tidy\BalanceStack\insertAfter().
MediaWiki\Tidy\BalanceStack::inListItemScope | ( | $tag | ) |
Determine if the stack has $tag in list item scope.
BalanceElement | array | string | $tag |
Definition at line 817 of file Balancer.php.
References $tag, MediaWiki\Tidy\BalanceSets\inListItemScopeSet(), and MediaWiki\Tidy\BalanceStack\inSpecificScope().
MediaWiki\Tidy\BalanceStack::inScope | ( | $tag | ) |
Determine if the stack has $tag in scope.
BalanceElement | array | string | $tag |
Definition at line 797 of file Balancer.php.
References MediaWiki\Tidy\BalanceSets\$inScopeSet, $tag, and MediaWiki\Tidy\BalanceStack\inSpecificScope().
Referenced by MediaWiki\Tidy\BalanceStack\adoptionAgency().
MediaWiki\Tidy\BalanceStack::inSelectScope | ( | $tag | ) |
Determine if the stack has $tag in select scope.
BalanceElement | array | string | $tag |
Definition at line 837 of file Balancer.php.
References MediaWiki\Tidy\BalanceSets\$inInvertedSelectScopeSet, $tag, and as.
MediaWiki\Tidy\BalanceStack::insertAfter | ( | BalanceElement | $a, |
BalanceElement | $b | ||
) |
Find $a in the BalanceStack and insert $b after it.
BalanceElement | $a | |
BalanceElement | $b |
Definition at line 1061 of file Balancer.php.
References MediaWiki\Tidy\BalanceStack\indexOf().
Referenced by MediaWiki\Tidy\BalanceStack\adoptionAgency().
MediaWiki\Tidy\BalanceStack::insertComment | ( | $value | ) |
Insert a comment at the appropriate place for inserting a node.
string | $value | Content of the comment. |
Definition at line 705 of file Balancer.php.
References $value, and MediaWiki\Tidy\BalanceStack\insertText().
MediaWiki\Tidy\BalanceStack::insertElement | ( | BalanceElement | $elt | ) |
Insert an element at the appropriate place and push it on to the open elements stack.
BalanceElement | $elt |
Definition at line 768 of file Balancer.php.
References MediaWiki\Tidy\BalanceSets\$tableSectionRowSet, MediaWiki\Tidy\BalanceSets\$tidyInlineSet, MediaWiki\Tidy\BalanceStack\fosterParent(), MediaWiki\Tidy\BalanceElement\isA(), and MediaWiki\Tidy\BalanceStack\pop().
Referenced by MediaWiki\Tidy\BalanceStack\insertForeignElement().
MediaWiki\Tidy\BalanceStack::insertForeignElement | ( | $namespaceURI, | |
$tag, | |||
$attribs | |||
) |
Insert a BalanceElement at the appropriate place, pushing it on to the open elements stack.
string | $namespaceURI | The element namespace |
string | $tag | The tag name |
string | $attribs | Normalized attributes, as a string. |
Definition at line 741 of file Balancer.php.
References $attribs, $tag, and MediaWiki\Tidy\BalanceStack\insertElement().
Referenced by MediaWiki\Tidy\BalanceStack\insertHTMLElement().
MediaWiki\Tidy\BalanceStack::insertHTMLElement | ( | $tag, | |
$attribs | |||
) |
Insert an HTML element at the appropriate place, pushing it on to the open elements stack.
string | $tag | The tag name |
string | $attribs | Normalized attributes, as a string. |
Definition at line 755 of file Balancer.php.
References $attribs, $tag, MediaWiki\Tidy\BalanceSets\HTML_NAMESPACE, and MediaWiki\Tidy\BalanceStack\insertForeignElement().
Referenced by MediaWiki\Tidy\BalanceStack\fosterParent().
MediaWiki\Tidy\BalanceStack::insertText | ( | $value, | |
$isComment = false |
|||
) |
Insert text at the appropriate place for inserting a node.
string | $value |
Definition at line 715 of file Balancer.php.
References MediaWiki\Tidy\BalanceSets\$tableSectionRowSet, MediaWiki\Tidy\BalanceSets\$tidyPWrapSet, $value, and MediaWiki\Tidy\BalanceStack\fosterParent().
Referenced by MediaWiki\Tidy\BalanceStack\fosterParent(), and MediaWiki\Tidy\BalanceStack\insertComment().
MediaWiki\Tidy\BalanceStack::inSpecificScope | ( | $tag, | |
$set | |||
) |
Determine if the stack has $tag in a specific scope, $set.
BalanceElement | array | string | $tag | |
BalanceElement | array | string | $set |
Definition at line 858 of file Balancer.php.
Referenced by MediaWiki\Tidy\BalanceStack\inButtonScope(), MediaWiki\Tidy\BalanceStack\inListItemScope(), MediaWiki\Tidy\BalanceStack\inScope(), and MediaWiki\Tidy\BalanceStack\inTableScope().
MediaWiki\Tidy\BalanceStack::inTableScope | ( | $tag | ) |
Determine if the stack has $tag in table scope.
BalanceElement | array | string | $tag |
Definition at line 827 of file Balancer.php.
References MediaWiki\Tidy\BalanceSets\$inTableScopeSet, $tag, and MediaWiki\Tidy\BalanceStack\inSpecificScope().
MediaWiki\Tidy\BalanceStack::length | ( | ) |
Return the number of elements currently in the BalanceStack.
Definition at line 957 of file Balancer.php.
Referenced by MediaWiki\Tidy\BalanceStack\adoptionAgency().
MediaWiki\Tidy\BalanceStack::node | ( | $idx | ) |
Return the BalanceElement at the given position $idx, where position 0 represents the root element.
int | $idx |
Definition at line 914 of file Balancer.php.
Referenced by MediaWiki\Tidy\BalanceStack\adoptionAgency().
MediaWiki\Tidy\BalanceStack::pop | ( | ) |
Remove the current node from the BalanceStack, flattening it in the process.
Definition at line 965 of file Balancer.php.
Referenced by MediaWiki\Tidy\BalanceStack\adoptionAgency(), MediaWiki\Tidy\BalanceStack\clearToContext(), MediaWiki\Tidy\BalanceStack\generateImpliedEndTags(), MediaWiki\Tidy\BalanceStack\insertElement(), MediaWiki\Tidy\BalanceStack\popTag(), and MediaWiki\Tidy\BalanceStack\popTo().
MediaWiki\Tidy\BalanceStack::popTag | ( | $tag | ) |
Pop elements off the stack up to and including the first element with the specified HTML tagname (or matching the given set).
BalanceElement | array | string | $tag |
Definition at line 995 of file Balancer.php.
References $tag, and MediaWiki\Tidy\BalanceStack\pop().
Referenced by MediaWiki\Tidy\BalanceStack\adoptionAgency().
MediaWiki\Tidy\BalanceStack::popTo | ( | $idx | ) |
Remove all nodes up to and including position $idx from the BalanceStack, flattening them in the process.
int | $idx |
Definition at line 982 of file Balancer.php.
References MediaWiki\Tidy\BalanceStack\pop().
MediaWiki\Tidy\BalanceStack::removeElement | ( | BalanceElement | $elt, |
$flatten = true |
|||
) |
Remove the given $elt from the BalanceStack, optionally flattening it in the process.
BalanceElement | $elt | The element to remove. |
bool | $flatten | Whether to flatten the removed element. |
Definition at line 1026 of file Balancer.php.
References MediaWiki\Tidy\BalanceElement\flatten().
Referenced by MediaWiki\Tidy\BalanceStack\adoptionAgency().
MediaWiki\Tidy\BalanceStack::replaceAt | ( | $idx, | |
BalanceElement | $elt | ||
) |
Replace the element at position $idx in the BalanceStack with $elt.
int | $idx | |
BalanceElement | $elt |
Definition at line 923 of file Balancer.php.
Referenced by MediaWiki\Tidy\BalanceStack\adoptionAgency().
MediaWiki\Tidy\BalanceStack::$currentNode |
Reference to the current element.
Definition at line 670 of file Balancer.php.
Referenced by MediaWiki\Tidy\BalanceStack\adjustedCurrentNode().
|
private |
Backing storage for the stack.
Definition at line 655 of file Balancer.php.
bool MediaWiki\Tidy\BalanceStack::$fosterParentMode = false |
Foster parent mode determines how nodes are inserted into the stack.
Definition at line 662 of file Balancer.php.
MediaWiki\Tidy\BalanceStack::$tidyCompat = false |
Tidy compatibility mode, determines behavior of body/blockquote.
Definition at line 666 of file Balancer.php.