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

Side by Side Diff: third_party/WebKit/Source/core/frame/PageScaleConstraintsSet.cpp

Issue 1611693002: Revert of Don't change layout size due to top control show/hide (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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) 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 m_constraintsDirty = true; 50 m_constraintsDirty = true;
51 } 51 }
52 52
53 const PageScaleConstraints& PageScaleConstraintsSet::defaultConstraints() const 53 const PageScaleConstraints& PageScaleConstraintsSet::defaultConstraints() const
54 { 54 {
55 return m_defaultConstraints; 55 return m_defaultConstraints;
56 } 56 }
57 57
58 void PageScaleConstraintsSet::updatePageDefinedConstraints(const ViewportDescrip tion& description, Length legacyFallbackWidth) 58 void PageScaleConstraintsSet::updatePageDefinedConstraints(const ViewportDescrip tion& description, Length legacyFallbackWidth)
59 { 59 {
60 m_pageDefinedConstraints = description.resolve(FloatSize(m_icbSize), legacyF allbackWidth); 60 m_pageDefinedConstraints = description.resolve(FloatSize(m_viewSize), legacy FallbackWidth);
61 61
62 m_constraintsDirty = true; 62 m_constraintsDirty = true;
63 } 63 }
64 64
65 void PageScaleConstraintsSet::clearPageDefinedConstraints() 65 void PageScaleConstraintsSet::clearPageDefinedConstraints()
66 { 66 {
67 m_pageDefinedConstraints = PageScaleConstraints(); 67 m_pageDefinedConstraints = PageScaleConstraints();
68 m_constraintsDirty = true; 68 m_constraintsDirty = true;
69 } 69 }
70 70
(...skipping 21 matching lines...) Expand all
92 void PageScaleConstraintsSet::computeFinalConstraints() 92 void PageScaleConstraintsSet::computeFinalConstraints()
93 { 93 {
94 m_finalConstraints = computeConstraintsStack(); 94 m_finalConstraints = computeConstraintsStack();
95 95
96 m_constraintsDirty = false; 96 m_constraintsDirty = false;
97 } 97 }
98 98
99 void PageScaleConstraintsSet::adjustFinalConstraintsToContentsSize(IntSize conte ntsSize, int nonOverlayScrollbarWidth, bool shrinksViewportContentToFit) 99 void PageScaleConstraintsSet::adjustFinalConstraintsToContentsSize(IntSize conte ntsSize, int nonOverlayScrollbarWidth, bool shrinksViewportContentToFit)
100 { 100 {
101 if (shrinksViewportContentToFit) 101 if (shrinksViewportContentToFit)
102 m_finalConstraints.fitToContentsWidth(contentsSize.width(), m_icbSize.wi dth() - nonOverlayScrollbarWidth); 102 m_finalConstraints.fitToContentsWidth(contentsSize.width(), m_viewSize.w idth() - nonOverlayScrollbarWidth);
103 103
104 m_finalConstraints.resolveAutoInitialScale(); 104 m_finalConstraints.resolveAutoInitialScale();
105 } 105 }
106 106
107 void PageScaleConstraintsSet::setNeedsReset(bool needsReset) 107 void PageScaleConstraintsSet::setNeedsReset(bool needsReset)
108 { 108 {
109 m_needsReset = needsReset; 109 m_needsReset = needsReset;
110 if (needsReset) 110 if (needsReset)
111 m_constraintsDirty = true; 111 m_constraintsDirty = true;
112 } 112 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 static float getLayoutWidthForNonWideViewport(const FloatSize& deviceSize, float initialScale) 145 static float getLayoutWidthForNonWideViewport(const FloatSize& deviceSize, float initialScale)
146 { 146 {
147 return initialScale == -1 ? deviceSize.width() : deviceSize.width() / initia lScale; 147 return initialScale == -1 ? deviceSize.width() : deviceSize.width() / initia lScale;
148 } 148 }
149 149
150 static float computeHeightByAspectRatio(float width, const FloatSize& deviceSize ) 150 static float computeHeightByAspectRatio(float width, const FloatSize& deviceSize )
151 { 151 {
152 return width * (deviceSize.height() / deviceSize.width()); 152 return width * (deviceSize.height() / deviceSize.width());
153 } 153 }
154 154
155 void PageScaleConstraintsSet::didChangeInitialContainingBlockSize(const IntSize& size) 155 void PageScaleConstraintsSet::didChangeViewSize(const IntSize& size)
156 { 156 {
157 if (m_icbSize == size) 157 if (m_viewSize == size)
158 return; 158 return;
159 159
160 m_icbSize = size; 160 m_viewSize = size;
161 m_constraintsDirty = true; 161 m_constraintsDirty = true;
162 } 162 }
163 163
164 IntSize PageScaleConstraintsSet::mainFrameSize() const
165 {
166 // The frame size should match the viewport size at minimum scale, since the
167 // viewport must always be contained by the frame.
168 FloatSize frameSize(m_viewSize);
169 frameSize.scale(1 / finalConstraints().minimumScale);
170 return expandedIntSize(frameSize);
171 }
172
164 IntSize PageScaleConstraintsSet::layoutSize() const 173 IntSize PageScaleConstraintsSet::layoutSize() const
165 { 174 {
166 return flooredIntSize(computeConstraintsStack().layoutSize); 175 return flooredIntSize(computeConstraintsStack().layoutSize);
167 } 176 }
168 177
169 void PageScaleConstraintsSet::adjustForAndroidWebViewQuirks(const ViewportDescri ption& description, int layoutFallbackWidth, float deviceScaleFactor, bool suppo rtTargetDensityDPI, bool wideViewportQuirkEnabled, bool useWideViewport, bool lo adWithOverviewMode, bool nonUserScalableQuirkEnabled) 178 void PageScaleConstraintsSet::adjustForAndroidWebViewQuirks(const ViewportDescri ption& description, int layoutFallbackWidth, float deviceScaleFactor, bool suppo rtTargetDensityDPI, bool wideViewportQuirkEnabled, bool useWideViewport, bool lo adWithOverviewMode, bool nonUserScalableQuirkEnabled)
170 { 179 {
171 if (!supportTargetDensityDPI && !wideViewportQuirkEnabled && loadWithOvervie wMode && !nonUserScalableQuirkEnabled) 180 if (!supportTargetDensityDPI && !wideViewportQuirkEnabled && loadWithOvervie wMode && !nonUserScalableQuirkEnabled)
172 return; 181 return;
173 182
(...skipping 25 matching lines...) Expand all
199 if (wideViewportQuirkEnabled && (!useWideViewport || description.maxWidt h.type() == DeviceWidth)) { 208 if (wideViewportQuirkEnabled && (!useWideViewport || description.maxWidt h.type() == DeviceWidth)) {
200 adjustedLayoutSizeWidth /= targetDensityDPIFactor; 209 adjustedLayoutSizeWidth /= targetDensityDPIFactor;
201 adjustedLayoutSizeHeight /= targetDensityDPIFactor; 210 adjustedLayoutSizeHeight /= targetDensityDPIFactor;
202 } 211 }
203 } 212 }
204 213
205 if (wideViewportQuirkEnabled) { 214 if (wideViewportQuirkEnabled) {
206 if (useWideViewport && (description.maxWidth.isAuto() || description.max Width.type() == ExtendToZoom) && description.zoom != 1.0f) { 215 if (useWideViewport && (description.maxWidth.isAuto() || description.max Width.type() == ExtendToZoom) && description.zoom != 1.0f) {
207 if (layoutFallbackWidth) 216 if (layoutFallbackWidth)
208 adjustedLayoutSizeWidth = layoutFallbackWidth; 217 adjustedLayoutSizeWidth = layoutFallbackWidth;
209 adjustedLayoutSizeHeight = computeHeightByAspectRatio(adjustedLayout SizeWidth, FloatSize(m_icbSize)); 218 adjustedLayoutSizeHeight = computeHeightByAspectRatio(adjustedLayout SizeWidth, FloatSize(m_viewSize));
210 } else if (!useWideViewport) { 219 } else if (!useWideViewport) {
211 const float nonWideScale = description.zoom < 1 && description.maxWi dth.type() != DeviceWidth && description.maxWidth.type() != DeviceHeight ? -1 : oldInitialScale; 220 const float nonWideScale = description.zoom < 1 && description.maxWi dth.type() != DeviceWidth && description.maxWidth.type() != DeviceHeight ? -1 : oldInitialScale;
212 adjustedLayoutSizeWidth = getLayoutWidthForNonWideViewport(FloatSize (m_icbSize), nonWideScale) / targetDensityDPIFactor; 221 adjustedLayoutSizeWidth = getLayoutWidthForNonWideViewport(FloatSize (m_viewSize), nonWideScale) / targetDensityDPIFactor;
213 float newInitialScale = targetDensityDPIFactor; 222 float newInitialScale = targetDensityDPIFactor;
214 if (m_userAgentConstraints.initialScale != -1 && (description.maxWid th.type() == DeviceWidth || ((description.maxWidth.isAuto() || description.maxWi dth.type() == ExtendToZoom) && description.zoom == -1))) { 223 if (m_userAgentConstraints.initialScale != -1 && (description.maxWid th.type() == DeviceWidth || ((description.maxWidth.isAuto() || description.maxWi dth.type() == ExtendToZoom) && description.zoom == -1))) {
215 adjustedLayoutSizeWidth /= m_userAgentConstraints.initialScale; 224 adjustedLayoutSizeWidth /= m_userAgentConstraints.initialScale;
216 newInitialScale = m_userAgentConstraints.initialScale; 225 newInitialScale = m_userAgentConstraints.initialScale;
217 } 226 }
218 adjustedLayoutSizeHeight = computeHeightByAspectRatio(adjustedLayout SizeWidth, FloatSize(m_icbSize)); 227 adjustedLayoutSizeHeight = computeHeightByAspectRatio(adjustedLayout SizeWidth, FloatSize(m_viewSize));
219 if (description.zoom < 1) { 228 if (description.zoom < 1) {
220 m_pageDefinedConstraints.initialScale = newInitialScale; 229 m_pageDefinedConstraints.initialScale = newInitialScale;
221 if (m_pageDefinedConstraints.minimumScale != -1) 230 if (m_pageDefinedConstraints.minimumScale != -1)
222 m_pageDefinedConstraints.minimumScale = std::min<float>(m_pa geDefinedConstraints.minimumScale, m_pageDefinedConstraints.initialScale); 231 m_pageDefinedConstraints.minimumScale = std::min<float>(m_pa geDefinedConstraints.minimumScale, m_pageDefinedConstraints.initialScale);
223 if (m_pageDefinedConstraints.maximumScale != -1) 232 if (m_pageDefinedConstraints.maximumScale != -1)
224 m_pageDefinedConstraints.maximumScale = std::max<float>(m_pa geDefinedConstraints.maximumScale, m_pageDefinedConstraints.initialScale); 233 m_pageDefinedConstraints.maximumScale = std::max<float>(m_pa geDefinedConstraints.maximumScale, m_pageDefinedConstraints.initialScale);
225 } 234 }
226 } 235 }
227 } 236 }
228 237
229 if (nonUserScalableQuirkEnabled && !description.userZoom) { 238 if (nonUserScalableQuirkEnabled && !description.userZoom) {
230 m_pageDefinedConstraints.initialScale = targetDensityDPIFactor; 239 m_pageDefinedConstraints.initialScale = targetDensityDPIFactor;
231 m_pageDefinedConstraints.minimumScale = m_pageDefinedConstraints.initial Scale; 240 m_pageDefinedConstraints.minimumScale = m_pageDefinedConstraints.initial Scale;
232 m_pageDefinedConstraints.maximumScale = m_pageDefinedConstraints.initial Scale; 241 m_pageDefinedConstraints.maximumScale = m_pageDefinedConstraints.initial Scale;
233 if (description.maxWidth.isAuto() || description.maxWidth.type() == Exte ndToZoom || description.maxWidth.type() == DeviceWidth) { 242 if (description.maxWidth.isAuto() || description.maxWidth.type() == Exte ndToZoom || description.maxWidth.type() == DeviceWidth) {
234 adjustedLayoutSizeWidth = m_icbSize.width() / targetDensityDPIFactor ; 243 adjustedLayoutSizeWidth = m_viewSize.width() / targetDensityDPIFacto r;
235 adjustedLayoutSizeHeight = computeHeightByAspectRatio(adjustedLayout SizeWidth, FloatSize(m_icbSize)); 244 adjustedLayoutSizeHeight = computeHeightByAspectRatio(adjustedLayout SizeWidth, FloatSize(m_viewSize));
236 } 245 }
237 } 246 }
238 247
239 m_pageDefinedConstraints.layoutSize.setWidth(adjustedLayoutSizeWidth); 248 m_pageDefinedConstraints.layoutSize.setWidth(adjustedLayoutSizeWidth);
240 m_pageDefinedConstraints.layoutSize.setHeight(adjustedLayoutSizeHeight); 249 m_pageDefinedConstraints.layoutSize.setHeight(adjustedLayoutSizeHeight);
241 } 250 }
242 251
243 } // namespace blink 252 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/PageScaleConstraintsSet.h ('k') | third_party/WebKit/Source/core/layout/LayoutView.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698