| 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 CSSVariableData_h | 5 #ifndef CSSVariableData_h |
| 6 #define CSSVariableData_h | 6 #define CSSVariableData_h |
| 7 | 7 |
| 8 #include "core/css/StylePropertySet.h" | 8 #include "core/css/StylePropertySet.h" |
| 9 #include "core/css/parser/CSSParserToken.h" | 9 #include "core/css/parser/CSSParserToken.h" |
| 10 #include "core/css/parser/CSSParserTokenRange.h" | 10 #include "core/css/parser/CSSParserTokenRange.h" |
| 11 #include "wtf/Forward.h" | 11 #include "wtf/Forward.h" |
| 12 #include "wtf/PassRefPtr.h" | 12 #include "wtf/PassRefPtr.h" |
| 13 #include "wtf/text/WTFString.h" | 13 #include "wtf/text/WTFString.h" |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 | 16 |
| 17 class CSSParserTokenRange; | 17 class CSSParserTokenRange; |
| 18 class CSSSyntaxDescriptor; | 18 class CSSSyntaxDescriptor; |
| 19 | 19 |
| 20 class CSSVariableData : public RefCounted<CSSVariableData> { | 20 class CSSVariableData : public RefCounted<CSSVariableData> { |
| 21 WTF_MAKE_NONCOPYABLE(CSSVariableData); | 21 WTF_MAKE_NONCOPYABLE(CSSVariableData); |
| 22 USING_FAST_MALLOC(CSSVariableData); | 22 USING_FAST_MALLOC(CSSVariableData); |
| 23 | 23 |
| 24 public: | 24 public: |
| 25 static PassRefPtr<CSSVariableData> create( | 25 static PassRefPtr<CSSVariableData> create(const CSSParserTokenRange& range, |
| 26 const CSSParserTokenRange& range, | 26 bool isAnimationTainted, |
| 27 bool needsVariableResolution = true) { | 27 bool needsVariableResolution) { |
| 28 return adoptRef(new CSSVariableData(range, needsVariableResolution)); | 28 return adoptRef(new CSSVariableData(range, isAnimationTainted, |
| 29 needsVariableResolution)); |
| 29 } | 30 } |
| 30 | 31 |
| 31 static PassRefPtr<CSSVariableData> createResolved( | 32 static PassRefPtr<CSSVariableData> createResolved( |
| 32 const Vector<CSSParserToken>& resolvedTokens, | 33 const Vector<CSSParserToken>& resolvedTokens, |
| 33 const CSSVariableData& unresolvedData) { | 34 const CSSVariableData& unresolvedData, |
| 34 return adoptRef( | 35 bool isAnimationTainted) { |
| 35 new CSSVariableData(resolvedTokens, unresolvedData.m_backingString)); | 36 return adoptRef(new CSSVariableData( |
| 37 resolvedTokens, unresolvedData.m_backingString, isAnimationTainted)); |
| 36 } | 38 } |
| 37 | 39 |
| 38 CSSParserTokenRange tokenRange() const { return m_tokens; } | 40 CSSParserTokenRange tokenRange() const { return m_tokens; } |
| 39 | 41 |
| 40 const Vector<CSSParserToken>& tokens() const { return m_tokens; } | 42 const Vector<CSSParserToken>& tokens() const { return m_tokens; } |
| 41 | 43 |
| 42 bool operator==(const CSSVariableData& other) const; | 44 bool operator==(const CSSVariableData& other) const; |
| 43 | 45 |
| 46 bool isAnimationTainted() const { return m_isAnimationTainted; } |
| 47 |
| 44 bool needsVariableResolution() const { return m_needsVariableResolution; } | 48 bool needsVariableResolution() const { return m_needsVariableResolution; } |
| 45 | 49 |
| 46 const CSSValue* parseForSyntax(const CSSSyntaxDescriptor&) const; | 50 const CSSValue* parseForSyntax(const CSSSyntaxDescriptor&) const; |
| 47 | 51 |
| 48 StylePropertySet* propertySet(); | 52 StylePropertySet* propertySet(); |
| 49 | 53 |
| 50 private: | 54 private: |
| 51 CSSVariableData(const CSSParserTokenRange&, bool needsVariableResolution); | 55 CSSVariableData(const CSSParserTokenRange&, |
| 56 bool isAnimationTainted, |
| 57 bool needsVariableResolution); |
| 52 | 58 |
| 53 // We can safely copy the tokens (which have raw pointers to substrings) becau
se | 59 // We can safely copy the tokens (which have raw pointers to substrings) becau
se |
| 54 // StylePropertySets contain references to CSSCustomPropertyDeclarations, whic
h | 60 // StylePropertySets contain references to CSSCustomPropertyDeclarations, whic
h |
| 55 // point to the unresolved CSSVariableData values that own the backing strings | 61 // point to the unresolved CSSVariableData values that own the backing strings |
| 56 // this will potentially reference. | 62 // this will potentially reference. |
| 57 CSSVariableData(const Vector<CSSParserToken>& resolvedTokens, | 63 CSSVariableData(const Vector<CSSParserToken>& resolvedTokens, |
| 58 String backingString) | 64 String backingString, |
| 65 bool isAnimationTainted) |
| 59 : m_backingString(backingString), | 66 : m_backingString(backingString), |
| 60 m_tokens(resolvedTokens), | 67 m_tokens(resolvedTokens), |
| 68 m_isAnimationTainted(isAnimationTainted), |
| 61 m_needsVariableResolution(false), | 69 m_needsVariableResolution(false), |
| 62 m_cachedPropertySet(false) {} | 70 m_cachedPropertySet(false) {} |
| 63 | 71 |
| 64 void consumeAndUpdateTokens(const CSSParserTokenRange&); | 72 void consumeAndUpdateTokens(const CSSParserTokenRange&); |
| 65 template <typename CharacterType> | 73 template <typename CharacterType> |
| 66 void updateTokens(const CSSParserTokenRange&); | 74 void updateTokens(const CSSParserTokenRange&); |
| 67 | 75 |
| 68 String m_backingString; | 76 String m_backingString; |
| 69 Vector<CSSParserToken> m_tokens; | 77 Vector<CSSParserToken> m_tokens; |
| 78 const bool m_isAnimationTainted; |
| 70 const bool m_needsVariableResolution; | 79 const bool m_needsVariableResolution; |
| 71 | 80 |
| 72 // Parsed representation for @apply | 81 // Parsed representation for @apply |
| 73 bool m_cachedPropertySet; | 82 bool m_cachedPropertySet; |
| 74 Persistent<StylePropertySet> m_propertySet; | 83 Persistent<StylePropertySet> m_propertySet; |
| 75 }; | 84 }; |
| 76 | 85 |
| 77 } // namespace blink | 86 } // namespace blink |
| 78 | 87 |
| 79 #endif // CSSVariableData_h | 88 #endif // CSSVariableData_h |
| OLD | NEW |