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

Side by Side Diff: sky/engine/core/css/resolver/StyleResolver.cpp

Issue 846183002: Remove tracking of pending sheets. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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 | « sky/engine/core/css/resolver/StyleResolver.h ('k') | sky/engine/core/dom/Document.h » ('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) 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, 2013 Apple Inc. All rights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 { 124 {
125 FrameView* view = document.view(); 125 FrameView* view = document.view();
126 if (view) { 126 if (view) {
127 m_medium = adoptPtr(new MediaQueryEvaluator(&view->frame())); 127 m_medium = adoptPtr(new MediaQueryEvaluator(&view->frame()));
128 m_printMediaType = equalIgnoringCase(view->mediaType(), MediaTypeNames:: print); 128 m_printMediaType = equalIgnoringCase(view->mediaType(), MediaTypeNames:: print);
129 } else { 129 } else {
130 m_medium = adoptPtr(new MediaQueryEvaluator("all")); 130 m_medium = adoptPtr(new MediaQueryEvaluator("all"));
131 } 131 }
132 } 132 }
133 133
134 void StyleResolver::lazyAppendAuthorStyleSheets(unsigned firstNew, const Vector< RefPtr<CSSStyleSheet> >& styleSheets)
135 {
136 unsigned size = styleSheets.size();
137 for (unsigned i = firstNew; i < size; ++i)
138 m_pendingStyleSheets.add(styleSheets[i].get());
139 }
140
141 void StyleResolver::removePendingAuthorStyleSheets(const Vector<RefPtr<CSSStyleS heet> >& styleSheets)
142 {
143 for (unsigned i = 0; i < styleSheets.size(); ++i)
144 m_pendingStyleSheets.remove(styleSheets[i].get());
145 }
146
147 void StyleResolver::appendCSSStyleSheet(CSSStyleSheet* cssSheet) 134 void StyleResolver::appendCSSStyleSheet(CSSStyleSheet* cssSheet)
148 { 135 {
149 ASSERT(cssSheet); 136 ASSERT(cssSheet);
150 if (cssSheet->mediaQueries() && !m_medium->eval(cssSheet->mediaQueries(), &m _viewportDependentMediaQueryResults)) 137 if (cssSheet->mediaQueries() && !m_medium->eval(cssSheet->mediaQueries(), &m _viewportDependentMediaQueryResults))
151 return; 138 return;
152 139
153 Node* ownerNode = cssSheet->ownerNode(); 140 Node* ownerNode = cssSheet->ownerNode();
154 if (!ownerNode) 141 if (!ownerNode)
155 return; 142 return;
156 143
(...skipping 13 matching lines...) Expand all
170 const Vector<RawPtr<StyleRuleFontFace> > fontFaceRules = ruleSet.fontFac eRules(); 157 const Vector<RawPtr<StyleRuleFontFace> > fontFaceRules = ruleSet.fontFac eRules();
171 for (unsigned i = 0; i < fontFaceRules.size(); ++i) { 158 for (unsigned i = 0; i < fontFaceRules.size(); ++i) {
172 if (RefPtr<FontFace> fontFace = FontFace::create(&document(), fontFa ceRules[i])) 159 if (RefPtr<FontFace> fontFace = FontFace::create(&document(), fontFa ceRules[i]))
173 fontSelector->fontFaceCache()->add(fontSelector, fontFaceRules[i ], fontFace); 160 fontSelector->fontFaceCache()->add(fontSelector, fontFaceRules[i ], fontFace);
174 } 161 }
175 if (fontFaceRules.size()) 162 if (fontFaceRules.size())
176 invalidateMatchedPropertiesCache(); 163 invalidateMatchedPropertiesCache();
177 } 164 }
178 } 165 }
179 166
180 void StyleResolver::appendPendingAuthorStyleSheets()
181 {
182 for (ListHashSet<RawPtr<CSSStyleSheet>, 16>::iterator it = m_pendingStyleShe ets.begin(); it != m_pendingStyleSheets.end(); ++it)
183 appendCSSStyleSheet(*it);
184
185 m_pendingStyleSheets.clear();
186 finishAppendAuthorStyleSheets();
187 }
188
189 void StyleResolver::appendAuthorStyleSheets(const Vector<RefPtr<CSSStyleSheet> > & styleSheets)
190 {
191 // This handles sheets added to the end of the stylesheet list only. In othe r cases the style resolver
192 // needs to be reconstructed. To handle insertions too the rule order number s would need to be updated.
193 unsigned size = styleSheets.size();
194 for (unsigned i = 0; i < size; ++i)
195 appendCSSStyleSheet(styleSheets[i].get());
196 }
197
198 void StyleResolver::finishAppendAuthorStyleSheets()
199 {
200 if (document().renderView() && document().renderView()->style())
201 document().renderView()->style()->font().update(document().styleEngine() ->fontSelector());
202 }
203
204 void StyleResolver::addToStyleSharingList(Element& element) 167 void StyleResolver::addToStyleSharingList(Element& element)
205 { 168 {
206 // Never add elements to the style sharing list if we're not in a recalcStyl e, 169 // Never add elements to the style sharing list if we're not in a recalcStyl e,
207 // otherwise we could leave stale pointers in there. 170 // otherwise we could leave stale pointers in there.
208 if (!document().inStyleRecalc()) 171 if (!document().inStyleRecalc())
209 return; 172 return;
210 ASSERT(element.supportsStyleSharing()); 173 ASSERT(element.supportsStyleSharing());
211 INCREMENT_STYLE_STATS_COUNTER(*this, sharedStyleCandidates); 174 INCREMENT_STYLE_STATS_COUNTER(*this, sharedStyleCandidates);
212 StyleSharingList& list = styleSharingList(); 175 StyleSharingList& list = styleSharingList();
213 if (list.size() >= styleSharingListSize) 176 if (list.size() >= styleSharingListSize)
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 void StyleResolver::loadPendingResources(StyleResolverState& state) 247 void StyleResolver::loadPendingResources(StyleResolverState& state)
285 { 248 {
286 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle Resources()); 249 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle Resources());
287 document().styleEngine()->fontSelector()->fontLoader()->loadPendingFonts(); 250 document().styleEngine()->fontSelector()->fontLoader()->loadPendingFonts();
288 } 251 }
289 252
290 PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS tyle* defaultParent) 253 PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS tyle* defaultParent)
291 { 254 {
292 ASSERT(document().frame()); 255 ASSERT(document().frame());
293 ASSERT(document().settings()); 256 ASSERT(document().settings());
294 ASSERT(!hasPendingAuthorStyleSheets());
295 257
296 didAccess(); 258 didAccess();
297 259
298 if (element == document().documentElement()) 260 if (element == document().documentElement())
299 document().setDirectionSetOnDocumentElement(false); 261 document().setDirectionSetOnDocumentElement(false);
300 StyleResolverState state(document(), element, defaultParent); 262 StyleResolverState state(document(), element, defaultParent);
301 263
302 if (state.parentStyle()) { 264 if (state.parentStyle()) {
303 SharedStyleFinder styleFinder(state.elementContext(), *this); 265 SharedStyleFinder styleFinder(state.elementContext(), *this);
304 if (RefPtr<RenderStyle> sharedStyle = styleFinder.findSharedStyle()) 266 if (RefPtr<RenderStyle> sharedStyle = styleFinder.findSharedStyle())
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 document().setHasViewportUnits(); 311 document().setHasViewportUnits();
350 312
351 // Now return the style. 313 // Now return the style.
352 return state.takeStyle(); 314 return state.takeStyle();
353 } 315 }
354 316
355 PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(Element* element, const RenderStyle& elementStyle, RenderStyle* parentStyle, const StyleKeyframe* keyfra me, const AtomicString& animationName) 317 PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(Element* element, const RenderStyle& elementStyle, RenderStyle* parentStyle, const StyleKeyframe* keyfra me, const AtomicString& animationName)
356 { 318 {
357 ASSERT(document().frame()); 319 ASSERT(document().frame());
358 ASSERT(document().settings()); 320 ASSERT(document().settings());
359 ASSERT(!hasPendingAuthorStyleSheets());
360 321
361 if (element == document().documentElement()) 322 if (element == document().documentElement())
362 document().setDirectionSetOnDocumentElement(false); 323 document().setDirectionSetOnDocumentElement(false);
363 StyleResolverState state(document(), element, parentStyle); 324 StyleResolverState state(document(), element, parentStyle);
364 325
365 MatchResult result; 326 MatchResult result;
366 result.addMatchedProperties(&keyframe->properties()); 327 result.addMatchedProperties(&keyframe->properties());
367 328
368 ASSERT(!state.style()); 329 ASSERT(!state.style());
369 330
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 bool StyleResolver::mediaQueryAffectedByViewportChange() const 739 bool StyleResolver::mediaQueryAffectedByViewportChange() const
779 { 740 {
780 for (unsigned i = 0; i < m_viewportDependentMediaQueryResults.size(); ++i) { 741 for (unsigned i = 0; i < m_viewportDependentMediaQueryResults.size(); ++i) {
781 if (m_medium->eval(m_viewportDependentMediaQueryResults[i]->expression() ) != m_viewportDependentMediaQueryResults[i]->result()) 742 if (m_medium->eval(m_viewportDependentMediaQueryResults[i]->expression() ) != m_viewportDependentMediaQueryResults[i]->result())
782 return true; 743 return true;
783 } 744 }
784 return false; 745 return false;
785 } 746 }
786 747
787 } // namespace blink 748 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/css/resolver/StyleResolver.h ('k') | sky/engine/core/dom/Document.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698