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

Unified Diff: third_party/WebKit/Source/core/css/MediaQuery.cpp

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
« no previous file with comments | « third_party/WebKit/Source/core/css/MediaQuery.h ('k') | third_party/WebKit/Source/core/css/MediaQueryExp.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/css/MediaQuery.cpp
diff --git a/third_party/WebKit/Source/core/css/MediaQuery.cpp b/third_party/WebKit/Source/core/css/MediaQuery.cpp
index 204208702384b3abecd71816f6ca73739cbda95f..6e051fc89c35b8f485fe8945d2047ae66ad5a363 100644
--- a/third_party/WebKit/Source/core/css/MediaQuery.cpp
+++ b/third_party/WebKit/Source/core/css/MediaQuery.cpp
@@ -30,6 +30,8 @@
#include "core/MediaTypeNames.h"
#include "core/css/MediaQueryExp.h"
+#include "core/css/serializer/CSSDeserializeStream.h"
+#include "core/css/serializer/CSSSerializeStream.h"
#include "core/html/parser/HTMLParserIdioms.h"
#include "wtf/NonCopyingSort.h"
#include "wtf/text/StringBuilder.h"
@@ -132,6 +134,30 @@ String MediaQuery::cssText() const
return m_serializationCache;
}
+void MediaQuery::serialize(CSSSerializeStream* stream) const
+{
+ stream->writeEnumAsInt<Restrictor>(m_restrictor);
+ stream->writeString(m_mediaType);
+
+ stream->writeUnsigned(m_expressions->size());
+ for (const OwnPtrWillBeMember<MediaQueryExp>& exp : *m_expressions)
+ exp->serialize(stream);
+}
+
+PassOwnPtrWillBeRawPtr<MediaQuery> MediaQuery::deserialize(CSSDeserializeStream* stream)
+{
+ Restrictor restrictor = stream->readIntAsEnum<Restrictor>();
+ String mediaType = stream->readString();
+
+ OwnPtrWillBeMember<ExpressionHeapVector> expressions = adoptPtrWillBeNoop(new ExpressionHeapVector);
+ unsigned size = stream->readUnsigned();
+ expressions->reserveCapacity(size);
+ for (unsigned i = 0; i < size; ++ i)
+ expressions->append(MediaQueryExp::deserialize(stream));
+
+ return adoptPtrWillBeNoop(new MediaQuery(restrictor, mediaType, expressions.release()));
+}
+
DEFINE_TRACE(MediaQuery)
{
// We don't support tracing of vectors of OwnPtrs (ie. OwnPtr<Vector<OwnPtr<MediaQuery>>>).
« no previous file with comments | « third_party/WebKit/Source/core/css/MediaQuery.h ('k') | third_party/WebKit/Source/core/css/MediaQueryExp.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698