summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/css/properties/css_property_ref.cc
blob: d93f3fbdb7d273c211834b60935937297ebcc38b (plain)
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
// 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.

#include "third_party/blink/renderer/core/css/properties/css_property_ref.h"

#include "third_party/blink/renderer/core/dom/document.h"

namespace blink {

CSSPropertyRef::CSSPropertyRef(const String& name, const Document& document)
    : property_id_(
          UnresolvedCSSPropertyID(document.GetExecutionContext(), name)) {
  if (property_id_ == CSSPropertyID::kVariable)
    custom_property_ = CustomProperty(AtomicString(name), document);
}

CSSPropertyRef::CSSPropertyRef(const CSSPropertyName& name,
                               const Document& document)
    : property_id_(name.Id()) {
  DCHECK_NE(name.Id(), CSSPropertyID::kInvalid);
  if (property_id_ == CSSPropertyID::kVariable)
    custom_property_ = CustomProperty(name.ToAtomicString(), document);
}

CSSPropertyRef::CSSPropertyRef(const CSSProperty& property)
    : property_id_(property.PropertyID()) {
  if (property.PropertyID() == CSSPropertyID::kVariable) {
    if (!Variable::IsStaticInstance(property))
      custom_property_ = static_cast<const CustomProperty&>(property);
    else
      property_id_ = CSSPropertyID::kInvalid;
  }
}

}  // namespace blink