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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 } | 129 } |
130 | 130 |
131 StyleResolver::StyleResolver(Document& document) | 131 StyleResolver::StyleResolver(Document& document) |
132 : m_document(document) | 132 : m_document(document) |
133 , m_viewportStyleResolver(ViewportStyleResolver::create(&document)) | 133 , m_viewportStyleResolver(ViewportStyleResolver::create(&document)) |
134 , m_needCollectFeatures(false) | 134 , m_needCollectFeatures(false) |
135 , m_styleResourceLoader(document.fetcher()) | 135 , m_styleResourceLoader(document.fetcher()) |
136 , m_styleResolverStatsSequence(0) | 136 , m_styleResolverStatsSequence(0) |
137 , m_accessCount(0) | 137 , m_accessCount(0) |
138 { | 138 { |
139 // Construct document root element default style. This is needed | |
140 // to evaluate media queries that contain relative constraints, like "screen
and (max-width: 10em)" | |
141 // This is here instead of constructor because when constructor is run, | |
142 // Document doesn't have documentElement. | |
143 // NOTE: This assumes that element that gets passed to the styleForElement c
all | |
144 // is always from the document that owns the StyleResolver. | |
145 FrameView* view = document.view(); | 139 FrameView* view = document.view(); |
146 if (view) | 140 if (view) |
147 m_medium = adoptPtr(new MediaQueryEvaluator(view->mediaType())); | 141 m_medium = adoptPtr(new MediaQueryEvaluator(view->mediaType(), &view->fr
ame())); |
148 else | 142 else |
149 m_medium = adoptPtr(new MediaQueryEvaluator("all")); | 143 m_medium = adoptPtr(new MediaQueryEvaluator("all")); |
150 | 144 |
151 Element* root = document.documentElement(); | |
152 if (root) | |
153 m_rootDefaultStyle = styleForElement(root, 0, DisallowStyleSharing, Matc
hOnlyUserAgentRules); | |
154 | |
155 if (m_rootDefaultStyle && view) | |
156 m_medium = adoptPtr(new MediaQueryEvaluator(view->mediaType(), &view->fr
ame(), m_rootDefaultStyle.get())); | |
157 | |
158 m_styleTree.clear(); | 145 m_styleTree.clear(); |
159 | 146 |
160 initWatchedSelectorRules(CSSSelectorWatch::from(document).watchedCallbackSel
ectors()); | 147 initWatchedSelectorRules(CSSSelectorWatch::from(document).watchedCallbackSel
ectors()); |
161 | 148 |
162 #if ENABLE(SVG_FONTS) | 149 #if ENABLE(SVG_FONTS) |
163 if (document.svgExtensions()) { | 150 if (document.svgExtensions()) { |
164 const HashSet<SVGFontFaceElement*>& svgFontFaceElements = document.svgEx
tensions()->svgFontFaceElements(); | 151 const HashSet<SVGFontFaceElement*>& svgFontFaceElements = document.svgEx
tensions()->svgFontFaceElements(); |
165 HashSet<SVGFontFaceElement*>::const_iterator end = svgFontFaceElements.e
nd(); | 152 HashSet<SVGFontFaceElement*>::const_iterator end = svgFontFaceElements.e
nd(); |
166 for (HashSet<SVGFontFaceElement*>::const_iterator it = svgFontFaceElemen
ts.begin(); it != end; ++it) | 153 for (HashSet<SVGFontFaceElement*>::const_iterator it = svgFontFaceElemen
ts.begin(); it != end; ++it) |
167 addFontFaceRule(&document, document.styleEngine()->fontSelector(), (
*it)->fontFaceRule()); | 154 addFontFaceRule(&document, document.styleEngine()->fontSelector(), (
*it)->fontFaceRule()); |
(...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1376 visitor->trace(m_keyframesRuleMap); | 1363 visitor->trace(m_keyframesRuleMap); |
1377 visitor->trace(m_viewportDependentMediaQueryResults); | 1364 visitor->trace(m_viewportDependentMediaQueryResults); |
1378 visitor->trace(m_viewportStyleResolver); | 1365 visitor->trace(m_viewportStyleResolver); |
1379 visitor->trace(m_siblingRuleSet); | 1366 visitor->trace(m_siblingRuleSet); |
1380 visitor->trace(m_uncommonAttributeRuleSet); | 1367 visitor->trace(m_uncommonAttributeRuleSet); |
1381 visitor->trace(m_watchedSelectorsRules); | 1368 visitor->trace(m_watchedSelectorsRules); |
1382 visitor->trace(m_treeBoundaryCrossingRules); | 1369 visitor->trace(m_treeBoundaryCrossingRules); |
1383 } | 1370 } |
1384 | 1371 |
1385 } // namespace WebCore | 1372 } // namespace WebCore |
OLD | NEW |