Changeset 62621 in webkit


Ignore:
Timestamp:
Jul 6, 2010 9:43:06 PM (14 years ago)
Author:
abarth@webkit.org
Message:

2010-07-06 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

Implement "act as if the banana has been peeled" (for lack of a better term)
https://bugs.webkit.org/show_bug.cgi?id=41734

The spec has a tricky passage that says "whenever a node would be
inserted into the current node, it must instead be foster parented."
This patch attempts to implement that requirement.

  • html/HTMLConstructionSite.cpp: (WebCore::HTMLConstructionSite::attach): (WebCore::HTMLConstructionSite::HTMLConstructionSite): (WebCore::HTMLConstructionSite::insertHTMLHtmlElement): (WebCore::HTMLConstructionSite::insertHTMLHeadElement): (WebCore::HTMLConstructionSite::insertHTMLBodyElement): (WebCore::HTMLConstructionSite::insertScriptElement): (WebCore::HTMLConstructionSite::fosterParent):
  • html/HTMLConstructionSite.h: (WebCore::HTMLConstructionSite::RedirectToFosterParentGuard::RedirectToFosterParentGuard): (WebCore::HTMLConstructionSite::RedirectToFosterParentGuard::~RedirectToFosterParentGuard):
  • html/HTMLTreeBuilder.cpp: (WebCore::HTMLTreeBuilder::processStartTagForInTable): (WebCore::HTMLTreeBuilder::processEndTagForInTable):
  • html/HTMLTreeBuilder.h:

2010-07-06 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

Implement "act as if the banana has been peeled" (for lack of a better term)
https://bugs.webkit.org/show_bug.cgi?id=41734

