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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/css/cssom/CSSRotation.h" 5 #include "core/css/cssom/CSSRotation.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "core/css/CSSFunctionValue.h" 8 #include "core/css/CSSFunctionValue.h"
9 #include "core/css/CSSPrimitiveValue.h" 9 #include "core/css/CSSPrimitiveValue.h"
10 #include "core/css/cssom/CSSUnitValue.h"
11 #include "core/geometry/DOMMatrix.h"
10 12
11 namespace blink { 13 namespace blink {
12 14
13 namespace { 15 namespace {
14 16
15 bool IsNumberValue(const CSSValue& value) { 17 bool IsNumberValue(const CSSValue& value) {
16 return value.IsPrimitiveValue() && ToCSSPrimitiveValue(value).IsNumber(); 18 return value.IsPrimitiveValue() && ToCSSPrimitiveValue(value).IsNumber();
17 } 19 }
18 20
19 CSSRotation* FromCSSRotate(const CSSFunctionValue& value) { 21 CSSRotation* FromCSSRotate(const CSSFunctionValue& value) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 exception_state.ThrowTypeError("Must pass an angle to CSSRotation"); 119 exception_state.ThrowTypeError("Must pass an angle to CSSRotation");
118 return; 120 return;
119 } 121 }
120 if (angle->IsCalculated()) { 122 if (angle->IsCalculated()) {
121 exception_state.ThrowTypeError("Calculated angles are not supported yet"); 123 exception_state.ThrowTypeError("Calculated angles are not supported yet");
122 return; 124 return;
123 } 125 }
124 angle_ = angle; 126 angle_ = angle;
125 } 127 }
126 128
129 DOMMatrix* CSSRotation::AsMatrix() const {
130 DOMMatrix* matrix = DOMMatrix::Create();
131 CSSUnitValue* angle = angle_->to(CSSPrimitiveValue::UnitType::kDegrees);
132 if (is2D()) {
133 matrix->rotateAxisAngleSelf(0, 0, 1, angle->value());
134 } else {
135 matrix->rotateAxisAngleSelf(x_, y_, z_, angle->value());
136 }
137 return matrix;
138 }
139
127 CSSFunctionValue* CSSRotation::ToCSSValue() const { 140 CSSFunctionValue* CSSRotation::ToCSSValue() const {
128 return nullptr; 141 // TODO(meade): Handle calc angles.
129 // TODO(meade): Re-implement this when we finish rewriting number/length 142 CSSUnitValue* angle = ToCSSUnitValue(angle_);
130 // types. 143 CSSFunctionValue* result =
131 // CSSFunctionValue* result = 144 CSSFunctionValue::Create(is2D() ? CSSValueRotate : CSSValueRotate3d);
132 // CSSFunctionValue::Create(is2D() ? CSSValueRotate : CSSValueRotate3d); 145 if (!is2D()) {
133 // if (!is2D()) { 146 result->Append(
134 // result->Append( 147 *CSSPrimitiveValue::Create(x_, CSSPrimitiveValue::UnitType::kNumber));
135 // *CSSPrimitiveValue::Create(x_, CSSPrimitiveValue::UnitType::kNumber)); 148 result->Append(
136 // result->Append( 149 *CSSPrimitiveValue::Create(y_, CSSPrimitiveValue::UnitType::kNumber));
137 // *CSSPrimitiveValue::Create(y_, CSSPrimitiveValue::UnitType::kNumber)); 150 result->Append(
138 // result->Append( 151 *CSSPrimitiveValue::Create(z_, CSSPrimitiveValue::UnitType::kNumber));
139 // *CSSPrimitiveValue::Create(z_, CSSPrimitiveValue::UnitType::kNumber)); 152 }
140 // } 153 result->Append(
141 // result->Append(*CSSPrimitiveValue::Create(angle_->Value(), 154 *CSSPrimitiveValue::Create(angle->value(), angle->GetInternalUnit()));
142 // angle_->Unit())); 155 return result;
143 // return result;
144 } 156 }
145 157
146 } // namespace blink 158 } // namespace blink
OLDNEW
« 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