Title: [119949] trunk
Revision
119949
Author
[email protected]
Date
2012-06-10 20:58:56 -0700 (Sun, 10 Jun 2012)

Log Message

An inheritance of '-webkit-user-modify' does not stop at shadow boundary.
https://bugs.webkit.org/show_bug.cgi?id=88514

Reviewed by Ryosuke Niwa.

Source/WebCore:

In StyleResolver::styleForElement(), we reset '-webkit-user-modify'
CSS property after inheriting a parent style, but that is not
enough.  We also have to reset '-webkit-user-modify' when we use a
cached result in applying matched properties.

Test: fast/dom/shadow/user-modify-inheritance.html

* css/StyleResolver.cpp:
(WebCore::StyleResolver::applyMatchedProperties):
(WebCore::StyleResolver::styleForElement):
* css/StyleResolver.h:
(StyleResolver):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::inheritFrom):
* rendering/style/RenderStyle.h:

LayoutTests:

* fast/dom/shadow/user-modify-inheritance-expected.txt: Added.
* fast/dom/shadow/user-modify-inheritance.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (119948 => 119949)


--- trunk/LayoutTests/ChangeLog	2012-06-11 02:30:39 UTC (rev 119948)
+++ trunk/LayoutTests/ChangeLog	2012-06-11 03:58:56 UTC (rev 119949)
@@ -1,3 +1,13 @@
+2012-06-10  Hayato Ito  <[email protected]>
+
+        An inheritance of '-webkit-user-modify' does not stop at shadow boundary.
+        https://bugs.webkit.org/show_bug.cgi?id=88514
+
+        Reviewed by Ryosuke Niwa.
+
+        * fast/dom/shadow/user-modify-inheritance-expected.txt: Added.
+        * fast/dom/shadow/user-modify-inheritance.html: Added.
+
 2012-06-10  Yoshifumi Inoue  <[email protected]>
 
         [Forms] Introduce Decimal behind the InputNumber type

Added: trunk/LayoutTests/fast/dom/shadow/user-modify-inheritance-expected.txt (0 => 119949)


--- trunk/LayoutTests/fast/dom/shadow/user-modify-inheritance-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/user-modify-inheritance-expected.txt	2012-06-11 03:58:56 UTC (rev 119949)
@@ -0,0 +1,15 @@
+Tests to ensure that a '-webkit-user-modify' CSS porperty is not inherited across shadow boundaries.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS computedStyle(prepareNodeInShadowRoot(document.getElementById("contenteditable-host1"), null), userModifyPropertyName) is "read-only"
+PASS computedStyle(prepareNodeInShadowRoot(document.getElementById("contenteditable-host2"), "false"), userModifyPropertyName) is "read-only"
+PASS computedStyle(prepareNodeInShadowRoot(document.getElementById("contenteditable-host3"), "true"), userModifyPropertyName) is "read-write"
+PASS computedStyle(prepareNodeInShadowRoot(document.getElementById("non-contenteditable-host1"), null), userModifyPropertyName) is "read-only"
+PASS computedStyle(prepareNodeInShadowRoot(document.getElementById("non-contenteditable-host2"), "false"), userModifyPropertyName) is "read-only"
+PASS computedStyle(prepareNodeInShadowRoot(document.getElementById("non-contenteditable-host3"), "true"), userModifyPropertyName) is "read-write"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/shadow/user-modify-inheritance.html (0 => 119949)


