Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: Source/core/css/resolver/ViewportStyleResolver.cpp

Issue 979033003: Move code from StyleResolver to ViewportStyleResolver. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/css/resolver/ViewportStyleResolver.h ('k') | Source/core/frame/Settings.in » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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/frame/Settings.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 bool useMobileViewportStyle = m_document->settings() && m_document->settings ()->useMobileViewportStyle();
63 #if OS(ANDROID)
64 // FIXME: Remove when useMobileViewportStyle is set from chromium.
65 useMobileViewportStyle = true;
66 #endif
67 if (useMobileViewportStyle)
68 collectViewportRules(defaultStyleSheets.defaultMobileViewportStyle(), Us erAgentOrigin);
69
70 if (m_document->isMobileDocument())
71 collectViewportRules(defaultStyleSheets.defaultXHTMLMobileProfileStyle() , UserAgentOrigin);
72
73 if (ScopedStyleResolver* scopedResolver = m_document->scopedStyleResolver())
74 scopedResolver->collectViewportRulesTo(this);
75
76 resolve();
77 }
78
54 void ViewportStyleResolver::collectViewportRules(RuleSet* rules, Origin origin) 79 void ViewportStyleResolver::collectViewportRules(RuleSet* rules, Origin origin)
55 { 80 {
56 rules->compactRulesIfNeeded(); 81 rules->compactRulesIfNeeded();
57 82
58 const WillBeHeapVector<RawPtrWillBeMember<StyleRuleViewport>>& viewportRules = rules->viewportRules(); 83 const WillBeHeapVector<RawPtrWillBeMember<StyleRuleViewport>>& viewportRules = rules->viewportRules();
59 for (size_t i = 0; i < viewportRules.size(); ++i) 84 for (size_t i = 0; i < viewportRules.size(); ++i)
60 addViewportRule(viewportRules[i], origin); 85 addViewportRule(viewportRules[i], origin);
61 } 86 }
62 87
63 void ViewportStyleResolver::addViewportRule(StyleRuleViewport* viewportRule, Ori gin origin) 88 void ViewportStyleResolver::addViewportRule(StyleRuleViewport* viewportRule, Ori gin origin)
(...skipping 13 matching lines...) Expand all
77 } 102 }
78 103
79 // We cannot use mergeAndOverrideOnConflict() here because it doesn't 104 // We cannot use mergeAndOverrideOnConflict() here because it doesn't
80 // respect the !important declaration (but addParsedProperty() does). 105 // respect the !important declaration (but addParsedProperty() does).
81 for (unsigned i = 0; i < propertyCount; ++i) 106 for (unsigned i = 0; i < propertyCount; ++i)
82 m_propertySet->addParsedProperty(propertySet.propertyAt(i).toCSSProperty ()); 107 m_propertySet->addParsedProperty(propertySet.propertyAt(i).toCSSProperty ());
83 } 108 }
84 109
85 void ViewportStyleResolver::resolve() 110 void ViewportStyleResolver::resolve()
86 { 111 {
87 if (!m_document)
88 return;
89
90 if (!m_propertySet) { 112 if (!m_propertySet) {
91 m_document->setViewportDescription(ViewportDescription(ViewportDescripti on::UserAgentStyleSheet)); 113 m_document->setViewportDescription(ViewportDescription(ViewportDescripti on::UserAgentStyleSheet));
92 return; 114 return;
93 } 115 }
94 116
95 ViewportDescription description(m_hasAuthorStyle ? ViewportDescription::Auth orStyleSheet : ViewportDescription::UserAgentStyleSheet); 117 ViewportDescription description(m_hasAuthorStyle ? ViewportDescription::Auth orStyleSheet : ViewportDescription::UserAgentStyleSheet);
96 118
97 description.userZoom = viewportArgumentValue(CSSPropertyUserZoom); 119 description.userZoom = viewportArgumentValue(CSSPropertyUserZoom);
98 description.zoom = viewportArgumentValue(CSSPropertyZoom); 120 description.zoom = viewportArgumentValue(CSSPropertyZoom);
99 description.minZoom = viewportArgumentValue(CSSPropertyMinZoom); 121 description.minZoom = viewportArgumentValue(CSSPropertyMinZoom);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 return result; 225 return result;
204 } 226 }
205 227
206 DEFINE_TRACE(ViewportStyleResolver) 228 DEFINE_TRACE(ViewportStyleResolver)
207 { 229 {
208 visitor->trace(m_propertySet); 230 visitor->trace(m_propertySet);
209 visitor->trace(m_document); 231 visitor->trace(m_document);
210 } 232 }
211 233
212 } // namespace blink 234 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/resolver/ViewportStyleResolver.h ('k') | Source/core/frame/Settings.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698