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

Unified Diff: Source/core/dom/ViewportDescription.cpp

Issue 82083002: Move viewport unit resolution to style recalc time (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: Created 7 years 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
Index: Source/core/dom/ViewportDescription.cpp
diff --git a/Source/core/dom/ViewportDescription.cpp b/Source/core/dom/ViewportDescription.cpp
index 77f924e623ba812de4200e337901fd69f67722f3..0c5b1d5cbdbb674dd97036ec284fb36d818f8a9d 100644
--- a/Source/core/dom/ViewportDescription.cpp
+++ b/Source/core/dom/ViewportDescription.cpp
@@ -54,17 +54,17 @@ float ViewportDescription::resolveViewportLength(const Length& length, const Flo
if (length.type() == ExtendToZoom)
return ViewportDescription::ValueExtendToZoom;
- if ((length.type() == Percent && direction == Horizontal) || length.type() == ViewportPercentageWidth)
- return initialViewportSize.width() * length.getFloatValue() / 100.0f;
-
- if ((length.type() == Percent && direction == Vertical) || length.type() == ViewportPercentageHeight)
- return initialViewportSize.height() * length.getFloatValue() / 100.0f;
-
- if (length.type() == ViewportPercentageMin)
- return min(initialViewportSize.width(), initialViewportSize.height()) * length.viewportPercentageLength() / 100.0f;
-
- if (length.type() == ViewportPercentageMax)
- return max(initialViewportSize.width(), initialViewportSize.height()) * length.viewportPercentageLength() / 100.0f;
+ if (length.type() == Percent) {
+ float value = length.getFloatValue();
+ if (value >= 0 && direction == Horizontal)
+ return initialViewportSize.width() * length.getFloatValue() / 100.0f;
+ if (value >= 0 && direction == Vertical)
+ return initialViewportSize.height() * length.getFloatValue() / 100.0f;
+ if (value == -1)
+ return initialViewportSize.width();
+ if (value == -2)
+ return initialViewportSize.height();
+ }
ASSERT_NOT_REACHED();
return ViewportDescription::ValueAuto;

Powered by Google App Engine
This is Rietveld 408576698