Title: [114334] trunk
Revision
114334
Author
commit-qu...@webkit.org
Date
2012-04-16 19:55:40 -0700 (Mon, 16 Apr 2012)

Log Message

[Shadow DOM] InsertionPoint should have isActive() member function.
https://bugs.webkit.org/show_bug.cgi?id=82010

Patch by Takashi Sakamoto <ta...@google.com> on 2012-04-16
Reviewed by Hajime Morita.

This patch adds isActive public member function to InsertionPoint and
makes InsertionPoint elements consider whether active or not.
If an InsertionPoint is inactive, the element is not shadow boundary
and is needed to be rendered.
c.f. https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#dfn-active-insertion-point

Test: update existing tests, i.e.
LayoutTests/fast/dom/shadow/shadow-contents-fallback-dynamic.html and
LayoutTests/fast/dom/shadow/shadow-contents-fallback.html

* html/shadow/InsertionPoint.cpp:
(WebCore::InsertionPoint::isActive):
A new public method for checking whether an insertion point is active or inactive.
If active, returns true. Otherwise, false.
(WebCore::InsertionPoint::isShadowBoundary):
Make the method consider whether an insertin point is active or inactive.
(WebCore::InsertionPoint::rendererIsNeeded):
Changed to return true If an insertion point is inactive.
(WebCore::InsertionPoint::attach):
Changed to call only HTMLElement::attach If an insertion point is inactive.
(WebCore::InsertionPoint::detach):
Changed to call only HTMLElement::detach If an insertion point is inactive.
* html/shadow/InsertionPoint.h:
(InsertionPoint):
Added isActive public method.
* dom/NodeRenderingContext.cpp:
(WebCore::NodeRenderingContext::NodeRenderingContext):
Changed to take into account an insertion point's activeness when parent is an insertion point.
(WebCore::NodeRenderingContext::firstRendererOf):
(WebCore::NodeRenderingContext::lastRendererOf):
Changed to take into account an insertion point's activeness.

Modified Paths

Diff

Modified: trunk/LayoutTests/fast/dom/shadow/shadow-contents-fallback-dynamic.html (114333 => 114334)


