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

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

Issue 1698203002: Simplify CSS variables resolution logic [1 of 2] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more tests Created 4 years, 10 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 "wtf/HashSet.h" 10 #include "wtf/HashSet.h"
(...skipping 12 matching lines...) Expand all
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698