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

Unified Diff: Source/core/style/ComputedStyle.cpp

Issue 1220793011: CSS Motion Path: Centre transform-origin on the path (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: current-transformation-matrix Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/style/ComputedStyle.cpp
diff --git a/Source/core/style/ComputedStyle.cpp b/Source/core/style/ComputedStyle.cpp
index 594eea063e035cd2c3b09557c5e04716b0271589..1e5044d4f0644d9d52e305f56305cf5db72ad0b3 100644
--- a/Source/core/style/ComputedStyle.cpp
+++ b/Source/core/style/ComputedStyle.cpp
@@ -927,10 +927,15 @@ void ComputedStyle::applyTransform(TransformationMatrix& result, const FloatRect
float offsetX = transformOriginX().type() == Percent ? boundingBox.x() : 0;
float offsetY = transformOriginY().type() == Percent ? boundingBox.y() : 0;
+ float originX = 0;
+ float originY = 0;
+ float originZ = 0;
+
if (applyTransformOrigin) {
- result.translate3d(floatValueForLength(transformOriginX(), boundingBox.width()) + offsetX,
- floatValueForLength(transformOriginY(), boundingBox.height()) + offsetY,
- transformOriginZ());
+ originX = floatValueForLength(transformOriginX(), boundingBox.width()) + offsetX;
+ originY = floatValueForLength(transformOriginY(), boundingBox.height()) + offsetY;
+ originZ = transformOriginZ();
+ result.translate3d(originX, originY, originZ);
}
if (applyIndependentTransformProperties == IncludeIndependentTransformProperties) {
@@ -945,7 +950,7 @@ void ComputedStyle::applyTransform(TransformationMatrix& result, const FloatRect
}
if (applyMotionPath == ComputedStyle::IncludeMotionPath)
- applyMotionPathTransform(result);
+ applyMotionPathTransform(originX, originY, result);
const Vector<RefPtr<TransformOperation>>& transformOperations = transform().operations();
unsigned size = transformOperations.size();
@@ -953,13 +958,11 @@ void ComputedStyle::applyTransform(TransformationMatrix& result, const FloatRect
transformOperations[i]->apply(result, boundingBox.size());
if (applyTransformOrigin) {
- result.translate3d(-floatValueForLength(transformOriginX(), boundingBox.width()) - offsetX,
- -floatValueForLength(transformOriginY(), boundingBox.height()) - offsetY,
- -transformOriginZ());
+ result.translate3d(-originX, -originY, -originZ);
}
}
-void ComputedStyle::applyMotionPathTransform(TransformationMatrix& transform) const
+void ComputedStyle::applyMotionPathTransform(float originX, float originY, TransformationMatrix& transform) const
{
const StyleMotionData& motionData = rareNonInheritedData->m_transform->m_motion;
ASSERT(motionData.m_path && motionData.m_path->isPathStyleMotionPath());
@@ -982,7 +985,7 @@ void ComputedStyle::applyMotionPathTransform(TransformationMatrix& transform) co
if (motionData.m_rotationType == MotionRotationFixed)
angle = 0;
- transform.translate(point.x(), point.y());
+ transform.translate(point.x() - originX, point.y() - originY);
transform.rotate(angle + motionData.m_rotation);
}
« LayoutTests/css3/motion-path/origin-expected.html ('K') | « Source/core/style/ComputedStyle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698