summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/css/parser/css_parser_local_context.h
blob: d5de80e82ed51fc94bc49b200f3791164d4f5799 (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
60
61
62
// 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_PARSER_CSS_PARSER_LOCAL_CONTEXT_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_PARSER_CSS_PARSER_LOCAL_CONTEXT_H_

#include "third_party/blink/renderer/core/css/css_property_names.h"
#include "third_party/blink/renderer/platform/wtf/allocator.h"

namespace blink {

// A wrapper class containing all local context when parsing a property.

class CORE_EXPORT CSSParserLocalContext {
  STACK_ALLOCATED();

 public:
  CSSParserLocalContext();

  // When parsing registered custom properties, a different result is required
  // depending on the context.
  enum class VariableMode {
    // The custom property is parsed according to the registered syntax (if
    // available).
    kTyped,
    // The registration of the custom property (if any) is ignored; the custom
    // property will parse as if unregistered.
    kUntyped,
    // The custom property will be parsed as if unregistered (that is,
    // a CSSCustomPropertyDeclaration will be returned), but the tokens must
    // also match the registered syntax (if any). This is useful for CSSOM,
    // where incoming values must validate against the registered syntax, but
    // are otherwise treated as unregistered.
    kValidatedUntyped
  };

  CSSParserLocalContext WithAliasParsing(bool) const;
  CSSParserLocalContext WithAnimationTainted(bool) const;
  CSSParserLocalContext WithCurrentShorthand(CSSPropertyID) const;
  CSSParserLocalContext WithVariableMode(VariableMode) const;

  bool UseAliasParsing() const;
  // Any custom property used in a @keyframes rule becomes animation-tainted,
  // which prevents the custom property from being substituted into the
  // 'animation' property, or one of its longhands.
  //
  // https://drafts.csswg.org/css-variables/#animation-tainted
  bool IsAnimationTainted() const;
  CSSPropertyID CurrentShorthand() const;
  VariableMode GetVariableMode() const;

 private:
  bool use_alias_parsing_;
  bool is_animation_tainted_;
  CSSPropertyID current_shorthand_;
  VariableMode variable_mode_;
};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_PARSER_CSS_PARSER_LOCAL_CONTEXT_H_