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

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

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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) 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 } 45 }
46 46
47 void TreeScopeStyleSheetCollection::addStyleSheetCandidateNode(Node* node) 47 void TreeScopeStyleSheetCollection::addStyleSheetCandidateNode(Node* node)
48 { 48 {
49 if (!node->inDocument()) 49 if (!node->inDocument())
50 return; 50 return;
51 51
52 m_styleSheetCandidateNodes.add(node); 52 m_styleSheetCandidateNodes.add(node);
53 } 53 }
54 54
55 TreeScopeStyleSheetCollection::StyleResolverUpdateType TreeScopeStyleSheetCollec tion::compareStyleSheets(const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet >>& oldStyleSheets, const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet>>& n ewStylesheets, WillBeHeapVector<RawPtrWillBeMember<StyleSheetContents>>& addedSh eets) 55 TreeScopeStyleSheetCollection::StyleResolverUpdateType TreeScopeStyleSheetCollec tion::compareStyleSheets(const HeapVector<Member<CSSStyleSheet>>& oldStyleSheets , const HeapVector<Member<CSSStyleSheet>>& newStylesheets, HeapVector<Member<Sty leSheetContents>>& addedSheets)
56 { 56 {
57 unsigned newStyleSheetCount = newStylesheets.size(); 57 unsigned newStyleSheetCount = newStylesheets.size();
58 unsigned oldStyleSheetCount = oldStyleSheets.size(); 58 unsigned oldStyleSheetCount = oldStyleSheets.size();
59 ASSERT(newStyleSheetCount >= oldStyleSheetCount); 59 ASSERT(newStyleSheetCount >= oldStyleSheetCount);
60 60
61 if (!newStyleSheetCount) 61 if (!newStyleSheetCount)
62 return Reconstruct; 62 return Reconstruct;
63 63
64 unsigned newIndex = 0; 64 unsigned newIndex = 0;
65 for (unsigned oldIndex = 0; oldIndex < oldStyleSheetCount; ++oldIndex) { 65 for (unsigned oldIndex = 0; oldIndex < oldStyleSheetCount; ++oldIndex) {
66 while (oldStyleSheets[oldIndex] != newStylesheets[newIndex]) { 66 while (oldStyleSheets[oldIndex] != newStylesheets[newIndex]) {
67 addedSheets.append(newStylesheets[newIndex]->contents()); 67 addedSheets.append(newStylesheets[newIndex]->contents());
68 if (++newIndex == newStyleSheetCount) 68 if (++newIndex == newStyleSheetCount)
69 return Reconstruct; 69 return Reconstruct;
70 } 70 }
71 if (++newIndex == newStyleSheetCount) 71 if (++newIndex == newStyleSheetCount)
72 return Reconstruct; 72 return Reconstruct;
73 } 73 }
74 bool hasInsertions = !addedSheets.isEmpty(); 74 bool hasInsertions = !addedSheets.isEmpty();
75 while (newIndex < newStyleSheetCount) { 75 while (newIndex < newStyleSheetCount) {
76 addedSheets.append(newStylesheets[newIndex]->contents()); 76 addedSheets.append(newStylesheets[newIndex]->contents());
77 ++newIndex; 77 ++newIndex;
78 } 78 }
79 // If all new sheets were added at the end of the list we can just add them to existing StyleResolver. 79 // If all new sheets were added at the end of the list we can just add them to existing StyleResolver.
80 // If there were insertions we need to re-add all the stylesheets so rules a re ordered correctly. 80 // If there were insertions we need to re-add all the stylesheets so rules a re ordered correctly.
81 return hasInsertions ? Reset : Additive; 81 return hasInsertions ? Reset : Additive;
82 } 82 }
83 83
84 bool TreeScopeStyleSheetCollection::activeLoadingStyleSheetLoaded(const WillBeHe apVector<RefPtrWillBeMember<CSSStyleSheet>>& newStyleSheets) 84 bool TreeScopeStyleSheetCollection::activeLoadingStyleSheetLoaded(const HeapVect or<Member<CSSStyleSheet>>& newStyleSheets)
85 { 85 {
86 // StyleSheets of <style> elements that @import stylesheets are active but l oading. We need to trigger a full recalc when such loads are done. 86 // StyleSheets of <style> elements that @import stylesheets are active but l oading. We need to trigger a full recalc when such loads are done.
87 bool hasActiveLoadingStylesheet = false; 87 bool hasActiveLoadingStylesheet = false;
88 unsigned newStylesheetCount = newStyleSheets.size(); 88 unsigned newStylesheetCount = newStyleSheets.size();
89 for (unsigned i = 0; i < newStylesheetCount; ++i) { 89 for (unsigned i = 0; i < newStylesheetCount; ++i) {
90 if (newStyleSheets[i]->isLoading()) 90 if (newStyleSheets[i]->isLoading())
91 hasActiveLoadingStylesheet = true; 91 hasActiveLoadingStylesheet = true;
92 } 92 }
93 if (m_hadActiveLoadingStylesheet && !hasActiveLoadingStylesheet) { 93 if (m_hadActiveLoadingStylesheet && !hasActiveLoadingStylesheet) {
94 m_hadActiveLoadingStylesheet = false; 94 m_hadActiveLoadingStylesheet = false;
95 return true; 95 return true;
96 } 96 }
97 m_hadActiveLoadingStylesheet = hasActiveLoadingStylesheet; 97 m_hadActiveLoadingStylesheet = hasActiveLoadingStylesheet;
98 return false; 98 return false;
99 } 99 }
100 100
101 static bool findFontFaceRulesFromStyleSheetContents(const WillBeHeapVector<RawPt rWillBeMember<StyleSheetContents>>& sheets, WillBeHeapVector<RawPtrWillBeMember< const StyleRuleFontFace>>& fontFaceRules) 101 static bool findFontFaceRulesFromStyleSheetContents(const HeapVector<Member<Styl eSheetContents>>& sheets, HeapVector<Member<const StyleRuleFontFace>>& fontFaceR ules)
102 { 102 {
103 bool hasFontFaceRule = false; 103 bool hasFontFaceRule = false;
104 104
105 for (unsigned i = 0; i < sheets.size(); ++i) { 105 for (unsigned i = 0; i < sheets.size(); ++i) {
106 ASSERT(sheets[i]); 106 ASSERT(sheets[i]);
107 if (sheets[i]->hasFontFaceRule()) { 107 if (sheets[i]->hasFontFaceRule()) {
108 // FIXME: We don't need this for styles in shadow tree. 108 // FIXME: We don't need this for styles in shadow tree.
109 sheets[i]->findFontFaceRules(fontFaceRules); 109 sheets[i]->findFontFaceRules(fontFaceRules);
110 hasFontFaceRule = true; 110 hasFontFaceRule = true;
111 } 111 }
112 } 112 }
113 return hasFontFaceRule; 113 return hasFontFaceRule;
114 } 114 }
115 115
116 void TreeScopeStyleSheetCollection::analyzeStyleSheetChange(StyleResolverUpdateM ode updateMode, const StyleSheetCollection& newCollection, StyleSheetChange& cha nge) 116 void TreeScopeStyleSheetCollection::analyzeStyleSheetChange(StyleResolverUpdateM ode updateMode, const StyleSheetCollection& newCollection, StyleSheetChange& cha nge)
117 { 117 {
118 if (activeLoadingStyleSheetLoaded(newCollection.activeAuthorStyleSheets())) 118 if (activeLoadingStyleSheetLoaded(newCollection.activeAuthorStyleSheets()))
119 return; 119 return;
120 120
121 if (updateMode != AnalyzedStyleUpdate) 121 if (updateMode != AnalyzedStyleUpdate)
122 return; 122 return;
123 123
124 // Find out which stylesheets are new. 124 // Find out which stylesheets are new.
125 WillBeHeapVector<RawPtrWillBeMember<StyleSheetContents>> addedSheets; 125 HeapVector<Member<StyleSheetContents>> addedSheets;
126 if (m_activeAuthorStyleSheets.size() <= newCollection.activeAuthorStyleSheet s().size()) { 126 if (m_activeAuthorStyleSheets.size() <= newCollection.activeAuthorStyleSheet s().size()) {
127 change.styleResolverUpdateType = compareStyleSheets(m_activeAuthorStyleS heets, newCollection.activeAuthorStyleSheets(), addedSheets); 127 change.styleResolverUpdateType = compareStyleSheets(m_activeAuthorStyleS heets, newCollection.activeAuthorStyleSheets(), addedSheets);
128 } else { 128 } else {
129 StyleResolverUpdateType updateType = compareStyleSheets(newCollection.ac tiveAuthorStyleSheets(), m_activeAuthorStyleSheets, addedSheets); 129 StyleResolverUpdateType updateType = compareStyleSheets(newCollection.ac tiveAuthorStyleSheets(), m_activeAuthorStyleSheets, addedSheets);
130 if (updateType != Additive) { 130 if (updateType != Additive) {
131 change.styleResolverUpdateType = updateType; 131 change.styleResolverUpdateType = updateType;
132 } else { 132 } else {
133 change.styleResolverUpdateType = Reset; 133 change.styleResolverUpdateType = Reset;
134 // If @font-face is removed, needs full style recalc. 134 // If @font-face is removed, needs full style recalc.
135 if (findFontFaceRulesFromStyleSheetContents(addedSheets, change.font FaceRulesToRemove)) 135 if (findFontFaceRulesFromStyleSheetContents(addedSheets, change.font FaceRulesToRemove))
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 } 168 }
169 169
170 DEFINE_TRACE(TreeScopeStyleSheetCollection) 170 DEFINE_TRACE(TreeScopeStyleSheetCollection)
171 { 171 {
172 visitor->trace(m_treeScope); 172 visitor->trace(m_treeScope);
173 visitor->trace(m_styleSheetCandidateNodes); 173 visitor->trace(m_styleSheetCandidateNodes);
174 StyleSheetCollection::trace(visitor); 174 StyleSheetCollection::trace(visitor);
175 } 175 }
176 176
177 } // namespace blink 177 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698