⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 118639 in webkit


Ignore:
Timestamp:
May 27, 2012, 6:53:17 PM (14 years ago)
Author:
macpherson@chromium.org
Message:

Use StringBuilder in WebKitCSSTransformValue::customCssText() to allow code reuse with CSS Variables.
https://bugs.webkit.org/show_bug.cgi?id=87462

Reviewed by Dimitri Glazkov.

Factor out strings into a const char* array, and use a StringBuilder instead of String concatenation.
This will allow future code to re-use the array of transform names, and StringBuilder is generally faster.

Covered by existing CSS transform tests.

  • css/WebKitCSSTransformValue.cpp:

(WebCore):
(WebCore::WebKitCSSTransformValue::customCssText):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r118632 r118639  
     12012-05-27  Luke Macpherson  <macpherson@chromium.org>
     2
     3        Use StringBuilder in WebKitCSSTransformValue::customCssText() to allow code reuse with CSS Variables.
     4        https://bugs.webkit.org/show_bug.cgi?id=87462
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        Factor out strings into a const char* array, and use a StringBuilder instead of String concatenation.
     9        This will allow future code to re-use the array of transform names, and StringBuilder is generally faster.
     10
     11        Covered by existing CSS transform tests.
     12
     13        * css/WebKitCSSTransformValue.cpp:
     14        (WebCore):
     15        (WebCore::WebKitCSSTransformValue::customCssText):
     16
    1172012-05-27  Arvid Nilsson  <anilsson@rim.com>
    218
  • trunk/Source/WebCore/css/WebKitCSSTransformValue.cpp

    r113588 r118639  
    3030#include "PlatformString.h"
    3131#include <wtf/PassRefPtr.h>
     32#include <wtf/text/StringBuilder.h>
    3233
    3334namespace WebCore {
     35
     36const int transformNameSize = 22;
     37const char* const transformName[transformNameSize] = {
     38     "",
     39     "translate",
     40     "translateX",
     41     "translateY",
     42     "rotate",
     43     "scale",
     44     "scaleX",
     45     "scaleY",
     46     "skew",
     47     "skewX",
     48     "skewY",
     49     "matrix",
     50     "translateZ",
     51     "translate3d",
     52     "rotateX",
     53     "rotateY",
     54     "rotateZ",
     55     "rotate3d",
     56     "scaleZ",
     57     "scale3d",
     58     "perspective",
     59     "matrix3d"
     60};
    3461
    3562WebKitCSSTransformValue::WebKitCSSTransformValue(TransformOperationType op)
     
    4168String WebKitCSSTransformValue::customCssText() const
    4269{
    43     String result;
    44     switch (m_type) {
    45         case TranslateTransformOperation:
    46             result += "translate(";
    47             break;
    48         case TranslateXTransformOperation:
    49             result += "translateX(";
    50             break;
    51         case TranslateYTransformOperation:
    52             result += "translateY(";
    53             break;
    54         case RotateTransformOperation:
    55             result += "rotate(";
    56             break;
    57         case ScaleTransformOperation:
    58             result += "scale(";
    59             break;
    60         case ScaleXTransformOperation:
    61             result += "scaleX(";
    62             break;
    63         case ScaleYTransformOperation:
    64             result += "scaleY(";
    65             break;
    66         case SkewTransformOperation:
    67             result += "skew(";
    68             break;
    69         case SkewXTransformOperation:
    70             result += "skewX(";
    71             break;
    72         case SkewYTransformOperation:
    73             result += "skewY(";
    74             break;
    75         case MatrixTransformOperation:
    76             result += "matrix(";
    77             break;
    78         case TranslateZTransformOperation:
    79             result += "translateZ(";
    80             break;
    81         case Translate3DTransformOperation:
    82             result += "translate3d(";
    83             break;
    84         case RotateXTransformOperation:
    85             result += "rotateX(";
    86             break;
    87         case RotateYTransformOperation:
    88             result += "rotateY(";
    89             break;
    90         case RotateZTransformOperation:
    91             result += "rotateZ(";
    92             break;
    93         case Rotate3DTransformOperation:
    94             result += "rotate3d(";
    95             break;
    96         case ScaleZTransformOperation:
    97             result += "scaleZ(";
    98             break;
    99         case Scale3DTransformOperation:
    100             result += "scale3d(";
    101             break;
    102         case PerspectiveTransformOperation:
    103             result += "perspective(";
    104             break;
    105         case Matrix3DTransformOperation:
    106             result += "matrix3d(";
    107             break;
    108         default:
    109             break;
     70    StringBuilder result;
     71    if (m_type != UnknownTransformOperation) {
     72        ASSERT(m_type < transformNameSize);
     73        result.append(transformName[m_type]);
     74        result.append('(');
     75        result.append(CSSValueList::customCssText());
     76        result.append(')');
    11077    }
    111 
    112     result += CSSValueList::customCssText();
    113 
    114     result += ")";
    115     return result;
     78    return result.toString();
    11679}
    11780
Note: See TracChangeset for help on using the changeset viewer.