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

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

Issue 103413006: Implement parsing of the new ellipse shape syntax. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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 b8735a82095938079632de526a3e297e09bddebe..9351faf39264e287179f87e0039215173aa024da 100644
--- a/Source/core/rendering/style/BasicShapes.h
+++ b/Source/core/rendering/style/BasicShapes.h
@@ -47,10 +47,12 @@ public:
enum Type {
BasicShapeRectangleType = 1,
- BasicShapeCircleType = 2,
- BasicShapeEllipseType = 3,
- BasicShapePolygonType = 4,
- BasicShapeInsetRectangleType = 5
+ DeprecatedBasicShapeCircleType = 2,
+ DeprecatedBasicShapeEllipseType = 3,
+ BasicShapeEllipseType = 4,
+ BasicShapePolygonType = 5,
+ BasicShapeInsetRectangleType = 6,
+ BasicShapeCircleType = 7
bemjb 2013/12/07 00:05:32 Do you want to remove these explicit numbers in th
};
bool canBlend(const BasicShape*) const;
@@ -105,10 +107,93 @@ private:
Length m_cornerRadiusY;
};
+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()) { }
+
+ 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()) { }
+
+ 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 Type type() const { return BasicShapeCircleType; }
+private:
+ BasicShapeCircle() { }
+
+ BasicShapeCenterCoordinate m_centerX;
+ BasicShapeCenterCoordinate m_centerY;
+ BasicShapeRadius m_radius;
+};
+
+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; }
@@ -120,9 +205,9 @@ public:
virtual void path(Path&, const FloatRect&) OVERRIDE;
virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const OVERRIDE;
- virtual Type type() const { return BasicShapeCircleType; }
+ virtual Type type() const { return DeprecatedBasicShapeCircleType; }
private:
- BasicShapeCircle() { }
+ DeprecatedBasicShapeCircle() { }
Length m_centerX;
Length m_centerY;
@@ -133,6 +218,33 @@ class BasicShapeEllipse : public BasicShape {
public:
static PassRefPtr<BasicShapeEllipse> create() { return adoptRef(new BasicShapeEllipse); }
+ const BasicShapeCenterCoordinate& centerX() const { return m_centerX; }
+ const BasicShapeCenterCoordinate& centerY() const { return m_centerY; }
+ const BasicShapeRadius& radiusX() const { return m_radiusX; }
+ const BasicShapeRadius& radiusY() const { return m_radiusY; }
+
+ void setCenterX(BasicShapeCenterCoordinate centerX) { m_centerX = centerX; }
+ void setCenterY(BasicShapeCenterCoordinate centerY) { m_centerY = centerY; }
+ void setRadiusX(BasicShapeRadius radiusX) { m_radiusX = radiusX; }
+ void setRadiusY(BasicShapeRadius radiusY) { m_radiusY = radiusY; }
+
+ virtual void path(Path&, const FloatRect&) OVERRIDE;
+ virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const OVERRIDE;
+
+ virtual Type type() const { return BasicShapeEllipseType; }
+private:
+ BasicShapeEllipse() { }
+
+ BasicShapeCenterCoordinate m_centerX;
+ BasicShapeCenterCoordinate m_centerY;
+ BasicShapeRadius m_radiusX;
+ BasicShapeRadius m_radiusY;
+};
+
+class DeprecatedBasicShapeEllipse : public BasicShape {
+public:
+ static PassRefPtr<DeprecatedBasicShapeEllipse> create() { return adoptRef(new DeprecatedBasicShapeEllipse); }
+
Length centerX() const { return m_centerX; }
Length centerY() const { return m_centerY; }
Length radiusX() const { return m_radiusX; }
@@ -146,9 +258,9 @@ public:
virtual void path(Path&, const FloatRect&) OVERRIDE;
virtual PassRefPtr<BasicShape> blend(const BasicShape*, double) const OVERRIDE;
- virtual Type type() const { return BasicShapeEllipseType; }
+ virtual Type type() const { return DeprecatedBasicShapeEllipseType; }
private:
- BasicShapeEllipse() { }
+ DeprecatedBasicShapeEllipse() { }
Length m_centerX;
Length m_centerY;

Powered by Google App Engine
This is Rietveld 408576698