Changeset 238946 in webkit
- Timestamp:
- Dec 6, 2018 5:35:25 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r238939 r238946 1 2018-12-06 Yongjun Zhang <yongjun_zhang@apple.com> 2 3 We should ignore minimumEffectiveDeviceWidth if the page specifies device-width in viewport meta-tag. 4 https://bugs.webkit.org/show_bug.cgi?id=192377 5 <rdar://problem/46364206> 6 7 Reviewed by Tim Horton. 8 9 * fast/viewport/ios/ignore-minimum-device-width-for-page-with-viewport-device-width-expected.txt: Added. 10 * fast/viewport/ios/ignore-minimum-device-width-for-page-with-viewport-device-width.html: Added. 11 * fast/viewport/ios/use-minimum-device-width-for-page-without-viewport-meta-expected.txt: Added. 12 * fast/viewport/ios/use-minimum-device-width-for-page-without-viewport-meta.html: Added. 13 1 14 2018-12-06 Wenson Hsieh <wenson_hsieh@apple.com> 2 15 -
trunk/Source/WebCore/ChangeLog
r238942 r238946 1 2018-12-06 Yongjun Zhang <yongjun_zhang@apple.com> 2 3 We should ignore minimumEffectiveDeviceWidth if the page specifies device-width in viewport meta-tag. 4 https://bugs.webkit.org/show_bug.cgi?id=192377 5 <rdar://problem/46364206> 6 7 Reviewed by Tim Horton. 8 9 If the page specifies width=device-width or initial-scale=1 in the viewport meta tag, we should use the 10 native device width and ignore the minimum effective device width in ViewportConfiguration. The patch 11 also introduces scalableNativeWebpageParameters() which uses the device width as default and also allows the page 12 to shrink-to-fit. If a page doesn't have viewport meta tag, or if the width argument isn't device-width 13 and the initial scale isn't 1, we will use scalableNativeWebpageParameters() as the default configuration. 14 15 Tests: fast/viewport/ios/ignore-minimum-device-width-for-page-with-viewport-device-width.html 16 fast/viewport/ios/use-minimum-device-width-for-page-without-viewport-meta.html 17 18 * page/ViewportConfiguration.cpp: 19 (WebCore::ViewportConfiguration::updateDefaultConfiguration): pick the default configuration based on 20 the page's viewport arguments. Also, we will always fall back to scalableNativeWebpageParameters() if we 21 can ignore scaling constraints. 22 (WebCore::ViewportConfiguration::setViewportArguments): When page sends us new ViewportArguments, pick 23 up the correponsding default configuration before updating the configuration. 24 (WebCore::ViewportConfiguration::setCanIgnoreScalingConstraints): When m_canIgnoreScalingConstraints is 25 changed, try to pick up the correponsding default configuration. 26 (WebCore::ViewportConfiguration::scalableNativeWebpageParameters): Add a new default set of viewport Parameters 27 this is very close to nativeWebpageParameters() excpet that it allows shrink to fit and its minimum scale 28 is 0.25. We will use this Parameters for pages that doesn't have viewport meta tag; or the width is 29 not device-width and initial scale is not 1. 30 (WebCore::ViewportConfiguration::updateConfiguration): If the page's viewport argument doesn't override 31 the default width, use the m_minimumLayoutSize.width(). 32 * page/ViewportConfiguration.h: 33 (WebCore::ViewportConfiguration::shouldIgnoreMinimumEffectiveDeviceWidth const): A helper method to tell 34 if we should avoid using minimum effective device width. 35 (WebCore::ViewportConfiguration::canOverrideConfigurationParameters const): If we are using a default 36 configuration that is neither nativeWebpageParameters() nor scalableNativeWebpageParameters(), don't override 37 it. 38 (WebCore::ViewportConfiguration::minimumEffectiveDeviceWidth const): Add a helper method to return minimum 39 effective device width based on shouldIgnoreMinimumEffectiveDeviceWidth(). 40 (WebCore::ViewportConfiguration::effectiveLayoutSizeScaleFactor const): Use minimumEffectiveDeviceWidth(). 41 1 42 2018-12-06 Adrian Perez de Castro <aperez@igalia.com> 2 43 -
trunk/Source/WebCore/page/ViewportConfiguration.cpp
r238623 r238946 144 144 } 145 145 146 bool ViewportConfiguration::canOverrideConfigurationParameters() const 147 { 148 return m_defaultConfiguration == ViewportConfiguration::nativeWebpageParameters() || m_defaultConfiguration == ViewportConfiguration::scalableNativeWebpageParameters(); 149 } 150 151 void ViewportConfiguration::updateDefaultConfiguration() 152 { 153 if (!canOverrideConfigurationParameters()) 154 return; 155 156 if (m_canIgnoreScalingConstraints) { 157 m_defaultConfiguration = ViewportConfiguration::scalableNativeWebpageParameters(); 158 return; 159 } 160 161 if (shouldIgnoreMinimumEffectiveDeviceWidth()) 162 m_defaultConfiguration = ViewportConfiguration::nativeWebpageParameters(); 163 else 164 m_defaultConfiguration = ViewportConfiguration::scalableNativeWebpageParameters(); 165 } 166 146 167 bool ViewportConfiguration::setViewportArguments(const ViewportArguments& viewportArguments) 147 168 { … … 152 173 m_viewportArguments = viewportArguments; 153 174 175 updateDefaultConfiguration(); 154 176 updateMinimumLayoutSize(); 155 177 updateConfiguration(); … … 163 185 164 186 m_canIgnoreScalingConstraints = canIgnoreScalingConstraints; 187 updateDefaultConfiguration(); 165 188 updateConfiguration(); 166 189 return true; … … 326 349 } 327 350 351 ViewportConfiguration::Parameters ViewportConfiguration::scalableNativeWebpageParameters() 352 { 353 Parameters parameters = ViewportConfiguration::nativeWebpageParameters(); 354 parameters.allowsShrinkToFit = true; 355 parameters.minimumScale = 0.25; 356 return parameters; 357 } 358 328 359 ViewportConfiguration::Parameters ViewportConfiguration::webpageParameters() 329 360 { … … 448 479 else if (booleanViewportArgumentIsSet(m_viewportArguments.shrinkToFit)) 449 480 m_configuration.allowsShrinkToFit = m_viewportArguments.shrinkToFit != 0.; 481 482 if (canOverrideConfigurationParameters() && !viewportArgumentsOverridesWidth) 483 m_configuration.width = m_minimumLayoutSize.width(); 450 484 451 485 m_configuration.avoidsUnsafeArea = m_viewportArguments.viewportFit != ViewportFit::Cover; -
trunk/Source/WebCore/page/ViewportConfiguration.h
r238623 r238946 104 104 // Matches a width=device-width, initial-scale=1 viewport. 105 105 WEBCORE_EXPORT static Parameters nativeWebpageParameters(); 106 static Parameters scalableNativeWebpageParameters(); 106 107 WEBCORE_EXPORT static Parameters webpageParameters(); 107 108 WEBCORE_EXPORT static Parameters textDocumentParameters(); … … 127 128 bool shouldIgnoreVerticalScalingConstraints() const; 128 129 bool shouldIgnoreHorizontalScalingConstraints() const; 130 void updateDefaultConfiguration(); 131 bool canOverrideConfigurationParameters() const; 132 133 constexpr bool shouldIgnoreMinimumEffectiveDeviceWidth() const 134 { 135 if (m_canIgnoreScalingConstraints) 136 return true; 137 138 if (m_viewportArguments == ViewportArguments()) 139 return false; 140 141 if (m_viewportArguments.width == ViewportArguments::ValueDeviceWidth || m_viewportArguments.zoom == 1.) 142 return true; 143 144 return false; 145 } 146 147 constexpr double minimumEffectiveDeviceWidth() const 148 { 149 if (shouldIgnoreMinimumEffectiveDeviceWidth()) 150 return 0; 151 return m_minimumEffectiveDeviceWidth; 152 } 129 153 130 154 constexpr double forceAlwaysUserScalableMaximumScale() const … … 142 166 constexpr double effectiveLayoutSizeScaleFactor() const 143 167 { 144 if (!m_viewLayoutSize.width() || !m _minimumEffectiveDeviceWidth)168 if (!m_viewLayoutSize.width() || !minimumEffectiveDeviceWidth()) 145 169 return m_layoutSizeScaleFactor; 146 return m_layoutSizeScaleFactor * m_viewLayoutSize.width() / std::max<double>(m _minimumEffectiveDeviceWidth, m_viewLayoutSize.width());170 return m_layoutSizeScaleFactor * m_viewLayoutSize.width() / std::max<double>(minimumEffectiveDeviceWidth(), m_viewLayoutSize.width()); 147 171 } 148 172 -
trunk/Source/WebKit/ChangeLog
r238941 r238946 1 2018-12-06 Yongjun Zhang <yongjun_zhang@apple.com> 2 3 We should ignore minimumEffectiveDeviceWidth if the page specifies device-width in viewport meta-tag. 4 https://bugs.webkit.org/show_bug.cgi?id=192377 5 <rdar://problem/46364206> 6 7 Reviewed by Tim Horton. 8 9 Since we are using page's viewport arguments to decide the default viewport parameters and 10 whether we can use mininum effective device width, we should always call setViewportArguments() 11 regardless of shouldIgnoreMetaViewport settings. 12 13 * WebProcess/WebPage/WebPage.cpp: 14 (WebKit::WebPage::viewportPropertiesDidChange): Always call setViewportArguments(). 15 (WebKit::WebPage::didCommitLoad): Ditto. 16 1 17 2018-12-06 Tim Horton <timothy_horton@apple.com> 2 18 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r238939 r238946 1933 1933 { 1934 1934 #if PLATFORM(IOS_FAMILY) 1935 if ( !m_page->settings().shouldIgnoreMetaViewport() &&m_viewportConfiguration.setViewportArguments(viewportArguments))1935 if (m_viewportConfiguration.setViewportArguments(viewportArguments)) 1936 1936 viewportConfigurationChanged(); 1937 1937 #endif … … 5548 5548 viewportChanged = true; 5549 5549 5550 if ( !m_page->settings().shouldIgnoreMetaViewport() &&m_viewportConfiguration.setViewportArguments(coreFrame->document()->viewportArguments()))5550 if (m_viewportConfiguration.setViewportArguments(coreFrame->document()->viewportArguments())) 5551 5551 viewportChanged = true; 5552 5552
Note: See TracChangeset
for help on using the changeset viewer.