⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 181488 in webkit


Ignore:
Timestamp:
Mar 13, 2015, 2:07:06 PM (11 years ago)
Author:
timothy_horton@apple.com
Message:

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:
  • 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.

Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r181485 r181488  
     12015-03-13  Timothy Horton  <timothy_horton@apple.com>
     2
     3        Sites that use a device-width viewport but don't have enough height to fill the view are scaled up
     4        https://bugs.webkit.org/show_bug.cgi?id=142664
     5        <rdar://problem/18859470>
     6
     7        Reviewed by Benjamin Poulain.
     8
     9        * page/ViewportConfiguration.cpp:
     10        (WebCore::ViewportConfiguration::shouldIgnoreHorizontalScalingConstraints):
     11        (WebCore::ViewportConfiguration::shouldIgnoreVerticalScalingConstraints):
     12        (WebCore::ViewportConfiguration::shouldIgnoreScalingConstraints):
     13        Split shouldIgnoreScalingConstraints into one for each dimension.
     14
     15        (WebCore::ViewportConfiguration::initialScale):
     16        (WebCore::ViewportConfiguration::minimumScale):
     17        Don't force the initial and minimum scales to cover the whole view if the
     18        page claims to want to lay out to device width but then lays out too big.
     19        This will allow pages that misbehave in this way to scale down further
     20        than they previously could, but will result in a region of empty background
     21        color being exposed at the initial/minimum scale.
     22
     23        (WebCore::ViewportConfiguration::description):
     24        Update the logging to show each dimension separately.
     25
     26        * page/ViewportConfiguration.h:
     27
    1282015-03-13  Mark Lam  <mark.lam@apple.com>
    229
  • trunk/Source/WebCore/page/ViewportConfiguration.cpp

    r181400 r181488  
    9898}
    9999
    100 bool ViewportConfiguration::shouldIgnoreScalingConstraints() const
     100bool ViewportConfiguration::shouldIgnoreHorizontalScalingConstraints() const
    101101{
    102102    if (!m_canIgnoreScalingConstraints)
     
    107107        return laidOutWiderThanViewport;
    108108
     109    if (m_configuration.initialScaleIsSet && m_configuration.initialScale == 1)
     110        return laidOutWiderThanViewport;
     111
     112    return false;
     113}
     114
     115bool ViewportConfiguration::shouldIgnoreVerticalScalingConstraints() const
     116{
     117    if (!m_canIgnoreScalingConstraints)
     118        return false;
     119
    109120    bool laidOutTallerThanViewport = m_contentSize.height() > layoutHeight();
    110121    if (m_viewportArguments.height == ViewportArguments::ValueDeviceHeight)
    111122        return laidOutTallerThanViewport;
    112123
    113     if (m_configuration.initialScaleIsSet && m_configuration.initialScale == 1)
    114         return laidOutWiderThanViewport;
    115 
    116124    return false;
     125}
     126
     127bool ViewportConfiguration::shouldIgnoreScalingConstraints() const
     128{
     129    return shouldIgnoreHorizontalScalingConstraints() || shouldIgnoreVerticalScalingConstraints();
    117130}
    118131
     
    131144    double width = m_contentSize.width() > 0 ? m_contentSize.width() : layoutWidth();
    132145    double initialScale = 0;
    133     if (width > 0)
     146    if (width > 0 && !shouldIgnoreVerticalScalingConstraints())
    134147        initialScale = minimumLayoutSize.width() / width;
    135148
    136     // Prevent the intial scale from shrinking to a height smaller than our view's minimum height.
     149    // Prevent the initial scale from shrinking to a height smaller than our view's minimum height.
    137150    double height = m_contentSize.height() > 0 ? m_contentSize.height() : layoutHeight();
    138     if (height > 0 && height * initialScale < minimumLayoutSize.height())
     151    if (height > 0 && height * initialScale < minimumLayoutSize.height() && !shouldIgnoreHorizontalScalingConstraints())
    139152        initialScale = minimumLayoutSize.height() / height;
    140153    return std::min(std::max(initialScale, shouldIgnoreScalingConstraints() ? m_defaultConfiguration.minimumScale : m_configuration.minimumScale), m_configuration.maximumScale);
     
    152165    const FloatSize& minimumLayoutSize = m_minimumLayoutSize;
    153166    double contentWidth = m_contentSize.width();
    154     if (contentWidth > 0 && contentWidth * minimumScale < minimumLayoutSize.width())
     167    if (contentWidth > 0 && contentWidth * minimumScale < minimumLayoutSize.width() && !shouldIgnoreVerticalScalingConstraints())
    155168        minimumScale = minimumLayoutSize.width() / contentWidth;
    156169
    157170    double contentHeight = m_contentSize.height();
    158     if (contentHeight > 0 && contentHeight * minimumScale < minimumLayoutSize.height())
     171    if (contentHeight > 0 && contentHeight * minimumScale < minimumLayoutSize.height() && !shouldIgnoreHorizontalScalingConstraints())
    159172        minimumScale = minimumLayoutSize.height() / contentHeight;
    160173
     
    491504    ts << "(computed layout size " << layoutSize() << ")\n";
    492505    ts.writeIndent();
    493     ts << "(ignoring scaling constraints " << (shouldIgnoreScalingConstraints() ? "true" : "false") << ")";
     506    ts << "(ignoring horizontal scaling constraints " << (shouldIgnoreHorizontalScalingConstraints() ? "true" : "false") << ")\n";
     507    ts.writeIndent();
     508    ts << "(ignoring vertical scaling constraints " << (shouldIgnoreVerticalScalingConstraints() ? "true" : "false") << ")";
    494509    ts.decreaseIndent();
    495510
  • trunk/Source/WebCore/page/ViewportConfiguration.h

    r181400 r181488  
    102102    int layoutWidth() const;
    103103    int layoutHeight() const;
     104
    104105    bool shouldIgnoreScalingConstraints() const;
     106    bool shouldIgnoreVerticalScalingConstraints() const;
     107    bool shouldIgnoreHorizontalScalingConstraints() const;
    105108
    106109    Parameters m_configuration;
  • trunk/Source/WebKit2/ChangeLog

    r181485 r181488  
     12015-03-13  Timothy Horton  <timothy_horton@apple.com>
     2
     3        Sites that use a device-width viewport but don't have enough height to fill the view are scaled up
     4        https://bugs.webkit.org/show_bug.cgi?id=142664
     5        <rdar://problem/18859470>
     6
     7        Reviewed by Benjamin Poulain.
     8
     9        * UIProcess/ios/WKScrollView.mm:
     10        (-[WKScrollView _rubberBandOffsetForOffset:maxOffset:minOffset:range:outside:]):
     11        Now that the WKContentView can (without pinching) be smaller than the unobscured
     12        region of the WKWebView, we need to take that into account when deciding where
     13        to retarget scrolling.
     14
    1152015-03-13  Mark Lam  <mark.lam@apple.com>
    216
  • trunk/Source/WebKit2/UIProcess/ios/WKScrollView.mm

    r176140 r181488  
    177177
    178178    CGFloat minimalHorizontalRange = bounds.size.width - contentInsets.left - contentInsets.right;
     179    CGFloat contentWidthAtMinimumScale = contentSize.width * (self.minimumZoomScale / self.zoomScale);
     180    if (contentWidthAtMinimumScale < minimalHorizontalRange) {
     181        CGFloat unobscuredEmptyHorizontalMarginAtMinimumScale = minimalHorizontalRange - contentWidthAtMinimumScale;
     182        minimalHorizontalRange -= unobscuredEmptyHorizontalMarginAtMinimumScale;
     183    }
    179184    if (contentSize.width < minimalHorizontalRange) {
    180185        if (valuesAreWithinOnePixel(minOffset, -contentInsets.left)
     
    189194
    190195    CGFloat minimalVerticalRange = bounds.size.height - contentInsets.top - contentInsets.bottom;
     196    CGFloat contentHeightAtMinimumScale = contentSize.height * (self.minimumZoomScale / self.zoomScale);
     197    if (contentHeightAtMinimumScale < minimalVerticalRange) {
     198        CGFloat unobscuredEmptyVerticalMarginAtMinimumScale = minimalVerticalRange - contentHeightAtMinimumScale;
     199        minimalVerticalRange -= unobscuredEmptyVerticalMarginAtMinimumScale;
     200    }
    191201    if (contentSize.height < minimalVerticalRange) {
    192202        if (valuesAreWithinOnePixel(minOffset, -contentInsets.top)
Note: See TracChangeset for help on using the changeset viewer.