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

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

Issue 2957603002: [CSS Typed OM] Re-implement ToCSSValue and AsMatrix for CSSRotation (Closed)
Patch Set: rebase Created 3 years, 5 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 | « third_party/WebKit/Source/core/css/cssom/CSSRotation.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/CSSRotation.cpp
diff --git a/third_party/WebKit/Source/core/css/cssom/CSSRotation.cpp b/third_party/WebKit/Source/core/css/cssom/CSSRotation.cpp
index 367e98477227c9e316c0d263551f7c6a02be57ff..32d606bec37084b3db8a9cfd49c0c8f841d2533e 100644
--- a/third_party/WebKit/Source/core/css/cssom/CSSRotation.cpp
+++ b/third_party/WebKit/Source/core/css/cssom/CSSRotation.cpp
@@ -7,6 +7,8 @@
#include "bindings/core/v8/ExceptionState.h"
#include "core/css/CSSFunctionValue.h"
#include "core/css/CSSPrimitiveValue.h"
+#include "core/css/cssom/CSSUnitValue.h"
+#include "core/geometry/DOMMatrix.h"
namespace blink {
@@ -124,23 +126,33 @@ void CSSRotation::setAngle(CSSNumericValue* angle,
angle_ = angle;
}
+DOMMatrix* CSSRotation::AsMatrix() const {
+ DOMMatrix* matrix = DOMMatrix::Create();
+ CSSUnitValue* angle = angle_->to(CSSPrimitiveValue::UnitType::kDegrees);
+ if (is2D()) {
+ matrix->rotateAxisAngleSelf(0, 0, 1, angle->value());
+ } else {
+ matrix->rotateAxisAngleSelf(x_, y_, z_, angle->value());
+ }
+ return matrix;
+}
+
CSSFunctionValue* CSSRotation::ToCSSValue() const {
- return nullptr;
- // TODO(meade): Re-implement this when we finish rewriting number/length
- // types.
- // CSSFunctionValue* result =
- // CSSFunctionValue::Create(is2D() ? CSSValueRotate : CSSValueRotate3d);
- // if (!is2D()) {
- // result->Append(
- // *CSSPrimitiveValue::Create(x_, CSSPrimitiveValue::UnitType::kNumber));
- // result->Append(
- // *CSSPrimitiveValue::Create(y_, CSSPrimitiveValue::UnitType::kNumber));
- // result->Append(
- // *CSSPrimitiveValue::Create(z_, CSSPrimitiveValue::UnitType::kNumber));
- // }
- // result->Append(*CSSPrimitiveValue::Create(angle_->Value(),
- // angle_->Unit()));
- // return result;
+ // TODO(meade): Handle calc angles.
+ CSSUnitValue* angle = ToCSSUnitValue(angle_);
+ CSSFunctionValue* result =
+ CSSFunctionValue::Create(is2D() ? CSSValueRotate : CSSValueRotate3d);
+ if (!is2D()) {
+ result->Append(
+ *CSSPrimitiveValue::Create(x_, CSSPrimitiveValue::UnitType::kNumber));
+ result->Append(
+ *CSSPrimitiveValue::Create(y_, CSSPrimitiveValue::UnitType::kNumber));
+ result->Append(
+ *CSSPrimitiveValue::Create(z_, CSSPrimitiveValue::UnitType::kNumber));
+ }
+ result->Append(
+ *CSSPrimitiveValue::Create(angle->value(), angle->GetInternalUnit()));
+ return result;
}
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/css/cssom/CSSRotation.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698