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

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

Issue 82083002: Move viewport unit resolution to style recalc time (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: add test for browser zoom 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
« no previous file with comments | « Source/core/css/resolver/StyleResolverState.cpp ('k') | Source/core/dom/Document.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 61894a2458a283c32027c6837af2366d13c7fd3a..f10f893d59855b3cef374193f98895c14d422e47 100644
--- a/Source/core/css/resolver/ViewportStyleResolver.cpp
+++ b/Source/core/css/resolver/ViewportStyleResolver.cpp
@@ -31,6 +31,7 @@
#include "core/css/resolver/ViewportStyleResolver.h"
#include "CSSValueKeywords.h"
+#include "core/css/CSSPrimitiveValueMappings.h"
#include "core/css/CSSToLengthConversionData.h"
#include "core/css/StylePropertySet.h"
#include "core/css/StyleRule.h"
@@ -183,25 +184,21 @@ Length ViewportStyleResolver::viewportLengthValue(CSSPropertyID id) const
CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value.get());
- if (primitiveValue->isLength())
- return primitiveValue->computeLength<Length>(CSSToLengthConversionData(m_document->renderStyle(), m_document->renderStyle(), 1.0f));
+ if (primitiveValue->getValueID() == CSSValueInternalExtendToZoom)
+ return Length(ExtendToZoom);
- if (primitiveValue->isViewportPercentageLength())
kenneth.r.christiansen 2013/12/18 07:16:19 Are we still supporting @viewport { width: 50%; }
Timothy Loh 2013/12/18 07:18:27 This gets converted in primitiveValue->convertToLe
- return primitiveValue->viewportPercentageLength();
+ RenderStyle* documentStyle = m_document->renderStyle();
- if (primitiveValue->isPercentage())
- return Length(primitiveValue->getFloatValue(), Percent);
+ // If we have viewport units the conversion will mark the document style as having viewport units.
+ bool documentStyleHasViewportUnits = documentStyle->hasViewportUnits();
+ documentStyle->setHasViewportUnits(false);
+ Length result = primitiveValue->convertToLength<AnyConversion>(CSSToLengthConversionData(documentStyle, documentStyle, m_document->renderView(), 1.0f));
+ if (documentStyle->hasViewportUnits())
+ m_document->setHasViewportUnits();
+ documentStyle->setHasViewportUnits(documentStyleHasViewportUnits);
- switch (primitiveValue->getValueID()) {
- case CSSValueInternalExtendToZoom:
- return Length(ExtendToZoom);
- case CSSValueAuto:
- return Length();
- default:
- // Unrecognized keyword.
- ASSERT_NOT_REACHED();
- return Length(0, Fixed);
- }
+ ASSERT(!result.isUndefined());
+ return result;
}
} // namespace WebCore
« no previous file with comments | « Source/core/css/resolver/StyleResolverState.cpp ('k') | Source/core/dom/Document.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698