summaryrefslogtreecommitdiff
path: root/Source/WebCore/css/CSSBasicShapes.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/css/CSSBasicShapes.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/css/CSSBasicShapes.h')
-rw-r--r--Source/WebCore/css/CSSBasicShapes.h284
1 files changed, 109 insertions, 175 deletions
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 <wtf/RefPtr.h>
+#include <wtf/TypeCasts.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
+class CSSPrimitiveValue;
+class SVGPathByteStream;
+
class CSSBasicShape : public RefCounted<CSSBasicShape> {
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<CSSPrimitiveValue> layoutBox) { m_layoutBox = layoutBox; }
-
public:
virtual ~CSSBasicShape() { }
protected:
CSSBasicShape() { }
- RefPtr<CSSPrimitiveValue> m_layoutBox;
+ RefPtr<CSSPrimitiveValue> m_referenceBox;
};
-class CSSBasicShapeRectangle : public CSSBasicShape {
+class CSSBasicShapeInset final : public CSSBasicShape {
public:
- static PassRefPtr<CSSBasicShapeRectangle> 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<CSSPrimitiveValue> x) { m_x = x; }
- void setY(PassRefPtr<CSSPrimitiveValue> y) { m_y = y; }
- void setWidth(PassRefPtr<CSSPrimitiveValue> width) { m_width = width; }
- void setHeight(PassRefPtr<CSSPrimitiveValue> height) { m_height = height; }
- void setRadiusX(PassRefPtr<CSSPrimitiveValue> radiusX) { m_radiusX = radiusX; }
- void setRadiusY(PassRefPtr<CSSPrimitiveValue> 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<CSSPrimitiveValue> m_y;
- RefPtr<CSSPrimitiveValue> m_x;
- RefPtr<CSSPrimitiveValue> m_width;
- RefPtr<CSSPrimitiveValue> m_height;
- RefPtr<CSSPrimitiveValue> m_radiusX;
- RefPtr<CSSPrimitiveValue> m_radiusY;
-};
-
-class CSSBasicShapeInsetRectangle : public CSSBasicShape {
-public:
- static PassRefPtr<CSSBasicShapeInsetRectangle> 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<CSSPrimitiveValue> top) { m_top = top; }
- void setRight(PassRefPtr<CSSPrimitiveValue> right) { m_right = right; }
- void setBottom(PassRefPtr<CSSPrimitiveValue> bottom) { m_bottom = bottom; }
- void setLeft(PassRefPtr<CSSPrimitiveValue> left) { m_left = left; }
- void setRadiusX(PassRefPtr<CSSPrimitiveValue> radiusX) { m_radiusX = radiusX; }
- void setRadiusY(PassRefPtr<CSSPrimitiveValue> 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<CSSPrimitiveValue> m_right;
- RefPtr<CSSPrimitiveValue> m_top;
- RefPtr<CSSPrimitiveValue> m_bottom;
- RefPtr<CSSPrimitiveValue> m_left;
- RefPtr<CSSPrimitiveValue> m_radiusX;
- RefPtr<CSSPrimitiveValue> m_radiusY;
-};
-
-
-class CSSBasicShapeInset : public CSSBasicShape {
-public:
- static PassRefPtr<CSSBasicShapeInset> create() { return adoptRef(new CSSBasicShapeInset); }
+ static Ref<CSSBasicShapeInset> 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<CSSPrimitiveValue> top) { m_top = top; }
- void setRight(PassRefPtr<CSSPrimitiveValue> right) { m_right = right; }
- void setBottom(PassRefPtr<CSSPrimitiveValue> bottom) { m_bottom = bottom; }
- void setLeft(PassRefPtr<CSSPrimitiveValue> left) { m_left = left; }
+ void setTop(Ref<CSSPrimitiveValue>&& top) { m_top = WTFMove(top); }
+ void setRight(Ref<CSSPrimitiveValue>&& right) { m_right = WTFMove(right); }
+ void setBottom(Ref<CSSPrimitiveValue>&& bottom) { m_bottom = WTFMove(bottom); }
+ void setLeft(Ref<CSSPrimitiveValue>&& left) { m_left = WTFMove(left); }
- void setTopLeftRadius(PassRefPtr<CSSPrimitiveValue> radius) { m_topLeftRadius = radius; }
- void setTopRightRadius(PassRefPtr<CSSPrimitiveValue> radius) { m_topRightRadius = radius; }
- void setBottomRightRadius(PassRefPtr<CSSPrimitiveValue> radius) { m_bottomRightRadius = radius; }
- void setBottomLeftRadius(PassRefPtr<CSSPrimitiveValue> radius) { m_bottomLeftRadius = radius; }
+ void updateShapeSize4Values(Ref<CSSPrimitiveValue>&& top, Ref<CSSPrimitiveValue>&& right, Ref<CSSPrimitiveValue>&& bottom, Ref<CSSPrimitiveValue>&& left)
+ {
+ setTop(WTFMove(top));
+ setRight(WTFMove(right));
+ setBottom(WTFMove(bottom));
+ setLeft(WTFMove(left));
+ }
+
+ void updateShapeSize1Value(Ref<CSSPrimitiveValue>&& value1)
+ {
+ updateShapeSize4Values(value1.copyRef(), value1.copyRef(), value1.copyRef(), value1.copyRef());
+ }
+
+ void updateShapeSize2Values(Ref<CSSPrimitiveValue>&& value1, Ref<CSSPrimitiveValue>&& value2)
+ {
+ updateShapeSize4Values(value1.copyRef(), value2.copyRef(), value1.copyRef(), value2.copyRef());
+ }
+
+ void updateShapeSize3Values(Ref<CSSPrimitiveValue>&& value1, Ref<CSSPrimitiveValue>&& value2, Ref<CSSPrimitiveValue>&& 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<CSSPrimitiveValue>&& radius) { m_topLeftRadius = WTFMove(radius); }
+ void setTopRightRadius(RefPtr<CSSPrimitiveValue>&& radius) { m_topRightRadius = WTFMove(radius); }
+ void setBottomRightRadius(RefPtr<CSSPrimitiveValue>&& radius) { m_bottomRightRadius = WTFMove(radius); }
+ void setBottomLeftRadius(RefPtr<CSSPrimitiveValue>&& radius) { m_bottomLeftRadius = WTFMove(radius); }
private:
CSSBasicShapeInset() { }
+ Type type() const final { return CSSBasicShapeInsetType; }
+ String cssText() const final;
+ bool equals(const CSSBasicShape&) const final;
+
RefPtr<CSSPrimitiveValue> m_top;
RefPtr<CSSPrimitiveValue> m_right;
RefPtr<CSSPrimitiveValue> m_bottom;
@@ -175,74 +127,50 @@ private:
RefPtr<CSSPrimitiveValue> m_bottomLeftRadius;
};
-class CSSBasicShapeCircle : public CSSBasicShape {
+class CSSBasicShapeCircle final : public CSSBasicShape {
public:
- static PassRefPtr<CSSBasicShapeCircle> 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<CSSBasicShapeCircle> 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<CSSPrimitiveValue> centerX) { m_centerX = centerX; }
- void setCenterY(PassRefPtr<CSSPrimitiveValue> centerY) { m_centerY = centerY; }
- void setRadius(PassRefPtr<CSSPrimitiveValue> radius) { m_radius = radius; }
+ void setCenterX(Ref<CSSPrimitiveValue>&& centerX) { m_centerX = WTFMove(centerX); }
+ void setCenterY(Ref<CSSPrimitiveValue>&& centerY) { m_centerY = WTFMove(centerY); }
+ void setRadius(Ref<CSSPrimitiveValue>&& radius) { m_radius = WTFMove(radius); }
private:
CSSBasicShapeCircle() { }
- RefPtr<CSSPrimitiveValue> m_centerX;
- RefPtr<CSSPrimitiveValue> m_centerY;
- RefPtr<CSSPrimitiveValue> m_radius;
-};
-
-class CSSDeprecatedBasicShapeCircle : public CSSBasicShape {
-public:
- static PassRefPtr<CSSDeprecatedBasicShapeCircle> 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<CSSPrimitiveValue> centerX) { m_centerX = centerX; }
- void setCenterY(PassRefPtr<CSSPrimitiveValue> centerY) { m_centerY = centerY; }
- void setRadius(PassRefPtr<CSSPrimitiveValue> 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<CSSPrimitiveValue> m_centerY;
RefPtr<CSSPrimitiveValue> m_centerX;
+ RefPtr<CSSPrimitiveValue> m_centerY;
RefPtr<CSSPrimitiveValue> m_radius;
};
-class CSSDeprecatedBasicShapeEllipse : public CSSBasicShape {
+class CSSBasicShapeEllipse final : public CSSBasicShape {
public:
- static PassRefPtr<CSSDeprecatedBasicShapeEllipse> create() { return adoptRef(new CSSDeprecatedBasicShapeEllipse); }
+ static Ref<CSSBasicShapeEllipse> 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<CSSPrimitiveValue> centerX) { m_centerX = centerX; }
- void setCenterY(PassRefPtr<CSSPrimitiveValue> centerY) { m_centerY = centerY; }
- void setRadiusX(PassRefPtr<CSSPrimitiveValue> radiusX) { m_radiusX = radiusX; }
- void setRadiusY(PassRefPtr<CSSPrimitiveValue> 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<CSSPrimitiveValue>&& centerX) { m_centerX = WTFMove(centerX); }
+ void setCenterY(Ref<CSSPrimitiveValue>&& centerY) { m_centerY = WTFMove(centerY); }
+ void setRadiusX(Ref<CSSPrimitiveValue>&& radiusX) { m_radiusX = WTFMove(radiusX); }
+ void setRadiusY(Ref<CSSPrimitiveValue>&& 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<CSSPrimitiveValue> m_centerX;
RefPtr<CSSPrimitiveValue> m_centerY;
@@ -250,64 +178,70 @@ private:
RefPtr<CSSPrimitiveValue> m_radiusY;
};
-class CSSBasicShapeEllipse : public CSSBasicShape {
+class CSSBasicShapePolygon final : public CSSBasicShape {
public:
- static PassRefPtr<CSSBasicShapeEllipse> create() { return adoptRef(new CSSBasicShapeEllipse); }
+ static Ref<CSSBasicShapePolygon> 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<CSSPrimitiveValue>&& x, Ref<CSSPrimitiveValue>&& y)
+ {
+ m_values.append(WTFMove(x));
+ m_values.append(WTFMove(y));
+ }
- void setCenterX(PassRefPtr<CSSPrimitiveValue> centerX) { m_centerX = centerX; }
- void setCenterY(PassRefPtr<CSSPrimitiveValue> centerY) { m_centerY = centerY; }
- void setRadiusX(PassRefPtr<CSSPrimitiveValue> radiusX) { m_radiusX = radiusX; }
- void setRadiusY(PassRefPtr<CSSPrimitiveValue> radiusY) { m_radiusY = radiusY; }
+ const Vector<Ref<CSSPrimitiveValue>>& 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<CSSPrimitiveValue> m_centerX;
- RefPtr<CSSPrimitiveValue> m_centerY;
- RefPtr<CSSPrimitiveValue> m_radiusX;
- RefPtr<CSSPrimitiveValue> m_radiusY;
+ Type type() const final { return CSSBasicShapePolygonType; }
+ String cssText() const final;
+ bool equals(const CSSBasicShape&) const final;
+
+ Vector<Ref<CSSPrimitiveValue>> m_values;
+ WindRule m_windRule;
};
-class CSSBasicShapePolygon : public CSSBasicShape {
+class CSSBasicShapePath final : public CSSBasicShape {
public:
- static PassRefPtr<CSSBasicShapePolygon> create() { return adoptRef(new CSSBasicShapePolygon); }
-
- void appendPoint(PassRefPtr<CSSPrimitiveValue> x, PassRefPtr<CSSPrimitiveValue> y)
+ static Ref<CSSBasicShapePath> create(std::unique_ptr<SVGPathByteStream>&& pathData)
{
- m_values.append(x);
- m_values.append(y);
+ return adoptRef(*new CSSBasicShapePath(WTFMove(pathData)));
}
- PassRefPtr<CSSPrimitiveValue> getXAt(unsigned i) const { return m_values.at(i * 2); }
- PassRefPtr<CSSPrimitiveValue> getYAt(unsigned i) const { return m_values.at(i * 2 + 1); }
- const Vector<RefPtr<CSSPrimitiveValue>>& 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<SVGPathByteStream>&&);
- Vector<RefPtr<CSSPrimitiveValue>> m_values;
- WindRule m_windRule;
+ Type type() const final { return CSSBasicShapePathType; }
+ String cssText() const final;
+ bool equals(const CSSBasicShape&) const final;
+
+ std::unique_ptr<SVGPathByteStream> 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)