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 CSSVariableData; |
17 class CSSVariableReferenceValue; | 18 class CSSVariableReferenceValue; |
18 class StyleResolverState; | 19 class StyleResolverState; |
19 class StyleVariableData; | 20 class StyleVariableData; |
20 | 21 |
21 class CSSVariableResolver { | 22 class CSSVariableResolver { |
22 public: | 23 public: |
23 static void resolveVariableDefinitions(StyleVariableData*); | 24 static void resolveVariableDefinitions(StyleVariableData*); |
24 static void resolveAndApplyVariableReferences(StyleResolverState&, CSSProper
tyID, const CSSVariableReferenceValue&); | 25 static void resolveAndApplyVariableReferences(StyleResolverState&, CSSProper
tyID, const CSSVariableReferenceValue&); |
25 | 26 |
26 // Shorthand properties are not supported. | 27 // Shorthand properties are not supported. |
27 static PassRefPtrWillBeRawPtr<CSSValue> resolveVariableReferences(StyleVaria
bleData*, CSSPropertyID, const CSSVariableReferenceValue&); | 28 static PassRefPtrWillBeRawPtr<CSSValue> resolveVariableReferences(StyleVaria
bleData*, CSSPropertyID, const CSSVariableReferenceValue&); |
28 | 29 |
29 private: | 30 private: |
30 CSSVariableResolver(StyleVariableData*); | 31 CSSVariableResolver(StyleVariableData*); |
31 CSSVariableResolver(StyleVariableData*, AtomicString& variable); | |
32 | 32 |
33 // Returns false if we encounter a reference to an invalid variable with no
fallback | 33 // These return false if we encounter a reference to an invalid variable wit
h no fallback |
| 34 |
| 35 // Resolves a range which may contain var() references |
| 36 bool resolveTokenRange(CSSParserTokenRange, Vector<CSSParserToken>& result); |
| 37 // Resolves the fallback (if present) of a var() reference, starting from th
e comma |
34 bool resolveFallback(CSSParserTokenRange, Vector<CSSParserToken>& result); | 38 bool resolveFallback(CSSParserTokenRange, Vector<CSSParserToken>& result); |
35 bool resolveVariableTokensRecursive(CSSParserTokenRange, Vector<CSSParserTok
en>& result); | 39 // Resolves the contents of a var() reference |
36 bool resolveVariableReferencesFromTokens(CSSParserTokenRange tokens, Vector<
CSSParserToken>& result); | 40 bool resolveVariableReference(CSSParserTokenRange, Vector<CSSParserToken>& r
esult); |
| 41 |
| 42 // These return null if the custom property is invalid |
| 43 |
| 44 // Returns the CSSVariableData for a custom property, resolving and storing
it if necessary |
| 45 CSSVariableData* valueForCustomProperty(AtomicString name); |
| 46 // Resolves the CSSVariableData from a custom property declaration |
| 47 PassRefPtr<CSSVariableData> resolveCustomProperty(AtomicString name, const C
SSVariableData&); |
37 | 48 |
38 StyleVariableData* m_styleVariableData; | 49 StyleVariableData* m_styleVariableData; |
39 HashSet<AtomicString> m_variablesSeen; | 50 HashSet<AtomicString> m_variablesSeen; |
40 // Resolution doesn't finish when a cycle is detected. Fallbacks still | 51 // Resolution doesn't finish when a cycle is detected. Fallbacks still |
41 // need to be tracked for additional cycles, and invalidation only | 52 // need to be tracked for additional cycles, and invalidation only |
42 // applies back to cycle starts. | 53 // applies back to cycle starts. |
43 HashSet<AtomicString> m_cycleStartPoints; | 54 HashSet<AtomicString> m_cycleStartPoints; |
44 }; | 55 }; |
45 | 56 |
46 } // namespace blink | 57 } // namespace blink |
47 | 58 |
48 #endif // CSSVariableResolver | 59 #endif // CSSVariableResolver |
OLD | NEW |