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

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

Issue 2514043002: [CSS Typed OM] Add CSSValue->CSSSkew conversions (Closed)
Patch Set: Created 4 years, 1 month 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 | « third_party/WebKit/Source/core/css/cssom/CSSSkew.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/css/cssom/CSSSkew.cpp
diff --git a/third_party/WebKit/Source/core/css/cssom/CSSSkew.cpp b/third_party/WebKit/Source/core/css/cssom/CSSSkew.cpp
index cfd66913b82358efa92a20fa69bd0a14e9f2a4ce..0af914aeddd8872758fd76106048a1b45c035ca1 100644
--- a/third_party/WebKit/Source/core/css/cssom/CSSSkew.cpp
+++ b/third_party/WebKit/Source/core/css/cssom/CSSSkew.cpp
@@ -6,15 +6,53 @@
#include "core/css/CSSFunctionValue.h"
#include "core/css/CSSPrimitiveValue.h"
+#include "core/css/cssom/CSSAngleValue.h"
namespace blink {
+CSSSkew* CSSSkew::fromCSSValue(const CSSFunctionValue& value) {
+ const CSSPrimitiveValue& xValue = toCSSPrimitiveValue(value.item(0));
+ if (xValue.isCalculated()) {
Timothy Loh 2016/11/29 03:49:37 Maybe add a TODO to handle this and the below calc
meade_UTC10 2016/11/29 05:18:03 Done.
+ return nullptr;
+ }
+ DCHECK(xValue.isAngle());
+ switch (value.functionType()) {
+ case CSSValueSkew:
+ if (value.length() == 2U) {
+ const CSSPrimitiveValue& yValue = toCSSPrimitiveValue(value.item(1));
+ if (yValue.isCalculated()) {
+ return nullptr;
+ }
+ DCHECK(yValue.isAngle());
+ return CSSSkew::create(
+ CSSAngleValue::create(xValue.getDoubleValue(),
+ xValue.typeWithCalcResolved()),
+ CSSAngleValue::create(yValue.getDoubleValue(),
+ yValue.typeWithCalcResolved()));
+ }
+ // Else fall through; skew(ax) == skewX(ax).
+ case CSSValueSkewX:
+ DCHECK_EQ(value.length(), 1U);
+ return CSSSkew::create(
+ CSSAngleValue::create(xValue.getDoubleValue(),
+ xValue.typeWithCalcResolved()),
+ CSSAngleValue::create(0, CSSPrimitiveValue::UnitType::Degrees));
+ case CSSValueSkewY:
+ DCHECK_EQ(value.length(), 1U);
+ return CSSSkew::create(
+ CSSAngleValue::create(0, CSSPrimitiveValue::UnitType::Degrees),
+ CSSAngleValue::create(xValue.getDoubleValue(),
+ xValue.typeWithCalcResolved()));
+ default:
+ NOTREACHED();
+ return nullptr;
+ }
+}
+
CSSFunctionValue* CSSSkew::toCSSValue() const {
CSSFunctionValue* result = CSSFunctionValue::create(CSSValueSkew);
- result->append(*CSSPrimitiveValue::create(
- m_ax->degrees(), CSSPrimitiveValue::UnitType::Number));
- result->append(*CSSPrimitiveValue::create(
- m_ay->degrees(), CSSPrimitiveValue::UnitType::Number));
+ result->append(*CSSPrimitiveValue::create(m_ax->value(), m_ax->unit()));
+ result->append(*CSSPrimitiveValue::create(m_ay->value(), m_ay->unit()));
return result;
}
« no previous file with comments | « third_party/WebKit/Source/core/css/cssom/CSSSkew.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698