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 "config.h" | 29 #include "config.h" |
30 #include "core/css/TreeBoundaryCrossingRules.h" | 30 #include "core/css/TreeBoundaryCrossingRules.h" |
31 | 31 |
32 #include "core/css/RuleFeature.h" | 32 #include "core/css/RuleFeature.h" |
33 #include "core/dom/StyleEngine.h" | 33 #include "core/dom/StyleEngine.h" |
34 | 34 |
35 namespace WebCore { | 35 namespace WebCore { |
36 | 36 |
37 void TreeBoundaryCrossingRules::addRule(StyleRule* rule, size_t selectorIndex, C
ontainerNode* scopingNode, AddRuleFlags addRuleFlags) | 37 void TreeBoundaryCrossingRules::addRule(StyleRule* rule, size_t selectorIndex, C
ontainerNode* scopingNode, CSSStyleSheet* parentStyleSheet, AddRuleFlags addRule
Flags) |
38 { | 38 { |
39 if (m_treeBoundaryCrossingRuleSetMap.contains(scopingNode)) { | 39 if (!m_treeBoundaryCrossingRuleSetMap.contains(scopingNode)) { |
40 m_treeBoundaryCrossingRuleSetMap.get(scopingNode)->addRule(rule, selecto
rIndex, addRuleFlags); | 40 OwnPtrWillBeRawPtr<CSSStyleSheetRuleSubSet> styleSheetRuleSubSetForScope
= adoptPtr(new CSSStyleSheetRuleSubSet()); |
| 41 m_treeBoundaryCrossingRuleSetMap.add(scopingNode, styleSheetRuleSubSetFo
rScope.release()); |
| 42 m_scopingNodes.add(scopingNode); |
| 43 } |
| 44 CSSStyleSheetRuleSubSet* ruleSubSet = m_treeBoundaryCrossingRuleSetMap.get(s
copingNode); |
| 45 |
| 46 if (ruleSubSet->contains(parentStyleSheet)) { |
| 47 ruleSubSet->get(parentStyleSheet)->addRule(rule, selectorIndex, addRuleF
lags); |
41 } else { | 48 } else { |
42 OwnPtrWillBeRawPtr<RuleSet> ruleSetForScope = RuleSet::create(); | 49 OwnPtrWillBeRawPtr<RuleSet> ruleSetForScope = RuleSet::create(); |
43 ruleSetForScope->addRule(rule, selectorIndex, addRuleFlags); | 50 ruleSetForScope->addRule(rule, selectorIndex, addRuleFlags); |
44 m_treeBoundaryCrossingRuleSetMap.add(scopingNode, ruleSetForScope.releas
e()); | 51 ruleSubSet->add(parentStyleSheet, ruleSetForScope.release()); |
45 m_scopingNodes.add(scopingNode); | |
46 } | 52 } |
47 } | 53 } |
48 | 54 |
49 void TreeBoundaryCrossingRules::reset(const ContainerNode* scopingNode) | 55 void TreeBoundaryCrossingRules::reset(const ContainerNode* scopingNode) |
50 { | 56 { |
51 m_treeBoundaryCrossingRuleSetMap.remove(scopingNode); | 57 m_treeBoundaryCrossingRuleSetMap.remove(scopingNode); |
52 m_scopingNodes.remove(scopingNode); | 58 m_scopingNodes.remove(scopingNode); |
53 } | 59 } |
54 | 60 |
| 61 static void collectFeaturesFromStyleSheetSubSet(TreeBoundaryCrossingRules::CSSSt
yleSheetRuleSubSet* styleSheetSubSet, RuleFeatureSet& features) |
| 62 { |
| 63 for (TreeBoundaryCrossingRules::CSSStyleSheetRuleSubSet::iterator::Values it
= styleSheetSubSet->values().begin(); it != styleSheetSubSet->values().end(); +
+it) { |
| 64 RuleSet* ruleSet = it->get(); |
| 65 features.add(ruleSet->features()); |
| 66 } |
| 67 } |
| 68 |
55 void TreeBoundaryCrossingRules::collectFeaturesTo(RuleFeatureSet& features) | 69 void TreeBoundaryCrossingRules::collectFeaturesTo(RuleFeatureSet& features) |
56 { | 70 { |
57 for (TreeBoundaryCrossingRuleSetMap::iterator::Values it = m_treeBoundaryCro
ssingRuleSetMap.values().begin(); it != m_treeBoundaryCrossingRuleSetMap.values(
).end(); ++it) { | 71 for (TreeBoundaryCrossingRuleSetMap::iterator::Values it = m_treeBoundaryCro
ssingRuleSetMap.values().begin(); it != m_treeBoundaryCrossingRuleSetMap.values(
).end(); ++it) { |
58 RuleSet* ruleSet = it->get(); | 72 CSSStyleSheetRuleSubSet* styleSheetSubSet = it->get(); |
59 features.add(ruleSet->features()); | 73 collectFeaturesFromStyleSheetSubSet(styleSheetSubSet, features); |
60 } | 74 } |
61 } | 75 } |
62 | 76 |
63 } // namespace WebCore | 77 } // namespace WebCore |
OLD | NEW |