MediaWiki REL1_31
MediaWiki\Tidy\BalanceActiveFormattingElements Class Reference

The list of active formatting elements, which is used to handle mis-nested formatting element tags in the HTML5 tree builder specification. More...

Public Member Functions

 __destruct ()
 
 __toString ()
 Get a string representation of the AFE list, for debugging.
 
 clearToMarker ()
 Follow the steps required when the spec asks us to "clear the list of active formatting elements up to the last marker".
 
 findElementByTag ( $tag)
 Find and return the last element with the specified tag between the end of the list and the last marker on the list.
 
 insertAfter (BalanceElement $a, BalanceElement $b)
 Find $a in the list and insert $b after it.
 
 insertMarker ()
 
 isInList (BalanceElement $elt)
 Determine whether an element is in the list of formatting elements.
 
 push (BalanceElement $elt)
 Follow the steps required when the spec requires us to "push onto the list of active formatting elements".
 
 reconstruct ( $stack)
 Reconstruct the active formatting elements.
 
 remove (BalanceElement $elt)
 Find the element $elt in the list and remove it.
 
 replace (BalanceElement $a, BalanceElement $b)
 Find element $a in the list and replace it with element $b.
 

Private Member Functions

 addToNoahList (BalanceElement $elt)
 
 removeFromNoahList (BalanceElement $elt)
 

Private Attributes

 $head
 The first (least recent) element in the list.
 
 $noahTableStack = [ [] ]
 An array of arrays representing the population of elements in each bucket according to the Noah's Ark clause.
 
 $tail
 The last (most recent) element in the list.
 

Detailed Description

The list of active formatting elements, which is used to handle mis-nested formatting element tags in the HTML5 tree builder specification.

Since
1.27
See also
https://html.spec.whatwg.org/multipage/syntax.html#list-of-active-formatting-elements

Definition at line 1396 of file Balancer.php.

Constructor & Destructor Documentation

◆ __destruct()

MediaWiki\Tidy\BalanceActiveFormattingElements::__destruct ( )

Definition at line 1423 of file Balancer.php.

Member Function Documentation

◆ __toString()

MediaWiki\Tidy\BalanceActiveFormattingElements::__toString ( )

Get a string representation of the AFE list, for debugging.

Definition at line 1727 of file Balancer.php.

References $s.

◆ addToNoahList()

MediaWiki\Tidy\BalanceActiveFormattingElements::addToNoahList ( BalanceElement $elt)
private

◆ clearToMarker()

MediaWiki\Tidy\BalanceActiveFormattingElements::clearToMarker ( )

Follow the steps required when the spec asks us to "clear the list of active formatting elements up to the last marker".

Definition at line 1489 of file Balancer.php.

References MediaWiki\Tidy\BalanceActiveFormattingElements\$tail.

◆ findElementByTag()

MediaWiki\Tidy\BalanceActiveFormattingElements::findElementByTag ( $tag)

Find and return the last element with the specified tag between the end of the list and the last marker on the list.

Used when parsing <a> "in body mode".

Parameters
string$tag
Returns
null|Node

Definition at line 1528 of file Balancer.php.

References MediaWiki\Tidy\BalanceActiveFormattingElements\$tail.

◆ insertAfter()

MediaWiki\Tidy\BalanceActiveFormattingElements::insertAfter ( BalanceElement $a,
BalanceElement $b )

Find $a in the list and insert $b after it.

Parameters
BalanceElement$a
BalanceElement$b

Definition at line 1659 of file Balancer.php.

References MediaWiki\Tidy\BalanceActiveFormattingElements\addToNoahList().

◆ insertMarker()

MediaWiki\Tidy\BalanceActiveFormattingElements::insertMarker ( )

◆ isInList()

MediaWiki\Tidy\BalanceActiveFormattingElements::isInList ( BalanceElement $elt)

Determine whether an element is in the list of formatting elements.

Parameters
BalanceElement$elt
Returns
bool

Definition at line 1544 of file Balancer.php.

◆ push()

MediaWiki\Tidy\BalanceActiveFormattingElements::push ( BalanceElement $elt)

Follow the steps required when the spec requires us to "push onto the list of active formatting elements".

Parameters
BalanceElement$elt

Definition at line 1449 of file Balancer.php.

References MediaWiki\Tidy\BalanceActiveFormattingElements\$head, and MediaWiki\Tidy\BalanceActiveFormattingElements\$tail.

◆ reconstruct()

MediaWiki\Tidy\BalanceActiveFormattingElements::reconstruct ( $stack)

Reconstruct the active formatting elements.

Parameters
BalanceStack$stackThe open elements stack
See also
https://html.spec.whatwg.org/multipage/syntax.html#reconstruct-the-active-formatting-elements

Definition at line 1681 of file Balancer.php.

References MediaWiki\Tidy\BalanceActiveFormattingElements\$tail, and replace.

◆ remove()

MediaWiki\Tidy\BalanceActiveFormattingElements::remove ( BalanceElement $elt)

Find the element $elt in the list and remove it.

Used when parsing <a> in body mode.

Parameters
BalanceElement$elt

Definition at line 1554 of file Balancer.php.

References MediaWiki\Tidy\BalanceActiveFormattingElements\removeFromNoahList().

◆ removeFromNoahList()

MediaWiki\Tidy\BalanceActiveFormattingElements::removeFromNoahList ( BalanceElement $elt)
private

◆ replace()

MediaWiki\Tidy\BalanceActiveFormattingElements::replace ( BalanceElement $a,
BalanceElement $b )

Find element $a in the list and replace it with element $b.

Parameters
BalanceElement$a
BalanceElement$b

Definition at line 1625 of file Balancer.php.

References MediaWiki\Tidy\BalanceActiveFormattingElements\addToNoahList(), and MediaWiki\Tidy\BalanceActiveFormattingElements\removeFromNoahList().

Member Data Documentation

◆ $head

MediaWiki\Tidy\BalanceActiveFormattingElements::$head
private

The first (least recent) element in the list.

Definition at line 1401 of file Balancer.php.

Referenced by MediaWiki\Tidy\BalanceActiveFormattingElements\push().

◆ $noahTableStack

MediaWiki\Tidy\BalanceActiveFormattingElements::$noahTableStack = [ [] ]
private

An array of arrays representing the population of elements in each bucket according to the Noah's Ark clause.

The outer array is stack-like, with each integer-indexed element representing a segment of the list, bounded by markers. The first element represents the segment of the list before the first marker.

The inner arrays are indexed by "Noah key", which is a string which uniquely identifies each bucket according to the rules in the spec. The value in the inner array is the first (least recently inserted) element in the bucket, and subsequent members of the bucket can be found by iterating through the singly-linked list via $node->nextNoah.

This is optimised for the most common case of inserting into a bucket with zero members, and deleting a bucket containing one member. In the worst case, iteration through the list is still O(1) in the document size, since each bucket can have at most 3 members.

Definition at line 1421 of file Balancer.php.

◆ $tail


The documentation for this class was generated from the following file: