OLD | NEW |
1 /* | 1 /* |
2 * CSS Media Query | 2 * CSS Media Query |
3 * | 3 * |
4 * Copyright (C) 2005, 2006 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>. | 4 * Copyright (C) 2005, 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 * | 6 * |
7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
9 * are met: | 9 * are met: |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 25 matching lines...) Expand all Loading... |
36 #include "wtf/text/StringBuilder.h" | 36 #include "wtf/text/StringBuilder.h" |
37 | 37 |
38 namespace blink { | 38 namespace blink { |
39 | 39 |
40 // http://dev.w3.org/csswg/cssom/#serialize-a-media-query | 40 // http://dev.w3.org/csswg/cssom/#serialize-a-media-query |
41 String MediaQuery::serialize() const | 41 String MediaQuery::serialize() const |
42 { | 42 { |
43 StringBuilder result; | 43 StringBuilder result; |
44 switch (m_restrictor) { | 44 switch (m_restrictor) { |
45 case MediaQuery::Only: | 45 case MediaQuery::Only: |
46 result.append("only "); | 46 result.appendLiteral("only "); |
47 break; | 47 break; |
48 case MediaQuery::Not: | 48 case MediaQuery::Not: |
49 result.append("not "); | 49 result.appendLiteral("not "); |
50 break; | 50 break; |
51 case MediaQuery::None: | 51 case MediaQuery::None: |
52 break; | 52 break; |
53 } | 53 } |
54 | 54 |
55 if (m_expressions->isEmpty()) { | 55 if (m_expressions->isEmpty()) { |
56 result.append(m_mediaType); | 56 result.append(m_mediaType); |
57 return result.toString(); | 57 return result.toString(); |
58 } | 58 } |
59 | 59 |
60 if (m_mediaType != MediaTypeNames::all || m_restrictor != None) { | 60 if (m_mediaType != MediaTypeNames::all || m_restrictor != None) { |
61 result.append(m_mediaType); | 61 result.append(m_mediaType); |
62 result.append(" and "); | 62 result.appendLiteral(" and "); |
63 } | 63 } |
64 | 64 |
65 result.append(m_expressions->at(0)->serialize()); | 65 result.append(m_expressions->at(0)->serialize()); |
66 for (size_t i = 1; i < m_expressions->size(); ++i) { | 66 for (size_t i = 1; i < m_expressions->size(); ++i) { |
67 result.append(" and "); | 67 result.appendLiteral(" and "); |
68 result.append(m_expressions->at(i)->serialize()); | 68 result.append(m_expressions->at(i)->serialize()); |
69 } | 69 } |
70 return result.toString(); | 70 return result.toString(); |
71 } | 71 } |
72 | 72 |
73 static bool expressionCompare(const OwnPtrWillBeMember<MediaQueryExp>& a, const
OwnPtrWillBeMember<MediaQueryExp>& b) | 73 static bool expressionCompare(const OwnPtrWillBeMember<MediaQueryExp>& a, const
OwnPtrWillBeMember<MediaQueryExp>& b) |
74 { | 74 { |
75 return codePointCompare(a->serialize(), b->serialize()) < 0; | 75 return codePointCompare(a->serialize(), b->serialize()) < 0; |
76 } | 76 } |
77 | 77 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 void MediaQuery::trace(Visitor* visitor) | 136 void MediaQuery::trace(Visitor* visitor) |
137 { | 137 { |
138 // We don't support tracing of vectors of OwnPtrs (ie. OwnPtr<Vector<OwnPtr<
MediaQuery> > >). | 138 // We don't support tracing of vectors of OwnPtrs (ie. OwnPtr<Vector<OwnPtr<
MediaQuery> > >). |
139 // Since this is a transitional object we are just ifdef'ing it out when oil
pan is not enabled. | 139 // Since this is a transitional object we are just ifdef'ing it out when oil
pan is not enabled. |
140 #if ENABLE(OILPAN) | 140 #if ENABLE(OILPAN) |
141 visitor->trace(m_expressions); | 141 visitor->trace(m_expressions); |
142 #endif | 142 #endif |
143 } | 143 } |
144 | 144 |
145 } | 145 } |
OLD | NEW |