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 29 matching lines...) Expand all Loading... |
40 namespace WebCore { | 40 namespace WebCore { |
41 | 41 |
42 DocumentRuleSets::DocumentRuleSets() | 42 DocumentRuleSets::DocumentRuleSets() |
43 { | 43 { |
44 } | 44 } |
45 | 45 |
46 DocumentRuleSets::~DocumentRuleSets() | 46 DocumentRuleSets::~DocumentRuleSets() |
47 { | 47 { |
48 } | 48 } |
49 | 49 |
50 void DocumentRuleSets::initUserStyle(StyleEngine* styleSheetCollection, const Ve
ctor<RefPtr<StyleRule> >& watchedSelectors, const MediaQueryEvaluator& medium, S
tyleResolver& resolver) | |
51 { | |
52 OwnPtr<RuleSet> tempUserStyle = RuleSet::create(); | |
53 if (CSSStyleSheet* pageUserSheet = styleSheetCollection->pageUserSheet()) | |
54 tempUserStyle->addRulesFromSheet(pageUserSheet->contents(), medium, &res
olver); | |
55 collectRulesFromUserStyleSheets(styleSheetCollection->documentUserStyleSheet
s(), *tempUserStyle, medium, resolver); | |
56 collectRulesFromWatchedSelectors(watchedSelectors, *tempUserStyle); | |
57 if (tempUserStyle->ruleCount() > 0 || tempUserStyle->pageRules().size() > 0) | |
58 m_userStyle = tempUserStyle.release(); | |
59 } | |
60 | |
61 void DocumentRuleSets::collectRulesFromUserStyleSheets(const Vector<RefPtr<CSSSt
yleSheet> >& userSheets, RuleSet& userStyle, const MediaQueryEvaluator& medium,
StyleResolver& resolver) | |
62 { | |
63 for (unsigned i = 0; i < userSheets.size(); ++i) { | |
64 ASSERT(userSheets[i]->contents()->isUserStyleSheet()); | |
65 userStyle.addRulesFromSheet(userSheets[i]->contents(), medium, &resolver
); | |
66 resolver.addFontFaceRules(userStyle.fontFaceRules()); | |
67 } | |
68 } | |
69 | |
70 void DocumentRuleSets::collectRulesFromWatchedSelectors(const Vector<RefPtr<Styl
eRule> >& watchedSelectors, RuleSet& userStyle) | |
71 { | |
72 for (unsigned i = 0; i < watchedSelectors.size(); ++i) | |
73 userStyle.addStyleRule(watchedSelectors[i].get(), RuleHasNoSpecialState)
; | |
74 } | |
75 | |
76 void DocumentRuleSets::resetAuthorStyle() | 50 void DocumentRuleSets::resetAuthorStyle() |
77 { | 51 { |
78 m_treeBoundaryCrossingRules.clear(); | 52 m_treeBoundaryCrossingRules.clear(); |
79 } | 53 } |
80 | 54 |
81 void DocumentRuleSets::collectFeaturesTo(RuleFeatureSet& features, bool isViewSo
urce) | 55 void DocumentRuleSets::collectFeaturesTo(RuleFeatureSet& features, bool isViewSo
urce) |
82 { | 56 { |
83 // Collect all ids and rules using sibling selectors (:first-child and simil
ar) | 57 // Collect all ids and rules using sibling selectors (:first-child and simil
ar) |
84 // in the current set of stylesheets. Style sharing code uses this informati
on to reject | 58 // in the current set of stylesheets. Style sharing code uses this informati
on to reject |
85 // sharing candidates. | 59 // sharing candidates. |
86 if (CSSDefaultStyleSheets::defaultStyle) | 60 if (CSSDefaultStyleSheets::defaultStyle) |
87 features.add(CSSDefaultStyleSheets::defaultStyle->features()); | 61 features.add(CSSDefaultStyleSheets::defaultStyle->features()); |
88 | 62 |
89 if (isViewSource) | 63 if (isViewSource) |
90 features.add(CSSDefaultStyleSheets::viewSourceStyle()->features()); | 64 features.add(CSSDefaultStyleSheets::viewSourceStyle()->features()); |
91 | 65 |
92 if (m_userStyle) | |
93 features.add(m_userStyle->features()); | |
94 | |
95 m_treeBoundaryCrossingRules.collectFeaturesTo(features); | 66 m_treeBoundaryCrossingRules.collectFeaturesTo(features); |
96 } | 67 } |
97 | 68 |
98 } // namespace WebCore | 69 } // namespace WebCore |
OLD | NEW |