Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(506)

Unified Diff: Source/core/css/resolver/ViewportStyleResolver.cpp

Issue 23604037: Recompute percentage based @viewport on resize. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed review issue Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/css/resolver/ViewportStyleResolver.h ('k') | Source/core/dom/ViewportArguments.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/resolver/ViewportStyleResolver.cpp
diff --git a/Source/core/css/resolver/ViewportStyleResolver.cpp b/Source/core/css/resolver/ViewportStyleResolver.cpp
index 34239374452d71ee590cdda4ac0ae685e9848c03..250edd19cab1e0f5ed4baee47a93766eccb40976 100644
--- a/Source/core/css/resolver/ViewportStyleResolver.cpp
+++ b/Source/core/css/resolver/ViewportStyleResolver.cpp
@@ -92,15 +92,15 @@ void ViewportStyleResolver::resolve()
ViewportArguments arguments(ViewportArguments::CSSDeviceAdaptation);
- arguments.userZoom = getViewportArgumentValue(CSSPropertyUserZoom);
- arguments.zoom = getViewportArgumentValue(CSSPropertyZoom);
- arguments.minZoom = getViewportArgumentValue(CSSPropertyMinZoom);
- arguments.maxZoom = getViewportArgumentValue(CSSPropertyMaxZoom);
- arguments.minWidth = getViewportArgumentValue(CSSPropertyMinWidth);
- arguments.maxWidth = getViewportArgumentValue(CSSPropertyMaxWidth);
- arguments.minHeight = getViewportArgumentValue(CSSPropertyMinHeight);
- arguments.maxHeight = getViewportArgumentValue(CSSPropertyMaxHeight);
- arguments.orientation = getViewportArgumentValue(CSSPropertyOrientation);
+ arguments.userZoom = viewportArgumentValue(CSSPropertyUserZoom);
+ arguments.zoom = viewportArgumentValue(CSSPropertyZoom);
+ arguments.minZoom = viewportArgumentValue(CSSPropertyMinZoom);
+ arguments.maxZoom = viewportArgumentValue(CSSPropertyMaxZoom);
+ arguments.minWidth = viewportLengthValue(CSSPropertyMinWidth);
+ arguments.maxWidth = viewportLengthValue(CSSPropertyMaxWidth);
+ arguments.minHeight = viewportLengthValue(CSSPropertyMinHeight);
+ arguments.maxHeight = viewportLengthValue(CSSPropertyMaxHeight);
+ arguments.orientation = viewportArgumentValue(CSSPropertyOrientation);
m_document->setViewportArguments(arguments);
m_document->updateViewportArguments();
@@ -108,7 +108,7 @@ void ViewportStyleResolver::resolve()
m_propertySet = 0;
}
-float ViewportStyleResolver::getViewportArgumentValue(CSSPropertyID id) const
+float ViewportStyleResolver::viewportArgumentValue(CSSPropertyID id) const
{
float defaultValue = ViewportArguments::ValueAuto;
@@ -133,12 +133,6 @@ float ViewportStyleResolver::getViewportArgumentValue(CSSPropertyID id) const
if (primitiveValue->isPercentage()) {
float percentValue = primitiveValue->getFloatValue() / 100.0f;
switch (id) {
- case CSSPropertyMaxHeight:
- case CSSPropertyMinHeight:
- return percentValue * m_document->initialViewportSize().height();
- case CSSPropertyMaxWidth:
- case CSSPropertyMinWidth:
- return percentValue * m_document->initialViewportSize().width();
case CSSPropertyMaxZoom:
case CSSPropertyMinZoom:
case CSSPropertyZoom:
@@ -167,4 +161,38 @@ float ViewportStyleResolver::getViewportArgumentValue(CSSPropertyID id) const
}
}
+Length ViewportStyleResolver::viewportLengthValue(CSSPropertyID id) const
+{
+ ASSERT(id == CSSPropertyMaxHeight
+ || id == CSSPropertyMinHeight
+ || id == CSSPropertyMaxWidth
+ || id == CSSPropertyMinWidth);
+
+ RefPtr<CSSValue> value = m_propertySet->getPropertyCSSValue(id);
+ if (!value || !value->isPrimitiveValue())
+ return Length(); // auto
+
+ CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value.get());
+
+ if (primitiveValue->isLength())
+ return primitiveValue->computeLength<Length>(m_document->renderStyle(), m_document->renderStyle());
+
+ if (primitiveValue->isViewportPercentageLength())
+ return primitiveValue->viewportPercentageLength();
+
+ if (primitiveValue->isPercentage())
+ return Length(primitiveValue->getFloatValue(), Percent);
+
+ switch (primitiveValue->getValueID()) {
+ case CSSValueInternalExtendToZoom:
+ return Length(ExtendToZoom);
+ case CSSValueAuto:
+ return Length();
+ default:
+ // Unrecognized keyword.
+ ASSERT_NOT_REACHED();
+ return Length(0, Fixed);
+ }
+}
+
} // namespace WebCore
« no previous file with comments | « Source/core/css/resolver/ViewportStyleResolver.h ('k') | Source/core/dom/ViewportArguments.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698