<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[184654] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/184654">184654</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2015-05-20 13:42:49 -0700 (Wed, 20 May 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add a mechanism to opt-out of the automatic scaling applied to not-really-responsive sites
https://bugs.webkit.org/show_bug.cgi?id=144760

Reviewed by Darin Adler.

Add a new viewport property, shrink-to-fit, which can be used to disable
the automatic scaling introduced in <a href="http://trac.webkit.org/projects/webkit/changeset/181400">r181400</a>. This provides sites with a
way to tell WebKit that they're really sure they want to be laid out at
window-width/height, even if they fail to fit within that size.

* dom/ViewportArguments.cpp:
(WebCore::ViewportArguments::resolve):
(WebCore::findBooleanValue):
(WebCore::setViewportFeature):
* dom/ViewportArguments.h:
(WebCore::ViewportArguments::ViewportArguments):
(WebCore::ViewportArguments::operator==):
* page/ViewportConfiguration.cpp:
(WebCore::ViewportConfiguration::shouldIgnoreHorizontalScalingConstraints):
(WebCore::ViewportConfiguration::shouldIgnoreVerticalScalingConstraints):
(WebCore::ViewportConfiguration::webpageParameters):
(WebCore::ViewportConfiguration::textDocumentParameters):
(WebCore::ViewportConfiguration::imageDocumentParameters):
(WebCore::ViewportConfiguration::testingParameters):
(WebCore::booleanViewportArgumentIsSet):
(WebCore::ViewportConfiguration::updateConfiguration):
(WebCore::ViewportConfigurationTextStream::operator&lt;&lt;):
(WebCore::viewportArgumentUserZoomIsSet): Deleted.
* page/ViewportConfiguration.h:
(WebCore::ViewportConfiguration::Parameters::Parameters):
Plumb the shrink-to-fit viewport property through.
If shrink-to-fit is set to yes, or not set, we behave as usual; if it is
set to no, we will bail from shouldIgnore[Horizontal|Vertical]ScalingConstraints,
effectively disabling the automatic scaling introduced in <a href="http://trac.webkit.org/projects/webkit/changeset/181400">r181400</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomViewportArgumentscpp">trunk/Source/WebCore/dom/ViewportArguments.cpp</a></li>
<li><a href="#trunkSourceWebCoredomViewportArgumentsh">trunk/Source/WebCore/dom/ViewportArguments.h</a></li>
<li><a href="#trunkSourceWebCorepageViewportConfigurationcpp">trunk/Source/WebCore/page/ViewportConfiguration.cpp</a></li>
<li><a href="#trunkSourceWebCorepageViewportConfigurationh">trunk/Source/WebCore/page/ViewportConfiguration.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (184653 => 184654)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-05-20 20:34:40 UTC (rev 184653)
+++ trunk/Source/WebCore/ChangeLog        2015-05-20 20:42:49 UTC (rev 184654)
</span><span class="lines">@@ -1,3 +1,40 @@
</span><ins>+2015-05-20  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        Add a mechanism to opt-out of the automatic scaling applied to not-really-responsive sites
+        https://bugs.webkit.org/show_bug.cgi?id=144760
+
+        Reviewed by Darin Adler.
+
+        Add a new viewport property, shrink-to-fit, which can be used to disable
+        the automatic scaling introduced in r181400. This provides sites with a
+        way to tell WebKit that they're really sure they want to be laid out at
+        window-width/height, even if they fail to fit within that size.
+
+        * dom/ViewportArguments.cpp:
+        (WebCore::ViewportArguments::resolve):
+        (WebCore::findBooleanValue):
+        (WebCore::setViewportFeature):
+        * dom/ViewportArguments.h:
+        (WebCore::ViewportArguments::ViewportArguments):
+        (WebCore::ViewportArguments::operator==):
+        * page/ViewportConfiguration.cpp:
+        (WebCore::ViewportConfiguration::shouldIgnoreHorizontalScalingConstraints):
+        (WebCore::ViewportConfiguration::shouldIgnoreVerticalScalingConstraints):
+        (WebCore::ViewportConfiguration::webpageParameters):
+        (WebCore::ViewportConfiguration::textDocumentParameters):
+        (WebCore::ViewportConfiguration::imageDocumentParameters):
+        (WebCore::ViewportConfiguration::testingParameters):
+        (WebCore::booleanViewportArgumentIsSet):
+        (WebCore::ViewportConfiguration::updateConfiguration):
+        (WebCore::ViewportConfigurationTextStream::operator&lt;&lt;):
+        (WebCore::viewportArgumentUserZoomIsSet): Deleted.
+        * page/ViewportConfiguration.h:
+        (WebCore::ViewportConfiguration::Parameters::Parameters):
+        Plumb the shrink-to-fit viewport property through.
+        If shrink-to-fit is set to yes, or not set, we behave as usual; if it is
+        set to no, we will bail from shouldIgnore[Horizontal|Vertical]ScalingConstraints,
+        effectively disabling the automatic scaling introduced in r181400.
+
</ins><span class="cx"> 2015-05-20  Antti Koivisto  &lt;antti@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Assertion failure in WebCore::BidiRun::BidiRun()
</span></span></pre></div>
<a id="trunkSourceWebCoredomViewportArgumentscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ViewportArguments.cpp (184653 => 184654)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ViewportArguments.cpp        2015-05-20 20:34:40 UTC (rev 184653)
+++ trunk/Source/WebCore/dom/ViewportArguments.cpp        2015-05-20 20:42:49 UTC (rev 184654)
</span><span class="lines">@@ -86,7 +86,6 @@
</span><span class="cx">     float resultZoom = zoom;
</span><span class="cx">     float resultMinZoom = minZoom;
</span><span class="cx">     float resultMaxZoom = maxZoom;
</span><del>-    float resultUserZoom = userZoom;
</del><span class="cx"> 
</span><span class="cx">     switch (int(resultWidth)) {
</span><span class="cx">     case ViewportArguments::ValueDeviceWidth:
</span><span class="lines">@@ -244,8 +243,9 @@
</span><span class="cx">     // if (resultZoom == ViewportArguments::ValueAuto)
</span><span class="cx">     //    result.initialScale = ViewportArguments::ValueAuto;
</span><span class="cx"> 
</span><del>-    result.userScalable = resultUserZoom;
</del><ins>+    result.userScalable = userZoom;
</ins><span class="cx">     result.orientation = orientation;
</span><ins>+    result.shrinkToFit = shrinkToFit;
</ins><span class="cx"> 
</span><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="lines">@@ -354,7 +354,7 @@
</span><span class="cx">     return value;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static float findUserScalableValue(const String&amp; keyString, const String&amp; valueString, Document* document)
</del><ins>+static float findBooleanValue(const String&amp; keyString, const String&amp; valueString, Document* document)
</ins><span class="cx"> {
</span><span class="cx">     // yes and no are used as keywords.
</span><span class="cx">     // Numbers &gt;= 1, numbers &lt;= -1, device-width and device-height are mapped to yes.
</span><span class="lines">@@ -392,12 +392,14 @@
</span><span class="cx">     else if (keyString == &quot;maximum-scale&quot;)
</span><span class="cx">         arguments-&gt;maxZoom = findScaleValue(keyString, valueString, document);
</span><span class="cx">     else if (keyString == &quot;user-scalable&quot;)
</span><del>-        arguments-&gt;userZoom = findUserScalableValue(keyString, valueString, document);
</del><ins>+        arguments-&gt;userZoom = findBooleanValue(keyString, valueString, document);
</ins><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     else if (keyString == &quot;minimal-ui&quot;)
</span><del>-        // FIXME: Ignore silently for now. This should eventually fallback to the warning.
</del><ins>+        // FIXME: Ignore silently for now. This should eventually fall back to the warning.
</ins><span class="cx">         { }
</span><span class="cx"> #endif
</span><ins>+    else if (keyString == &quot;shrink-to-fit&quot;)
+        arguments-&gt;shrinkToFit = findBooleanValue(keyString, valueString, document);
</ins><span class="cx">     else
</span><span class="cx">         reportViewportWarning(document, UnrecognizedViewportArgumentKeyError, keyString, String());
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoredomViewportArgumentsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ViewportArguments.h (184653 => 184654)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ViewportArguments.h        2015-05-20 20:34:40 UTC (rev 184653)
+++ trunk/Source/WebCore/dom/ViewportArguments.h        2015-05-20 20:42:49 UTC (rev 184654)
</span><span class="lines">@@ -51,6 +51,7 @@
</span><span class="cx"> 
</span><span class="cx">     float userScalable;
</span><span class="cx">     float orientation;
</span><ins>+    float shrinkToFit;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> struct ViewportArguments {
</span><span class="lines">@@ -76,34 +77,24 @@
</span><span class="cx"> 
</span><span class="cx">     explicit ViewportArguments(Type type = Implicit)
</span><span class="cx">         : type(type)
</span><del>-        , width(ValueAuto)
-        , minWidth(ValueAuto)
-        , maxWidth(ValueAuto)
-        , height(ValueAuto)
-        , minHeight(ValueAuto)
-        , maxHeight(ValueAuto)
-        , zoom(ValueAuto)
-        , minZoom(ValueAuto)
-        , maxZoom(ValueAuto)
-        , userZoom(ValueAuto)
-        , orientation(ValueAuto)
</del><span class="cx">     {
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // All arguments are in CSS units.
</span><span class="cx">     ViewportAttributes resolve(const FloatSize&amp; initialViewportSize, const FloatSize&amp; deviceSize, int defaultWidth) const;
</span><span class="cx"> 
</span><del>-    float width;
-    float minWidth;
-    float maxWidth;
-    float height;
-    float minHeight;
-    float maxHeight;
-    float zoom;
-    float minZoom;
-    float maxZoom;
-    float userZoom;
-    float orientation;
</del><ins>+    float width { ValueAuto };
+    float minWidth { ValueAuto };
+    float maxWidth { ValueAuto };
+    float height { ValueAuto };
+    float minHeight { ValueAuto };
+    float maxHeight { ValueAuto };
+    float zoom { ValueAuto };
+    float minZoom { ValueAuto };
+    float maxZoom { ValueAuto };
+    float userZoom { ValueAuto };
+    float orientation { ValueAuto };
+    float shrinkToFit { ValueAuto };
</ins><span class="cx"> 
</span><span class="cx">     bool operator==(const ViewportArguments&amp; other) const
</span><span class="cx">     {
</span><span class="lines">@@ -119,7 +110,8 @@
</span><span class="cx">             &amp;&amp; minZoom == other.minZoom
</span><span class="cx">             &amp;&amp; maxZoom == other.maxZoom
</span><span class="cx">             &amp;&amp; userZoom == other.userZoom
</span><del>-            &amp;&amp; orientation == other.orientation;
</del><ins>+            &amp;&amp; orientation == other.orientation
+            &amp;&amp; shrinkToFit == other.shrinkToFit;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     bool operator!=(const ViewportArguments&amp; other) const
</span></span></pre></div>
<a id="trunkSourceWebCorepageViewportConfigurationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/ViewportConfiguration.cpp (184653 => 184654)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/ViewportConfiguration.cpp        2015-05-20 20:34:40 UTC (rev 184653)
+++ trunk/Source/WebCore/page/ViewportConfiguration.cpp        2015-05-20 20:42:49 UTC (rev 184654)
</span><span class="lines">@@ -103,6 +103,9 @@
</span><span class="cx">     if (!m_canIgnoreScalingConstraints)
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><ins>+    if (!m_configuration.allowsShrinkToFit)
+        return false;
+
</ins><span class="cx">     bool laidOutWiderThanViewport = m_contentSize.width() &gt; layoutWidth();
</span><span class="cx">     if (m_viewportArguments.width == ViewportArguments::ValueDeviceWidth)
</span><span class="cx">         return laidOutWiderThanViewport;
</span><span class="lines">@@ -118,6 +121,9 @@
</span><span class="cx">     if (!m_canIgnoreScalingConstraints)
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><ins>+    if (!m_configuration.allowsShrinkToFit)
+        return false;
+
</ins><span class="cx">     bool laidOutTallerThanViewport = m_contentSize.height() &gt; layoutHeight();
</span><span class="cx">     if (m_viewportArguments.height == ViewportArguments::ValueDeviceHeight &amp;&amp; m_viewportArguments.width == ViewportArguments::ValueAuto)
</span><span class="cx">         return laidOutTallerThanViewport;
</span><span class="lines">@@ -188,6 +194,7 @@
</span><span class="cx">     parameters.width = 980;
</span><span class="cx">     parameters.widthIsSet = true;
</span><span class="cx">     parameters.allowsUserScaling = true;
</span><ins>+    parameters.allowsShrinkToFit = true;
</ins><span class="cx">     parameters.minimumScale = 0.25;
</span><span class="cx">     parameters.maximumScale = 5;
</span><span class="cx">     return parameters;
</span><span class="lines">@@ -206,6 +213,7 @@
</span><span class="cx"> 
</span><span class="cx">     parameters.widthIsSet = true;
</span><span class="cx">     parameters.allowsUserScaling = true;
</span><ins>+    parameters.allowsShrinkToFit = false;
</ins><span class="cx">     parameters.minimumScale = 0.25;
</span><span class="cx">     parameters.maximumScale = 5;
</span><span class="cx">     return parameters;
</span><span class="lines">@@ -217,6 +225,7 @@
</span><span class="cx">     parameters.width = 980;
</span><span class="cx">     parameters.widthIsSet = true;
</span><span class="cx">     parameters.allowsUserScaling = true;
</span><ins>+    parameters.allowsShrinkToFit = false;
</ins><span class="cx">     parameters.minimumScale = 0.01;
</span><span class="cx">     parameters.maximumScale = 5;
</span><span class="cx">     return parameters;
</span><span class="lines">@@ -234,6 +243,7 @@
</span><span class="cx">     Parameters parameters;
</span><span class="cx">     parameters.initialScale = 1;
</span><span class="cx">     parameters.initialScaleIsSet = true;
</span><ins>+    parameters.allowsShrinkToFit = true;
</ins><span class="cx">     parameters.minimumScale = 1;
</span><span class="cx">     parameters.maximumScale = 5;
</span><span class="cx">     return parameters;
</span><span class="lines">@@ -261,7 +271,7 @@
</span><span class="cx">         valueIsSet = false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static inline bool viewportArgumentUserZoomIsSet(float value)
</del><ins>+static inline bool booleanViewportArgumentIsSet(float value)
</ins><span class="cx"> {
</span><span class="cx">     return !value || value == 1;
</span><span class="cx"> }
</span><span class="lines">@@ -292,8 +302,11 @@
</span><span class="cx">         m_configuration.heightIsSet = viewportArgumentsOverridesHeight;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (viewportArgumentUserZoomIsSet(m_viewportArguments.userZoom))
</del><ins>+    if (booleanViewportArgumentIsSet(m_viewportArguments.userZoom))
</ins><span class="cx">         m_configuration.allowsUserScaling = m_viewportArguments.userZoom != 0.;
</span><ins>+
+    if (booleanViewportArgumentIsSet(m_viewportArguments.shrinkToFit))
+        m_configuration.allowsShrinkToFit = m_viewportArguments.shrinkToFit != 0.;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> double ViewportConfiguration::viewportArgumentsLength(double length) const
</span><span class="lines">@@ -437,6 +450,7 @@
</span><span class="cx">     dumpProperty(ts, &quot;minimumScale&quot;, parameters.minimumScale);
</span><span class="cx">     dumpProperty(ts, &quot;maximumScale&quot;, parameters.maximumScale);
</span><span class="cx">     dumpProperty(ts, &quot;allowsUserScaling&quot;, parameters.allowsUserScaling);
</span><ins>+    dumpProperty(ts, &quot;allowsShrinkToFit&quot;, parameters.allowsShrinkToFit);
</ins><span class="cx"> 
</span><span class="cx">     return ts;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorepageViewportConfigurationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/ViewportConfiguration.h (184653 => 184654)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/ViewportConfiguration.h        2015-05-20 20:34:40 UTC (rev 184653)
+++ trunk/Source/WebCore/page/ViewportConfiguration.h        2015-05-20 20:42:49 UTC (rev 184654)
</span><span class="lines">@@ -45,6 +45,7 @@
</span><span class="cx">             , minimumScale(0)
</span><span class="cx">             , maximumScale(0)
</span><span class="cx">             , allowsUserScaling(false)
</span><ins>+            , allowsShrinkToFit(false)
</ins><span class="cx">             , widthIsSet(false)
</span><span class="cx">             , heightIsSet(false)
</span><span class="cx">             , initialScaleIsSet(false)
</span><span class="lines">@@ -57,6 +58,7 @@
</span><span class="cx">         double minimumScale;
</span><span class="cx">         double maximumScale;
</span><span class="cx">         bool allowsUserScaling;
</span><ins>+        bool allowsShrinkToFit;
</ins><span class="cx"> 
</span><span class="cx">         bool widthIsSet;
</span><span class="cx">         bool heightIsSet;
</span><span class="lines">@@ -85,6 +87,7 @@
</span><span class="cx">     WEBCORE_EXPORT double minimumScale() const;
</span><span class="cx">     double maximumScale() const { return m_configuration.maximumScale; }
</span><span class="cx">     WEBCORE_EXPORT bool allowsUserScaling() const;
</span><ins>+    bool allowsShrinkToFit() const;
</ins><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT static Parameters webpageParameters();
</span><span class="cx">     WEBCORE_EXPORT static Parameters textDocumentParameters();
</span><span class="lines">@@ -96,7 +99,7 @@
</span><span class="cx">     WTF::CString description() const;
</span><span class="cx">     void dump() const;
</span><span class="cx"> #endif
</span><del>-    
</del><ins>+
</ins><span class="cx"> private:
</span><span class="cx">     void updateConfiguration();
</span><span class="cx">     double viewportArgumentsLength(double length) const;
</span></span></pre>
</div>
</div>

</body>
</html>