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

Side by Side Diff: Source/core/dom/TreeScopeStyleSheetCollection.cpp

Issue 180003002: Consistently use on-heap collections for StyleRuleBase descendants. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: addressed reviewers comments Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 8 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
9 * Copyright (C) 2013 Google Inc. All rights reserved. 9 * Copyright (C) 2013 Google Inc. All rights reserved.
10 * 10 *
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 } 68 }
69 69
70 void TreeScopeStyleSheetCollection::removeStyleSheetCandidateNode(Node* node, Co ntainerNode* scopingNode) 70 void TreeScopeStyleSheetCollection::removeStyleSheetCandidateNode(Node* node, Co ntainerNode* scopingNode)
71 { 71 {
72 m_styleSheetCandidateNodes.remove(node); 72 m_styleSheetCandidateNodes.remove(node);
73 73
74 if (!isTreeScopeRoot(scopingNode)) 74 if (!isTreeScopeRoot(scopingNode))
75 m_scopingNodesForStyleScoped.remove(scopingNode); 75 m_scopingNodesForStyleScoped.remove(scopingNode);
76 } 76 }
77 77
78 TreeScopeStyleSheetCollection::StyleResolverUpdateType TreeScopeStyleSheetCollec tion::compareStyleSheets(const Vector<RefPtr<CSSStyleSheet> >& oldStyleSheets, c onst Vector<RefPtr<CSSStyleSheet> >& newStylesheets, Vector<StyleSheetContents*> & addedSheets) 78 TreeScopeStyleSheetCollection::StyleResolverUpdateType TreeScopeStyleSheetCollec tion::compareStyleSheets(const Vector<RefPtr<CSSStyleSheet> >& oldStyleSheets, c onst Vector<RefPtr<CSSStyleSheet> >& newStylesheets, WillBeHeapVector<RawPtrWill BeMember<StyleSheetContents> >& addedSheets)
79 { 79 {
80 unsigned newStyleSheetCount = newStylesheets.size(); 80 unsigned newStyleSheetCount = newStylesheets.size();
81 unsigned oldStyleSheetCount = oldStyleSheets.size(); 81 unsigned oldStyleSheetCount = oldStyleSheets.size();
82 ASSERT(newStyleSheetCount >= oldStyleSheetCount); 82 ASSERT(newStyleSheetCount >= oldStyleSheetCount);
83 83
84 if (!newStyleSheetCount) 84 if (!newStyleSheetCount)
85 return Reconstruct; 85 return Reconstruct;
86 86
87 unsigned newIndex = 0; 87 unsigned newIndex = 0;
88 for (unsigned oldIndex = 0; oldIndex < oldStyleSheetCount; ++oldIndex) { 88 for (unsigned oldIndex = 0; oldIndex < oldStyleSheetCount; ++oldIndex) {
(...skipping 25 matching lines...) Expand all
114 hasActiveLoadingStylesheet = true; 114 hasActiveLoadingStylesheet = true;
115 } 115 }
116 if (m_hadActiveLoadingStylesheet && !hasActiveLoadingStylesheet) { 116 if (m_hadActiveLoadingStylesheet && !hasActiveLoadingStylesheet) {
117 m_hadActiveLoadingStylesheet = false; 117 m_hadActiveLoadingStylesheet = false;
118 return true; 118 return true;
119 } 119 }
120 m_hadActiveLoadingStylesheet = hasActiveLoadingStylesheet; 120 m_hadActiveLoadingStylesheet = hasActiveLoadingStylesheet;
121 return false; 121 return false;
122 } 122 }
123 123
124 static bool findFontFaceRulesFromStyleSheetContents(Vector<StyleSheetContents*> sheets, Vector<const StyleRuleFontFace*>& fontFaceRules) 124 static bool findFontFaceRulesFromStyleSheetContents(const WillBeHeapVector<RawPt rWillBeMember<StyleSheetContents> >& sheets, WillBeHeapVector<RawPtrWillBeMember <const StyleRuleFontFace> >& fontFaceRules)
125 { 125 {
126 bool hasFontFaceRule = false; 126 bool hasFontFaceRule = false;
127 127
128 for (unsigned i = 0; i < sheets.size(); ++i) { 128 for (unsigned i = 0; i < sheets.size(); ++i) {
129 ASSERT(sheets[i]); 129 ASSERT(sheets[i]);
130 if (sheets[i]->hasFontFaceRule()) { 130 if (sheets[i]->hasFontFaceRule()) {
131 // FIXME: We don't need this for styles in shadow tree. 131 // FIXME: We don't need this for styles in shadow tree.
132 sheets[i]->findFontFaceRules(fontFaceRules); 132 sheets[i]->findFontFaceRules(fontFaceRules);
133 hasFontFaceRule = true; 133 hasFontFaceRule = true;
134 } 134 }
135 } 135 }
136 return hasFontFaceRule; 136 return hasFontFaceRule;
137 } 137 }
138 138
139 void TreeScopeStyleSheetCollection::analyzeStyleSheetChange(StyleResolverUpdateM ode updateMode, const StyleSheetCollection& newCollection, StyleSheetChange& cha nge) 139 void TreeScopeStyleSheetCollection::analyzeStyleSheetChange(StyleResolverUpdateM ode updateMode, const StyleSheetCollection& newCollection, StyleSheetChange& cha nge)
140 { 140 {
141 if (activeLoadingStyleSheetLoaded(newCollection.activeAuthorStyleSheets())) 141 if (activeLoadingStyleSheetLoaded(newCollection.activeAuthorStyleSheets()))
142 return; 142 return;
143 143
144 if (updateMode != AnalyzedStyleUpdate) 144 if (updateMode != AnalyzedStyleUpdate)
145 return; 145 return;
146 146
147 // Find out which stylesheets are new. 147 // Find out which stylesheets are new.
148 Vector<StyleSheetContents*> addedSheets; 148 WillBeHeapVector<RawPtrWillBeMember<StyleSheetContents> > addedSheets;
149 if (m_activeAuthorStyleSheets.size() <= newCollection.activeAuthorStyleSheet s().size()) { 149 if (m_activeAuthorStyleSheets.size() <= newCollection.activeAuthorStyleSheet s().size()) {
150 change.styleResolverUpdateType = compareStyleSheets(m_activeAuthorStyleS heets, newCollection.activeAuthorStyleSheets(), addedSheets); 150 change.styleResolverUpdateType = compareStyleSheets(m_activeAuthorStyleS heets, newCollection.activeAuthorStyleSheets(), addedSheets);
151 } else { 151 } else {
152 StyleResolverUpdateType updateType = compareStyleSheets(newCollection.ac tiveAuthorStyleSheets(), m_activeAuthorStyleSheets, addedSheets); 152 StyleResolverUpdateType updateType = compareStyleSheets(newCollection.ac tiveAuthorStyleSheets(), m_activeAuthorStyleSheets, addedSheets);
153 if (updateType != Additive) { 153 if (updateType != Additive) {
154 change.styleResolverUpdateType = updateType; 154 change.styleResolverUpdateType = updateType;
155 } else { 155 } else {
156 change.styleResolverUpdateType = Reset; 156 change.styleResolverUpdateType = Reset;
157 // If @font-face is removed, needs full style recalc. 157 // If @font-face is removed, needs full style recalc.
158 if (findFontFaceRulesFromStyleSheetContents(addedSheets, change.font FaceRulesToRemove)) 158 if (findFontFaceRulesFromStyleSheetContents(addedSheets, change.font FaceRulesToRemove))
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 } 212 }
213 return false; 213 return false;
214 } 214 }
215 215
216 void TreeScopeStyleSheetCollection::updateUsesRemUnits() 216 void TreeScopeStyleSheetCollection::updateUsesRemUnits()
217 { 217 {
218 m_usesRemUnits = styleSheetsUseRemUnits(m_activeAuthorStyleSheets); 218 m_usesRemUnits = styleSheetsUseRemUnits(m_activeAuthorStyleSheets);
219 } 219 }
220 220
221 } 221 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698