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

Side by Side Diff: third_party/WebKit/Source/core/css/MediaQuery.cpp

Issue 2017303002: Revert of Remove StringBuilder::appendLiteral. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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) 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 24 matching lines...) Expand all
35 #include "wtf/text/StringBuilder.h" 35 #include "wtf/text/StringBuilder.h"
36 36
37 namespace blink { 37 namespace blink {
38 38
39 // http://dev.w3.org/csswg/cssom/#serialize-a-media-query 39 // http://dev.w3.org/csswg/cssom/#serialize-a-media-query
40 String MediaQuery::serialize() const 40 String MediaQuery::serialize() const
41 { 41 {
42 StringBuilder result; 42 StringBuilder result;
43 switch (m_restrictor) { 43 switch (m_restrictor) {
44 case MediaQuery::Only: 44 case MediaQuery::Only:
45 result.append("only "); 45 result.appendLiteral("only ");
46 break; 46 break;
47 case MediaQuery::Not: 47 case MediaQuery::Not:
48 result.append("not "); 48 result.appendLiteral("not ");
49 break; 49 break;
50 case MediaQuery::None: 50 case MediaQuery::None:
51 break; 51 break;
52 } 52 }
53 53
54 if (m_expressions.isEmpty()) { 54 if (m_expressions.isEmpty()) {
55 result.append(m_mediaType); 55 result.append(m_mediaType);
56 return result.toString(); 56 return result.toString();
57 } 57 }
58 58
59 if (m_mediaType != MediaTypeNames::all || m_restrictor != None) { 59 if (m_mediaType != MediaTypeNames::all || m_restrictor != None) {
60 result.append(m_mediaType); 60 result.append(m_mediaType);
61 result.append(" and "); 61 result.appendLiteral(" and ");
62 } 62 }
63 63
64 result.append(m_expressions.at(0)->serialize()); 64 result.append(m_expressions.at(0)->serialize());
65 for (size_t i = 1; i < m_expressions.size(); ++i) { 65 for (size_t i = 1; i < m_expressions.size(); ++i) {
66 result.append(" and "); 66 result.appendLiteral(" and ");
67 result.append(m_expressions.at(i)->serialize()); 67 result.append(m_expressions.at(i)->serialize());
68 } 68 }
69 return result.toString(); 69 return result.toString();
70 } 70 }
71 71
72 static bool expressionCompare(const Member<MediaQueryExp>& a, const Member<Media QueryExp>& b) 72 static bool expressionCompare(const Member<MediaQueryExp>& a, const Member<Media QueryExp>& b)
73 { 73 {
74 return codePointCompare(a->serialize(), b->serialize()) < 0; 74 return codePointCompare(a->serialize(), b->serialize()) < 0;
75 } 75 }
76 76
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 } 133 }
134 134
135 DEFINE_TRACE(MediaQuery) 135 DEFINE_TRACE(MediaQuery)
136 { 136 {
137 // We don't support tracing of vectors of OwnPtrs (ie. OwnPtr<Vector<OwnPtr< MediaQuery>>>). 137 // We don't support tracing of vectors of OwnPtrs (ie. OwnPtr<Vector<OwnPtr< MediaQuery>>>).
138 // Since this is a transitional object we are just ifdef'ing it out when oil pan is not enabled. 138 // Since this is a transitional object we are just ifdef'ing it out when oil pan is not enabled.
139 visitor->trace(m_expressions); 139 visitor->trace(m_expressions);
140 } 140 }
141 141
142 } // namespace blink 142 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/MediaList.cpp ('k') | third_party/WebKit/Source/core/css/MediaQueryExp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698