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

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

Issue 23742003: Use css-device-adapt constraining for legacy viewport tags. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Review issue: one assignent per line/statement Created 7 years, 3 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/page/PageScaleConstraintsSet.h ('k') | Source/core/testing/Internals.cpp » ('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) 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 , m_constraintsDirty(false) 44 , m_constraintsDirty(false)
45 { 45 {
46 m_finalConstraints = defaultConstraints(); 46 m_finalConstraints = defaultConstraints();
47 } 47 }
48 48
49 PageScaleConstraints PageScaleConstraintsSet::defaultConstraints() const 49 PageScaleConstraints PageScaleConstraintsSet::defaultConstraints() const
50 { 50 {
51 return PageScaleConstraints(-1, defaultMinimumScale, defaultMaximumScale); 51 return PageScaleConstraints(-1, defaultMinimumScale, defaultMaximumScale);
52 } 52 }
53 53
54 void PageScaleConstraintsSet::updatePageDefinedConstraints(const ViewportArgumen ts& arguments, IntSize viewSize, int layoutFallbackWidth) 54 void PageScaleConstraintsSet::updatePageDefinedConstraints(const ViewportArgumen ts& arguments, IntSize viewSize)
55 { 55 {
56 m_pageDefinedConstraints = arguments.resolve(viewSize, layoutFallbackWidth); 56 m_pageDefinedConstraints = arguments.resolve(viewSize);
57 57
58 m_constraintsDirty = true; 58 m_constraintsDirty = true;
59 } 59 }
60 60
61 void PageScaleConstraintsSet::setUserAgentConstraints(const PageScaleConstraints & userAgentConstraints) 61 void PageScaleConstraintsSet::setUserAgentConstraints(const PageScaleConstraints & userAgentConstraints)
62 { 62 {
63 m_userAgentConstraints = userAgentConstraints; 63 m_userAgentConstraints = userAgentConstraints;
64 m_constraintsDirty = true; 64 m_constraintsDirty = true;
65 } 65 }
66 66
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 118
119 static float getLayoutWidthForNonWideViewport(const FloatSize& deviceSize, float initialScale) 119 static float getLayoutWidthForNonWideViewport(const FloatSize& deviceSize, float initialScale)
120 { 120 {
121 return initialScale == -1 ? deviceSize.width() : deviceSize.width() / initia lScale; 121 return initialScale == -1 ? deviceSize.width() : deviceSize.width() / initia lScale;
122 } 122 }
123 123
124 void PageScaleConstraintsSet::adjustPageDefinedConstraintsForAndroidWebView(cons t ViewportArguments& arguments, IntSize viewSize, int layoutFallbackWidth, float deviceScaleFactor, bool useWideViewport, bool loadWithOverviewMode) 124 void PageScaleConstraintsSet::adjustPageDefinedConstraintsForAndroidWebView(cons t ViewportArguments& arguments, IntSize viewSize, int layoutFallbackWidth, float deviceScaleFactor, bool useWideViewport, bool loadWithOverviewMode)
125 { 125 {
126 float initialScale = m_pageDefinedConstraints.initialScale; 126 float initialScale = m_pageDefinedConstraints.initialScale;
127 if (arguments.zoom == -1 && !loadWithOverviewMode) { 127 if (arguments.zoom == -1 && !loadWithOverviewMode) {
128 if (arguments.width == -1 || (useWideViewport && arguments.width != View portArguments::ValueDeviceWidth)) 128 if (arguments.maxWidth.isAuto() || (useWideViewport && arguments.maxWidt h.isFixed()))
129 m_pageDefinedConstraints.initialScale = 1.0f; 129 m_pageDefinedConstraints.initialScale = 1.0f;
130 } 130 }
131 131
132 float targetDensityDPIFactor = computeDeprecatedTargetDensityDPIFactor(argum ents, deviceScaleFactor); 132 float targetDensityDPIFactor = computeDeprecatedTargetDensityDPIFactor(argum ents, deviceScaleFactor);
133 if (m_pageDefinedConstraints.initialScale != -1) 133 if (m_pageDefinedConstraints.initialScale != -1)
134 m_pageDefinedConstraints.initialScale *= targetDensityDPIFactor; 134 m_pageDefinedConstraints.initialScale *= targetDensityDPIFactor;
135 m_pageDefinedConstraints.minimumScale *= targetDensityDPIFactor; 135 m_pageDefinedConstraints.minimumScale *= targetDensityDPIFactor;
136 m_pageDefinedConstraints.maximumScale *= targetDensityDPIFactor; 136 m_pageDefinedConstraints.maximumScale *= targetDensityDPIFactor;
137 137
138 float adjustedLayoutSizeWidth = m_pageDefinedConstraints.layoutSize.width(); 138 float adjustedLayoutSizeWidth = m_pageDefinedConstraints.layoutSize.width();
139 if (useWideViewport && arguments.width == -1 && arguments.zoom != 1.0f) 139 if (useWideViewport && arguments.maxWidth.type() == ExtendToZoom && argument s.zoom != 1.0f)
140 adjustedLayoutSizeWidth = layoutFallbackWidth; 140 adjustedLayoutSizeWidth = layoutFallbackWidth;
141 else { 141 else {
142 if (!useWideViewport) 142 if (!useWideViewport)
143 adjustedLayoutSizeWidth = getLayoutWidthForNonWideViewport(viewSize, initialScale); 143 adjustedLayoutSizeWidth = getLayoutWidthForNonWideViewport(viewSize, initialScale);
144 if (!useWideViewport || arguments.width == -1 || arguments.width == View portArguments::ValueDeviceWidth) 144 if (!useWideViewport || arguments.maxWidth.type() == ExtendToZoom || arg uments.maxWidth.isViewportPercentage())
145 adjustedLayoutSizeWidth /= targetDensityDPIFactor; 145 adjustedLayoutSizeWidth /= targetDensityDPIFactor;
146 } 146 }
147 147
148 ASSERT(m_pageDefinedConstraints.layoutSize.width() > 0); 148 ASSERT(m_pageDefinedConstraints.layoutSize.width() > 0);
149 float adjustedLayoutSizeHeight = (adjustedLayoutSizeWidth * m_pageDefinedCon straints.layoutSize.height()) / m_pageDefinedConstraints.layoutSize.width(); 149 float adjustedLayoutSizeHeight = (adjustedLayoutSizeWidth * m_pageDefinedCon straints.layoutSize.height()) / m_pageDefinedConstraints.layoutSize.width();
150 m_pageDefinedConstraints.layoutSize.setWidth(adjustedLayoutSizeWidth); 150 m_pageDefinedConstraints.layoutSize.setWidth(adjustedLayoutSizeWidth);
151 m_pageDefinedConstraints.layoutSize.setHeight(adjustedLayoutSizeHeight); 151 m_pageDefinedConstraints.layoutSize.setHeight(adjustedLayoutSizeHeight);
152 } 152 }
153 153
154 } // namespace WebCore 154 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/page/PageScaleConstraintsSet.h ('k') | Source/core/testing/Internals.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698