X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Ftidy%2FBalancer.php;h=e57063377877d221c107f0a067c3705ec9d1e497;hp=947a57248092f486e7bee99b82648d1d85fdcdef;hb=08edb27f6ce31c676660a4ef89b87da79bde2cc2;hpb=5256bb8ce2da1390f84ef535d990129eebd74fd2 diff --git a/includes/tidy/Balancer.php b/includes/tidy/Balancer.php index 947a572480..e570633778 100644 --- a/includes/tidy/Balancer.php +++ b/includes/tidy/Balancer.php @@ -627,6 +627,7 @@ class BalanceElement { /** * Get a string key for the Noah's Ark algorithm + * @return string */ public function getNoahKey() { if ( $this->noahKey === null ) { @@ -710,6 +711,7 @@ class BalanceStack implements IteratorAggregate { /** * Insert a comment at the appropriate place for inserting a node. * @param string $value Content of the comment. + * @return string * @see https://html.spec.whatwg.org/multipage/syntax.html#insert-a-comment */ public function insertComment( $value ) { @@ -721,6 +723,7 @@ class BalanceStack implements IteratorAggregate { * Insert text at the appropriate place for inserting a node. * @param string $value * @param bool $isComment + * @return string * @see https://html.spec.whatwg.org/multipage/syntax.html#appropriate-place-for-inserting-a-node */ public function insertText( $value, $isComment = false ) { @@ -901,6 +904,8 @@ class BalanceStack implements IteratorAggregate { /** * Return the adjusted current node. + * @param string $fragmentContext + * @return string */ public function adjustedCurrentNode( $fragmentContext ) { return ( $fragmentContext && count( $this->elements ) === 1 ) ? @@ -1513,6 +1518,8 @@ class BalanceActiveFormattingElements { * 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". + * @param string $tag + * @return null|Node */ public function findElementByTag( $tag ) { $elt = $this->tail; @@ -1662,13 +1669,11 @@ class BalanceActiveFormattingElements { $this->addToNoahList( $b ); } - // @codingStandardsIgnoreStart Generic.Files.LineLength.TooLong /** * Reconstruct the active formatting elements. * @param BalanceStack $stack The open elements stack * @see https://html.spec.whatwg.org/multipage/syntax.html#reconstruct-the-active-formatting-elements */ - // @codingStandardsIgnoreEnd public function reconstruct( $stack ) { $entry = $this->tail; // If there are no entries in the list of active formatting elements, @@ -2047,73 +2052,73 @@ class Balancer { return true; } elseif ( $token === 'tag' ) { switch ( $value ) { - case 'font': - if ( isset( $attribs['color'] ) - || isset( $attribs['face'] ) - || isset( $attribs['size'] ) - ) { - break; - } - // otherwise, fall through - case 'b': - case 'big': - case 'blockquote': - case 'body': - case 'br': - case 'center': - case 'code': - case 'dd': - case 'div': - case 'dl': - case 'dt': - case 'em': - case 'embed': - case 'h1': - case 'h2': - case 'h3': - case 'h4': - case 'h5': - case 'h6': - case 'head': - case 'hr': - case 'i': - case 'img': - case 'li': - case 'listing': - case 'menu': - case 'meta': - case 'nobr': - case 'ol': - case 'p': - case 'pre': - case 'ruby': - case 's': - case 'small': - case 'span': - case 'strong': - case 'strike': - case 'sub': - case 'sup': - case 'table': - case 'tt': - case 'u': - case 'ul': - case 'var': - if ( $this->fragmentContext ) { - break; - } - while ( true ) { - $this->stack->pop(); - $node = $this->stack->currentNode; - if ( - $node->isMathmlTextIntegrationPoint() || - $node->isHtmlIntegrationPoint() || - $node->isHtml() + case 'font': + if ( isset( $attribs['color'] ) + || isset( $attribs['face'] ) + || isset( $attribs['size'] ) ) { break; } - } - return $this->insertToken( $token, $value, $attribs, $selfClose ); + // otherwise, fall through + case 'b': + case 'big': + case 'blockquote': + case 'body': + case 'br': + case 'center': + case 'code': + case 'dd': + case 'div': + case 'dl': + case 'dt': + case 'em': + case 'embed': + case 'h1': + case 'h2': + case 'h3': + case 'h4': + case 'h5': + case 'h6': + case 'head': + case 'hr': + case 'i': + case 'img': + case 'li': + case 'listing': + case 'menu': + case 'meta': + case 'nobr': + case 'ol': + case 'p': + case 'pre': + case 'ruby': + case 's': + case 'small': + case 'span': + case 'strong': + case 'strike': + case 'sub': + case 'sup': + case 'table': + case 'tt': + case 'u': + case 'ul': + case 'var': + if ( $this->fragmentContext ) { + break; + } + while ( true ) { + $this->stack->pop(); + $node = $this->stack->currentNode; + if ( + $node->isMathmlTextIntegrationPoint() || + $node->isHtmlIntegrationPoint() || + $node->isHtml() + ) { + break; + } + } + return $this->insertToken( $token, $value, $attribs, $selfClose ); } // "Any other start tag" $adjusted = ( $this->fragmentContext && $this->stack->length() === 1 ) ? @@ -2265,56 +2270,56 @@ class Balancer { } if ( $node->isHtml() ) { switch ( $node->localName ) { - case 'select': - $stackLength = $this->stack->length(); - for ( $j = $i + 1; $j < $stackLength - 1; $j++ ) { - $ancestor = $this->stack->node( $stackLength - $j - 1 ); - if ( $ancestor->isHtmlNamed( 'template' ) ) { - break; + case 'select': + $stackLength = $this->stack->length(); + for ( $j = $i + 1; $j < $stackLength - 1; $j++ ) { + $ancestor = $this->stack->node( $stackLength - $j - 1 ); + if ( $ancestor->isHtmlNamed( 'template' ) ) { + break; + } + if ( $ancestor->isHtmlNamed( 'table' ) ) { + $this->switchMode( 'inSelectInTableMode' ); + return; + } } - if ( $ancestor->isHtmlNamed( 'table' ) ) { - $this->switchMode( 'inSelectInTableMode' ); - return; - } - } - $this->switchMode( 'inSelectMode' ); - return; - case 'tr': - $this->switchMode( 'inRowMode' ); - return; - case 'tbody': - case 'tfoot': - case 'thead': - $this->switchMode( 'inTableBodyMode' ); - return; - case 'caption': - $this->switchMode( 'inCaptionMode' ); - return; - case 'colgroup': - $this->switchMode( 'inColumnGroupMode' ); - return; - case 'table': - $this->switchMode( 'inTableMode' ); - return; - case 'template': - $this->switchMode( - array_slice( $this->templateInsertionModes, -1 )[0] - ); - return; - case 'body': - $this->switchMode( 'inBodyMode' ); - return; - // OMITTED: