MediaWiki REL1_30
|
The "stack of open elements" as defined in the HTML5 tree builder spec. More...
Public Member Functions | |
__construct (array $config) | |
Create a new BalanceStack with a single BalanceElement on it, representing the root <html> node. | |
__toString () | |
Return the contents of the open elements stack as a string for debugging. | |
adjustedCurrentNode ( $fragmentContext) | |
Return the adjusted current node. | |
adoptionAgency ( $tag, $afe) | |
Run the "adoption agency algoritm" (AAA) for the given subject tag name. | |
clearToContext ( $set) | |
Pop elements off the stack not including the first element in the specified set. | |
generateImpliedEndTags ( $butnot=null, $thorough=false) | |
Generate implied end tags. | |
getIterator () | |
Return an iterator over this stack which visits the current node first, and the root node last. | |
getOutput () | |
Return a string representing the output of the tree builder: all the children of the root <html> node. | |
inButtonScope ( $tag) | |
Determine if the stack has $tag in button scope. | |
indexOf ( $tag) | |
Return the position of the given BalanceElement, set, or HTML tag name string in the BalanceStack. | |
inListItemScope ( $tag) | |
Determine if the stack has $tag in list item scope. | |
inScope ( $tag) | |
Determine if the stack has $tag in scope. | |
inSelectScope ( $tag) | |
Determine if the stack has $tag in select scope. | |
insertAfter (BalanceElement $a, BalanceElement $b) | |
Find $a in the BalanceStack and insert $b after it. | |
insertComment ( $value) | |
Insert a comment at the appropriate place for inserting a node. | |
insertElement (BalanceElement $elt) | |
Insert an element at the appropriate place and push it on to the open elements stack. | |
insertForeignElement ( $namespaceURI, $tag, $attribs) | |
Insert a BalanceElement at the appropriate place, pushing it on to the open elements stack. | |
insertHTMLElement ( $tag, $attribs) | |
Insert an HTML element at the appropriate place, pushing it on to the open elements stack. | |
insertText ( $value, $isComment=false) | |
Insert text at the appropriate place for inserting a node. | |
inSpecificScope ( $tag, $set) | |
Determine if the stack has $tag in a specific scope, $set. | |
inTableScope ( $tag) | |
Determine if the stack has $tag in table scope. | |
length () | |
Return the number of elements currently in the BalanceStack. | |
node ( $idx) | |
Return the BalanceElement at the given position $idx, where position 0 represents the root element. | |
pop () | |
Remove the current node from the BalanceStack, flattening it in the process. | |
popTag ( $tag) | |
Pop elements off the stack up to and including the first element with the specified HTML tagname (or matching the given set). | |
popTo ( $idx) | |
Remove all nodes up to and including position $idx from the BalanceStack, flattening them in the process. | |
removeElement (BalanceElement $elt, $flatten=true) | |
Remove the given $elt from the BalanceStack, optionally flattening it in the process. | |
replaceAt ( $idx, BalanceElement $elt) | |
Replace the element at position $idx in the BalanceStack with $elt. | |
Public Attributes | |
$currentNode | |
Reference to the current element. | |
$fosterParentMode = false | |
Foster parent mode determines how nodes are inserted into the stack. | |
Private Member Functions | |
fosterParent ( $elt) | |
Foster parent the given $elt in the stack of open elements. | |
Private Attributes | |
$config | |
Configuration options governing flattening. | |
$elements = [] | |
Backing storage for the stack. | |
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 657 of file Balancer.php.
MediaWiki\Tidy\BalanceStack::__construct | ( | array | $config | ) |
Create a new BalanceStack with a single BalanceElement on it, representing the root <html> node.
array | $config | Balancer configuration; see Balancer::_construct(). |
Definition at line 686 of file Balancer.php.
References MediaWiki\Tidy\BalanceStack\$config, and 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 1363 of file Balancer.php.
MediaWiki\Tidy\BalanceStack::adjustedCurrentNode | ( | $fragmentContext | ) |
Return the adjusted current node.
string | $fragmentContext |
Definition at line 910 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 1158 of file Balancer.php.
References MediaWiki\Tidy\BalanceSets\$specialSet, MediaWiki\Tidy\BalanceSets\$tableSectionRowSet, 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 1025 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 1096 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 890 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 920 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 701 of file Balancer.php.
References $out.
MediaWiki\Tidy\BalanceStack::inButtonScope | ( | $tag | ) |
Determine if the stack has $tag in button scope.
BalanceElement | array | string | $tag |
Definition at line 821 of file Balancer.php.
References 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 960 of file Balancer.php.
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 831 of file Balancer.php.
References 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 811 of file Balancer.php.
References MediaWiki\Tidy\BalanceSets\$inScopeSet, 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 851 of file Balancer.php.
References MediaWiki\Tidy\BalanceSets\$inInvertedSelectScopeSet.
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 1076 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 717 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 782 of file Balancer.php.
References MediaWiki\Tidy\BalanceSets\$tableSectionRowSet, MediaWiki\Tidy\BalanceSets\$tidyInlineSet, MediaWiki\Tidy\BalanceStack\fosterParent(), 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 755 of file Balancer.php.
References $attribs, 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 769 of file Balancer.php.
References $attribs, MediaWiki\Tidy\BalanceSets\HTML_NAMESPACE, and MediaWiki\Tidy\BalanceStack\insertForeignElement().
Referenced by MediaWiki\Tidy\BalanceStack\fosterParent(), and MediaWiki\Tidy\BalanceStack\insertText().
MediaWiki\Tidy\BalanceStack::insertText | ( | $value, | |
$isComment = false ) |
Insert text at the appropriate place for inserting a node.
string | $value | |
bool | $isComment |
Definition at line 729 of file Balancer.php.
References MediaWiki\Tidy\BalanceSets\$tableSectionRowSet, MediaWiki\Tidy\BalanceSets\$tidyPWrapSet, $value, MediaWiki\Tidy\BalanceStack\fosterParent(), MediaWiki\Tidy\BalanceStack\insertHTMLElement(), and MediaWiki\Tidy\BalanceStack\insertText().
Referenced by MediaWiki\Tidy\BalanceStack\fosterParent(), MediaWiki\Tidy\BalanceStack\insertComment(), and MediaWiki\Tidy\BalanceStack\insertText().
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 872 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 841 of file Balancer.php.
References MediaWiki\Tidy\BalanceSets\$inTableScopeSet, and MediaWiki\Tidy\BalanceStack\inSpecificScope().
MediaWiki\Tidy\BalanceStack::length | ( | ) |
Return the number of elements currently in the BalanceStack.
Definition at line 973 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 930 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 981 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 1010 of file Balancer.php.
References 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 998 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 1041 of file Balancer.php.
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 939 of file Balancer.php.
Referenced by MediaWiki\Tidy\BalanceStack\adoptionAgency().
|
private |
Configuration options governing flattening.
Definition at line 675 of file Balancer.php.
Referenced by MediaWiki\Tidy\BalanceStack\__construct().
MediaWiki\Tidy\BalanceStack::$currentNode |
Reference to the current element.
Definition at line 679 of file Balancer.php.
Referenced by MediaWiki\Tidy\BalanceStack\adjustedCurrentNode().
|
private |
Backing storage for the stack.
Definition at line 662 of file Balancer.php.
bool MediaWiki\Tidy\BalanceStack::$fosterParentMode = false |
Foster parent mode determines how nodes are inserted into the stack.
Definition at line 669 of file Balancer.php.