--- trunk/LayoutTests/fast/dom/shadow/user-modify-inheritance.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/shadow/user-modify-inheritance.html	2012-06-11 03:58:56 UTC (rev 119949)
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="contenteditable-host1" contenteditable></div>
+<div id="contenteditable-host2" contenteditable></div>
+<div id="contenteditable-host3" contenteditable></div>
+<div id="non-contenteditable-host1"></div>
+<div id="non-contenteditable-host2"></div>
+<div id="non-contenteditable-host3"></div>
+<pre id="console"></pre>
+<script>
+description("Tests to ensure that a '-webkit-user-modify' CSS porperty is not inherited across shadow boundaries.");
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+
+function computedStyle(element, style) {
+    var cs = window.getComputedStyle(element);
+    if (!cs)
+        return '(NA)';
+    if (cs.getPropertyCSSValue(style))
+        return cs.getPropertyCSSValue(style).cssText;
+    return undefined;
+}
+
+function prepareNodeInShadowRoot(host, contentEditableAttributeValueForNode) {
+    var shadowRoot = new WebKitShadowRoot(host);
+    var nodeInShadow = document.createElement('div');
+    if (contentEditableAttributeValueForNode != null)
+        nodeInShadow.setAttribute('contenteditable', contentEditableAttributeValueForNode);
+    shadowRoot.appendChild(nodeInShadow);
+    document.body.offsetLeft;
+    return nodeInShadow;
+}
+
+var userModifyPropertyName = '-webkit-user-modify';
+
+shouldBeEqualToString('computedStyle(prepareNodeInShadowRoot(document.getElementById("contenteditable-host1"), null), userModifyPropertyName)', 'read-only');
+shouldBeEqualToString('computedStyle(prepareNodeInShadowRoot(document.getElementById("contenteditable-host2"), "false"), userModifyPropertyName)', 'read-only');
+shouldBeEqualToString('computedStyle(prepareNodeInShadowRoot(document.getElementById("contenteditable-host3"), "true"), userModifyPropertyName)', 'read-write');
+shouldBeEqualToString('computedStyle(prepareNodeInShadowRoot(document.getElementById("non-contenteditable-host1"), null), userModifyPropertyName)', 'read-only');
+shouldBeEqualToString('computedStyle(prepareNodeInShadowRoot(document.getElementById("non-contenteditable-host2"), "false"), userModifyPropertyName)', 'read-only');
+shouldBeEqualToString('computedStyle(prepareNodeInShadowRoot(document.getElementById("non-contenteditable-host3"), "true"), userModifyPropertyName)', 'read-write');
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (119948 => 119949)


--- trunk/Source/WebCore/ChangeLog	2012-06-11 02:30:39 UTC (rev 119948)
+++ trunk/Source/WebCore/ChangeLog	2012-06-11 03:58:56 UTC (rev 119949)
@@ -1,3 +1,26 @@
+2012-06-10  Hayato Ito  <[email protected]>
+
+        An inheritance of '-webkit-user-modify' does not stop at shadow boundary.
+        https://bugs.webkit.org/show_bug.cgi?id=88514
+
+        Reviewed by Ryosuke Niwa.
+
+        In StyleResolver::styleForElement(), we reset '-webkit-user-modify'
+        CSS property after inheriting a parent style, but that is not
+        enough.  We also have to reset '-webkit-user-modify' when we use a
+        cached result in applying matched properties.
+
+        Test: fast/dom/shadow/user-modify-inheritance.html
+
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::applyMatchedProperties):
+        (WebCore::StyleResolver::styleForElement):
+        * css/StyleResolver.h:
+        (StyleResolver):
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::RenderStyle::inheritFrom):
+        * rendering/style/RenderStyle.h:
+
 2012-06-10  Yoshifumi Inoue  <[email protected]>
 
         [Forms] Introduce Decimal behind the InputNumber type

Modified: trunk/Source/WebCore/css/StyleResolver.cpp (119948 => 119949)


--- trunk/Source/WebCore/css/StyleResolver.cpp	2012-06-11 02:30:39 UTC (rev 119948)
+++ trunk/Source/WebCore/css/StyleResolver.cpp	2012-06-11 03:58:56 UTC (rev 119949)
@@ -1619,7 +1619,7 @@
     return documentStyle.release();
 }
 
