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<<):
(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.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@184654
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2015-05-20 Tim Horton <timothy_horton@apple.com>
+
+ 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<<):
+ (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.
+
2015-05-20 Antti Koivisto <antti@apple.com>
Assertion failure in WebCore::BidiRun::BidiRun()
float resultZoom = zoom;
float resultMinZoom = minZoom;
float resultMaxZoom = maxZoom;
- float resultUserZoom = userZoom;
switch (int(resultWidth)) {
case ViewportArguments::ValueDeviceWidth:
// if (resultZoom == ViewportArguments::ValueAuto)
// result.initialScale = ViewportArguments::ValueAuto;
- result.userScalable = resultUserZoom;
+ result.userScalable = userZoom;
result.orientation = orientation;
+ result.shrinkToFit = shrinkToFit;
return result;
}
return value;
}
-static float findUserScalableValue(const String& keyString, const String& valueString, Document* document)
+static float findBooleanValue(const String& keyString, const String& valueString, Document* document)
{
// yes and no are used as keywords.
// Numbers >= 1, numbers <= -1, device-width and device-height are mapped to yes.
else if (keyString == "maximum-scale")
arguments->maxZoom = findScaleValue(keyString, valueString, document);
else if (keyString == "user-scalable")
- arguments->userZoom = findUserScalableValue(keyString, valueString, document);
+ arguments->userZoom = findBooleanValue(keyString, valueString, document);
#if PLATFORM(IOS)
else if (keyString == "minimal-ui")
- // FIXME: Ignore silently for now. This should eventually fallback to the warning.
+ // FIXME: Ignore silently for now. This should eventually fall back to the warning.
{ }
#endif
+ else if (keyString == "shrink-to-fit")
+ arguments->shrinkToFit = findBooleanValue(keyString, valueString, document);
else
reportViewportWarning(document, UnrecognizedViewportArgumentKeyError, keyString, String());
}
float userScalable;
float orientation;
+ float shrinkToFit;
};
struct ViewportArguments {
explicit ViewportArguments(Type type = Implicit)
: type(type)
- , width(ValueAuto)
- , minWidth(ValueAuto)
- , maxWidth(ValueAuto)
- , height(ValueAuto)
- , minHeight(ValueAuto)
- , maxHeight(ValueAuto)
- , zoom(ValueAuto)
- , minZoom(ValueAuto)
- , maxZoom(ValueAuto)
- , userZoom(ValueAuto)
- , orientation(ValueAuto)
{
}
// All arguments are in CSS units.
ViewportAttributes resolve(const FloatSize& initialViewportSize, const FloatSize& deviceSize, int defaultWidth) const;
- float width;
- float minWidth;
- float maxWidth;
- float height;
- float minHeight;
- float maxHeight;
- float zoom;
- float minZoom;
- float maxZoom;
- float userZoom;
- float orientation;
+ 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 };
bool operator==(const ViewportArguments& other) const
{
&& minZoom == other.minZoom
&& maxZoom == other.maxZoom
&& userZoom == other.userZoom
- && orientation == other.orientation;
+ && orientation == other.orientation
+ && shrinkToFit == other.shrinkToFit;
}
bool operator!=(const ViewportArguments& other) const
if (!m_canIgnoreScalingConstraints)
return false;
+ if (!m_configuration.allowsShrinkToFit)
+ return false;
+
bool laidOutWiderThanViewport = m_contentSize.width() > layoutWidth();
if (m_viewportArguments.width == ViewportArguments::ValueDeviceWidth)
return laidOutWiderThanViewport;
if (!m_canIgnoreScalingConstraints)
return false;
+ if (!m_configuration.allowsShrinkToFit)
+ return false;
+
bool laidOutTallerThanViewport = m_contentSize.height() > layoutHeight();
if (m_viewportArguments.height == ViewportArguments::ValueDeviceHeight && m_viewportArguments.width == ViewportArguments::ValueAuto)
return laidOutTallerThanViewport;
parameters.width = 980;
parameters.widthIsSet = true;
parameters.allowsUserScaling = true;
+ parameters.allowsShrinkToFit = true;
parameters.minimumScale = 0.25;
parameters.maximumScale = 5;
return parameters;
parameters.widthIsSet = true;
parameters.allowsUserScaling = true;
+ parameters.allowsShrinkToFit = false;
parameters.minimumScale = 0.25;
parameters.maximumScale = 5;
return parameters;
parameters.width = 980;
parameters.widthIsSet = true;
parameters.allowsUserScaling = true;
+ parameters.allowsShrinkToFit = false;
parameters.minimumScale = 0.01;
parameters.maximumScale = 5;
return parameters;
Parameters parameters;
parameters.initialScale = 1;
parameters.initialScaleIsSet = true;
+ parameters.allowsShrinkToFit = true;
parameters.minimumScale = 1;
parameters.maximumScale = 5;
return parameters;
valueIsSet = false;
}
-static inline bool viewportArgumentUserZoomIsSet(float value)
+static inline bool booleanViewportArgumentIsSet(float value)
{
return !value || value == 1;
}
m_configuration.heightIsSet = viewportArgumentsOverridesHeight;
}
- if (viewportArgumentUserZoomIsSet(m_viewportArguments.userZoom))
+ if (booleanViewportArgumentIsSet(m_viewportArguments.userZoom))
m_configuration.allowsUserScaling = m_viewportArguments.userZoom != 0.;
+
+ if (booleanViewportArgumentIsSet(m_viewportArguments.shrinkToFit))
+ m_configuration.allowsShrinkToFit = m_viewportArguments.shrinkToFit != 0.;
}
double ViewportConfiguration::viewportArgumentsLength(double length) const
dumpProperty(ts, "minimumScale", parameters.minimumScale);
dumpProperty(ts, "maximumScale", parameters.maximumScale);
dumpProperty(ts, "allowsUserScaling", parameters.allowsUserScaling);
+ dumpProperty(ts, "allowsShrinkToFit", parameters.allowsShrinkToFit);
return ts;
}
, minimumScale(0)
, maximumScale(0)
, allowsUserScaling(false)
+ , allowsShrinkToFit(false)
, widthIsSet(false)
, heightIsSet(false)
, initialScaleIsSet(false)
double minimumScale;
double maximumScale;
bool allowsUserScaling;
+ bool allowsShrinkToFit;
bool widthIsSet;
bool heightIsSet;
WEBCORE_EXPORT double minimumScale() const;
double maximumScale() const { return m_configuration.maximumScale; }
WEBCORE_EXPORT bool allowsUserScaling() const;
+ bool allowsShrinkToFit() const;
WEBCORE_EXPORT static Parameters webpageParameters();
WEBCORE_EXPORT static Parameters textDocumentParameters();
WTF::CString description() const;
void dump() const;
#endif
-
+
private:
void updateConfiguration();
double viewportArgumentsLength(double length) const;