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

Side by Side Diff: third_party/WebKit/Source/core/css/MediaQueryExp.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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * CSS Media Query 2 * CSS Media Query
3 * 3 *
4 * Copyright (C) 2006 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>. 4 * Copyright (C) 2006 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>.
5 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 5 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
6 * Copyright (C) 2013 Apple Inc. All rights reserved. 6 * Copyright (C) 2013 Apple Inc. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
(...skipping 12 matching lines...) Expand all
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
25 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */ 28 */
29 29
30 #include "core/css/MediaQueryExp.h" 30 #include "core/css/MediaQueryExp.h"
31 31
32 #include "core/css/parser/CSSParserToken.h" 32 #include "core/css/parser/CSSParserToken.h"
33 #include "core/css/serializer/CSSDeserializeStream.h"
34 #include "core/css/serializer/CSSSerializeStream.h"
33 #include "core/html/parser/HTMLParserIdioms.h" 35 #include "core/html/parser/HTMLParserIdioms.h"
34 #include "platform/Decimal.h" 36 #include "platform/Decimal.h"
35 #include "platform/RuntimeEnabledFeatures.h" 37 #include "platform/RuntimeEnabledFeatures.h"
36 #include "wtf/text/StringBuffer.h" 38 #include "wtf/text/StringBuffer.h"
37 #include "wtf/text/StringBuilder.h" 39 #include "wtf/text/StringBuilder.h"
38 40
39 namespace blink { 41 namespace blink {
40 42
41 using namespace MediaFeatureNames; 43 using namespace MediaFeatureNames;
42 44
45 void MediaQueryExpValue::serialize(CSSSerializeStream* stream) const
46 {
47 stream->writeEnumAsInt<CSSValueID>(id);
48 stream->writeDouble(value);
49 stream->writeEnumAsInt<CSSPrimitiveValue::UnitType>(unit);
50 stream->writeUnsigned(numerator);
51 stream->writeUnsigned(denominator);
52 stream->writeBool(isID);
53 stream->writeBool(isValue);
54 stream->writeBool(isRatio);
55 }
56
57 MediaQueryExpValue MediaQueryExpValue::deserialize(CSSDeserializeStream* stream)
58 {
59 MediaQueryExpValue value;
60 value.id = stream->readIntAsEnum<CSSValueID>();
61 value.value = stream->readDouble();
62 value.unit = stream->readIntAsEnum<CSSPrimitiveValue::UnitType>();
63 value.numerator = stream->readUnsigned();
64 value.denominator = stream->readUnsigned();
65 value.isID = stream->readBool();
66 value.isValue = stream->readBool();
67 value.isRatio = stream->readBool();
68 return value;
69 }
70
43 static inline bool featureWithValidIdent(const String& mediaFeature, CSSValueID ident) 71 static inline bool featureWithValidIdent(const String& mediaFeature, CSSValueID ident)
44 { 72 {
45 if (mediaFeature == displayModeMediaFeature) 73 if (mediaFeature == displayModeMediaFeature)
46 return ident == CSSValueFullscreen || ident == CSSValueStandalone || ide nt == CSSValueMinimalUi || ident == CSSValueBrowser; 74 return ident == CSSValueFullscreen || ident == CSSValueStandalone || ide nt == CSSValueMinimalUi || ident == CSSValueBrowser;
47 75
48 if (mediaFeature == orientationMediaFeature) 76 if (mediaFeature == orientationMediaFeature)
49 return ident == CSSValuePortrait || ident == CSSValueLandscape; 77 return ident == CSSValuePortrait || ident == CSSValueLandscape;
50 78
51 if (mediaFeature == pointerMediaFeature || mediaFeature == anyPointerMediaFe ature) 79 if (mediaFeature == pointerMediaFeature || mediaFeature == anyPointerMediaFe ature)
52 return ident == CSSValueNone || ident == CSSValueCoarse || ident == CSSV alueFine; 80 return ident == CSSValueNone || ident == CSSValueCoarse || ident == CSSV alueFine;
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 output.append(printNumber(numerator)); 323 output.append(printNumber(numerator));
296 output.append('/'); 324 output.append('/');
297 output.append(printNumber(denominator)); 325 output.append(printNumber(denominator));
298 } else if (isID) { 326 } else if (isID) {
299 output.append(getValueName(id)); 327 output.append(getValueName(id));
300 } 328 }
301 329
302 return output.toString(); 330 return output.toString();
303 } 331 }
304 332
333 void MediaQueryExp::serialize(CSSSerializeStream* stream) const
334 {
335 stream->writeString(m_mediaFeature);
336 m_expValue.serialize(stream);
337 }
338
339 PassOwnPtrWillBeRawPtr<MediaQueryExp> MediaQueryExp::deserialize(CSSDeserializeS tream* stream)
340 {
341 String mediaFeature = stream->readString();
342 MediaQueryExpValue expValue = MediaQueryExpValue::deserialize(stream);
343 return adoptPtrWillBeNoop(new MediaQueryExp(mediaFeature, expValue));
344 }
345
305 } // namespace 346 } // namespace
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/MediaQueryExp.h ('k') | third_party/WebKit/Source/core/css/StylePropertySet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698