-
Notifications
You must be signed in to change notification settings - Fork 6.6k
/
css_custom_ident_value.cc
52 lines (43 loc) · 1.73 KB
/
css_custom_ident_value.cc
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
// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/core/css/css_custom_ident_value.h"
#include "third_party/blink/renderer/core/css/css_markup.h"
#include "third_party/blink/renderer/core/css/properties/css_unresolved_property.h"
#include "third_party/blink/renderer/core/dom/tree_scope.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink {
CSSCustomIdentValue::CSSCustomIdentValue(const AtomicString& str)
: CSSValue(kCustomIdentClass),
string_(str),
property_id_(CSSPropertyID::kInvalid) {
needs_tree_scope_population_ = true;
}
CSSCustomIdentValue::CSSCustomIdentValue(CSSPropertyID id)
: CSSValue(kCustomIdentClass), string_(), property_id_(id) {
DCHECK(IsKnownPropertyID());
}
String CSSCustomIdentValue::CustomCSSText() const {
if (IsKnownPropertyID()) {
return CSSUnresolvedProperty::Get(property_id_)
.GetPropertyNameAtomicString();
}
StringBuilder builder;
SerializeIdentifier(string_, builder);
return builder.ReleaseString();
}
const CSSCustomIdentValue& CSSCustomIdentValue::PopulateWithTreeScope(
const TreeScope* tree_scope) const {
DCHECK(this->needs_tree_scope_population_);
CSSCustomIdentValue* populated =
MakeGarbageCollected<CSSCustomIdentValue>(*this);
populated->tree_scope_ = tree_scope;
populated->needs_tree_scope_population_ = false;
return *populated;
}
void CSSCustomIdentValue::TraceAfterDispatch(blink::Visitor* visitor) const {
visitor->Trace(tree_scope_);
CSSValue::TraceAfterDispatch(visitor);
}
} // namespace blink