OLD | NEW |
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 "wtf/HashSet.h" | 10 #include "wtf/HashSet.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 static void resolveVariableDefinitions(StyleVariableData*); | 23 static void resolveVariableDefinitions(StyleVariableData*); |
24 static void resolveAndApplyVariableReferences(StyleResolverState&, CSSProper
tyID, const CSSVariableReferenceValue&); | 24 static void resolveAndApplyVariableReferences(StyleResolverState&, CSSProper
tyID, const CSSVariableReferenceValue&); |
25 | 25 |
26 // Shorthand properties are not supported. | 26 // Shorthand properties are not supported. |
27 static PassRefPtrWillBeRawPtr<CSSValue> resolveVariableReferences(StyleVaria
bleData*, CSSPropertyID, const CSSVariableReferenceValue&); | 27 static PassRefPtrWillBeRawPtr<CSSValue> resolveVariableReferences(StyleVaria
bleData*, CSSPropertyID, const CSSVariableReferenceValue&); |
28 | 28 |
29 private: | 29 private: |
30 CSSVariableResolver(StyleVariableData*); | 30 CSSVariableResolver(StyleVariableData*); |
31 CSSVariableResolver(StyleVariableData*, AtomicString& variable); | 31 CSSVariableResolver(StyleVariableData*, AtomicString& variable); |
32 | 32 |
33 struct ResolutionState { | 33 // Returns false if we encounter a reference to an invalid variable with no
fallback |
34 bool success; | 34 bool resolveFallback(CSSParserTokenRange, Vector<CSSParserToken>& result); |
35 // Resolution doesn't finish when a cycle is detected. Fallbacks still | 35 bool resolveVariableTokensRecursive(CSSParserTokenRange, Vector<CSSParserTok
en>& result); |
36 // need to be tracked for additional cycles, and invalidation only | 36 bool resolveVariableReferencesFromTokens(CSSParserTokenRange tokens, Vector<
CSSParserToken>& result); |
37 // applies back to cycle starts. This context member tracks all | |
38 // detected cycle start points. | |
39 HashSet<AtomicString> cycleStartPoints; | |
40 | |
41 ResolutionState() | |
42 : success(true) | |
43 { }; | |
44 }; | |
45 | |
46 void resolveFallback(CSSParserTokenRange, Vector<CSSParserToken>& result, Re
solutionState& context); | |
47 void resolveVariableTokensRecursive(CSSParserTokenRange, Vector<CSSParserTok
en>& result, ResolutionState& context); | |
48 void resolveVariableReferencesFromTokens(CSSParserTokenRange tokens, Vector<
CSSParserToken>& result, ResolutionState& context); | |
49 | 37 |
50 StyleVariableData* m_styleVariableData; | 38 StyleVariableData* m_styleVariableData; |
51 HashSet<AtomicString> m_variablesSeen; | 39 HashSet<AtomicString> m_variablesSeen; |
| 40 // Resolution doesn't finish when a cycle is detected. Fallbacks still |
| 41 // need to be tracked for additional cycles, and invalidation only |
| 42 // applies back to cycle starts. |
| 43 HashSet<AtomicString> m_cycleStartPoints; |
52 }; | 44 }; |
53 | 45 |
54 } // namespace blink | 46 } // namespace blink |
55 | 47 |
56 #endif // CSSVariableResolver | 48 #endif // CSSVariableResolver |
OLD | NEW |