--- trunk/LayoutTests/fast/dom/shadow/shadow-contents-fallback-dynamic.html	2012-04-17 02:15:18 UTC (rev 114333)
+++ trunk/LayoutTests/fast/dom/shadow/shadow-contents-fallback-dynamic.html	2012-04-17 02:55:40 UTC (rev 114334)
@@ -342,7 +342,7 @@
 
 function testContentInContent(callIfDone) {
     document.getElementById('expect-container').innerHTML =
-        "<div>{SHADOW: <span>S1</span><span>S2</span>}</div>";
+        "<div>{SHADOW: <content><span>CONTENT 2 FALLBACK</span></content>}</div>";
 
     var target = document.createElement('div');
     target.appendChild(createSpanWithText('S1'));
@@ -373,7 +373,7 @@
 
 function testContentInContentFallback(callIfDone) {
     document.getElementById('expect-container').innerHTML =
-        "<div>{SHADOW: <span>CONTENT 2 FALLBACK</span>}</div>";
+        "<div>{SHADOW: <content><span>CONTENT 2 FALLBACK</span></content>}</div>";
 
     var target = document.createElement('div');
     target.appendChild(createSpanWithText('S1'));
@@ -404,7 +404,7 @@
 
 function testContentInContentFallbackDirect(callIfDone) {
     document.getElementById('expect-container').innerHTML =
-        "<div><span>CONTENT 2 FALLBACK</span></div>";
+        "<div><content><span>CONTENT 2 FALLBACK</span></content></div>";
 
     var target = document.createElement('div');
     target.appendChild(createSpanWithText('S1'));

Modified: trunk/LayoutTests/fast/dom/shadow/shadow-contents-fallback.html (114333 => 114334)


--- trunk/LayoutTests/fast/dom/shadow/shadow-contents-fallback.html	2012-04-17 02:15:18 UTC (rev 114333)
+++ trunk/LayoutTests/fast/dom/shadow/shadow-contents-fallback.html	2012-04-17 02:55:40 UTC (rev 114334)
@@ -267,7 +267,7 @@
 
     document.getElementById('actual-container').appendChild(target);
     document.getElementById('expect-container').innerHTML =
-        "<div>{SHADOW: <span>S1</span><span>S2</span>}</div>";
+        "<div>{SHADOW: <content><span>CONTENT 2 FALLBACK</span></content>}</div>";
 }
 
 function testContentInContentFallback() {
@@ -290,7 +290,7 @@
 
     document.getElementById('actual-container').appendChild(target);
     document.getElementById('expect-container').innerHTML =
-        "<div>{SHADOW: <span>CONTENT 2 FALLBACK</span>}</div>";
+        "<div>{SHADOW: <content><span>CONTENT 2 FALLBACK</span></content>}</div>";
 }
 
 function testContentInContentFallbackWithDisplayNone() {
@@ -316,7 +316,7 @@
 
     document.getElementById('actual-container').appendChild(target);
     document.getElementById('expect-container').innerHTML =
-        "<div>{SHADOW: <span>CONTENT 2 FALLBACK</span>}</div>";
+        "<div>{SHADOW: <content><span>CONTENT 2 FALLBACK</span></content>}</div>";
 }
 
 function testContentInContentFallbackDirect() {
@@ -337,7 +337,7 @@
 
     document.getElementById('actual-container').appendChild(target);
     document.getElementById('expect-container').innerHTML =
-        "<div><span>CONTENT 2 FALLBACK</span></div>";
+        "<div><content><span>CONTENT 2 FALLBACK</span></content></div>";
 }
 
 var testFuncs = [

Modified: trunk/Source/WebCore/ChangeLog (114333 => 114334)


--- trunk/Source/WebCore/ChangeLog	2012-04-17 02:15:18 UTC (rev 114333)
+++ trunk/Source/WebCore/ChangeLog	2012-04-17 02:55:40 UTC (rev 114334)
@@ -1,3 +1,42 @@
+2012-04-16  Takashi Sakamoto  <ta...@google.com>
+
+        [Shadow DOM] InsertionPoint should have isActive() member function.
+        https://bugs.webkit.org/show_bug.cgi?id=82010
+
+        Reviewed by Hajime Morita.
+
+        This patch adds isActive public member function to InsertionPoint and
+        makes InsertionPoint elements consider whether active or not.
+        If an InsertionPoint is inactive, the element is not shadow boundary
+        and is needed to be rendered.
+        c.f. https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#dfn-active-insertion-point
+
+        Test: update existing tests, i.e.
+        LayoutTests/fast/dom/shadow/shadow-contents-fallback-dynamic.html and
+        LayoutTests/fast/dom/shadow/shadow-contents-fallback.html
+
+        * html/shadow/InsertionPoint.cpp:
+        (WebCore::InsertionPoint::isActive):
+        A new public method for checking whether an insertion point is active or inactive.
+        If active, returns true. Otherwise, false.
+        (WebCore::InsertionPoint::isShadowBoundary):
+        Make the method consider whether an insertin point is active or inactive.
+        (WebCore::InsertionPoint::rendererIsNeeded):
+        Changed to return true If an insertion point is inactive.
+        (WebCore::InsertionPoint::attach):
+        Changed to call only HTMLElement::attach If an insertion point is inactive.
+        (WebCore::InsertionPoint::detach):
+        Changed to call only HTMLElement::detach If an insertion point is inactive.
+        * html/shadow/InsertionPoint.h:
+        (InsertionPoint):
+        Added isActive public method.
+        * dom/NodeRenderingContext.cpp:
+        (WebCore::NodeRenderingContext::NodeRenderingContext):
+        Changed to take into account an insertion point's activeness when parent is an insertion point.
+        (WebCore::NodeRenderingContext::firstRendererOf):
+        (WebCore::NodeRenderingContext::lastRendererOf):
+        Changed to take into account an insertion point's activeness.
+
 2012-04-16  MORITA Hajime  <morr...@google.com>
 
         Type tags in NodeFlags could be compressed

Modified: trunk/Source/WebCore/dom/NodeRenderingContext.cpp (114333 => 114334)


--- trunk/Source/WebCore/dom/NodeRenderingContext.cpp	2012-04-17 02:15:18 UTC (rev 114333)
+++ trunk/Source/WebCore/dom/NodeRenderingContext.cpp	2012-04-17 02:55:40 UTC (rev 114334)
@@ -101,7 +101,11 @@
                 m_phase = AttachingNotFallbacked;
             else
                 m_phase = AttachingFallbacked;
-            m_parentNodeForRenderingAndStyle = NodeRenderingContext(parent).parentNodeForRenderingAndStyle();
+
+            if (toInsertionPoint(parent)->isActive())
+                m_parentNodeForRenderingAndStyle = NodeRenderingContext(parent).parentNodeForRenderingAndStyle();
+            else
+                m_parentNodeForRenderingAndStyle = parent;
             return;
         }
     }
@@ -202,7 +206,7 @@
             return node->renderer();
         }
 
