| 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
|
|
|