Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (163262 => 163263)
--- trunk/Source/WebCore/CMakeLists.txt 2014-02-02 16:15:20 UTC (rev 163262)
+++ trunk/Source/WebCore/CMakeLists.txt 2014-02-02 17:27:02 UTC (rev 163263)
@@ -1104,7 +1104,6 @@
css/StyleResolver.cpp
css/StyleRule.cpp
css/StyleRuleImport.cpp
- css/StyleScopeResolver.cpp
css/StyleSheet.cpp
css/StyleSheetContents.cpp
css/StyleSheetList.cpp
Modified: trunk/Source/WebCore/ChangeLog (163262 => 163263)
--- trunk/Source/WebCore/ChangeLog 2014-02-02 16:15:20 UTC (rev 163262)
+++ trunk/Source/WebCore/ChangeLog 2014-02-02 17:27:02 UTC (rev 163263)
@@ -1,3 +1,36 @@
+2014-02-02 Antti Koivisto <an...@apple.com>
+
+ Remove StyleScopeResolver
+ https://bugs.webkit.org/show_bug.cgi?id=128069
+
+ Reviewed by Anders Carlsson.
+
+ This is dead code.
+
+ * CMakeLists.txt:
+ * GNUmakefile.list.am:
+ * WebCore.xcodeproj/project.pbxproj:
+ * css/DocumentRuleSets.cpp:
+ (WebCore::DocumentRuleSets::appendAuthorStyleSheets):
+ (WebCore::DocumentRuleSets::collectFeatures):
+ * css/DocumentRuleSets.h:
+ * css/ElementRuleCollector.h:
+ (WebCore::ElementRuleCollector::ElementRuleCollector):
+ * css/RuleSet.cpp:
+ (WebCore::RuleSet::addChildRules):
+ * css/StyleResolver.cpp:
+ (WebCore::StyleResolver::pushParentElement):
+ (WebCore::StyleResolver::popParentElement):
+ (WebCore::StyleResolver::locateSharedStyle):
+ (WebCore::StyleResolver::styleForElement):
+ * css/StyleResolver.h:
+ (WebCore::StyleResolver::document):
+ * css/StyleScopeResolver.cpp: Removed.
+ * css/StyleScopeResolver.h: Removed.
+ * style/StyleResolveTree.cpp:
+ (WebCore::Style::attachShadowRoot):
+ (WebCore::Style::resolveShadowTree):
+
2014-02-02 Zalan Bujtas <za...@apple.com>
Subpixel rendering: Make BorderEdge/RoundedRect::Radii LayoutUnit aware.
Modified: trunk/Source/WebCore/GNUmakefile.list.am (163262 => 163263)
--- trunk/Source/WebCore/GNUmakefile.list.am 2014-02-02 16:15:20 UTC (rev 163262)
+++ trunk/Source/WebCore/GNUmakefile.list.am 2014-02-02 17:27:02 UTC (rev 163263)
@@ -2694,8 +2694,6 @@
Source/WebCore/css/StyleRule.h \
Source/WebCore/css/StyleRuleImport.cpp \
Source/WebCore/css/StyleRuleImport.h \
- Source/WebCore/css/StyleScopeResolver.cpp \
- Source/WebCore/css/StyleScopeResolver.h \
Source/WebCore/css/StyleSheet.cpp \
Source/WebCore/css/StyleSheet.h \
Source/WebCore/css/StyleSheetContents.cpp \
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (163262 => 163263)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2014-02-02 16:15:20 UTC (rev 163262)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2014-02-02 17:27:02 UTC (rev 163263)
@@ -3724,7 +3724,6 @@
A7AD2F870EC89D07008AB002 /* LinkHash.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7AD2F850EC89D07008AB002 /* LinkHash.cpp */; };
A7AD2F880EC89D07008AB002 /* LinkHash.h in Headers */ = {isa = PBXBuildFile; fileRef = A7AD2F860EC89D07008AB002 /* LinkHash.h */; settings = {ATTRIBUTES = (Private, ); }; };
A7B6E69F0B291A9600D0529F /* DragData.h in Headers */ = {isa = PBXBuildFile; fileRef = A7B6E69D0B291A9600D0529F /* DragData.h */; settings = {ATTRIBUTES = (Private, ); }; };
- A7B761A1161EE526002083D3 /* StyleScopeResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = A7B7619F161EE526002083D3 /* StyleScopeResolver.h */; };
A7BBE26611AFB3F20005EA03 /* JSHTMLMeterElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7BBE26411AFB3F20005EA03 /* JSHTMLMeterElement.cpp */; };
A7BBE26711AFB3F20005EA03 /* JSHTMLMeterElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A7BBE26511AFB3F20005EA03 /* JSHTMLMeterElement.h */; };
A7BF7EDF14C9175A0014489D /* InternalSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7BF7EDC14C9175A0014489D /* InternalSettings.cpp */; };
@@ -10701,7 +10700,6 @@
A7B4EA7814C9348400C8F5BF /* JSInternalSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSInternalSettings.cpp; sourceTree = "<group>"; };
A7B4EA7914C9348400C8F5BF /* JSInternalSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSInternalSettings.h; sourceTree = "<group>"; };
A7B6E69D0B291A9600D0529F /* DragData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DragData.h; sourceTree = "<group>"; };
- A7B7619F161EE526002083D3 /* StyleScopeResolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleScopeResolver.h; sourceTree = "<group>"; };
A7BBE26411AFB3F20005EA03 /* JSHTMLMeterElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLMeterElement.cpp; sourceTree = "<group>"; };
A7BBE26511AFB3F20005EA03 /* JSHTMLMeterElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHTMLMeterElement.h; sourceTree = "<group>"; };
A7BE7EDD14C9175A0014489D /* MallocStatistics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MallocStatistics.h; sourceTree = "<group>"; };
@@ -21523,7 +21521,6 @@
E4BBED4B14FCDBA1003F0B98 /* StyleRule.h */,
E4946EAC156E64DD00D3297F /* StyleRuleImport.cpp */,
E4946EAD156E64DD00D3297F /* StyleRuleImport.h */,
- A7B7619F161EE526002083D3 /* StyleScopeResolver.h */,
A8EA80050A19516E00A8EF5F /* StyleSheet.cpp */,
A8EA80040A19516E00A8EF5F /* StyleSheet.h */,
850656DC0AAB44D9002D15C0 /* StyleSheet.idl */,
@@ -25339,7 +25336,6 @@
E139866415478474001E3F65 /* StyleResolver.h in Headers */,
E4BBED4D14FCDBA1003F0B98 /* StyleRule.h in Headers */,
E4946EAF156E64DD00D3297F /* StyleRuleImport.h in Headers */,
- A7B761A1161EE526002083D3 /* StyleScopeResolver.h in Headers */,
A8EA800C0A19516E00A8EF5F /* StyleSheet.h in Headers */,
0F54DCE61881051D003EEDBB /* TextAutoSizing.h in Headers */,
E4F9EEF3156DA00700D23E7E /* StyleSheetContents.h in Headers */,
Modified: trunk/Source/WebCore/css/CSSAllInOne.cpp (163262 => 163263)
--- trunk/Source/WebCore/css/CSSAllInOne.cpp 2014-02-02 16:15:20 UTC (rev 163262)
+++ trunk/Source/WebCore/css/CSSAllInOne.cpp 2014-02-02 17:27:02 UTC (rev 163263)
@@ -84,5 +84,4 @@
#include "StyleProperties.cpp"
#include "StylePropertyShorthand.cpp"
#include "StyleResolver.cpp"
-#include "StyleScopeResolver.cpp"
#include "ViewportStyleResolver.cpp"
Modified: trunk/Source/WebCore/css/DocumentRuleSets.cpp (163262 => 163263)
--- trunk/Source/WebCore/css/DocumentRuleSets.cpp 2014-02-02 16:15:20 UTC (rev 163262)
+++ trunk/Source/WebCore/css/DocumentRuleSets.cpp 2014-02-02 17:27:02 UTC (rev 163263)
@@ -93,24 +93,14 @@
ASSERT(!cssSheet->disabled());
if (cssSheet->mediaQueries() && !medium->eval(cssSheet->mediaQueries(), resolver))
continue;
- StyleSheetContents& sheet = cssSheet->contents();
-#if ENABLE(SHADOW_DOM)
- if (const ContainerNode* scope = StyleScopeResolver::scopeFor(cssSheet)) {
- // FIXME: Remove a dependency to calling a StyleResolver's member function.
- // If we can avoid calling resolver->ensureScopeResolver() here, we don't have to include "StyleResolver.h".
- // https://bugs.webkit.org/show_bug.cgi?id=108890
- resolver->ensureScopeResolver()->ensureRuleSetFor(scope)->addRulesFromSheet(&sheet, *medium, resolver, scope);
- continue;
- }
-#endif
- m_authorStyle->addRulesFromSheet(&sheet, *medium, resolver);
+ m_authorStyle->addRulesFromSheet(&cssSheet->contents(), *medium, resolver);
inspectorCSSOMWrappers.collectFromStyleSheetIfNeeded(cssSheet);
}
m_authorStyle->shrinkToFit();
- collectFeatures(isViewSource, resolver->scopeResolver());
+ collectFeatures(isViewSource);
}
-void DocumentRuleSets::collectFeatures(bool isViewSource, StyleScopeResolver* scopeResolver)
+void DocumentRuleSets::collectFeatures(bool isViewSource)
{
m_features.clear();
// Collect all ids and rules using sibling selectors (:first-child and similar)
@@ -123,8 +113,6 @@
if (isViewSource)
m_features.add(CSSDefaultStyleSheets::viewSourceStyle()->features());
- if (scopeResolver)
- scopeResolver->collectFeaturesTo(m_features);
if (m_userStyle)
m_features.add(m_userStyle->features());
Modified: trunk/Source/WebCore/css/DocumentRuleSets.h (163262 => 163263)
--- trunk/Source/WebCore/css/DocumentRuleSets.h 2014-02-02 16:15:20 UTC (rev 163262)
+++ trunk/Source/WebCore/css/DocumentRuleSets.h 2014-02-02 17:27:02 UTC (rev 163263)
@@ -38,7 +38,6 @@
class InspectorCSSOMWrappers;
class MediaQueryEvaluator;
class RuleSet;
-class StyleScopeResolver;
class DocumentRuleSets {
public:
@@ -55,7 +54,7 @@
void resetAuthorStyle();
void appendAuthorStyleSheets(unsigned firstNew, const Vector<RefPtr<CSSStyleSheet>>&, MediaQueryEvaluator*, InspectorCSSOMWrappers&, bool isViewSource, StyleResolver*);
- void collectFeatures(bool isViewSource, StyleScopeResolver*);
+ void collectFeatures(bool isViewSource);
private:
void collectRulesFromUserStyleSheets(const Vector<RefPtr<CSSStyleSheet>>&, RuleSet& userStyle, const MediaQueryEvaluator&, StyleResolver&);
Modified: trunk/Source/WebCore/css/ElementRuleCollector.h (163262 => 163263)
--- trunk/Source/WebCore/css/ElementRuleCollector.h 2014-02-02 16:15:20 UTC (rev 163262)
+++ trunk/Source/WebCore/css/ElementRuleCollector.h 2014-02-02 17:27:02 UTC (rev 163263)
@@ -37,7 +37,6 @@
class RuleData;
class RuleSet;
class SelectorFilter;
-class StyleScopeResolver;
class ElementRuleCollector {
public:
@@ -45,7 +44,6 @@
: m_state(state)
, m_ruleSets(styleResolver->ruleSets())
, m_selectorFilter(styleResolver->selectorFilter())
- , m_scopeResolver(styleResolver->scopeResolver())
, m_isPrintStyle(false)
, m_regionForStyling(0)
, m_pseudoStyleRequest(NOPSEUDO)
@@ -91,7 +89,6 @@
const StyleResolver::State& m_state;
DocumentRuleSets& m_ruleSets;
SelectorFilter& m_selectorFilter;
- StyleScopeResolver* m_scopeResolver;
bool m_isPrintStyle;
RenderRegion* m_regionForStyling;
Modified: trunk/Source/WebCore/css/RuleSet.cpp (163262 => 163263)
--- trunk/Source/WebCore/css/RuleSet.cpp 2014-02-02 16:15:20 UTC (rev 163262)
+++ trunk/Source/WebCore/css/RuleSet.cpp 2014-02-02 17:27:02 UTC (rev 163263)
@@ -306,10 +306,6 @@
addRegionRule(static_cast<StyleRuleRegion*>(rule), hasDocumentSecurityOrigin);
}
#endif
-#if ENABLE(SHADOW_DOM)
- else if (rule->isHostRule())
- resolver->addHostRule(static_cast<StyleRuleHost*>(rule), hasDocumentSecurityOrigin, scope);
-#endif
#if ENABLE(CSS_DEVICE_ADAPTATION)
else if (rule->isViewportRule() && resolver) {
// @viewport should not be scoped.
Modified: trunk/Source/WebCore/css/StyleResolver.cpp (163262 => 163263)
--- trunk/Source/WebCore/css/StyleResolver.cpp 2014-02-02 16:15:20 UTC (rev 163262)
+++ trunk/Source/WebCore/css/StyleResolver.cpp 2014-02-02 17:27:02 UTC (rev 163263)
@@ -328,10 +328,6 @@
m_selectorFilter.setupParentStack(parent);
else
m_selectorFilter.pushParent(parent);
-
- // Note: We mustn't skip ShadowRoot nodes for the scope stack.
- if (m_scopeResolver)
- m_scopeResolver->push(parent, parent->parentOrShadowHostNode());
}
void StyleResolver::popParentElement(Element* parent)
@@ -340,24 +336,8 @@
// Pause maintaining the stack in this case.
if (m_selectorFilter.parentStackIsConsistent(parent))
m_selectorFilter.popParent();
- if (m_scopeResolver)
- m_scopeResolver->pop(parent);
}
-void StyleResolver::pushParentShadowRoot(const ShadowRoot* shadowRoot)
-{
- ASSERT(shadowRoot->hostElement());
- if (m_scopeResolver)
- m_scopeResolver->push(shadowRoot, shadowRoot->hostElement());
-}
-
-void StyleResolver::popParentShadowRoot(const ShadowRoot* shadowRoot)
-{
- ASSERT(shadowRoot->hostElement());
- if (m_scopeResolver)
- m_scopeResolver->pop(shadowRoot);
-}
-
// This is a simplified style setting function for keyframe styles
void StyleResolver::addKeyframeStyle(PassRefPtr<StyleRuleKeyframes> rule)
{
@@ -397,15 +377,6 @@
m_matchedPropertiesCacheAdditionsSinceLastSweep = 0;
}
-inline bool StyleResolver::styleSharingCandidateMatchesHostRules()
-{
-#if ENABLE(SHADOW_DOM)
- return m_scopeResolver && m_scopeResolver->styleSharingCandidateMatchesHostRules(m_state.element());
-#else
- return false;
-#endif
-}
-
bool StyleResolver::classNamesAffectedByRules(const SpaceSplitString& classNames) const
{
for (unsigned i = 0; i < classNames.size(); ++i) {
@@ -775,9 +746,6 @@
// Can't share if attribute rules apply.
if (styleSharingCandidateMatchesRuleSet(m_ruleSets.uncommonAttribute()))
return 0;
- // Can't share if @host @-rules apply.
- if (styleSharingCandidateMatchesHostRules())
- return 0;
// Tracking child index requires unique style for each node. This may get set by the sibling rule match above.
if (parentElementPreventsSharing(state.element()->parentElement()))
return 0;
@@ -839,7 +807,7 @@
bool needsCollection = false;
CSSDefaultStyleSheets::ensureDefaultStyleSheetsForElement(element, needsCollection);
if (needsCollection)
- m_ruleSets.collectFeatures(document().isViewSource(), m_scopeResolver.get());
+ m_ruleSets.collectFeatures(document().isViewSource());
ElementRuleCollector collector(this, state);
collector.setRegionForStyling(regionForStyling);
Modified: trunk/Source/WebCore/css/StyleResolver.h (163262 => 163263)
--- trunk/Source/WebCore/css/StyleResolver.h 2014-02-02 16:15:20 UTC (rev 163262)
+++ trunk/Source/WebCore/css/StyleResolver.h 2014-02-02 17:27:02 UTC (rev 163263)
@@ -36,7 +36,6 @@
#include "SelectorChecker.h"
#include "SelectorFilter.h"
#include "StyleInheritedData.h"
-#include "StyleScopeResolver.h"
#include "ViewportStyleResolver.h"
#include <memory>
#include <wtf/HashMap.h>
@@ -77,7 +76,6 @@
class RuleData;
class RuleSet;
class Settings;
-class StyleScopeResolver;
class StyleImage;
class StyleKeyframe;
class StylePendingImage;
@@ -147,11 +145,6 @@
// Using these during tree walk will allow style selector to optimize child and descendant selector lookups.
void pushParentElement(Element*);
void popParentElement(Element*);
- void pushParentShadowRoot(const ShadowRoot*);
- void popParentShadowRoot(const ShadowRoot*);
-#if ENABLE(SHADOW_DOM)
- void addHostRule(StyleRuleHost* rule, bool hasDocumentSecurityOrigin, const ContainerNode* scope) { ensureScopeResolver()->addHostRule(rule, hasDocumentSecurityOrigin, scope); }
-#endif
PassRef<RenderStyle> styleForElement(Element*, RenderStyle* parentStyle = 0, StyleSharingBehavior = AllowStyleSharing,
RuleMatchingBehavior = MatchAllRules, RenderRegion* regionForStyling = 0);
@@ -168,7 +161,6 @@
RenderStyle* rootElementStyle() const { return m_state.rootElementStyle(); }
Element* element() { return m_state.element(); }
Document& document() { return m_document; }
- StyleScopeResolver* scopeResolver() const { return m_scopeResolver.get(); }
bool hasParentNode() const { return m_state.parentNode(); }
// FIXME: It could be better to call m_ruleSets.appendAuthorStyleSheets() directly after we factor StyleRsolver further.
@@ -179,21 +171,10 @@
const DocumentRuleSets& ruleSets() const { return m_ruleSets; }
SelectorFilter& selectorFilter() { return m_selectorFilter; }
-#if ENABLE(SHADOW_DOM)
- StyleScopeResolver* ensureScopeResolver()
- {
- ASSERT(RuntimeEnabledFeatures::sharedFeatures().shadowDOMEnabled());
- if (!m_scopeResolver)
- m_scopeResolver = std::make_unique<StyleScopeResolver>();
- return m_scopeResolver.get();
- }
-#endif
-
private:
void initElement(Element*);
RenderStyle* locateSharedStyle();
bool styleSharingCandidateMatchesRuleSet(RuleSet*);
- bool styleSharingCandidateMatchesHostRules();
Node* locateCousinList(Element* parent, unsigned& visitedNodeCount) const;
StyledElement* findSiblingForStyleSharing(Node*, unsigned& count) const;
bool canShareStyleWithElement(StyledElement*) const;
@@ -545,7 +526,6 @@
const DeprecatedStyleBuilder& m_deprecatedStyleBuilder;
- std::unique_ptr<StyleScopeResolver> m_scopeResolver;
CSSToStyleMap m_styleMap;
InspectorCSSOMWrappers m_inspectorCSSOMWrappers;
Deleted: trunk/Source/WebCore/css/StyleScopeResolver.cpp (163262 => 163263)
--- trunk/Source/WebCore/css/StyleScopeResolver.cpp 2014-02-02 16:15:20 UTC (rev 163262)
+++ trunk/Source/WebCore/css/StyleScopeResolver.cpp 2014-02-02 17:27:02 UTC (rev 163263)
@@ -1,228 +0,0 @@
-/*
- * Copyright (C) 1999 Lars Knoll (kn...@kde.org)
- * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "StyleScopeResolver.h"
-
-#if ENABLE(SHADOW_DOM)
-
-#include "CSSStyleRule.h"
-#include "CSSStyleSheet.h"
-#include "ContentDistributor.h"
-#include "HTMLNames.h"
-#include "HTMLStyleElement.h"
-#include "RuleFeature.h"
-#include "RuleSet.h"
-#include "ShadowRoot.h"
-
-namespace WebCore {
-
-StyleScopeResolver::StyleScopeResolver()
- : m_stackParent(0)
- , m_stackParentBoundsIndex(0)
-{
-}
-
-StyleScopeResolver::~StyleScopeResolver()
-{
-}
-
-const ContainerNode* StyleScopeResolver::scopeFor(const CSSStyleSheet* sheet)
-{
- ASSERT(sheet);
-
- Document* document = sheet->ownerDocument();
- if (!document)
- return 0;
- Node* ownerNode = sheet->ownerNode();
- if (!ownerNode || !ownerNode->isHTMLElement() || !isHTMLStyleElement(ownerNode))
- return 0;
-
- HTMLStyleElement* styleElement = toHTMLStyleElement(ownerNode);
- if (!styleElement->scoped())
- return styleElement->isInShadowTree() ? styleElement->containingShadowRoot() : 0;
-
- ContainerNode* parent = styleElement->parentNode();
- if (!parent)
- return 0;
-
- return (parent->isElementNode() || parent->isShadowRoot()) ? parent : 0;
-}
-
-inline RuleSet* StyleScopeResolver::ruleSetFor(const ContainerNode* scope) const
-{
- if (!scope->hasScopedHTMLStyleChild())
- return 0;
- ScopedRuleSetMap::const_iterator it = m_authorStyles.find(scope);
- return it != m_authorStyles.end() ? it->value.get() : 0;
-}
-
-RuleSet* StyleScopeResolver::ensureRuleSetFor(const ContainerNode* scope)
-{
- ScopedRuleSetMap::AddResult addResult = m_authorStyles.add(scope, nullptr);
- if (addResult.isNewEntry)
- addResult.iterator->value = RuleSet::create();
- return addResult.iterator->value.get();
-}
-
-void StyleScopeResolver::setupStack(const ContainerNode* parent)
-{
- // The scoping element stack shouldn't be used if <style scoped> isn't used anywhere.
- ASSERT(!m_authorStyles.isEmpty());
-
- m_stack.shrink(0);
- int authorStyleBoundsIndex = 0;
- for (const ContainerNode* scope = parent; scope; scope = scope->parentOrShadowHostNode()) {
- RuleSet* ruleSet = ruleSetFor(scope);
- if (ruleSet)
- m_stack.append(StackFrame(scope, authorStyleBoundsIndex, ruleSet));
- if (scope->isShadowRoot() && !toShadowRoot(scope)->applyAuthorStyles())
- --authorStyleBoundsIndex;
- }
-
- m_stack.reverse();
- m_stackParent = parent;
- m_stackParentBoundsIndex = 0;
-}
-
-void StyleScopeResolver::push(const ContainerNode* scope, const ContainerNode* scopeParent)
-{
- // Shortcut: Don't bother with the scoping element stack if <style scoped> isn't used anywhere.
- if (m_authorStyles.isEmpty()) {
- ASSERT(!m_stackParent);
- ASSERT(m_stack.isEmpty());
- return;
- }
-
- // In some wacky cases during style resolve we may get invoked for random elements.
- // Recreate the whole scoping element stack in such cases.
- if (!stackIsConsistent(scopeParent)) {
- setupStack(scope);
- return;
- }
-
- if (scope->isShadowRoot() && !toShadowRoot(scope)->applyAuthorStyles())
- ++m_stackParentBoundsIndex;
- // Otherwise just push the parent onto the stack.
- RuleSet* ruleSet = ruleSetFor(scope);
- if (ruleSet)
- m_stack.append(StackFrame(scope, m_stackParentBoundsIndex, ruleSet));
- m_stackParent = scope;
-}
-
-void StyleScopeResolver::pop(const ContainerNode* scope)
-{
- // Only bother to update the scoping element stack if it is consistent.
- if (stackIsConsistent(scope)) {
- if (!m_stack.isEmpty() && m_stack.last().m_scope == scope)
- m_stack.removeLast();
- if (scope->isShadowRoot() && !toShadowRoot(scope)->applyAuthorStyles())
- --m_stackParentBoundsIndex;
- m_stackParent = scope->parentOrShadowHostNode();
- }
-}
-
-void StyleScopeResolver::collectFeaturesTo(RuleFeatureSet& features)
-{
- for (ScopedRuleSetMap::iterator it = m_authorStyles.begin(); it != m_authorStyles.end(); ++it)
- features.add(it->value->features());
-#if ENABLE(SHADOW_DOM)
- for (ScopedRuleSetMap::iterator it = m_atHostRules.begin(); it != m_atHostRules.end(); ++it)
- features.add(it->value->features());
-#endif
-}
-
-inline RuleSet* StyleScopeResolver::ensureAtHostRuleSetFor(const ShadowRoot* shadowRoot)
-{
- ScopedRuleSetMap::AddResult addResult = m_atHostRules.add(shadowRoot, nullptr);
- if (addResult.isNewEntry)
- addResult.iterator->value = RuleSet::create();
- return addResult.iterator->value.get();
-}
-
-inline RuleSet* StyleScopeResolver::atHostRuleSetFor(const ShadowRoot* shadowRoot) const
-{
- ScopedRuleSetMap::const_iterator it = m_atHostRules.find(shadowRoot);
- return it != m_atHostRules.end() ? it->value.get() : 0;
-}
-
-#if ENABLE(SHADOW_DOM)
-void StyleScopeResolver::addHostRule(StyleRuleHost* hostRule, bool hasDocumentSecurityOrigin, const ContainerNode* scope)
-{
- if (!scope || !scope->isInShadowTree())
- return;
-
- ShadowRoot* shadowRoot = scope->containingShadowRoot();
- if (!shadowRoot || !shadowRoot->host())
- return;
-
- RuleSet* rule = ensureAtHostRuleSetFor(shadowRoot);
-
- const Vector<RefPtr<StyleRuleBase> >& childRules = hostRule->childRules();
- AddRuleFlags addRuleFlags = hasDocumentSecurityOrigin ? RuleHasDocumentSecurityOrigin : RuleHasNoSpecialState;
- addRuleFlags = static_cast<AddRuleFlags>(addRuleFlags | RuleCanUseFastCheckSelector);
- for (unsigned i = 0; i < childRules.size(); ++i) {
- StyleRuleBase* hostStylingRule = childRules[i].get();
- if (hostStylingRule->isStyleRule())
- rule->addStyleRule(static_cast<StyleRule*>(hostStylingRule), addRuleFlags);
- }
-}
-#endif
-
-bool StyleScopeResolver::styleSharingCandidateMatchesHostRules(const Element* element)
-{
- if (m_atHostRules.isEmpty())
- return false;
-
- // FIXME(99827): https://bugs.webkit.org/show_bug.cgi?id=99827
- // add a new flag to ElementShadow and cache whether any@host @-rules are
- // applied to the element or not. So we can avoid always traversing
- // shadow roots.
- if (ShadowRoot* shadowRoot = element->shadowRoot()) {
- if (atHostRuleSetFor(shadowRoot))
- return true;
- }
- return false;
-}
-
-void StyleScopeResolver::matchHostRules(const Element* element, Vector<RuleSet*>& matchedRules)
-{
- if (m_atHostRules.isEmpty())
- return;
-
- // FIXME(99827): https://bugs.webkit.org/show_bug.cgi?id=99827
- // add a new flag to ElementShadow and cache whether any @host @-rules are
- // applied to the element or not. So we can quickly exit this method
- // by using the flag.
- if (ShadowRoot* shadowRoot = element->shadowRoot()) {
- if (RuleSet* ruleSet = atHostRuleSetFor(shadowRoot))
- matchedRules.append(ruleSet);
- }
-}
-
-}
-
-#endif // ENABLE(SHADOW_DOM)
Deleted: trunk/Source/WebCore/css/StyleScopeResolver.h (163262 => 163263)
--- trunk/Source/WebCore/css/StyleScopeResolver.h 2014-02-02 16:15:20 UTC (rev 163262)
+++ trunk/Source/WebCore/css/StyleScopeResolver.h 2014-02-02 17:27:02 UTC (rev 163263)
@@ -1,125 +0,0 @@
-/*
- * Copyright (C) 1999 Lars Knoll (kn...@kde.org)
- * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
- * Copyright (C) 2012 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef StyleScopeResolver_h
-#define StyleScopeResolver_h
-
-#include <wtf/Assertions.h>
-#include <wtf/Forward.h>
-#include <wtf/HashMap.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-class ContainerNode;
-class CSSStyleSheet;
-class Element;
-class RuleSet;
-class ShadowRoot;
-class StyleRuleHost;
-struct RuleFeatureSet;
-
-#if ENABLE(SHADOW_DOM)
-
-class StyleScopeResolver {
-public:
- typedef HashMap<const ContainerNode*, OwnPtr<RuleSet>> ScopedRuleSetMap;
-
- struct StackFrame {
- StackFrame() : m_scope(0), m_authorStyleBoundsIndex(0), m_ruleSet(0) { }
- StackFrame(const ContainerNode* scope, int authorStyleBoundsIndex, RuleSet* ruleSet)
- : m_scope(scope), m_authorStyleBoundsIndex(authorStyleBoundsIndex), m_ruleSet(ruleSet)
- { }
-
- const ContainerNode* m_scope;
- int m_authorStyleBoundsIndex;
- RuleSet* m_ruleSet;
- };
-
- StyleScopeResolver();
- ~StyleScopeResolver();
-
- static const ContainerNode* scopeFor(const CSSStyleSheet*);
-
- void push(const ContainerNode* scope, const ContainerNode* scopeParent);
- void pop(const ContainerNode* scope);
- bool hasScopedStyles() const { return !m_authorStyles.isEmpty(); }
- RuleSet* ensureRuleSetFor(const ContainerNode* scope);
- bool ensureStackConsistency(ContainerNode*);
- unsigned stackSize() const { return m_stack.size(); }
- const StackFrame& stackFrameAt(unsigned index) const { return m_stack.at(index); }
- bool matchesStyleBounds(const StackFrame& frame) const { return frame.m_authorStyleBoundsIndex == m_stackParentBoundsIndex; }
- void collectFeaturesTo(RuleFeatureSet&);
-
- void addHostRule(StyleRuleHost*, bool hasDocumentSecurityOrigin, const ContainerNode* scope);
- bool styleSharingCandidateMatchesHostRules(const Element*);
- void matchHostRules(const Element*, Vector<RuleSet*>& matchedRules);
-
-private:
- RuleSet* ruleSetFor(const ContainerNode* scope) const;
- void setupStack(const ContainerNode*);
- bool stackIsConsistent(const ContainerNode* parent) const { return parent && parent == m_stackParent; }
- RuleSet* ensureAtHostRuleSetFor(const ShadowRoot*);
- RuleSet* atHostRuleSetFor(const ShadowRoot*) const;
-
- ScopedRuleSetMap m_authorStyles;
-
- // Vector (used as stack) that keeps track of scoping elements (i.e., elements with a <style scoped> child)
- // encountered during tree iteration for style resolution.
- Vector<StackFrame> m_stack;
- // Element last seen as parent element when updating m_scopingElementStack.
- // This is used to decide whether m_scopingElementStack is consistent, separately from SelectorChecker::m_parentStack.
- const ContainerNode* m_stackParent;
- int m_stackParentBoundsIndex;
-
- ScopedRuleSetMap m_atHostRules;
-};
-
-inline bool StyleScopeResolver::ensureStackConsistency(ContainerNode* parent)
-{
- // Match scoped author rules by traversing the scoped element stack (rebuild it if it got inconsistent).
- if (!stackIsConsistent(parent))
- setupStack(parent);
- return !m_stack.isEmpty();
-}
-
-#else
-
-class StyleScopeResolver {
-public:
- static const ContainerNode* scopeFor(const CSSStyleSheet*) { return 0; }
- void push(const ContainerNode*, const ContainerNode*) { }
- void pop(const ContainerNode*) { }
- void collectFeaturesTo(RuleFeatureSet&) { }
- RuleSet* ensureRuleSetFor(const ContainerNode*) { return 0; }
-};
-
-#endif // ENABLE(SHADOW_DOM)
-
-} // namespace WebCore
-
-#endif // StyleScopeResolver_h
Modified: trunk/Source/WebCore/style/StyleResolveTree.cpp (163262 => 163263)
--- trunk/Source/WebCore/style/StyleResolveTree.cpp 2014-02-02 16:15:20 UTC (rev 163262)
+++ trunk/Source/WebCore/style/StyleResolveTree.cpp 2014-02-02 17:27:02 UTC (rev 163263)
@@ -466,13 +466,8 @@
static void attachShadowRoot(ShadowRoot& shadowRoot)
{
- StyleResolver& styleResolver = shadowRoot.document().ensureStyleResolver();
- styleResolver.pushParentShadowRoot(&shadowRoot);
-
attachChildren(shadowRoot);
- styleResolver.popParentShadowRoot(&shadowRoot);
-
shadowRoot.clearNeedsStyleRecalc();
shadowRoot.clearChildNeedsStyleRecalc();
}
@@ -726,19 +721,16 @@
{
if (!shadowRoot)
return;
- StyleResolver& styleResolver = shadowRoot->document().ensureStyleResolver();
- styleResolver.pushParentShadowRoot(shadowRoot);
for (Node* child = shadowRoot->firstChild(); child; child = child->nextSibling()) {
if (child->isTextNode()) {
- // Current user agent ShadowRoots don't have immediate text children so this branch is never actually taken.
updateTextStyle(*toText(child));
continue;
}
- resolveTree(*toElement(child), change);
+ if (child->isElementNode())
+ resolveTree(*toElement(child), change);
}
- styleResolver.popParentShadowRoot(shadowRoot);
shadowRoot->clearNeedsStyleRecalc();
shadowRoot->clearChildNeedsStyleRecalc();
}