| 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" |
| 11 #include "wtf/text/AtomicString.h" | 11 #include "wtf/text/AtomicString.h" |
| 12 #include "wtf/text/AtomicStringHash.h" | 12 #include "wtf/text/AtomicStringHash.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 class CSSParserTokenRange; | 16 class CSSParserTokenRange; |
| 17 class CSSVariableReferenceValue; | 17 class CSSVariableReferenceValue; |
| 18 class StyleResolverState; | 18 class StyleResolverState; |
| 19 class StyleVariableData; | 19 class StyleVariableData; |
| 20 | 20 |
| 21 class CSSVariableResolver { | 21 class CSSVariableResolver { |
| 22 public: | 22 public: |
| 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 RawPtr<CSSValue> resolveVariableReferences(StyleVariableData*, CSSPro
pertyID, 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 struct ResolutionState { |
| 34 bool success; | 34 bool success; |
| 35 // Resolution doesn't finish when a cycle is detected. Fallbacks still | 35 // Resolution doesn't finish when a cycle is detected. Fallbacks still |
| 36 // need to be tracked for additional cycles, and invalidation only | 36 // need to be tracked for additional cycles, and invalidation only |
| 37 // applies back to cycle starts. This context member tracks all | 37 // applies back to cycle starts. This context member tracks all |
| 38 // detected cycle start points. | 38 // detected cycle start points. |
| 39 HashSet<AtomicString> cycleStartPoints; | 39 HashSet<AtomicString> cycleStartPoints; |
| 40 | 40 |
| 41 ResolutionState() | 41 ResolutionState() |
| 42 : success(true) | 42 : success(true) |
| 43 { }; | 43 { }; |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 void resolveFallback(CSSParserTokenRange, Vector<CSSParserToken>& result, Re
solutionState& context); | 46 void resolveFallback(CSSParserTokenRange, Vector<CSSParserToken>& result, Re
solutionState& context); |
| 47 void resolveVariableTokensRecursive(CSSParserTokenRange, Vector<CSSParserTok
en>& result, ResolutionState& context); | 47 void resolveVariableTokensRecursive(CSSParserTokenRange, Vector<CSSParserTok
en>& result, ResolutionState& context); |
| 48 void resolveVariableReferencesFromTokens(CSSParserTokenRange tokens, Vector<
CSSParserToken>& result, ResolutionState& context); | 48 void resolveVariableReferencesFromTokens(CSSParserTokenRange tokens, Vector<
CSSParserToken>& result, ResolutionState& context); |
| 49 | 49 |
| 50 StyleVariableData* m_styleVariableData; | 50 StyleVariableData* m_styleVariableData; |
| 51 HashSet<AtomicString> m_variablesSeen; | 51 HashSet<AtomicString> m_variablesSeen; |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 } // namespace blink | 54 } // namespace blink |
| 55 | 55 |
| 56 #endif // CSSVariableResolver | 56 #endif // CSSVariableResolver |
| OLD | NEW |