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

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

Issue 2867883003: [CSS Typed OM] Delete obsolete number and length classes from Typed OM (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/StylePropertyMapReadonly.cpp ('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/CSSCalcLength.h"
10 #include "core/css/cssom/CSSKeywordValue.h" 9 #include "core/css/cssom/CSSKeywordValue.h"
11 #include "core/css/cssom/CSSNumberValue.h"
12 #include "core/css/cssom/CSSOMTypes.h" 10 #include "core/css/cssom/CSSOMTypes.h"
13 #include "core/css/cssom/CSSSimpleLength.h"
14 #include "core/css/cssom/CSSStyleValue.h" 11 #include "core/css/cssom/CSSStyleValue.h"
15 #include "core/css/cssom/CSSStyleVariableReferenceValue.h" 12 #include "core/css/cssom/CSSStyleVariableReferenceValue.h"
16 #include "core/css/cssom/CSSTransformValue.h" 13 #include "core/css/cssom/CSSTransformValue.h"
17 #include "core/css/cssom/CSSURLImageValue.h" 14 #include "core/css/cssom/CSSURLImageValue.h"
18 #include "core/css/cssom/CSSUnparsedValue.h" 15 #include "core/css/cssom/CSSUnparsedValue.h"
19 #include "core/css/cssom/CSSUnsupportedStyleValue.h" 16 #include "core/css/cssom/CSSUnsupportedStyleValue.h"
20 17
21 namespace blink { 18 namespace blink {
22 19
23 namespace { 20 namespace {
24 21
25 CSSStyleValue* CreateStyleValueFromPrimitiveValue( 22 CSSStyleValue* CreateStyleValueFromPrimitiveValue(
26 const CSSPrimitiveValue& primitive_value) { 23 const CSSPrimitiveValue& primitive_value) {
27 if (primitive_value.IsNumber())
28 return CSSNumberValue::Create(primitive_value.GetDoubleValue());
29 if (primitive_value.IsLength() || primitive_value.IsPercentage())
30 return CSSSimpleLength::FromCSSValue(primitive_value);
31 return nullptr; 24 return nullptr;
32 } 25 }
33 26
34 CSSStyleValue* CreateStyleValueWithPropertyInternal(CSSPropertyID property_id, 27 CSSStyleValue* CreateStyleValueWithPropertyInternal(CSSPropertyID property_id,
35 const CSSValue& value) { 28 const CSSValue& value) {
36 switch (property_id) { 29 switch (property_id) {
37 case CSSPropertyTransform: 30 case CSSPropertyTransform:
38 return CSSTransformValue::FromCSSValue(value); 31 return CSSTransformValue::FromCSSValue(value);
39 default: 32 default:
40 // TODO(meade): Implement other properties. 33 // TODO(meade): Implement other properties.
41 break; 34 break;
42 } 35 }
43 if (value.IsPrimitiveValue() && ToCSSPrimitiveValue(value).IsCalculated()) {
44 // TODO(meade): Handle other calculated types, e.g. angles here.
45 if (CSSOMTypes::PropertyCanTakeType(property_id,
46 CSSStyleValue::kCalcLengthType)) {
47 return CSSCalcLength::FromCSSValue(ToCSSPrimitiveValue(value));
48 }
49 }
50 return nullptr; 36 return nullptr;
51 } 37 }
52 38
53 CSSStyleValue* CreateStyleValue(const CSSValue& value) { 39 CSSStyleValue* CreateStyleValue(const CSSValue& value) {
54 if (value.IsCSSWideKeyword() || value.IsIdentifierValue() || 40 if (value.IsCSSWideKeyword() || value.IsIdentifierValue() ||
55 value.IsCustomIdentValue()) 41 value.IsCustomIdentValue())
56 return CSSKeywordValue::FromCSSValue(value); 42 return CSSKeywordValue::FromCSSValue(value);
57 if (value.IsPrimitiveValue()) 43 if (value.IsPrimitiveValue())
58 return CreateStyleValueFromPrimitiveValue(ToCSSPrimitiveValue(value)); 44 return CreateStyleValueFromPrimitiveValue(ToCSSPrimitiveValue(value));
59 if (value.IsVariableReferenceValue()) 45 if (value.IsVariableReferenceValue())
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 } 95 }
110 return style_value_vector; 96 return style_value_vector;
111 } 97 }
112 98
113 CSSStyleValueVector StyleValueFactory::CssValueToStyleValueVector( 99 CSSStyleValueVector StyleValueFactory::CssValueToStyleValueVector(
114 const CSSValue& css_value) { 100 const CSSValue& css_value) {
115 return CssValueToStyleValueVector(CSSPropertyInvalid, css_value); 101 return CssValueToStyleValueVector(CSSPropertyInvalid, css_value);
116 } 102 }
117 103
118 } // namespace blink 104 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/cssom/StylePropertyMapReadonly.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698