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

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

Issue 1215103007: Remove remaining HTML elements (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 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 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
4 * Copyright (C) 2012 Google Inc. All rights reserved. 4 * Copyright (C) 2012 Google Inc. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 16 matching lines...) Expand all
27 #include "sky/engine/core/css/resolver/ScopedStyleResolver.h" 27 #include "sky/engine/core/css/resolver/ScopedStyleResolver.h"
28 28
29 #include "sky/engine/core/css/RuleFeature.h" 29 #include "sky/engine/core/css/RuleFeature.h"
30 #include "sky/engine/core/css/StyleRule.h" 30 #include "sky/engine/core/css/StyleRule.h"
31 #include "sky/engine/core/css/StyleSheetContents.h" 31 #include "sky/engine/core/css/StyleSheetContents.h"
32 #include "sky/engine/core/css/resolver/StyleResolver.h" 32 #include "sky/engine/core/css/resolver/StyleResolver.h"
33 #include "sky/engine/core/dom/Document.h" 33 #include "sky/engine/core/dom/Document.h"
34 #include "sky/engine/core/dom/StyleEngine.h" 34 #include "sky/engine/core/dom/StyleEngine.h"
35 #include "sky/engine/core/dom/TreeScope.h" 35 #include "sky/engine/core/dom/TreeScope.h"
36 #include "sky/engine/core/dom/shadow/ShadowRoot.h" 36 #include "sky/engine/core/dom/shadow/ShadowRoot.h"
37 #include "sky/engine/core/html/HTMLStyleElement.h"
38 37
39 namespace blink { 38 namespace blink {
40 39
41 ScopedStyleResolver::ScopedStyleResolver(TreeScope& scope) 40 ScopedStyleResolver::ScopedStyleResolver(TreeScope& scope)
42 : m_scope(scope) 41 : m_scope(scope)
43 { 42 {
44 } 43 }
45 44
46 void ScopedStyleResolver::updateActiveStyleSheets() 45 void ScopedStyleResolver::updateActiveStyleSheets()
47 { 46 {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 bool ScopedStyleResolver::hasSelectorForAttribute(const AtomicString& attributeN ame) const 83 bool ScopedStyleResolver::hasSelectorForAttribute(const AtomicString& attributeN ame) const
85 { 84 {
86 for (auto& sheet : m_authorStyleSheets) { 85 for (auto& sheet : m_authorStyleSheets) {
87 RuleSet& ruleSet = sheet->contents()->ensureRuleSet(); 86 RuleSet& ruleSet = sheet->contents()->ensureRuleSet();
88 if (ruleSet.features().hasSelectorForAttribute(attributeName)) 87 if (ruleSet.features().hasSelectorForAttribute(attributeName))
89 return true; 88 return true;
90 } 89 }
91 return false; 90 return false;
92 } 91 }
93 92
94 void ScopedStyleResolver::addStyleSheetCandidateNode(HTMLStyleElement& element)
95 {
96 ASSERT(element.inActiveDocument());
97 m_styleSheetCandidateNodes.add(&element);
98 }
99
100 void ScopedStyleResolver::removeStyleSheetCandidateNode(HTMLStyleElement& elemen t)
101 {
102 m_styleSheetCandidateNodes.remove(&element);
103 }
104
105 void ScopedStyleResolver::collectStyleSheets(Vector<RefPtr<CSSStyleSheet>>& shee ts) 93 void ScopedStyleResolver::collectStyleSheets(Vector<RefPtr<CSSStyleSheet>>& shee ts)
106 { 94 {
107 MediaQueryEvaluator medium(m_scope.document().view());
108
109 for (Node* node : m_styleSheetCandidateNodes) {
110 ASSERT(isHTMLStyleElement(*node));
111 CSSStyleSheet* sheet = toHTMLStyleElement(node)->sheet();
112 if (sheet && (!sheet->mediaQueries() || medium.eval(sheet->mediaQueries( )))) {
113 sheets.append(sheet);
114 }
115 }
116 } 95 }
117 96
118 void ScopedStyleResolver::collectMatchingAuthorRules(ElementRuleCollector& colle ctor, CascadeOrder cascadeOrder) 97 void ScopedStyleResolver::collectMatchingAuthorRules(ElementRuleCollector& colle ctor, CascadeOrder cascadeOrder)
119 { 98 {
120 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) { 99 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) {
121 MatchRequest matchRequest(&m_authorStyleSheets[i]->contents()->ensureRul eSet(), m_authorStyleSheets[i].get(), i); 100 MatchRequest matchRequest(&m_authorStyleSheets[i]->contents()->ensureRul eSet(), m_authorStyleSheets[i].get(), i);
122 collector.collectMatchingRules(matchRequest, cascadeOrder); 101 collector.collectMatchingRules(matchRequest, cascadeOrder);
123 } 102 }
124 } 103 }
125 104
126 void ScopedStyleResolver::collectMatchingHostRules(ElementRuleCollector& collect or, CascadeOrder cascadeOrder) 105 void ScopedStyleResolver::collectMatchingHostRules(ElementRuleCollector& collect or, CascadeOrder cascadeOrder)
127 { 106 {
128 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) { 107 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) {
129 MatchRequest matchRequest(&m_authorStyleSheets[i]->contents()->ensureRul eSet(), m_authorStyleSheets[i].get(), i); 108 MatchRequest matchRequest(&m_authorStyleSheets[i]->contents()->ensureRul eSet(), m_authorStyleSheets[i].get(), i);
130 collector.collectMatchingHostRules(matchRequest, cascadeOrder); 109 collector.collectMatchingHostRules(matchRequest, cascadeOrder);
131 } 110 }
132 } 111 }
133 112
134 } // namespace blink 113 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/css/resolver/ScopedStyleResolver.h ('k') | sky/engine/core/dom/ContainerNode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698