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

Unified Diff: third_party/WebKit/Source/core/css/serializer/CSSDeserializeStream.h

Issue 1481383002: [Experimental] CSSSerializer Proof-of-concept Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: snapshot: top_25 sites ser/dser now works Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/css/serializer/CSSDeserializeStream.h
diff --git a/third_party/WebKit/Source/core/css/serializer/CSSDeserializeStream.h b/third_party/WebKit/Source/core/css/serializer/CSSDeserializeStream.h
new file mode 100644
index 0000000000000000000000000000000000000000..a113088e799da5fdd700bc4fa9761b22ec025bfd
--- /dev/null
+++ b/third_party/WebKit/Source/core/css/serializer/CSSDeserializeStream.h
@@ -0,0 +1,74 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CSSDeserializeStream_h
+#define CSSDeserializeStream_h
+
+#include "core/css/CSSValue.h"
+#include "core/dom/QualifiedName.h"
+#include "platform/graphics/Color.h"
+#include "wtf/Vector.h"
+#include "wtf/PassRefPtr.h"
+
+namespace blink {
+
+struct StylePropertyMetadata;
+struct Referrer;
+
+template<typename T> class CSSDeserializeTrait;
+
+class CSSDeserializeStream {
+ WTF_MAKE_NONCOPYABLE(CSSDeserializeStream);
+
+public:
+ CSSDeserializeStream(const char*, size_t);
+ CSSValue::ClassType readClassType();
+ Color readColor();
+ bool readBool();
+ int readInt();
+ unsigned readUnsigned();
+ double readDouble();
+ UChar32 readUChar32();
+ String readString();
+ AtomicString readAtomicString();
+ QualifiedName readQualifiedName();
+ StylePropertyMetadata readStylePropertyMetadata();
+ Referrer readReferrer();
+
+ template<typename T> T readIntAsEnum()
+ {
+ return static_cast<T>(readInt());
+ }
+
+ template<typename T> PassRefPtr<T> readNullableRef();
+
+private:
+ size_t unconsumedSize() const;
+ void padIfNeeded();
+
+ const char* m_ptr;
+ const char* m_ptrEnd;
+};
+
+template<typename T> class CSSDeserializeTrait {
+public:
+ static bool deserializeNonNullHeader(CSSDeserializeStream* stream)
+ {
+ return stream->readBool();
+ }
+};
+
+template<typename T>
+inline PassRefPtr<T> CSSDeserializeStream::readNullableRef()
+{
+ if (!CSSDeserializeTrait<T>::deserializeNonNullHeader(this)) {
+ return nullptr;
+ }
+
+ return T::deserialize(this);
+}
+
+} // namespace blink
+
+#endif // CSSDeserializeStream_h

Powered by Google App Engine
This is Rietveld 408576698