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

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

Issue 1913833002: Current work-in-progress crbug.com/567021 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More assert fixes Created 4 years, 6 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 10 matching lines...) Expand all
21 * You should have received a copy of the GNU Library General Public License 21 * You should have received a copy of the GNU Library General Public License
22 * along with this library; see the file COPYING.LIB. If not, write to 22 * along with this library; see the file COPYING.LIB. If not, write to
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 "core/dom/ShadowTreeStyleSheetCollection.h" 27 #include "core/dom/ShadowTreeStyleSheetCollection.h"
28 28
29 #include "core/HTMLNames.h" 29 #include "core/HTMLNames.h"
30 #include "core/css/CSSStyleSheet.h" 30 #include "core/css/CSSStyleSheet.h"
31 #include "core/css/StyleSheetContents.h"
31 #include "core/css/resolver/StyleResolver.h" 32 #include "core/css/resolver/StyleResolver.h"
32 #include "core/dom/Element.h" 33 #include "core/dom/Element.h"
33 #include "core/dom/StyleChangeReason.h" 34 #include "core/dom/StyleChangeReason.h"
34 #include "core/dom/StyleEngine.h" 35 #include "core/dom/StyleEngine.h"
35 #include "core/dom/StyleSheetCandidate.h" 36 #include "core/dom/StyleSheetCandidate.h"
36 #include "core/dom/shadow/ShadowRoot.h" 37 #include "core/dom/shadow/ShadowRoot.h"
37 #include "core/html/HTMLStyleElement.h" 38 #include "core/html/HTMLStyleElement.h"
38 39
39 namespace blink { 40 namespace blink {
40 41
41 using namespace HTMLNames; 42 using namespace HTMLNames;
42 43
43 ShadowTreeStyleSheetCollection::ShadowTreeStyleSheetCollection(ShadowRoot& shado wRoot) 44 ShadowTreeStyleSheetCollection::ShadowTreeStyleSheetCollection(ShadowRoot& shado wRoot)
44 : TreeScopeStyleSheetCollection(shadowRoot) 45 : TreeScopeStyleSheetCollection(shadowRoot)
45 { 46 {
46 } 47 }
47 48
48 void ShadowTreeStyleSheetCollection::collectStyleSheets(StyleEngine& engine, Sty leSheetCollection& collection) 49 void ShadowTreeStyleSheetCollection::collectStyleSheets(StyleSheetCollection& co llection)
49 { 50 {
50 for (Node* n : m_styleSheetCandidateNodes) { 51 for (Node* n : m_styleSheetCandidateNodes) {
51 StyleSheetCandidate candidate(*n); 52 StyleSheetCandidate candidate(*n);
52 DCHECK(!candidate.isXSL()); 53 DCHECK(!candidate.isXSL());
53 54
54 if (!candidate.isCSSStyle()) 55 if (!candidate.isCSSStyle())
55 continue; 56 continue;
56 57
57 StyleSheet* sheet = candidate.sheet(); 58 StyleSheet* sheet = candidate.sheet();
58 if (!sheet) 59 if (!sheet)
59 continue; 60 continue;
60 61
61 collection.appendSheetForList(sheet); 62 collection.appendSheetForList(sheet);
62 if (candidate.canBeActivated(nullAtom)) 63 if (candidate.canBeActivated(nullAtom)) {
63 collection.appendActiveStyleSheet(toCSSStyleSheet(sheet)); 64 CSSStyleSheet* cssSheet = toCSSStyleSheet(sheet);
65 collection.appendActiveStyleSheet(std::make_pair(cssSheet, &document ().styleEngine().ensureRuleSetForSheet(*cssSheet)));
66 }
64 } 67 }
65 } 68 }
66 69
67 void ShadowTreeStyleSheetCollection::updateActiveStyleSheets(StyleEngine& engine , StyleResolverUpdateMode updateMode) 70 void ShadowTreeStyleSheetCollection::updateActiveStyleSheets()
68 { 71 {
69 StyleSheetCollection collection; 72 StyleSheetCollection collection;
70 collectStyleSheets(engine, collection); 73 collectStyleSheets(collection);
71 74 applyActiveStyleSheetChanges(collection);
72 StyleSheetChange change;
73 analyzeStyleSheetChange(updateMode, collection, change);
74
75 if (StyleResolver* styleResolver = engine.resolver()) {
76 if (change.styleResolverUpdateType != Additive) {
77 // We should not destroy StyleResolver when we find any stylesheet u pdate in a shadow tree.
78 // In this case, we will reset rulesets created from style elements in the shadow tree.
79 styleResolver->resetAuthorStyle(treeScope());
80 styleResolver->removePendingAuthorStyleSheets(m_activeAuthorStyleShe ets);
81 styleResolver->lazyAppendAuthorStyleSheets(0, collection.activeAutho rStyleSheets());
82 } else {
83 styleResolver->lazyAppendAuthorStyleSheets(m_activeAuthorStyleSheets .size(), collection.activeAuthorStyleSheets());
84 }
85 }
86 if (change.requiresFullStyleRecalc)
87 toShadowRoot(treeScope().rootNode()).host().setNeedsStyleRecalc(SubtreeS tyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::ActiveStylesh eetsUpdate));
88
89 collection.swap(*this);
90 } 75 }
91 76
92 } // namespace blink 77 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698