Title: [141973] trunk/Source/WebCore
Revision
141973
Author
[email protected]
Date
2013-02-06 00:00:14 -0800 (Wed, 06 Feb 2013)

Log Message

Unreviewed, rolling out r141964.
http://trac.webkit.org/changeset/141964
https://bugs.webkit.org/show_bug.cgi?id=109014

caused performance regression (Requested by hayato on
#webkit).

Patch by Sheriff Bot <[email protected]> on 2013-02-05

* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.gypi:
* WebCore.xcodeproj/project.pbxproj:
* css/CSSAllInOne.cpp:
* css/DocumentRuleSets.cpp: Removed.
* css/DocumentRuleSets.h: Removed.
* css/StyleResolver.cpp:
(WebCore::StyleResolver::StyleResolver):
(WebCore::StyleResolver::collectRulesFromUserStyleSheets):
(WebCore):
(WebCore::makeRuleSet):
(WebCore::StyleResolver::resetAuthorStyle):
(WebCore::StyleResolver::appendAuthorStyleSheets):
(WebCore::StyleResolver::matchAuthorRules):
(WebCore::StyleResolver::matchUserRules):
(WebCore::StyleResolver::classNamesAffectedByRules):
(WebCore::StyleResolver::locateCousinList):
(WebCore::StyleResolver::canShareStyleWithElement):
(WebCore::StyleResolver::locateSharedStyle):
(WebCore::StyleResolver::styleForElement):
(WebCore::StyleResolver::styleForPage):
(WebCore::StyleResolver::checkRegionStyle):
(WebCore::StyleResolver::applyProperty):
(WebCore::StyleResolver::collectFeatures):
(WebCore::StyleResolver::reportMemoryUsage):
* css/StyleResolver.h:
(StyleResolver):
(WebCore::StyleResolver::usesSiblingRules):
(WebCore::StyleResolver::usesFirstLineRules):
(WebCore::StyleResolver::usesBeforeAfterRules):
(WebCore::StyleResolver::hasSelectorForAttribute):
(WebCore::StyleResolver::hasSelectorForClass):
(WebCore::StyleResolver::hasSelectorForId):
* dom/DocumentStyleSheetCollection.cpp:
(WebCore::DocumentStyleSheetCollection::updateActiveStyleSheets):

Modified Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/CMakeLists.txt (141972 => 141973)


--- trunk/Source/WebCore/CMakeLists.txt	2013-02-06 07:44:53 UTC (rev 141972)
+++ trunk/Source/WebCore/CMakeLists.txt	2013-02-06 08:00:14 UTC (rev 141973)
@@ -1070,7 +1070,6 @@
     css/CSSValue.cpp
     css/CSSValueList.cpp
     css/CSSValuePool.cpp
-    css/DocumentRuleSets.cpp
     css/FontFeatureValue.cpp
     css/FontValue.cpp
     css/InspectorCSSOMWrappers.cpp

Modified: trunk/Source/WebCore/ChangeLog (141972 => 141973)


--- trunk/Source/WebCore/ChangeLog	2013-02-06 07:44:53 UTC (rev 141972)
+++ trunk/Source/WebCore/ChangeLog	2013-02-06 08:00:14 UTC (rev 141973)
@@ -1,3 +1,50 @@
+2013-02-05  Sheriff Bot  <[email protected]>
+
+        Unreviewed, rolling out r141964.
+        http://trac.webkit.org/changeset/141964
+        https://bugs.webkit.org/show_bug.cgi?id=109014
+
+        caused performance regression (Requested by hayato on
+        #webkit).
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * Target.pri:
+        * WebCore.gypi:
+        * WebCore.xcodeproj/project.pbxproj:
+        * css/CSSAllInOne.cpp:
+        * css/DocumentRuleSets.cpp: Removed.
+        * css/DocumentRuleSets.h: Removed.
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::StyleResolver):
+        (WebCore::StyleResolver::collectRulesFromUserStyleSheets):
+        (WebCore):
+        (WebCore::makeRuleSet):
+        (WebCore::StyleResolver::resetAuthorStyle):
+        (WebCore::StyleResolver::appendAuthorStyleSheets):
+        (WebCore::StyleResolver::matchAuthorRules):
+        (WebCore::StyleResolver::matchUserRules):
+        (WebCore::StyleResolver::classNamesAffectedByRules):
+        (WebCore::StyleResolver::locateCousinList):
+        (WebCore::StyleResolver::canShareStyleWithElement):
+        (WebCore::StyleResolver::locateSharedStyle):
+        (WebCore::StyleResolver::styleForElement):
+        (WebCore::StyleResolver::styleForPage):
+        (WebCore::StyleResolver::checkRegionStyle):
+        (WebCore::StyleResolver::applyProperty):
+        (WebCore::StyleResolver::collectFeatures):
+        (WebCore::StyleResolver::reportMemoryUsage):
+        * css/StyleResolver.h:
+        (StyleResolver):
+        (WebCore::StyleResolver::usesSiblingRules):
+        (WebCore::StyleResolver::usesFirstLineRules):
+        (WebCore::StyleResolver::usesBeforeAfterRules):
+        (WebCore::StyleResolver::hasSelectorForAttribute):
+        (WebCore::StyleResolver::hasSelectorForClass):
+        (WebCore::StyleResolver::hasSelectorForId):
+        * dom/DocumentStyleSheetCollection.cpp:
+        (WebCore::DocumentStyleSheetCollection::updateActiveStyleSheets):
+
 2013-02-05  Kentaro Hara  <[email protected]>
 
         Add #if USE(V8) to Node::V8CollectableDuringMinorGCFlag

Modified: trunk/Source/WebCore/GNUmakefile.list.am (141972 => 141973)


--- trunk/Source/WebCore/GNUmakefile.list.am	2013-02-06 07:44:53 UTC (rev 141972)
+++ trunk/Source/WebCore/GNUmakefile.list.am	2013-02-06 08:00:14 UTC (rev 141973)
@@ -2620,8 +2620,6 @@
 	Source/WebCore/css/CSSValuePool.h \
 	Source/WebCore/css/CSSVariableValue.h \
 	Source/WebCore/css/DashboardRegion.h \
-	Source/WebCore/css/DocumentRuleSets.cpp \
-	Source/WebCore/css/DocumentRuleSets.h \
 	Source/WebCore/css/FontFeatureValue.cpp \
 	Source/WebCore/css/FontFeatureValue.h \
 	Source/WebCore/css/FontValue.cpp \

Modified: trunk/Source/WebCore/Target.pri (141972 => 141973)


--- trunk/Source/WebCore/Target.pri	2013-02-06 07:44:53 UTC (rev 141972)
+++ trunk/Source/WebCore/Target.pri	2013-02-06 08:00:14 UTC (rev 141973)
@@ -307,7 +307,6 @@
     css/CSSValue.cpp \
     css/CSSValueList.cpp \
     css/CSSValuePool.cpp \
-    css/DocumentRuleSets.cpp \
     css/FontFeatureValue.cpp \
     css/FontValue.cpp \
     css/InspectorCSSOMWrappers.cpp \

Modified: trunk/Source/WebCore/WebCore.gypi (141972 => 141973)


--- trunk/Source/WebCore/WebCore.gypi	2013-02-06 07:44:53 UTC (rev 141972)
+++ trunk/Source/WebCore/WebCore.gypi	2013-02-06 08:00:14 UTC (rev 141973)
@@ -1545,8 +1545,6 @@
             'css/CSSVariableValue.h',
             'css/Counter.h',
             'css/DashboardRegion.h',
-            'css/DocumentRuleSets.cpp',
-            'css/DocumentRuleSets.h',
             'css/FontFeatureValue.cpp',
             'css/FontFeatureValue.h',
             'css/FontValue.cpp',

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (141972 => 141973)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2013-02-06 07:44:53 UTC (rev 141972)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2013-02-06 08:00:14 UTC (rev 141973)
@@ -1437,8 +1437,6 @@
 		4A1E71A614E106AC00626F9D /* JSShadowRoot.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A1E71A414E106AC00626F9D /* JSShadowRoot.h */; };
 		4A38BF5014FE1C0900612512 /* WebSocketDeflateFramer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A38BF4E14FE1C0900612512 /* WebSocketDeflateFramer.cpp */; };
 		4A38BF5114FE1C0900612512 /* WebSocketDeflateFramer.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A38BF4F14FE1C0900612512 /* WebSocketDeflateFramer.h */; };
