Changeset 147441 in webkit
- Timestamp:
- Apr 2, 2013, 9:14:40 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r147437 r147441 1 2013-04-02 Adam Klein <adamk@chromium.org> 2 3 HTML parser should consistently inspect the namespace of elements on the stack of open elements 4 https://bugs.webkit.org/show_bug.cgi?id=113723 5 6 Reviewed by Adam Barth. 7 8 * html5lib/generated/run-namespace-sensitivity-data-expected.txt: Added. 9 * html5lib/generated/run-namespace-sensitivity-data.html: Added. 10 * html5lib/generated/run-namespace-sensitivity-write-expected.txt: Added. 11 * html5lib/generated/run-namespace-sensitivity-write.html: Added. 12 * html5lib/resources/namespace-sensitivity.dat: Added. 13 1 14 2013-04-02 Andrei Bucur <abucur@adobe.com> 2 15 -
trunk/Source/WebCore/ChangeLog
r147440 r147441 1 2013-04-02 Adam Klein <adamk@chromium.org> 2 3 HTML parser should consistently inspect the namespace of elements on the stack of open elements 4 https://bugs.webkit.org/show_bug.cgi?id=113723 5 6 Reviewed by Adam Barth. 7 8 Added HTMLStackItem::matchesHTMLTag method and use that nearly 9 everywhere instead of HTMLStackItem::hasLocalName. The most important 10 of these changes is in HTMLElementStack's inScopeCommon() function, 11 where the use of matchesHTMLTag means that any of the inXXXScope() 12 calls now only match HTML tags. 13 14 Tests: html5lib/generated/run-namespace-sensitivity-data.html 15 html5lib/generated/run-namespace-sensitivity-write.html 16 17 * html/parser/HTMLConstructionSite.cpp: 18 (WebCore::HTMLConstructionSite::generateImpliedEndTagsWithExclusion): 19 * html/parser/HTMLElementStack.cpp: 20 (WebCore::HTMLElementStack::popUntil): 21 (WebCore::HTMLElementStack::topmost): 22 (WebCore::inScopeCommon): 23 (WebCore::HTMLElementStack::inScope): 24 (WebCore::HTMLElementStack::inListItemScope): 25 (WebCore::HTMLElementStack::inTableScope): 26 (WebCore::HTMLElementStack::inButtonScope): 27 (WebCore::HTMLElementStack::inSelectScope): 28 * html/parser/HTMLElementStack.h: 29 (WebCore::HTMLElementStack::popUntilPopped): 30 * html/parser/HTMLFormattingElementList.cpp: 31 (WebCore::HTMLFormattingElementList::closestElementInScopeWithName): 32 * html/parser/HTMLStackItem.h: 33 (WebCore::HTMLStackItem::matchesHTMLTag): 34 (HTMLStackItem): 35 * html/parser/HTMLTreeBuilder.cpp: 36 (WebCore::HTMLTreeBuilder::HTMLTreeBuilder): 37 (WebCore::HTMLTreeBuilder::processAnyOtherEndTagForInBody): 38 (WebCore::HTMLTreeBuilder::processEndTagForInCell): 39 (WebCore::HTMLTreeBuilder::processEndTagForInBody): 40 1 41 2013-04-02 Hayato Ito <hayato@chromium.org> 2 42 -
trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp
r147281 r147441 597 597 void HTMLConstructionSite::generateImpliedEndTagsWithExclusion(const AtomicString& tagName) 598 598 { 599 while (hasImpliedEndTag(currentStackItem()) && !currentStackItem()-> hasLocalName(tagName))599 while (hasImpliedEndTag(currentStackItem()) && !currentStackItem()->matchesHTMLTag(tagName)) 600 600 m_openElements.pop(); 601 601 } -
trunk/Source/WebCore/html/parser/HTMLElementStack.cpp
r146028 r147441 220 220 void HTMLElementStack::popUntil(const AtomicString& tagName) 221 221 { 222 while (!topStackItem()-> hasLocalName(tagName)) {222 while (!topStackItem()->matchesHTMLTag(tagName)) { 223 223 // pop() will ASSERT if a <body>, <head> or <html> will be popped. 224 224 pop(); … … 226 226 } 227 227 228 void HTMLElementStack::popUntil(const QualifiedName& tagName)229 {230 while (!topStackItem()->hasTagName(tagName)) {231 // pop() will ASSERT if a <body>, <head> or <html> will be popped.232 pop();233 }234 }235 236 228 void HTMLElementStack::popUntilPopped(const AtomicString& tagName) 237 {238 popUntil(tagName);239 pop();240 }241 242 void HTMLElementStack::popUntilPopped(const QualifiedName& tagName)243 229 { 244 230 popUntil(tagName); … … 443 429 { 444 430 for (ElementRecord* pos = m_top.get(); pos; pos = pos->next()) { 445 if (pos->stackItem()-> hasLocalName(tagName))431 if (pos->stackItem()->matchesHTMLTag(tagName)) 446 432 return pos; 447 433 } … … 464 450 for (HTMLElementStack::ElementRecord* pos = top; pos; pos = pos->next()) { 465 451 HTMLStackItem* item = pos->stackItem().get(); 466 if (item->hasLocalName(targetTag)) 467 return true; 468 if (isMarker(item)) 469 return false; 470 } 471 ASSERT_NOT_REACHED(); // <html> is always on the stack and is a scope marker. 472 return false; 473 } 474 475 template <bool isMarker(HTMLStackItem*)> 476 bool inScopeCommon(HTMLElementStack::ElementRecord* top, const QualifiedName& targetTag) 477 { 478 for (HTMLElementStack::ElementRecord* pos = top; pos; pos = pos->next()) { 479 HTMLStackItem* item = pos->stackItem().get(); 480 if (item->hasTagName(targetTag)) 452 if (item->matchesHTMLTag(targetTag)) 481 453 return true; 482 454 if (isMarker(item)) … … 520 492 bool HTMLElementStack::inScope(const QualifiedName& tagName) const 521 493 { 522 // FIXME: Is localName() right for non-html elements?523 494 return inScope(tagName.localName()); 524 495 } … … 531 502 bool HTMLElementStack::inListItemScope(const QualifiedName& tagName) const 532 503 { 533 // FIXME: Is localName() right for non-html elements?534 504 return inListItemScope(tagName.localName()); 535 505 } … … 542 512 bool HTMLElementStack::inTableScope(const QualifiedName& tagName) const 543 513 { 544 return in ScopeCommon<isTableScopeMarker>(m_top.get(), tagName);514 return inTableScope(tagName.localName()); 545 515 } 546 516 … … 552 522 bool HTMLElementStack::inButtonScope(const QualifiedName& tagName) const 553 523 { 554 // FIXME: Is localName() right for non-html elements?555 524 return inButtonScope(tagName.localName()); 556 525 } … … 563 532 bool HTMLElementStack::inSelectScope(const QualifiedName& tagName) const 564 533 { 565 // FIXME: Is localName() right for non-html elements?566 534 return inSelectScope(tagName.localName()); 567 535 } -
trunk/Source/WebCore/html/parser/HTMLElementStack.h
r146028 r147441 117 117 void popUntil(Element*); 118 118 void popUntilPopped(const AtomicString& tagName); 119 120 // FIXME: These are fixes for https://www.w3.org/Bugs/Public/show_bug.cgi?id=21292 121 void popUntil(const QualifiedName&); 122 void popUntilPopped(const QualifiedName&); 119 void popUntilPopped(const QualifiedName& tagName) { popUntilPopped(tagName.localName()); } 123 120 124 121 void popUntilPopped(Element*); -
trunk/Source/WebCore/html/parser/HTMLFormattingElementList.cpp
r145248 r147441 55 55 if (entry.isMarker()) 56 56 return 0; 57 if (entry.stackItem()-> hasLocalName(targetName))57 if (entry.stackItem()->matchesHTMLTag(targetName)) 58 58 return entry.element(); 59 59 } -
trunk/Source/WebCore/html/parser/HTMLStackItem.h
r146904 r147441 78 78 bool hasLocalName(const AtomicString& name) const { return m_tokenLocalName == name; } 79 79 bool hasTagName(const QualifiedName& name) const { return m_tokenLocalName == name.localName() && m_namespaceURI == name.namespaceURI(); } 80 81 bool matchesHTMLTag(const AtomicString& name) const { return m_tokenLocalName == name && m_namespaceURI == HTMLNames::xhtmlNamespaceURI; } 82 bool matchesHTMLTag(const QualifiedName& name) const { return m_tokenLocalName == name && m_namespaceURI == HTMLNames::xhtmlNamespaceURI; } 80 83 81 84 bool causesFosterParenting() -
trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp
r147018 r147441 306 306 307 307 #if ENABLE(TEMPLATE_ELEMENT) 308 if (contextElement->has LocalName(templateTag))308 if (contextElement->hasTagName(templateTag)) 309 309 m_templateInsertionModes.append(TemplateContentsMode); 310 310 #endif … … 1505 1505 while (1) { 1506 1506 RefPtr<HTMLStackItem> item = record->stackItem(); 1507 if (item-> hasLocalName(token->name())) {1507 if (item->matchesHTMLTag(token->name())) { 1508 1508 m_tree.generateImpliedEndTagsWithExclusion(token->name()); 1509 if (!m_tree.currentStackItem()-> hasLocalName(token->name()))1509 if (!m_tree.currentStackItem()->matchesHTMLTag(token->name())) 1510 1510 parseError(token); 1511 1511 m_tree.openElements()->popUntilPopped(item->element()); … … 1785 1785 } 1786 1786 m_tree.generateImpliedEndTags(); 1787 if (!m_tree.currentStackItem()-> hasLocalName(token->name()))1787 if (!m_tree.currentStackItem()->matchesHTMLTag(token->name())) 1788 1788 parseError(token); 1789 1789 m_tree.openElements()->popUntilPopped(token->name()); … … 1860 1860 } 1861 1861 m_tree.generateImpliedEndTags(); 1862 if (!m_tree.currentStackItem()-> hasLocalName(token->name()))1862 if (!m_tree.currentStackItem()->matchesHTMLTag(token->name())) 1863 1863 parseError(token); 1864 1864 m_tree.openElements()->popUntilPopped(token->name()); … … 1885 1885 } 1886 1886 m_tree.generateImpliedEndTagsWithExclusion(token->name()); 1887 if (!m_tree.currentStackItem()-> hasLocalName(token->name()))1887 if (!m_tree.currentStackItem()->matchesHTMLTag(token->name())) 1888 1888 parseError(token); 1889 1889 m_tree.openElements()->popUntilPopped(token->name()); … … 1896 1896 } 1897 1897 m_tree.generateImpliedEndTagsWithExclusion(token->name()); 1898 if (!m_tree.currentStackItem()-> hasLocalName(token->name()))1898 if (!m_tree.currentStackItem()->matchesHTMLTag(token->name())) 1899 1899 parseError(token); 1900 1900 m_tree.openElements()->popUntilPopped(token->name()); … … 1908 1908 } 1909 1909 m_tree.generateImpliedEndTagsWithExclusion(token->name()); 1910 if (!m_tree.currentStackItem()-> hasLocalName(token->name()))1910 if (!m_tree.currentStackItem()->matchesHTMLTag(token->name())) 1911 1911 parseError(token); 1912 1912 m_tree.openElements()->popUntilPopped(token->name()); … … 1919 1919 } 1920 1920 m_tree.generateImpliedEndTags(); 1921 if (!m_tree.currentStackItem()-> hasLocalName(token->name()))1921 if (!m_tree.currentStackItem()->matchesHTMLTag(token->name())) 1922 1922 parseError(token); 1923 1923 m_tree.openElements()->popUntilNumberedHeaderElementPopped(); … … 1936 1936 } 1937 1937 m_tree.generateImpliedEndTags(); 1938 if (!m_tree.currentStackItem()-> hasLocalName(token->name()))1938 if (!m_tree.currentStackItem()->matchesHTMLTag(token->name())) 1939 1939 parseError(token); 1940 1940 m_tree.openElements()->popUntilPopped(token->name());
Note:
See TracChangeset
for help on using the changeset viewer.