diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-09-10 19:10:20 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-09-10 19:10:20 +0200 |
commit | 284837daa07b29d6a63a748544a90b1f5842ac5c (patch) | |
tree | ecd258180bde91fe741e0cfd2638beb3c6da7e8e /Source/WebCore/css/CSSGradientValue.cpp | |
parent | 2e2ba8ff45915f40ed3e014101269c175f2a89a0 (diff) | |
download | qtwebkit-284837daa07b29d6a63a748544a90b1f5842ac5c.tar.gz |
Imported WebKit commit 68645295d2e3e09af2c942f092556f06aa5f8b0d (http://svn.webkit.org/repository/webkit/trunk@128073)
New snapshot
Diffstat (limited to 'Source/WebCore/css/CSSGradientValue.cpp')
-rw-r--r-- | Source/WebCore/css/CSSGradientValue.cpp | 182 |
1 files changed, 112 insertions, 70 deletions
diff --git a/Source/WebCore/css/CSSGradientValue.cpp b/Source/WebCore/css/CSSGradientValue.cpp index c7daacc87..fc485f918 100644 --- a/Source/WebCore/css/CSSGradientValue.cpp +++ b/Source/WebCore/css/CSSGradientValue.cpp @@ -33,11 +33,12 @@ #include "Image.h" #include "IntSize.h" #include "IntSizeHash.h" -#include "MemoryInstrumentation.h" #include "NodeRenderStyle.h" -#include "PlatformString.h" #include "RenderObject.h" #include "StyleResolver.h" +#include "WebCoreMemoryInstrumentation.h" +#include <wtf/text/StringBuilder.h> +#include <wtf/text/WTFString.h> using namespace std; @@ -45,7 +46,7 @@ namespace WebCore { void CSSGradientColorStop::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const { - MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS); info.addInstrumentedMember(m_position); info.addInstrumentedMember(m_color); } @@ -462,7 +463,7 @@ bool CSSGradientValue::isCacheable() const void CSSGradientValue::reportBaseClassMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const { - MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS); CSSImageGeneratorValue::reportBaseClassMemoryUsage(memoryObjectInfo); info.addInstrumentedMember(m_firstX); info.addInstrumentedMember(m_firstY); @@ -473,51 +474,71 @@ void CSSGradientValue::reportBaseClassMemoryUsage(MemoryObjectInfo* memoryObject String CSSLinearGradientValue::customCssText() const { - String result; + StringBuilder result; if (m_deprecatedType) { - result = "-webkit-gradient(linear, "; - result += m_firstX->cssText() + " "; - result += m_firstY->cssText() + ", "; - result += m_secondX->cssText() + " "; - result += m_secondY->cssText(); + result.appendLiteral("-webkit-gradient(linear, "); + result.append(m_firstX->cssText()); + result.append(' '); + result.append(m_firstY->cssText()); + result.appendLiteral(", "); + result.append(m_secondX->cssText()); + result.append(' '); + result.append(m_secondY->cssText()); for (unsigned i = 0; i < m_stops.size(); i++) { const CSSGradientColorStop& stop = m_stops[i]; - result += ", "; - if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 0) - result += "from(" + stop.m_color->cssText() + ")"; - else if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 1) - result += "to(" + stop.m_color->cssText() + ")"; - else - result += "color-stop(" + String::number(stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER)) + ", " + stop.m_color->cssText() + ")"; + result.appendLiteral(", "); + if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 0) { + result.appendLiteral("from("); + result.append(stop.m_color->cssText()); + result.append(')'); + } else if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 1) { + result.appendLiteral("to("); + result.append(stop.m_color->cssText()); + result.append(')'); + } else { + result.appendLiteral("color-stop("); + result.append(String::number(stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER))); + result.appendLiteral(", "); + result.append(stop.m_color->cssText()); + result.append(')'); + } } } else { - result = m_repeating ? "-webkit-repeating-linear-gradient(" : "-webkit-linear-gradient("; + if (m_repeating) + result.appendLiteral("-webkit-repeating-linear-gradient("); + else + result.appendLiteral("-webkit-linear-gradient("); + if (m_angle) - result += m_angle->cssText(); + result.append(m_angle->cssText()); else { - if (m_firstX && m_firstY) - result += m_firstX->cssText() + " " + m_firstY->cssText(); - else if (m_firstX || m_firstY) { + if (m_firstX && m_firstY) { + result.append(m_firstX->cssText()); + result.append(' '); + result.append(m_firstY->cssText()); + } else if (m_firstX || m_firstY) { if (m_firstX) - result += m_firstX->cssText(); + result.append(m_firstX->cssText()); if (m_firstY) - result += m_firstY->cssText(); + result.append(m_firstY->cssText()); } } for (unsigned i = 0; i < m_stops.size(); i++) { const CSSGradientColorStop& stop = m_stops[i]; - result += ", "; - result += stop.m_color->cssText(); - if (stop.m_position) - result += " " + stop.m_position->cssText(); + result.appendLiteral(", "); + result.append(stop.m_color->cssText()); + if (stop.m_position) { + result.append(' '); + result.append(stop.m_position->cssText()); + } } } - result += ")"; - return result; + result.append(')'); + return result.toString(); } // Compute the endpoints so that a gradient of the given angle covers a box of the given size. @@ -615,78 +636,99 @@ PassRefPtr<Gradient> CSSLinearGradientValue::createGradient(RenderObject* render void CSSLinearGradientValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const { - MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS); CSSGradientValue::reportBaseClassMemoryUsage(memoryObjectInfo); info.addInstrumentedMember(m_angle); } String CSSRadialGradientValue::customCssText() const { - String result; + StringBuilder result; if (m_deprecatedType) { - result = "-webkit-gradient(radial, "; - - result += m_firstX->cssText() + " "; - result += m_firstY->cssText() + ", "; - result += m_firstRadius->cssText() + ", "; - result += m_secondX->cssText() + " "; - result += m_secondY->cssText(); - result += ", "; - result += m_secondRadius->cssText(); + result.appendLiteral("-webkit-gradient(radial, "); + result.append(m_firstX->cssText()); + result.append(' '); + result.append(m_firstY->cssText()); + result.appendLiteral(", "); + result.append(m_firstRadius->cssText()); + result.appendLiteral(", "); + result.append(m_secondX->cssText()); + result.append(' '); + result.append(m_secondY->cssText()); + result.appendLiteral(", "); + result.append(m_secondRadius->cssText()); // FIXME: share? for (unsigned i = 0; i < m_stops.size(); i++) { const CSSGradientColorStop& stop = m_stops[i]; - result += ", "; - if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 0) - result += "from(" + stop.m_color->cssText() + ")"; - else if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 1) - result += "to(" + stop.m_color->cssText() + ")"; - else - result += "color-stop(" + String::number(stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER)) + ", " + stop.m_color->cssText() + ")"; + result.appendLiteral(", "); + if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 0) { + result.appendLiteral("from("); + result.append(stop.m_color->cssText()); + result.append(')'); + } else if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 1) { + result.appendLiteral("to("); + result.append(stop.m_color->cssText()); + result.append(')'); + } else { + result.appendLiteral("color-stop("); + result.append(String::number(stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER))); + result.appendLiteral(", "); + result.append(stop.m_color->cssText()); + result.append(')'); + } } } else { + if (m_repeating) + result.appendLiteral("-webkit-repeating-radial-gradient("); + else + result.appendLiteral("-webkit-radial-gradient("); - result = m_repeating ? "-webkit-repeating-radial-gradient(" : "-webkit-radial-gradient("; if (m_firstX && m_firstY) { - result += m_firstX->cssText() + " " + m_firstY->cssText(); + result.append(m_firstX->cssText()); + result.append(' '); + result.append(m_firstY->cssText()); } else if (m_firstX) - result += m_firstX->cssText(); + result.append(m_firstX->cssText()); else if (m_firstY) - result += m_firstY->cssText(); + result.append(m_firstY->cssText()); else - result += "center"; - + result.appendLiteral("center"); if (m_shape || m_sizingBehavior) { - result += ", "; - if (m_shape) - result += m_shape->cssText() + " "; - else - result += "ellipse "; + result.appendLiteral(", "); + if (m_shape) { + result.append(m_shape->cssText()); + result.append(' '); + } else + result.appendLiteral("ellipse "); if (m_sizingBehavior) - result += m_sizingBehavior->cssText(); + result.append(m_sizingBehavior->cssText()); else - result += "cover"; + result.appendLiteral("cover"); } else if (m_endHorizontalSize && m_endVerticalSize) { - result += ", "; - result += m_endHorizontalSize->cssText() + " " + m_endVerticalSize->cssText(); + result.appendLiteral(", "); + result.append(m_endHorizontalSize->cssText()); + result.append(' '); + result.append(m_endVerticalSize->cssText()); } for (unsigned i = 0; i < m_stops.size(); i++) { const CSSGradientColorStop& stop = m_stops[i]; - result += ", "; - result += stop.m_color->cssText(); - if (stop.m_position) - result += " " + stop.m_position->cssText(); + result.appendLiteral(", "); + result.append(stop.m_color->cssText()); + if (stop.m_position) { + result.append(' '); + result.append(stop.m_position->cssText()); + } } } - result += ")"; - return result; + result.append(')'); + return result.toString(); } float CSSRadialGradientValue::resolveRadius(CSSPrimitiveValue* radius, RenderStyle* style, RenderStyle* rootStyle, float* widthOrHeight) @@ -919,7 +961,7 @@ PassRefPtr<Gradient> CSSRadialGradientValue::createGradient(RenderObject* render void CSSRadialGradientValue::reportDescendantMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const { - MemoryClassInfo info(memoryObjectInfo, this, MemoryInstrumentation::CSS); + MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS); CSSGradientValue::reportBaseClassMemoryUsage(memoryObjectInfo); info.addInstrumentedMember(m_firstRadius); info.addInstrumentedMember(m_secondRadius); |