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

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

Issue 148703004: Have TreeScopeStyleSheetCollection::document() return a reference. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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
« no previous file with comments | « Source/core/dom/TreeScopeStyleSheetCollection.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 void TreeScopeStyleSheetCollection::addStyleSheetCandidateNode(Node* node, bool createdByParser) 48 void TreeScopeStyleSheetCollection::addStyleSheetCandidateNode(Node* node, bool createdByParser)
49 { 49 {
50 if (!node->inDocument()) 50 if (!node->inDocument())
51 return; 51 return;
52 52
53 // Until the <body> exists, we have no choice but to compare document positi ons, 53 // Until the <body> exists, we have no choice but to compare document positi ons,
54 // since styles outside of the body and head continue to be shunted into the head 54 // since styles outside of the body and head continue to be shunted into the head
55 // (and thus can shift to end up before dynamically added DOM content that i s also 55 // (and thus can shift to end up before dynamically added DOM content that i s also
56 // outside the body). 56 // outside the body).
57 if (createdByParser && document()->body()) 57 if (createdByParser && document().body())
58 m_styleSheetCandidateNodes.parserAdd(node); 58 m_styleSheetCandidateNodes.parserAdd(node);
59 else 59 else
60 m_styleSheetCandidateNodes.add(node); 60 m_styleSheetCandidateNodes.add(node);
61 61
62 if (!node->hasTagName(HTMLNames::styleTag)) 62 if (!node->hasTagName(HTMLNames::styleTag))
63 return; 63 return;
64 64
65 ContainerNode* scopingNode = toHTMLStyleElement(node)->scopingNode(); 65 ContainerNode* scopingNode = toHTMLStyleElement(node)->scopingNode();
66 if (!isTreeScopeRoot(scopingNode)) 66 if (!isTreeScopeRoot(scopingNode))
67 m_scopingNodesForStyleScoped.add(scopingNode); 67 m_scopingNodesForStyleScoped.add(scopingNode);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 173 }
174 } 174 }
175 175
176 // FIXME: If styleResolverUpdateType is Reconstruct, we should return early here since 176 // FIXME: If styleResolverUpdateType is Reconstruct, we should return early here since
177 // we need to recalc the whole document. It's wrong to use StyleInvalidation Analysis since 177 // we need to recalc the whole document. It's wrong to use StyleInvalidation Analysis since
178 // it only looks at the addedSheets. 178 // it only looks at the addedSheets.
179 179
180 // No point in doing the analysis work if we're just going to recalc the who le document anyways. 180 // No point in doing the analysis work if we're just going to recalc the who le document anyways.
181 // This needs to be done after the compareStyleSheets calls above to ensure we don't throw away 181 // This needs to be done after the compareStyleSheets calls above to ensure we don't throw away
182 // the StyleResolver if we don't need to. 182 // the StyleResolver if we don't need to.
183 if (document()->hasPendingForcedStyleRecalc()) 183 if (document().hasPendingForcedStyleRecalc())
184 return; 184 return;
185 185
186 // If we are already parsing the body and so may have significant amount of elements, put some effort into trying to avoid style recalcs. 186 // If we are already parsing the body and so may have significant amount of elements, put some effort into trying to avoid style recalcs.
187 if (!document()->body() || document()->hasNodesWithPlaceholderStyle()) 187 if (!document().body() || document().hasNodesWithPlaceholderStyle())
188 return; 188 return;
189 StyleInvalidationAnalysis invalidationAnalysis(addedSheets); 189 StyleInvalidationAnalysis invalidationAnalysis(addedSheets);
190 if (invalidationAnalysis.dirtiesAllStyle()) 190 if (invalidationAnalysis.dirtiesAllStyle())
191 return; 191 return;
192 invalidationAnalysis.invalidateStyle(*document()); 192 invalidationAnalysis.invalidateStyle(document());
193 change.requiresFullStyleRecalc = false; 193 change.requiresFullStyleRecalc = false;
194 return; 194 return;
195 } 195 }
196 196
197 void TreeScopeStyleSheetCollection::clearMediaQueryRuleSetStyleSheets() 197 void TreeScopeStyleSheetCollection::clearMediaQueryRuleSetStyleSheets()
198 { 198 {
199 for (size_t i = 0; i < m_activeAuthorStyleSheets.size(); ++i) { 199 for (size_t i = 0; i < m_activeAuthorStyleSheets.size(); ++i) {
200 StyleSheetContents* contents = m_activeAuthorStyleSheets[i]->contents(); 200 StyleSheetContents* contents = m_activeAuthorStyleSheets[i]->contents();
201 if (contents->hasMediaQueries()) 201 if (contents->hasMediaQueries())
202 contents->clearRuleSet(); 202 contents->clearRuleSet();
(...skipping 22 matching lines...) Expand all
225 } 225 }
226 return false; 226 return false;
227 } 227 }
228 228
229 void TreeScopeStyleSheetCollection::updateUsesRemUnits() 229 void TreeScopeStyleSheetCollection::updateUsesRemUnits()
230 { 230 {
231 m_usesRemUnits = styleSheetsUseRemUnits(m_activeAuthorStyleSheets); 231 m_usesRemUnits = styleSheetsUseRemUnits(m_activeAuthorStyleSheets);
232 } 232 }
233 233
234 } 234 }
OLDNEW
« no previous file with comments | « Source/core/dom/TreeScopeStyleSheetCollection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698