Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(922)

Side by Side Diff: Source/core/css/DocumentRuleSets.cpp

Issue 18371008: Add a WebDocument::watchCssSelectors(selectors) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@pinned
Patch Set: Fix most comments; TODO benchmark and use Element::recalcStyle Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 74 }
75 75
76 DocumentRuleSets::DocumentRuleSets() 76 DocumentRuleSets::DocumentRuleSets()
77 { 77 {
78 } 78 }
79 79
80 DocumentRuleSets::~DocumentRuleSets() 80 DocumentRuleSets::~DocumentRuleSets()
81 { 81 {
82 } 82 }
83 83
84 void DocumentRuleSets::initUserStyle(DocumentStyleSheetCollection* styleSheetCol lection, const MediaQueryEvaluator& medium, StyleResolver& resolver) 84 void DocumentRuleSets::initUserStyle(DocumentStyleSheetCollection* styleSheetCol lection, const Vector<RefPtr<StyleRule> >& watchedSelectors, const MediaQueryEva luator& medium, StyleResolver& resolver)
85 { 85 {
86 OwnPtr<RuleSet> tempUserStyle = RuleSet::create(); 86 OwnPtr<RuleSet> tempUserStyle = RuleSet::create();
87 if (CSSStyleSheet* pageUserSheet = styleSheetCollection->pageUserSheet()) 87 if (CSSStyleSheet* pageUserSheet = styleSheetCollection->pageUserSheet())
88 tempUserStyle->addRulesFromSheet(pageUserSheet->contents(), medium, &res olver); 88 tempUserStyle->addRulesFromSheet(pageUserSheet->contents(), medium, &res olver);
89 collectRulesFromUserStyleSheets(styleSheetCollection->injectedUserStyleSheet s(), *tempUserStyle, medium, resolver); 89 collectRulesFromUserStyleSheets(styleSheetCollection->injectedUserStyleSheet s(), *tempUserStyle, medium, resolver);
90 collectRulesFromUserStyleSheets(styleSheetCollection->documentUserStyleSheet s(), *tempUserStyle, medium, resolver); 90 collectRulesFromUserStyleSheets(styleSheetCollection->documentUserStyleSheet s(), *tempUserStyle, medium, resolver);
91 collectRulesFromWatchedSelectors(watchedSelectors, *tempUserStyle);
91 if (tempUserStyle->ruleCount() > 0 || tempUserStyle->pageRules().size() > 0) 92 if (tempUserStyle->ruleCount() > 0 || tempUserStyle->pageRules().size() > 0)
92 m_userStyle = tempUserStyle.release(); 93 m_userStyle = tempUserStyle.release();
93 } 94 }
94 95
95 void DocumentRuleSets::collectRulesFromUserStyleSheets(const Vector<RefPtr<CSSSt yleSheet> >& userSheets, RuleSet& userStyle, const MediaQueryEvaluator& medium, StyleResolver& resolver) 96 void DocumentRuleSets::collectRulesFromUserStyleSheets(const Vector<RefPtr<CSSSt yleSheet> >& userSheets, RuleSet& userStyle, const MediaQueryEvaluator& medium, StyleResolver& resolver)
96 { 97 {
97 for (unsigned i = 0; i < userSheets.size(); ++i) { 98 for (unsigned i = 0; i < userSheets.size(); ++i) {
98 ASSERT(userSheets[i]->contents()->isUserStyleSheet()); 99 ASSERT(userSheets[i]->contents()->isUserStyleSheet());
99 userStyle.addRulesFromSheet(userSheets[i]->contents(), medium, &resolver ); 100 userStyle.addRulesFromSheet(userSheets[i]->contents(), medium, &resolver );
100 } 101 }
101 } 102 }
102 103
104 void DocumentRuleSets::collectRulesFromWatchedSelectors(const Vector<RefPtr<Styl eRule> >& watchedSelectors, RuleSet& userStyle)
105 {
106 for (unsigned i = 0; i < watchedSelectors.size(); ++i) {
107 userStyle.addStyleRule(watchedSelectors[i].get(), RuleHasNoSpecialState) ;
108 }
esprehn 2013/07/17 07:14:32 leave off braces
Jeffrey Yasskin 2013/08/02 01:34:07 Done.
109 }
110
103 void DocumentRuleSets::resetAuthorStyle() 111 void DocumentRuleSets::resetAuthorStyle()
104 { 112 {
105 m_shadowDistributedRules.clear(); 113 m_shadowDistributedRules.clear();
106 } 114 }
107 115
108 void DocumentRuleSets::collectFeaturesTo(RuleFeatureSet& features, bool isViewSo urce) 116 void DocumentRuleSets::collectFeaturesTo(RuleFeatureSet& features, bool isViewSo urce)
109 { 117 {
110 // Collect all ids and rules using sibling selectors (:first-child and simil ar) 118 // Collect all ids and rules using sibling selectors (:first-child and simil ar)
111 // in the current set of stylesheets. Style sharing code uses this informati on to reject 119 // in the current set of stylesheets. Style sharing code uses this informati on to reject
112 // sharing candidates. 120 // sharing candidates.
(...skipping 10 matching lines...) Expand all
123 } 131 }
124 132
125 void DocumentRuleSets::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) con st 133 void DocumentRuleSets::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) con st
126 { 134 {
127 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS); 135 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
128 info.addMember(m_userStyle, "userStyle"); 136 info.addMember(m_userStyle, "userStyle");
129 info.addMember(m_shadowDistributedRules, "shadowDistributedRules"); 137 info.addMember(m_shadowDistributedRules, "shadowDistributedRules");
130 } 138 }
131 139
132 } // namespace WebCore 140 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698