From: Tim Starling Date: Mon, 1 Aug 2016 01:51:46 +0000 (+1000) Subject: Balancer: consistent single-line comment style X-Git-Tag: 1.31.0-rc.0~6137^2~3 X-Git-Url: http://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=77eceb1a9bb8e9afb7a7403972075945dda4b110 Balancer: consistent single-line comment style Also break a line that was over 100 bytes Change-Id: I875d572d4147f2438526a49ca6cb5b73907bdc9b --- diff --git a/includes/tidy/Balancer.php b/includes/tidy/Balancer.php index b2d6ba1bcf..20f8f55a58 100644 --- a/includes/tidy/Balancer.php +++ b/includes/tidy/Balancer.php @@ -32,31 +32,31 @@ use \IteratorAggregate; use \ReverseArrayIterator; use \Sanitizer; -# A note for future librarization[1] -- this file is a good candidate -# for splitting into an independent library, except that it is currently -# highly optimized for MediaWiki use. It only implements the portions -# of the HTML5 tree builder used by tags supported by MediaWiki, and -# does not contain a true tokenizer pass, instead relying on -# comment stripping, attribute normalization, and escaping done by -# the MediaWiki Sanitizer. It also deliberately avoids building -# a true DOM in memory, instead serializing elements to an output string -# as soon as possible (usually as soon as the tag is closed) to reduce -# its memory footprint. - -# We've been gradually lifting some of these restrictions to handle -# non-sanitized output generated by extensions, but we shortcut the tokenizer -# for speed (primarily by splitting on `<`) and so rely on syntactic -# well-formedness. - -# On the other hand, I've been pretty careful to note with comments in the -# code the places where this implementation omits features of the spec or -# depends on the MediaWiki Sanitizer. Perhaps in the future we'll want to -# implement the missing pieces and make this a standalone PHP HTML5 parser. -# In order to do so, some sort of MediaWiki-specific API will need -# to be added to (a) allow the Balancer to bypass the tokenizer, -# and (b) support on-the-fly flattening instead of DOM node creation. - -# [1]: https://www.mediawiki.org/wiki/Library_infrastructure_for_MediaWiki +// A note for future librarization[1] -- this file is a good candidate +// for splitting into an independent library, except that it is currently +// highly optimized for MediaWiki use. It only implements the portions +// of the HTML5 tree builder used by tags supported by MediaWiki, and +// does not contain a true tokenizer pass, instead relying on +// comment stripping, attribute normalization, and escaping done by +// the MediaWiki Sanitizer. It also deliberately avoids building +// a true DOM in memory, instead serializing elements to an output string +// as soon as possible (usually as soon as the tag is closed) to reduce +// its memory footprint. + +// We've been gradually lifting some of these restrictions to handle +// non-sanitized output generated by extensions, but we shortcut the tokenizer +// for speed (primarily by splitting on `<`) and so rely on syntactic +// well-formedness. + +// On the other hand, I've been pretty careful to note with comments in the +// code the places where this implementation omits features of the spec or +// depends on the MediaWiki Sanitizer. Perhaps in the future we'll want to +// implement the missing pieces and make this a standalone PHP HTML5 parser. +// In order to do so, some sort of MediaWiki-specific API will need +// to be added to (a) allow the Balancer to bypass the tokenizer, +// and (b) support on-the-fly flattening instead of DOM node creation. + +// [1]: https://www.mediawiki.org/wiki/Library_infrastructure_for_MediaWiki /** * Utility constants and sets for the HTML5 tree building algorithm. @@ -500,7 +500,7 @@ class BalanceElement { $flat = "{$this}"; } $this->parent->children[$idx] = $flat; - $this->parent = 'flat'; # for assertion checking + $this->parent = 'flat'; // for assertion checking return $flat; } @@ -544,7 +544,7 @@ class BalanceElement { return $out; } - # Utility functions on BalanceElements. + // Utility functions on BalanceElements. /** * Determine if $this represents a specific HTML tag, is a member of @@ -561,7 +561,7 @@ class BalanceElement { return isset( $set[$this->namespaceURI] ) && isset( $set[$this->namespaceURI][$this->localName] ); } else { - # assume this is an HTML element name. + // assume this is an HTML element name. return $this->isHtml() && $this->localName === $set; } } @@ -674,7 +674,7 @@ class BalanceStack implements IteratorAggregate { * representing the root <html> node. */ public function __construct() { - # always a root element on the stack + // always a root element on the stack array_push( $this->elements, new BalanceElement( BalanceSets::HTML_NAMESPACE, 'html', [] ) @@ -1069,7 +1069,7 @@ class BalanceStack implements IteratorAggregate { } } - # Fostering and adoption. + // Fostering and adoption. /** * Foster parent the given $elt in the stack of open elements. @@ -1086,7 +1086,7 @@ class BalanceStack implements IteratorAggregate { $parent = $this->elements[$lastTemplate]; } elseif ( $lastTable >= 0 ) { $parent = $this->elements[$lastTable]->parent; - # Assume all tables have parents, since we're not running scripts! + // Assume all tables have parents, since we're not running scripts! Assert::invariant( $parent !== null, "All tables should have parents" ); @@ -1771,7 +1771,7 @@ class BalanceActiveFormattingElements { *