Title: [124465] trunk
- Revision
- 124465
- Author
- [email protected]
- Date
- 2012-08-02 09:11:50 -0700 (Thu, 02 Aug 2012)
Log Message
Check if the last table element's parent node is an element when determining the foster parent element.
https://bugs.webkit.org/show_bug.cgi?id=92977
Patch by Kwang Yul Seo <[email protected]> on 2012-08-02
Reviewed by Adam Barth.
Source/WebCore:
According to the HTML5 spec, if the last table element in the stack of open elements has no parent,
or ITS PARENT NODE IS NOT AN ELEMENT, then the foster parent element is the element
before the last table element in the stack of open elements.
Changed to check if the table element's parent node is an element.
Test: fast/parser/foster-parent.html
* html/parser/HTMLConstructionSite.cpp:
(WebCore::HTMLConstructionSite::findFosterSite):
LayoutTests:
This new test changes the table element's parent node to a newly created document fragment node.
Because a document fragment node is not an element, the foster parent element must be the element
before the last table element in the stack of open elements.
* fast/parser/foster-parent-expected.txt: Added.
* fast/parser/foster-parent.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (124464 => 124465)
--- trunk/LayoutTests/ChangeLog 2012-08-02 16:09:32 UTC (rev 124464)
+++ trunk/LayoutTests/ChangeLog 2012-08-02 16:11:50 UTC (rev 124465)
@@ -1,3 +1,17 @@
+2012-08-02 Kwang Yul Seo <[email protected]>
+
+ Check if the last table element's parent node is an element when determining the foster parent element.
+ https://bugs.webkit.org/show_bug.cgi?id=92977
+
+ Reviewed by Adam Barth.
+
+ This new test changes the table element's parent node to a newly created document fragment node.
+ Because a document fragment node is not an element, the foster parent element must be the element
+ before the last table element in the stack of open elements.
+
+ * fast/parser/foster-parent-expected.txt: Added.
+ * fast/parser/foster-parent.html: Added.
+
2012-08-02 Antti Koivisto <[email protected]>
Inline stylesheets can confuse style sharing
Added: trunk/LayoutTests/fast/parser/foster-parent-expected.txt (0 => 124465)
--- trunk/LayoutTests/fast/parser/foster-parent-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/parser/foster-parent-expected.txt 2012-08-02 16:11:50 UTC (rev 124465)
@@ -0,0 +1,3 @@
+Otherwise, if there is a table element in the stack of open elements, but the last table element in the stack of open elements has no parent, or its parent node is not an element, then the foster parent element is the element before the last table element in the stack of open elements.
+
+success
Added: trunk/LayoutTests/fast/parser/foster-parent.html (0 => 124465)
--- trunk/LayoutTests/fast/parser/foster-parent.html (rev 0)
+++ trunk/LayoutTests/fast/parser/foster-parent.html 2012-08-02 16:11:50 UTC (rev 124465)
@@ -0,0 +1,30 @@
+<html>
+<body>
+<script>
+if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+</script>
+
+<div id="div">
+ <table id="table">
+ <script>
+ var table = document.getElementById('table');
+ table.parentNode.removeChild(table);
+ var docFragment = document.createDocumentFragment();
+ docFragment.appendChild(table);
+ </script>
+ <h1 id="h1">Otherwise, if there is a table element in the stack of open elements, but the last table element in the stack of open elements has no parent, or its parent node is not an element, then the foster parent element is the element before the last table element in the stack of open elements.</h1>
+ </table>
+</div>
+
+<script>
+var div = document.getElementById('div');
+var h1 = document.getElementById('h1');
+
+if (h1 && h1 === div.firstElementChild)
+ document.write("success");
+else
+ document.write("failure");
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (124464 => 124465)
--- trunk/Source/WebCore/ChangeLog 2012-08-02 16:09:32 UTC (rev 124464)
+++ trunk/Source/WebCore/ChangeLog 2012-08-02 16:11:50 UTC (rev 124465)
@@ -1,3 +1,21 @@
+2012-08-02 Kwang Yul Seo <[email protected]>
+
+ Check if the last table element's parent node is an element when determining the foster parent element.
+ https://bugs.webkit.org/show_bug.cgi?id=92977
+
+ Reviewed by Adam Barth.
+
+ According to the HTML5 spec, if the last table element in the stack of open elements has no parent,
+ or ITS PARENT NODE IS NOT AN ELEMENT, then the foster parent element is the element
+ before the last table element in the stack of open elements.
+
+ Changed to check if the table element's parent node is an element.
+
+ Test: fast/parser/foster-parent.html
+
+ * html/parser/HTMLConstructionSite.cpp:
+ (WebCore::HTMLConstructionSite::findFosterSite):
+
2012-08-02 Philippe Normand <[email protected]>
[GStreamer] Use GST_DEBUG instead of LOG_VERBOSE
Modified: trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp (124464 => 124465)
--- trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp 2012-08-02 16:09:32 UTC (rev 124464)
+++ trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp 2012-08-02 16:11:50 UTC (rev 124465)
@@ -476,7 +476,10 @@
HTMLElementStack::ElementRecord* lastTableElementRecord = m_openElements.topmost(tableTag.localName());
if (lastTableElementRecord) {
Element* lastTableElement = lastTableElementRecord->element();
- if (ContainerNode* parent = lastTableElement->parentNode()) {
+ ContainerNode* parent = lastTableElement->parentNode();
+ // When parsing HTML fragments, we skip step 4.2 ("Let root be a new html element with no attributes") for efficiency,
+ // and instead use the DocumentFragment as a root node. So we must treat the root node (DocumentFragment) as if it is a html element here.
+ if (parent && (parent->isElementNode() || (m_isParsingFragment && parent == m_openElements.rootNode()))) {
task.parent = parent;
task.nextChild = lastTableElement;
return;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes