Title: [199060] trunk
- Revision
- 199060
- Author
- [email protected]
- Date
- 2016-04-05 09:45:51 -0700 (Tue, 05 Apr 2016)
Log Message
Shadow DOM: :host() From The First Shadow Context Should Not Style All Shadow Context
https://bugs.webkit.org/show_bug.cgi?id=156235
<rdar://problem/24668206>
Reviewed by Andreas Kling.
Source/WebCore:
Test: fast/shadow-dom/host-style-sharing.html
* style/StyleSharingResolver.cpp:
(WebCore::Style::SharingResolver::resolve):
(WebCore::Style::SharingResolver::canShareStyleWithElement):
Disallow style sharing for shadow hosts affected by :host pseudo class rules.
LayoutTests:
* fast/shadow-dom/host-style-sharing-expected.html: Added.
* fast/shadow-dom/host-style-sharing.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (199059 => 199060)
--- trunk/LayoutTests/ChangeLog 2016-04-05 16:22:39 UTC (rev 199059)
+++ trunk/LayoutTests/ChangeLog 2016-04-05 16:45:51 UTC (rev 199060)
@@ -1,5 +1,16 @@
2016-04-05 Antti Koivisto <[email protected]>
+ Shadow DOM: :host() From The First Shadow Context Should Not Style All Shadow Context
+ https://bugs.webkit.org/show_bug.cgi?id=156235
+ <rdar://problem/24668206>
+
+ Reviewed by Andreas Kling.
+
+ * fast/shadow-dom/host-style-sharing-expected.html: Added.
+ * fast/shadow-dom/host-style-sharing.html: Added.
+
+2016-04-05 Antti Koivisto <[email protected]>
+
Use RenderTreeUpdater for text node mutations
https://bugs.webkit.org/show_bug.cgi?id=156107
Added: trunk/LayoutTests/fast/shadow-dom/host-style-sharing-expected.html (0 => 199060)
--- trunk/LayoutTests/fast/shadow-dom/host-style-sharing-expected.html (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/host-style-sharing-expected.html 2016-04-05 16:45:51 UTC (rev 199060)
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title></title>
+ </head>
+ <body>
+ <style>
+ #host1 { border: 1px solid #f09; }
+ #host2 { border: 1px solid #000; }
+ </style>
+
+ <template id="for-host-1">
+ I ♥ <slot name="what-I-love"><slot>
+ </template>
+
+ <template id="for-host-2">
+ I <strike>♥</strike> <slot name="what-I-hate"><slot>
+ </template>
+
+ <div id="host1">
+ <span name="what-I-love">Shadow DOM<span>
+ </div>
+
+ <div id="host2">
+ <span name="what-I-hate">Shadow DOM<span>
+ </div>
+
+ <script>
+ var host1 = document.querySelector('#host1');
+ var host1ShadowRoot = host1.attachShadow({mode: 'closed'});
+ var host1ShadowContent = document.importNode(document.querySelector('#for-host-1').content, true);
+ host1ShadowRoot.appendChild(host1ShadowContent);
+
+ var host2 = document.querySelector('#host2');
+ var host2ShadowRoot = host2.attachShadow({mode: 'closed'});
+ var host2ShadowContent = document.importNode(document.querySelector('#for-host-2').content, true);
+ host2ShadowRoot.appendChild(host2ShadowContent);
+ </script>
+ </body>
+</html>
Added: trunk/LayoutTests/fast/shadow-dom/host-style-sharing.html (0 => 199060)
--- trunk/LayoutTests/fast/shadow-dom/host-style-sharing.html (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/host-style-sharing.html 2016-04-05 16:45:51 UTC (rev 199060)
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title></title>
+ </head>
+ <body>
+ <template id="for-host-1">
+ <style>
+ :host { border: 1px solid #f09; }
+ </style>
+ I ♥ <slot name="what-I-love"><slot>
+ </template>
+
+ <template id="for-host-2">
+ <style>
+ :host { border: 1px solid #000; }
+ </style>
+ I <strike>♥</strike> <slot name="what-I-hate"><slot>
+ </template>
+
+ <div id="host1">
+ <span name="what-I-love">Shadow DOM<span>
+ </div>
+
+ <div id="host2">
+ <span name="what-I-hate">Shadow DOM<span>
+ </div>
+
+ <script>
+ var host1 = document.querySelector('#host1');
+ var host1ShadowRoot = host1.attachShadow({mode: 'closed'});
+ var host1ShadowContent = document.importNode(document.querySelector('#for-host-1').content, true);
+ host1ShadowRoot.appendChild(host1ShadowContent);
+
+ var host2 = document.querySelector('#host2');
+ var host2ShadowRoot = host2.attachShadow({mode: 'closed'});
+ var host2ShadowContent = document.importNode(document.querySelector('#for-host-2').content, true);
+ host2ShadowRoot.appendChild(host2ShadowContent);
+ </script>
+ </body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (199059 => 199060)
--- trunk/Source/WebCore/ChangeLog 2016-04-05 16:22:39 UTC (rev 199059)
+++ trunk/Source/WebCore/ChangeLog 2016-04-05 16:45:51 UTC (rev 199060)
@@ -1,3 +1,19 @@
+2016-04-05 Antti Koivisto <[email protected]>
+
+ Shadow DOM: :host() From The First Shadow Context Should Not Style All Shadow Context
+ https://bugs.webkit.org/show_bug.cgi?id=156235
+ <rdar://problem/24668206>
+
+ Reviewed by Andreas Kling.
+
+ Test: fast/shadow-dom/host-style-sharing.html
+
+ * style/StyleSharingResolver.cpp:
+ (WebCore::Style::SharingResolver::resolve):
+ (WebCore::Style::SharingResolver::canShareStyleWithElement):
+
+ Disallow style sharing for shadow hosts affected by :host pseudo class rules.
+
2016-04-05 Alex Christensen <[email protected]>
Speculative build fix after r199043
Modified: trunk/Source/WebCore/style/StyleSharingResolver.cpp (199059 => 199060)
--- trunk/Source/WebCore/style/StyleSharingResolver.cpp 2016-04-05 16:22:39 UTC (rev 199059)
+++ trunk/Source/WebCore/style/StyleSharingResolver.cpp 2016-04-05 16:45:51 UTC (rev 199060)
@@ -33,6 +33,7 @@
#include "NodeRenderStyle.h"
#include "RenderStyle.h"
#include "SVGElement.h"
+#include "ShadowRoot.h"
#include "StyleUpdate.h"
#include "StyledElement.h"
#include "VisitedLinkState.h"
@@ -95,6 +96,10 @@
return nullptr;
if (elementHasDirectionAuto(element))
return nullptr;
+#if ENABLE(SHADOW_DOM)
+ if (element.shadowRoot() && !element.shadowRoot()->styleResolver().ruleSets().authorStyle()->hostPseudoClassRules().isEmpty())
+ return nullptr;
+#endif
Context context {
update,
@@ -278,6 +283,11 @@
if (element.matchesInvalidPseudoClass() != element.matchesValidPseudoClass())
return false;
+#if ENABLE(SHADOW_DOM)
+ if (element.shadowRoot() && !element.shadowRoot()->styleResolver().ruleSets().authorStyle()->hostPseudoClassRules().isEmpty())
+ return nullptr;
+#endif
+
#if ENABLE(VIDEO_TRACK)
// Deny sharing styles between WebVTT and non-WebVTT nodes.
if (is<WebVTTElement>(element))
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes