WebKitCSSTransformValue.cpp [plain text]
#include "config.h"
#include "WebKitCSSTransformValue.h"
#include "CSSValueList.h"
#include <wtf/PassRefPtr.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
const char* const transformNamePrefixes[] = {
0,
"translate(",
"translateX(",
"translateY(",
"rotate(",
"scale(",
"scaleX(",
"scaleY(",
"skew(",
"skewX(",
"skewY(",
"matrix(",
"translateZ(",
"translate3d(",
"rotateX(",
"rotateY(",
"rotateZ(",
"rotate3d(",
"scaleZ(",
"scale3d(",
"perspective(",
"matrix3d("
};
static inline String transformValueToCssString(WebKitCSSTransformValue::TransformOperationType operation, const String& value)
{
if (operation != WebKitCSSTransformValue::UnknownTransformOperation) {
ASSERT_WITH_SECURITY_IMPLICATION(static_cast<size_t>(operation) < WTF_ARRAY_LENGTH(transformNamePrefixes));
return makeString(transformNamePrefixes[operation], value, ')');
}
return String();
}
WebKitCSSTransformValue::WebKitCSSTransformValue(TransformOperationType op)
: CSSValueList(WebKitCSSTransformClass, CommaSeparator)
, m_type(op)
{
}
String WebKitCSSTransformValue::customCSSText() const
{
return transformValueToCssString(m_type, CSSValueList::customCSSText());
}
WebKitCSSTransformValue::WebKitCSSTransformValue(const WebKitCSSTransformValue& cloneFrom)
: CSSValueList(cloneFrom)
, m_type(cloneFrom.m_type)
{
}
PassRefPtr<WebKitCSSTransformValue> WebKitCSSTransformValue::cloneForCSSOM() const
{
return adoptRef(new WebKitCSSTransformValue(*this));
}
}