1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_STYLE_RAY_H_
6 #define THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_STYLE_RAY_H_
7 
8 #include "third_party/blink/renderer/core/style/basic_shapes.h"
9 #include "third_party/blink/renderer/platform/wtf/casting.h"
10 
11 namespace blink {
12 
13 class StyleRay : public BasicShape {
14  public:
15   enum class RaySize {
16     kClosestSide,
17     kClosestCorner,
18     kFarthestSide,
19     kFarthestCorner,
20     kSides
21   };
22 
23   static scoped_refptr<StyleRay> Create(float angle, RaySize, bool contain);
24   ~StyleRay() override = default;
25 
Angle()26   float Angle() const { return angle_; }
Size()27   RaySize Size() const { return size_; }
Contain()28   bool Contain() const { return contain_; }
29 
30   void GetPath(Path&, const FloatRect&, float) override;
31   bool operator==(const BasicShape&) const override;
32 
GetType()33   ShapeType GetType() const override { return kStyleRayType; }
34 
35  private:
36   StyleRay(float angle, RaySize, bool contain);
37 
38   float angle_;
39   RaySize size_;
40   bool contain_;
41 };
42 
43 template <>
44 struct DowncastTraits<StyleRay> {
45   static bool AllowFrom(const BasicShape& value) {
46     return value.GetType() == BasicShape::kStyleRayType;
47   }
48 };
49 
50 }  // namespace blink
51 
52 #endif
53