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

Unified Diff: Source/core/rendering/style/BasicShapes.cpp

Issue 124303002: Layout support for new ellipse shape syntax (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase against ToT Created 6 years, 11 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/rendering/style/BasicShapes.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/style/BasicShapes.cpp
diff --git a/Source/core/rendering/style/BasicShapes.cpp b/Source/core/rendering/style/BasicShapes.cpp
index eb5b94745d049df94283a4dec11da62980fa490b..18293efd9397594ab1fb82c2f47f2cbe49f6cb17 100644
--- a/Source/core/rendering/style/BasicShapes.cpp
+++ b/Source/core/rendering/style/BasicShapes.cpp
@@ -58,7 +58,16 @@ bool BasicShape::canBlend(const BasicShape* other) const
return false;
}
- return true;
+ // Ellipses with keywords for radii or center coordinates cannot be animated.
+ if (type() != BasicShape::BasicShapeEllipseType)
+ return true;
+
+ const BasicShapeEllipse* thisEllipse = static_cast<const BasicShapeEllipse*>(this);
+ const BasicShapeEllipse* otherEllipse = static_cast<const BasicShapeEllipse*>(other);
+ return (thisEllipse->radiusX().canBlend(otherEllipse->radiusX())
+ && thisEllipse->radiusY().canBlend(otherEllipse->radiusY())
+ && thisEllipse->centerX().canBlend(otherEllipse->centerX())
+ && thisEllipse->centerY().canBlend(otherEllipse->centerY()));
}
void BasicShapeRectangle::path(Path& path, const FloatRect& boundingBox)
@@ -227,25 +236,27 @@ bool BasicShapeEllipse::operator==(const BasicShape& o) const
return m_centerX == other.m_centerX && m_centerY == other.m_centerY && m_radiusX == other.m_radiusX && m_radiusY == other.m_radiusY;
}
+float BasicShapeEllipse::floatValueForRadiusInBox(const BasicShapeRadius& radius, float center, float boxWidthOrHeight) const
+{
+ if (radius.type() == BasicShapeRadius::Value)
+ return floatValueForLength(radius.value(), boxWidthOrHeight);
+
+ if (radius.type() == BasicShapeRadius::ClosestSide)
+ return std::min(center, boxWidthOrHeight - center);
+
+ ASSERT(radius.type() == BasicShapeRadius::FarthestSide);
+ return std::max(center, boxWidthOrHeight - center);
+}
+
void BasicShapeEllipse::path(Path& path, const FloatRect& boundingBox)
{
ASSERT(path.isEmpty());
- // FIXME Complete implementation of path. Bug 124619.
- // Compute closest-side and farthest-side from boundingBox.
- // Compute top, left, bottom, right from boundingBox.
- if (m_radiusX.type() != BasicShapeRadius::Value || m_radiusY.type() != BasicShapeRadius::Value)
- return;
- if (m_centerX.keyword() != BasicShapeCenterCoordinate::None || m_centerY.keyword() != BasicShapeCenterCoordinate::None)
- return;
-
- float diagonal = hypotf(boundingBox.width(), boundingBox.height()) / sqrtf(2);
- float centerX = floatValueForLength(m_centerX.length(), boundingBox.width());
- float centerY = floatValueForLength(m_centerY.length(), boundingBox.height());
- float radiusX = floatValueForLength(m_radiusX.value(), diagonal);
- float radiusY = floatValueForLength(m_radiusY.value(), diagonal);
+ FloatPoint center = floatPointForCenterCoordinate(m_centerX, m_centerY, boundingBox.size());
+ float radiusX = floatValueForRadiusInBox(m_radiusX, center.x(), boundingBox.width());
+ float radiusY = floatValueForRadiusInBox(m_radiusY, center.y(), boundingBox.height());
path.addEllipse(FloatRect(
- centerX - radiusX + boundingBox.x(),
- centerY - radiusY + boundingBox.y(),
+ center.x() - radiusX + boundingBox.x(),
+ center.y() - radiusY + boundingBox.y(),
radiusX * 2,
radiusY * 2
));
« no previous file with comments | « Source/core/rendering/style/BasicShapes.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698