1 | /*
|
---|
2 | * Copyright (C) 2021 Tyler Wilcock <[email protected]>.
|
---|
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 "CSSRule.h"
|
---|
29 | #include "StyleProperties.h"
|
---|
30 | #include "StyleRule.h"
|
---|
31 | #include <wtf/text/AtomString.h>
|
---|
32 |
|
---|
33 | namespace WebCore {
|
---|
34 |
|
---|
35 | // The keywords that can be used as values for the counter-style `system` descriptor.
|
---|
36 | // https://www.w3.org/TR/css-counter-styles-3/#counter-style-system
|
---|
37 | enum class CounterStyleSystem : uint8_t {
|
---|
38 | Cyclic,
|
---|
39 | Numeric,
|
---|
40 | Alphabetic,
|
---|
41 | Symbolic,
|
---|
42 | Additive,
|
---|
43 | Fixed,
|
---|
44 | Extends
|
---|
45 | };
|
---|
46 |
|
---|
47 | class StyleRuleCounterStyle final : public StyleRuleBase {
|
---|
48 | public:
|
---|
49 | static Ref<StyleRuleCounterStyle> create(const AtomString& name, Ref<StyleProperties>&&);
|
---|
50 | ~StyleRuleCounterStyle();
|
---|
51 |
|
---|
52 | const StyleProperties& properties() const { return m_properties; }
|
---|
53 | MutableStyleProperties& mutableProperties();
|
---|
54 |
|
---|
55 | const AtomString& name() const { return m_name; }
|
---|
56 | String system() const { return m_properties->getPropertyValue(CSSPropertySystem); }
|
---|
57 | String negative() const { return m_properties->getPropertyValue(CSSPropertyNegative); }
|
---|
58 | String prefix() const { return m_properties->getPropertyValue(CSSPropertyPrefix); }
|
---|
59 | String suffix() const { return m_properties->getPropertyValue(CSSPropertySuffix); }
|
---|
60 | String range() const { return m_properties->getPropertyValue(CSSPropertyRange); }
|
---|
61 | String pad() const { return m_properties->getPropertyValue(CSSPropertyPad); }
|
---|
62 | String fallback() const { return m_properties->getPropertyValue(CSSPropertyFallback); }
|
---|
63 | String symbols() const { return m_properties->getPropertyValue(CSSPropertySymbols); }
|
---|
64 | String additiveSymbols() const { return m_properties->getPropertyValue(CSSPropertyAdditiveSymbols); }
|
---|
65 | String speakAs() const { return m_properties->getPropertyValue(CSSPropertySpeakAs); }
|
---|
66 |
|
---|
67 | bool newValueInvalidOrEqual(CSSPropertyID, const RefPtr<CSSValue> newValue) const;
|
---|
68 |
|
---|
69 | void setName(const AtomString& name) { m_name = name; }
|
---|
70 |
|
---|
71 | private:
|
---|
72 | explicit StyleRuleCounterStyle(const AtomString&, Ref<StyleProperties>&&);
|
---|
73 |
|
---|
74 | AtomString m_name;
|
---|
75 | Ref<StyleProperties> m_properties;
|
---|
76 | };
|
---|
77 |
|
---|
78 | class CSSCounterStyleRule final : public CSSRule {
|
---|
79 | public:
|
---|
80 | static Ref<CSSCounterStyleRule> create(StyleRuleCounterStyle&, CSSStyleSheet*);
|
---|
81 | virtual ~CSSCounterStyleRule();
|
---|
82 |
|
---|
83 | String cssText() const final;
|
---|
84 | void reattach(StyleRuleBase&) final;
|
---|
85 | StyleRuleType styleRuleType() const final { return StyleRuleType::CounterStyle; }
|
---|
86 |
|
---|
87 | String name() const { return m_counterStyleRule->name(); }
|
---|
88 | String system() const { return m_counterStyleRule->system(); }
|
---|
89 | String negative() const { return m_counterStyleRule->negative(); }
|
---|
90 | String prefix() const { return m_counterStyleRule->prefix(); }
|
---|
91 | String suffix() const { return m_counterStyleRule->suffix(); }
|
---|
92 | String range() const { return m_counterStyleRule->range(); }
|
---|
93 | String pad() const { return m_counterStyleRule->pad(); }
|
---|
94 | String fallback() const { return m_counterStyleRule->fallback(); }
|
---|
95 | String symbols() const { return m_counterStyleRule->symbols(); }
|
---|
96 | String additiveSymbols() const { return m_counterStyleRule->additiveSymbols(); }
|
---|
97 | String speakAs() const { return m_counterStyleRule->speakAs(); }
|
---|
98 |
|
---|
99 | void setName(const String&);
|
---|
100 | void setSystem(const String&);
|
---|
101 | void setNegative(const String&);
|
---|
102 | void setPrefix(const String&);
|
---|
103 | void setSuffix(const String&);
|
---|
104 | void setRange(const String&);
|
---|
105 | void setPad(const String&);
|
---|
106 | void setFallback(const String&);
|
---|
107 | void setSymbols(const String&);
|
---|
108 | void setAdditiveSymbols(const String&);
|
---|
109 | void setSpeakAs(const String&);
|
---|
110 |
|
---|
111 | private:
|
---|
112 | CSSCounterStyleRule(StyleRuleCounterStyle&, CSSStyleSheet* parent);
|
---|
113 |
|
---|
114 | void setterInternal(CSSPropertyID, const String&);
|
---|
115 |
|
---|
116 | Ref<StyleRuleCounterStyle> m_counterStyleRule;
|
---|
117 | };
|
---|
118 |
|
---|
119 | } // namespace WebCore
|
---|
120 |
|
---|
121 | SPECIALIZE_TYPE_TRAITS_CSS_RULE(CSSCounterStyleRule, StyleRuleType::CounterStyle)
|
---|
122 |
|
---|
123 | SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::StyleRuleCounterStyle)
|
---|
124 | static bool isType(const WebCore::StyleRuleBase& rule) { return rule.isCounterStyleRule(); }
|
---|
125 | SPECIALIZE_TYPE_TRAITS_END()
|
---|
126 |
|
---|