| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) |
| 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) | 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) |
| 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All r
ights reserved. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All r
ights reserved. |
| 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
| 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
| 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
| 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. | 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
| 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 #include "sky/engine/config.h" | 29 #include "sky/engine/config.h" |
| 30 #include "sky/engine/core/css/RuleSet.h" | 30 #include "sky/engine/core/css/RuleSet.h" |
| 31 | 31 |
| 32 #include "gen/sky/platform/RuntimeEnabledFeatures.h" | 32 #include "gen/sky/platform/RuntimeEnabledFeatures.h" |
| 33 #include "sky/engine/core/css/CSSFontSelector.h" | 33 #include "sky/engine/core/css/CSSFontSelector.h" |
| 34 #include "sky/engine/core/css/CSSSelector.h" | 34 #include "sky/engine/core/css/CSSSelector.h" |
| 35 #include "sky/engine/core/css/CSSSelectorList.h" | 35 #include "sky/engine/core/css/CSSSelectorList.h" |
| 36 #include "sky/engine/core/css/SelectorChecker.h" | 36 #include "sky/engine/core/css/SelectorChecker.h" |
| 37 #include "sky/engine/core/css/StyleRuleKeyframes.h" | |
| 38 #include "sky/engine/core/css/StyleSheetContents.h" | 37 #include "sky/engine/core/css/StyleSheetContents.h" |
| 39 #include "sky/engine/platform/TraceEvent.h" | 38 #include "sky/engine/platform/TraceEvent.h" |
| 40 #include "sky/engine/wtf/TerminatedArrayBuilder.h" | 39 #include "sky/engine/wtf/TerminatedArrayBuilder.h" |
| 41 | 40 |
| 42 namespace blink { | 41 namespace blink { |
| 43 | 42 |
| 44 // ----------------------------------------------------------------- | 43 // ----------------------------------------------------------------- |
| 45 | 44 |
| 46 RuleData::RuleData(StyleRule* rule, unsigned selectorIndex, unsigned position) | 45 RuleData::RuleData(StyleRule* rule, unsigned selectorIndex, unsigned position) |
| 47 : m_rule(rule) | 46 : m_rule(rule) |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 m_universalRules.append(ruleData); | 133 m_universalRules.append(ruleData); |
| 135 } | 134 } |
| 136 } | 135 } |
| 137 | 136 |
| 138 void RuleSet::addFontFaceRule(StyleRuleFontFace* rule) | 137 void RuleSet::addFontFaceRule(StyleRuleFontFace* rule) |
| 139 { | 138 { |
| 140 ensurePendingRules(); // So that m_fontFaceRules.shrinkToFit() gets called. | 139 ensurePendingRules(); // So that m_fontFaceRules.shrinkToFit() gets called. |
| 141 m_fontFaceRules.append(rule); | 140 m_fontFaceRules.append(rule); |
| 142 } | 141 } |
| 143 | 142 |
| 144 void RuleSet::addKeyframesRule(StyleRuleKeyframes* rule) | |
| 145 { | |
| 146 ensurePendingRules(); // So that m_keyframesRules.shrinkToFit() gets called. | |
| 147 m_keyframesRules.append(rule); | |
| 148 } | |
| 149 | |
| 150 void RuleSet::addChildRules(const Vector<RefPtr<StyleRuleBase> >& rules) | 143 void RuleSet::addChildRules(const Vector<RefPtr<StyleRuleBase> >& rules) |
| 151 { | 144 { |
| 152 for (unsigned i = 0; i < rules.size(); ++i) { | 145 for (unsigned i = 0; i < rules.size(); ++i) { |
| 153 StyleRuleBase* rule = rules[i].get(); | 146 StyleRuleBase* rule = rules[i].get(); |
| 154 | 147 |
| 155 if (rule->isStyleRule()) { | 148 if (rule->isStyleRule()) { |
| 156 StyleRule* styleRule = toStyleRule(rule); | 149 StyleRule* styleRule = toStyleRule(rule); |
| 157 | 150 |
| 158 const CSSSelectorList& selectorList = styleRule->selectorList(); | 151 const CSSSelectorList& selectorList = styleRule->selectorList(); |
| 159 for (size_t selectorIndex = 0; selectorIndex != kNotFound; selectorI
ndex = selectorList.indexOfNextSelectorAfter(selectorIndex)) | 152 for (size_t selectorIndex = 0; selectorIndex != kNotFound; selectorI
ndex = selectorList.indexOfNextSelectorAfter(selectorIndex)) |
| 160 addRule(styleRule, selectorIndex); | 153 addRule(styleRule, selectorIndex); |
| 161 } else if (rule->isFontFaceRule()) { | 154 } else if (rule->isFontFaceRule()) { |
| 162 addFontFaceRule(toStyleRuleFontFace(rule)); | 155 addFontFaceRule(toStyleRuleFontFace(rule)); |
| 163 } else if (rule->isKeyframesRule()) { | 156 } else if (rule->isKeyframesRule()) { |
| 164 addKeyframesRule(toStyleRuleKeyframes(rule)); | 157 // TODO(esprehn): remove this. |
| 165 } else if (rule->isSupportsRule() && toStyleRuleSupports(rule)->conditio
nIsSupported()) { | 158 } else if (rule->isSupportsRule() && toStyleRuleSupports(rule)->conditio
nIsSupported()) { |
| 166 addChildRules(toStyleRuleSupports(rule)->childRules()); | 159 addChildRules(toStyleRuleSupports(rule)->childRules()); |
| 167 } | 160 } |
| 168 } | 161 } |
| 169 } | 162 } |
| 170 | 163 |
| 171 void RuleSet::addRulesFromSheet(StyleSheetContents* sheet) | 164 void RuleSet::addRulesFromSheet(StyleSheetContents* sheet) |
| 172 { | 165 { |
| 173 TRACE_EVENT0("blink", "RuleSet::addRulesFromSheet"); | 166 TRACE_EVENT0("blink", "RuleSet::addRulesFromSheet"); |
| 174 ASSERT(sheet); | 167 ASSERT(sheet); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 201 | 194 |
| 202 void RuleSet::compactRules() | 195 void RuleSet::compactRules() |
| 203 { | 196 { |
| 204 ASSERT(m_pendingRules); | 197 ASSERT(m_pendingRules); |
| 205 OwnPtr<PendingRuleMaps> pendingRules = m_pendingRules.release(); | 198 OwnPtr<PendingRuleMaps> pendingRules = m_pendingRules.release(); |
| 206 compactPendingRules(pendingRules->idRules, m_idRules); | 199 compactPendingRules(pendingRules->idRules, m_idRules); |
| 207 compactPendingRules(pendingRules->classRules, m_classRules); | 200 compactPendingRules(pendingRules->classRules, m_classRules); |
| 208 compactPendingRules(pendingRules->tagRules, m_tagRules); | 201 compactPendingRules(pendingRules->tagRules, m_tagRules); |
| 209 m_universalRules.shrinkToFit(); | 202 m_universalRules.shrinkToFit(); |
| 210 m_fontFaceRules.shrinkToFit(); | 203 m_fontFaceRules.shrinkToFit(); |
| 211 m_keyframesRules.shrinkToFit(); | |
| 212 } | 204 } |
| 213 | 205 |
| 214 #ifndef NDEBUG | 206 #ifndef NDEBUG |
| 215 void RuleSet::show() | 207 void RuleSet::show() |
| 216 { | 208 { |
| 217 for (Vector<RuleData>::const_iterator it = m_allRules.begin(); it != m_allRu
les.end(); ++it) | 209 for (Vector<RuleData>::const_iterator it = m_allRules.begin(); it != m_allRu
les.end(); ++it) |
| 218 it->selector().show(); | 210 it->selector().show(); |
| 219 } | 211 } |
| 220 #endif | 212 #endif |
| 221 | 213 |
| 222 } // namespace blink | 214 } // namespace blink |
| OLD | NEW |