summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/css/cssom/declared_style_property_map.h
blob: 63e229b7f0e506f7cefaf959d1e402a5e4601a9a (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright 2017 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_CSSOM_DECLARED_STYLE_PROPERTY_MAP_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_CSSOM_DECLARED_STYLE_PROPERTY_MAP_H_

#include "third_party/blink/renderer/core/css/cssom/style_property_map.h"

namespace blink {

class CSSStyleRule;
class StyleRule;

// This class implements declared StylePropertMap in the Typed CSSOM
// API. The specification is here:
// https://drafts.css-houdini.org/css-typed-om/#declared-stylepropertymap-objects
//
// The declared StylePropertyMap retrieves styles specified by a CSS style rule
// and returns them as CSSStyleValues. The IDL for this class is in
// StylePropertyMap.idl. The declared StylePropertyMap for an element is
// accessed via CSSStyleRule.styleMap (see CSSStyleRule.idl)
class CORE_EXPORT DeclaredStylePropertyMap final : public StylePropertyMap {
 public:
  explicit DeclaredStylePropertyMap(CSSStyleRule* owner_rule);

  void Trace(blink::Visitor* visitor) override {
    visitor->Trace(owner_rule_);
    StylePropertyMap::Trace(visitor);
  }

  unsigned int size() final;

 protected:
  const CSSValue* GetProperty(CSSPropertyID) override;
  const CSSValue* GetCustomProperty(AtomicString) override;
  void ForEachProperty(const IterationCallback&) override;
  void SetProperty(CSSPropertyID, const CSSValue&) override;
  bool SetShorthandProperty(CSSPropertyID,
                            const String&,
                            SecureContextMode) override;
  void SetCustomProperty(const AtomicString&, const CSSValue&) override;
  void RemoveProperty(CSSPropertyID) override;
  void RemoveCustomProperty(const AtomicString&) override;
  void RemoveAllProperties() final;

  String SerializationForShorthand(const CSSProperty&) final;

 private:
  StyleRule* GetStyleRule() const;

  WeakMember<CSSStyleRule> owner_rule_;

  DISALLOW_COPY_AND_ASSIGN(DeclaredStylePropertyMap);
};

}  // namespace blink

#endif