From 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Tue, 27 Jun 2017 06:07:23 +0000 Subject: webkitgtk-2.16.5 --- Source/WebCore/css/CSSBasicShapes.h | 284 ++++++++++++++---------------------- 1 file changed, 109 insertions(+), 175 deletions(-) (limited to 'Source/WebCore/css/CSSBasicShapes.h') diff --git a/Source/WebCore/css/CSSBasicShapes.h b/Source/WebCore/css/CSSBasicShapes.h index 4d85bf42b..6f449cc70 100644 --- a/Source/WebCore/css/CSSBasicShapes.h +++ b/Source/WebCore/css/CSSBasicShapes.h @@ -27,115 +27,44 @@ * SUCH DAMAGE. */ -#ifndef CSSBasicShapes_h -#define CSSBasicShapes_h +#pragma once -#include "CSSPrimitiveValue.h" #include "WindRule.h" #include +#include #include #include namespace WebCore { +class CSSPrimitiveValue; +class SVGPathByteStream; + class CSSBasicShape : public RefCounted { public: enum Type { - CSSBasicShapeRectangleType, - CSSDeprecatedBasicShapeCircleType, - CSSDeprecatedBasicShapeEllipseType, CSSBasicShapePolygonType, - CSSBasicShapeInsetRectangleType, CSSBasicShapeCircleType, CSSBasicShapeEllipseType, - CSSBasicShapeInsetType + CSSBasicShapeInsetType, + CSSBasicShapePathType }; virtual Type type() const = 0; virtual String cssText() const = 0; virtual bool equals(const CSSBasicShape&) const = 0; - CSSPrimitiveValue* layoutBox() const { return m_layoutBox.get(); } - void setLayoutBox(PassRefPtr layoutBox) { m_layoutBox = layoutBox; } - public: virtual ~CSSBasicShape() { } protected: CSSBasicShape() { } - RefPtr m_layoutBox; + RefPtr m_referenceBox; }; -class CSSBasicShapeRectangle : public CSSBasicShape { +class CSSBasicShapeInset final : public CSSBasicShape { public: - static PassRefPtr create() { return adoptRef(new CSSBasicShapeRectangle); } - - CSSPrimitiveValue* x() const { return m_x.get(); } - CSSPrimitiveValue* y() const { return m_y.get(); } - CSSPrimitiveValue* width() const { return m_width.get(); } - CSSPrimitiveValue* height() const { return m_height.get(); } - CSSPrimitiveValue* radiusX() const { return m_radiusX.get(); } - CSSPrimitiveValue* radiusY() const { return m_radiusY.get(); } - - void setX(PassRefPtr x) { m_x = x; } - void setY(PassRefPtr y) { m_y = y; } - void setWidth(PassRefPtr width) { m_width = width; } - void setHeight(PassRefPtr height) { m_height = height; } - void setRadiusX(PassRefPtr radiusX) { m_radiusX = radiusX; } - void setRadiusY(PassRefPtr radiusY) { m_radiusY = radiusY; } - - virtual Type type() const override { return CSSBasicShapeRectangleType; } - virtual String cssText() const override; - virtual bool equals(const CSSBasicShape&) const override; - -private: - CSSBasicShapeRectangle() { } - - RefPtr m_y; - RefPtr m_x; - RefPtr m_width; - RefPtr m_height; - RefPtr m_radiusX; - RefPtr m_radiusY; -}; - -class CSSBasicShapeInsetRectangle : public CSSBasicShape { -public: - static PassRefPtr create() { return adoptRef(new CSSBasicShapeInsetRectangle); } - - CSSPrimitiveValue* top() const { return m_top.get(); } - CSSPrimitiveValue* right() const { return m_right.get(); } - CSSPrimitiveValue* bottom() const { return m_bottom.get(); } - CSSPrimitiveValue* left() const { return m_left.get(); } - CSSPrimitiveValue* radiusX() const { return m_radiusX.get(); } - CSSPrimitiveValue* radiusY() const { return m_radiusY.get(); } - - void setTop(PassRefPtr top) { m_top = top; } - void setRight(PassRefPtr right) { m_right = right; } - void setBottom(PassRefPtr bottom) { m_bottom = bottom; } - void setLeft(PassRefPtr left) { m_left = left; } - void setRadiusX(PassRefPtr radiusX) { m_radiusX = radiusX; } - void setRadiusY(PassRefPtr radiusY) { m_radiusY = radiusY; } - - virtual Type type() const override { return CSSBasicShapeInsetRectangleType; } - virtual String cssText() const override; - virtual bool equals(const CSSBasicShape&) const override; - -private: - CSSBasicShapeInsetRectangle() { } - - RefPtr m_right; - RefPtr m_top; - RefPtr m_bottom; - RefPtr m_left; - RefPtr m_radiusX; - RefPtr m_radiusY; -}; - - -class CSSBasicShapeInset : public CSSBasicShape { -public: - static PassRefPtr create() { return adoptRef(new CSSBasicShapeInset); } + static Ref create() { return adoptRef(*new CSSBasicShapeInset); } CSSPrimitiveValue* top() const { return m_top.get(); } CSSPrimitiveValue* right() const { return m_right.get(); } @@ -147,23 +76,46 @@ public: CSSPrimitiveValue* bottomRightRadius() const { return m_bottomRightRadius.get(); } CSSPrimitiveValue* bottomLeftRadius() const { return m_bottomLeftRadius.get(); } - void setTop(PassRefPtr top) { m_top = top; } - void setRight(PassRefPtr right) { m_right = right; } - void setBottom(PassRefPtr bottom) { m_bottom = bottom; } - void setLeft(PassRefPtr left) { m_left = left; } + void setTop(Ref&& top) { m_top = WTFMove(top); } + void setRight(Ref&& right) { m_right = WTFMove(right); } + void setBottom(Ref&& bottom) { m_bottom = WTFMove(bottom); } + void setLeft(Ref&& left) { m_left = WTFMove(left); } - void setTopLeftRadius(PassRefPtr radius) { m_topLeftRadius = radius; } - void setTopRightRadius(PassRefPtr radius) { m_topRightRadius = radius; } - void setBottomRightRadius(PassRefPtr radius) { m_bottomRightRadius = radius; } - void setBottomLeftRadius(PassRefPtr radius) { m_bottomLeftRadius = radius; } + void updateShapeSize4Values(Ref&& top, Ref&& right, Ref&& bottom, Ref&& left) + { + setTop(WTFMove(top)); + setRight(WTFMove(right)); + setBottom(WTFMove(bottom)); + setLeft(WTFMove(left)); + } + + void updateShapeSize1Value(Ref&& value1) + { + updateShapeSize4Values(value1.copyRef(), value1.copyRef(), value1.copyRef(), value1.copyRef()); + } + + void updateShapeSize2Values(Ref&& value1, Ref&& value2) + { + updateShapeSize4Values(value1.copyRef(), value2.copyRef(), value1.copyRef(), value2.copyRef()); + } + + void updateShapeSize3Values(Ref&& value1, Ref&& value2, Ref&& value3) + { + updateShapeSize4Values(WTFMove(value1), value2.copyRef(), WTFMove(value3), value2.copyRef()); + } - virtual Type type() const override { return CSSBasicShapeInsetType; } - virtual String cssText() const override; - virtual bool equals(const CSSBasicShape&) const override; + void setTopLeftRadius(RefPtr&& radius) { m_topLeftRadius = WTFMove(radius); } + void setTopRightRadius(RefPtr&& radius) { m_topRightRadius = WTFMove(radius); } + void setBottomRightRadius(RefPtr&& radius) { m_bottomRightRadius = WTFMove(radius); } + void setBottomLeftRadius(RefPtr&& radius) { m_bottomLeftRadius = WTFMove(radius); } private: CSSBasicShapeInset() { } + Type type() const final { return CSSBasicShapeInsetType; } + String cssText() const final; + bool equals(const CSSBasicShape&) const final; + RefPtr m_top; RefPtr m_right; RefPtr m_bottom; @@ -175,74 +127,50 @@ private: RefPtr m_bottomLeftRadius; }; -class CSSBasicShapeCircle : public CSSBasicShape { +class CSSBasicShapeCircle final : public CSSBasicShape { public: - static PassRefPtr create() { return adoptRef(new CSSBasicShapeCircle); } - - virtual Type type() const override { return CSSBasicShapeCircleType; } - virtual String cssText() const override; - virtual bool equals(const CSSBasicShape&) const override; + static Ref create() { return adoptRef(*new CSSBasicShapeCircle); } CSSPrimitiveValue* centerX() const { return m_centerX.get(); } CSSPrimitiveValue* centerY() const { return m_centerY.get(); } CSSPrimitiveValue* radius() const { return m_radius.get(); } - void setCenterX(PassRefPtr centerX) { m_centerX = centerX; } - void setCenterY(PassRefPtr centerY) { m_centerY = centerY; } - void setRadius(PassRefPtr radius) { m_radius = radius; } + void setCenterX(Ref&& centerX) { m_centerX = WTFMove(centerX); } + void setCenterY(Ref&& centerY) { m_centerY = WTFMove(centerY); } + void setRadius(Ref&& radius) { m_radius = WTFMove(radius); } private: CSSBasicShapeCircle() { } - RefPtr m_centerX; - RefPtr m_centerY; - RefPtr m_radius; -}; - -class CSSDeprecatedBasicShapeCircle : public CSSBasicShape { -public: - static PassRefPtr create() { return adoptRef(new CSSDeprecatedBasicShapeCircle); } - - CSSPrimitiveValue* centerX() const { return m_centerX.get(); } - CSSPrimitiveValue* centerY() const { return m_centerY.get(); } - CSSPrimitiveValue* radius() const { return m_radius.get(); } - - void setCenterX(PassRefPtr centerX) { m_centerX = centerX; } - void setCenterY(PassRefPtr centerY) { m_centerY = centerY; } - void setRadius(PassRefPtr radius) { m_radius = radius; } - - virtual Type type() const override { return CSSDeprecatedBasicShapeCircleType; } - virtual String cssText() const override; - virtual bool equals(const CSSBasicShape&) const override; + Type type() const final { return CSSBasicShapeCircleType; } + String cssText() const final; + bool equals(const CSSBasicShape&) const final; -private: - CSSDeprecatedBasicShapeCircle() { } - - RefPtr m_centerY; RefPtr m_centerX; + RefPtr m_centerY; RefPtr m_radius; }; -class CSSDeprecatedBasicShapeEllipse : public CSSBasicShape { +class CSSBasicShapeEllipse final : public CSSBasicShape { public: - static PassRefPtr create() { return adoptRef(new CSSDeprecatedBasicShapeEllipse); } + static Ref create() { return adoptRef(*new CSSBasicShapeEllipse); } CSSPrimitiveValue* centerX() const { return m_centerX.get(); } CSSPrimitiveValue* centerY() const { return m_centerY.get(); } CSSPrimitiveValue* radiusX() const { return m_radiusX.get(); } CSSPrimitiveValue* radiusY() const { return m_radiusY.get(); } - void setCenterX(PassRefPtr centerX) { m_centerX = centerX; } - void setCenterY(PassRefPtr centerY) { m_centerY = centerY; } - void setRadiusX(PassRefPtr radiusX) { m_radiusX = radiusX; } - void setRadiusY(PassRefPtr radiusY) { m_radiusY = radiusY; } - - virtual Type type() const override { return CSSDeprecatedBasicShapeEllipseType; } - virtual String cssText() const override; - virtual bool equals(const CSSBasicShape&) const override; + void setCenterX(Ref&& centerX) { m_centerX = WTFMove(centerX); } + void setCenterY(Ref&& centerY) { m_centerY = WTFMove(centerY); } + void setRadiusX(Ref&& radiusX) { m_radiusX = WTFMove(radiusX); } + void setRadiusY(Ref&& radiusY) { m_radiusY = WTFMove(radiusY); } private: - CSSDeprecatedBasicShapeEllipse() { } + CSSBasicShapeEllipse() { } + + Type type() const final { return CSSBasicShapeEllipseType; } + String cssText() const final; + bool equals(const CSSBasicShape&) const final; RefPtr m_centerX; RefPtr m_centerY; @@ -250,64 +178,70 @@ private: RefPtr m_radiusY; }; -class CSSBasicShapeEllipse : public CSSBasicShape { +class CSSBasicShapePolygon final : public CSSBasicShape { public: - static PassRefPtr create() { return adoptRef(new CSSBasicShapeEllipse); } + static Ref create() { return adoptRef(*new CSSBasicShapePolygon); } - CSSPrimitiveValue* centerX() const { return m_centerX.get(); } - CSSPrimitiveValue* centerY() const { return m_centerY.get(); } - CSSPrimitiveValue* radiusX() const { return m_radiusX.get(); } - CSSPrimitiveValue* radiusY() const { return m_radiusY.get(); } + void appendPoint(Ref&& x, Ref&& y) + { + m_values.append(WTFMove(x)); + m_values.append(WTFMove(y)); + } - void setCenterX(PassRefPtr centerX) { m_centerX = centerX; } - void setCenterY(PassRefPtr centerY) { m_centerY = centerY; } - void setRadiusX(PassRefPtr radiusX) { m_radiusX = radiusX; } - void setRadiusY(PassRefPtr radiusY) { m_radiusY = radiusY; } + const Vector>& values() const { return m_values; } - virtual Type type() const override { return CSSBasicShapeEllipseType; } - virtual String cssText() const override; - virtual bool equals(const CSSBasicShape&) const override; + void setWindRule(WindRule rule) { m_windRule = rule; } + WindRule windRule() const { return m_windRule; } private: - CSSBasicShapeEllipse() { } + CSSBasicShapePolygon() + : m_windRule(RULE_NONZERO) + { + } - RefPtr m_centerX; - RefPtr m_centerY; - RefPtr m_radiusX; - RefPtr m_radiusY; + Type type() const final { return CSSBasicShapePolygonType; } + String cssText() const final; + bool equals(const CSSBasicShape&) const final; + + Vector> m_values; + WindRule m_windRule; }; -class CSSBasicShapePolygon : public CSSBasicShape { +class CSSBasicShapePath final : public CSSBasicShape { public: - static PassRefPtr create() { return adoptRef(new CSSBasicShapePolygon); } - - void appendPoint(PassRefPtr x, PassRefPtr y) + static Ref create(std::unique_ptr&& pathData) { - m_values.append(x); - m_values.append(y); + return adoptRef(*new CSSBasicShapePath(WTFMove(pathData))); } - PassRefPtr getXAt(unsigned i) const { return m_values.at(i * 2); } - PassRefPtr getYAt(unsigned i) const { return m_values.at(i * 2 + 1); } - const Vector>& values() const { return m_values; } + const SVGPathByteStream& pathData() const + { + return *m_byteStream; + } - void setWindRule(WindRule w) { m_windRule = w; } + void setWindRule(WindRule rule) { m_windRule = rule; } WindRule windRule() const { return m_windRule; } - virtual Type type() const override { return CSSBasicShapePolygonType; } - virtual String cssText() const override; - virtual bool equals(const CSSBasicShape&) const override; - private: - CSSBasicShapePolygon() - : m_windRule(RULE_NONZERO) - { - } + CSSBasicShapePath(std::unique_ptr&&); - Vector> m_values; - WindRule m_windRule; + Type type() const final { return CSSBasicShapePathType; } + String cssText() const final; + bool equals(const CSSBasicShape&) const final; + + std::unique_ptr m_byteStream; + WindRule m_windRule { RULE_NONZERO }; }; } // namespace WebCore -#endif // CSSBasicShapes_h +#define SPECIALIZE_TYPE_TRAITS_CSS_BASIC_SHAPES(ToValueTypeName) \ +SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToValueTypeName) \ + static bool isType(const WebCore::CSSBasicShape& basicShape) { return basicShape.type() == WebCore::CSSBasicShape::ToValueTypeName##Type; } \ +SPECIALIZE_TYPE_TRAITS_END() + +SPECIALIZE_TYPE_TRAITS_CSS_BASIC_SHAPES(CSSBasicShapeInset) +SPECIALIZE_TYPE_TRAITS_CSS_BASIC_SHAPES(CSSBasicShapeCircle) +SPECIALIZE_TYPE_TRAITS_CSS_BASIC_SHAPES(CSSBasicShapeEllipse) +SPECIALIZE_TYPE_TRAITS_CSS_BASIC_SHAPES(CSSBasicShapePolygon) +SPECIALIZE_TYPE_TRAITS_CSS_BASIC_SHAPES(CSSBasicShapePath) -- cgit v1.2.1