| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CSSDeserializeStream_h |
| 6 #define CSSDeserializeStream_h |
| 7 |
| 8 #include "core/css/CSSValue.h" |
| 9 #include "core/dom/QualifiedName.h" |
| 10 #include "platform/graphics/Color.h" |
| 11 #include "wtf/Vector.h" |
| 12 #include "wtf/PassRefPtr.h" |
| 13 |
| 14 namespace blink { |
| 15 |
| 16 struct StylePropertyMetadata; |
| 17 struct Referrer; |
| 18 |
| 19 template<typename T> class CSSDeserializeTrait; |
| 20 |
| 21 class CSSDeserializeStream { |
| 22 WTF_MAKE_NONCOPYABLE(CSSDeserializeStream); |
| 23 |
| 24 public: |
| 25 CSSDeserializeStream(const char*, size_t); |
| 26 CSSValue::ClassType readClassType(); |
| 27 Color readColor(); |
| 28 bool readBool(); |
| 29 int readInt(); |
| 30 unsigned readUnsigned(); |
| 31 double readDouble(); |
| 32 UChar32 readUChar32(); |
| 33 String readString(); |
| 34 AtomicString readAtomicString(); |
| 35 QualifiedName readQualifiedName(); |
| 36 StylePropertyMetadata readStylePropertyMetadata(); |
| 37 Referrer readReferrer(); |
| 38 |
| 39 template<typename T> T readIntAsEnum() |
| 40 { |
| 41 return static_cast<T>(readInt()); |
| 42 } |
| 43 |
| 44 template<typename T> PassRefPtr<T> readNullableRef(); |
| 45 |
| 46 private: |
| 47 size_t unconsumedSize() const; |
| 48 void padIfNeeded(); |
| 49 |
| 50 const char* m_ptr; |
| 51 const char* m_ptrEnd; |
| 52 }; |
| 53 |
| 54 template<typename T> class CSSDeserializeTrait { |
| 55 public: |
| 56 static bool deserializeNonNullHeader(CSSDeserializeStream* stream) |
| 57 { |
| 58 return stream->readBool(); |
| 59 } |
| 60 }; |
| 61 |
| 62 template<typename T> |
| 63 inline PassRefPtr<T> CSSDeserializeStream::readNullableRef() |
| 64 { |
| 65 if (!CSSDeserializeTrait<T>::deserializeNonNullHeader(this)) { |
| 66 return nullptr; |
| 67 } |
| 68 |
| 69 return T::deserialize(this); |
| 70 } |
| 71 |
| 72 } // namespace blink |
| 73 |
| 74 #endif // CSSDeserializeStream_h |
| OLD | NEW |