-		4A4F48A916B0DFC000EDBB29 /* DocumentRuleSets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A4F48A716B0DFC000EDBB29 /* DocumentRuleSets.cpp */; };
-		4A4F48AA16B0DFC000EDBB29 /* DocumentRuleSets.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A4F48A816B0DFC000EDBB29 /* DocumentRuleSets.h */; };
 		4A5A2ADB161E7E00005889DD /* WebSocketExtensionParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A5A2AD9161E7E00005889DD /* WebSocketExtensionParser.cpp */; };
 		4A5A2ADC161E7E00005889DD /* WebSocketExtensionParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A5A2ADA161E7E00005889DD /* WebSocketExtensionParser.h */; };
 		4A6A0C5B15232F2400B09C6E /* ComposedShadowTreeWalker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A6A0C5915232F2400B09C6E /* ComposedShadowTreeWalker.cpp */; };
@@ -8819,8 +8817,6 @@
 		4A1E71A414E106AC00626F9D /* JSShadowRoot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSShadowRoot.h; sourceTree = "<group>"; };
 		4A38BF4E14FE1C0900612512 /* WebSocketDeflateFramer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebSocketDeflateFramer.cpp; path = Modules/websockets/WebSocketDeflateFramer.cpp; sourceTree = "<group>"; };
 		4A38BF4F14FE1C0900612512 /* WebSocketDeflateFramer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebSocketDeflateFramer.h; path = Modules/websockets/WebSocketDeflateFramer.h; sourceTree = "<group>"; };
-		4A4F48A716B0DFC000EDBB29 /* DocumentRuleSets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentRuleSets.cpp; sourceTree = "<group>"; };
-		4A4F48A816B0DFC000EDBB29 /* DocumentRuleSets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentRuleSets.h; sourceTree = "<group>"; };
 		4A5A2AD9161E7E00005889DD /* WebSocketExtensionParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebSocketExtensionParser.cpp; path = Modules/websockets/WebSocketExtensionParser.cpp; sourceTree = "<group>"; };
 		4A5A2ADA161E7E00005889DD /* WebSocketExtensionParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebSocketExtensionParser.h; path = Modules/websockets/WebSocketExtensionParser.h; sourceTree = "<group>"; };
 		4A6A0C5915232F2400B09C6E /* ComposedShadowTreeWalker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ComposedShadowTreeWalker.cpp; sourceTree = "<group>"; };
@@ -21846,8 +21842,6 @@
 				E49BD9F9131FD2ED003C56F0 /* CSSValuePool.h */,
 				CAE9F90E146441F000C245B1 /* CSSVariableValue.h */,
 				A80E6CE10A1989CA007FB8C5 /* DashboardRegion.h */,
-				4A4F48A716B0DFC000EDBB29 /* DocumentRuleSets.cpp */,
-				4A4F48A816B0DFC000EDBB29 /* DocumentRuleSets.h */,
 				4A6E9FC113C17D1D0046A7F8 /* FontFeatureValue.cpp */,
 				4A6E9FC213C17D1D0046A7F8 /* FontFeatureValue.h */,
 				A80E6CC70A1989CA007FB8C5 /* FontValue.cpp */,
@@ -23424,7 +23418,6 @@
 				CE057FA61220731100A476D5 /* DocumentMarkerController.h in Headers */,
 				14947FFE12F80CD200A0F631 /* DocumentOrderedMap.h in Headers */,
 				BCCFBAE80B5152ED0001F1D7 /* DocumentParser.h in Headers */,
-				4A4F48AA16B0DFC000EDBB29 /* DocumentRuleSets.h in Headers */,
 				AD6E71AD1668899D00320C13 /* DocumentSharedObjectPool.h in Headers */,
 				E47E276516036ED200EE2AFB /* DocumentStyleSheetCollection.h in Headers */,
 				0B90561A0F2578BF0095FF6A /* DocumentThreadableLoader.h in Headers */,
@@ -27068,7 +27061,6 @@
 				CE057FA51220731100A476D5 /* DocumentMarkerController.cpp in Sources */,
 				14947FFD12F80CD200A0F631 /* DocumentOrderedMap.cpp in Sources */,
 				A8C2280E11D4A59700D5A7D3 /* DocumentParser.cpp in Sources */,
-				4A4F48A916B0DFC000EDBB29 /* DocumentRuleSets.cpp in Sources */,
 				AD6E71AC1668899D00320C13 /* DocumentSharedObjectPool.cpp in Sources */,
 				E47E276816036EDC00EE2AFB /* DocumentStyleSheetCollection.cpp in Sources */,
 				0B9056190F2578BE0095FF6A /* DocumentThreadableLoader.cpp in Sources */,

Modified: trunk/Source/WebCore/css/CSSAllInOne.cpp (141972 => 141973)


--- trunk/Source/WebCore/css/CSSAllInOne.cpp	2013-02-06 07:44:53 UTC (rev 141972)
+++ trunk/Source/WebCore/css/CSSAllInOne.cpp	2013-02-06 08:00:14 UTC (rev 141973)
@@ -69,7 +69,6 @@
 #include "CSSValue.cpp"
 #include "CSSValueList.cpp"
 #include "CSSValuePool.cpp"
-#include "DocumentRuleSets.cpp"
 #include "InspectorCSSOMWrappers.cpp"
 #include "RuleFeature.cpp"
 #include "RuleSet.cpp"

Deleted: trunk/Source/WebCore/css/DocumentRuleSets.cpp (141972 => 141973)


