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

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: rename browser zoom to page zoom Created 6 years, 12 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/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..f10190a948d4c7fa5b62498a144fd5cc86d0989b 100644
--- a/Source/core/css/resolver/ViewportStyleResolver.cpp
+++ b/Source/core/css/resolver/ViewportStyleResolver.cpp
@@ -31,12 +31,14 @@
#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"
#include "core/dom/Document.h"
#include "core/dom/NodeRenderStyle.h"
#include "core/dom/ViewportDescription.h"
+#include "core/frame/FrameView.h"
namespace WebCore {
@@ -183,25 +185,25 @@ 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())
- 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);
- switch (primitiveValue->getValueID()) {
- case CSSValueInternalExtendToZoom:
- return Length(ExtendToZoom);
- case CSSValueAuto:
- return Length();
- default:
- // Unrecognized keyword.
- ASSERT_NOT_REACHED();
- return Length(0, Fixed);
- }
+ FrameView* view = m_document->view();
+ float width = view ? view->width() : 0;
+ float height = view ? view->height() : 0;
+
+ Length result = primitiveValue->convertToLength<AnyConversion>(CSSToLengthConversionData(documentStyle, documentStyle, width, height, 1.0f));
+ if (documentStyle->hasViewportUnits())
+ m_document->setHasViewportUnits();
+ documentStyle->setHasViewportUnits(documentStyleHasViewportUnits);
+
+ 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