| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) |
| 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) | 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) |
| 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
All rights reserved. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
All rights reserved. |
| 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
| 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
| 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
| 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. | 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
| 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 ruleSet = RuleSet::create(); | 119 ruleSet = RuleSet::create(); |
| 120 ruleSet->addRulesFromSheet(styleSheet.get()); | 120 ruleSet->addRulesFromSheet(styleSheet.get()); |
| 121 | 121 |
| 122 return *ruleSet; | 122 return *ruleSet; |
| 123 } | 123 } |
| 124 | 124 |
| 125 StyleResolver::StyleResolver(Document& document) | 125 StyleResolver::StyleResolver(Document& document) |
| 126 : m_document(document) | 126 : m_document(document) |
| 127 , m_printMediaType(false) | 127 , m_printMediaType(false) |
| 128 , m_styleResourceLoader(document.fetcher()) | 128 , m_styleResourceLoader(document.fetcher()) |
| 129 , m_styleSharingDepth(0) | |
| 130 , m_styleResolverStatsSequence(0) | 129 , m_styleResolverStatsSequence(0) |
| 131 , m_accessCount(0) | 130 , m_accessCount(0) |
| 132 { | 131 { |
| 133 FrameView* view = document.view(); | 132 FrameView* view = document.view(); |
| 134 if (view) { | 133 if (view) { |
| 135 m_medium = adoptPtr(new MediaQueryEvaluator(&view->frame())); | 134 m_medium = adoptPtr(new MediaQueryEvaluator(&view->frame())); |
| 136 m_printMediaType = equalIgnoringCase(view->mediaType(), MediaTypeNames::
print); | 135 m_printMediaType = equalIgnoringCase(view->mediaType(), MediaTypeNames::
print); |
| 137 } else { | 136 } else { |
| 138 m_medium = adoptPtr(new MediaQueryEvaluator("all")); | 137 m_medium = adoptPtr(new MediaQueryEvaluator("all")); |
| 139 } | 138 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 if (!document().inStyleRecalc()) | 209 if (!document().inStyleRecalc()) |
| 211 return; | 210 return; |
| 212 ASSERT(element.supportsStyleSharing()); | 211 ASSERT(element.supportsStyleSharing()); |
| 213 INCREMENT_STYLE_STATS_COUNTER(*this, sharedStyleCandidates); | 212 INCREMENT_STYLE_STATS_COUNTER(*this, sharedStyleCandidates); |
| 214 StyleSharingList& list = styleSharingList(); | 213 StyleSharingList& list = styleSharingList(); |
| 215 if (list.size() >= styleSharingListSize) | 214 if (list.size() >= styleSharingListSize) |
| 216 list.removeLast(); | 215 list.removeLast(); |
| 217 list.prepend(&element); | 216 list.prepend(&element); |
| 218 } | 217 } |
| 219 | 218 |
| 220 StyleSharingList& StyleResolver::styleSharingList() | |
| 221 { | |
| 222 m_styleSharingLists.resize(styleSharingMaxDepth); | |
| 223 | |
| 224 // We never put things at depth 0 into the list since that's only the <html>
element | |
| 225 // and it has no siblings or cousins to share with. | |
| 226 unsigned depth = std::max(std::min(m_styleSharingDepth, styleSharingMaxDepth
), 1u) - 1u; | |
| 227 | |
| 228 if (!m_styleSharingLists[depth]) | |
| 229 m_styleSharingLists[depth] = adoptPtr(new StyleSharingList); | |
| 230 return *m_styleSharingLists[depth]; | |
| 231 } | |
| 232 | |
| 233 void StyleResolver::clearStyleSharingList() | 219 void StyleResolver::clearStyleSharingList() |
| 234 { | 220 { |
| 235 m_styleSharingLists.resize(0); | 221 m_styleSharingList.clear(); |
| 236 } | 222 } |
| 237 | 223 |
| 238 StyleResolver::~StyleResolver() | 224 StyleResolver::~StyleResolver() |
| 239 { | 225 { |
| 240 } | 226 } |
| 241 | 227 |
| 242 void StyleResolver::matchAuthorRules(Element* element, ElementRuleCollector& col
lector) | 228 void StyleResolver::matchAuthorRules(Element* element, ElementRuleCollector& col
lector) |
| 243 { | 229 { |
| 244 collector.clearMatchedRules(); | 230 collector.clearMatchedRules(); |
| 245 collector.matchedResult().ranges.lastAuthorRule = collector.matchedResult().
matchedProperties.size() - 1; | 231 collector.matchedResult().ranges.lastAuthorRule = collector.matchedResult().
matchedProperties.size() - 1; |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 bool StyleResolver::mediaQueryAffectedByViewportChange() const | 795 bool StyleResolver::mediaQueryAffectedByViewportChange() const |
| 810 { | 796 { |
| 811 for (unsigned i = 0; i < m_viewportDependentMediaQueryResults.size(); ++i) { | 797 for (unsigned i = 0; i < m_viewportDependentMediaQueryResults.size(); ++i) { |
| 812 if (m_medium->eval(m_viewportDependentMediaQueryResults[i]->expression()
) != m_viewportDependentMediaQueryResults[i]->result()) | 798 if (m_medium->eval(m_viewportDependentMediaQueryResults[i]->expression()
) != m_viewportDependentMediaQueryResults[i]->result()) |
| 813 return true; | 799 return true; |
| 814 } | 800 } |
| 815 return false; | 801 return false; |
| 816 } | 802 } |
| 817 | 803 |
| 818 } // namespace blink | 804 } // namespace blink |
| OLD | NEW |