| OLD | NEW |
| 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/CSSTransformValue.h" | 5 #include "core/css/cssom/CSSTransformValue.h" |
| 6 | 6 |
| 7 #include "core/css/CSSValueList.h" | 7 #include "core/css/CSSValueList.h" |
| 8 #include "core/css/cssom/CSSMatrixComponent.h" | |
| 9 #include "core/css/cssom/CSSTransformComponent.h" | 8 #include "core/css/cssom/CSSTransformComponent.h" |
| 10 #include "core/geometry/DOMMatrix.h" | 9 #include "core/geometry/DOMMatrix.h" |
| 11 | 10 |
| 12 namespace blink { | 11 namespace blink { |
| 13 | 12 |
| 14 CSSTransformValue* CSSTransformValue::FromCSSValue(const CSSValue& css_value) { | 13 CSSTransformValue* CSSTransformValue::FromCSSValue(const CSSValue& css_value) { |
| 15 if (!css_value.IsValueList()) { | 14 if (!css_value.IsValueList()) { |
| 16 // TODO(meade): Also need to check the separator here if we care. | 15 // TODO(meade): Also need to check the separator here if we care. |
| 17 return nullptr; | 16 return nullptr; |
| 18 } | 17 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 32 if (!transform_components_[i]->is2D()) { | 31 if (!transform_components_[i]->is2D()) { |
| 33 return false; | 32 return false; |
| 34 } | 33 } |
| 35 } | 34 } |
| 36 return true; | 35 return true; |
| 37 } | 36 } |
| 38 | 37 |
| 39 DOMMatrix* CSSTransformValue::toMatrix() const { | 38 DOMMatrix* CSSTransformValue::toMatrix() const { |
| 40 DOMMatrix* matrix = DOMMatrix::Create(); | 39 DOMMatrix* matrix = DOMMatrix::Create(); |
| 41 for (size_t i = 0; i < transform_components_.size(); i++) { | 40 for (size_t i = 0; i < transform_components_.size(); i++) { |
| 42 CSSMatrixComponent* matrixComponent = transform_components_[i]->asMatrix(); | 41 DOMMatrix* matrixComponent = transform_components_[i]->AsMatrix(); |
| 43 if (matrixComponent) { | 42 if (matrixComponent) { |
| 44 matrix->multiplySelf(matrixComponent->matrix()); | 43 matrix->multiplySelf(matrixComponent); |
| 45 } | 44 } |
| 46 } | 45 } |
| 47 return matrix; | 46 return matrix; |
| 48 } | 47 } |
| 49 | 48 |
| 50 const CSSValue* CSSTransformValue::ToCSSValue() const { | 49 const CSSValue* CSSTransformValue::ToCSSValue() const { |
| 51 CSSValueList* transform_css_value = CSSValueList::CreateSpaceSeparated(); | 50 CSSValueList* transform_css_value = CSSValueList::CreateSpaceSeparated(); |
| 52 for (size_t i = 0; i < transform_components_.size(); i++) { | 51 for (size_t i = 0; i < transform_components_.size(); i++) { |
| 53 const CSSValue* component = transform_components_[i]->ToCSSValue(); | 52 const CSSValue* component = transform_components_[i]->ToCSSValue(); |
| 54 // TODO(meade): Remove this check once numbers and lengths are rewritten. | 53 // TODO(meade): Remove this check once numbers and lengths are rewritten. |
| 55 if (!component) | 54 if (!component) |
| 56 return nullptr; | 55 return nullptr; |
| 57 transform_css_value->Append(*component); | 56 transform_css_value->Append(*component); |
| 58 } | 57 } |
| 59 return transform_css_value; | 58 return transform_css_value; |
| 60 } | 59 } |
| 61 | 60 |
| 62 } // namespace blink | 61 } // namespace blink |
| OLD | NEW |