Chromium Code Reviews| Index: Source/core/rendering/style/BasicShapes.h |
| diff --git a/Source/core/rendering/style/BasicShapes.h b/Source/core/rendering/style/BasicShapes.h |
| index 088f8f5d79e9c1bd2e2606f125902b0ac413a5cf..56356f92ac3c26f780102b65dd1dcc2757f085e5 100644 |
| --- a/Source/core/rendering/style/BasicShapes.h |
| +++ b/Source/core/rendering/style/BasicShapes.h |
| @@ -87,12 +87,12 @@ class BasicShapeRectangle FINAL : public BasicShape { |
| public: |
| static PassRefPtr<BasicShapeRectangle> create() { return adoptRef(new BasicShapeRectangle); } |
| - Length x() const { return m_x; } |
| - Length y() const { return m_y; } |
| - Length width() const { return m_width; } |
| - Length height() const { return m_height; } |
| - Length cornerRadiusX() const { return m_cornerRadiusX; } |
| - Length cornerRadiusY() const { return m_cornerRadiusY; } |
| + const Length& x() const { return m_x; } |
|
Bear Travis
2014/01/23 22:04:42
Is this change necessary to this patch? It feels l
|
| + const Length& y() const { return m_y; } |
| + const Length& width() const { return m_width; } |
| + const Length& height() const { return m_height; } |
| + const Length& cornerRadiusX() const { return m_cornerRadiusX; } |
| + const Length& cornerRadiusY() const { return m_cornerRadiusY; } |
| void setX(Length x) { m_x = x; } |
| void setY(Length y) { m_y = y; } |
| @@ -127,39 +127,48 @@ DEFINE_BASICSHAPE_TYPE_CASTS(BasicShapeRectangle); |
| class BasicShapeCenterCoordinate { |
| public: |
| - enum Keyword { |
| - None, |
| - Top, |
| - Right, |
| - Bottom, |
| - Left |
| + enum Direction { |
| + TopLeft, |
| + BottomRight |
| }; |
| - 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; } |
| + BasicShapeCenterCoordinate() |
| + : m_direction(TopLeft) |
| + , m_length(Undefined) |
| + { |
| + updateComputedLength(); |
| + } |
| - Keyword keyword() const { return m_keyword; } |
| - const Length& length() const { return m_length; } |
| + BasicShapeCenterCoordinate(Direction direction, Length length) |
| + : m_direction(direction) |
| + , m_length(length) |
| + { |
| + updateComputedLength(); |
| + } |
| - bool canBlend(const BasicShapeCenterCoordinate& other) const |
| + BasicShapeCenterCoordinate(const BasicShapeCenterCoordinate& other) |
| + : m_direction(other.direction()) |
| + , m_length(other.length()) |
| + , m_computedLength(other.m_computedLength) |
| { |
| - // FIXME determine how to interpolate between keywords. See issue 330248. |
| - return m_keyword == None && other.keyword() == None; |
| } |
| + bool operator==(const BasicShapeCenterCoordinate& other) const { return m_direction == other.m_direction && m_length == other.m_length && m_computedLength == other.m_computedLength; } |
| + |
| + Direction direction() const { return m_direction; } |
| + const Length& length() const { return m_length; } |
| + const Length& computedLength() const { return m_computedLength; } |
| + |
| 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)); |
| + return BasicShapeCenterCoordinate(TopLeft, m_computedLength.blend(other.m_computedLength, progress, ValueRangeAll)); |
| } |
| private: |
| - Keyword m_keyword; |
| + Direction m_direction; |
| Length m_length; |
| + Length m_computedLength; |
| + |
| + void updateComputedLength(); |
| }; |
| class BasicShapeRadius { |
| @@ -230,9 +239,9 @@ class DeprecatedBasicShapeCircle FINAL : 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; } |
| + const Length& centerX() const { return m_centerX; } |
| + const Length& centerY() const { return m_centerY; } |
| + const Length& radius() const { return m_radius; } |
| void setCenterX(Length centerX) { m_centerX = centerX; } |
| void setCenterY(Length centerY) { m_centerY = centerY; } |
| @@ -347,12 +356,12 @@ class BasicShapeInsetRectangle FINAL : public BasicShape { |
| public: |
| static PassRefPtr<BasicShapeInsetRectangle> create() { return adoptRef(new BasicShapeInsetRectangle); } |
| - Length top() const { return m_top; } |
| - Length right() const { return m_right; } |
| - Length bottom() const { return m_bottom; } |
| - Length left() const { return m_left; } |
| - Length cornerRadiusX() const { return m_cornerRadiusX; } |
| - Length cornerRadiusY() const { return m_cornerRadiusY; } |
| + const Length& top() const { return m_top; } |
| + const Length& right() const { return m_right; } |
| + const Length& bottom() const { return m_bottom; } |
| + const Length& left() const { return m_left; } |
| + const Length& cornerRadiusX() const { return m_cornerRadiusX; } |
| + const Length& cornerRadiusY() const { return m_cornerRadiusY; } |
| void setTop(Length top) { m_top = top; } |
| void setRight(Length right) { m_right = right; } |