Massive test progression.

  • html5lib/runner-expected-html5.txt:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r62619 r62621  
     12010-07-06  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Implement "act as if the banana has been peeled" (for lack of a better term)
     6        https://bugs.webkit.org/show_bug.cgi?id=41734
     7
     8        Massive test progression.
     9
     10        * html5lib/runner-expected-html5.txt:
     11
    1122010-07-06  Kent Tamura  <tkent@chromium.org>
    213
  • trunk/LayoutTests/html5lib/runner-expected-html5.txt

    r62618 r62621  
    121279
    131380
    14 90
    1514103
    16 112
    1715
    1816Test 30 of 113 in resources/tests1.dat failed. Input:
     
    2321|   <body>
    2422|     <a>
     23|       <a>
    2524|       <table>
    2625|         <tbody>
     
    3029|                 <table>
    3130|               <a>
    32 |           <a>
    3331|       <a>
    3432|         <b>
     
    6765|       <div>
    6866|         "hello"
     67|         <b>
     68|           "me!"
    6969|         <table>
    7070|           "excite!"
    71 |           <b>
    72 |             "me!"
    7371|           <tbody>
    7472|             <tr>
     
    150148|       href="blah"
    151149|       "aba"
     150|       <a>
     151|         href="foo"
     152|         "br"
    152153|       <table>
    153 |         <a>
    154 |           href="foo"
    155 |           "br"
    156154|         <tbody>
    157155|           <tr>
     
    220218|   <head>
    221219|   <body>
    222 |     <table>
    223 |       <a>
    224 |         href="blah"
    225 |         "aba"
     220|     <a>
     221|       href="blah"
     222|       "aba"
     223|     <table>
    226224|       <tbody>
    227225|         <tr>
     
    253251|       "aoe"
    254252
    255 Test 90 of 113 in resources/tests1.dat failed. Input:
    256 <a><table><a></table><p><a><div><a>
    257 Got:
    258 | <html>
    259 |   <head>
    260 |   <body>
    261 |     <a>
    262 |       <table>
    263 |         <a>
    264 |     <p>
    265 |       <a>
    266 |     <div>
    267 |       <a>
    268 Expected:
     253Test 103 of 113 in resources/tests1.dat failed. Input:
     254<a><table><td><a><table></table><a></tr><a></table><a>
     255Got:
    269256| <html>
    270257|   <head>
     
    272259|     <a>
    273260|       <a>
    274 |       <table>
    275 |     <p>
    276 |       <a>
    277 |     <div>
    278 |       <a>
    279 
    280 Test 103 of 113 in resources/tests1.dat failed. Input:
    281 <a><table><td><a><table></table><a></tr><a></table><a>
    282 Got:
    283 | <html>
    284 |   <head>
    285 |   <body>
    286 |     <a>
    287261|       <table>
    288262|         <tbody>
     
    292266|                 <table>
    293267|               <a>
    294 |           <a>
    295268|       <a>
    296269Expected:
     
    308281|               <a>
    309282|     <a>
    310 
    311 Test 112 of 113 in resources/tests1.dat failed. Input:
    312 <table><tr></strong></b></em></i></u></strike></s></blink></tt></pre></big></small></font></select></h1></h2></h3></h4></h5></h6></body></br></a></img></title></span></style></script></table></th></td></tr></frame></area></link></param></hr></input></col></base></meta></basefont></bgsound></embed></spacer></p></dd></dt></caption></colgroup></tbody></tfoot></thead></address></blockquote></center></dir></div></dl></fieldset></listing></menu></ol></ul></li></nobr></wbr></form></button></marquee></object></html></frameset></head></iframe></image></isindex></noembed></noframes></noscript></optgroup></option></plaintext></textarea>
    313 Got:
    314 | <html>
    315 |   <head>
    316 |   <body>
    317 |     <table>
    318 |       <tbody>
    319 |         <tr>
    320 |           <br>
    321 |     <p>
    322 Expected:
    323 | <html>
    324 |   <head>
    325 |   <body>
    326 |     <br>
    327 |     <table>
    328 |       <tbody>
    329 |         <tr>
    330 |     <p>
    331283resources/tests2.dat:
    332 11
    33328413
    33428547
    33528648
    33628749
    337 
    338 Test 11 of 59 in resources/tests2.dat failed. Input:
    339 <table><plaintext><td>
    340 Got:
    341 | <html>
    342 |   <head>
    343 |   <body>
    344 |     <table>
    345 |       <plaintext>
    346 |         "<td>"
    347 Expected:
    348 | <html>
    349 |   <head>
    350 |   <body>
    351 |     <plaintext>
    352 |       "<td>"
    353 |     <table>
    354288
    355289Test 13 of 59 in resources/tests2.dat failed. Input:
     
    66159527
    66259630
    663 33
    664 36
    66559737
    66659842
     
    816748| <frame>
    817749
    818 Test 33 of 51 in resources/tests6.dat failed. Input:
    819 <table><tr><div>
    820 Got:
    821 | <html>
    822 |   <head>
    823 |   <body>
    824 |     <table>
    825 |       <tbody>
    826 |         <tr>
    827 |           <div>
    828 Expected:
    829 | <html>
    830 |   <head>
    831 |   <body>
    832 |     <div>
    833 |     <table>
    834 |       <tbody>
    835 |         <tr>
    836 
    837 Test 36 of 51 in resources/tests6.dat failed. Input:
    838 <table><tr><div><td>
    839 Got:
    840 | <html>
    841 |   <head>
    842 |   <body>
    843 |     <table>
    844 |       <tbody>
    845 |         <tr>
    846 |           <div>
    847 |           <td>
    848 Expected:
    849 | <html>
    850 |   <head>
    851 |   <body>
    852 |     <div>
    853 |     <table>
    854 |       <tbody>
    855 |         <tr>
    856 |           <td>
    857 
    858750Test 37 of 51 in resources/tests6.dat failed. Input:
    859751<caption><col><colgroup><tbody><tfoot><thead><tr>
     
    923815|   <body>
    924816resources/tests7.dat:
    925 2
    926 5
    9278176
    9288187
     
    93382318
    93482419
    935 20
    93682524
    93782627
     
    94082930
    941830
    942 Test 2 of 30 in resources/tests7.dat failed. Input:
    943 <!doctype html><table><title>X</title></table>
    944 Got:
    945 | <!DOCTYPE html>
    946 | <html>
    947 |   <head>
    948 |   <body>
    949 |     <table>
    950 |       <title>
    951 |         "X"
    952 Expected:
    953 | <!DOCTYPE html>
    954 | <html>
    955 |   <head>
    956 |   <body>
    957 |     <title>
    958 |       "X"
    959 |     <table>
    960 
    961 Test 5 of 30 in resources/tests7.dat failed. Input:
    962 <!doctype html><table><meta></table>
    963 Got:
    964 | <!DOCTYPE html>
    965 | <html>
    966 |   <head>
    967 |   <body>
    968 |     <table>
    969 |       <meta>
    970 Expected:
    971 | <!DOCTYPE html>
    972 | <html>
    973 |   <head>
    974 |   <body>
    975 |     <meta>
    976 |     <table>
    977 
    978831Test 6 of 30 in resources/tests7.dat failed. Input:
    979832<!doctype html><table>X<tr><td><table> <meta></table></table>
     
    985838|     <table>
    986839|       "X"
    987 |       <tbody>
    988 |         <tr>
    989 |           <td>
    990 |             <table>
    991 |               " "
    992 |               <meta>
    993 Expected:
    994 | <!DOCTYPE html>
    995 | <html>
    996 |   <head>
    997 |   <body>
    998 |     "X"
    999 |     <table>
    1000840|       <tbody>
    1001841|         <tr>
     
    1004844|             <table>
    1005845|               " "
     846Expected:
     847| <!DOCTYPE html>
     848| <html>
     849|   <head>
     850|   <body>
     851|     "X"
     852|     <table>
     853|       <tbody>
     854|         <tr>
     855|           <td>
     856|             <meta>
     857|             <table>
     858|               " "
    1006859
    1007860Test 7 of 30 in resources/tests7.dat failed. Input:
     
    1126979|         type="hidDEN"
    1127980
    1128 Test 20 of 30 in resources/tests7.dat failed. Input:
    1129 <!doctype html><table><select>X<tr>
    1130 Got:
    1131 | <!DOCTYPE html>
    1132 | <html>
    1133 |   <head>
    1134 |   <body>
    1135 |     <table>
    1136 |       <select>
    1137 |         "X"
    1138 |       <tbody>
    1139 |         <tr>
    1140 Expected:
    1141 | <!DOCTYPE html>
    1142 | <html>
    1143 |   <head>
    1144 |   <body>
    1145 |     <select>
    1146 |       "X"
    1147 |     <table>
    1148 |       <tbody>
    1149 |         <tr>
    1150 
    1151981Test 24 of 30 in resources/tests7.dat failed. Input:
    1152982<body>X</body></body>
     
    1164994|   <head>
    1165995|   <body>
    1166 |     <table>
    1167 |       <b>
     996|     <b>
     997|     <table>
    1168998|       <tbody>
    1169999|         <tr>
     
    13501180|   <head>
    13511181|   <body>
    1352 |     <table>
     1182|     <div>
     1183|       "x"
    13531184|       <div>
    1354 |         "x"
    1355 |         <div>
     1185|     <table>
    13561186|       "xx"
    13571187Expected:
     
    1412124214
    1413124315
    1414 17
    1415124418
    1416124519
     
    14571286|   <head>
    14581287|   <body>
    1459 |     <table>
    1460 |       <math>
     1288|     <math>
     1289|     <table>
    14611290Expected:
    14621291| <!DOCTYPE html>
     
    14741303|   <head>
    14751304|   <body>
    1476 |     <table>
    1477 |       <math>
    1478 |         <mi>
    1479 |           "foo"
     1305|     <math>
     1306|       <mi>
     1307|         "foo"
     1308|     <table>
    14801309Expected:
    14811310| <!DOCTYPE html>
     
    14951324|   <head>
    14961325|   <body>
    1497 |     <table>
    1498 |       <math>
    1499 |         <mi>
    1500 |           "foo"
    1501 |         <mi>
    1502 |           "bar"
     1326|     <math>
     1327|       <mi>
     1328|         "foo"
     1329|       <mi>
     1330|         "bar"
     1331|     <table>
    15031332Expected:
    15041333| <!DOCTYPE html>
     
    15201349|   <head>
    15211350|   <body>
     1351|     <math>
     1352|       <mi>
     1353|         "foo"
     1354|       <mi>
     1355|         "bar"
    15221356|     <table>
    15231357|       <tbody>
    1524 |         <math>
    1525 |           <mi>
    1526 |             "foo"
    1527 |           <mi>
    1528 |             "bar"
    15291358Expected:
    15301359| <!DOCTYPE html>
     
    15471376|   <head>
    15481377|   <body>
     1378|     <math>
     1379|       <mi>
     1380|         "foo"
     1381|       <mi>
     1382|         "bar"
    15491383|     <table>
    15501384|       <tbody>
    15511385|         <tr>
    1552 |           <math>
    1553 |             <mi>
    1554 |               "foo"
    1555 |             <mi>
    1556 |               "bar"
    15571386Expected:
    15581387| <!DOCTYPE html>
     
    17411570|   <head>
    17421571|   <body>
     1572|     <math>
     1573|       <mi>
     1574|         "foo"
     1575|       <mi>
     1576|         "bar"
     1577|       <p>
     1578|         "baz"
    17431579|     <table>
    17441580|       <colgroup>
    1745 |       <math>
    1746 |         <mi>
    1747 |           "foo"
    1748 |         <mi>
    1749 |           "bar"
    1750 |         <p>
    1751 |           "baz"
    17521581|     <p>
    17531582|       "quux"
     
    17661595|     <table>
    17671596|       <colgroup>
    1768 |     <p>
    1769 |       "quux"
    1770 
    1771 Test 17 of 25 in resources/tests9.dat failed. Input:
    1772 <!DOCTYPE html><body><table><select><math><mi>foo</mi><mi>bar</mi><p>baz</table><p>quux
    1773 Got:
    1774 | <!DOCTYPE html>
    1775 | <html>
    1776 |   <head>
    1777 |   <body>
    1778 |     <table>
    1779 |       <select>
    1780 |         "foobarbaz"
    1781 |     <p>
    1782 |       "quux"
    1783 Expected:
    1784 | <!DOCTYPE html>
    1785 | <html>
    1786 |   <head>
    1787 |   <body>
    1788 |     <select>
    1789 |       "foobarbaz"
    1790 |     <table>
    17911597|     <p>
    17921598|       "quux"
     
    1955176114
    1956176215
    1957 17
    1958176318
    1959176419
     
    20001805|   <head>
    20011806|   <body>
    2002 |     <table>
    2003 |       <svg>
     1807|     <svg>
     1808|     <table>
    20041809Expected:
    20051810| <!DOCTYPE html>
     
    20171822|   <head>
    20181823|   <body>
    2019 |     <table>
    2020 |       <svg>
    2021 |         <g>
    2022 |           "foo"
     1824|     <svg>
     1825|       <g>
     1826|         "foo"
     1827|     <table>
    20231828Expected:
    20241829| <!DOCTYPE html>
     
    20381843|   <head>
    20391844|   <body>
    2040 |     <table>
    2041 |       <svg>
    2042 |         <g>
    2043 |           "foo"
    2044 |         <g>
    2045 |           "bar"
     1845|     <svg>
     1846|       <g>
     1847|         "foo"
     1848|       <g>
     1849|         "bar"
     1850|     <table>
    20461851Expected:
    20471852| <!DOCTYPE html>
     
    20631868|   <head>
    20641869|   <body>
     1870|     <svg>
     1871|       <g>
     1872|         "foo"
     1873|       <g>
     1874|         "bar"
    20651875|     <table>
    20661876|       <tbody>
    2067 |         <svg>
    2068 |           <g>
    2069 |             "foo"
    2070 |           <g>
    2071 |             "bar"
    20721877Expected:
    20731878| <!DOCTYPE html>
     
    20901895|   <head>
    20911896|   <body>
     1897|     <svg>
     1898|       <g>
     1899|         "foo"
     1900|       <g>
     1901|         "bar"
    20921902|     <table>
    20931903|       <tbody>
    20941904|         <tr>
    2095 |           <svg>
    2096 |             <g>
    2097 |               "foo"
    2098 |             <g>
    2099 |               "bar"
    21001905Expected:
    21011906| <!DOCTYPE html>
     
    22842089|   <head>
    22852090|   <body>
     2091|     <svg>
     2092|       <g>
     2093|         "foo"
     2094|       <g>
     2095|         "bar"
     2096|       <p>
     2097|         "baz"
    22862098|     <table>
    22872099|       <colgroup>
    2288 |       <svg>
    2289 |         <g>
    2290 |           "foo"
    2291 |         <g>
    2292 |           "bar"
    2293 |         <p>
    2294 |           "baz"
    22952100|     <p>
    22962101|       "quux"
     
    23092114|     <table>
    23102115|       <colgroup>
    2311 |     <p>
    2312 |       "quux"
    2313 
    2314 Test 17 of 25 in resources/tests10.dat failed. Input:
    2315 <!DOCTYPE html><body><table><select><svg><g>foo</g><g>bar</g><p>baz</table><p>quux
    2316 Got:
    2317 | <!DOCTYPE html>
    2318 | <html>
    2319 |   <head>
    2320 |   <body>
    2321 |     <table>
    2322 |       <select>
    2323 |         "foobarbaz"
    2324 |     <p>
    2325 |       "quux"
    2326 Expected:
    2327 | <!DOCTYPE html>
    2328 | <html>
    2329 |   <head>
    2330 |   <body>
    2331 |     <select>
    2332 |       "foobarbaz"
    2333 |     <table>
    23342116|     <p>
    23352117|       "quux"
     
    3545332710
    3546332811
    3547 12
    35483329
    35493330Test 1 of 14 in resources/tests15.dat failed. Input:
     
    36283409|   <head>
    36293410|   <body>
     3411|     <meta>
    36303412|     <table>
    36313413|       " X"
    3632 |       <meta>
    36333414Expected:
    36343415| <!DOCTYPE html>
     
    37173498|         " <tr>x "
    37183499|       " "
    3719 
    3720 Test 12 of 14 in resources/tests15.dat failed. Input:
    3721 <!doctype html><div><table><a>foo</a> <tr><td>bar</td> </tr></table></div>
    3722 Got:
    3723 | <!DOCTYPE html>
    3724 | <html>
    3725 |   <head>
    3726 |   <body>
    3727 |     <div>
    3728 |       <table>
    3729 |         <a>
    3730 |           "foo"
    3731 |         " "
    3732 |         <tbody>
    3733 |           <tr>
    3734 |             <td>
    3735 |               "bar"
    3736 |             " "
    3737 Expected:
    3738 | <!DOCTYPE html>
    3739 | <html>
    3740 |   <head>
    3741 |   <body>
    3742 |     <div>
    3743 |       <a>
    3744 |         "foo"
    3745 |       <table>
    3746 |         " "
    3747 |         <tbody>
    3748 |           <tr>
    3749 |             <td>
    3750 |               "bar"
    3751 |             " "
    37523500resources/tests16.dat: PASS
    37533501
     
    379535434
    379635445
    3797 6
    37983545
    37993546Test 3 of 9 in resources/adoption01.dat failed. Input:
     
    38693616|         "4"
    38703617|       "5"
    3871 
    3872 Test 6 of 9 in resources/adoption01.dat failed. Input:
    3873 <table><a>1<p>2</a>3</p>
    3874 Got:
    3875 | <html>
    3876 |   <head>
    3877 |   <body>
    3878 |     <p>
    3879 |       <a>
    3880 |         "2"
    3881 |       "3"
    3882 |     <table>
    3883 |       <a>
    3884 |         "1"
    3885 Expected:
    3886 | <html>
    3887 |   <head>
    3888 |   <body>
    3889 |     <a>
    3890 |       "1"
    3891 |     <p>
    3892 |       <a>
    3893 |         "2"
    3894 |       "3"
    3895 |     <table>
    38963618resources/inbody01.dat: PASS
    38973619
     
    39003622resources/tables01.dat:
    390136234
    3902 7
    390336248
    3904 9
    3905 10
    39063625
    39073626Test 4 of 15 in resources/tables01.dat failed. Input:
     
    39223641|       <colgroup>
    39233642
    3924 Test 7 of 15 in resources/tables01.dat failed. Input:
    3925 <table><select><option>3</select></table>
    3926 Got:
    3927 | <html>
    3928 |   <head>
    3929 |   <body>
    3930 |     <table>
    3931 |       <select>
    3932 |         <option>
    3933 |           "3"
    3934 Expected:
    3935 | <html>
    3936 |   <head>
    3937 |   <body>
    3938 |     <select>
    3939 |       <option>
    3940 |         "3"
    3941 |     <table>
    3942 
    39433643Test 8 of 15 in resources/tables01.dat failed. Input:
    39443644<table><select><table></table></select></table>
     
    39473647|   <head>
    39483648|   <body>
    3949 |     <table>
    3950 |       <select>
    3951 Expected:
    3952 | <html>
    3953 |   <head>
    3954 |   <body>
    39553649|     <select>
    39563650|     <table>
    3957 |     <table>
    3958 
    3959 Test 9 of 15 in resources/tables01.dat failed. Input:
    3960 <table><select></table>
    3961 Got:
    3962 | <html>
    3963 |   <head>
    3964 |   <body>
    3965 |     <table>
    3966 |       <select>
    39673651Expected:
    39683652| <html>
     
    39713655|     <select>
    39723656|     <table>
    3973 
    3974 Test 10 of 15 in resources/tables01.dat failed. Input:
    3975 <table><select><option>A<tr><td>B</td></tr></table>
    3976 Got:
    3977 | <html>
    3978 |   <head>
    3979 |   <body>
    3980 |     <table>
    3981 |       <select>
    3982 |         <option>
    3983 |           "A"
    3984 |       <tbody>
    3985 |         <tr>
    3986 |           <td>
    3987 |             "B"
    3988 Expected:
    3989 | <html>
    3990 |   <head>
    3991 |   <body>
    3992 |     <select>
    3993 |       <option>
    3994 |         "A"
    3995 |     <table>
    3996 |       <tbody>
    3997 |         <tr>
    3998 |           <td>
    3999 |             "B"
     3657|     <table>
    40003658#EOF
  • trunk/WebCore/ChangeLog

    r62618 r62621  
     12010-07-06  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Implement "act as if the banana has been peeled" (for lack of a better term)
     6        https://bugs.webkit.org/show_bug.cgi?id=41734
     7
     8        The spec has a tricky passage that says "whenever a node would be
     9        inserted into the current node, it must instead be foster parented."
     10        This patch attempts to implement that requirement.
     11
     12        * html/HTMLConstructionSite.cpp:
     13        (WebCore::HTMLConstructionSite::attach):
     14        (WebCore::HTMLConstructionSite::HTMLConstructionSite):
     15        (WebCore::HTMLConstructionSite::insertHTMLHtmlElement):
     16        (WebCore::HTMLConstructionSite::insertHTMLHeadElement):
     17        (WebCore::HTMLConstructionSite::insertHTMLBodyElement):
     18        (WebCore::HTMLConstructionSite::insertScriptElement):
     19        (WebCore::HTMLConstructionSite::fosterParent):
     20        * html/HTMLConstructionSite.h:
     21        (WebCore::HTMLConstructionSite::RedirectToFosterParentGuard::RedirectToFosterParentGuard):
     22        (WebCore::HTMLConstructionSite::RedirectToFosterParentGuard::~RedirectToFosterParentGuard):
     23        * html/HTMLTreeBuilder.cpp:
     24        (WebCore::HTMLTreeBuilder::processStartTagForInTable):
     25        (WebCore::HTMLTreeBuilder::processEndTagForInTable):
     26        * html/HTMLTreeBuilder.h:
     27
    1282010-07-06  Eric Seidel  <eric@webkit.org>
    229
  • trunk/WebCore/html/HTMLConstructionSite.cpp

    r62611 r62621  
    7878{
    7979    RefPtr<ChildType> child = prpChild;
     80
     81    if (m_redirectAttachToFosterParent) {
     82        fosterParent(child.get());
     83        return child.release();
     84    }
     85
    8086    parent->parserAddChild(child);
    8187    // It's slightly unfortunate that we need to hold a reference to child
     
    9197    : m_document(document)
    9298    , m_fragmentScriptingPermission(scriptingPermission)
     99    , m_redirectAttachToFosterParent(false)
    93100{
    94101}
     
    167174void HTMLConstructionSite::insertHTMLHtmlElement(AtomicHTMLToken& token)
    168175{
     176    ASSERT(!m_redirectAttachToFosterParent);
    169177    m_openElements.pushHTMLHtmlElement(createElementAndAttachToCurrent(token));
    170178}
     
    172180void HTMLConstructionSite::insertHTMLHeadElement(AtomicHTMLToken& token)
    173181{
     182    ASSERT(!m_redirectAttachToFosterParent);
    174183    m_head = createElementAndAttachToCurrent(token);
    175184    m_openElements.pushHTMLHeadElement(m_head);
     
    178187void HTMLConstructionSite::insertHTMLBodyElement(AtomicHTMLToken& token)
    179188{
     189    ASSERT(!m_redirectAttachToFosterParent);
    180190    m_openElements.pushHTMLBodyElement(createElementAndAttachToCurrent(token));
    181191}
     
    277287}
    278288
    279 void HTMLConstructionSite::fosterParent(Element* element)
     289void HTMLConstructionSite::fosterParent(Node* node)
    280290{
    281291    Element* fosterParentElement = 0;
     
    286296            // FIXME: We need an insertElement which does not send mutation events.
    287297            ExceptionCode ec = 0;
    288             lastTableElement->parent()->insertBefore(element, lastTableElement, ec);
     298            lastTableElement->parent()->insertBefore(node, lastTableElement, ec);
     299            // FIXME: Do we need to call attach()?
    289300            ASSERT(!ec);
    290301            return;
     
    296307    }
    297308
    298     fosterParentElement->parserAddChild(element);
    299 }
    300 
    301 }
     309    fosterParentElement->parserAddChild(node);
     310    // FIXME: Do we need to call attach()?
     311}
     312
     313}
  • trunk/WebCore/html/HTMLConstructionSite.h

    r62618 r62621  
    6464    PassRefPtr<Element> createElement(AtomicHTMLToken&);
    6565
    66     void fosterParent(Element*);
     66    void fosterParent(Node*);
    6767
    6868    bool indexOfFirstUnopenFormattingElement(unsigned& firstUnopenElementIndex) const;
     
    8585    void setForm(PassRefPtr<Element> form) { m_form = form; }
    8686
     87    class RedirectToFosterParentGuard : public Noncopyable {
     88    public:
     89        RedirectToFosterParentGuard(HTMLConstructionSite& tree, bool shouldRedirect)
     90            : m_tree(tree)
     91            , m_wasRedirectingBefore(tree.m_redirectAttachToFosterParent)
     92        {
     93            m_tree.m_redirectAttachToFosterParent = shouldRedirect;
     94        }
     95
     96        ~RedirectToFosterParentGuard()
     97        {
     98            m_tree.m_redirectAttachToFosterParent = m_wasRedirectingBefore;
     99        }
     100
     101    private:
     102        HTMLConstructionSite& m_tree;
     103        bool m_wasRedirectingBefore;
     104    };
     105
    87106private:
     107    friend class RedirectToFosterParentGuard;
     108
    88109    template<typename ChildType>
    89110    PassRefPtr<ChildType> attach(Node* parent, PassRefPtr<ChildType> prpChild);
     
    98119    mutable HTMLFormattingElementList m_activeFormattingElements;
    99120    FragmentScriptingPermission m_fragmentScriptingPermission;
     121
     122    // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#parsing-main-intable
     123    // In the "in table" insertion mode, we sometimes get into a state where
     124    // "whenever a node would be inserted into the current node, it must instead
     125    // be foster parented."  This flag tracks whether we're in that state.
     126    bool m_redirectAttachToFosterParent;
    100127};
    101128
  • trunk/WebCore/html/HTMLTreeBuilder.cpp

    r62618 r62621  
    202202}
    203203
     204bool requiresRedirectToFosterParent(Element* element)
     205{
     206    return element->hasTagName(tableTag)
     207        || isTableBodyContextTag(element->localName())
     208        || element->hasTagName(trTag);
     209}
     210
    204211// http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#formatting
    205212bool isFormattingTag(const AtomicString& tagName)
     
    856863    }
    857864    parseError(token);
    858     if (m_tree.currentElement()->hasTagName(tableTag) || isTableBodyContextTag(m_tree.currentElement()->localName()) || m_tree.currentElement()->hasTagName(trTag))
    859         notImplemented(); // "whenever a node would be inserted into the current node, it must instead be foster parented."
     865    HTMLConstructionSite::RedirectToFosterParentGuard redirecter(m_tree, requiresRedirectToFosterParent(m_tree.currentElement()));
    860866    processStartTagForInBody(token);
    861867}
     
    15791585        return;
    15801586    }
    1581     // FIXME: Do we need to worry about "whenever a node would be inserted into the current node, it must instead be foster parented"?
     1587    // Is this redirection necessary here?
     1588    HTMLConstructionSite::RedirectToFosterParentGuard redirecter(m_tree, requiresRedirectToFosterParent(m_tree.currentElement()));
    15821589    processEndTagForInBody(token);
    15831590}
  • trunk/WebCore/html/HTMLTreeBuilder.h

    r62610 r62621  
    151151
    152152    HTMLElementStack::ElementRecord* furthestBlockForFormattingElement(Element*);
    153     void findFosterParentFor(Element*);
    154153    void reparentChildren(Element* oldParent, Element* newParent);
    155154    void callTheAdoptionAgency(AtomicHTMLToken&);
Note: See TracChangeset for help on using the changeset viewer.