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

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: Removed stray method declaration 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
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"
45 #include "core/inspector/InspectorInstrumentation.h"
dgozman 2015/03/08 06:32:11 Not used anymore.
rune 2015/03/08 19:15:26 Done.
42 46
43 namespace blink { 47 namespace blink {
44 48
45 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(ViewportStyleResolver); 49 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(ViewportStyleResolver);
46 50
47 ViewportStyleResolver::ViewportStyleResolver(Document* document) 51 ViewportStyleResolver::ViewportStyleResolver(Document* document)
48 : m_document(document) 52 : m_document(document)
49 , m_hasAuthorStyle(false) 53 , m_hasAuthorStyle(false)
50 { 54 {
51 ASSERT(m_document); 55 ASSERT(m_document);
52 } 56 }
53 57
58 void ViewportStyleResolver::collectViewportRules()
59 {
60 CSSDefaultStyleSheets& defaultStyleSheets = CSSDefaultStyleSheets::instance( );
61 collectViewportRules(defaultStyleSheets.defaultStyle(), UserAgentOrigin);
62
63 bool useMobileViewportStyle = m_document->settings() && m_document->settings ()->useMobileViewportStyle();
64 #if OS(ANDROID)
65 // FIXME: Remove when useMobileViewportStyle is set from chromium.
66 useMobileViewportStyle = true;
67 #endif
68 if (useMobileViewportStyle)
69 collectViewportRules(defaultStyleSheets.defaultMobileViewportStyle(), Us erAgentOrigin);
70
71 if (m_document->isMobileDocument())
72 collectViewportRules(defaultStyleSheets.defaultXHTMLMobileProfileStyle() , UserAgentOrigin);
73
74 if (ScopedStyleResolver* scopedResolver = m_document->scopedStyleResolver())
75 scopedResolver->collectViewportRulesTo(this);
76
77 resolve();
78 }
79
54 void ViewportStyleResolver::collectViewportRules(RuleSet* rules, Origin origin) 80 void ViewportStyleResolver::collectViewportRules(RuleSet* rules, Origin origin)
55 { 81 {
56 rules->compactRulesIfNeeded(); 82 rules->compactRulesIfNeeded();
57 83
58 const WillBeHeapVector<RawPtrWillBeMember<StyleRuleViewport> >& viewportRule s = rules->viewportRules(); 84 const WillBeHeapVector<RawPtrWillBeMember<StyleRuleViewport>>& viewportRules = rules->viewportRules();
59 for (size_t i = 0; i < viewportRules.size(); ++i) 85 for (size_t i = 0; i < viewportRules.size(); ++i)
60 addViewportRule(viewportRules[i], origin); 86 addViewportRule(viewportRules[i], origin);
61 } 87 }
62 88
63 void ViewportStyleResolver::addViewportRule(StyleRuleViewport* viewportRule, Ori gin origin) 89 void ViewportStyleResolver::addViewportRule(StyleRuleViewport* viewportRule, Ori gin origin)
64 { 90 {
65 StylePropertySet& propertySet = viewportRule->mutableProperties(); 91 StylePropertySet& propertySet = viewportRule->mutableProperties();
66 92
67 unsigned propertyCount = propertySet.propertyCount(); 93 unsigned propertyCount = propertySet.propertyCount();
68 if (!propertyCount) 94 if (!propertyCount)
69 return; 95 return;
70 96
71 if (origin == AuthorOrigin) 97 if (origin == AuthorOrigin)
72 m_hasAuthorStyle = true; 98 m_hasAuthorStyle = true;
73 99
74 if (!m_propertySet) { 100 if (!m_propertySet) {
75 m_propertySet = propertySet.mutableCopy(); 101 m_propertySet = propertySet.mutableCopy();
76 return; 102 return;
77 } 103 }
78 104
79 // We cannot use mergeAndOverrideOnConflict() here because it doesn't 105 // We cannot use mergeAndOverrideOnConflict() here because it doesn't
80 // respect the !important declaration (but addParsedProperty() does). 106 // respect the !important declaration (but addParsedProperty() does).
81 for (unsigned i = 0; i < propertyCount; ++i) 107 for (unsigned i = 0; i < propertyCount; ++i)
82 m_propertySet->addParsedProperty(propertySet.propertyAt(i).toCSSProperty ()); 108 m_propertySet->addParsedProperty(propertySet.propertyAt(i).toCSSProperty ());
83 } 109 }
84 110
85 void ViewportStyleResolver::resolve() 111 void ViewportStyleResolver::resolve()
86 { 112 {
87 if (!m_document)
88 return;
89
90 if (!m_propertySet) { 113 if (!m_propertySet) {
91 m_document->setViewportDescription(ViewportDescription(ViewportDescripti on::UserAgentStyleSheet)); 114 m_document->setViewportDescription(ViewportDescription(ViewportDescripti on::UserAgentStyleSheet));
92 return; 115 return;
93 } 116 }
94 117
95 ViewportDescription description(m_hasAuthorStyle ? ViewportDescription::Auth orStyleSheet : ViewportDescription::UserAgentStyleSheet); 118 ViewportDescription description(m_hasAuthorStyle ? ViewportDescription::Auth orStyleSheet : ViewportDescription::UserAgentStyleSheet);
96 119
97 description.userZoom = viewportArgumentValue(CSSPropertyUserZoom); 120 description.userZoom = viewportArgumentValue(CSSPropertyUserZoom);
98 description.zoom = viewportArgumentValue(CSSPropertyZoom); 121 description.zoom = viewportArgumentValue(CSSPropertyZoom);
99 description.minZoom = viewportArgumentValue(CSSPropertyMinZoom); 122 description.minZoom = viewportArgumentValue(CSSPropertyMinZoom);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 return result; 226 return result;
204 } 227 }
205 228
206 DEFINE_TRACE(ViewportStyleResolver) 229 DEFINE_TRACE(ViewportStyleResolver)
207 { 230 {
208 visitor->trace(m_propertySet); 231 visitor->trace(m_propertySet);
209 visitor->trace(m_document); 232 visitor->trace(m_document);
210 } 233 }
211 234
212 } // namespace blink 235 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698