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

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

Issue 1573283002: Don't change layout size due to top control show/hide (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove redundant call to viewportSizeForViewportUnits 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_viewSize), legacy FallbackWidth); 60 m_pageDefinedConstraints = description.resolve(FloatSize(m_icbSize), legacyF allbackWidth);
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_viewSize.w idth() - nonOverlayScrollbarWidth); 102 m_finalConstraints.fitToContentsWidth(contentsSize.width(), m_icbSize.wi dth() - 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::didChangeViewSize(const IntSize& size) 155 void PageScaleConstraintsSet::didChangeInitialContainingBlockSize(const IntSize& size)
156 { 156 {
157 if (m_viewSize == size) 157 if (m_icbSize == size)
158 return; 158 return;
159 159
160 m_viewSize = size; 160 m_icbSize = 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
173 IntSize PageScaleConstraintsSet::layoutSize() const 164 IntSize PageScaleConstraintsSet::layoutSize() const
174 { 165 {
175 return flooredIntSize(computeConstraintsStack().layoutSize); 166 return flooredIntSize(computeConstraintsStack().layoutSize);
176 } 167 }
177 168
178 void PageScaleConstraintsSet::adjustForAndroidWebViewQuirks(const ViewportDescri ption& description, int layoutFallbackWidth, float deviceScaleFactor, bool suppo rtTargetDensityDPI, bool wideViewportQuirkEnabled, bool useWideViewport, bool lo adWithOverviewMode, bool nonUserScalableQuirkEnabled) 169 void PageScaleConstraintsSet::adjustForAndroidWebViewQuirks(const ViewportDescri ption& description, int layoutFallbackWidth, float deviceScaleFactor, bool suppo rtTargetDensityDPI, bool wideViewportQuirkEnabled, bool useWideViewport, bool lo adWithOverviewMode, bool nonUserScalableQuirkEnabled)
179 { 170 {
180 if (!supportTargetDensityDPI && !wideViewportQuirkEnabled && loadWithOvervie wMode && !nonUserScalableQuirkEnabled) 171 if (!supportTargetDensityDPI && !wideViewportQuirkEnabled && loadWithOvervie wMode && !nonUserScalableQuirkEnabled)
181 return; 172 return;
182 173
(...skipping 25 matching lines...) Expand all
208 if (wideViewportQuirkEnabled && (!useWideViewport || description.maxWidt h.type() == DeviceWidth)) { 199 if (wideViewportQuirkEnabled && (!useWideViewport || description.maxWidt h.type() == DeviceWidth)) {
209 adjustedLayoutSizeWidth /= targetDensityDPIFactor; 200 adjustedLayoutSizeWidth /= targetDensityDPIFactor;
210 adjustedLayoutSizeHeight /= targetDensityDPIFactor; 201 adjustedLayoutSizeHeight /= targetDensityDPIFactor;
211 } 202 }
212 } 203 }
213 204
214 if (wideViewportQuirkEnabled) { 205 if (wideViewportQuirkEnabled) {
215 if (useWideViewport && (description.maxWidth.isAuto() || description.max Width.type() == ExtendToZoom) && description.zoom != 1.0f) { 206 if (useWideViewport && (description.maxWidth.isAuto() || description.max Width.type() == ExtendToZoom) && description.zoom != 1.0f) {
216 if (layoutFallbackWidth) 207 if (layoutFallbackWidth)
217 adjustedLayoutSizeWidth = layoutFallbackWidth; 208 adjustedLayoutSizeWidth = layoutFallbackWidth;
218 adjustedLayoutSizeHeight = computeHeightByAspectRatio(adjustedLayout SizeWidth, FloatSize(m_viewSize)); 209 adjustedLayoutSizeHeight = computeHeightByAspectRatio(adjustedLayout SizeWidth, FloatSize(m_icbSize));
219 } else if (!useWideViewport) { 210 } else if (!useWideViewport) {
220 const float nonWideScale = description.zoom < 1 && description.maxWi dth.type() != DeviceWidth && description.maxWidth.type() != DeviceHeight ? -1 : oldInitialScale; 211 const float nonWideScale = description.zoom < 1 && description.maxWi dth.type() != DeviceWidth && description.maxWidth.type() != DeviceHeight ? -1 : oldInitialScale;
221 adjustedLayoutSizeWidth = getLayoutWidthForNonWideViewport(FloatSize (m_viewSize), nonWideScale) / targetDensityDPIFactor; 212 adjustedLayoutSizeWidth = getLayoutWidthForNonWideViewport(FloatSize (m_icbSize), nonWideScale) / targetDensityDPIFactor;
222 float newInitialScale = targetDensityDPIFactor; 213 float newInitialScale = targetDensityDPIFactor;
223 if (m_userAgentConstraints.initialScale != -1 && (description.maxWid th.type() == DeviceWidth || ((description.maxWidth.isAuto() || description.maxWi dth.type() == ExtendToZoom) && description.zoom == -1))) { 214 if (m_userAgentConstraints.initialScale != -1 && (description.maxWid th.type() == DeviceWidth || ((description.maxWidth.isAuto() || description.maxWi dth.type() == ExtendToZoom) && description.zoom == -1))) {
224 adjustedLayoutSizeWidth /= m_userAgentConstraints.initialScale; 215 adjustedLayoutSizeWidth /= m_userAgentConstraints.initialScale;
225 newInitialScale = m_userAgentConstraints.initialScale; 216 newInitialScale = m_userAgentConstraints.initialScale;
226 } 217 }
227 adjustedLayoutSizeHeight = computeHeightByAspectRatio(adjustedLayout SizeWidth, FloatSize(m_viewSize)); 218 adjustedLayoutSizeHeight = computeHeightByAspectRatio(adjustedLayout SizeWidth, FloatSize(m_icbSize));
228 if (description.zoom < 1) { 219 if (description.zoom < 1) {
229 m_pageDefinedConstraints.initialScale = newInitialScale; 220 m_pageDefinedConstraints.initialScale = newInitialScale;
230 if (m_pageDefinedConstraints.minimumScale != -1) 221 if (m_pageDefinedConstraints.minimumScale != -1)
231 m_pageDefinedConstraints.minimumScale = std::min<float>(m_pa geDefinedConstraints.minimumScale, m_pageDefinedConstraints.initialScale); 222 m_pageDefinedConstraints.minimumScale = std::min<float>(m_pa geDefinedConstraints.minimumScale, m_pageDefinedConstraints.initialScale);
232 if (m_pageDefinedConstraints.maximumScale != -1) 223 if (m_pageDefinedConstraints.maximumScale != -1)
233 m_pageDefinedConstraints.maximumScale = std::max<float>(m_pa geDefinedConstraints.maximumScale, m_pageDefinedConstraints.initialScale); 224 m_pageDefinedConstraints.maximumScale = std::max<float>(m_pa geDefinedConstraints.maximumScale, m_pageDefinedConstraints.initialScale);
234 } 225 }
235 } 226 }
236 } 227 }
237 228
238 if (nonUserScalableQuirkEnabled && !description.userZoom) { 229 if (nonUserScalableQuirkEnabled && !description.userZoom) {
239 m_pageDefinedConstraints.initialScale = targetDensityDPIFactor; 230 m_pageDefinedConstraints.initialScale = targetDensityDPIFactor;
240 m_pageDefinedConstraints.minimumScale = m_pageDefinedConstraints.initial Scale; 231 m_pageDefinedConstraints.minimumScale = m_pageDefinedConstraints.initial Scale;
241 m_pageDefinedConstraints.maximumScale = m_pageDefinedConstraints.initial Scale; 232 m_pageDefinedConstraints.maximumScale = m_pageDefinedConstraints.initial Scale;
242 if (description.maxWidth.isAuto() || description.maxWidth.type() == Exte ndToZoom || description.maxWidth.type() == DeviceWidth) { 233 if (description.maxWidth.isAuto() || description.maxWidth.type() == Exte ndToZoom || description.maxWidth.type() == DeviceWidth) {
243 adjustedLayoutSizeWidth = m_viewSize.width() / targetDensityDPIFacto r; 234 adjustedLayoutSizeWidth = m_icbSize.width() / targetDensityDPIFactor ;
244 adjustedLayoutSizeHeight = computeHeightByAspectRatio(adjustedLayout SizeWidth, FloatSize(m_viewSize)); 235 adjustedLayoutSizeHeight = computeHeightByAspectRatio(adjustedLayout SizeWidth, FloatSize(m_icbSize));
245 } 236 }
246 } 237 }
247 238
248 m_pageDefinedConstraints.layoutSize.setWidth(adjustedLayoutSizeWidth); 239 m_pageDefinedConstraints.layoutSize.setWidth(adjustedLayoutSizeWidth);
249 m_pageDefinedConstraints.layoutSize.setHeight(adjustedLayoutSizeHeight); 240 m_pageDefinedConstraints.layoutSize.setHeight(adjustedLayoutSizeHeight);
250 } 241 }
251 242
252 } // namespace blink 243 } // 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