Commit d0eaf727 authored by krit@webkit.org's avatar krit@webkit.org

Refactor transform code in StyleResolver

https://bugs.webkit.org/show_bug.cgi?id=114874

Reviewed by Andreas Kling.

Move transform code frome StyleResolver into own files.

Refactoring, no changes in functionality.

* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* css/StyleResolver.cpp:
(WebCore::StyleResolver::applyProperty):
(WebCore::StyleResolver::parseCustomFilterTransformParameter):
* css/StyleResolver.h:
* css/TransformFunctions.cpp: Added.
(WebCore):
(WebCore::transformOperationType):
(WebCore::convertToFloatLength):
(WebCore::transformsForValue):
* css/TransformFunctions.h: Added.
(WebCore):
* css/WebKitCSSMatrix.cpp:
(WebCore::WebKitCSSMatrix::setMatrixValue):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@148753 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7c6da803
......@@ -1099,6 +1099,7 @@ set(WebCore_SOURCES
css/SVGCSSComputedStyleDeclaration.cpp
css/SVGCSSParser.cpp
css/SVGCSSStyleSelector.cpp
css/TransformFunctions.cpp
css/ViewportStyleResolver.cpp
css/WebKitCSSFilterRule.cpp
css/WebKitCSSFilterValue.cpp
......
2013-04-19 Dirk Schulze <krit@webkit.org>
Refactor transform code in StyleResolver
https://bugs.webkit.org/show_bug.cgi?id=114874
Reviewed by Andreas Kling.
Move transform code frome StyleResolver into own files.
Refactoring, no changes in functionality.
* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* css/StyleResolver.cpp:
(WebCore::StyleResolver::applyProperty):
(WebCore::StyleResolver::parseCustomFilterTransformParameter):
* css/StyleResolver.h:
* css/TransformFunctions.cpp: Added.
(WebCore):
(WebCore::transformOperationType):
(WebCore::convertToFloatLength):
(WebCore::transformsForValue):
* css/TransformFunctions.h: Added.
(WebCore):
* css/WebKitCSSMatrix.cpp:
(WebCore::WebKitCSSMatrix::setMatrixValue):
2013-04-19 Erik Arvidsson <arv@chromium.org>
Rename TextTrackList owner to element for consistency
......@@ -2753,6 +2753,8 @@ webcore_sources += \
Source/WebCore/css/StyleSheetContents.h \
Source/WebCore/css/StyleSheetList.cpp \
Source/WebCore/css/StyleSheetList.h \
Source/WebCore/css/TransformFunctions.cpp \
Source/WebCore/css/TransformFunctions.h \
Source/WebCore/css/ViewportStyleResolver.cpp \
Source/WebCore/css/ViewportStyleResolver.h \
Source/WebCore/css/WebKitCSSArrayFunctionValue.cpp \
......
......@@ -343,6 +343,7 @@ SOURCES += \
css/StyleSheet.cpp \
css/StyleSheetContents.cpp \
css/StyleSheetList.cpp \
css/TransformFunctions.cpp \
css/ViewportStyleResolver.cpp \
css/WebKitCSSArrayFunctionValue.cpp \
css/WebKitCSSFilterRule.cpp \
......@@ -1583,6 +1584,7 @@ HEADERS += \
css/StyleSheet.h \
css/StyleSheetContents.h \
css/StyleSheetList.h \
css/TransformFunctions.h \
css/ViewportStyleResolver.h \
css/WebKitCSSArrayFunctionValue.h \
css/WebKitCSSFilterRule.h \
......
......@@ -38942,6 +38942,14 @@
RelativePath="..\css\SVGCSSStyleSelector.cpp"
>
</File>
<File
RelativePath="..\css\TransformFunctions.cpp"
>
</File>
<File
RelativePath="..\css\TransformFunctions.h"
>
</File>
<File
RelativePath="..\css\ViewportStyleResolver.cpp"
>
......@@ -5388,6 +5388,7 @@
<ClCompile Include="..\css\SVGCSSComputedStyleDeclaration.cpp" />
<ClCompile Include="..\css\SVGCSSParser.cpp" />
<ClCompile Include="..\css\SVGCSSStyleSelector.cpp" />
<ClCompile Include="..\css\TransformFunctions.cpp" />
<ClCompile Include="..\css\ViewportStyleResolver.cpp" />
<ClCompile Include="..\css\WebKitCSSArrayFunctionValue.cpp" />
<ClCompile Include="..\css\WebKitCSSFilterValue.cpp" />
......@@ -12168,6 +12169,7 @@
<ClInclude Include="..\css\StyleSheet.h" />
<ClInclude Include="..\css\StyleSheetContents.h" />
<ClInclude Include="..\css\StyleSheetList.h" />
<ClInclude Include="..\css\TransformFunctions.h" />
<ClInclude Include="..\css\ViewportStyleResolver.h" />
<ClInclude Include="..\css\WebKitCSSArrayFunctionValue.h" />
<ClInclude Include="..\css\WebKitCSSFilterValue.h" />
......@@ -3783,6 +3783,9 @@
<ClCompile Include="..\css\SVGCSSStyleSelector.cpp">
<Filter>css</Filter>
</ClCompile>
<ClCompile Include="..\css\TransformFunctions.cpp">
<Filter>css</Filter>
</ClCompile>
<ClCompile Include="..\css\ViewportStyleResolver.cpp">
<Filter>css</Filter>
</ClCompile>
......@@ -10560,6 +10563,9 @@
<ClInclude Include="..\css\StyleSheetList.h">
<Filter>css</Filter>
</ClInclude>
<ClInclude Include="..\css\TransformFunctions.h">
<Filter>css</Filter>
</ClInclude>
<ClInclude Include="..\css\ViewportStyleResolver.h">
<Filter>css</Filter>
</ClInclude>
......
......@@ -5729,6 +5729,8 @@
FABE72FE1059C21100D999DD /* MathMLNames.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FABE72FC1059C21100D999DD /* MathMLNames.cpp */; };
FB2C15C3165D649D0039C9F8 /* CachedSVGDocumentReference.h in Headers */ = {isa = PBXBuildFile; fileRef = FB2C15C2165D64900039C9F8 /* CachedSVGDocumentReference.h */; settings = {ATTRIBUTES = (Private, ); }; };
FB3056C2169E5DAC0096A232 /* CSSGroupingRule.h in Headers */ = {isa = PBXBuildFile; fileRef = FB3056C1169E5DAC0096A232 /* CSSGroupingRule.h */; };
FB484F4C171F821E00040755 /* TransformFunctions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FB484F4A171F821E00040755 /* TransformFunctions.cpp */; };
FB484F4D171F821E00040755 /* TransformFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = FB484F4B171F821E00040755 /* TransformFunctions.h */; };
FB49C39D16784947007FFB5D /* CSSHostRule.h in Headers */ = {isa = PBXBuildFile; fileRef = FB49C39C16784947007FFB5D /* CSSHostRule.h */; };
FB78AD2E151BF5E600FE54D3 /* CSSParserMode.h in Headers */ = {isa = PBXBuildFile; fileRef = FB78AD2C151BF5D200FE54D3 /* CSSParserMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
FB91392416AE4C17001FE682 /* DOMPath.h in Headers */ = {isa = PBXBuildFile; fileRef = FB91392016AE4B0B001FE682 /* DOMPath.h */; };
......@@ -12570,6 +12572,8 @@
FABE72FC1059C21100D999DD /* MathMLNames.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLNames.cpp; sourceTree = "<group>"; };
FB2C15C2165D64900039C9F8 /* CachedSVGDocumentReference.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedSVGDocumentReference.h; sourceTree = "<group>"; };
FB3056C1169E5DAC0096A232 /* CSSGroupingRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSGroupingRule.h; sourceTree = "<group>"; };
FB484F4A171F821E00040755 /* TransformFunctions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TransformFunctions.cpp; sourceTree = "<group>"; };
FB484F4B171F821E00040755 /* TransformFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TransformFunctions.h; sourceTree = "<group>"; };
FB49C39C16784947007FFB5D /* CSSHostRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSHostRule.h; sourceTree = "<group>"; };
FB49C39E16784954007FFB5D /* CSSHostRule.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CSSHostRule.idl; sourceTree = "<group>"; };
FB78AD2C151BF5D200FE54D3 /* CSSParserMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSParserMode.h; sourceTree = "<group>"; };
......@@ -19865,6 +19869,8 @@
B2227B020D00BFF10071B782 /* SVGCSSPropertyNames.in */,
B2227B030D00BFF10071B782 /* SVGCSSStyleSelector.cpp */,
B2227B040D00BFF10071B782 /* SVGCSSValueKeywords.in */,
FB484F4A171F821E00040755 /* TransformFunctions.cpp */,
FB484F4B171F821E00040755 /* TransformFunctions.h */,
BC5EC1760A507E3E006007F5 /* view-source.css */,
3FFFF9AB159D9B060020BBD5 /* ViewportStyleResolver.cpp */,
3FFFF9AC159D9B060020BBD5 /* ViewportStyleResolver.h */,
......@@ -24042,6 +24048,7 @@
E152551516FD2350003D7ADB /* WebCoreResourceHandleAsOperationQueueDelegate.h in Headers */,
E1B533491717DEE300F205F9 /* CachedRawResourceClient.h in Headers */,
BE88E0C21715CE2600658D98 /* TrackListBase.h in Headers */,
FB484F4D171F821E00040755 /* TransformFunctions.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -26992,6 +26999,7 @@
E152551616FD2350003D7ADB /* WebCoreResourceHandleAsOperationQueueDelegate.mm in Sources */,
E1B533471717D0A100F205F9 /* CachedSVGDocumentReference.cpp in Sources */,
BE88E0C11715CE2600658D98 /* TrackListBase.cpp in Sources */,
FB484F4C171F821E00040755 /* TransformFunctions.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -81,8 +81,6 @@
#include "LinkHash.h"
#include "LocaleToScriptMapping.h"
#include "MathMLNames.h"
#include "Matrix3DTransformOperation.h"
#include "MatrixTransformOperation.h"
#include "MediaList.h"
#include "MediaQueryEvaluator.h"
#include "NodeRenderStyle.h"
......@@ -90,7 +88,6 @@
#include "Page.h"
#include "PageRuleCollector.h"
#include "Pair.h"
#include "PerspectiveTransformOperation.h"
#include "QuotesData.h"
#include "Rect.h"
#include "RenderRegion.h"
......@@ -99,18 +96,15 @@
#include "RenderStyleConstants.h"
#include "RenderTheme.h"
#include "RenderView.h"
#include "RotateTransformOperation.h"
#include "RuleSet.h"
#include "SVGDocumentExtensions.h"
#include "SVGFontFaceElement.h"
#include "ScaleTransformOperation.h"
#include "SecurityOrigin.h"
#include "SelectorCheckerFastPath.h"
#include "Settings.h"
#include "ShadowData.h"
#include "ShadowRoot.h"
#include "ShadowValue.h"
#include "SkewTransformOperation.h"
#include "StyleCachedImage.h"
#include "StyleGeneratedImage.h"
#include "StylePendingImage.h"
......@@ -121,8 +115,8 @@
#include "StyleSheetContents.h"
#include "StyleSheetList.h"
#include "Text.h"
#include "TransformationMatrix.h"
#include "TranslateTransformOperation.h"
#include "TransformFunctions.h"
#include "TransformOperations.h"
#include "UserAgentStyleSheets.h"
#include "ViewportStyleResolver.h"
#include "VisitedLinkState.h"
......@@ -2652,7 +2646,7 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value)
case CSSPropertyWebkitTransform: {
HANDLE_INHERIT_AND_INITIAL(transform, Transform);
TransformOperations operations;
createTransformOperations(value, state.style(), state.rootElementStyle(), operations);
transformsForValue(state.style(), state.rootElementStyle(), value, operations);
state.style()->setTransform(operations);
return;
}
......@@ -3541,280 +3535,6 @@ bool StyleResolver::affectedByViewportChange() const
return false;
}
static TransformOperation::OperationType getTransformOperationType(WebKitCSSTransformValue::TransformOperationType type)
{
switch (type) {
case WebKitCSSTransformValue::ScaleTransformOperation: return TransformOperation::SCALE;
case WebKitCSSTransformValue::ScaleXTransformOperation: return TransformOperation::SCALE_X;
case WebKitCSSTransformValue::ScaleYTransformOperation: return TransformOperation::SCALE_Y;
case WebKitCSSTransformValue::ScaleZTransformOperation: return TransformOperation::SCALE_Z;
case WebKitCSSTransformValue::Scale3DTransformOperation: return TransformOperation::SCALE_3D;
case WebKitCSSTransformValue::TranslateTransformOperation: return TransformOperation::TRANSLATE;
case WebKitCSSTransformValue::TranslateXTransformOperation: return TransformOperation::TRANSLATE_X;
case WebKitCSSTransformValue::TranslateYTransformOperation: return TransformOperation::TRANSLATE_Y;
case WebKitCSSTransformValue::TranslateZTransformOperation: return TransformOperation::TRANSLATE_Z;
case WebKitCSSTransformValue::Translate3DTransformOperation: return TransformOperation::TRANSLATE_3D;
case WebKitCSSTransformValue::RotateTransformOperation: return TransformOperation::ROTATE;
case WebKitCSSTransformValue::RotateXTransformOperation: return TransformOperation::ROTATE_X;
case WebKitCSSTransformValue::RotateYTransformOperation: return TransformOperation::ROTATE_Y;
case WebKitCSSTransformValue::RotateZTransformOperation: return TransformOperation::ROTATE_Z;
case WebKitCSSTransformValue::Rotate3DTransformOperation: return TransformOperation::ROTATE_3D;
case WebKitCSSTransformValue::SkewTransformOperation: return TransformOperation::SKEW;
case WebKitCSSTransformValue::SkewXTransformOperation: return TransformOperation::SKEW_X;
case WebKitCSSTransformValue::SkewYTransformOperation: return TransformOperation::SKEW_Y;
case WebKitCSSTransformValue::MatrixTransformOperation: return TransformOperation::MATRIX;
case WebKitCSSTransformValue::Matrix3DTransformOperation: return TransformOperation::MATRIX_3D;
case WebKitCSSTransformValue::PerspectiveTransformOperation: return TransformOperation::PERSPECTIVE;
case WebKitCSSTransformValue::UnknownTransformOperation: return TransformOperation::NONE;
}
return TransformOperation::NONE;
}
bool StyleResolver::createTransformOperations(CSSValue* inValue, RenderStyle* style, RenderStyle* rootStyle, TransformOperations& outOperations)
{
if (!inValue || !inValue->isValueList()) {
outOperations.clear();
return false;
}
float zoomFactor = style ? style->effectiveZoom() : 1;
TransformOperations operations;
for (CSSValueListIterator i = inValue; i.hasMore(); i.advance()) {
CSSValue* currValue = i.value();
if (!currValue->isWebKitCSSTransformValue())
continue;
WebKitCSSTransformValue* transformValue = static_cast<WebKitCSSTransformValue*>(i.value());
if (!transformValue->length())
continue;
bool haveNonPrimitiveValue = false;
for (unsigned j = 0; j < transformValue->length(); ++j) {
if (!transformValue->itemWithoutBoundsCheck(j)->isPrimitiveValue()) {
haveNonPrimitiveValue = true;
break;
}
}
if (haveNonPrimitiveValue)
continue;
CSSPrimitiveValue* firstValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(0));
switch (transformValue->operationType()) {
case WebKitCSSTransformValue::ScaleTransformOperation:
case WebKitCSSTransformValue::ScaleXTransformOperation:
case WebKitCSSTransformValue::ScaleYTransformOperation: {
double sx = 1.0;
double sy = 1.0;
if (transformValue->operationType() == WebKitCSSTransformValue::ScaleYTransformOperation)
sy = firstValue->getDoubleValue();
else {
sx = firstValue->getDoubleValue();
if (transformValue->operationType() != WebKitCSSTransformValue::ScaleXTransformOperation) {
if (transformValue->length() > 1) {
CSSPrimitiveValue* secondValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(1));
sy = secondValue->getDoubleValue();
} else
sy = sx;
}
}
operations.operations().append(ScaleTransformOperation::create(sx, sy, 1.0, getTransformOperationType(transformValue->operationType())));
break;
}
case WebKitCSSTransformValue::ScaleZTransformOperation:
case WebKitCSSTransformValue::Scale3DTransformOperation: {
double sx = 1.0;
double sy = 1.0;
double sz = 1.0;
if (transformValue->operationType() == WebKitCSSTransformValue::ScaleZTransformOperation)
sz = firstValue->getDoubleValue();
else if (transformValue->operationType() == WebKitCSSTransformValue::ScaleYTransformOperation)
sy = firstValue->getDoubleValue();
else {
sx = firstValue->getDoubleValue();
if (transformValue->operationType() != WebKitCSSTransformValue::ScaleXTransformOperation) {
if (transformValue->length() > 2) {
CSSPrimitiveValue* thirdValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(2));
sz = thirdValue->getDoubleValue();
}
if (transformValue->length() > 1) {
CSSPrimitiveValue* secondValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(1));
sy = secondValue->getDoubleValue();
} else
sy = sx;
}
}
operations.operations().append(ScaleTransformOperation::create(sx, sy, sz, getTransformOperationType(transformValue->operationType())));
break;
}
case WebKitCSSTransformValue::TranslateTransformOperation:
case WebKitCSSTransformValue::TranslateXTransformOperation:
case WebKitCSSTransformValue::TranslateYTransformOperation: {
Length tx = Length(0, Fixed);
Length ty = Length(0, Fixed);
if (transformValue->operationType() == WebKitCSSTransformValue::TranslateYTransformOperation)
ty = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
else {
tx = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
if (transformValue->operationType() != WebKitCSSTransformValue::TranslateXTransformOperation) {
if (transformValue->length() > 1) {
CSSPrimitiveValue* secondValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(1));
ty = convertToFloatLength(secondValue, style, rootStyle, zoomFactor);
}
}
}
if (tx.isUndefined() || ty.isUndefined())
return false;
operations.operations().append(TranslateTransformOperation::create(tx, ty, Length(0, Fixed), getTransformOperationType(transformValue->operationType())));
break;
}
case WebKitCSSTransformValue::TranslateZTransformOperation:
case WebKitCSSTransformValue::Translate3DTransformOperation: {
Length tx = Length(0, Fixed);
Length ty = Length(0, Fixed);
Length tz = Length(0, Fixed);
if (transformValue->operationType() == WebKitCSSTransformValue::TranslateZTransformOperation)
tz = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
else if (transformValue->operationType() == WebKitCSSTransformValue::TranslateYTransformOperation)
ty = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
else {
tx = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
if (transformValue->operationType() != WebKitCSSTransformValue::TranslateXTransformOperation) {
if (transformValue->length() > 2) {
CSSPrimitiveValue* thirdValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(2));
tz = convertToFloatLength(thirdValue, style, rootStyle, zoomFactor);
}
if (transformValue->length() > 1) {
CSSPrimitiveValue* secondValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(1));
ty = convertToFloatLength(secondValue, style, rootStyle, zoomFactor);
}
}
}
if (tx.isUndefined() || ty.isUndefined() || tz.isUndefined())
return false;
operations.operations().append(TranslateTransformOperation::create(tx, ty, tz, getTransformOperationType(transformValue->operationType())));
break;
}
case WebKitCSSTransformValue::RotateTransformOperation: {
double angle = firstValue->computeDegrees();
operations.operations().append(RotateTransformOperation::create(0, 0, 1, angle, getTransformOperationType(transformValue->operationType())));
break;
}
case WebKitCSSTransformValue::RotateXTransformOperation:
case WebKitCSSTransformValue::RotateYTransformOperation:
case WebKitCSSTransformValue::RotateZTransformOperation: {
double x = 0;
double y = 0;
double z = 0;
double angle = firstValue->computeDegrees();
if (transformValue->operationType() == WebKitCSSTransformValue::RotateXTransformOperation)
x = 1;
else if (transformValue->operationType() == WebKitCSSTransformValue::RotateYTransformOperation)
y = 1;
else
z = 1;
operations.operations().append(RotateTransformOperation::create(x, y, z, angle, getTransformOperationType(transformValue->operationType())));
break;
}
case WebKitCSSTransformValue::Rotate3DTransformOperation: {
if (transformValue->length() < 4)
break;
CSSPrimitiveValue* secondValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(1));
CSSPrimitiveValue* thirdValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(2));
CSSPrimitiveValue* fourthValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(3));
double x = firstValue->getDoubleValue();
double y = secondValue->getDoubleValue();
double z = thirdValue->getDoubleValue();
double angle = fourthValue->computeDegrees();
operations.operations().append(RotateTransformOperation::create(x, y, z, angle, getTransformOperationType(transformValue->operationType())));
break;
}
case WebKitCSSTransformValue::SkewTransformOperation:
case WebKitCSSTransformValue::SkewXTransformOperation:
case WebKitCSSTransformValue::SkewYTransformOperation: {
double angleX = 0;
double angleY = 0;
double angle = firstValue->computeDegrees();
if (transformValue->operationType() == WebKitCSSTransformValue::SkewYTransformOperation)
angleY = angle;
else {
angleX = angle;
if (transformValue->operationType() == WebKitCSSTransformValue::SkewTransformOperation) {
if (transformValue->length() > 1) {
CSSPrimitiveValue* secondValue = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(1));
angleY = secondValue->computeDegrees();
}
}
}
operations.operations().append(SkewTransformOperation::create(angleX, angleY, getTransformOperationType(transformValue->operationType())));
break;
}
case WebKitCSSTransformValue::MatrixTransformOperation: {
if (transformValue->length() < 6)
break;
double a = firstValue->getDoubleValue();
double b = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(1))->getDoubleValue();
double c = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(2))->getDoubleValue();
double d = static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(3))->getDoubleValue();
double e = zoomFactor * static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(4))->getDoubleValue();
double f = zoomFactor * static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(5))->getDoubleValue();
operations.operations().append(MatrixTransformOperation::create(a, b, c, d, e, f));
break;
}
case WebKitCSSTransformValue::Matrix3DTransformOperation: {
if (transformValue->length() < 16)
break;
TransformationMatrix matrix(static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(0))->getDoubleValue(),
static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(1))->getDoubleValue(),
static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(2))->getDoubleValue(),
static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(3))->getDoubleValue(),
static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(4))->getDoubleValue(),
static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(5))->getDoubleValue(),
static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(6))->getDoubleValue(),
static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(7))->getDoubleValue(),
static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(8))->getDoubleValue(),
static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(9))->getDoubleValue(),
static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(10))->getDoubleValue(),
static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(11))->getDoubleValue(),
zoomFactor * static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(12))->getDoubleValue(),
zoomFactor * static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(13))->getDoubleValue(),
static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(14))->getDoubleValue(),
static_cast<CSSPrimitiveValue*>(transformValue->itemWithoutBoundsCheck(15))->getDoubleValue());
operations.operations().append(Matrix3DTransformOperation::create(matrix));
break;
}
case WebKitCSSTransformValue::PerspectiveTransformOperation: {
Length p = Length(0, Fixed);
if (firstValue->isLength())
p = convertToFloatLength(firstValue, style, rootStyle, zoomFactor);
else {
// This is a quirk that should go away when 3d transforms are finalized.
double val = firstValue->getDoubleValue();
p = val >= 0 ? Length(clampToPositiveInteger(val), Fixed) : Length(Undefined);
}
if (p.isUndefined())
return false;
operations.operations().append(PerspectiveTransformOperation::create(p));
break;
}
case WebKitCSSTransformValue::UnknownTransformOperation:
ASSERT_NOT_REACHED();
break;
}
}
outOperations = operations;
return true;
}
#if ENABLE(CSS_FILTERS)
static FilterOperation::OperationType filterOperationForType(WebKitCSSFilterValue::FilterOperationType type)
{
......@@ -3992,7 +3712,7 @@ PassRefPtr<CustomFilterParameter> StyleResolver::parseCustomFilterTransformParam
{
RefPtr<CustomFilterTransformParameter> transformParameter = CustomFilterTransformParameter::create(name);
TransformOperations operations;
createTransformOperations(values, m_state.style(), m_state.rootElementStyle(), operations);
transformsForValue(m_state.style(), m_state.rootElementStyle(), values, operations);
transformParameter->setOperations(operations);
return transformParameter.release();
}
......
......@@ -304,8 +304,6 @@ public:
bool usesSiblingRules() const { return !m_ruleSets.features().siblingRules.isEmpty(); }
bool usesFirstLineRules() const { return m_ruleSets.features().usesFirstLineRules; }
bool usesBeforeAfterRules() const { return m_ruleSets.features().usesBeforeAfterRules; }
static bool createTransformOperations(CSSValue* inValue, RenderStyle* inStyle, RenderStyle* rootStyle, TransformOperations& outOperations);
void invalidateMatchedPropertiesCache();
......
/*
* Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
* Copyright (C) 2012 Google Inc. All rights reserved.
* Copyright (C) 2012, 2013 Adobe Systems Incorporated. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "config.h"
#include "TransformFunctions.h"
#include "CSSPrimitiveValueMappings.h"
#include "CSSValueList.h"
#include "CSSValuePool.h"
#include "Matrix3DTransformOperation.h"
#include "MatrixTransformOperation.h"
#include "PerspectiveTransformOperation.h"
#include "RenderStyle.h"
#include "RotateTransformOperation.h"
#include "ScaleTransformOperation.h"
#include "SkewTransformOperation.h"
#include "TranslateTransformOperation.h"
#include "WebKitCSSTransformValue.h"
namespace WebCore {
static TransformOperation::OperationType transformOperationType(WebKitCSSTransformValue::TransformOperationType type)
{
switch (type) {
case WebKitCSSTransformValue::ScaleTransformOperation: return TransformOperation::SCALE;
case WebKitCSSTransformValue::ScaleXTransformOperation: return TransformOperation::SCALE_X;
case WebKitCSSTransformValue::ScaleYTransformOperation: return TransformOperation::SCALE_Y;
case WebKitCSSTransformValue::ScaleZTransformOperation: return TransformOperation::SCALE_Z;
case WebKitCSSTransformValue::Scale3DTransformOperation: return TransformOperation::SCALE_3D;
case WebKitCSSTransformValue::TranslateTransformOperation: return TransformOperation::TRANSLATE;
case WebKitCSSTransformValue::TranslateXTransformOperation: return TransformOperation::TRANSLATE_X;
case WebKitCSSTransformValue::TranslateYTransformOperation: return TransformOperation::TRANSLATE_Y;
case WebKitCSSTransformValue::TranslateZTransformOperation: return TransformOperation::TRANSLATE_Z;
case WebKitCSSTransformValue::Translate3DTransformOperation: return TransformOperation::TRANSLATE_3D;
case WebKitCSSTransformValue::RotateTransformOperation: return TransformOperation::ROTATE;
case WebKitCSSTransformValue::RotateXTransformOperation: return TransformOperation::ROTATE_X;
case WebKitCSSTransformValue::RotateYTransformOperation: return TransformOperation::ROTATE_Y;
case WebKitCSSTransformValue::RotateZTransformOperation: return TransformOperation::ROTATE_Z;
case WebKitCSSTransformValue::Rotate3DTransformOperation: return TransformOperation::ROTATE_3D;
case WebKitCSSTransformValue::SkewTransformOperation: return TransformOperation::SKEW;
case WebKitCSSTransformValue::SkewXTransformOperation: return TransformOperation::SKEW_X;
case WebKitCSSTransformValue::SkewYTransformOperation: return TransformOperation::SKEW_Y;
case WebKitCSSTransformValue::MatrixTransformOperation: return TransformOperation::MATRIX;
case WebKitCSSTransformValue::Matrix3DTransformOperation: return TransformOperation::MATRIX_3D;
case WebKitCSSTransformValue::PerspectiveTransformOperation: return TransformOperation::PERSPECTIVE;
case WebKitCSSTransformValue::UnknownTransformOperation: return TransformOperation::NONE;
}
return TransformOperation::NONE;
}
static Length convertToFloatLength(const CSSPrimitiveValue* primitiveValue, const RenderStyle* style, const RenderStyle* rootStyle, double multiplier)
{
return primitiveValue ? primitiveValue->convertToLength<FixedFloatConversion | PercentConversion | CalculatedConversion | FractionConversion | ViewportPercentageConversion>(style, rootStyle, multiplier) : Length(Undefined);
}
bool transformsForValue(const RenderStyle* style, const RenderStyle* rootStyle, CSSValue* value, TransformOperations& outOperations)
{
if (!value || !value->isValueList()) {
outOperations.clear();
return false;
}
float zoomFactor = style ? style->effectiveZoom() : 1;
TransformOperations operations;
for (CSSValueListIterator i = value; i.hasMore(); i.advance()) {
CSSValue* currValue = i.value();