summaryrefslogtreecommitdiff
path: root/Source/WebCore/rendering/style/ShapeValue.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/rendering/style/ShapeValue.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/rendering/style/ShapeValue.h')
-rw-r--r--Source/WebCore/rendering/style/ShapeValue.h88
1 files changed, 35 insertions, 53 deletions
diff --git a/Source/WebCore/rendering/style/ShapeValue.h b/Source/WebCore/rendering/style/ShapeValue.h
index 53c11a7e8..b749a26c0 100644
--- a/Source/WebCore/rendering/style/ShapeValue.h
+++ b/Source/WebCore/rendering/style/ShapeValue.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
+ * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,92 +28,73 @@
* SUCH DAMAGE.
*/
-#ifndef ShapeValue_h
-#define ShapeValue_h
+#pragma once
#include "BasicShapes.h"
-#include "CSSValueKeywords.h"
-#include "CachedImage.h"
#include "StyleImage.h"
-#include <wtf/PassRefPtr.h>
namespace WebCore {
class ShapeValue : public RefCounted<ShapeValue> {
public:
- enum ShapeValueType {
- // The None value is defined by a null ShapeValue*
- Shape,
- Box,
- Outside,
- Image
- };
-
- static PassRefPtr<ShapeValue> createShapeValue(PassRefPtr<BasicShape> shape, LayoutBox layoutBox)
- {
- return adoptRef(new ShapeValue(shape, layoutBox));
- }
-
- static PassRefPtr<ShapeValue> createLayoutBoxValue(LayoutBox layoutBox)
+ static Ref<ShapeValue> create(Ref<BasicShape>&& shape, CSSBoxType cssBox)
{
- return adoptRef(new ShapeValue(layoutBox));
+ return adoptRef(*new ShapeValue(WTFMove(shape), cssBox));
}
- static PassRefPtr<ShapeValue> createOutsideValue()
+ static Ref<ShapeValue> create(CSSBoxType boxShape)
{
- return adoptRef(new ShapeValue(Outside));
+ return adoptRef(*new ShapeValue(boxShape));
}
- static PassRefPtr<ShapeValue> createImageValue(PassRefPtr<StyleImage> image)
+ static Ref<ShapeValue> create(Ref<StyleImage>&& image)
{
- return adoptRef(new ShapeValue(image));
+ return adoptRef(*new ShapeValue(WTFMove(image)));
}
- ShapeValueType type() const { return m_type; }
+ enum class Type { Shape, Box, Image };
+ Type type() const { return m_type; }
BasicShape* shape() const { return m_shape.get(); }
- LayoutBox layoutBox() const { return m_layoutBox; }
-
+ CSSBoxType cssBox() const { return m_cssBox; }
StyleImage* image() const { return m_image.get(); }
- bool isImageValid() const { return image() && image()->cachedImage() && image()->cachedImage()->hasImage(); }
- void setImage(PassRefPtr<StyleImage> image)
+ bool isImageValid() const;
+
+ void setImage(Ref<StyleImage>&& image)
{
- ASSERT(type() == Image);
- if (m_image != image)
- m_image = image;
+ ASSERT(m_type == Type::Image);
+ m_image = WTFMove(image);
}
- bool operator==(const ShapeValue& other) const { return type() == other.type(); }
-
-private:
- ShapeValue(PassRefPtr<BasicShape> shape, LayoutBox layoutBox)
- : m_type(Shape)
- , m_shape(shape)
- , m_layoutBox(layoutBox)
+ bool operator==(const ShapeValue&) const;
+ bool operator!=(const ShapeValue& other) const
{
+ return !(*this == other);
}
- ShapeValue(ShapeValueType type)
- : m_type(type)
- , m_layoutBox(BoxMissing)
+
+private:
+ ShapeValue(Ref<BasicShape>&& shape, CSSBoxType cssBox)
+ : m_type(Type::Shape)
+ , m_shape(WTFMove(shape))
+ , m_cssBox(cssBox)
{
}
- ShapeValue(PassRefPtr<StyleImage> image)
- : m_type(Image)
- , m_image(image)
- , m_layoutBox(BoxMissing)
+
+ explicit ShapeValue(Ref<StyleImage>&& image)
+ : m_type(Type::Image)
+ , m_image(WTFMove(image))
{
}
- ShapeValue(LayoutBox layoutBox)
- : m_type(Box)
- , m_layoutBox(layoutBox)
+
+ explicit ShapeValue(CSSBoxType cssBox)
+ : m_type(Type::Box)
+ , m_cssBox(cssBox)
{
}
- ShapeValueType m_type;
+ Type m_type;
RefPtr<BasicShape> m_shape;
RefPtr<StyleImage> m_image;
- LayoutBox m_layoutBox;
+ CSSBoxType m_cssBox { BoxMissing };
};
}
-
-#endif