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

Side by Side Diff: third_party/WebKit/Source/core/css/CSSGlobalRuleSet.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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "core/css/CSSGlobalRuleSet.h"
6
7 #include "core/css/CSSDefaultStyleSheets.h"
8 #include "core/css/RuleSet.h"
9 #include "core/dom/CSSSelectorWatch.h"
10 #include "core/dom/Document.h"
11 #include "core/dom/StyleEngine.h"
12
13 namespace blink {
14
15 void CSSGlobalRuleSet::initWatchedSelectorsRuleSet(Document& document)
16 {
17 m_watchedSelectorsRuleSet = nullptr;
18 CSSSelectorWatch* watch = CSSSelectorWatch::fromIfExists(document);
19 if (!watch)
20 return;
21 const HeapVector<Member<StyleRule>>& watchedSelectors = watch->watchedCallba ckSelectors();
22 if (!watchedSelectors.size())
23 return;
24 m_watchedSelectorsRuleSet = RuleSet::create();
25 for (unsigned i = 0; i < watchedSelectors.size(); ++i)
26 m_watchedSelectorsRuleSet->addStyleRule(watchedSelectors[i].get(), RuleH asNoSpecialState);
27 }
28
29 static RuleSet* makeRuleSet(const HeapVector<RuleFeature>& rules)
30 {
31 size_t size = rules.size();
32 if (!size)
33 return nullptr;
34 RuleSet* ruleSet = RuleSet::create();
35 for (size_t i = 0; i < size; ++i)
36 ruleSet->addRule(rules[i].rule, rules[i].selectorIndex, rules[i].hasDocu mentSecurityOrigin ? RuleHasDocumentSecurityOrigin : RuleHasNoSpecialState);
37 return ruleSet;
38 }
39
40 void CSSGlobalRuleSet::update(Document& document)
41 {
42 m_features.clear();
43
44 CSSDefaultStyleSheets& defaultStyleSheets = CSSDefaultStyleSheets::instance( );
45 if (defaultStyleSheets.defaultStyle())
46 m_features.add(defaultStyleSheets.defaultStyle()->features());
47
48 if (document.isViewSource())
49 m_features.add(defaultStyleSheets.defaultViewSourceStyle()->features());
50
51 if (m_watchedSelectorsRuleSet)
52 m_features.add(m_watchedSelectorsRuleSet->features());
53
54 document.styleEngine().collectScopedStyleFeaturesTo(m_features);
55
56 m_siblingRuleSet = makeRuleSet(m_features.siblingRules);
57 m_uncommonAttributeRuleSet = makeRuleSet(m_features.uncommonAttributeRules);
58 }
59
60 DEFINE_TRACE(CSSGlobalRuleSet)
61 {
62 visitor->trace(m_features);
63 visitor->trace(m_siblingRuleSet);
64 visitor->trace(m_uncommonAttributeRuleSet);
65 visitor->trace(m_watchedSelectorsRuleSet);
66 }
67
68 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSGlobalRuleSet.h ('k') | third_party/WebKit/Source/core/css/CSSStyleSheet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698