summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/css/property_registry.h
blob: b9dc7a10ef452e49bd7cd6b617bf5a19df847de6 (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
37
38
39
40
41
42
43
44
45
// Copyright 2016 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_PROPERTY_REGISTRY_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_PROPERTY_REGISTRY_H_

#include "third_party/blink/renderer/core/css/property_registration.h"
#include "third_party/blink/renderer/platform/wtf/text/atomic_string.h"
#include "third_party/blink/renderer/platform/wtf/text/atomic_string_hash.h"

namespace blink {

class CORE_EXPORT PropertyRegistry : public GarbageCollected<PropertyRegistry> {
 public:
  using RegistrationMap =
      HeapHashMap<AtomicString, Member<PropertyRegistration>>;

  static PropertyRegistry* Create() { return new PropertyRegistry(); }

  void RegisterProperty(const AtomicString&, PropertyRegistration&);
  const PropertyRegistration* Registration(const AtomicString&) const;
  size_t RegistrationCount() const { return registrations_.size(); }

  RegistrationMap::const_iterator begin() const;
  RegistrationMap::const_iterator end() const;

  void Trace(blink::Visitor* visitor) { visitor->Trace(registrations_); }

  // Parse the incoming value and return the parsed result, if:
  //  1. A registration with the specified name exists, and
  //  2. The incoming value is a CSSCustomPropertyDeclaration, has no
  //     unresolved var-references and matches the registered syntax.
  // Otherwise the incoming value is returned.
  static const CSSValue* ParseIfRegistered(const Document& document,
                                           const AtomicString& property_name,
                                           const CSSValue*);

 private:
  RegistrationMap registrations_;
};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_PROPERTY_REGISTRY_H_