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

Side by Side Diff: third_party/WebKit/Source/core/css/cssom/CSSTranslation.cpp

Issue 2937383002: [CSS Typed OM] Add missing error handling in the CSSTranslation constructor (Closed)
Patch Set: rebase Created 3 years, 6 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/CSSTranslation.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/CSSTranslation.h" 5 #include "core/css/cssom/CSSTranslation.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "core/css/CSSPrimitiveValue.h" 8 #include "core/css/CSSPrimitiveValue.h"
9 #include "core/css/cssom/CSSNumericValue.h" 9 #include "core/css/cssom/CSSNumericValue.h"
10 10
11 namespace blink { 11 namespace blink {
12 12
13 CSSTranslation* CSSTranslation::Create(CSSNumericValue* x, 13 CSSTranslation* CSSTranslation::Create(CSSNumericValue* x,
14 CSSNumericValue* y, 14 CSSNumericValue* y,
15 CSSNumericValue* z, 15 CSSNumericValue* z,
16 ExceptionState& exception_state) { 16 ExceptionState& exception_state) {
17 if (z->ContainsPercent()) { 17 if ((x->GetType() != CSSStyleValue::StyleValueType::kLengthType &&
18 x->GetType() != CSSStyleValue::StyleValueType::kPercentType) ||
19 (y->GetType() != CSSStyleValue::StyleValueType::kLengthType &&
20 y->GetType() != CSSStyleValue::StyleValueType::kPercentType)) {
21 exception_state.ThrowTypeError(
22 "Must pass length or percentage to X and Y of CSSTranslation");
23 return nullptr;
24 }
25 if (z && z->GetType() != CSSStyleValue::StyleValueType::kLengthType) {
26 exception_state.ThrowTypeError("Must pass length to Z of CSSTranslation");
27 return nullptr;
28 }
29 if (z && z->ContainsPercent()) {
18 exception_state.ThrowTypeError( 30 exception_state.ThrowTypeError(
19 "CSSTranslation does not support z CSSNumericValue with percent units"); 31 "CSSTranslation does not support z CSSNumericValue with percent units");
20 return nullptr; 32 return nullptr;
21 } 33 }
22 return new CSSTranslation(x, y, z); 34 return new CSSTranslation(x, y, z);
23 } 35 }
24 36
25 CSSFunctionValue* CSSTranslation::ToCSSValue() const { 37 CSSFunctionValue* CSSTranslation::ToCSSValue() const {
26 CSSFunctionValue* result = CSSFunctionValue::Create( 38 CSSFunctionValue* result = CSSFunctionValue::Create(
27 Is2D() ? CSSValueTranslate : CSSValueTranslate3d); 39 Is2D() ? CSSValueTranslate : CSSValueTranslate3d);
28 result->Append(*x_->ToCSSValue()); 40 result->Append(*x_->ToCSSValue());
29 result->Append(*y_->ToCSSValue()); 41 result->Append(*y_->ToCSSValue());
30 if (!Is2D()) 42 if (!Is2D())
31 result->Append(*z_->ToCSSValue()); 43 result->Append(*z_->ToCSSValue());
32 return result; 44 return result;
33 } 45 }
34 46
35 } // namespace blink 47 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/cssom/CSSTranslation.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698