https://bugs.webkit.org/show_bug.cgi?id=142664
<rdar://problem/
18859470>
Reviewed by Benjamin Poulain.
* page/ViewportConfiguration.cpp:
(WebCore::ViewportConfiguration::shouldIgnoreHorizontalScalingConstraints):
(WebCore::ViewportConfiguration::shouldIgnoreVerticalScalingConstraints):
(WebCore::ViewportConfiguration::shouldIgnoreScalingConstraints):
Split shouldIgnoreScalingConstraints into one for each dimension.
(WebCore::ViewportConfiguration::initialScale):
(WebCore::ViewportConfiguration::minimumScale):
Don't force the initial and minimum scales to cover the whole view if the
page claims to want to lay out to device width but then lays out too big.
This will allow pages that misbehave in this way to scale down further
than they previously could, but will result in a region of empty background
color being exposed at the initial/minimum scale.
(WebCore::ViewportConfiguration::description):
Update the logging to show each dimension separately.
* page/ViewportConfiguration.h:
* UIProcess/ios/WKScrollView.mm:
(-[WKScrollView _rubberBandOffsetForOffset:maxOffset:minOffset:range:outside:]):
Now that the WKContentView can (without pinching) be smaller than the unobscured
region of the WKWebView, we need to take that into account when deciding where
to retarget scrolling.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181488
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2015-03-13 Timothy Horton <timothy_horton@apple.com>
+
+ Sites that use a device-width viewport but don't have enough height to fill the view are scaled up
+ https://bugs.webkit.org/show_bug.cgi?id=142664
+ <rdar://problem/18859470>
+
+ Reviewed by Benjamin Poulain.
+
+ * page/ViewportConfiguration.cpp:
+ (WebCore::ViewportConfiguration::shouldIgnoreHorizontalScalingConstraints):
+ (WebCore::ViewportConfiguration::shouldIgnoreVerticalScalingConstraints):
+ (WebCore::ViewportConfiguration::shouldIgnoreScalingConstraints):
+ Split shouldIgnoreScalingConstraints into one for each dimension.
+
+ (WebCore::ViewportConfiguration::initialScale):
+ (WebCore::ViewportConfiguration::minimumScale):
+ Don't force the initial and minimum scales to cover the whole view if the
+ page claims to want to lay out to device width but then lays out too big.
+ This will allow pages that misbehave in this way to scale down further
+ than they previously could, but will result in a region of empty background
+ color being exposed at the initial/minimum scale.
+
+ (WebCore::ViewportConfiguration::description):
+ Update the logging to show each dimension separately.
+
+ * page/ViewportConfiguration.h:
+
2015-03-13 Mark Lam <mark.lam@apple.com>
Replace TCSpinLock with a new WTF::SpinLock based on WTF::Atomic.
return IntSize(layoutWidth(), layoutHeight());
}
-bool ViewportConfiguration::shouldIgnoreScalingConstraints() const
+bool ViewportConfiguration::shouldIgnoreHorizontalScalingConstraints() const
{
if (!m_canIgnoreScalingConstraints)
return false;
if (m_viewportArguments.width == ViewportArguments::ValueDeviceWidth)
return laidOutWiderThanViewport;
+ if (m_configuration.initialScaleIsSet && m_configuration.initialScale == 1)
+ return laidOutWiderThanViewport;
+
+ return false;
+}
+
+bool ViewportConfiguration::shouldIgnoreVerticalScalingConstraints() const
+{
+ if (!m_canIgnoreScalingConstraints)
+ return false;
+
bool laidOutTallerThanViewport = m_contentSize.height() > layoutHeight();
if (m_viewportArguments.height == ViewportArguments::ValueDeviceHeight)
return laidOutTallerThanViewport;
- if (m_configuration.initialScaleIsSet && m_configuration.initialScale == 1)
- return laidOutWiderThanViewport;
-
return false;
}
+bool ViewportConfiguration::shouldIgnoreScalingConstraints() const
+{
+ return shouldIgnoreHorizontalScalingConstraints() || shouldIgnoreVerticalScalingConstraints();
+}
+
double ViewportConfiguration::initialScale() const
{
ASSERT(!constraintsAreAllRelative(m_configuration));
const FloatSize& minimumLayoutSize = m_minimumLayoutSize;
double width = m_contentSize.width() > 0 ? m_contentSize.width() : layoutWidth();
double initialScale = 0;
- if (width > 0)
+ if (width > 0 && !shouldIgnoreVerticalScalingConstraints())
initialScale = minimumLayoutSize.width() / width;
- // Prevent the intial scale from shrinking to a height smaller than our view's minimum height.
+ // Prevent the initial scale from shrinking to a height smaller than our view's minimum height.
double height = m_contentSize.height() > 0 ? m_contentSize.height() : layoutHeight();
- if (height > 0 && height * initialScale < minimumLayoutSize.height())
+ if (height > 0 && height * initialScale < minimumLayoutSize.height() && !shouldIgnoreHorizontalScalingConstraints())
initialScale = minimumLayoutSize.height() / height;
return std::min(std::max(initialScale, shouldIgnoreScalingConstraints() ? m_defaultConfiguration.minimumScale : m_configuration.minimumScale), m_configuration.maximumScale);
}
const FloatSize& minimumLayoutSize = m_minimumLayoutSize;
double contentWidth = m_contentSize.width();
- if (contentWidth > 0 && contentWidth * minimumScale < minimumLayoutSize.width())
+ if (contentWidth > 0 && contentWidth * minimumScale < minimumLayoutSize.width() && !shouldIgnoreVerticalScalingConstraints())
minimumScale = minimumLayoutSize.width() / contentWidth;
double contentHeight = m_contentSize.height();
- if (contentHeight > 0 && contentHeight * minimumScale < minimumLayoutSize.height())
+ if (contentHeight > 0 && contentHeight * minimumScale < minimumLayoutSize.height() && !shouldIgnoreHorizontalScalingConstraints())
minimumScale = minimumLayoutSize.height() / contentHeight;
minimumScale = std::min(std::max(minimumScale, m_configuration.minimumScale), m_configuration.maximumScale);
ts.writeIndent();
ts << "(computed layout size " << layoutSize() << ")\n";
ts.writeIndent();
- ts << "(ignoring scaling constraints " << (shouldIgnoreScalingConstraints() ? "true" : "false") << ")";
+ ts << "(ignoring horizontal scaling constraints " << (shouldIgnoreHorizontalScalingConstraints() ? "true" : "false") << ")\n";
+ ts.writeIndent();
+ ts << "(ignoring vertical scaling constraints " << (shouldIgnoreVerticalScalingConstraints() ? "true" : "false") << ")";
ts.decreaseIndent();
ts << ")\n";
double viewportArgumentsLength(double length) const;
int layoutWidth() const;
int layoutHeight() const;
+
bool shouldIgnoreScalingConstraints() const;
+ bool shouldIgnoreVerticalScalingConstraints() const;
+ bool shouldIgnoreHorizontalScalingConstraints() const;
Parameters m_configuration;
Parameters m_defaultConfiguration;
+2015-03-13 Timothy Horton <timothy_horton@apple.com>
+
+ Sites that use a device-width viewport but don't have enough height to fill the view are scaled up
+ https://bugs.webkit.org/show_bug.cgi?id=142664
+ <rdar://problem/18859470>
+
+ Reviewed by Benjamin Poulain.
+
+ * UIProcess/ios/WKScrollView.mm:
+ (-[WKScrollView _rubberBandOffsetForOffset:maxOffset:minOffset:range:outside:]):
+ Now that the WKContentView can (without pinching) be smaller than the unobscured
+ region of the WKWebView, we need to take that into account when deciding where
+ to retarget scrolling.
+
2015-03-13 Mark Lam <mark.lam@apple.com>
Replace TCSpinLock with a new WTF::SpinLock based on WTF::Atomic.
CGRect bounds = self.bounds;
CGFloat minimalHorizontalRange = bounds.size.width - contentInsets.left - contentInsets.right;
+ CGFloat contentWidthAtMinimumScale = contentSize.width * (self.minimumZoomScale / self.zoomScale);
+ if (contentWidthAtMinimumScale < minimalHorizontalRange) {
+ CGFloat unobscuredEmptyHorizontalMarginAtMinimumScale = minimalHorizontalRange - contentWidthAtMinimumScale;
+ minimalHorizontalRange -= unobscuredEmptyHorizontalMarginAtMinimumScale;
+ }
if (contentSize.width < minimalHorizontalRange) {
if (valuesAreWithinOnePixel(minOffset, -contentInsets.left)
&& valuesAreWithinOnePixel(maxOffset, contentSize.width + contentInsets.right - bounds.size.width)
}
CGFloat minimalVerticalRange = bounds.size.height - contentInsets.top - contentInsets.bottom;
+ CGFloat contentHeightAtMinimumScale = contentSize.height * (self.minimumZoomScale / self.zoomScale);
+ if (contentHeightAtMinimumScale < minimalVerticalRange) {
+ CGFloat unobscuredEmptyVerticalMarginAtMinimumScale = minimalVerticalRange - contentHeightAtMinimumScale;
+ minimalVerticalRange -= unobscuredEmptyVerticalMarginAtMinimumScale;
+ }
if (contentSize.height < minimalVerticalRange) {
if (valuesAreWithinOnePixel(minOffset, -contentInsets.top)
&& valuesAreWithinOnePixel(maxOffset, contentSize.height + contentInsets.bottom - bounds.size.height)