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

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

Issue 2047923002: [WIP] Add support for CSSValue-> CSSLengthValue and CSSTranslation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@supported-types
Patch Set: Created 4 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/StyleValueFactory.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/StyleValueFactory.h" 5 #include "core/css/cssom/StyleValueFactory.h"
6 6
7 #include "core/css/CSSValue.h" 7 #include "core/css/CSSValue.h"
8 #include "core/css/cssom/CSSSimpleLength.h" 8 #include "core/css/cssom/CSSLengthValue.h"
9 #include "core/css/cssom/CSSStyleValue.h" 9 #include "core/css/cssom/CSSStyleValue.h"
10 #include "core/css/cssom/TransformValue.h" 10 #include "core/css/cssom/TransformValue.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 CSSStyleValueVector StyleValueFactory::cssValueToStyleValueVector(CSSPropertyID propertyID, const CSSValue& value) 14 CSSStyleValueVector StyleValueFactory::cssValueToStyleValueVector(CSSPropertyID propertyID, const CSSValue& value)
15 { 15 {
16 CSSStyleValueVector styleValueVector; 16 CSSStyleValueVector styleValueVector;
17 17
18 if (value.isPrimitiveValue()) { 18 if (value.isPrimitiveValue()) {
19 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); 19 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
20 if (primitiveValue.isLength() && !primitiveValue.isCalculated()) { 20 if (primitiveValue.isLength()) {
21 styleValueVector.append(CSSSimpleLength::create(primitiveValue.getDo ubleValue(), primitiveValue.typeWithCalcResolved())); 21 styleValueVector.append(CSSLengthValue::fromCSSValue(value));
22 return styleValueVector; 22 return styleValueVector;
23 } 23 }
24 } 24 }
25 25
26 switch (propertyID) { 26 switch (propertyID) {
27 case CSSPropertyTransform: 27 case CSSPropertyTransform:
28 styleValueVector.append(TransformValue::fromCSSValue(value)); 28 styleValueVector.append(TransformValue::fromCSSValue(value));
29 break; 29 break;
30 default: 30 default:
31 // TODO(meade): Implement the rest. 31 // TODO(meade): Implement the rest.
32 break; 32 break;
33 } 33 }
34 return styleValueVector; 34 return styleValueVector;
35 } 35 }
36 36
37 CSSStyleValue* StyleValueFactory::cssValueToSingleStyleValue(CSSPropertyID prope rtyID, const CSSValue& value)
38 {
39 CSSStyleValueVector styleValueVector = StyleValueFactory::cssValueToStyleVal ueVector(propertyID, value);
40 if (styleValueVector.size() != 1)
41 return nullptr;
42
43 return styleValueVector[0];
44 }
45
37 } // namespace blink 46 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/cssom/StyleValueFactory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698