| OLD | NEW |
| 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 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 namespace blink { | 40 namespace blink { |
| 41 | 41 |
| 42 ScopedStyleResolver::ScopedStyleResolver(TreeScope& scope) | 42 ScopedStyleResolver::ScopedStyleResolver(TreeScope& scope) |
| 43 : m_scope(scope) | 43 : m_scope(scope) |
| 44 { | 44 { |
| 45 } | 45 } |
| 46 | 46 |
| 47 void ScopedStyleResolver::appendStyleSheet(CSSStyleSheet& sheet) | 47 void ScopedStyleResolver::appendStyleSheet(CSSStyleSheet& sheet) |
| 48 { | 48 { |
| 49 Document& document = m_scope.document(); | 49 MediaQueryEvaluator medium(m_scope.document().view()); |
| 50 StyleResolver& styleResolver = document.styleResolver(); | |
| 51 MediaQueryEvaluator& medium = styleResolver.medium(); | |
| 52 | 50 |
| 53 if (sheet.mediaQueries() && !medium.eval(sheet.mediaQueries(), &m_viewportDe
pendentMediaQueryResults)) | 51 if (sheet.mediaQueries() && !medium.eval(sheet.mediaQueries())) |
| 54 return; | 52 return; |
| 55 | 53 |
| 56 styleResolver.addMediaQueryAffectedByViewportChange(m_viewportDependentMedia
QueryResults); | |
| 57 | |
| 58 const RuleSet& ruleSet = sheet.contents()->ensureRuleSet(); | 54 const RuleSet& ruleSet = sheet.contents()->ensureRuleSet(); |
| 59 m_features.add(ruleSet.features()); | 55 m_features.add(ruleSet.features()); |
| 60 } | 56 } |
| 61 | 57 |
| 62 void ScopedStyleResolver::updateActiveStyleSheets() | 58 void ScopedStyleResolver::updateActiveStyleSheets() |
| 63 { | 59 { |
| 64 Vector<RefPtr<CSSStyleSheet>> candidateSheets; | 60 Vector<RefPtr<CSSStyleSheet>> candidateSheets; |
| 65 collectStyleSheets(candidateSheets); | 61 collectStyleSheets(candidateSheets); |
| 66 m_authorStyleSheets.swap(candidateSheets); | 62 m_authorStyleSheets.swap(candidateSheets); |
| 67 | 63 |
| 68 Node& root = m_scope.rootNode(); | 64 Node& root = m_scope.rootNode(); |
| 69 | 65 |
| 70 // TODO(esprehn): We should avoid subtree recalcs in sky when rules change | 66 // TODO(esprehn): We should avoid subtree recalcs in sky when rules change |
| 71 // and only recalc specific tree scopes. | 67 // and only recalc specific tree scopes. |
| 72 root.setNeedsStyleRecalc(SubtreeStyleChange); | 68 root.setNeedsStyleRecalc(SubtreeStyleChange); |
| 73 | 69 |
| 74 // TODO(esprehn): We should use LocalStyleChange, :host rule changes | 70 // TODO(esprehn): We should use LocalStyleChange, :host rule changes |
| 75 // can only impact the host directly as Sky has no descendant selectors. | 71 // can only impact the host directly as Sky has no descendant selectors. |
| 76 if (root.isShadowRoot()) | 72 if (root.isShadowRoot()) |
| 77 toShadowRoot(root).host()->setNeedsStyleRecalc(SubtreeStyleChange); | 73 toShadowRoot(root).host()->setNeedsStyleRecalc(SubtreeStyleChange); |
| 78 | 74 |
| 79 m_features.clear(); | 75 m_features.clear(); |
| 80 m_viewportDependentMediaQueryResults.clear(); | |
| 81 | 76 |
| 82 for (RefPtr<CSSStyleSheet>& sheet : m_authorStyleSheets) | 77 for (RefPtr<CSSStyleSheet>& sheet : m_authorStyleSheets) |
| 83 appendStyleSheet(*sheet); | 78 appendStyleSheet(*sheet); |
| 84 } | 79 } |
| 85 | 80 |
| 86 const MediaQueryResultList& ScopedStyleResolver::viewportDependentMediaQueryResu
lts() const | |
| 87 { | |
| 88 return m_viewportDependentMediaQueryResults; | |
| 89 } | |
| 90 | |
| 91 void ScopedStyleResolver::addStyleSheetCandidateNode(HTMLStyleElement& element) | 81 void ScopedStyleResolver::addStyleSheetCandidateNode(HTMLStyleElement& element) |
| 92 { | 82 { |
| 93 ASSERT(element.inActiveDocument()); | 83 ASSERT(element.inActiveDocument()); |
| 94 m_styleSheetCandidateNodes.add(&element); | 84 m_styleSheetCandidateNodes.add(&element); |
| 95 } | 85 } |
| 96 | 86 |
| 97 void ScopedStyleResolver::removeStyleSheetCandidateNode(HTMLStyleElement& elemen
t) | 87 void ScopedStyleResolver::removeStyleSheetCandidateNode(HTMLStyleElement& elemen
t) |
| 98 { | 88 { |
| 99 m_styleSheetCandidateNodes.remove(&element); | 89 m_styleSheetCandidateNodes.remove(&element); |
| 100 } | 90 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 void ScopedStyleResolver::collectMatchingHostRules(ElementRuleCollector& collect
or, CascadeOrder cascadeOrder) | 122 void ScopedStyleResolver::collectMatchingHostRules(ElementRuleCollector& collect
or, CascadeOrder cascadeOrder) |
| 133 { | 123 { |
| 134 RuleRange ruleRange = collector.matchedResult().ranges.authorRuleRange(); | 124 RuleRange ruleRange = collector.matchedResult().ranges.authorRuleRange(); |
| 135 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) { | 125 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) { |
| 136 MatchRequest matchRequest(&m_authorStyleSheets[i]->contents()->ruleSet()
, m_authorStyleSheets[i].get(), i); | 126 MatchRequest matchRequest(&m_authorStyleSheets[i]->contents()->ruleSet()
, m_authorStyleSheets[i].get(), i); |
| 137 collector.collectMatchingHostRules(matchRequest, ruleRange, cascadeOrder
); | 127 collector.collectMatchingHostRules(matchRequest, ruleRange, cascadeOrder
); |
| 138 } | 128 } |
| 139 } | 129 } |
| 140 | 130 |
| 141 } // namespace blink | 131 } // namespace blink |
| OLD | NEW |