1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_PROPERTIES_LONGHANDS_CUSTOM_PROPERTY_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_PROPERTIES_LONGHANDS_CUSTOM_PROPERTY_H_
#include "third_party/blink/renderer/core/css/properties/longhands/variable.h"
#include "third_party/blink/renderer/core/css/property_registration.h"
namespace blink {
class PropertyRegistry;
// Represents a custom property (both registered and unregistered).
//
// Unlike all other CSSProperty instances, instances of this class are
// allocated dynamically on demand. (See CSSPropertyRef).
//
// TODO(andruud): Move functionality from Variable to here, and eventually
// remove Variable.
class CORE_EXPORT CustomProperty : public Variable {
DISALLOW_NEW();
public:
CustomProperty()
: CustomProperty(AtomicString(),
static_cast<const PropertyRegistration*>(nullptr)) {}
CustomProperty(const AtomicString& name, const Document&);
CustomProperty(const AtomicString& name, const PropertyRegistry*);
const AtomicString& GetPropertyNameAtomicString() const override;
CSSPropertyName GetCSSPropertyName() const override;
void ApplyInitial(StyleResolverState&) const override;
void ApplyInherit(StyleResolverState&) const override;
void ApplyValue(StyleResolverState&, const CSSValue&) const override;
const CSSValue* ParseSingleValue(CSSParserTokenRange&,
const CSSParserContext&,
const CSSParserLocalContext&) const override;
const CSSValue* CSSValueFromComputedStyleInternal(
const ComputedStyle&,
const SVGComputedStyle&,
const LayoutObject*,
bool allow_visited_style) const override;
bool IsRegistered() const { return registration_; }
void Trace(Visitor* visitor) { visitor->Trace(registration_); }
private:
CustomProperty(const AtomicString& name,
const PropertyRegistration* registration);
const CSSValue* ParseUntyped(CSSParserTokenRange,
const CSSParserContext&,
const CSSParserLocalContext&) const;
const CSSValue* ParseTyped(CSSParserTokenRange,
const CSSParserContext&,
const CSSParserLocalContext&) const;
AtomicString name_;
Member<const PropertyRegistration> registration_;
};
template <>
struct DowncastTraits<CustomProperty> {
static bool AllowFrom(const CSSProperty& property) {
DCHECK(!Variable::IsStaticInstance(property));
return property.PropertyID() == CSSPropertyID::kVariable;
}
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_PROPERTIES_LONGHANDS_CUSTOM_PROPERTY_H_
|