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

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

Issue 2373233002: Add fromCSSValue methods to LengthValue subclasses, remove extra method in CSSSimpleLength. (Closed)
Patch Set: Update test expectations, remove extra includes and unused args Created 4 years, 2 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/CSSSimpleLength.idl ('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/CSSImageValue.h" 7 #include "core/css/CSSImageValue.h"
8 #include "core/css/CSSValue.h" 8 #include "core/css/CSSValue.h"
9 #include "core/css/cssom/CSSNumberValue.h" 9 #include "core/css/cssom/CSSNumberValue.h"
10 #include "core/css/cssom/CSSSimpleLength.h" 10 #include "core/css/cssom/CSSSimpleLength.h"
11 #include "core/css/cssom/CSSStyleValue.h" 11 #include "core/css/cssom/CSSStyleValue.h"
12 #include "core/css/cssom/CSSStyleVariableReferenceValue.h" 12 #include "core/css/cssom/CSSStyleVariableReferenceValue.h"
13 #include "core/css/cssom/CSSTransformValue.h" 13 #include "core/css/cssom/CSSTransformValue.h"
14 #include "core/css/cssom/CSSURLImageValue.h" 14 #include "core/css/cssom/CSSURLImageValue.h"
15 #include "core/css/cssom/CSSUnparsedValue.h" 15 #include "core/css/cssom/CSSUnparsedValue.h"
16 #include "core/css/cssom/CSSUnsupportedStyleValue.h" 16 #include "core/css/cssom/CSSUnsupportedStyleValue.h"
17 17
18 namespace blink { 18 namespace blink {
19 19
20 namespace { 20 namespace {
21 21
22 CSSStyleValue* styleValueForPrimitiveValue(const CSSPrimitiveValue& primitiveVal ue)
23 {
24 if (primitiveValue.isNumber())
25 return CSSNumberValue::create(primitiveValue.getDoubleValue());
26 if (primitiveValue.isLength())
27 return CSSSimpleLength::fromCSSValue(primitiveValue);
28
29 return nullptr;
30 }
31
22 CSSStyleValue* styleValueForProperty(CSSPropertyID propertyID, const CSSValue& v alue) 32 CSSStyleValue* styleValueForProperty(CSSPropertyID propertyID, const CSSValue& v alue)
23 { 33 {
24 switch (propertyID) { 34 switch (propertyID) {
25 case CSSPropertyTransform: 35 case CSSPropertyTransform:
26 return CSSTransformValue::fromCSSValue(value); 36 return CSSTransformValue::fromCSSValue(value);
27 default: 37 default:
28 // TODO(meade): Implement other complex properties. 38 // TODO(meade): Implement other complex properties.
29 break; 39 break;
30 } 40 }
31 41
32 if (value.isPrimitiveValue()) { 42 if (value.isPrimitiveValue())
33 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); 43 return styleValueForPrimitiveValue(toCSSPrimitiveValue(value));
34 if (primitiveValue.isLength() && !primitiveValue.isCalculated()) 44 if (value.isVariableReferenceValue())
35 return CSSSimpleLength::create(primitiveValue.getDoubleValue(), prim itiveValue.typeWithCalcResolved());
36 if (primitiveValue.isNumber())
37 return CSSNumberValue::create(primitiveValue.getDoubleValue());
38 }
39
40 if (value.isVariableReferenceValue()) {
41 return CSSUnparsedValue::fromCSSValue(toCSSVariableReferenceValue(value) ); 45 return CSSUnparsedValue::fromCSSValue(toCSSVariableReferenceValue(value) );
42 } 46 if (value.isImageValue())
43 47 return CSSURLImageValue::create(toCSSImageValue(value).valueWithURLMadeA bsolute());
44 if (value.isImageValue()) {
45 const CSSImageValue& imageValue = toCSSImageValue(value);
46 return CSSURLImageValue::create(imageValue.valueWithURLMadeAbsolute());
47 }
48 48
49 return nullptr; 49 return nullptr;
50 } 50 }
51 51
52 CSSStyleValueVector unsupportedCSSValue(const CSSValue& value) 52 CSSStyleValueVector unsupportedCSSValue(const CSSValue& value)
53 { 53 {
54 CSSStyleValueVector styleValueVector; 54 CSSStyleValueVector styleValueVector;
55 styleValueVector.append(CSSUnsupportedStyleValue::create(value.cssText())); 55 styleValueVector.append(CSSUnsupportedStyleValue::create(value.cssText()));
56 return styleValueVector; 56 return styleValueVector;
57 } 57 }
(...skipping 19 matching lines...) Expand all
77 styleValue = styleValueForProperty(propertyID, *innerValue); 77 styleValue = styleValueForProperty(propertyID, *innerValue);
78 if (!styleValue) { 78 if (!styleValue) {
79 return unsupportedCSSValue(value); 79 return unsupportedCSSValue(value);
80 } 80 }
81 styleValueVector.append(styleValue); 81 styleValueVector.append(styleValue);
82 } 82 }
83 return styleValueVector; 83 return styleValueVector;
84 } 84 }
85 85
86 } // namespace blink 86 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/cssom/CSSSimpleLength.idl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698