-        if (isInsertionPoint(node)) {
+        if (isInsertionPoint(node) && toInsertionPoint(node)->isActive()) {
             if (RenderObject* first = firstRendererOfInsertionPoint(toInsertionPoint(node)))
                 return first;
         }
@@ -220,7 +224,7 @@
                 continue;
             return node->renderer();
         }
-        if (isInsertionPoint(node)) {
+        if (isInsertionPoint(node) && toInsertionPoint(node)->isActive()) {
             if (RenderObject* last = lastRendererOfInsertionPoint(toInsertionPoint(node)))
                 return last;
         }

Modified: trunk/Source/WebCore/html/shadow/InsertionPoint.cpp (114333 => 114334)


--- trunk/Source/WebCore/html/shadow/InsertionPoint.cpp	2012-04-17 02:15:18 UTC (rev 114333)
+++ trunk/Source/WebCore/html/shadow/InsertionPoint.cpp	2012-04-17 02:55:40 UTC (rev 114334)
@@ -48,9 +48,8 @@
 
 void InsertionPoint::attach()
 {
-    TreeScope* scope = treeScope();
-    if (scope->rootNode()->isShadowRoot()) {
-        ShadowRoot* root = toShadowRoot(scope->rootNode());
+    if (isShadowBoundary()) {
+        ShadowRoot* root = toShadowRoot(treeScope()->rootNode());
         if (doesSelectFromHostChildren()) {
             distributeHostChildren(root->tree());
             attachDistributedNode();
@@ -66,7 +65,8 @@
 
 void InsertionPoint::detach()
 {
-    if (ShadowRoot* root = toShadowRoot(shadowTreeRootNode())) {
+    ShadowRoot* root = toShadowRoot(shadowTreeRootNode());
+    if (root && isActive()) {
         ShadowTree* tree = root->tree();
 
         if (doesSelectFromHostChildren())
@@ -97,9 +97,21 @@
 
 bool InsertionPoint::isShadowBoundary() const
 {
-    return treeScope()->rootNode()->isShadowRoot();
+    return treeScope()->rootNode()->isShadowRoot() && isActive();
 }
 
+bool InsertionPoint::isActive() const
+{
+    const Node* node = parentNode();
+    while (node) {
+        if (WebCore::isInsertionPoint(node))
+            return false;
+
+        node = node->parentNode();
+    }
+    return true;
+}
+
 bool InsertionPoint::rendererIsNeeded(const NodeRenderingContext& context)
 {
     return !isShadowBoundary() && HTMLElement::rendererIsNeeded(context);

Modified: trunk/Source/WebCore/html/shadow/InsertionPoint.h (114333 => 114334)


--- trunk/Source/WebCore/html/shadow/InsertionPoint.h	2012-04-17 02:15:18 UTC (rev 114333)
+++ trunk/Source/WebCore/html/shadow/InsertionPoint.h	2012-04-17 02:55:40 UTC (rev 114334)
@@ -45,6 +45,7 @@
     const HTMLContentSelectionList* selections() const { return &m_selections; }
     bool hasSelection() const { return m_selections.first(); }
     bool isShadowBoundary() const;
+    bool isActive() const;
 
     virtual const AtomicString& select() const = 0;
     virtual bool isSelectValid() const = 0;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to