Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. | 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 | 24 |
| 25 #include "core/css/RuleFeature.h" | 25 #include "core/css/RuleFeature.h" |
| 26 #include "core/css/StyleRule.h" | 26 #include "core/css/StyleRule.h" |
| 27 #include "wtf/Forward.h" | 27 #include "wtf/Forward.h" |
| 28 #include "wtf/HashMap.h" | 28 #include "wtf/HashMap.h" |
| 29 #include "wtf/LinkedStack.h" | 29 #include "wtf/LinkedStack.h" |
| 30 | 30 |
| 31 namespace WebCore { | 31 namespace WebCore { |
| 32 | 32 |
| 33 enum AddRuleFlags { | 33 enum AddRuleFlags { |
| 34 RuleHasNoSpecialState = 0, | 34 RuleHasNoSpecialState = 0, |
| 35 RuleHasDocumentSecurityOrigin = 1, | 35 RuleHasDocumentSecurityOrigin = 1, |
| 36 RuleCanUseFastCheckSelector = 1 << 1, | 36 RuleCanUseFastCheckSelector = 1 << 1, |
| 37 RuleIsInRegionRule = 1 << 2, | 37 RuleIsInRegionRule = 1 << 2, |
| 38 RuleSkipsFontFaceAndViewportRule = 1 << 3 | |
|
eseidel
2013/11/06 01:39:10
Does this mean you can have rules which ignore the
tasak
2013/11/06 05:42:26
I mean, if RuleSkipsFontFaceAndViewportRule is set
| |
| 38 }; | 39 }; |
| 39 | 40 |
| 40 enum PropertyWhitelistType { | 41 enum PropertyWhitelistType { |
| 41 PropertyWhitelistNone = 0, | 42 PropertyWhitelistNone = 0, |
| 42 PropertyWhitelistRegion, | 43 PropertyWhitelistRegion, |
| 43 PropertyWhitelistCue | 44 PropertyWhitelistCue |
| 44 }; | 45 }; |
| 45 | 46 |
| 46 class CSSSelector; | 47 class CSSSelector; |
| 47 class ContainerNode; | 48 class ContainerNode; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 unsigned d[4]; | 102 unsigned d[4]; |
| 102 }; | 103 }; |
| 103 | 104 |
| 104 COMPILE_ASSERT(sizeof(RuleData) == sizeof(SameSizeAsRuleData), RuleData_should_s tay_small); | 105 COMPILE_ASSERT(sizeof(RuleData) == sizeof(SameSizeAsRuleData), RuleData_should_s tay_small); |
| 105 | 106 |
| 106 class RuleSet { | 107 class RuleSet { |
| 107 WTF_MAKE_NONCOPYABLE(RuleSet); WTF_MAKE_FAST_ALLOCATED; | 108 WTF_MAKE_NONCOPYABLE(RuleSet); WTF_MAKE_FAST_ALLOCATED; |
| 108 public: | 109 public: |
| 109 static PassOwnPtr<RuleSet> create() { return adoptPtr(new RuleSet); } | 110 static PassOwnPtr<RuleSet> create() { return adoptPtr(new RuleSet); } |
| 110 | 111 |
| 111 void addRulesFromSheet(StyleSheetContents*, const MediaQueryEvaluator&, Styl eResolver* = 0, const ContainerNode* = 0); | 112 void addRulesFromSheet(StyleSheetContents*, const MediaQueryEvaluator&, Styl eResolver* = 0, const ContainerNode* = 0, bool processFontFaceAndViewportRule = true); |
| 112 void addStyleRule(StyleRule*, AddRuleFlags); | 113 void addStyleRule(StyleRule*, AddRuleFlags); |
| 113 void addRule(StyleRule*, unsigned selectorIndex, AddRuleFlags); | 114 void addRule(StyleRule*, unsigned selectorIndex, AddRuleFlags); |
| 115 void addViewportRule(StyleRuleViewport*); | |
| 114 | 116 |
| 115 const RuleFeatureSet& features() const { return m_features; } | 117 const RuleFeatureSet& features() const { return m_features; } |
| 116 | 118 |
| 117 const RuleData* idRules(StringImpl* key) const { ASSERT(!m_pendingRules); re turn m_idRules.get(key); } | 119 const RuleData* idRules(StringImpl* key) const { ASSERT(!m_pendingRules); re turn m_idRules.get(key); } |
| 118 const RuleData* classRules(StringImpl* key) const { ASSERT(!m_pendingRules); return m_classRules.get(key); } | 120 const RuleData* classRules(StringImpl* key) const { ASSERT(!m_pendingRules); return m_classRules.get(key); } |
| 119 const RuleData* tagRules(StringImpl* key) const { ASSERT(!m_pendingRules); r eturn m_tagRules.get(key); } | 121 const RuleData* tagRules(StringImpl* key) const { ASSERT(!m_pendingRules); r eturn m_tagRules.get(key); } |
| 120 const RuleData* shadowPseudoElementRules(StringImpl* key) const { ASSERT(!m_ pendingRules); return m_shadowPseudoElementRules.get(key); } | 122 const RuleData* shadowPseudoElementRules(StringImpl* key) const { ASSERT(!m_ pendingRules); return m_shadowPseudoElementRules.get(key); } |
| 121 const Vector<RuleData>* linkPseudoClassRules() const { ASSERT(!m_pendingRule s); return &m_linkPseudoClassRules; } | 123 const Vector<RuleData>* linkPseudoClassRules() const { ASSERT(!m_pendingRule s); return &m_linkPseudoClassRules; } |
| 122 const Vector<RuleData>* cuePseudoRules() const { ASSERT(!m_pendingRules); re turn &m_cuePseudoRules; } | 124 const Vector<RuleData>* cuePseudoRules() const { ASSERT(!m_pendingRules); re turn &m_cuePseudoRules; } |
| 123 const Vector<RuleData>* focusPseudoClassRules() const { ASSERT(!m_pendingRul es); return &m_focusPseudoClassRules; } | 125 const Vector<RuleData>* focusPseudoClassRules() const { ASSERT(!m_pendingRul es); return &m_focusPseudoClassRules; } |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 148 typedef HashMap<StringImpl*, OwnPtr<LinkedStack<RuleData> > > PendingRuleMap ; | 150 typedef HashMap<StringImpl*, OwnPtr<LinkedStack<RuleData> > > PendingRuleMap ; |
| 149 typedef HashMap<StringImpl*, OwnPtr<RuleData> > CompactRuleMap; | 151 typedef HashMap<StringImpl*, OwnPtr<RuleData> > CompactRuleMap; |
| 150 | 152 |
| 151 RuleSet() | 153 RuleSet() |
| 152 : m_ruleCount(0) | 154 : m_ruleCount(0) |
| 153 { | 155 { |
| 154 } | 156 } |
| 155 | 157 |
| 156 void addToRuleSet(StringImpl* key, PendingRuleMap&, const RuleData&); | 158 void addToRuleSet(StringImpl* key, PendingRuleMap&, const RuleData&); |
| 157 void addPageRule(StyleRulePage*); | 159 void addPageRule(StyleRulePage*); |
| 158 void addViewportRule(StyleRuleViewport*); | |
| 159 void addRegionRule(StyleRuleRegion*, bool hasDocumentSecurityOrigin, const C ontainerNode* scope); | 160 void addRegionRule(StyleRuleRegion*, bool hasDocumentSecurityOrigin, const C ontainerNode* scope); |
| 160 | 161 |
| 161 void addChildRules(const Vector<RefPtr<StyleRuleBase> >&, const MediaQueryEv aluator& medium, StyleResolver*, const ContainerNode* scope, bool hasDocumentSec urityOrigin, AddRuleFlags); | 162 void addChildRules(const Vector<RefPtr<StyleRuleBase> >&, const MediaQueryEv aluator& medium, StyleResolver*, const ContainerNode* scope, bool hasDocumentSec urityOrigin, AddRuleFlags); |
| 162 bool findBestRuleSetAndAdd(const CSSSelector*, RuleData&); | 163 bool findBestRuleSetAndAdd(const CSSSelector*, RuleData&); |
| 163 | 164 |
| 164 void compactRules(); | 165 void compactRules(); |
| 165 static void compactPendingRules(PendingRuleMap&, CompactRuleMap&); | 166 static void compactPendingRules(PendingRuleMap&, CompactRuleMap&); |
| 166 | 167 |
| 167 struct PendingRuleMaps { | 168 struct PendingRuleMaps { |
| 168 PendingRuleMap idRules; | 169 PendingRuleMap idRules; |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 190 Vector<StyleRulePage*> m_pageRules; | 191 Vector<StyleRulePage*> m_pageRules; |
| 191 Vector<StyleRuleViewport*> m_viewportRules; | 192 Vector<StyleRuleViewport*> m_viewportRules; |
| 192 | 193 |
| 193 unsigned m_ruleCount; | 194 unsigned m_ruleCount; |
| 194 OwnPtr<PendingRuleMaps> m_pendingRules; | 195 OwnPtr<PendingRuleMaps> m_pendingRules; |
| 195 }; | 196 }; |
| 196 | 197 |
| 197 } // namespace WebCore | 198 } // namespace WebCore |
| 198 | 199 |
| 199 #endif // RuleSet_h | 200 #endif // RuleSet_h |
| OLD | NEW |