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

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

Issue 2247773004: [WIP] CSS Motion Path: offset-anchor and offset-position Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: offsetAnchor Created 4 years, 4 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: third_party/WebKit/Source/core/style/ComputedStyle.cpp
diff --git a/third_party/WebKit/Source/core/style/ComputedStyle.cpp b/third_party/WebKit/Source/core/style/ComputedStyle.cpp
index 8188e6012b3af91a0b81babb7c48af57ac993297..ac48e69a0ea36a37c2516af243da8b00b5d3bb62 100644
--- a/third_party/WebKit/Source/core/style/ComputedStyle.cpp
+++ b/third_party/WebKit/Source/core/style/ComputedStyle.cpp
@@ -988,6 +988,7 @@ static bool hasPropertyThatCreatesStackingContext(const Vector<CSSPropertyID>& p
case CSSPropertyPosition:
case CSSPropertyMixBlendMode:
case CSSPropertyIsolation:
+ case CSSPropertyOffsetPath:
return true;
default:
break;
@@ -1097,7 +1098,7 @@ void ComputedStyle::applyTransform(TransformationMatrix& result, const LayoutSiz
void ComputedStyle::applyTransform(TransformationMatrix& result, const FloatRect& boundingBox, ApplyTransformOrigin applyOrigin, ApplyMotionPath applyMotionPath, ApplyIndependentTransformProperties applyIndependentTransformProperties) const
{
- if (!hasMotionPath())
+ if (!hasOffsetPath())
applyMotionPath = ExcludeMotionPath;
bool applyTransformOrigin = requireTransformOrigin(applyOrigin, applyMotionPath);
@@ -1127,7 +1128,7 @@ void ComputedStyle::applyTransform(TransformationMatrix& result, const FloatRect
}
if (applyMotionPath == ComputedStyle::IncludeMotionPath)
- applyMotionPathTransform(originX, originY, result);
+ applyMotionPathTransform(originX, originY, boundingBox, result);
const Vector<RefPtr<TransformOperation>>& transformOperations = transform().operations();
unsigned size = transformOperations.size();
@@ -1139,13 +1140,13 @@ void ComputedStyle::applyTransform(TransformationMatrix& result, const FloatRect
}
}
-void ComputedStyle::applyMotionPathTransform(float originX, float originY, TransformationMatrix& transform) const
+void ComputedStyle::applyMotionPathTransform(float originX, float originY, const FloatRect& boundingBox, TransformationMatrix& transform) const
{
const StyleMotionData& motionData = m_rareNonInheritedData->m_transform->m_motion;
ASSERT(motionData.m_path);
const StylePath& motionPath = *motionData.m_path;
float pathLength = motionPath.length();
- float distance = floatValueForLength(motionData.m_offset, pathLength);
+ float distance = floatValueForLength(motionData.m_distance, pathLength);
float computedDistance;
if (motionPath.isClosed() && pathLength > 0) {
computedDistance = fmod(distance, pathLength);
@@ -1159,10 +1160,27 @@ void ComputedStyle::applyMotionPathTransform(float originX, float originY, Trans
float angle;
motionPath.path().pointAndNormalAtLength(computedDistance, point, angle);
- if (motionData.m_rotation.type == MotionRotationFixed)
+ if (motionData.m_rotation.type == OffsetRotationFixed)
angle = 0;
- transform.translate(point.x() - originX, point.y() - originY);
+ float translateX = point.x();
+ float translateY = point.y();
+ const LengthPoint& position = offsetPosition();
+ if (position.x() == Auto) {
+ translateX -= originX;
+ translateY -= originY;
+ } else {
+ translateX += floatValueForLength(position.x(), boundingBox.width()) - floatValueForLength(left(), boundingBox.width());
+ translateY += floatValueForLength(position.y(), boundingBox.height()) - floatValueForLength(top(), boundingBox.height());
+ }
+
+ const LengthPoint& anchor = offsetAnchor();
+ // TODO(ericwilligers): Consider interaction between position, anchor, rotation
+ if (anchor.x() != Auto) {
+ translateX += floatValueForLength(left(), boundingBox.width()) - boundingBox.x() - floatValueForLength(anchor.x(), boundingBox.width());
+ translateY += floatValueForLength(top(), boundingBox.height()) - boundingBox.y() - floatValueForLength(anchor.y(), boundingBox.height());
+ }
+ transform.translate(translateX, translateY);
transform.rotate(angle + motionData.m_rotation.angle);
}
@@ -1843,7 +1861,7 @@ void ComputedStyle::setMarginEnd(const Length& margin)
}
}
-void ComputedStyle::setMotionPath(PassRefPtr<StylePath> path)
+void ComputedStyle::setOffsetPath(PassRefPtr<StylePath> path)
{
m_rareNonInheritedData.access()->m_transform.access()->m_motion.m_path = path;
}
« no previous file with comments | « third_party/WebKit/Source/core/style/ComputedStyle.h ('k') | third_party/WebKit/Source/core/style/ComputedStyleConstants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698