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 13 matching lines...) Expand all Loading... | |
24 * along with this library; see the file COPYING.LIB. If not, write to | 24 * along with this library; see the file COPYING.LIB. If not, write to |
25 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 25 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
26 * Boston, MA 02110-1301, USA. | 26 * Boston, MA 02110-1301, USA. |
27 */ | 27 */ |
28 | 28 |
29 #include "config.h" | 29 #include "config.h" |
30 #include "core/css/resolver/StyleResolver.h" | 30 #include "core/css/resolver/StyleResolver.h" |
31 | 31 |
32 #include "core/CSSPropertyNames.h" | 32 #include "core/CSSPropertyNames.h" |
33 #include "core/HTMLNames.h" | 33 #include "core/HTMLNames.h" |
34 #include "core/MediaTypeNames.h" | |
34 #include "core/StylePropertyShorthand.h" | 35 #include "core/StylePropertyShorthand.h" |
35 #include "core/animation/ActiveAnimations.h" | 36 #include "core/animation/ActiveAnimations.h" |
36 #include "core/animation/Animation.h" | 37 #include "core/animation/Animation.h" |
37 #include "core/animation/AnimationTimeline.h" | 38 #include "core/animation/AnimationTimeline.h" |
38 #include "core/animation/StyleInterpolation.h" | 39 #include "core/animation/StyleInterpolation.h" |
39 #include "core/animation/animatable/AnimatableValue.h" | 40 #include "core/animation/animatable/AnimatableValue.h" |
40 #include "core/animation/css/CSSAnimatableValueFactory.h" | 41 #include "core/animation/css/CSSAnimatableValueFactory.h" |
41 #include "core/animation/css/CSSAnimations.h" | 42 #include "core/animation/css/CSSAnimations.h" |
42 #include "core/css/CSSCalculationValue.h" | 43 #include "core/css/CSSCalculationValue.h" |
43 #include "core/css/CSSDefaultStyleSheets.h" | 44 #include "core/css/CSSDefaultStyleSheets.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 { | 126 { |
126 RefPtrWillBeRawPtr<FontFace> fontFace = FontFace::create(document, fontFaceR ule); | 127 RefPtrWillBeRawPtr<FontFace> fontFace = FontFace::create(document, fontFaceR ule); |
127 if (fontFace) | 128 if (fontFace) |
128 cssFontSelector->fontFaceCache()->add(cssFontSelector, fontFaceRule, fon tFace); | 129 cssFontSelector->fontFaceCache()->add(cssFontSelector, fontFaceRule, fon tFace); |
129 } | 130 } |
130 | 131 |
131 StyleResolver::StyleResolver(Document& document) | 132 StyleResolver::StyleResolver(Document& document) |
132 : m_document(document) | 133 : m_document(document) |
133 , m_viewportStyleResolver(ViewportStyleResolver::create(&document)) | 134 , m_viewportStyleResolver(ViewportStyleResolver::create(&document)) |
134 , m_needCollectFeatures(false) | 135 , m_needCollectFeatures(false) |
136 , m_printMediaType(false) | |
135 , m_styleResourceLoader(document.fetcher()) | 137 , m_styleResourceLoader(document.fetcher()) |
136 , m_styleSharingDepth(0) | 138 , m_styleSharingDepth(0) |
137 , m_styleResolverStatsSequence(0) | 139 , m_styleResolverStatsSequence(0) |
138 , m_accessCount(0) | 140 , m_accessCount(0) |
139 { | 141 { |
140 FrameView* view = document.view(); | 142 FrameView* view = document.view(); |
141 if (view) | 143 if (view) { |
142 m_medium = adoptPtr(new MediaQueryEvaluator(&view->frame())); | 144 m_medium = adoptPtr(new MediaQueryEvaluator(&view->frame())); |
143 else | 145 m_printMediaType = equalIgnoringCase(view->mediaType(), MediaTypeNames:: print); |
esprehn
2014/08/11 20:33:21
Do we destroy the StyleResolver when the media typ
| |
146 } else { | |
144 m_medium = adoptPtr(new MediaQueryEvaluator("all")); | 147 m_medium = adoptPtr(new MediaQueryEvaluator("all")); |
148 } | |
145 | 149 |
146 initWatchedSelectorRules(CSSSelectorWatch::from(document).watchedCallbackSel ectors()); | 150 initWatchedSelectorRules(CSSSelectorWatch::from(document).watchedCallbackSel ectors()); |
147 | 151 |
148 #if ENABLE(SVG_FONTS) | 152 #if ENABLE(SVG_FONTS) |
149 if (document.svgExtensions()) { | 153 if (document.svgExtensions()) { |
150 const WillBeHeapHashSet<RawPtrWillBeMember<SVGFontFaceElement> >& svgFon tFaceElements = document.svgExtensions()->svgFontFaceElements(); | 154 const WillBeHeapHashSet<RawPtrWillBeMember<SVGFontFaceElement> >& svgFon tFaceElements = document.svgExtensions()->svgFontFaceElements(); |
151 WillBeHeapHashSet<RawPtrWillBeMember<SVGFontFaceElement> >::const_iterat or end = svgFontFaceElements.end(); | 155 WillBeHeapHashSet<RawPtrWillBeMember<SVGFontFaceElement> >::const_iterat or end = svgFontFaceElements.end(); |
152 for (WillBeHeapHashSet<RawPtrWillBeMember<SVGFontFaceElement> >::const_i terator it = svgFontFaceElements.begin(); it != end; ++it) | 156 for (WillBeHeapHashSet<RawPtrWillBeMember<SVGFontFaceElement> >::const_i terator it = svgFontFaceElements.begin(); it != end; ++it) |
153 addFontFaceRule(&document, document.styleEngine()->fontSelector(), ( *it)->fontFaceRule()); | 157 addFontFaceRule(&document, document.styleEngine()->fontSelector(), ( *it)->fontFaceRule()); |
154 } | 158 } |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
449 collector.collectMatchingRules(matchRequest, ruleRange); | 453 collector.collectMatchingRules(matchRequest, ruleRange); |
450 | 454 |
451 collector.sortAndTransferMatchedRules(); | 455 collector.sortAndTransferMatchedRules(); |
452 } | 456 } |
453 | 457 |
454 void StyleResolver::matchUARules(ElementRuleCollector& collector) | 458 void StyleResolver::matchUARules(ElementRuleCollector& collector) |
455 { | 459 { |
456 collector.setMatchingUARules(true); | 460 collector.setMatchingUARules(true); |
457 | 461 |
458 CSSDefaultStyleSheets& defaultStyleSheets = CSSDefaultStyleSheets::instance( ); | 462 CSSDefaultStyleSheets& defaultStyleSheets = CSSDefaultStyleSheets::instance( ); |
459 RuleSet* userAgentStyleSheet = m_medium->mediaTypeMatchSpecific("print") | 463 RuleSet* userAgentStyleSheet = m_printMediaType ? defaultStyleSheets.default PrintStyle() : defaultStyleSheets.defaultStyle(); |
460 ? defaultStyleSheets.defaultPrintStyle() : defaultStyleSheets.defaultSty le(); | |
461 matchUARules(collector, userAgentStyleSheet); | 464 matchUARules(collector, userAgentStyleSheet); |
462 | 465 |
463 // In quirks mode, we match rules from the quirks user agent sheet. | 466 // In quirks mode, we match rules from the quirks user agent sheet. |
464 if (document().inQuirksMode()) | 467 if (document().inQuirksMode()) |
465 matchUARules(collector, defaultStyleSheets.defaultQuirksStyle()); | 468 matchUARules(collector, defaultStyleSheets.defaultQuirksStyle()); |
466 | 469 |
467 // If document uses view source styles (in view source mode or in xml viewer mode), then we match rules from the view source style sheet. | 470 // If document uses view source styles (in view source mode or in xml viewer mode), then we match rules from the view source style sheet. |
468 if (document().isViewSource()) | 471 if (document().isViewSource()) |
469 matchUARules(collector, defaultStyleSheets.defaultViewSourceStyle()); | 472 matchUARules(collector, defaultStyleSheets.defaultViewSourceStyle()); |
470 | 473 |
(...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1600 visitor->trace(m_uncommonAttributeRuleSet); | 1603 visitor->trace(m_uncommonAttributeRuleSet); |
1601 visitor->trace(m_watchedSelectorsRules); | 1604 visitor->trace(m_watchedSelectorsRules); |
1602 visitor->trace(m_treeBoundaryCrossingRules); | 1605 visitor->trace(m_treeBoundaryCrossingRules); |
1603 visitor->trace(m_styleSharingLists); | 1606 visitor->trace(m_styleSharingLists); |
1604 visitor->trace(m_pendingStyleSheets); | 1607 visitor->trace(m_pendingStyleSheets); |
1605 visitor->trace(m_document); | 1608 visitor->trace(m_document); |
1606 #endif | 1609 #endif |
1607 } | 1610 } |
1608 | 1611 |
1609 } // namespace blink | 1612 } // namespace blink |
OLD | NEW |