-static inline bool isAtShadowBoundary(Element* element)
+static inline bool isAtShadowBoundary(const Element* element)
 {
     if (!element)
         return false;
@@ -1654,7 +1654,7 @@
     m_style = RenderStyle::create();
 
     if (m_parentStyle)
-        m_style->inheritFrom(m_parentStyle);
+        m_style->inheritFrom(m_parentStyle, isAtShadowBoundary(element) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary);
     else {
         m_parentStyle = style();
         // Make sure our fonts are initialized if we don't inherit them from our parent style.
@@ -1665,10 +1665,6 @@
             m_style->font().update(0);
     }
 
-    // Even if surrounding content is user-editable, shadow DOM should act as a single unit, and not necessarily be editable
-    if (isAtShadowBoundary(element))
-        m_style->setUserModify(RenderStyle::initialUserModify());
-
     if (element->isLink()) {
         m_style->setIsLink(true);
         m_style->setInsideLink(m_elementLinkState);
@@ -1682,7 +1678,7 @@
     else
         matchAllRules(matchResult, matchingBehavior != MatchAllRulesExcludingSMIL);
 
-    applyMatchedProperties(matchResult);
+    applyMatchedProperties(matchResult, element);
 
     // Clean up our style object's display and text decorations (among other fixups).
     adjustRenderStyle(style(), m_parentStyle, element);
@@ -1843,7 +1839,7 @@
 
     m_style->setStyleType(pseudo);
 
-    applyMatchedProperties(matchResult);
+    applyMatchedProperties(matchResult, e);
 
     // Clean up our style object's display and text decorations (among other fixups).
     adjustRenderStyle(style(), parentStyle, 0);
@@ -2823,8 +2819,9 @@
     return true;
 }
 
-void StyleResolver::applyMatchedProperties(const MatchResult& matchResult)
+void StyleResolver::applyMatchedProperties(const MatchResult& matchResult, const Element* element)
 {
+    ASSERT(element);
     unsigned cacheHash = matchResult.isCacheable ? computeMatchedPropertiesHash(matchResult.matchedProperties.data(), matchResult.matchedProperties.size()) : 0;
     bool applyInheritedOnly = false;
     const MatchedPropertiesCacheItem* cacheItem = 0;
@@ -2837,7 +2834,7 @@
             EInsideLink linkStatus = m_style->insideLink();
             // If the cache item parent style has identical inherited properties to the current parent style then the
             // resulting style will be identical too. We copy the inherited properties over from the cache and are done.
-            m_style->inheritFrom(cacheItem->renderStyle.get());
+            m_style->inheritFrom(cacheItem->renderStyle.get(), isAtShadowBoundary(element) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary);
             // Unfortunately the link status is treated like an inherited property. We need to explicitly restore it.
             m_style->setInsideLink(linkStatus);
             return;

Modified: trunk/Source/WebCore/css/StyleResolver.h (119948 => 119949)


--- trunk/Source/WebCore/css/StyleResolver.h	2012-06-11 02:30:39 UTC (rev 119948)
+++ trunk/Source/WebCore/css/StyleResolver.h	2012-06-11 03:58:56 UTC (rev 119949)
@@ -353,7 +353,7 @@
 
     bool checkSelector(const RuleData&, const ContainerNode* scope = 0);
     bool checkRegionSelector(CSSSelector* regionSelector, Element* regionElement);
-    void applyMatchedProperties(const MatchResult&);
+    void applyMatchedProperties(const MatchResult&, const Element*);
     enum StyleApplicationPass {
         HighPriorityProperties,
         LowPriorityProperties

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (119948 => 119949)


--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2012-06-11 02:30:39 UTC (rev 119948)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2012-06-11 03:58:56 UTC (rev 119949)
@@ -162,9 +162,15 @@
 {
 }
 
-void RenderStyle::inheritFrom(const RenderStyle* inheritParent)
+void RenderStyle::inheritFrom(const RenderStyle* inheritParent, IsAtShadowBoundary isAtShadowBoundary)
 {
-    rareInheritedData = inheritParent->rareInheritedData;
+    if (isAtShadowBoundary == AtShadowBoundary) {
+        // Even if surrounding content is user-editable, shadow DOM should act as a single unit, and not necessarily be editable
+        EUserModify currentUserModify = userModify();
+        rareInheritedData = inheritParent->rareInheritedData;
+        setUserModify(currentUserModify);
+    } else
+        rareInheritedData = inheritParent->rareInheritedData;
     inherited = inheritParent->inherited;
     inherited_flags = inheritParent->inherited_flags;
 #if ENABLE(SVG)

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (119948 => 119949)


--- trunk/Source/WebCore/rendering/style/RenderStyle.h	2012-06-11 02:30:39 UTC (rev 119948)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h	2012-06-11 03:58:56 UTC (rev 119949)
@@ -390,7 +390,12 @@
     static PassRefPtr<RenderStyle> createAnonymousStyleWithDisplay(const RenderStyle* parentStyle, EDisplay);
     static PassRefPtr<RenderStyle> clone(const RenderStyle*);
 
-    void inheritFrom(const RenderStyle* inheritParent);
+    enum IsAtShadowBoundary {
+        AtShadowBoundary,
+        NotAtShadowBoundary,
+    };
+
+    void inheritFrom(const RenderStyle* inheritParent, IsAtShadowBoundary = NotAtShadowBoundary);
     void copyNonInheritedFrom(const RenderStyle*);
 
     PseudoId styleType() const { return static_cast<PseudoId>(noninherited_flags._styleType); }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to