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

Side by Side Diff: third_party/WebKit/Source/core/css/cssom/CSSLengthValue.h

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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef CSSLengthValue_h 5 #ifndef CSSLengthValue_h
6 #define CSSLengthValue_h 6 #define CSSLengthValue_h
7 7
8 #include "core/css/CSSPrimitiveValue.h" 8 #include "core/css/CSSPrimitiveValue.h"
9 #include "core/css/cssom/CSSStyleValue.h" 9 #include "core/css/cssom/CSSStyleValue.h"
10 10
11 namespace blink { 11 namespace blink {
12 12
13 class CalcDictionary; 13 class CalcDictionary;
14 class ExceptionState; 14 class ExceptionState;
15 15
16 class CORE_EXPORT CSSLengthValue : public CSSStyleValue { 16 class CORE_EXPORT CSSLengthValue : public CSSStyleValue {
17 WTF_MAKE_NONCOPYABLE(CSSLengthValue); 17 WTF_MAKE_NONCOPYABLE(CSSLengthValue);
18 DEFINE_WRAPPERTYPEINFO(); 18 DEFINE_WRAPPERTYPEINFO();
19 public: 19 public:
20 static CSSLengthValue* fromCSSValue(const CSSValue& value);
20 static CSSPrimitiveValue::UnitType unitFromName(const String& name); 21 static CSSPrimitiveValue::UnitType unitFromName(const String& name);
21 22
22 CSSLengthValue* add(const CSSLengthValue* other, ExceptionState&); 23 CSSLengthValue* add(const CSSLengthValue* other, ExceptionState&);
23 CSSLengthValue* subtract(const CSSLengthValue* other, ExceptionState&); 24 CSSLengthValue* subtract(const CSSLengthValue* other, ExceptionState&);
24 CSSLengthValue* multiply(double, ExceptionState&); 25 CSSLengthValue* multiply(double, ExceptionState&);
25 CSSLengthValue* divide(double, ExceptionState&); 26 CSSLengthValue* divide(double, ExceptionState&);
26 27
27 virtual bool containsPercent() const = 0; 28 virtual bool containsPercent() const = 0;
28 29
29 static CSSLengthValue* from(const String& cssString, ExceptionState&); 30 static CSSLengthValue* from(const String& cssString, ExceptionState&);
30 static CSSLengthValue* from(double value, const String& typeStr, ExceptionSt ate&); 31 static CSSLengthValue* from(double value, const String& typeStr, ExceptionSt ate&);
31 static CSSLengthValue* from(const CalcDictionary&, ExceptionState&); 32 static CSSLengthValue* from(const CalcDictionary&, ExceptionState&);
32 33
33 protected: 34 protected:
34 CSSLengthValue() {} 35 CSSLengthValue() {}
35 36
36 virtual CSSLengthValue* addInternal(const CSSLengthValue* other, ExceptionSt ate&); 37 virtual CSSLengthValue* addInternal(const CSSLengthValue* other, ExceptionSt ate&);
37 virtual CSSLengthValue* subtractInternal(const CSSLengthValue* other, Except ionState&); 38 virtual CSSLengthValue* subtractInternal(const CSSLengthValue* other, Except ionState&);
38 virtual CSSLengthValue* multiplyInternal(double, ExceptionState&); 39 virtual CSSLengthValue* multiplyInternal(double);
39 virtual CSSLengthValue* divideInternal(double, ExceptionState&); 40 virtual CSSLengthValue* divideInternal(double);
40 41
41 static bool isSupportedLengthUnit(CSSPrimitiveValue::UnitType unit) 42 static bool isSupportedLengthUnit(CSSPrimitiveValue::UnitType unit)
42 { 43 {
43 return (CSSPrimitiveValue::isLength(unit) || unit == CSSPrimitiveValue:: UnitType::Percentage) 44 return (CSSPrimitiveValue::isLength(unit) || unit == CSSPrimitiveValue:: UnitType::Percentage)
44 && unit != CSSPrimitiveValue::UnitType::QuirkyEms 45 && unit != CSSPrimitiveValue::UnitType::QuirkyEms
45 && unit != CSSPrimitiveValue::UnitType::UserUnits; 46 && unit != CSSPrimitiveValue::UnitType::UserUnits;
46 } 47 }
47 48
48 static const int kNumSupportedUnits = 15; 49 static const int kNumSupportedUnits = 15;
49 }; 50 };
50 51
51 DEFINE_TYPE_CASTS(CSSLengthValue, CSSStyleValue, value, 52 DEFINE_TYPE_CASTS(CSSLengthValue, CSSStyleValue, value,
52 (value->type() == CSSStyleValue::SimpleLengthType 53 (value->type() == CSSStyleValue::SimpleLengthType
53 || value->type() == CSSStyleValue::CalcLengthType), 54 || value->type() == CSSStyleValue::CalcLengthType),
54 (value.type() == CSSStyleValue::SimpleLengthType 55 (value.type() == CSSStyleValue::SimpleLengthType
55 || value.type() == CSSStyleValue::CalcLengthType)); 56 || value.type() == CSSStyleValue::CalcLengthType));
56 57
57 } // namespace blink 58 } // namespace blink
58 59
59 #endif 60 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698