OLD | NEW |
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 25 matching lines...) Expand all Loading... |
36 #include "core/dom/StyleEngine.h" | 36 #include "core/dom/StyleEngine.h" |
37 #include "core/html/HTMLLinkElement.h" | 37 #include "core/html/HTMLLinkElement.h" |
38 #include "core/html/HTMLStyleElement.h" | 38 #include "core/html/HTMLStyleElement.h" |
39 | 39 |
40 namespace blink { | 40 namespace blink { |
41 | 41 |
42 TreeScopeStyleSheetCollection::TreeScopeStyleSheetCollection(TreeScope& treeScop
e) | 42 TreeScopeStyleSheetCollection::TreeScopeStyleSheetCollection(TreeScope& treeScop
e) |
43 : m_treeScope(treeScope) | 43 : m_treeScope(treeScope) |
44 , m_hadActiveLoadingStylesheet(false) | 44 , m_hadActiveLoadingStylesheet(false) |
45 , m_usesRemUnits(false) | 45 , m_usesRemUnits(false) |
| 46 , m_usesVariables(false) |
46 { | 47 { |
47 } | 48 } |
48 | 49 |
49 void TreeScopeStyleSheetCollection::addStyleSheetCandidateNode(Node* node, bool
createdByParser) | 50 void TreeScopeStyleSheetCollection::addStyleSheetCandidateNode(Node* node, bool
createdByParser) |
50 { | 51 { |
51 if (!node->inDocument()) | 52 if (!node->inDocument()) |
52 return; | 53 return; |
53 | 54 |
54 // Until the <body> exists, we have no choice but to compare document positi
ons, | 55 // Until the <body> exists, we have no choice but to compare document positi
ons, |
55 // since styles outside of the body and head continue to be shunted into the
head | 56 // since styles outside of the body and head continue to be shunted into the
head |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 170 |
170 void TreeScopeStyleSheetCollection::clearMediaQueryRuleSetStyleSheets() | 171 void TreeScopeStyleSheetCollection::clearMediaQueryRuleSetStyleSheets() |
171 { | 172 { |
172 for (size_t i = 0; i < m_activeAuthorStyleSheets.size(); ++i) { | 173 for (size_t i = 0; i < m_activeAuthorStyleSheets.size(); ++i) { |
173 StyleSheetContents* contents = m_activeAuthorStyleSheets[i]->contents(); | 174 StyleSheetContents* contents = m_activeAuthorStyleSheets[i]->contents(); |
174 if (contents->hasMediaQueries()) | 175 if (contents->hasMediaQueries()) |
175 contents->clearRuleSet(); | 176 contents->clearRuleSet(); |
176 } | 177 } |
177 } | 178 } |
178 | 179 |
179 static bool styleSheetsUseRemUnits(const WillBeHeapVector<RefPtrWillBeMember<CSS
StyleSheet>>& sheets) | 180 void TreeScopeStyleSheetCollection::updateUsesRemUnitsAndVariables() |
180 { | 181 { |
181 for (unsigned i = 0; i < sheets.size(); ++i) { | 182 m_usesRemUnits = m_usesVariables = false; |
182 if (sheets[i]->contents()->usesRemUnits()) | 183 unsigned numberOfStylesheets = m_activeAuthorStyleSheets.size(); |
183 return true; | 184 for (unsigned i = 0; i < numberOfStylesheets; ++i) { |
| 185 StyleSheetContents* contents = m_activeAuthorStyleSheets[i]->contents(); |
| 186 if (contents->usesRemUnits()) |
| 187 m_usesRemUnits = true; |
| 188 if (contents->usesVariables()) { |
| 189 ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled()); |
| 190 m_usesVariables = true; |
| 191 } |
184 } | 192 } |
185 return false; | |
186 } | |
187 | |
188 void TreeScopeStyleSheetCollection::updateUsesRemUnits() | |
189 { | |
190 m_usesRemUnits = styleSheetsUseRemUnits(m_activeAuthorStyleSheets); | |
191 } | 193 } |
192 | 194 |
193 DEFINE_TRACE(TreeScopeStyleSheetCollection) | 195 DEFINE_TRACE(TreeScopeStyleSheetCollection) |
194 { | 196 { |
195 visitor->trace(m_treeScope); | 197 visitor->trace(m_treeScope); |
196 visitor->trace(m_styleSheetCandidateNodes); | 198 visitor->trace(m_styleSheetCandidateNodes); |
197 StyleSheetCollection::trace(visitor); | 199 StyleSheetCollection::trace(visitor); |
198 } | 200 } |
199 | 201 |
200 } | 202 } |
OLD | NEW |