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

Side by Side Diff: Source/core/css/StylePropertySerializer.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/MediaQuerySetTest.cpp ('k') | Source/core/css/parser/BisonCSSParserTest.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 * (C) 1999-2003 Lars Knoll (knoll@kde.org) 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved.
4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. 4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved.
5 * Copyright (C) 2013 Intel Corporation. All rights reserved. 5 * Copyright (C) 2013 Intel Corporation. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 { 708 {
709 // FIXME: Ensure initial values do not appear in CSS_VALUE_LISTS. 709 // FIXME: Ensure initial values do not appear in CSS_VALUE_LISTS.
710 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, initialRepeatValue, (CSSPrimitiveValue::create(CSSValueRepeat))); 710 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, initialRepeatValue, (CSSPrimitiveValue::create(CSSValueRepeat)));
711 const CSSPrimitiveValue& repeatX = repeatXCSSValue.isInitialValue() ? *initi alRepeatValue : toCSSPrimitiveValue(repeatXCSSValue); 711 const CSSPrimitiveValue& repeatX = repeatXCSSValue.isInitialValue() ? *initi alRepeatValue : toCSSPrimitiveValue(repeatXCSSValue);
712 const CSSPrimitiveValue& repeatY = repeatYCSSValue.isInitialValue() ? *initi alRepeatValue : toCSSPrimitiveValue(repeatYCSSValue); 712 const CSSPrimitiveValue& repeatY = repeatYCSSValue.isInitialValue() ? *initi alRepeatValue : toCSSPrimitiveValue(repeatYCSSValue);
713 CSSValueID repeatXValueId = repeatX.getValueID(); 713 CSSValueID repeatXValueId = repeatX.getValueID();
714 CSSValueID repeatYValueId = repeatY.getValueID(); 714 CSSValueID repeatYValueId = repeatY.getValueID();
715 if (repeatXValueId == repeatYValueId) { 715 if (repeatXValueId == repeatYValueId) {
716 builder.append(repeatX.cssText()); 716 builder.append(repeatX.cssText());
717 } else if (repeatXValueId == CSSValueNoRepeat && repeatYValueId == CSSValueR epeat) { 717 } else if (repeatXValueId == CSSValueNoRepeat && repeatYValueId == CSSValueR epeat) {
718 builder.append("repeat-y"); 718 builder.appendLiteral("repeat-y");
719 } else if (repeatXValueId == CSSValueRepeat && repeatYValueId == CSSValueNoR epeat) { 719 } else if (repeatXValueId == CSSValueRepeat && repeatYValueId == CSSValueNoR epeat) {
720 builder.append("repeat-x"); 720 builder.appendLiteral("repeat-x");
721 } else { 721 } else {
722 builder.append(repeatX.cssText()); 722 builder.append(repeatX.cssText());
723 builder.append(" "); 723 builder.appendLiteral(" ");
724 builder.append(repeatY.cssText()); 724 builder.append(repeatY.cssText());
725 } 725 }
726 } 726 }
727 727
728 String StylePropertySerializer::backgroundRepeatPropertyValue() const 728 String StylePropertySerializer::backgroundRepeatPropertyValue() const
729 { 729 {
730 RefPtrWillBeRawPtr<CSSValue> repeatX = m_propertySet.getPropertyCSSValue(CSS PropertyBackgroundRepeatX); 730 RefPtrWillBeRawPtr<CSSValue> repeatX = m_propertySet.getPropertyCSSValue(CSS PropertyBackgroundRepeatX);
731 RefPtrWillBeRawPtr<CSSValue> repeatY = m_propertySet.getPropertyCSSValue(CSS PropertyBackgroundRepeatY); 731 RefPtrWillBeRawPtr<CSSValue> repeatY = m_propertySet.getPropertyCSSValue(CSS PropertyBackgroundRepeatY);
732 if (!repeatX || !repeatY) 732 if (!repeatX || !repeatY)
733 return String(); 733 return String();
(...skipping 21 matching lines...) Expand all
755 } else if (repeatY->cssValueType() == CSSValue::CSS_VALUE_LIST) { 755 } else if (repeatY->cssValueType() == CSSValue::CSS_VALUE_LIST) {
756 repeatYList = toCSSValueList(repeatY.get()); 756 repeatYList = toCSSValueList(repeatY.get());
757 } else { 757 } else {
758 return String(); 758 return String();
759 } 759 }
760 760
761 size_t shorthandLength = lowestCommonMultiple(repeatXList->length(), repeatY List->length()); 761 size_t shorthandLength = lowestCommonMultiple(repeatXList->length(), repeatY List->length());
762 StringBuilder builder; 762 StringBuilder builder;
763 for (size_t i = 0; i < shorthandLength; ++i) { 763 for (size_t i = 0; i < shorthandLength; ++i) {
764 if (i) 764 if (i)
765 builder.append(", "); 765 builder.appendLiteral(", ");
766 appendBackgroundRepeatValue(builder, 766 appendBackgroundRepeatValue(builder,
767 *repeatXList->item(i % repeatXList->length()), 767 *repeatXList->item(i % repeatXList->length()),
768 *repeatYList->item(i % repeatYList->length())); 768 *repeatYList->item(i % repeatYList->length()));
769 } 769 }
770 return builder.toString(); 770 return builder.toString();
771 } 771 }
772 772
773 void StylePropertySerializer::appendBackgroundPropertyAsText(StringBuilder& resu lt, unsigned& numDecls) const 773 void StylePropertySerializer::appendBackgroundPropertyAsText(StringBuilder& resu lt, unsigned& numDecls) const
774 { 774 {
775 if (isPropertyShorthandAvailable(backgroundShorthand())) { 775 if (isPropertyShorthandAvailable(backgroundShorthand())) {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 isInitialValue = false; 866 isInitialValue = false;
867 if (!value->isInheritedValue()) 867 if (!value->isInheritedValue())
868 isInheritedValue = false; 868 isInheritedValue = false;
869 if (isImportant != m_propertySet.propertyIsImportant(shorthand.propertie s()[i])) 869 if (isImportant != m_propertySet.propertyIsImportant(shorthand.propertie s()[i]))
870 return false; 870 return false;
871 } 871 }
872 return isInitialValue || isInheritedValue; 872 return isInitialValue || isInheritedValue;
873 } 873 }
874 874
875 } 875 }
OLDNEW
« no previous file with comments | « Source/core/css/MediaQuerySetTest.cpp ('k') | Source/core/css/parser/BisonCSSParserTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698