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

Side by Side Diff: Source/core/page/PageScaleConstraintsSet.cpp

Issue 19555002: Translate viewport related meta tags into @viewport descriptors as suggested by the CSS Device Adap… (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 , m_constraintsDirty(false) 42 , m_constraintsDirty(false)
43 { 43 {
44 m_finalConstraints = defaultConstraints(); 44 m_finalConstraints = defaultConstraints();
45 } 45 }
46 46
47 PageScaleConstraints PageScaleConstraintsSet::defaultConstraints() const 47 PageScaleConstraints PageScaleConstraintsSet::defaultConstraints() const
48 { 48 {
49 return PageScaleConstraints(-1, defaultMinimumScale, defaultMaximumScale); 49 return PageScaleConstraints(-1, defaultMinimumScale, defaultMaximumScale);
50 } 50 }
51 51
52 void PageScaleConstraintsSet::updatePageDefinedConstraints(const ViewportArgumen ts& arguments, IntSize viewSize, int layoutFallbackWidth) 52 void PageScaleConstraintsSet::updatePageDefinedConstraints(const ViewportArgumen ts& arguments, IntSize viewSize)
53 { 53 {
54 m_pageDefinedConstraints = arguments.resolve(viewSize, layoutFallbackWidth); 54 m_pageDefinedConstraints = arguments.resolve(viewSize);
55 55
56 m_constraintsDirty = true; 56 m_constraintsDirty = true;
57 } 57 }
58 58
59 void PageScaleConstraintsSet::setUserAgentConstraints(const PageScaleConstraints & userAgentConstraints) 59 void PageScaleConstraintsSet::setUserAgentConstraints(const PageScaleConstraints & userAgentConstraints)
60 { 60 {
61 m_userAgentConstraints = userAgentConstraints; 61 m_userAgentConstraints = userAgentConstraints;
62 m_constraintsDirty = true; 62 m_constraintsDirty = true;
63 } 63 }
64 64
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 return targetDPI > 0 ? 160.0f / targetDPI : 1.0f; 114 return targetDPI > 0 ? 160.0f / targetDPI : 1.0f;
115 } 115 }
116 116
117 static float getLayoutWidthForNonWideViewport(const FloatSize& deviceSize, float initialScale) 117 static float getLayoutWidthForNonWideViewport(const FloatSize& deviceSize, float initialScale)
118 { 118 {
119 return initialScale == -1 ? deviceSize.width() : deviceSize.width() / initia lScale; 119 return initialScale == -1 ? deviceSize.width() : deviceSize.width() / initia lScale;
120 } 120 }
121 121
122 void PageScaleConstraintsSet::adjustPageDefinedConstraintsForAndroidWebView(cons t ViewportArguments& arguments, IntSize viewSize, int layoutFallbackWidth, float deviceScaleFactor, bool useWideViewport, bool loadWithOverviewMode) 122 void PageScaleConstraintsSet::adjustPageDefinedConstraintsForAndroidWebView(cons t ViewportArguments& arguments, IntSize viewSize, int layoutFallbackWidth, float deviceScaleFactor, bool useWideViewport, bool loadWithOverviewMode)
123 { 123 {
124 float initialScale = m_pageDefinedConstraints.initialScale; 124 float zoom = m_pageDefinedConstraints.initialScale;
125 if (arguments.zoom == -1 && !loadWithOverviewMode) { 125 if (zoom < 0 && !loadWithOverviewMode) {
126 if (arguments.width == -1 || (useWideViewport && arguments.width != View portArguments::ValueDeviceWidth)) 126 if (arguments.minWidth < 0 || useWideViewport)
127 m_pageDefinedConstraints.initialScale = 1.0f; 127 m_pageDefinedConstraints.initialScale = 1.0f;
128 } 128 }
129 129
130 float targetDensityDPIFactor = computeDeprecatedTargetDensityDPIFactor(argum ents, deviceScaleFactor); 130 float targetDensityDPIFactor = computeDeprecatedTargetDensityDPIFactor(argum ents, deviceScaleFactor);
131 if (m_pageDefinedConstraints.initialScale != -1) 131 if (m_pageDefinedConstraints.initialScale != -1)
132 m_pageDefinedConstraints.initialScale *= targetDensityDPIFactor; 132 m_pageDefinedConstraints.initialScale *= targetDensityDPIFactor;
133 m_pageDefinedConstraints.minimumScale *= targetDensityDPIFactor; 133 m_pageDefinedConstraints.minimumScale *= targetDensityDPIFactor;
134 m_pageDefinedConstraints.maximumScale *= targetDensityDPIFactor; 134 m_pageDefinedConstraints.maximumScale *= targetDensityDPIFactor;
135 135
136 float adjustedLayoutSizeWidth = m_pageDefinedConstraints.layoutSize.width(); 136 float adjustedLayoutSizeWidth = m_pageDefinedConstraints.layoutSize.width();
137 if (useWideViewport && arguments.width == -1 && arguments.zoom != 1.0f) 137
138 if (!useWideViewport)
139 adjustedLayoutSizeWidth = getLayoutWidthForNonWideViewport(viewSize, zoo m);
140
141 adjustedLayoutSizeWidth /= targetDensityDPIFactor;
142
143 // FIXME: Why this particular Android behavior?
144 //
145 // <meta name="viewport" content="initial-scale=2.0"> translates into:
146 // @viewport { zoom: 2.0; width: extend-to-zoom; } according to the spec.
aelias_OOO_until_Jul13 2013/08/27 16:58:09 We've observed that classic Android WebView does n
147 //
148 // But Android seems to convert the width into 'auto';
149 if (useWideViewport && arguments.maxWidth < 0 && arguments.zoom != 1.0f)
138 adjustedLayoutSizeWidth = layoutFallbackWidth; 150 adjustedLayoutSizeWidth = layoutFallbackWidth;
139 else {
140 if (!useWideViewport)
141 adjustedLayoutSizeWidth = getLayoutWidthForNonWideViewport(viewSize, initialScale);
142 if (!useWideViewport || arguments.width == -1 || arguments.width == View portArguments::ValueDeviceWidth)
143 adjustedLayoutSizeWidth /= targetDensityDPIFactor;
144 }
145 151
146 ASSERT(m_pageDefinedConstraints.layoutSize.width() > 0); 152 ASSERT(m_pageDefinedConstraints.layoutSize.width() > 0);
147 float adjustedLayoutSizeHeight = (adjustedLayoutSizeWidth * m_pageDefinedCon straints.layoutSize.height()) / m_pageDefinedConstraints.layoutSize.width(); 153 float adjustedLayoutSizeHeight = (adjustedLayoutSizeWidth * m_pageDefinedCon straints.layoutSize.height()) / m_pageDefinedConstraints.layoutSize.width();
154
148 m_pageDefinedConstraints.layoutSize.setWidth(adjustedLayoutSizeWidth); 155 m_pageDefinedConstraints.layoutSize.setWidth(adjustedLayoutSizeWidth);
149 m_pageDefinedConstraints.layoutSize.setHeight(adjustedLayoutSizeHeight); 156 m_pageDefinedConstraints.layoutSize.setHeight(adjustedLayoutSizeHeight);
150 } 157 }
151 158
152 } // namespace WebCore 159 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698