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

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

Issue 1006723003: Fix template angle bracket syntax in dom (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 9 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') | Source/core/dom/WeakNodeMap.cpp » ('j') | 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // Until the <body> exists, we have no choice but to compare document positi ons, 54 // Until the <body> exists, we have no choice but to compare document positi ons,
55 // since styles outside of the body and head continue to be shunted into the head 55 // since styles outside of the body and head continue to be shunted into the head
56 // (and thus can shift to end up before dynamically added DOM content that i s also 56 // (and thus can shift to end up before dynamically added DOM content that i s also
57 // outside the body). 57 // outside the body).
58 if (createdByParser && document().body() && !node->nextSibling()) 58 if (createdByParser && document().body() && !node->nextSibling())
59 m_styleSheetCandidateNodes.parserAdd(node); 59 m_styleSheetCandidateNodes.parserAdd(node);
60 else 60 else
61 m_styleSheetCandidateNodes.add(node); 61 m_styleSheetCandidateNodes.add(node);
62 } 62 }
63 63
64 TreeScopeStyleSheetCollection::StyleResolverUpdateType TreeScopeStyleSheetCollec tion::compareStyleSheets(const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet > >& oldStyleSheets, const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> >& newStylesheets, WillBeHeapVector<RawPtrWillBeMember<StyleSheetContents> >& adde dSheets) 64 TreeScopeStyleSheetCollection::StyleResolverUpdateType TreeScopeStyleSheetCollec tion::compareStyleSheets(const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet >>& oldStyleSheets, const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet>>& n ewStylesheets, WillBeHeapVector<RawPtrWillBeMember<StyleSheetContents>>& addedSh eets)
65 { 65 {
66 unsigned newStyleSheetCount = newStylesheets.size(); 66 unsigned newStyleSheetCount = newStylesheets.size();
67 unsigned oldStyleSheetCount = oldStyleSheets.size(); 67 unsigned oldStyleSheetCount = oldStyleSheets.size();
68 ASSERT(newStyleSheetCount >= oldStyleSheetCount); 68 ASSERT(newStyleSheetCount >= oldStyleSheetCount);
69 69
70 if (!newStyleSheetCount) 70 if (!newStyleSheetCount)
71 return Reconstruct; 71 return Reconstruct;
72 72
73 unsigned newIndex = 0; 73 unsigned newIndex = 0;
74 for (unsigned oldIndex = 0; oldIndex < oldStyleSheetCount; ++oldIndex) { 74 for (unsigned oldIndex = 0; oldIndex < oldStyleSheetCount; ++oldIndex) {
75 while (oldStyleSheets[oldIndex] != newStylesheets[newIndex]) { 75 while (oldStyleSheets[oldIndex] != newStylesheets[newIndex]) {
76 addedSheets.append(newStylesheets[newIndex]->contents()); 76 addedSheets.append(newStylesheets[newIndex]->contents());
77 if (++newIndex == newStyleSheetCount) 77 if (++newIndex == newStyleSheetCount)
78 return Reconstruct; 78 return Reconstruct;
79 } 79 }
80 if (++newIndex == newStyleSheetCount) 80 if (++newIndex == newStyleSheetCount)
81 return Reconstruct; 81 return Reconstruct;
82 } 82 }
83 bool hasInsertions = !addedSheets.isEmpty(); 83 bool hasInsertions = !addedSheets.isEmpty();
84 while (newIndex < newStyleSheetCount) { 84 while (newIndex < newStyleSheetCount) {
85 addedSheets.append(newStylesheets[newIndex]->contents()); 85 addedSheets.append(newStylesheets[newIndex]->contents());
86 ++newIndex; 86 ++newIndex;
87 } 87 }
88 // If all new sheets were added at the end of the list we can just add them to existing StyleResolver. 88 // If all new sheets were added at the end of the list we can just add them to existing StyleResolver.
89 // If there were insertions we need to re-add all the stylesheets so rules a re ordered correctly. 89 // If there were insertions we need to re-add all the stylesheets so rules a re ordered correctly.
90 return hasInsertions ? Reset : Additive; 90 return hasInsertions ? Reset : Additive;
91 } 91 }
92 92
93 bool TreeScopeStyleSheetCollection::activeLoadingStyleSheetLoaded(const WillBeHe apVector<RefPtrWillBeMember<CSSStyleSheet> >& newStyleSheets) 93 bool TreeScopeStyleSheetCollection::activeLoadingStyleSheetLoaded(const WillBeHe apVector<RefPtrWillBeMember<CSSStyleSheet>>& newStyleSheets)
94 { 94 {
95 // StyleSheets of <style> elements that @import stylesheets are active but l oading. We need to trigger a full recalc when such loads are done. 95 // StyleSheets of <style> elements that @import stylesheets are active but l oading. We need to trigger a full recalc when such loads are done.
96 bool hasActiveLoadingStylesheet = false; 96 bool hasActiveLoadingStylesheet = false;
97 unsigned newStylesheetCount = newStyleSheets.size(); 97 unsigned newStylesheetCount = newStyleSheets.size();
98 for (unsigned i = 0; i < newStylesheetCount; ++i) { 98 for (unsigned i = 0; i < newStylesheetCount; ++i) {
99 if (newStyleSheets[i]->isLoading()) 99 if (newStyleSheets[i]->isLoading())
100 hasActiveLoadingStylesheet = true; 100 hasActiveLoadingStylesheet = true;
101 } 101 }
102 if (m_hadActiveLoadingStylesheet && !hasActiveLoadingStylesheet) { 102 if (m_hadActiveLoadingStylesheet && !hasActiveLoadingStylesheet) {
103 m_hadActiveLoadingStylesheet = false; 103 m_hadActiveLoadingStylesheet = false;
104 return true; 104 return true;
105 } 105 }
106 m_hadActiveLoadingStylesheet = hasActiveLoadingStylesheet; 106 m_hadActiveLoadingStylesheet = hasActiveLoadingStylesheet;
107 return false; 107 return false;
108 } 108 }
109 109
110 static bool findFontFaceRulesFromStyleSheetContents(const WillBeHeapVector<RawPt rWillBeMember<StyleSheetContents> >& sheets, WillBeHeapVector<RawPtrWillBeMember <const StyleRuleFontFace> >& fontFaceRules) 110 static bool findFontFaceRulesFromStyleSheetContents(const WillBeHeapVector<RawPt rWillBeMember<StyleSheetContents>>& sheets, WillBeHeapVector<RawPtrWillBeMember< const StyleRuleFontFace>>& fontFaceRules)
111 { 111 {
112 bool hasFontFaceRule = false; 112 bool hasFontFaceRule = false;
113 113
114 for (unsigned i = 0; i < sheets.size(); ++i) { 114 for (unsigned i = 0; i < sheets.size(); ++i) {
115 ASSERT(sheets[i]); 115 ASSERT(sheets[i]);
116 if (sheets[i]->hasFontFaceRule()) { 116 if (sheets[i]->hasFontFaceRule()) {
117 // FIXME: We don't need this for styles in shadow tree. 117 // FIXME: We don't need this for styles in shadow tree.
118 sheets[i]->findFontFaceRules(fontFaceRules); 118 sheets[i]->findFontFaceRules(fontFaceRules);
119 hasFontFaceRule = true; 119 hasFontFaceRule = true;
120 } 120 }
121 } 121 }
122 return hasFontFaceRule; 122 return hasFontFaceRule;
123 } 123 }
124 124
125 void TreeScopeStyleSheetCollection::analyzeStyleSheetChange(StyleResolverUpdateM ode updateMode, const StyleSheetCollection& newCollection, StyleSheetChange& cha nge) 125 void TreeScopeStyleSheetCollection::analyzeStyleSheetChange(StyleResolverUpdateM ode updateMode, const StyleSheetCollection& newCollection, StyleSheetChange& cha nge)
126 { 126 {
127 if (activeLoadingStyleSheetLoaded(newCollection.activeAuthorStyleSheets())) 127 if (activeLoadingStyleSheetLoaded(newCollection.activeAuthorStyleSheets()))
128 return; 128 return;
129 129
130 if (updateMode != AnalyzedStyleUpdate) 130 if (updateMode != AnalyzedStyleUpdate)
131 return; 131 return;
132 132
133 // Find out which stylesheets are new. 133 // Find out which stylesheets are new.
134 WillBeHeapVector<RawPtrWillBeMember<StyleSheetContents> > addedSheets; 134 WillBeHeapVector<RawPtrWillBeMember<StyleSheetContents>> addedSheets;
135 if (m_activeAuthorStyleSheets.size() <= newCollection.activeAuthorStyleSheet s().size()) { 135 if (m_activeAuthorStyleSheets.size() <= newCollection.activeAuthorStyleSheet s().size()) {
136 change.styleResolverUpdateType = compareStyleSheets(m_activeAuthorStyleS heets, newCollection.activeAuthorStyleSheets(), addedSheets); 136 change.styleResolverUpdateType = compareStyleSheets(m_activeAuthorStyleS heets, newCollection.activeAuthorStyleSheets(), addedSheets);
137 } else { 137 } else {
138 StyleResolverUpdateType updateType = compareStyleSheets(newCollection.ac tiveAuthorStyleSheets(), m_activeAuthorStyleSheets, addedSheets); 138 StyleResolverUpdateType updateType = compareStyleSheets(newCollection.ac tiveAuthorStyleSheets(), m_activeAuthorStyleSheets, addedSheets);
139 if (updateType != Additive) { 139 if (updateType != Additive) {
140 change.styleResolverUpdateType = updateType; 140 change.styleResolverUpdateType = updateType;
141 } else { 141 } else {
142 change.styleResolverUpdateType = Reset; 142 change.styleResolverUpdateType = Reset;
143 // If @font-face is removed, needs full style recalc. 143 // If @font-face is removed, needs full style recalc.
144 if (findFontFaceRulesFromStyleSheetContents(addedSheets, change.font FaceRulesToRemove)) 144 if (findFontFaceRulesFromStyleSheetContents(addedSheets, change.font FaceRulesToRemove))
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 { 180 {
181 DocumentOrderedList::iterator begin = m_styleSheetCandidateNodes.begin(); 181 DocumentOrderedList::iterator begin = m_styleSheetCandidateNodes.begin();
182 DocumentOrderedList::iterator end = m_styleSheetCandidateNodes.end(); 182 DocumentOrderedList::iterator end = m_styleSheetCandidateNodes.end();
183 for (DocumentOrderedList::iterator it = begin; it != end; ++it) { 183 for (DocumentOrderedList::iterator it = begin; it != end; ++it) {
184 Node* node = *it; 184 Node* node = *it;
185 if (isHTMLLinkElement(*node)) 185 if (isHTMLLinkElement(*node))
186 toHTMLLinkElement(node)->setEnabledIfExitTransitionStyle(enabled); 186 toHTMLLinkElement(node)->setEnabledIfExitTransitionStyle(enabled);
187 } 187 }
188 } 188 }
189 189
190 static bool styleSheetsUseRemUnits(const WillBeHeapVector<RefPtrWillBeMember<CSS StyleSheet> >& sheets) 190 static bool styleSheetsUseRemUnits(const WillBeHeapVector<RefPtrWillBeMember<CSS StyleSheet>>& sheets)
191 { 191 {
192 for (unsigned i = 0; i < sheets.size(); ++i) { 192 for (unsigned i = 0; i < sheets.size(); ++i) {
193 if (sheets[i]->contents()->usesRemUnits()) 193 if (sheets[i]->contents()->usesRemUnits())
194 return true; 194 return true;
195 } 195 }
196 return false; 196 return false;
197 } 197 }
198 198
199 void TreeScopeStyleSheetCollection::updateUsesRemUnits() 199 void TreeScopeStyleSheetCollection::updateUsesRemUnits()
200 { 200 {
201 m_usesRemUnits = styleSheetsUseRemUnits(m_activeAuthorStyleSheets); 201 m_usesRemUnits = styleSheetsUseRemUnits(m_activeAuthorStyleSheets);
202 } 202 }
203 203
204 DEFINE_TRACE(TreeScopeStyleSheetCollection) 204 DEFINE_TRACE(TreeScopeStyleSheetCollection)
205 { 205 {
206 visitor->trace(m_treeScope); 206 visitor->trace(m_treeScope);
207 visitor->trace(m_styleSheetCandidateNodes); 207 visitor->trace(m_styleSheetCandidateNodes);
208 StyleSheetCollection::trace(visitor); 208 StyleSheetCollection::trace(visitor);
209 } 209 }
210 210
211 } 211 }
OLDNEW
« no previous file with comments | « Source/core/dom/TreeScopeStyleSheetCollection.h ('k') | Source/core/dom/WeakNodeMap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698