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

Side by Side Diff: sky/engine/core/dom/StyleSheetCollection.cpp

Issue 836383005: Don't walk treescopes in updateActiveStyleSheets until the resolver exists. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Remove comments. 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/dom/StyleSheetCollection.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 12 matching lines...) Expand all
23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 * Boston, MA 02110-1301, USA. 24 * Boston, MA 02110-1301, USA.
25 */ 25 */
26 26
27 #include "sky/engine/config.h" 27 #include "sky/engine/config.h"
28 #include "sky/engine/core/dom/StyleSheetCollection.h" 28 #include "sky/engine/core/dom/StyleSheetCollection.h"
29 29
30 #include "sky/engine/core/css/CSSStyleSheet.h" 30 #include "sky/engine/core/css/CSSStyleSheet.h"
31 #include "sky/engine/core/css/resolver/StyleResolver.h" 31 #include "sky/engine/core/css/resolver/StyleResolver.h"
32 #include "sky/engine/core/dom/Document.h" 32 #include "sky/engine/core/dom/Document.h"
33 #include "sky/engine/core/dom/StyleEngine.h"
34 #include "sky/engine/core/dom/shadow/ShadowRoot.h" 33 #include "sky/engine/core/dom/shadow/ShadowRoot.h"
35 #include "sky/engine/core/dom/TreeScope.h" 34 #include "sky/engine/core/dom/TreeScope.h"
36 #include "sky/engine/core/html/HTMLStyleElement.h" 35 #include "sky/engine/core/html/HTMLStyleElement.h"
37 36
38 namespace blink { 37 namespace blink {
39 38
40 StyleSheetCollection::StyleSheetCollection(TreeScope& treeScope) 39 StyleSheetCollection::StyleSheetCollection(TreeScope& treeScope)
41 : m_treeScope(treeScope) 40 : m_treeScope(treeScope)
42 , m_needsUpdate(true) 41 , m_needsUpdate(true)
43 { 42 {
(...skipping 18 matching lines...) Expand all
62 61
63 void StyleSheetCollection::collectStyleSheets(Vector<RefPtr<CSSStyleSheet>>& she ets) 62 void StyleSheetCollection::collectStyleSheets(Vector<RefPtr<CSSStyleSheet>>& she ets)
64 { 63 {
65 for (Node* node : m_styleSheetCandidateNodes) { 64 for (Node* node : m_styleSheetCandidateNodes) {
66 ASSERT(isHTMLStyleElement(*node)); 65 ASSERT(isHTMLStyleElement(*node));
67 if (CSSStyleSheet* sheet = toHTMLStyleElement(node)->sheet()) 66 if (CSSStyleSheet* sheet = toHTMLStyleElement(node)->sheet())
68 sheets.append(sheet); 67 sheets.append(sheet);
69 } 68 }
70 } 69 }
71 70
72 void StyleSheetCollection::updateActiveStyleSheets(StyleEngine* engine) 71 void StyleSheetCollection::updateActiveStyleSheets(StyleResolver& resolver)
73 { 72 {
74 // TODO(esprehn): We need to check if the resolver exists otherwise style 73 if (!m_needsUpdate)
75 // doesn't get computed right. We should figure out why.
76 if (!m_needsUpdate && engine->resolver())
77 return; 74 return;
78 75
79 Vector<RefPtr<CSSStyleSheet>> candidateSheets; 76 Vector<RefPtr<CSSStyleSheet>> candidateSheets;
80 collectStyleSheets(candidateSheets); 77 collectStyleSheets(candidateSheets);
81 78
79 m_treeScope.scopedStyleResolver().resetAuthorStyle();
80 resolver.removePendingAuthorStyleSheets(m_activeAuthorStyleSheets);
81 resolver.lazyAppendAuthorStyleSheets(0, candidateSheets);
82
82 Node& root = m_treeScope.rootNode(); 83 Node& root = m_treeScope.rootNode();
83 84
84 // TODO(esprehn): Remove special casing for Document.
85 if (root.isDocumentNode()) {
86 engine->clearResolver();
87 // FIMXE: The following depends on whether StyleRuleFontFace was modifie d or not.
88 // No need to always-clear font cache.
89 engine->clearFontCache();
90 } else if (StyleResolver* styleResolver = engine->resolver()) {
91 // We should not destroy StyleResolver when we find any stylesheet updat e in a shadow tree.
92 // In this case, we will reset rulesets created from style elements in t he shadow tree.
93 m_treeScope.scopedStyleResolver().resetAuthorStyle();
94 styleResolver->removePendingAuthorStyleSheets(m_activeAuthorStyleSheets) ;
95 styleResolver->lazyAppendAuthorStyleSheets(0, candidateSheets);
96 }
97
98 // TODO(esprehn): We should avoid subtree recalcs in sky when rules change 85 // TODO(esprehn): We should avoid subtree recalcs in sky when rules change
99 // and only recalc specific tree scopes. 86 // and only recalc specific tree scopes.
100 root.setNeedsStyleRecalc(SubtreeStyleChange); 87 root.setNeedsStyleRecalc(SubtreeStyleChange);
101 88
102 // TODO(esprehn): We should use LocalStyleChange, :host rule changes 89 // TODO(esprehn): We should use LocalStyleChange, :host rule changes
103 // can only impact the host directly as Sky has no descendant selectors. 90 // can only impact the host directly as Sky has no descendant selectors.
104 if (root.isShadowRoot()) 91 if (root.isShadowRoot())
105 toShadowRoot(root).host()->setNeedsStyleRecalc(SubtreeStyleChange); 92 toShadowRoot(root).host()->setNeedsStyleRecalc(SubtreeStyleChange);
106 93
107 m_activeAuthorStyleSheets.swap(candidateSheets); 94 m_activeAuthorStyleSheets.swap(candidateSheets);
108 m_needsUpdate = false; 95 m_needsUpdate = false;
109 } 96 }
110 97
111 } 98 }
OLDNEW
« no previous file with comments | « sky/engine/core/dom/StyleSheetCollection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698