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

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

Issue 1158603003: CSS Independent Transform Properties (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase master and explicit applyTransform parameters 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 7fe135e88cc6309d1383f31041608db2d2e06f26..6c56be6044895f07188d116aa62ced5af9601414 100644
--- a/Source/core/style/ComputedStyle.cpp
+++ b/Source/core/style/ComputedStyle.cpp
@@ -883,15 +883,17 @@ bool ComputedStyle::hasWillChangeCompositingHint() const
return false;
}
-inline bool requireTransformOrigin(const Vector<RefPtr<TransformOperation>>& transformOperations, ComputedStyle::ApplyTransformOrigin applyOrigin, ComputedStyle::ApplyMotionPath applyMotionPath)
+bool ComputedStyle::requireTransformOrigin(ApplyTransformOrigin applyOrigin, ApplyMotionPath applyMotionPath) const
{
+ const Vector<RefPtr<TransformOperation>>& transformOperations = transform().operations();
+
// transform-origin brackets the transform with translate operations.
// Optimize for the case where the only transform is a translation, since the transform-origin is irrelevant
// in that case.
- if (applyOrigin != ComputedStyle::IncludeTransformOrigin)
+ if (applyOrigin != IncludeTransformOrigin)
return false;
- if (applyMotionPath == ComputedStyle::IncludeMotionPath)
+ if (applyMotionPath == IncludeMotionPath)
return true;
unsigned size = transformOperations.size();
@@ -905,39 +907,50 @@ inline bool requireTransformOrigin(const Vector<RefPtr<TransformOperation>>& tra
return true;
}
- return false;
+ return scale() || rotate();
}
-void ComputedStyle::applyTransform(TransformationMatrix& transform, const LayoutSize& borderBoxSize, ApplyTransformOrigin applyOrigin, ApplyMotionPath applyMotionPath) const
+void ComputedStyle::applyTransform(TransformationMatrix& result, const LayoutSize& borderBoxSize, ApplyTransformOrigin applyOrigin, ApplyMotionPath applyMotionPath, ApplyIndependentTransformProperties applyIndependentTransformProperties) const
{
- applyTransform(transform, FloatRect(FloatPoint(), FloatSize(borderBoxSize)), applyOrigin, applyMotionPath);
+ applyTransform(result, FloatRect(FloatPoint(), FloatSize(borderBoxSize)), applyOrigin, applyMotionPath, applyIndependentTransformProperties);
}
-void ComputedStyle::applyTransform(TransformationMatrix& transform, const FloatRect& boundingBox, ApplyTransformOrigin applyOrigin, ApplyMotionPath applyMotionPath) const
+void ComputedStyle::applyTransform(TransformationMatrix& result, const FloatRect& boundingBox, ApplyTransformOrigin applyOrigin, ApplyMotionPath applyMotionPath, ApplyIndependentTransformProperties applyIndependentTransformProperties) const
{
if (!hasMotionPath())
applyMotionPath = ExcludeMotionPath;
- const Vector<RefPtr<TransformOperation>>& transformOperations = rareNonInheritedData->m_transform->m_operations.operations();
- bool applyTransformOrigin = requireTransformOrigin(transformOperations, applyOrigin, applyMotionPath);
+ bool applyTransformOrigin = requireTransformOrigin(applyOrigin, applyMotionPath);
float offsetX = transformOriginX().type() == Percent ? boundingBox.x() : 0;
float offsetY = transformOriginY().type() == Percent ? boundingBox.y() : 0;
if (applyTransformOrigin) {
- transform.translate3d(floatValueForLength(transformOriginX(), boundingBox.width()) + offsetX,
+ result.translate3d(floatValueForLength(transformOriginX(), boundingBox.width()) + offsetX,
floatValueForLength(transformOriginY(), boundingBox.height()) + offsetY,
transformOriginZ());
}
+ if (applyIndependentTransformProperties == IncludeIndependentTransformProperties) {
+ if (translate())
+ translate()->apply(result, boundingBox.size());
+
+ if (rotate())
+ rotate()->apply(result, boundingBox.size());
+
+ if (scale())
+ scale()->apply(result, boundingBox.size());
+ }
+
if (applyMotionPath == ComputedStyle::IncludeMotionPath)
- applyMotionPathTransform(transform);
+ applyMotionPathTransform(result);
+ const Vector<RefPtr<TransformOperation>>& transformOperations = transform().operations();
unsigned size = transformOperations.size();
for (unsigned i = 0; i < size; ++i)
- transformOperations[i]->apply(transform, boundingBox.size());
+ transformOperations[i]->apply(result, boundingBox.size());
if (applyTransformOrigin) {
- transform.translate3d(-floatValueForLength(transformOriginX(), boundingBox.width()) - offsetX,
+ result.translate3d(-floatValueForLength(transformOriginX(), boundingBox.width()) - offsetX,
-floatValueForLength(transformOriginY(), boundingBox.height()) - offsetY,
-transformOriginZ());
}

Powered by Google App Engine
This is Rietveld 408576698