Complex classes like TemplateInspector often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use TemplateInspector, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
32 | class TemplateInspector |
||
33 | { |
||
34 | /** |
||
35 | * @var string allowChild bitfield (all branches) |
||
36 | */ |
||
37 | protected $allowChildBitfield = "\0"; |
||
38 | |||
39 | /** |
||
40 | * @var bool Whether elements are allowed as children |
||
41 | */ |
||
42 | protected $allowsChildElements = true; |
||
43 | |||
44 | /** |
||
45 | * @var bool Whether text nodes are allowed as children |
||
46 | */ |
||
47 | protected $allowsText = true; |
||
48 | |||
49 | /** |
||
50 | * @var string OR-ed bitfield representing all of the categories used by this template |
||
51 | */ |
||
52 | protected $contentBitfield = "\0"; |
||
53 | |||
54 | /** |
||
55 | * @var string denyDescendant bitfield |
||
56 | */ |
||
57 | protected $denyDescendantBitfield = "\0"; |
||
58 | |||
59 | /** |
||
60 | * @var DOMDocument Document containing the template |
||
61 | */ |
||
62 | protected $dom; |
||
63 | |||
64 | /** |
||
65 | * @var bool Whether this template contains any HTML elements |
||
66 | */ |
||
67 | protected $hasElements = false; |
||
68 | |||
69 | /** |
||
70 | * @var bool Whether this template renders non-whitespace text nodes at its root |
||
71 | */ |
||
72 | protected $hasRootText = false; |
||
73 | |||
74 | /** |
||
75 | * @var bool Whether this template should be considered a block-level element |
||
76 | */ |
||
77 | protected $isBlock = false; |
||
78 | |||
79 | /** |
||
80 | * @var bool Whether the template uses the "empty" content model |
||
81 | */ |
||
82 | protected $isEmpty = true; |
||
83 | |||
84 | /** |
||
85 | * @var bool Whether this template adds to the list of active formatting elements |
||
86 | */ |
||
87 | protected $isFormattingElement = false; |
||
88 | |||
89 | /** |
||
90 | * @var bool Whether this template lets content through via an xsl:apply-templates element |
||
91 | */ |
||
92 | protected $isPassthrough = false; |
||
93 | |||
94 | /** |
||
95 | * @var bool Whether all branches use the transparent content model |
||
96 | */ |
||
97 | protected $isTransparent = false; |
||
98 | |||
99 | /** |
||
100 | * @var bool Whether all branches have an ancestor that is a void element |
||
101 | */ |
||
102 | protected $isVoid = true; |
||
103 | |||
104 | /** |
||
105 | * @var array Names of every last HTML element that precedes an <xsl:apply-templates/> node |
||
106 | */ |
||
107 | protected $leafNodes = []; |
||
108 | |||
109 | /** |
||
110 | * @var bool Whether any branch has an element that preserves new lines by default (e.g. <pre>) |
||
111 | */ |
||
112 | protected $preservesNewLines = false; |
||
113 | |||
114 | /** |
||
115 | * @var array Bitfield of the first HTML element of every branch |
||
116 | */ |
||
117 | protected $rootBitfields = []; |
||
118 | |||
119 | /** |
||
120 | * @var array Names of every HTML element that have no HTML parent |
||
121 | */ |
||
122 | protected $rootNodes = []; |
||
123 | |||
124 | /** |
||
125 | * @var DOMXPath XPath engine associated with $this->dom |
||
126 | */ |
||
127 | protected $xpath; |
||
128 | |||
129 | /** |
||
130 | * Constructor |
||
131 | * |
||
132 | * @param string $template Template content |
||
133 | */ |
||
134 | public function __construct($template) |
||
143 | |||
144 | /** |
||
145 | * Return whether this template allows a given child |
||
146 | * |
||
147 | * @param self $child |
||
148 | * @return bool |
||
149 | */ |
||
150 | public function allowsChild(self $child) |
||
173 | |||
174 | /** |
||
175 | * Return whether this template allows a given descendant |
||
176 | * |
||
177 | * @param self $descendant |
||
178 | * @return bool |
||
179 | */ |
||
180 | public function allowsDescendant(self $descendant) |
||
196 | |||
197 | /** |
||
198 | * Return whether this template allows elements as children |
||
199 | * |
||
200 | * @return bool |
||
201 | */ |
||
202 | public function allowsChildElements() |
||
206 | |||
207 | /** |
||
208 | * Return whether this template allows text nodes as children |
||
209 | * |
||
210 | * @return bool |
||
211 | */ |
||
212 | public function allowsText() |
||
216 | |||
217 | /** |
||
218 | * Return whether this template automatically closes given parent template |
||
219 | * |
||
220 | * @param self $parent |
||
221 | * @return bool |
||
222 | */ |
||
223 | public function closesParent(self $parent) |
||
245 | |||
246 | /** |
||
247 | * Return the source template as a DOMDocument |
||
248 | * |
||
249 | * NOTE: the document should not be modified |
||
250 | * |
||
251 | * @return DOMDocument |
||
252 | */ |
||
253 | public function getDOM() |
||
257 | |||
258 | /** |
||
259 | * Return whether this template should be considered a block-level element |
||
260 | * |
||
261 | * @return bool |
||
262 | */ |
||
263 | public function isBlock() |
||
267 | |||
268 | /** |
||
269 | * Return whether this template adds to the list of active formatting elements |
||
270 | * |
||
271 | * @return bool |
||
272 | */ |
||
273 | public function isFormattingElement() |
||
277 | |||
278 | /** |
||
279 | * Return whether this template uses the "empty" content model |
||
280 | * |
||
281 | * @return bool |
||
282 | */ |
||
283 | public function isEmpty() |
||
287 | |||
288 | /** |
||
289 | * Return whether this template lets content through via an xsl:apply-templates element |
||
290 | * |
||
291 | * @return bool |
||
292 | */ |
||
293 | public function isPassthrough() |
||
297 | |||
298 | /** |
||
299 | * Return whether this template uses the "transparent" content model |
||
300 | * |
||
301 | * @return bool |
||
302 | */ |
||
303 | public function isTransparent() |
||
307 | |||
308 | /** |
||
309 | * Return whether all branches have an ancestor that is a void element |
||
310 | * |
||
311 | * @return bool |
||
312 | */ |
||
313 | public function isVoid() |
||
317 | |||
318 | /** |
||
319 | * Return whether this template preserves the whitespace in its descendants |
||
320 | * |
||
321 | * @return bool |
||
322 | */ |
||
323 | public function preservesNewLines() |
||
327 | |||
328 | /** |
||
329 | * Analyses the content of the whole template and set $this->contentBitfield accordingly |
||
330 | */ |
||
331 | protected function analyseContent() |
||
345 | |||
346 | /** |
||
347 | * Records the HTML elements (and their bitfield) rendered at the root of the template |
||
348 | */ |
||
349 | protected function analyseRootNodes() |
||
396 | |||
397 | /** |
||
398 | * Analyses each branch that leads to an <xsl:apply-templates/> tag |
||
399 | */ |
||
400 | protected function analyseBranches() |
||
610 | |||
611 | /** |
||
612 | * Test whether given element is a block-level element |
||
613 | * |
||
614 | * @param string $elName Element name |
||
615 | * @param DOMElement $node Context node |
||
616 | * @return bool |
||
617 | */ |
||
618 | protected function elementIsBlock($elName, DOMElement $node) |
||
632 | |||
633 | /** |
||
634 | * Evaluate a boolean XPath query |
||
635 | * |
||
636 | * @param string $query XPath query |
||
637 | * @param DOMElement $node Context node |
||
638 | * @return boolean |
||
639 | */ |
||
640 | protected function evaluate($query, DOMElement $node) |
||
644 | |||
645 | /** |
||
646 | * Retrieve and return the inline style assigned to given element |
||
647 | * |
||
648 | * @param DOMElement $node Context node |
||
649 | * @return string |
||
650 | */ |
||
651 | protected function getStyle(DOMElement $node) |
||
666 | |||
667 | /** |
||
668 | * Get all XSL elements of given name |
||
669 | * |
||
670 | * @param string $elName XSL element's name, e.g. "apply-templates" |
||
671 | * @return \DOMNodeList |
||
672 | */ |
||
673 | protected function getXSLElements($elName) |
||
677 | |||
678 | /** |
||
679 | * Test whether given node is a span element used for formatting |
||
680 | * |
||
681 | * Will return TRUE if the node is a span element with a class attribute and/or a style attribute |
||
682 | * and no other attributes |
||
683 | * |
||
684 | * @param DOMElement $node |
||
685 | * @return boolean |
||
686 | */ |
||
687 | protected function isFormattingSpan(DOMElement $node) |
||
710 | |||
711 | /** |
||
712 | * "What is this?" you might ask. This is basically a compressed version of the HTML5 content |
||
713 | * models and rules, with some liberties taken. |
||
714 | * |
||
715 | * For each element, up to three bitfields are defined: "c", "ac" and "dd". Bitfields are stored |
||
716 | * as raw bytes, formatted using the octal notation to keep the sources ASCII. |
||
717 | * |
||
718 | * "c" represents the categories the element belongs to. The categories are comprised of HTML5 |
||
719 | * content models (such as "phrasing content" or "interactive content") plus a few special |
||
720 | * categories created to cover the parts of the specs that refer to "a group of X and Y |
||
721 | * elements" rather than a specific content model. |
||
722 | * |
||
723 | * "ac" represents the categories that are allowed as children of given element. |
||
724 | * |
||
725 | * "dd" represents the categories that must not appear as a descendant of given element. |
||
726 | * |
||
727 | * Sometimes, HTML5 specifies some restrictions on when an element can accept certain children, |
||
728 | * or what categories the element belongs to. For example, an <img> element is only part of the |
||
729 | * "interactive content" category if it has a "usemap" attribute. Those restrictions are |
||
730 | * expressed as an XPath expression and stored using the concatenation of the key of the bitfield |
||
731 | * plus the bit number of the category. For instance, if "interactive content" got assigned to |
||
732 | * bit 2, the definition of the <img> element will contain a key "c2" with value "@usemap". |
||
733 | * |
||
734 | * Additionally, other flags are set: |
||
735 | * |
||
736 | * "t" indicates that the element uses the "transparent" content model. |
||
737 | * "e" indicates that the element uses the "empty" content model. |
||
738 | * "v" indicates that the element is a void element. |
||
739 | * "nt" indicates that the element does not accept text nodes. (no text) |
||
740 | * "to" indicates that the element should only contain text. (text-only) |
||
741 | * "fe" indicates that the element is a formatting element. It will automatically be reopened |
||
742 | * when closed by an end tag of a different name. |
||
743 | * "b" indicates that the element is not phrasing content, which makes it likely to act like |
||
744 | * a block element. |
||
745 | * |
||
746 | * Finally, HTML5 defines "optional end tag" rules, where one element automatically closes its |
||
747 | * predecessor. Those are used to generate closeParent rules and are stored in the "cp" key. |
||
748 | * |
||
749 | * @var array |
||
750 | * @see /scripts/patchTemplateInspector.php |
||
751 | */ |
||
752 | protected static $htmlElements = [ |
||
753 | 'a'=>['c'=>"\17\0\0\0\0\1",'c3'=>'@href','ac'=>"\0",'dd'=>"\10\0\0\0\0\1",'t'=>1,'fe'=>1], |
||
754 | 'abbr'=>['c'=>"\7",'ac'=>"\4"], |
||
755 | 'address'=>['c'=>"\3\40",'ac'=>"\1",'dd'=>"\0\45",'b'=>1,'cp'=>['p']], |
||
756 | 'article'=>['c'=>"\3\4",'ac'=>"\1",'b'=>1,'cp'=>['p']], |
||
757 | 'aside'=>['c'=>"\3\4",'ac'=>"\1",'dd'=>"\0\0\0\0\10",'b'=>1,'cp'=>['p']], |
||
758 | 'audio'=>['c'=>"\57",'c3'=>'@controls','c1'=>'@controls','ac'=>"\0\0\0\104",'ac26'=>'not(@src)','dd'=>"\0\0\0\0\0\2",'dd41'=>'@src','t'=>1], |
||
759 | 'b'=>['c'=>"\7",'ac'=>"\4",'fe'=>1], |
||
760 | 'base'=>['c'=>"\20",'nt'=>1,'e'=>1,'v'=>1,'b'=>1], |
||
761 | 'bdi'=>['c'=>"\7",'ac'=>"\4"], |
||
762 | 'bdo'=>['c'=>"\7",'ac'=>"\4"], |
||
763 | 'blockquote'=>['c'=>"\203",'ac'=>"\1",'b'=>1,'cp'=>['p']], |
||
764 | 'body'=>['c'=>"\200\0\4",'ac'=>"\1",'b'=>1], |
||
765 | 'br'=>['c'=>"\5",'nt'=>1,'e'=>1,'v'=>1], |
||
766 | 'button'=>['c'=>"\117",'ac'=>"\4",'dd'=>"\10"], |
||
767 | 'canvas'=>['c'=>"\47",'ac'=>"\0",'t'=>1], |
||
768 | 'caption'=>['c'=>"\0\2",'ac'=>"\1",'dd'=>"\0\0\0\200",'b'=>1], |
||
769 | 'cite'=>['c'=>"\7",'ac'=>"\4"], |
||
770 | 'code'=>['c'=>"\7",'ac'=>"\4",'fe'=>1], |
||
771 | 'col'=>['c'=>"\0\0\20",'nt'=>1,'e'=>1,'v'=>1,'b'=>1], |
||
772 | 'colgroup'=>['c'=>"\0\2",'ac'=>"\0\0\20",'ac20'=>'not(@span)','nt'=>1,'e'=>1,'e0'=>'@span','b'=>1], |
||
773 | 'data'=>['c'=>"\7",'ac'=>"\4"], |
||
774 | 'datalist'=>['c'=>"\5",'ac'=>"\4\200\0\10"], |
||
775 | 'dd'=>['c'=>"\0\0\200",'ac'=>"\1",'b'=>1,'cp'=>['dd','dt']], |
||
776 | 'del'=>['c'=>"\5",'ac'=>"\0",'t'=>1], |
||
777 | 'details'=>['c'=>"\213",'ac'=>"\1\0\0\2",'b'=>1,'cp'=>['p']], |
||
778 | 'dfn'=>['c'=>"\7\0\0\0\40",'ac'=>"\4",'dd'=>"\0\0\0\0\40"], |
||
779 | 'div'=>['c'=>"\3",'ac'=>"\1",'b'=>1,'cp'=>['p']], |
||
780 | 'dl'=>['c'=>"\3",'c1'=>'dt and dd','ac'=>"\0\200\200",'nt'=>1,'b'=>1,'cp'=>['p']], |
||
781 | 'dt'=>['c'=>"\0\0\200",'ac'=>"\1",'dd'=>"\0\5\0\40",'b'=>1,'cp'=>['dd','dt']], |
||
782 | 'em'=>['c'=>"\7",'ac'=>"\4",'fe'=>1], |
||
783 | 'embed'=>['c'=>"\57",'nt'=>1,'e'=>1,'v'=>1], |
||
784 | 'fieldset'=>['c'=>"\303",'ac'=>"\1\0\0\20",'b'=>1,'cp'=>['p']], |
||
785 | 'figcaption'=>['c'=>"\0\0\0\0\0\4",'ac'=>"\1",'b'=>1,'cp'=>['p']], |
||
786 | 'figure'=>['c'=>"\203",'ac'=>"\1\0\0\0\0\4",'b'=>1,'cp'=>['p']], |
||
787 | 'footer'=>['c'=>"\3\40",'ac'=>"\1",'dd'=>"\0\0\0\0\10",'b'=>1,'cp'=>['p']], |
||
788 | 'form'=>['c'=>"\3\0\0\0\20",'ac'=>"\1",'dd'=>"\0\0\0\0\20",'b'=>1,'cp'=>['p']], |
||
789 | 'h1'=>['c'=>"\3\1",'ac'=>"\4",'b'=>1,'cp'=>['p']], |
||
790 | 'h2'=>['c'=>"\3\1",'ac'=>"\4",'b'=>1,'cp'=>['p']], |
||
791 | 'h3'=>['c'=>"\3\1",'ac'=>"\4",'b'=>1,'cp'=>['p']], |
||
792 | 'h4'=>['c'=>"\3\1",'ac'=>"\4",'b'=>1,'cp'=>['p']], |
||
793 | 'h5'=>['c'=>"\3\1",'ac'=>"\4",'b'=>1,'cp'=>['p']], |
||
794 | 'h6'=>['c'=>"\3\1",'ac'=>"\4",'b'=>1,'cp'=>['p']], |
||
795 | 'head'=>['c'=>"\0\0\4",'ac'=>"\20",'nt'=>1,'b'=>1], |
||
796 | 'header'=>['c'=>"\3\40\0\40",'ac'=>"\1",'dd'=>"\0\0\0\0\10",'b'=>1,'cp'=>['p']], |
||
797 | 'hr'=>['c'=>"\1\100",'nt'=>1,'e'=>1,'v'=>1,'b'=>1,'cp'=>['p']], |
||
798 | 'html'=>['c'=>"\0",'ac'=>"\0\0\4",'nt'=>1,'b'=>1], |
||
799 | 'i'=>['c'=>"\7",'ac'=>"\4",'fe'=>1], |
||
800 | 'iframe'=>['c'=>"\57",'ac'=>"\4"], |
||
801 | 'img'=>['c'=>"\57\20\10",'c3'=>'@usemap','nt'=>1,'e'=>1,'v'=>1], |
||
802 | 'input'=>['c'=>"\17\20",'c3'=>'@type!="hidden"','c12'=>'@type!="hidden" or @type="hidden"','c1'=>'@type!="hidden"','nt'=>1,'e'=>1,'v'=>1], |
||
803 | 'ins'=>['c'=>"\7",'ac'=>"\0",'t'=>1], |
||
804 | 'kbd'=>['c'=>"\7",'ac'=>"\4"], |
||
805 | 'keygen'=>['c'=>"\117",'nt'=>1,'e'=>1,'v'=>1], |
||
806 | 'label'=>['c'=>"\17\20\0\0\4",'ac'=>"\4",'dd'=>"\0\0\1\0\4"], |
||
807 | 'legend'=>['c'=>"\0\0\0\20",'ac'=>"\4",'b'=>1], |
||
808 | 'li'=>['c'=>"\0\0\0\0\200",'ac'=>"\1",'b'=>1,'cp'=>['li']], |
||
809 | 'link'=>['c'=>"\20",'nt'=>1,'e'=>1,'v'=>1,'b'=>1], |
||
810 | 'main'=>['c'=>"\3\0\0\0\10",'ac'=>"\1",'b'=>1,'cp'=>['p']], |
||
811 | 'mark'=>['c'=>"\7",'ac'=>"\4"], |
||
812 | 'media element'=>['c'=>"\0\0\0\0\0\2",'nt'=>1,'b'=>1], |
||
813 | 'menu'=>['c'=>"\1\100",'ac'=>"\0\300",'nt'=>1,'b'=>1,'cp'=>['p']], |
||
814 | 'menuitem'=>['c'=>"\0\100",'nt'=>1,'e'=>1,'v'=>1,'b'=>1], |
||
815 | 'meta'=>['c'=>"\20",'nt'=>1,'e'=>1,'v'=>1,'b'=>1], |
||
816 | 'meter'=>['c'=>"\7\0\1\0\2",'ac'=>"\4",'dd'=>"\0\0\0\0\2"], |
||
817 | 'nav'=>['c'=>"\3\4",'ac'=>"\1",'dd'=>"\0\0\0\0\10",'b'=>1,'cp'=>['p']], |
||
818 | 'noscript'=>['c'=>"\25",'nt'=>1], |
||
819 | 'object'=>['c'=>"\147",'ac'=>"\0\0\0\0\1",'t'=>1], |
||
820 | 'ol'=>['c'=>"\3",'c1'=>'li','ac'=>"\0\200\0\0\200",'nt'=>1,'b'=>1,'cp'=>['p']], |
||
821 | 'optgroup'=>['c'=>"\0\0\2",'ac'=>"\0\200\0\10",'nt'=>1,'b'=>1,'cp'=>['optgroup','option']], |
||
822 | 'option'=>['c'=>"\0\0\2\10",'b'=>1,'cp'=>['option']], |
||
823 | 'output'=>['c'=>"\107",'ac'=>"\4"], |
||
824 | 'p'=>['c'=>"\3",'ac'=>"\4",'b'=>1,'cp'=>['p']], |
||
825 | 'param'=>['c'=>"\0\0\0\0\1",'nt'=>1,'e'=>1,'v'=>1,'b'=>1], |
||
826 | 'picture'=>['c'=>"\45",'ac'=>"\0\200\10",'nt'=>1], |
||
827 | 'pre'=>['c'=>"\3",'ac'=>"\4",'pre'=>1,'b'=>1,'cp'=>['p']], |
||
828 | 'progress'=>['c'=>"\7\0\1\1",'ac'=>"\4",'dd'=>"\0\0\0\1"], |
||
829 | 'q'=>['c'=>"\7",'ac'=>"\4"], |
||
830 | 'rb'=>['c'=>"\0\10",'ac'=>"\4",'b'=>1], |
||
831 | 'rp'=>['c'=>"\0\10\100",'ac'=>"\4",'b'=>1,'cp'=>['rp','rt']], |
||
832 | 'rt'=>['c'=>"\0\10\100",'ac'=>"\4",'b'=>1,'cp'=>['rp','rt']], |
||
833 | 'rtc'=>['c'=>"\0\10",'ac'=>"\4\0\100",'b'=>1], |
||
834 | 'ruby'=>['c'=>"\7",'ac'=>"\4\10"], |
||
835 | 's'=>['c'=>"\7",'ac'=>"\4",'fe'=>1], |
||
836 | 'samp'=>['c'=>"\7",'ac'=>"\4"], |
||
837 | 'script'=>['c'=>"\25\200",'to'=>1], |
||
838 | 'section'=>['c'=>"\3\4",'ac'=>"\1",'b'=>1,'cp'=>['p']], |
||
839 | 'select'=>['c'=>"\117",'ac'=>"\0\200\2",'nt'=>1], |
||
840 | 'small'=>['c'=>"\7",'ac'=>"\4",'fe'=>1], |
||
841 | 'source'=>['c'=>"\0\0\10\4",'nt'=>1,'e'=>1,'v'=>1,'b'=>1], |
||
842 | 'span'=>['c'=>"\7",'ac'=>"\4"], |
||
843 | 'strong'=>['c'=>"\7",'ac'=>"\4",'fe'=>1], |
||
844 | 'style'=>['c'=>"\20",'to'=>1,'b'=>1], |
||
845 | 'sub'=>['c'=>"\7",'ac'=>"\4"], |
||
846 | 'summary'=>['c'=>"\0\0\0\2",'ac'=>"\4\1",'b'=>1], |
||
847 | 'sup'=>['c'=>"\7",'ac'=>"\4"], |
||
848 | 'table'=>['c'=>"\3\0\0\200",'ac'=>"\0\202",'nt'=>1,'b'=>1,'cp'=>['p']], |
||
849 | 'tbody'=>['c'=>"\0\2",'ac'=>"\0\200\0\0\100",'nt'=>1,'b'=>1,'cp'=>['tbody','td','tfoot','th','thead','tr']], |
||
850 | 'td'=>['c'=>"\200\0\40",'ac'=>"\1",'b'=>1,'cp'=>['td','th']], |
||
851 | 'template'=>['c'=>"\25\200\20",'nt'=>1], |
||
852 | 'textarea'=>['c'=>"\117",'pre'=>1,'to'=>1], |
||
853 | 'tfoot'=>['c'=>"\0\2",'ac'=>"\0\200\0\0\100",'nt'=>1,'b'=>1,'cp'=>['tbody','td','th','thead','tr']], |
||
854 | 'th'=>['c'=>"\0\0\40",'ac'=>"\1",'dd'=>"\0\5\0\40",'b'=>1,'cp'=>['td','th']], |
||
855 | 'thead'=>['c'=>"\0\2",'ac'=>"\0\200\0\0\100",'nt'=>1,'b'=>1], |
||
856 | 'time'=>['c'=>"\7",'ac'=>"\4",'ac2'=>'@datetime'], |
||
857 | 'title'=>['c'=>"\20",'to'=>1,'b'=>1], |
||
858 | 'tr'=>['c'=>"\0\2\0\0\100",'ac'=>"\0\200\40",'nt'=>1,'b'=>1,'cp'=>['td','th','tr']], |
||
859 | 'track'=>['c'=>"\0\0\0\100",'nt'=>1,'e'=>1,'v'=>1,'b'=>1], |
||
860 | 'u'=>['c'=>"\7",'ac'=>"\4",'fe'=>1], |
||
861 | 'ul'=>['c'=>"\3",'c1'=>'li','ac'=>"\0\200\0\0\200",'nt'=>1,'b'=>1,'cp'=>['p']], |
||
862 | 'var'=>['c'=>"\7",'ac'=>"\4"], |
||
863 | 'video'=>['c'=>"\57",'c3'=>'@controls','ac'=>"\0\0\0\104",'ac26'=>'not(@src)','dd'=>"\0\0\0\0\0\2",'dd41'=>'@src','t'=>1], |
||
864 | 'wbr'=>['c'=>"\5",'nt'=>1,'e'=>1,'v'=>1] |
||
865 | ]; |
||
866 | |||
867 | /** |
||
868 | * Get the bitfield value for a given element name in a given context |
||
869 | * |
||
870 | * @param string $elName Name of the HTML element |
||
871 | * @param string $k Bitfield name: either 'c', 'ac' or 'dd' |
||
872 | * @param DOMElement $node Context node (not necessarily the same as $elName) |
||
873 | * @return string |
||
874 | */ |
||
875 | protected function getBitfield($elName, $k, DOMElement $node) |
||
917 | |||
918 | /** |
||
919 | * Test whether given element has given property in context |
||
920 | * |
||
921 | * @param string $elName Element name |
||
922 | * @param string $propName Property name, see self::$htmlElements |
||
923 | * @param DOMElement $node Context node |
||
924 | * @return bool |
||
925 | */ |
||
926 | protected function hasProperty($elName, $propName, DOMElement $node) |
||
940 | |||
941 | /** |
||
942 | * Test whether two bitfields have any bits in common |
||
943 | * |
||
944 | * @param string $bitfield1 |
||
945 | * @param string $bitfield2 |
||
946 | * @return bool |
||
947 | */ |
||
948 | protected static function match($bitfield1, $bitfield2) |
||
952 | } |