Title: [123570] trunk
Revision
123570
Author
[email protected]
Date
2012-07-24 21:13:41 -0700 (Tue, 24 Jul 2012)

Log Message

https://bugs.webkit.org/show_bug.cgi?id=89179
Rendering LI having Shadow DOM seems weird

Reviewed by Dimitri Glazkov.

Source/WebCore:

This incorrect rendering happend because HTMLLIElement::attach()
wasn't aware of composed shadow subtree. This change makes it
aware of that using ComposedShadowTreeParentWalker.

Test: fast/dom/shadow/shadow-and-list-elements.html

* html/HTMLLIElement.cpp:
(WebCore::HTMLLIElement::attach):

LayoutTests:

* fast/dom/shadow/shadow-and-list-elements-expected.html: Added.
* fast/dom/shadow/shadow-and-list-elements.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (123569 => 123570)


--- trunk/LayoutTests/ChangeLog	2012-07-25 03:25:58 UTC (rev 123569)
+++ trunk/LayoutTests/ChangeLog	2012-07-25 04:13:41 UTC (rev 123570)
@@ -1,3 +1,13 @@
+2012-07-24  MORITA Hajime  <[email protected]>
+
+        https://bugs.webkit.org/show_bug.cgi?id=89179
+        Rendering LI having Shadow DOM seems weird
+
+        Reviewed by Dimitri Glazkov.
+
+        * fast/dom/shadow/shadow-and-list-elements-expected.html: Added.
+        * fast/dom/shadow/shadow-and-list-elements.html: Added.
+
 2012-07-24  Jer Noble  <[email protected]>
 
         setting playbackRate on a MediaController doesn't change the playbackRate for slaved media

Added: trunk/LayoutTests/fast/dom/shadow/shadow-and-list-elements-expected.html (0 => 123570)


--- trunk/LayoutTests/fast/dom/shadow/shadow-and-list-elements-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/shadow-and-list-elements-expected.html	2012-07-25 04:13:41 UTC (rev 123570)
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+<body>
+<div>
+  <ol>
+    <li>A</li>
+    <li id="hostEquivalent"></li>
+    <li>C</li>
+  </ol>
+</div>
+<script>
+// We cannot use hostEquivalent.innerHTML instead of appendChild()s becuase
+// the parser prevents to create expected tree:
+//
+// <ol>
+//   <li>A</li>
+//   <li>
+//      <li>X</li>
+//      <ul>B</ul>
+//      <li>Y</li>
+//   </li>
+//   <li>C</li>
+// </ol>   
+var hostEquivalent = document.getElementById("hostEquivalent");
+
+var childX = document.createElement("li");
+childX.innerHTML = "X";
+hostEquivalent.appendChild(childX);
+
+var childUl = document.createElement("ul");
+childUl.innerHTML = "B";
+hostEquivalent.appendChild(childUl);
+
+var childY = document.createElement("li");
+childY.innerHTML = "Y";
+hostEquivalent.appendChild(childY);
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/fast/dom/shadow/shadow-and-list-elements.html (0 => 123570)


--- trunk/LayoutTests/fast/dom/shadow/shadow-and-list-elements.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/shadow-and-list-elements.html	2012-07-25 04:13:41 UTC (rev 123570)
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+/* 
+ * To fill missing UA styles which appears in the expected.html through the "li ul" selector in html.css.
+ * Following <ul> crosses shadow boundary and doesn't match it.
+ * https://bugs.webkit.org/show_bug.cgi?id=92192
+ */
+ul {
+   -webkit-margin-before: 0px;
+   -webkit-margin-after: 0px;
+}
+</style>
+</head>
+<body>
+<div>
+  <ol>
+    <li>A</li>
+    <li id="host">B</li>
+    <li>C</li>
+  </ol>
+</div>
+<script>
+// The tree to be created:
+//
+// <ol>
+//   <li>A</li>
+//   <li>B
+//      #shadow-root
+//        <li>X</li>
+//        <ul><shadow></shadow></ul>
+//        <li>Y</li>
+//   </li>
+//   <li>C</li>
+// </ol>   
+var host = document.getElementById("host");
+var shadow = new WebKitShadowRoot(host);
+shadow.applyAuthorStyles = true;
+shadow.innerHTML = "<li>X</li><ul><shadow></shadow></ul><li>Y</li>";
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (123569 => 123570)


--- trunk/Source/WebCore/ChangeLog	2012-07-25 03:25:58 UTC (rev 123569)
+++ trunk/Source/WebCore/ChangeLog	2012-07-25 04:13:41 UTC (rev 123570)
@@ -1,3 +1,19 @@
+2012-07-24  MORITA Hajime  <[email protected]>
+
+        https://bugs.webkit.org/show_bug.cgi?id=89179
+        Rendering LI having Shadow DOM seems weird
+
+        Reviewed by Dimitri Glazkov.
+
+        This incorrect rendering happend because HTMLLIElement::attach()
+        wasn't aware of composed shadow subtree. This change makes it
+        aware of that using ComposedShadowTreeParentWalker.
+
+        Test: fast/dom/shadow/shadow-and-list-elements.html
+
+        * html/HTMLLIElement.cpp:
+        (WebCore::HTMLLIElement::attach):
+
 2012-07-24  Alec Flett  <[email protected]>
 
         IndexedDB: fix #include dependencies so IDBRequest isn't an include root

Modified: trunk/Source/WebCore/html/HTMLLIElement.cpp (123569 => 123570)


--- trunk/Source/WebCore/html/HTMLLIElement.cpp	2012-07-25 03:25:58 UTC (rev 123569)
+++ trunk/Source/WebCore/html/HTMLLIElement.cpp	2012-07-25 04:13:41 UTC (rev 123570)
@@ -26,6 +26,7 @@
 #include "Attribute.h"
 #include "CSSPropertyNames.h"
 #include "CSSValueKeywords.h"
+#include "ComposedShadowTreeWalker.h"
 #include "HTMLNames.h"
 #include "RenderListItem.h"
 
@@ -95,10 +96,13 @@
 
         // Find the enclosing list node.
         Node* listNode = 0;
-        Node* n = this;
-        while (!listNode && (n = n->parentNode())) {
-            if (n->hasTagName(ulTag) || n->hasTagName(olTag))
-                listNode = n;
+        ComposedShadowTreeParentWalker walker(this);
+        while (!listNode) {
+            walker.parentIncludingInsertionPointAndShadowRoot();
+            if (!walker.get())
+                break;
+            if (walker.get()->hasTagName(ulTag) || walker.get()->hasTagName(olTag))
+                listNode = walker.get();
         }
 
         // If we are not in a list, tell the renderer so it can position us inside.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to