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

Side by Side Diff: Source/core/css/MediaQueryExp.cpp

Issue 482753002: Use StringBuilder::appendLiteral() / StringBuilder::append(char) when possible (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/css/MediaQuery.cpp ('k') | Source/core/css/MediaQuerySetTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 bool MediaQueryExp::operator==(const MediaQueryExp& other) const 301 bool MediaQueryExp::operator==(const MediaQueryExp& other) const
302 { 302 {
303 return (other.m_mediaFeature == m_mediaFeature) 303 return (other.m_mediaFeature == m_mediaFeature)
304 && ((!other.m_expValue.isValid() && !m_expValue.isValid()) 304 && ((!other.m_expValue.isValid() && !m_expValue.isValid())
305 || (other.m_expValue.isValid() && m_expValue.isValid() && other.m_ex pValue.equals(m_expValue))); 305 || (other.m_expValue.isValid() && m_expValue.isValid() && other.m_ex pValue.equals(m_expValue)));
306 } 306 }
307 307
308 String MediaQueryExp::serialize() const 308 String MediaQueryExp::serialize() const
309 { 309 {
310 StringBuilder result; 310 StringBuilder result;
311 result.append("("); 311 result.append('(');
312 result.append(m_mediaFeature.lower()); 312 result.append(m_mediaFeature.lower());
313 if (m_expValue.isValid()) { 313 if (m_expValue.isValid()) {
314 result.append(": "); 314 result.appendLiteral(": ");
315 result.append(m_expValue.cssText()); 315 result.append(m_expValue.cssText());
316 } 316 }
317 result.append(")"); 317 result.append(')');
318 318
319 return result.toString(); 319 return result.toString();
320 } 320 }
321 321
322 static inline String printNumber(double number) 322 static inline String printNumber(double number)
323 { 323 {
324 return Decimal::fromDouble(number).toString(); 324 return Decimal::fromDouble(number).toString();
325 } 325 }
326 326
327 String MediaQueryExpValue::cssText() const 327 String MediaQueryExpValue::cssText() const
328 { 328 {
329 StringBuilder output; 329 StringBuilder output;
330 if (isValue) { 330 if (isValue) {
331 output.append(printNumber(value)); 331 output.append(printNumber(value));
332 output.append(CSSPrimitiveValue::unitTypeToString(unit)); 332 output.append(CSSPrimitiveValue::unitTypeToString(unit));
333 } else if (isRatio) { 333 } else if (isRatio) {
334 output.append(printNumber(numerator)); 334 output.append(printNumber(numerator));
335 output.append("/"); 335 output.append('/');
336 output.append(printNumber(denominator)); 336 output.append(printNumber(denominator));
337 } else if (isID) { 337 } else if (isID) {
338 output.append(getValueName(id)); 338 output.append(getValueName(id));
339 } 339 }
340 340
341 return output.toString(); 341 return output.toString();
342 } 342 }
343 343
344 } // namespace 344 } // namespace
OLDNEW
« no previous file with comments | « Source/core/css/MediaQuery.cpp ('k') | Source/core/css/MediaQuerySetTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698