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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 } | 67 } |
68 | 68 |
69 DocumentRuleSets::DocumentRuleSets() | 69 DocumentRuleSets::DocumentRuleSets() |
70 { | 70 { |
71 } | 71 } |
72 | 72 |
73 DocumentRuleSets::~DocumentRuleSets() | 73 DocumentRuleSets::~DocumentRuleSets() |
74 { | 74 { |
75 } | 75 } |
76 | 76 |
77 void DocumentRuleSets::initUserStyle(StyleEngine* styleSheetCollection, const Me
diaQueryEvaluator& medium, StyleResolver& resolver) | 77 void DocumentRuleSets::initUserStyle(StyleEngine* styleSheetCollection, const Ve
ctor<RefPtr<StyleRule> >& watchedSelectors, const MediaQueryEvaluator& medium, S
tyleResolver& resolver) |
78 { | 78 { |
79 OwnPtr<RuleSet> tempUserStyle = RuleSet::create(); | 79 OwnPtr<RuleSet> tempUserStyle = RuleSet::create(); |
80 if (CSSStyleSheet* pageUserSheet = styleSheetCollection->pageUserSheet()) | 80 if (CSSStyleSheet* pageUserSheet = styleSheetCollection->pageUserSheet()) |
81 tempUserStyle->addRulesFromSheet(pageUserSheet->contents(), medium, &res
olver); | 81 tempUserStyle->addRulesFromSheet(pageUserSheet->contents(), medium, &res
olver); |
82 collectRulesFromUserStyleSheets(styleSheetCollection->injectedUserStyleSheet
s(), *tempUserStyle, medium, resolver); | 82 collectRulesFromUserStyleSheets(styleSheetCollection->injectedUserStyleSheet
s(), *tempUserStyle, medium, resolver); |
83 collectRulesFromUserStyleSheets(styleSheetCollection->documentUserStyleSheet
s(), *tempUserStyle, medium, resolver); | 83 collectRulesFromUserStyleSheets(styleSheetCollection->documentUserStyleSheet
s(), *tempUserStyle, medium, resolver); |
| 84 collectRulesFromWatchedSelectors(watchedSelectors, *tempUserStyle); |
84 if (tempUserStyle->ruleCount() > 0 || tempUserStyle->pageRules().size() > 0) | 85 if (tempUserStyle->ruleCount() > 0 || tempUserStyle->pageRules().size() > 0) |
85 m_userStyle = tempUserStyle.release(); | 86 m_userStyle = tempUserStyle.release(); |
86 } | 87 } |
87 | 88 |
88 void DocumentRuleSets::collectRulesFromUserStyleSheets(const Vector<RefPtr<CSSSt
yleSheet> >& userSheets, RuleSet& userStyle, const MediaQueryEvaluator& medium,
StyleResolver& resolver) | 89 void DocumentRuleSets::collectRulesFromUserStyleSheets(const Vector<RefPtr<CSSSt
yleSheet> >& userSheets, RuleSet& userStyle, const MediaQueryEvaluator& medium,
StyleResolver& resolver) |
89 { | 90 { |
90 for (unsigned i = 0; i < userSheets.size(); ++i) { | 91 for (unsigned i = 0; i < userSheets.size(); ++i) { |
91 ASSERT(userSheets[i]->contents()->isUserStyleSheet()); | 92 ASSERT(userSheets[i]->contents()->isUserStyleSheet()); |
92 userStyle.addRulesFromSheet(userSheets[i]->contents(), medium, &resolver
); | 93 userStyle.addRulesFromSheet(userSheets[i]->contents(), medium, &resolver
); |
93 } | 94 } |
94 } | 95 } |
95 | 96 |
| 97 void DocumentRuleSets::collectRulesFromWatchedSelectors(const Vector<RefPtr<Styl
eRule> >& watchedSelectors, RuleSet& userStyle) |
| 98 { |
| 99 for (unsigned i = 0; i < watchedSelectors.size(); ++i) |
| 100 userStyle.addStyleRule(watchedSelectors[i].get(), RuleHasNoSpecialState)
; |
| 101 } |
| 102 |
96 void DocumentRuleSets::resetAuthorStyle() | 103 void DocumentRuleSets::resetAuthorStyle() |
97 { | 104 { |
98 m_shadowDistributedRules.clear(); | 105 m_shadowDistributedRules.clear(); |
99 } | 106 } |
100 | 107 |
101 void DocumentRuleSets::collectFeaturesTo(RuleFeatureSet& features, bool isViewSo
urce) | 108 void DocumentRuleSets::collectFeaturesTo(RuleFeatureSet& features, bool isViewSo
urce) |
102 { | 109 { |
103 // Collect all ids and rules using sibling selectors (:first-child and simil
ar) | 110 // Collect all ids and rules using sibling selectors (:first-child and simil
ar) |
104 // in the current set of stylesheets. Style sharing code uses this informati
on to reject | 111 // in the current set of stylesheets. Style sharing code uses this informati
on to reject |
105 // sharing candidates. | 112 // sharing candidates. |
106 if (CSSDefaultStyleSheets::defaultStyle) | 113 if (CSSDefaultStyleSheets::defaultStyle) |
107 features.add(CSSDefaultStyleSheets::defaultStyle->features()); | 114 features.add(CSSDefaultStyleSheets::defaultStyle->features()); |
108 | 115 |
109 if (isViewSource) | 116 if (isViewSource) |
110 features.add(CSSDefaultStyleSheets::viewSourceStyle()->features()); | 117 features.add(CSSDefaultStyleSheets::viewSourceStyle()->features()); |
111 | 118 |
112 if (m_userStyle) | 119 if (m_userStyle) |
113 features.add(m_userStyle->features()); | 120 features.add(m_userStyle->features()); |
114 | 121 |
115 m_shadowDistributedRules.collectFeaturesTo(features); | 122 m_shadowDistributedRules.collectFeaturesTo(features); |
116 } | 123 } |
117 | 124 |
118 } // namespace WebCore | 125 } // namespace WebCore |
OLD | NEW |