Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(612)

Unified Diff: Source/core/css/resolver/ScopedStyleResolver.h

Issue 102953007: Selectors in styles in shadowRoots should match in all of the host's shadowRoots. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/css/ElementRuleCollector.cpp ('k') | Source/core/css/resolver/ScopedStyleTree.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/resolver/ScopedStyleResolver.h
diff --git a/Source/core/css/resolver/ScopedStyleResolver.h b/Source/core/css/resolver/ScopedStyleResolver.h
index 2ad0d7f728c5ea954cf3424561572317f7b4cb9f..68c8e9152ec1748978c2dcb9a696a2dca59ff3e7 100644
--- a/Source/core/css/resolver/ScopedStyleResolver.h
+++ b/Source/core/css/resolver/ScopedStyleResolver.h
@@ -30,6 +30,7 @@
#include "core/css/ElementRuleCollector.h"
#include "core/css/RuleSet.h"
#include "core/dom/ContainerNode.h"
+#include "core/dom/shadow/ShadowRoot.h"
#include "wtf/HashMap.h"
#include "wtf/OwnPtr.h"
#include "wtf/PassOwnPtr.h"
@@ -53,6 +54,7 @@ public:
const TreeScope& treeScope() const { return m_scopingNode.treeScope(); }
void setParent(ScopedStyleResolver* newParent) { m_parent = newParent; }
ScopedStyleResolver* parent() { return m_parent; }
+ bool crossingScopeBoundary(const Element*) const;
public:
bool checkRegionStyle(Element*);
@@ -78,6 +80,30 @@ private:
KeyframesRuleMap m_keyframesRuleMap;
};
+inline bool ScopedStyleResolver::crossingScopeBoundary(const Element* element) const
+{
+ // Since this resolver is for style scoped, rules declared in the style have higher priority
+ // than rules declared in styles whose scoping node is the ancestor. So need to ++cascadeScope.
+ if (!m_scopingNode.isShadowRoot())
+ return true;
+
+ // If parent is a given shadow host, this resolver is for shadow trees hosted by the host.
+ // Since styles in shadow trees hosted by the same shadow host will apply all elements in
+ // the shadow trees, we should treat rules in the styles as the same cascade.
+ // Should not ++cascadeScope.
+ Element* host = toShadowRoot(&m_scopingNode)->host();
+ if (element == host)
+ return false;
+
+ // If parent is document scope or style scoped, ++cascadeScope because of CSS cascade spec.
+ if (!m_parent || !m_parent->scopingNode().isShadowRoot())
+ return true;
+
+ // If parent is hosted by the same shadow host, keep the same cascadeScope.
+ // Otherwise, ++cascadeScope.
+ return toShadowRoot(&m_parent->scopingNode())->host() != host;
+}
+
} // namespace WebCore
#endif // ScopedStyleResolver_h
« no previous file with comments | « Source/core/css/ElementRuleCollector.cpp ('k') | Source/core/css/resolver/ScopedStyleTree.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698