1 | /*
|
---|
2 | * Copyright (C) 2016 Apple Inc. All rights reserved.
|
---|
3 | *
|
---|
4 | * Redistribution and use in source and binary forms, with or without
|
---|
5 | * modification, are permitted provided that the following conditions
|
---|
6 | * are met:
|
---|
7 | * 1. Redistributions of source code must retain the above copyright
|
---|
8 | * notice, this list of conditions and the following disclaimer.
|
---|
9 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
10 | * notice, this list of conditions and the following disclaimer in the
|
---|
11 | * documentation and/or other materials provided with the distribution.
|
---|
12 | *
|
---|
13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
|
---|
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
---|
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
---|
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
|
---|
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
---|
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
---|
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
---|
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
---|
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
---|
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #pragma once
|
---|
27 |
|
---|
28 | #include "CSSPrimitiveValue.h"
|
---|
29 | #include "DeprecatedCSSOMValue.h"
|
---|
30 |
|
---|
31 | namespace WebCore {
|
---|
32 |
|
---|
33 | class DeprecatedCSSOMCounter;
|
---|
34 | class DeprecatedCSSOMRGBColor;
|
---|
35 | class DeprecatedCSSOMRect;
|
---|
36 |
|
---|
37 | class DeprecatedCSSOMPrimitiveValue : public DeprecatedCSSOMValue {
|
---|
38 | public:
|
---|
39 | // Only expose what's in the IDL file.
|
---|
40 | enum UnitType {
|
---|
41 | CSS_UNKNOWN = 0,
|
---|
42 | CSS_NUMBER = 1,
|
---|
43 | CSS_PERCENTAGE = 2,
|
---|
44 | CSS_EMS = 3,
|
---|
45 | CSS_EXS = 4,
|
---|
46 | CSS_PX = 5,
|
---|
47 | CSS_CM = 6,
|
---|
48 | CSS_MM = 7,
|
---|
49 | CSS_IN = 8,
|
---|
50 | CSS_PT = 9,
|
---|
51 | CSS_PC = 10,
|
---|
52 | CSS_DEG = 11,
|
---|
53 | CSS_RAD = 12,
|
---|
54 | CSS_GRAD = 13,
|
---|
55 | CSS_MS = 14,
|
---|
56 | CSS_S = 15,
|
---|
57 | CSS_HZ = 16,
|
---|
58 | CSS_KHZ = 17,
|
---|
59 | CSS_DIMENSION = 18,
|
---|
60 | CSS_STRING = 19,
|
---|
61 | CSS_URI = 20,
|
---|
62 | CSS_IDENT = 21,
|
---|
63 | CSS_ATTR = 22,
|
---|
64 | CSS_COUNTER = 23,
|
---|
65 | CSS_RECT = 24,
|
---|
66 | CSS_RGBCOLOR = 25
|
---|
67 | // Do not add new units here; this is deprecated and we shouldn't expose anything not in DOM Level 2 Style.
|
---|
68 | };
|
---|
69 |
|
---|
70 | static Ref<DeprecatedCSSOMPrimitiveValue> create(const CSSPrimitiveValue& value, CSSStyleDeclaration& owner)
|
---|
71 | {
|
---|
72 | return adoptRef(*new DeprecatedCSSOMPrimitiveValue(value, owner));
|
---|
73 | }
|
---|
74 |
|
---|
75 | bool equals(const DeprecatedCSSOMPrimitiveValue& other) const { return m_value->equals(other.m_value); }
|
---|
76 | String cssText() const { return m_value->cssText(); }
|
---|
77 |
|
---|
78 | WEBCORE_EXPORT unsigned short primitiveType() const;
|
---|
79 | WEBCORE_EXPORT ExceptionOr<float> getFloatValue(unsigned short unitType) const;
|
---|
80 | WEBCORE_EXPORT ExceptionOr<String> getStringValue() const;
|
---|
81 | WEBCORE_EXPORT ExceptionOr<Ref<DeprecatedCSSOMCounter>> getCounterValue() const;
|
---|
82 | WEBCORE_EXPORT ExceptionOr<Ref<DeprecatedCSSOMRect>> getRectValue() const;
|
---|
83 | WEBCORE_EXPORT ExceptionOr<Ref<DeprecatedCSSOMRGBColor>> getRGBColorValue() const;
|
---|
84 |
|
---|
85 | static ExceptionOr<void> setFloatValue(unsigned short, double) { return Exception { NoModificationAllowedError }; }
|
---|
86 | static ExceptionOr<void> setStringValue(unsigned short, const String&) { return Exception { NoModificationAllowedError }; }
|
---|
87 |
|
---|
88 | String stringValue() const { return m_value->stringValue(); }
|
---|
89 | bool isCSSWideKeyword() const { return m_value->isCSSWideKeyword(); }
|
---|
90 | unsigned cssValueType() const { return m_value->cssValueType(); }
|
---|
91 |
|
---|
92 | private:
|
---|
93 | DeprecatedCSSOMPrimitiveValue(const CSSPrimitiveValue& value, CSSStyleDeclaration& owner)
|
---|
94 | : DeprecatedCSSOMValue(DeprecatedPrimitiveValueClass, owner)
|
---|
95 | , m_value(const_cast<CSSPrimitiveValue&>(value))
|
---|
96 | {
|
---|
97 | }
|
---|
98 |
|
---|
99 | Ref<CSSPrimitiveValue> m_value;
|
---|
100 | };
|
---|
101 |
|
---|
102 | } // namespace WebCore
|
---|
103 |
|
---|
104 | SPECIALIZE_TYPE_TRAITS_CSSOM_VALUE(DeprecatedCSSOMPrimitiveValue, isPrimitiveValue())
|
---|