Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: third_party/WebKit/Source/core/css/resolver/CSSVariableResolver.h

Issue 2878853002: Make CSSVariableResolver's interface object based instead of static functions (Closed)
Patch Set: rebased Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CSSVariableResolver_h 5 #ifndef CSSVariableResolver_h
6 #define CSSVariableResolver_h 6 #define CSSVariableResolver_h
7 7
8 #include "core/CSSPropertyNames.h" 8 #include "core/CSSPropertyNames.h"
9 #include "core/css/parser/CSSParserToken.h" 9 #include "core/css/parser/CSSParserToken.h"
10 #include "platform/wtf/HashSet.h" 10 #include "platform/wtf/HashSet.h"
11 #include "platform/wtf/text/AtomicString.h" 11 #include "platform/wtf/text/AtomicString.h"
12 #include "platform/wtf/text/AtomicStringHash.h" 12 #include "platform/wtf/text/AtomicStringHash.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 class CSSParserTokenRange; 16 class CSSParserTokenRange;
17 class CSSPendingSubstitutionValue; 17 class CSSPendingSubstitutionValue;
18 class CSSVariableData; 18 class CSSVariableData;
19 class CSSVariableReferenceValue; 19 class CSSVariableReferenceValue;
20 class PropertyRegistry; 20 class PropertyRegistry;
21 class StyleResolverState; 21 class StyleResolverState;
22 class StyleInheritedVariables; 22 class StyleInheritedVariables;
23 class StyleNonInheritedVariables; 23 class StyleNonInheritedVariables;
24 24
25 class CSSVariableResolver { 25 class CSSVariableResolver {
26 STACK_ALLOCATED(); 26 STACK_ALLOCATED();
27 27
28 public: 28 public:
29 static void ResolveVariableDefinitions(const StyleResolverState&); 29 CSSVariableResolver(const StyleResolverState&);
30
31 void ResolveVariableDefinitions();
30 32
31 // Shorthand properties are not supported. 33 // Shorthand properties are not supported.
32 static const CSSValue* ResolveVariableReferences( 34 const CSSValue* ResolveVariableReferences(CSSPropertyID,
33 const StyleResolverState&, 35 const CSSValue&,
34 CSSPropertyID, 36 bool disallow_animation_tainted);
35 const CSSValue&,
36 bool disallow_animation_tainted);
37 37
38 static void ComputeRegisteredVariables(const StyleResolverState&); 38 void ComputeRegisteredVariables();
39 39
40 private: 40 private:
41 CSSVariableResolver(const StyleResolverState&); 41 const CSSValue* ResolvePendingSubstitutions(
42
43 static const CSSValue* ResolvePendingSubstitutions(
44 const StyleResolverState&,
45 CSSPropertyID, 42 CSSPropertyID,
46 const CSSPendingSubstitutionValue&, 43 const CSSPendingSubstitutionValue&,
47 bool disallow_animation_tainted); 44 bool disallow_animation_tainted);
48 static const CSSValue* ResolveVariableReferences( 45 const CSSValue* ResolveVariableReferences(CSSPropertyID,
49 const StyleResolverState&, 46 const CSSVariableReferenceValue&,
50 CSSPropertyID, 47 bool disallow_animation_tainted);
51 const CSSVariableReferenceValue&,
52 bool disallow_animation_tainted);
53 48
54 // These return false if we encounter a reference to an invalid variable with 49 // These return false if we encounter a reference to an invalid variable with
55 // no fallback. 50 // no fallback.
56 51
57 // Resolves a range which may contain var() references or @apply rules. 52 // Resolves a range which may contain var() references or @apply rules.
58 bool ResolveTokenRange(CSSParserTokenRange, 53 bool ResolveTokenRange(CSSParserTokenRange,
59 bool disallow_animation_tainted, 54 bool disallow_animation_tainted,
60 Vector<CSSParserToken>& result, 55 Vector<CSSParserToken>& result,
61 Vector<String>& result_backing_strings, 56 Vector<String>& result_backing_strings,
62 bool& result_is_animation_tainted); 57 bool& result_is_animation_tainted);
(...skipping 17 matching lines...) Expand all
80 75
81 // These return null if the custom property is invalid. 76 // These return null if the custom property is invalid.
82 77
83 // Returns the CSSVariableData for a custom property, resolving and storing it 78 // Returns the CSSVariableData for a custom property, resolving and storing it
84 // if necessary. 79 // if necessary.
85 CSSVariableData* ValueForCustomProperty(AtomicString name); 80 CSSVariableData* ValueForCustomProperty(AtomicString name);
86 // Resolves the CSSVariableData from a custom property declaration. 81 // Resolves the CSSVariableData from a custom property declaration.
87 PassRefPtr<CSSVariableData> ResolveCustomProperty(AtomicString name, 82 PassRefPtr<CSSVariableData> ResolveCustomProperty(AtomicString name,
88 const CSSVariableData&); 83 const CSSVariableData&);
89 84
85 const StyleResolverState& state_;
90 StyleInheritedVariables* inherited_variables_; 86 StyleInheritedVariables* inherited_variables_;
91 StyleNonInheritedVariables* non_inherited_variables_; 87 StyleNonInheritedVariables* non_inherited_variables_;
92 Member<const PropertyRegistry> registry_; 88 Member<const PropertyRegistry> registry_;
93 HashSet<AtomicString> variables_seen_; 89 HashSet<AtomicString> variables_seen_;
94 // Resolution doesn't finish when a cycle is detected. Fallbacks still 90 // Resolution doesn't finish when a cycle is detected. Fallbacks still
95 // need to be tracked for additional cycles, and invalidation only 91 // need to be tracked for additional cycles, and invalidation only
96 // applies back to cycle starts. 92 // applies back to cycle starts.
97 HashSet<AtomicString> cycle_start_points_; 93 HashSet<AtomicString> cycle_start_points_;
98 }; 94 };
99 95
100 } // namespace blink 96 } // namespace blink
101 97
102 #endif // CSSVariableResolver 98 #endif // CSSVariableResolver
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698