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

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 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
« no previous file with comments | « Source/core/style/ComputedStyle.h ('k') | Source/core/style/StyleTransformData.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/style/ComputedStyle.cpp
diff --git a/Source/core/style/ComputedStyle.cpp b/Source/core/style/ComputedStyle.cpp
index 7fe135e88cc6309d1383f31041608db2d2e06f26..594eea063e035cd2c3b09557c5e04716b0271589 100644
--- a/Source/core/style/ComputedStyle.cpp
+++ b/Source/core/style/ComputedStyle.cpp
@@ -42,6 +42,9 @@
#include "platform/fonts/FontSelector.h"
#include "platform/geometry/FloatRoundedRect.h"
#include "platform/graphics/GraphicsContext.h"
+#include "platform/transforms/RotateTransformOperation.h"
+#include "platform/transforms/ScaleTransformOperation.h"
+#include "platform/transforms/TranslateTransformOperation.h"
#include "wtf/MathExtras.h"
#include <algorithm>
@@ -883,15 +886,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 +910,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());
}
« no previous file with comments | « Source/core/style/ComputedStyle.h ('k') | Source/core/style/StyleTransformData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698