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

Unified Diff: third_party/WebKit/Source/core/css/cssom/LengthValue.cpp

Issue 1689573002: CSS Typed OM: asMatrix for TransformComponent with LengthValue types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@asMatrixMethod
Patch Set: Add in Translation and use exceptionState.hadException Created 4 years, 10 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
Index: third_party/WebKit/Source/core/css/cssom/LengthValue.cpp
diff --git a/third_party/WebKit/Source/core/css/cssom/LengthValue.cpp b/third_party/WebKit/Source/core/css/cssom/LengthValue.cpp
index 637f5076a9d7baa48b920d3c8836f105a2ee2146..786514aa1979893e45e4bd9bd96f4cce7fc22311 100644
--- a/third_party/WebKit/Source/core/css/cssom/LengthValue.cpp
+++ b/third_party/WebKit/Source/core/css/cssom/LengthValue.cpp
@@ -5,9 +5,12 @@
#include "core/css/cssom/LengthValue.h"
#include "bindings/core/v8/ExceptionState.h"
+#include "core/css/CSSPrimitiveValue.h"
+#include "core/css/CSSToLengthConversionData.h"
#include "core/css/cssom/CalcDictionary.h"
#include "core/css/cssom/SimpleLength.h"
#include "core/css/cssom/StyleCalcLength.h"
+#include "core/style/ComputedStyle.h"
#include "wtf/HashMap.h"
namespace blink {
@@ -64,6 +67,23 @@ LengthValue* LengthValue::divide(double x, ExceptionState& exceptionState)
return divideInternal(x, exceptionState);
}
+double LengthValue::computeLengthPx(ExceptionState& exceptionState) const
+{
+ if (isRelative()) {
+ // TODO: Resolve relative units to a pixel value.
+ exceptionState.throwTypeError("Cannot resolve a relative unit to a pixel value.");
+ return 0;
+ }
+
+ CSSValue* cssValue = toCSSValue();
+ CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(cssValue);
+ ComputedStyle* computedStyle = const_cast<ComputedStyle*>(ComputedStyle::create().get());
+ CSSToLengthConversionData conversionData = CSSToLengthConversionData(computedStyle,
+ CSSToLengthConversionData::FontSizes(), CSSToLengthConversionData::ViewportSize(), 1);
+
+ return primitiveValue->CSSPrimitiveValue::computeLength<double>(conversionData);
+}
+
LengthValue* LengthValue::addInternal(const LengthValue*, ExceptionState&)
{
ASSERT_NOT_REACHED();

Powered by Google App Engine
This is Rietveld 408576698