Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6b6ea0b

Browse files
author
Edward Z. Yang ext:(%22)
committed
Fix foster parenting bug, and current node bug. Improve debugging facilities.
1 parent120e332 commit6b6ea0b

File tree

1 file changed

+30
-17
lines changed

1 file changed

+30
-17
lines changed

‎library/HTML5/TreeConstructer.php

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,10 @@ public function emitToken($token, $mode = null) {
140140
if ($backtrace[1]['class'] !== 'HTML5_TreeConstructer') echo "--\n";
141141
echo $this->strConst($mode) . "\n ";
142142
token_dump($token);
143+
$this->printStack();
144+
$this->printActiveFormattingElements();
143145
if ($this->foster_parent) echo " -> this is a foster parent mode\n";
144-
*/
146+
*/
145147

146148
if ($this->ignore_lf_token)$this->ignore_lf_token--;
147149
$this->ignored =false;
@@ -1933,18 +1935,10 @@ public function emitToken($token, $mode = null) {
19331935
/* Parse error. Process the token as if the insertion mode was "in
19341936
body", with the following exception: */
19351937

1936-
/* If the current node is a table, tbody, tfoot, thead, or tr
1937-
element, then, whenever a node would be inserted into the current
1938-
node, it must instead be inserted into the foster parent element. */
1939-
if(in_array(end($this->stack)->tagName,
1940-
array('table','tbody','tfoot','thead','tr'))) {
1941-
$old =$this->foster_parent;
1942-
$this->foster_parent =true;
1943-
$this->processWithRulesFor($token,self::IN_BODY);
1944-
$this->foster_parent =$old;
1945-
}else {
1946-
$this->processWithRulesFor($token,self::IN_BODY);
1947-
}
1938+
$old =$this->foster_parent;
1939+
$this->foster_parent =true;
1940+
$this->processWithRulesFor($token,self::IN_BODY);
1941+
$this->foster_parent =$old;
19481942
}
19491943
break;
19501944

@@ -2788,7 +2782,12 @@ private function insertComment($data) {
27882782
}
27892783

27902784
privatefunctionappendToRealParent($node) {
2791-
if(!$this->foster_parent) {
2785+
// this is only for the foster_parent case
2786+
/* If the current node is a table, tbody, tfoot, thead, or tr
2787+
element, then, whenever a node would be inserted into the current
2788+
node, it must instead be inserted into the foster parent element. */
2789+
if(!$this->foster_parent || !in_array(end($this->stack)->tagName,
2790+
array('table','tbody','tfoot','thead','tr'))) {
27922791
$this->appendChild(end($this->stack),$node);
27932792
}else {
27942793
$this->fosterParent($node);
@@ -2910,7 +2909,7 @@ private function reconstructActiveFormattingElements() {
29102909

29112910
/* 9. Append clone to the current node and push it onto the stack
29122911
of open elements so that it is the new current node. */
2913-
end($this->stack)->appendChild($clone);
2912+
$this->appendToRealParent($clone);
29142913
$this->stack[] =$clone;
29152914

29162915
/* 10. Replace the entry for entry in the list with an entry for
@@ -3209,10 +3208,24 @@ public function fosterParent($node) {
32093208
* For debugging, prints the stack
32103209
*/
32113210
privatefunctionprintStack() {
3212-
echo" Stack:\n";
3211+
$names =array();
32133212
foreach ($this->stackas$i =>$element) {
3214-
echo"" . ($i+1) ."." .$element->tagName ."\n";
3213+
$names[] =$element->tagName;
3214+
}
3215+
echo" -> stack [" .implode(',',$names) ."]\n";
3216+
}
3217+
3218+
/**
3219+
* For debugging, prints active formatting elements
3220+
*/
3221+
privatefunctionprintActiveFormattingElements() {
3222+
if (!$this->a_formatting)return;
3223+
$names =array();
3224+
foreach ($this->a_formattingas$node) {
3225+
if ($node ===self::MARKER)$names[] ='MARKER';
3226+
else$names[] =$node->tagName;
32153227
}
3228+
echo" -> active formatting [" .implode(',',$names) ."]\n";
32163229
}
32173230

32183231
publicfunctioncurrentTableIsTainted() {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp