<https://webkit.org/b/119936> Fix some encapsulation issues of RuleSet
authorbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Aug 2013 21:39:43 +0000 (21:39 +0000)
committerbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Aug 2013 21:39:43 +0000 (21:39 +0000)
Reviewed by Darin Adler.

None of the attributes of RuleSet should be modified directly.

* css/DocumentRuleSets.cpp:
(WebCore::DocumentRuleSets::initUserStyle):
* css/ElementRuleCollector.cpp:
(WebCore::ElementRuleCollector::collectMatchingRulesForRegion):
* css/RuleSet.h:
(WebCore::RuleSet::RuleSetSelectorPair::RuleSetSelectorPair):
(WebCore::RuleSet::regionSelectorsAndRuleSets):
(WebCore::RuleSet::ruleCount):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::checkRegionStyle):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@154299 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/css/DocumentRuleSets.cpp
Source/WebCore/css/ElementRuleCollector.cpp
Source/WebCore/css/RuleSet.h
Source/WebCore/css/StyleResolver.cpp

index 35bb988ab355283ee3a7062fcb5bb0632a73c0fe..e324588313e714a4e81fd7f59dec2c031f911fb7 100644 (file)
@@ -1,3 +1,22 @@
+2013-08-19  Benjamin Poulain  <benjamin@webkit.org>
+
+        <https://webkit.org/b/119936> Fix some encapsulation issues of RuleSet
+
+        Reviewed by Darin Adler.
+
+        None of the attributes of RuleSet should be modified directly.
+
+        * css/DocumentRuleSets.cpp:
+        (WebCore::DocumentRuleSets::initUserStyle):
+        * css/ElementRuleCollector.cpp:
+        (WebCore::ElementRuleCollector::collectMatchingRulesForRegion):
+        * css/RuleSet.h:
+        (WebCore::RuleSet::RuleSetSelectorPair::RuleSetSelectorPair):
+        (WebCore::RuleSet::regionSelectorsAndRuleSets):
+        (WebCore::RuleSet::ruleCount):
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::checkRegionStyle):
+
 2013-08-19  Benjamin Poulain  <benjamin@webkit.org>
 
         <https://webkit.org/b/119937> Remove ElementRuleCollector's m_behaviorAtBoundary
index b0d74fa0277135fbdff386c1feb57f09d7fdabed..979ca451f6006a6077ce16e43b492c52d8d89d4d 100644 (file)
@@ -53,7 +53,7 @@ void DocumentRuleSets::initUserStyle(DocumentStyleSheetCollection* styleSheetCol
         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)
+    if (tempUserStyle->ruleCount() > 0 || tempUserStyle->pageRules().size() > 0)
         m_userStyle = tempUserStyle.release();
 }
 
index c0af5b784b2f19bc6d2c4a189f97363791ef2761..4d8fb640712228db5d83d8fd6690123b9cb5fbec 100644 (file)
@@ -179,11 +179,11 @@ void ElementRuleCollector::collectMatchingRulesForRegion(const MatchRequest& mat
     if (!m_regionForStyling)
         return;
 
-    unsigned size = matchRequest.ruleSet->m_regionSelectorsAndRuleSets.size();
+    unsigned size = matchRequest.ruleSet->regionSelectorsAndRuleSets().size();
     for (unsigned i = 0; i < size; ++i) {
-        const CSSSelector* regionSelector = matchRequest.ruleSet->m_regionSelectorsAndRuleSets.at(i).selector;
+        const CSSSelector* regionSelector = matchRequest.ruleSet->regionSelectorsAndRuleSets().at(i).selector;
         if (checkRegionSelector(regionSelector, toElement(m_regionForStyling->node()))) {
-            RuleSet* regionRules = matchRequest.ruleSet->m_regionSelectorsAndRuleSets.at(i).ruleSet.get();
+            RuleSet* regionRules = matchRequest.ruleSet->regionSelectorsAndRuleSets().at(i).ruleSet.get();
             ASSERT(regionRules);
             collectMatchingRules(MatchRequest(regionRules, matchRequest.includeEmptyRules, matchRequest.scope), ruleRange);
         }
index feafee2de481c77992fba708e0265c84568afc5f..bcd692849e5bcb0b8539f05bfab1f9aa09152f9c 100644 (file)
@@ -106,6 +106,14 @@ COMPILE_ASSERT(sizeof(RuleData) == sizeof(SameSizeAsRuleData), RuleData_should_s
 class RuleSet {
     WTF_MAKE_NONCOPYABLE(RuleSet); WTF_MAKE_FAST_ALLOCATED;
 public:
+    struct RuleSetSelectorPair {
+        RuleSetSelectorPair(const CSSSelector* selector, PassOwnPtr<RuleSet> ruleSet) : selector(selector), ruleSet(ruleSet) { }
+        RuleSetSelectorPair(const RuleSetSelectorPair& pair) : selector(pair.selector), ruleSet(const_cast<RuleSetSelectorPair*>(&pair)->ruleSet.release()) { }
+
+        const CSSSelector* selector;
+        OwnPtr<RuleSet> ruleSet;
+    };
+
     static PassOwnPtr<RuleSet> create() { return adoptPtr(new RuleSet); }
 
     typedef HashMap<AtomicStringImpl*, OwnPtr<Vector<RuleData> > > AtomRuleMap;
@@ -133,12 +141,14 @@ public:
     const Vector<RuleData>* focusPseudoClassRules() const { return &m_focusPseudoClassRules; }
     const Vector<RuleData>* universalRules() const { return &m_universalRules; }
     const Vector<StyleRulePage*>& pageRules() const { return m_pageRules; }
+    const Vector<RuleSetSelectorPair>& regionSelectorsAndRuleSets() const { return m_regionSelectorsAndRuleSets; }
+
+    unsigned ruleCount() const { return m_ruleCount; }
 
 private:
     void addChildRules(const Vector<RefPtr<StyleRuleBase> >&, const MediaQueryEvaluator& medium, StyleResolver*, const ContainerNode* scope, bool hasDocumentSecurityOrigin, AddRuleFlags);
     bool findBestRuleSetAndAdd(const CSSSelector*, RuleData&);
 
-public:
     RuleSet();
 
     AtomRuleMap m_idRules;
@@ -155,15 +165,6 @@ public:
     unsigned m_ruleCount;
     bool m_autoShrinkToFitEnabled;
     RuleFeatureSet m_features;
-
-    struct RuleSetSelectorPair {
-        RuleSetSelectorPair(const CSSSelector* selector, PassOwnPtr<RuleSet> ruleSet) : selector(selector), ruleSet(ruleSet) { }
-        RuleSetSelectorPair(const RuleSetSelectorPair& rs) : selector(rs.selector), ruleSet(const_cast<RuleSetSelectorPair*>(&rs)->ruleSet.release()) { }
-
-        const CSSSelector* selector;
-        OwnPtr<RuleSet> ruleSet;
-    };
-
     Vector<RuleSetSelectorPair> m_regionSelectorsAndRuleSets;
 };
 
index 0f4690e267217658d06c1d60b2d52e18236bdbef..e99d5ec50824300af16e2b8cd8944f95de306e52 100644 (file)
@@ -1432,18 +1432,18 @@ bool StyleResolver::checkRegionStyle(Element* regionElement)
     // 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_ruleSets.authorStyle()->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_ruleSets.authorStyle()->regionSelectorsAndRuleSets().at(i).ruleSet.get());
+        if (checkRegionSelector(m_ruleSets.authorStyle()->regionSelectorsAndRuleSets().at(i).selector, regionElement))
             return true;
     }
 
     if (m_ruleSets.userStyle()) {
-        rulesSize = m_ruleSets.userStyle()->m_regionSelectorsAndRuleSets.size();
+        rulesSize = m_ruleSets.userStyle()->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_ruleSets.userStyle()->regionSelectorsAndRuleSets().at(i).ruleSet.get());
+            if (checkRegionSelector(m_ruleSets.userStyle()->regionSelectorsAndRuleSets().at(i).selector, regionElement))
                 return true;
         }
     }