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

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

Issue 98723006: Parse new circle shape syntax (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase after 164114 Created 7 years 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/rendering/style/BasicShapes.h
diff --git a/Source/core/rendering/style/BasicShapes.h b/Source/core/rendering/style/BasicShapes.h
index 254089c2e5e52fd3748549bfd6d98b793b61a2f4..0485afe633b9fef2c835e0612e110bf83fe4e7ab 100644
--- a/Source/core/rendering/style/BasicShapes.h
+++ b/Source/core/rendering/style/BasicShapes.h
@@ -48,10 +48,11 @@ public:
enum Type {
BasicShapeRectangleType = 1,
- BasicShapeCircleType = 2,
+ DeprecatedBasicShapeCircleType = 2,
BasicShapeEllipseType = 3,
BasicShapePolygonType = 4,
- BasicShapeInsetRectangleType = 5
+ BasicShapeInsetRectangleType = 5,
+ BasicShapeCircleType = 6
Bem Jones-Bey (adobe) 2013/12/18 21:57:57 The explicit numbers got removed in a subsequent p
};
bool canBlend(const BasicShape*) const;
@@ -122,10 +123,98 @@ private:
DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapeRectangle);
+class BasicShapeCenterCoordinate {
+public:
+ enum Keyword {
+ None,
+ Top,
+ Right,
+ Bottom,
+ Left
+ };
+ BasicShapeCenterCoordinate() : m_keyword(None), m_length(Undefined) { }
+ explicit BasicShapeCenterCoordinate(Length length) : m_keyword(None), m_length(length) { }
+ BasicShapeCenterCoordinate(Keyword keyword, Length length) : m_keyword(keyword), m_length(length) { }
+ BasicShapeCenterCoordinate(const BasicShapeCenterCoordinate& other) : m_keyword(other.keyword()), m_length(other.length()) { }
+ bool operator==(const BasicShapeCenterCoordinate& other) const { return m_keyword == other.m_keyword && m_length == other.m_length; }
+
+ Keyword keyword() const { return m_keyword; }
+ const Length& length() const { return m_length; }
+
+ BasicShapeCenterCoordinate blend(const BasicShapeCenterCoordinate& other, double progress) const
+ {
+ if (m_keyword != None || other.keyword() != None)
+ return BasicShapeCenterCoordinate(other);
+
+ return BasicShapeCenterCoordinate(m_length.blend(other.length(), progress, ValueRangeAll));
+ }
+
+private:
+ Keyword m_keyword;
+ Length m_length;
+};
+
+class BasicShapeRadius {
+public:
+ enum Type {
+ Value,
+ ClosestSide,
+ FarthestSide
+ };
+ BasicShapeRadius() : m_value(Undefined), m_type(ClosestSide) { }
+ explicit BasicShapeRadius(Length v) : m_value(v), m_type(Value) { }
+ explicit BasicShapeRadius(Type t) : m_value(Undefined), m_type(t) { }
+ BasicShapeRadius(const BasicShapeRadius& other) : m_value(other.value()), m_type(other.type()) { }
+ bool operator==(const BasicShapeRadius& other) const { return m_type == other.m_type && m_value == other.m_value; }
+
+ const Length& value() const { return m_value; }
+ Type type() const { return m_type; }
+
+ BasicShapeRadius blend(const BasicShapeRadius& other, double progress) const
+ {
+ if (m_type != Value || other.type() != Value)
+ return BasicShapeRadius(other);
+
+ return BasicShapeRadius(m_value.blend(other.value(), progress, ValueRangeAll));
+ }
+
+private:
+ Length m_value;
+ Type m_type;
+
+};
+
class BasicShapeCircle : public BasicShape {
public:
static PassRefPtr<BasicShapeCircle> create() { return adoptRef(new BasicShapeCircle); }
+ const BasicShapeCenterCoordinate& centerX() const { return m_centerX; }
+ const BasicShapeCenterCoordinate& centerY() const { return m_centerY; }
+ const BasicShapeRadius& radius() const { return m_radius; }
+
+ void setCenterX(BasicShapeCenterCoordinate centerX) { m_centerX = centerX; }
+ void setCenterY(BasicShapeCenterCoordinate centerY) { m_centerY = centerY; }
+ void setRadius(BasicShapeRadius radius) { m_radius = radius; }
+
+ virtual void path(Path&, const FloatRect&) OVERRIDE;
+ virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const OVERRIDE;
+ virtual bool operator==(const BasicShape&) const OVERRIDE;
+
+ virtual Type type() const { return BasicShapeCircleType; }
+private:
+ BasicShapeCircle() { }
+
+ BasicShapeCenterCoordinate m_centerX;
+ BasicShapeCenterCoordinate m_centerY;
+ BasicShapeRadius m_radius;
+};
+
+DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapeCircle);
+
+class DeprecatedBasicShapeCircle : public BasicShape {
+public:
+ static PassRefPtr<DeprecatedBasicShapeCircle> create() { return adoptRef(new DeprecatedBasicShapeCircle); }
+
Length centerX() const { return m_centerX; }
Length centerY() const { return m_centerY; }
Length radius() const { return m_radius; }
@@ -138,16 +227,16 @@ public:
virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const OVERRIDE;
virtual bool operator==(const BasicShape&) const OVERRIDE;
- virtual Type type() const { return BasicShapeCircleType; }
+ virtual Type type() const { return DeprecatedBasicShapeCircleType; }
private:
- BasicShapeCircle() { }
+ DeprecatedBasicShapeCircle() { }
Length m_centerX;
Length m_centerY;
Length m_radius;
};
-DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapeCircle);
+DEFINE_BASICSHAPE_TYPE_CASTS(DeprecatedBasicShapeCircle);
class BasicShapeEllipse : public BasicShape {
public:

Powered by Google App Engine
This is Rietveld 408576698