--- trunk/Source/WebCore/css/DocumentRuleSets.cpp	2013-02-06 07:44:53 UTC (rev 141972)
+++ trunk/Source/WebCore/css/DocumentRuleSets.cpp	2013-02-06 08:00:14 UTC (rev 141973)
@@ -1,145 +0,0 @@
-/*
- * Copyright (C) 1999 Lars Knoll ([email protected])
- *           (C) 2004-2005 Allan Sandfeld Jensen ([email protected])
- * Copyright (C) 2006, 2007 Nicholas Shanks ([email protected])
- * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
- * Copyright (C) 2007 Alexey Proskuryakov <[email protected]>
- * Copyright (C) 2007, 2008 Eric Seidel <[email protected]>
- * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
- * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
- * Copyright (C) Research In Motion Limited 2011. All rights reserved.
- * Copyright (C) 2013 Google Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "DocumentRuleSets.h"
-
-#include "CSSDefaultStyleSheets.h"
-#include "CSSStyleSheet.h"
-#include "DocumentStyleSheetCollection.h"
-#include "MediaQueryEvaluator.h"
-#include "StyleResolver.h"
-#include "StyleSheetContents.h"
-
-namespace WebCore {
-
-DocumentRuleSets::DocumentRuleSets()
-{
-}
-
-DocumentRuleSets::~DocumentRuleSets()
-{
-}
-
-void DocumentRuleSets::initUserStyle(DocumentStyleSheetCollection* styleSheetCollection, const MediaQueryEvaluator& medium, StyleResolver& resolver)
-{
-    OwnPtr<RuleSet> tempUserStyle = RuleSet::create();
-    if (CSSStyleSheet* pageUserSheet = styleSheetCollection->pageUserSheet())
-        tempUserStyle->addRulesFromSheet(pageUserSheet->contents(), medium, &resolver);
-    collectRulesFromUserStyleSheets(styleSheetCollection->injectedUserStyleSheets(), *tempUserStyle, medium, resolver);
-    collectRulesFromUserStyleSheets(styleSheetCollection->documentUserStyleSheets(), *tempUserStyle, medium, resolver);
-    if (tempUserStyle->m_ruleCount > 0 || tempUserStyle->m_pageRules.size() > 0)
-        m_userStyle = tempUserStyle.release();
-}
-
-void DocumentRuleSets::collectRulesFromUserStyleSheets(const Vector<RefPtr<CSSStyleSheet> >& userSheets, RuleSet& userStyle, const MediaQueryEvaluator& medium, StyleResolver& resolver)
-{
-    for (unsigned i = 0; i < userSheets.size(); ++i) {
-        ASSERT(userSheets[i]->contents()->isUserStyleSheet());
-        userStyle.addRulesFromSheet(userSheets[i]->contents(), medium, &resolver);
-    }
-}
-
-static PassOwnPtr<RuleSet> makeRuleSet(const Vector<RuleFeature>& rules)
-{
-    size_t size = rules.size();
-    if (!size)
-        return nullptr;
-    OwnPtr<RuleSet> ruleSet = RuleSet::create();
-    for (size_t i = 0; i < size; ++i)
-        ruleSet->addRule(rules[i].rule, rules[i].selectorIndex, rules[i].hasDocumentSecurityOrigin ? RuleHasDocumentSecurityOrigin : RuleHasNoSpecialState);
-    ruleSet->shrinkToFit();
-    return ruleSet.release();
-}
-
-void DocumentRuleSets::resetAuthorStyle()
-{
-    m_authorStyle = RuleSet::create();
-    m_authorStyle->disableAutoShrinkToFit();
-}
-
-void DocumentRuleSets::appendAuthorStyleSheets(unsigned firstNew, const Vector<RefPtr<CSSStyleSheet> >& styleSheets, MediaQueryEvaluator* medium, InspectorCSSOMWrappers& inspectorCSSOMWrappers, bool isViewSource, StyleResolver* resolver)
-{
-    // This handles sheets added to the end of the stylesheet list only. In other cases the style resolver
-    // needs to be reconstructed. To handle insertions too the rule order numbers would need to be updated.
-    unsigned size = styleSheets.size();
-    for (unsigned i = firstNew; i < size; ++i) {
-        CSSStyleSheet* cssSheet = styleSheets[i].get();
-        ASSERT(!cssSheet->disabled());
-        if (cssSheet->mediaQueries() && !medium->eval(cssSheet->mediaQueries(), resolver))
-            continue;
-        StyleSheetContents* sheet = cssSheet->contents();
-#if ENABLE(STYLE_SCOPED) || 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);
-        inspectorCSSOMWrappers.collectFromStyleSheetIfNeeded(cssSheet);
-    }
-    m_authorStyle->shrinkToFit();
-    collectFeatures(isViewSource, resolver->scopeResolver());
-}
-
-void DocumentRuleSets::collectFeatures(bool isViewSource, StyleScopeResolver* scopeResolver)
-{
-    m_features.clear();
-    // Collect all ids and rules using sibling selectors (:first-child and similar)
-    // in the current set of stylesheets. Style sharing code uses this information to reject
-    // sharing candidates.
-    if (CSSDefaultStyleSheets::defaultStyle)
-        m_features.add(CSSDefaultStyleSheets::defaultStyle->features());
-    if (m_authorStyle)
-        m_features.add(m_authorStyle->features());
-    if (isViewSource)
-        m_features.add(CSSDefaultStyleSheets::viewSourceStyle()->features());
-
-    if (scopeResolver)
-        scopeResolver->collectFeaturesTo(m_features);
-    if (m_userStyle)
-        m_features.add(m_userStyle->features());
-
-    m_siblingRuleSet = makeRuleSet(m_features.siblingRules);
-    m_uncommonAttributeRuleSet = makeRuleSet(m_features.uncommonAttributeRules);
-}
-
-void DocumentRuleSets::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
-{
-    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
-    info.addMember(m_authorStyle);
-    info.addMember(m_userStyle);
-    info.addMember(m_features);
-    info.addMember(m_siblingRuleSet);
-    info.addMember(m_uncommonAttributeRuleSet);
-}
-
-} // namespace WebCore

Deleted: trunk/Source/WebCore/css/DocumentRuleSets.h (141972 => 141973)


--- trunk/Source/WebCore/css/DocumentRuleSets.h	2013-02-06 07:44:53 UTC (rev 141972)
+++ trunk/Source/WebCore/css/DocumentRuleSets.h	2013-02-06 08:00:14 UTC (rev 141973)
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 1999 Lars Knoll ([email protected])
- * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
- * Copyright (C) 2013 Google Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef DocumentRuleSets_h
-#define DocumentRuleSets_h
-
-#include "RuleFeature.h"
-
-#include <wtf/OwnPtr.h>
-#include <wtf/RefPtr.h>
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-class CSSStyleRule;
-class CSSStyleSheet;
-class DocumentStyleSheetCollection;
-class InspectorCSSOMWrappers;
-class MediaQueryEvaluator;
-class RuleSet;
-class StyleResolver;
-class StyleScopeResolver;
-
-class DocumentRuleSets {
-public:
-    DocumentRuleSets();
-    ~DocumentRuleSets();
-    RuleSet* authorStyle() const { return m_authorStyle.get(); }
-    RuleSet* userStyle() const { return m_userStyle.get(); }
-    RuleFeatureSet& features() { return m_features; }
-    const RuleFeatureSet& features() const { return m_features; }
-    RuleSet* sibling() const { return m_siblingRuleSet.get(); }
-    RuleSet* uncommonAttribute() const { return m_uncommonAttributeRuleSet.get(); }
-
-    void initUserStyle(DocumentStyleSheetCollection*, const MediaQueryEvaluator&, StyleResolver&);
-    void resetAuthorStyle();
-    void appendAuthorStyleSheets(unsigned firstNew, const Vector<RefPtr<CSSStyleSheet> >&, MediaQueryEvaluator*, InspectorCSSOMWrappers&, bool isViewSource, StyleResolver*);
-
-    void collectFeatures(bool isViewSource, StyleScopeResolver*);
-    void reportMemoryUsage(MemoryObjectInfo*) const;
-
-private:
-    void collectRulesFromUserStyleSheets(const Vector<RefPtr<CSSStyleSheet> >&, RuleSet& userStyle, const MediaQueryEvaluator&, StyleResolver&);
-    OwnPtr<RuleSet> m_authorStyle;
-    OwnPtr<RuleSet> m_userStyle;
-    RuleFeatureSet m_features;
-    OwnPtr<RuleSet> m_siblingRuleSet;
-    OwnPtr<RuleSet> m_uncommonAttributeRuleSet;
-};
-
-} // namespace WebCore
-
-#endif // DocumentRuleSets_h

Modified: trunk/Source/WebCore/css/StyleResolver.cpp (141972 => 141973)


--- trunk/Source/WebCore/css/StyleResolver.cpp	2013-02-06 07:44:53 UTC (rev 141972)
+++ trunk/Source/WebCore/css/StyleResolver.cpp	2013-02-06 08:00:14 UTC (rev 141973)
@@ -259,10 +259,16 @@
     if (m_rootDefaultStyle && view)
         m_medium = adoptPtr(new MediaQueryEvaluator(view->mediaType(), view->frame(), m_rootDefaultStyle.get()));
 
-    m_ruleSets.resetAuthorStyle();
+    resetAuthorStyle();
 
     DocumentStyleSheetCollection* styleSheetCollection = document->styleSheetCollection();
-    m_ruleSets.initUserStyle(styleSheetCollection, *m_medium, *this);
+    OwnPtr<RuleSet> tempUserStyle = RuleSet::create();
+    if (CSSStyleSheet* pageUserSheet = styleSheetCollection->pageUserSheet())
+        tempUserStyle->addRulesFromSheet(pageUserSheet->contents(), *m_medium, this);
+    collectRulesFromUserStyleSheets(styleSheetCollection->injectedUserStyleSheets(), *tempUserStyle);
+    collectRulesFromUserStyleSheets(styleSheetCollection->documentUserStyleSheets(), *tempUserStyle);
+    if (tempUserStyle->m_ruleCount > 0 || tempUserStyle->m_pageRules.size() > 0)
+        m_userStyle = tempUserStyle.release();
 
 #if ENABLE(SVG_FONTS)
     if (document->svgExtensions()) {
@@ -276,9 +282,56 @@
     appendAuthorStyleSheets(0, styleSheetCollection->activeAuthorStyleSheets());
 }
 
+void StyleResolver::collectRulesFromUserStyleSheets(const Vector<RefPtr<CSSStyleSheet> >& userSheets, RuleSet& userStyle)
+{
+    for (unsigned i = 0; i < userSheets.size(); ++i) {
+        ASSERT(userSheets[i]->contents()->isUserStyleSheet());
+        userStyle.addRulesFromSheet(userSheets[i]->contents(), *m_medium, this);
+    }
+}
+
+static PassOwnPtr<RuleSet> makeRuleSet(const Vector<RuleFeature>& rules)
+{
+    size_t size = rules.size();
+    if (!size)
+        return nullptr;
+    OwnPtr<RuleSet> ruleSet = RuleSet::create();
+    for (size_t i = 0; i < size; ++i)
+        ruleSet->addRule(rules[i].rule, rules[i].selectorIndex, rules[i].hasDocumentSecurityOrigin ? RuleHasDocumentSecurityOrigin : RuleHasNoSpecialState);
+    ruleSet->shrinkToFit();
+    return ruleSet.release();
+}
+
+void StyleResolver::resetAuthorStyle()
+{
+    m_authorStyle = RuleSet::create();
+    m_authorStyle->disableAutoShrinkToFit();
+}
+
 void StyleResolver::appendAuthorStyleSheets(unsigned firstNew, const Vector<RefPtr<CSSStyleSheet> >& styleSheets)
 {
-    m_ruleSets.appendAuthorStyleSheets(firstNew, styleSheets, m_medium.get(), m_inspectorCSSOMWrappers, document()->isViewSource(), this);
+    // This handles sheets added to the end of the stylesheet list only. In other cases the style resolver
+    // needs to be reconstructed. To handle insertions too the rule order numbers would need to be updated.
+    unsigned size = styleSheets.size();
+    for (unsigned i = firstNew; i < size; ++i) {
+        CSSStyleSheet* cssSheet = styleSheets[i].get();
+        ASSERT(!cssSheet->disabled());
+        if (cssSheet->mediaQueries() && !m_medium->eval(cssSheet->mediaQueries(), this))
+            continue;
+        StyleSheetContents* sheet = cssSheet->contents();
+#if ENABLE(STYLE_SCOPED) || ENABLE(SHADOW_DOM)
+        if (const ContainerNode* scope = StyleScopeResolver::scopeFor(cssSheet)) {
+            ensureScopeResolver()->ensureRuleSetFor(scope)->addRulesFromSheet(sheet, *m_medium, this, scope);
+            continue;
+        }
+#endif
+
+        m_authorStyle->addRulesFromSheet(sheet, *m_medium, this);
+        m_inspectorCSSOMWrappers.collectFromStyleSheetIfNeeded(cssSheet);
+    }
+    m_authorStyle->shrinkToFit();
+    collectFeatures();
+    
     if (document()->renderer() && document()->renderer()->style())
         document()->renderer()->style()->font().update(fontSelector());
 
@@ -586,7 +639,7 @@
         return;
 
     // Match global author rules.
-    MatchRequest matchRequest(m_ruleSets.authorStyle(), includeEmptyRules);
+    MatchRequest matchRequest(m_authorStyle.get(), includeEmptyRules);
     RuleRange ruleRange = result.ranges.authorRuleRange();
     collectMatchingRules(matchRequest, ruleRange);
     collectMatchingRulesForRegion(matchRequest, ruleRange);
@@ -597,13 +650,13 @@
 
 void StyleResolver::matchUserRules(MatchResult& result, bool includeEmptyRules)
 {
-    if (!m_ruleSets.userStyle())
+    if (!m_userStyle)
         return;
     
     m_state.matchedRules.clear();
 
     result.ranges.lastUserRule = result.matchedProperties.size() - 1;
-    MatchRequest matchRequest(m_ruleSets.userStyle(), includeEmptyRules);
+    MatchRequest matchRequest(m_userStyle.get(), includeEmptyRules);
     RuleRange ruleRange = result.ranges.userRuleRange();
     collectMatchingRules(matchRequest, ruleRange);
     collectMatchingRulesForRegion(matchRequest, ruleRange);
@@ -739,7 +792,7 @@
 bool StyleResolver::classNamesAffectedByRules(const SpaceSplitString& classNames) const
 {
     for (unsigned i = 0; i < classNames.size(); ++i) {
-        if (m_ruleSets.features().classesInRules.contains(classNames[i].impl()))
+        if (m_features.classesInRules.contains(classNames[i].impl()))
             return true;
     }
     return false;
@@ -814,7 +867,7 @@
     if (p->isSVGElement() && static_cast<SVGElement*>(p)->animatedSMILStyleProperties())
         return 0;
 #endif
-    if (p->hasID() && m_ruleSets.features().idsInRules.contains(p->idForStyleResolution().impl()))
+    if (p->hasID() && m_features.idsInRules.contains(p->idForStyleResolution().impl()))
         return 0;
 
     RenderStyle* parentStyle = p->renderStyle();
@@ -996,7 +1049,7 @@
     if (element->additionalPresentationAttributeStyle() != state.styledElement->additionalPresentationAttributeStyle())
         return false;
 
-    if (element->hasID() && m_ruleSets.features().idsInRules.contains(element->idForStyleResolution().impl()))
+    if (element->hasID() && m_features.idsInRules.contains(element->idForStyleResolution().impl()))
         return false;
     if (element->hasScopedHTMLStyleChild())
         return false;
@@ -1079,7 +1132,7 @@
         return 0;
 #endif
     // Ids stop style sharing if they show up in the stylesheets.
-    if (state.styledElement->hasID() && m_ruleSets.features().idsInRules.contains(state.styledElement->idForStyleResolution().impl()))
+    if (state.styledElement->hasID() && m_features.idsInRules.contains(state.styledElement->idForStyleResolution().impl()))
         return 0;
     if (parentElementPreventsSharing(state.element->parentElement()))
         return 0;
@@ -1111,10 +1164,10 @@
         return 0;
 
     // Can't share if sibling rules apply. This is checked at the end as it should rarely fail.
-    if (styleSharingCandidateMatchesRuleSet(m_ruleSets.sibling()))
+    if (styleSharingCandidateMatchesRuleSet(m_siblingRuleSet.get()))
         return 0;
     // Can't share if attribute rules apply.
-    if (styleSharingCandidateMatchesRuleSet(m_ruleSets.uncommonAttribute()))
+    if (styleSharingCandidateMatchesRuleSet(m_uncommonAttributeRuleSet.get()))
         return 0;
     // Can't share if @host @-rules apply.
     if (styleSharingCandidateMatchesHostRules())
@@ -1383,7 +1436,7 @@
     bool needsCollection = false;
     CSSDefaultStyleSheets::ensureDefaultStyleSheetsForElement(element, needsCollection);
     if (needsCollection)
-        m_ruleSets.collectFeatures(document()->isViewSource(), m_scopeResolver.get());
+        collectFeatures();
 
     MatchResult matchResult;
     if (matchingBehavior == MatchOnlyUserAgentRules)
@@ -1584,9 +1637,9 @@
     
     MatchResult result;
     matchPageRules(result, CSSDefaultStyleSheets::defaultPrintStyle, isLeft, isFirst, page);
-    matchPageRules(result, m_ruleSets.userStyle(), isLeft, isFirst, page);
+    matchPageRules(result, m_userStyle.get(), isLeft, isFirst, page);
     // Only consider the global author RuleSet for @page rules, as per the HTML5 spec.
-    matchPageRules(result, m_ruleSets.authorStyle(), isLeft, isFirst, page);
+    matchPageRules(result, m_authorStyle.get(), isLeft, isFirst, page);
     m_state.lineHeightValue = 0;
     bool inheritedOnly = false;
 #if ENABLE(CSS_VARIABLES)
@@ -1956,18 +2009,18 @@
     // FIXME (BUG 72472): We don't add @-webkit-region rules of scoped style sheets for the moment,
     // so all region rules are global by default. Verify whether that can stand or needs changing.
 
-    unsigned rulesSize = m_ruleSets.authorStyle()->m_regionSelectorsAndRuleSets.size();
+    unsigned rulesSize = m_authorStyle->m_regionSelectorsAndRuleSets.size();
     for (unsigned i = 0; i < rulesSize; ++i) {
-        ASSERT(m_ruleSets.authorStyle()->m_regionSelectorsAndRuleSets.at(i).ruleSet.get());
-        if (checkRegionSelector(m_ruleSets.authorStyle()->m_regionSelectorsAndRuleSets.at(i).selector, regionElement))
+        ASSERT(m_authorStyle->m_regionSelectorsAndRuleSets.at(i).ruleSet.get());
+        if (checkRegionSelector(m_authorStyle->m_regionSelectorsAndRuleSets.at(i).selector, regionElement))
             return true;
     }
 
-    if (m_ruleSets.userStyle()) {
-        rulesSize = m_ruleSets.userStyle()->m_regionSelectorsAndRuleSets.size();
+    if (m_userStyle) {
+        rulesSize = m_userStyle->m_regionSelectorsAndRuleSets.size();
         for (unsigned i = 0; i < rulesSize; ++i) {
-            ASSERT(m_ruleSets.userStyle()->m_regionSelectorsAndRuleSets.at(i).ruleSet.get());
-            if (checkRegionSelector(m_ruleSets.userStyle()->m_regionSelectorsAndRuleSets.at(i).selector, regionElement))
+            ASSERT(m_userStyle->m_regionSelectorsAndRuleSets.at(i).ruleSet.get());
+            if (checkRegionSelector(m_userStyle->m_regionSelectorsAndRuleSets.at(i).selector, regionElement))
                 return true;
         }
     }
@@ -2831,7 +2884,7 @@
                     state.style->setContent(value.isNull() ? emptyAtom : value.impl(), didSet);
                     didSet = true;
                     // register the fact that the attribute value affects the style
-                    m_ruleSets.features().attrsInRules.add(attr.localName().impl());
+                    m_features.attrsInRules.add(attr.localName().impl());
                 } else if (contentValue->isCounter()) {
                     Counter* counterValue = contentValue->getCounterValue();
                     EListStyleType listStyleType = NoneListStyle;
@@ -5113,6 +5166,28 @@
 #endif
 }
 
+void StyleResolver::collectFeatures()
+{
+    m_features.clear();
+    // Collect all ids and rules using sibling selectors (:first-child and similar)
+    // in the current set of stylesheets. Style sharing code uses this information to reject
+    // sharing candidates.
+    if (CSSDefaultStyleSheets::defaultStyle)
+        m_features.add(CSSDefaultStyleSheets::defaultStyle->features());
+    if (m_authorStyle)
+        m_features.add(m_authorStyle->features());
+    if (document()->isViewSource())
+        m_features.add(CSSDefaultStyleSheets::viewSourceStyle()->features());
+
+    if (m_scopeResolver)
+        m_scopeResolver->collectFeaturesTo(m_features);
+    if (m_userStyle)
+        m_features.add(m_userStyle->features());
+
+    m_siblingRuleSet = makeRuleSet(m_features.siblingRules);
+    m_uncommonAttributeRuleSet = makeRuleSet(m_features.uncommonAttributeRules);
+}
+
 void StyleResolver::MatchedProperties::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
 {
     MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
@@ -5137,7 +5212,11 @@
 void StyleResolver::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
 {
     MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
-    info.addMember(m_ruleSets, "ruleSets");
+    info.addMember(m_authorStyle, "authorStyle");
+    info.addMember(m_userStyle, "userStyle");
+    info.addMember(m_features, "features");
+    info.addMember(m_siblingRuleSet, "siblingRuleSet");
+    info.addMember(m_uncommonAttributeRuleSet, "uncommonAttributeRuleSet");
     info.addMember(m_keyframesRuleMap, "keyframesRuleMap");
     info.addMember(m_matchedPropertiesCache, "matchedPropertiesCache");
     info.addMember(m_matchedPropertiesCacheSweepTimer, "matchedPropertiesCacheSweepTimer");

Modified: trunk/Source/WebCore/css/StyleResolver.h (141972 => 141973)


--- trunk/Source/WebCore/css/StyleResolver.h	2013-02-06 07:44:53 UTC (rev 141972)
+++ trunk/Source/WebCore/css/StyleResolver.h	2013-02-06 08:00:14 UTC (rev 141973)
@@ -26,7 +26,6 @@
 #include "CSSRuleList.h"
 #include "CSSToStyleMap.h"
 #include "CSSValueList.h"
-#include "DocumentRuleSets.h"
 #include "InspectorCSSOMWrappers.h"
 #include "LinkHash.h"
 #include "MediaQueryExp.h"
@@ -170,7 +169,6 @@
     RenderStyle* rootElementStyle() const { return m_state.rootElementStyle; }
     Element* element() const { return m_state.element; }
     Document* document() const { return m_document; }
-    StyleScopeResolver* scopeResolver() const { return m_scopeResolver.get(); }
     const FontDescription& fontDescription() { return style()->fontDescription(); }
     const FontDescription& parentFontDescription() { return parentStyle()->fontDescription(); }
     void setFontDescription(const FontDescription& fontDescription) { m_state.fontDirty |= style()->setFontDescription(fontDescription); }
@@ -181,13 +179,10 @@
     void setTextOrientation(TextOrientation textOrientation) { m_state.fontDirty |= style()->setTextOrientation(textOrientation); }
     bool hasParentNode() const { return m_state.parentNode; }
 
-    // FIXME: It could be better to call m_ruleSets.appendAuthorStyleSheets() directly after we factor StyleRsolver further.
-    // https://bugs.webkit.org/show_bug.cgi?id=108890
+    void resetAuthorStyle();
     void appendAuthorStyleSheets(unsigned firstNew, const Vector<RefPtr<CSSStyleSheet> >&);
 
-    DocumentRuleSets& ruleSets() { return m_ruleSets; }
-    const DocumentRuleSets& ruleSets() const { return m_ruleSets; }
-
+private:
 #if ENABLE(STYLE_SCOPED) || ENABLE(SHADOW_DOM)
     StyleScopeResolver* ensureScopeResolver()
     {
@@ -206,9 +201,9 @@
     }
 #endif
 
-private:
     void initForStyleResolve(Element*, RenderStyle* parentStyle = 0, PseudoId = NOPSEUDO);
     void initElement(Element*);
+    void collectFeatures();
     RenderStyle* locateSharedStyle();
     bool styleSharingCandidateMatchesRuleSet(RuleSet*);
     bool styleSharingCandidateMatchesHostRules();
@@ -276,9 +271,9 @@
 
     bool checkRegionStyle(Element* regionElement);
 
-    bool usesSiblingRules() const { return !m_ruleSets.features().siblingRules.isEmpty(); }
-    bool usesFirstLineRules() const { return m_ruleSets.features().usesFirstLineRules; }
-    bool usesBeforeAfterRules() const { return m_ruleSets.features().usesBeforeAfterRules; }
+    bool usesSiblingRules() const { return !m_features.siblingRules.isEmpty(); }
+    bool usesFirstLineRules() const { return m_features.usesFirstLineRules; }
+    bool usesBeforeAfterRules() const { return m_features.usesBeforeAfterRules; }
 
     static bool createTransformOperations(CSSValue* inValue, RenderStyle* inStyle, RenderStyle* rootStyle, TransformOperations& outOperations);
     
@@ -417,8 +412,13 @@
     bool isFirstPage(int pageIndex) const;
     String pageName(int pageIndex) const;
 
-    DocumentRuleSets m_ruleSets;
+    OwnPtr<RuleSet> m_authorStyle;
+    OwnPtr<RuleSet> m_userStyle;
 
+    RuleFeatureSet m_features;
+    OwnPtr<RuleSet> m_siblingRuleSet;
+    OwnPtr<RuleSet> m_uncommonAttributeRuleSet;
+
     typedef HashMap<AtomicStringImpl*, RefPtr<StyleRuleKeyframes> > KeyframesRuleMap;
     KeyframesRuleMap m_keyframesRuleMap;
 
@@ -524,6 +524,8 @@
 private:
     static RenderStyle* s_styleNotYetAvailable;
 
+    void collectRulesFromUserStyleSheets(const Vector<RefPtr<CSSStyleSheet> >&, RuleSet& userStyle);
+
     void cacheBorderAndBackground();
 
 private:
@@ -601,19 +603,19 @@
 inline bool StyleResolver::hasSelectorForAttribute(const AtomicString &attributeName) const
 {
     ASSERT(!attributeName.isEmpty());
-    return m_ruleSets.features().attrsInRules.contains(attributeName.impl());
+    return m_features.attrsInRules.contains(attributeName.impl());
 }
 
 inline bool StyleResolver::hasSelectorForClass(const AtomicString& classValue) const
 {
     ASSERT(!classValue.isEmpty());
-    return m_ruleSets.features().classesInRules.contains(classValue.impl());
+    return m_features.classesInRules.contains(classValue.impl());
 }
 
 inline bool StyleResolver::hasSelectorForId(const AtomicString& idValue) const
 {
     ASSERT(!idValue.isEmpty());
-    return m_ruleSets.features().idsInRules.contains(idValue.impl());
+    return m_features.idsInRules.contains(idValue.impl());
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/dom/DocumentStyleSheetCollection.cpp (141972 => 141973)


--- trunk/Source/WebCore/dom/DocumentStyleSheetCollection.cpp	2013-02-06 07:44:53 UTC (rev 141972)
+++ trunk/Source/WebCore/dom/DocumentStyleSheetCollection.cpp	2013-02-06 08:00:14 UTC (rev 141973)
@@ -478,7 +478,7 @@
     else {
         StyleResolver* styleResolver = m_document->styleResolver();
         if (styleResolverUpdateType == Reset) {
-            styleResolver->ruleSets().resetAuthorStyle();
+            styleResolver->resetAuthorStyle();
             styleResolver->appendAuthorStyleSheets(0, activeCSSStyleSheets);
         } else {
             ASSERT(styleResolverUpdateType == Additive);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to