| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012-2013 Intel Corporation. All rights reserved. | 2 * Copyright (C) 2012-2013 Intel Corporation. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above | 8 * 1. Redistributions of source code must retain the above |
| 9 * copyright notice, this list of conditions and the following | 9 * copyright notice, this list of conditions and the following |
| 10 * disclaimer. | 10 * disclaimer. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR |
| 25 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF | 25 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF |
| 26 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 26 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 27 * SUCH DAMAGE. | 27 * SUCH DAMAGE. |
| 28 */ | 28 */ |
| 29 | 29 |
| 30 #include "config.h" | 30 #include "config.h" |
| 31 #include "core/css/resolver/ViewportStyleResolver.h" | 31 #include "core/css/resolver/ViewportStyleResolver.h" |
| 32 | 32 |
| 33 #include "core/CSSValueKeywords.h" | 33 #include "core/CSSValueKeywords.h" |
| 34 #include "core/css/CSSDefaultStyleSheets.h" |
| 34 #include "core/css/CSSPrimitiveValueMappings.h" | 35 #include "core/css/CSSPrimitiveValueMappings.h" |
| 35 #include "core/css/CSSToLengthConversionData.h" | 36 #include "core/css/CSSToLengthConversionData.h" |
| 36 #include "core/css/StylePropertySet.h" | 37 #include "core/css/StylePropertySet.h" |
| 37 #include "core/css/StyleRule.h" | 38 #include "core/css/StyleRule.h" |
| 39 #include "core/css/resolver/ScopedStyleResolver.h" |
| 38 #include "core/dom/Document.h" | 40 #include "core/dom/Document.h" |
| 39 #include "core/dom/NodeLayoutStyle.h" | 41 #include "core/dom/NodeLayoutStyle.h" |
| 40 #include "core/dom/ViewportDescription.h" | 42 #include "core/dom/ViewportDescription.h" |
| 41 #include "core/frame/FrameView.h" | 43 #include "core/frame/FrameView.h" |
| 44 #include "core/inspector/InspectorInstrumentation.h" |
| 42 | 45 |
| 43 namespace blink { | 46 namespace blink { |
| 44 | 47 |
| 45 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(ViewportStyleResolver); | 48 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(ViewportStyleResolver); |
| 46 | 49 |
| 47 ViewportStyleResolver::ViewportStyleResolver(Document* document) | 50 ViewportStyleResolver::ViewportStyleResolver(Document* document) |
| 48 : m_document(document) | 51 : m_document(document) |
| 49 , m_hasAuthorStyle(false) | 52 , m_hasAuthorStyle(false) |
| 50 { | 53 { |
| 51 ASSERT(m_document); | 54 ASSERT(m_document); |
| 52 } | 55 } |
| 53 | 56 |
| 57 void ViewportStyleResolver::collectViewportRules() |
| 58 { |
| 59 CSSDefaultStyleSheets& defaultStyleSheets = CSSDefaultStyleSheets::instance(
); |
| 60 collectViewportRules(defaultStyleSheets.defaultStyle(), UserAgentOrigin); |
| 61 |
| 62 RuleSet* rules = defaultStyleSheets.defaultViewportStyle(); |
| 63 if (InspectorInstrumentation::shouldApplyViewportStyleOverride(m_document)) |
| 64 rules = defaultStyleSheets.defaultViewportOverrideStyle(); |
| 65 |
| 66 collectViewportRules(rules, UserAgentOrigin); |
| 67 |
| 68 if (m_document->isMobileDocument()) |
| 69 collectViewportRules(defaultStyleSheets.defaultXHTMLMobileProfileStyle()
, UserAgentOrigin); |
| 70 |
| 71 if (ScopedStyleResolver* scopedResolver = m_document->scopedStyleResolver()) |
| 72 scopedResolver->collectViewportRulesTo(this); |
| 73 |
| 74 resolve(); |
| 75 } |
| 76 |
| 54 void ViewportStyleResolver::collectViewportRules(RuleSet* rules, Origin origin) | 77 void ViewportStyleResolver::collectViewportRules(RuleSet* rules, Origin origin) |
| 55 { | 78 { |
| 56 rules->compactRulesIfNeeded(); | 79 rules->compactRulesIfNeeded(); |
| 57 | 80 |
| 58 const WillBeHeapVector<RawPtrWillBeMember<StyleRuleViewport> >& viewportRule
s = rules->viewportRules(); | 81 const WillBeHeapVector<RawPtrWillBeMember<StyleRuleViewport>>& viewportRules
= rules->viewportRules(); |
| 59 for (size_t i = 0; i < viewportRules.size(); ++i) | 82 for (size_t i = 0; i < viewportRules.size(); ++i) |
| 60 addViewportRule(viewportRules[i], origin); | 83 addViewportRule(viewportRules[i], origin); |
| 61 } | 84 } |
| 62 | 85 |
| 63 void ViewportStyleResolver::addViewportRule(StyleRuleViewport* viewportRule, Ori
gin origin) | 86 void ViewportStyleResolver::addViewportRule(StyleRuleViewport* viewportRule, Ori
gin origin) |
| 64 { | 87 { |
| 65 StylePropertySet& propertySet = viewportRule->mutableProperties(); | 88 StylePropertySet& propertySet = viewportRule->mutableProperties(); |
| 66 | 89 |
| 67 unsigned propertyCount = propertySet.propertyCount(); | 90 unsigned propertyCount = propertySet.propertyCount(); |
| 68 if (!propertyCount) | 91 if (!propertyCount) |
| 69 return; | 92 return; |
| 70 | 93 |
| 71 if (origin == AuthorOrigin) | 94 if (origin == AuthorOrigin) |
| 72 m_hasAuthorStyle = true; | 95 m_hasAuthorStyle = true; |
| 73 | 96 |
| 74 if (!m_propertySet) { | 97 if (!m_propertySet) { |
| 75 m_propertySet = propertySet.mutableCopy(); | 98 m_propertySet = propertySet.mutableCopy(); |
| 76 return; | 99 return; |
| 77 } | 100 } |
| 78 | 101 |
| 79 // We cannot use mergeAndOverrideOnConflict() here because it doesn't | 102 // We cannot use mergeAndOverrideOnConflict() here because it doesn't |
| 80 // respect the !important declaration (but addParsedProperty() does). | 103 // respect the !important declaration (but addParsedProperty() does). |
| 81 for (unsigned i = 0; i < propertyCount; ++i) | 104 for (unsigned i = 0; i < propertyCount; ++i) |
| 82 m_propertySet->addParsedProperty(propertySet.propertyAt(i).toCSSProperty
()); | 105 m_propertySet->addParsedProperty(propertySet.propertyAt(i).toCSSProperty
()); |
| 83 } | 106 } |
| 84 | 107 |
| 85 void ViewportStyleResolver::resolve() | 108 void ViewportStyleResolver::resolve() |
| 86 { | 109 { |
| 87 if (!m_document) | |
| 88 return; | |
| 89 | |
| 90 if (!m_propertySet) { | 110 if (!m_propertySet) { |
| 91 m_document->setViewportDescription(ViewportDescription(ViewportDescripti
on::UserAgentStyleSheet)); | 111 m_document->setViewportDescription(ViewportDescription(ViewportDescripti
on::UserAgentStyleSheet)); |
| 92 return; | 112 return; |
| 93 } | 113 } |
| 94 | 114 |
| 95 ViewportDescription description(m_hasAuthorStyle ? ViewportDescription::Auth
orStyleSheet : ViewportDescription::UserAgentStyleSheet); | 115 ViewportDescription description(m_hasAuthorStyle ? ViewportDescription::Auth
orStyleSheet : ViewportDescription::UserAgentStyleSheet); |
| 96 | 116 |
| 97 description.userZoom = viewportArgumentValue(CSSPropertyUserZoom); | 117 description.userZoom = viewportArgumentValue(CSSPropertyUserZoom); |
| 98 description.zoom = viewportArgumentValue(CSSPropertyZoom); | 118 description.zoom = viewportArgumentValue(CSSPropertyZoom); |
| 99 description.minZoom = viewportArgumentValue(CSSPropertyMinZoom); | 119 description.minZoom = viewportArgumentValue(CSSPropertyMinZoom); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 return result; | 223 return result; |
| 204 } | 224 } |
| 205 | 225 |
| 206 DEFINE_TRACE(ViewportStyleResolver) | 226 DEFINE_TRACE(ViewportStyleResolver) |
| 207 { | 227 { |
| 208 visitor->trace(m_propertySet); | 228 visitor->trace(m_propertySet); |
| 209 visitor->trace(m_document); | 229 visitor->trace(m_document); |
| 210 } | 230 } |
| 211 | 231 |
| 212 } // namespace blink | 232 } // namespace blink |
| OLD | NEW |