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

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: Fixed html import issue. Created 4 years 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 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All
7 * rights reserved. 7 * rights reserved.
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 10 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
(...skipping 29 matching lines...) Expand all
40 40
41 namespace blink { 41 namespace blink {
42 42
43 using namespace HTMLNames; 43 using namespace HTMLNames;
44 44
45 ShadowTreeStyleSheetCollection::ShadowTreeStyleSheetCollection( 45 ShadowTreeStyleSheetCollection::ShadowTreeStyleSheetCollection(
46 ShadowRoot& shadowRoot) 46 ShadowRoot& shadowRoot)
47 : TreeScopeStyleSheetCollection(shadowRoot) {} 47 : TreeScopeStyleSheetCollection(shadowRoot) {}
48 48
49 void ShadowTreeStyleSheetCollection::collectStyleSheets( 49 void ShadowTreeStyleSheetCollection::collectStyleSheets(
50 StyleEngine& engine,
51 StyleSheetCollection& collection) { 50 StyleSheetCollection& collection) {
52 for (Node* n : m_styleSheetCandidateNodes) { 51 for (Node* n : m_styleSheetCandidateNodes) {
53 StyleSheetCandidate candidate(*n); 52 StyleSheetCandidate candidate(*n);
54 DCHECK(!candidate.isXSL()); 53 DCHECK(!candidate.isXSL());
55 54
56 StyleSheet* sheet = candidate.sheet(); 55 StyleSheet* sheet = candidate.sheet();
57 if (!sheet) 56 if (!sheet)
58 continue; 57 continue;
59 58
60 collection.appendSheetForList(sheet); 59 collection.appendSheetForList(sheet);
61 if (candidate.canBeActivated(nullAtom)) 60 if (candidate.canBeActivated(nullAtom)) {
62 collection.appendActiveStyleSheet(toCSSStyleSheet(sheet)); 61 CSSStyleSheet* cssSheet = toCSSStyleSheet(sheet);
62 collection.appendActiveStyleSheet(std::make_pair(
63 cssSheet, document().styleEngine().ruleSetForSheet(*cssSheet)));
64 }
63 } 65 }
64 } 66 }
65 67
66 void ShadowTreeStyleSheetCollection::updateActiveStyleSheets( 68 void ShadowTreeStyleSheetCollection::updateActiveStyleSheets() {
67 StyleEngine& engine,
68 StyleResolverUpdateMode updateMode) {
69 // StyleSheetCollection is GarbageCollected<>, allocate it on the heap. 69 // StyleSheetCollection is GarbageCollected<>, allocate it on the heap.
70 StyleSheetCollection* collection = StyleSheetCollection::create(); 70 StyleSheetCollection* collection = StyleSheetCollection::create();
71 collectStyleSheets(engine, *collection); 71 collectStyleSheets(*collection);
72 72 applyActiveStyleSheetChanges(*collection);
73 StyleSheetChange change;
74 analyzeStyleSheetChange(updateMode, collection->activeAuthorStyleSheets(),
75 change);
76
77 if (StyleResolver* styleResolver = engine.resolver()) {
78 if (change.styleResolverUpdateType != Additive) {
79 // We should not destroy StyleResolver when we find any stylesheet update
80 // in a shadow tree. In this case, we will reset rulesets created from
81 // style elements in the shadow tree.
82 engine.resetAuthorStyle(treeScope());
83 styleResolver->removePendingAuthorStyleSheets(m_activeAuthorStyleSheets);
84 styleResolver->lazyAppendAuthorStyleSheets(
85 0, collection->activeAuthorStyleSheets());
86 } else {
87 styleResolver->lazyAppendAuthorStyleSheets(
88 m_activeAuthorStyleSheets.size(),
89 collection->activeAuthorStyleSheets());
90 }
91 }
92 if (change.requiresFullStyleRecalc)
93 toShadowRoot(treeScope().rootNode())
94 .host()
95 .setNeedsStyleRecalc(SubtreeStyleChange,
96 StyleChangeReasonForTracing::create(
97 StyleChangeReason::ActiveStylesheetsUpdate));
98
99 collection->swap(*this);
100 collection->dispose();
101 } 73 }
102 74
103 } // namespace blink 75 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698