OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above | 8 * 1. Redistributions of source code must retain the above |
9 * copyright notice, this list of conditions and the following | 9 * copyright notice, this list of conditions and the following |
10 * disclaimer. | 10 * disclaimer. |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 #ifndef Shape_h | 30 #ifndef Shape_h |
31 #define Shape_h | 31 #define Shape_h |
32 | 32 |
33 #include "core/CoreExport.h" | 33 #include "core/CoreExport.h" |
34 #include "core/style/BasicShapes.h" | 34 #include "core/style/BasicShapes.h" |
35 #include "core/style/StyleImage.h" | 35 #include "core/style/StyleImage.h" |
36 #include "platform/geometry/LayoutRect.h" | 36 #include "platform/geometry/LayoutRect.h" |
37 #include "platform/graphics/Path.h" | 37 #include "platform/graphics/Path.h" |
38 #include "platform/text/WritingMode.h" | 38 #include "platform/text/WritingMode.h" |
39 #include "wtf/PassOwnPtr.h" | 39 #include <memory> |
40 | 40 |
41 namespace blink { | 41 namespace blink { |
42 | 42 |
43 class FloatRoundedRect; | 43 class FloatRoundedRect; |
44 | 44 |
45 struct LineSegment { | 45 struct LineSegment { |
46 STACK_ALLOCATED(); | 46 STACK_ALLOCATED(); |
47 LineSegment() | 47 LineSegment() |
48 : logicalLeft(0) | 48 : logicalLeft(0) |
49 , logicalRight(0) | 49 , logicalRight(0) |
(...skipping 19 matching lines...) Expand all Loading... |
69 // physical coordinates. | 69 // physical coordinates. |
70 | 70 |
71 class CORE_EXPORT Shape { | 71 class CORE_EXPORT Shape { |
72 USING_FAST_MALLOC(Shape); | 72 USING_FAST_MALLOC(Shape); |
73 public: | 73 public: |
74 struct DisplayPaths { | 74 struct DisplayPaths { |
75 STACK_ALLOCATED(); | 75 STACK_ALLOCATED(); |
76 Path shape; | 76 Path shape; |
77 Path marginShape; | 77 Path marginShape; |
78 }; | 78 }; |
79 static PassOwnPtr<Shape> createShape(const BasicShape*, const LayoutSize& lo
gicalBoxSize, WritingMode, float margin); | 79 static std::unique_ptr<Shape> createShape(const BasicShape*, const LayoutSiz
e& logicalBoxSize, WritingMode, float margin); |
80 static PassOwnPtr<Shape> createRasterShape(Image*, float threshold, const La
youtRect& imageRect, const LayoutRect& marginRect, WritingMode, float margin); | 80 static std::unique_ptr<Shape> createRasterShape(Image*, float threshold, con
st LayoutRect& imageRect, const LayoutRect& marginRect, WritingMode, float margi
n); |
81 static PassOwnPtr<Shape> createEmptyRasterShape(WritingMode, float margin); | 81 static std::unique_ptr<Shape> createEmptyRasterShape(WritingMode, float marg
in); |
82 static PassOwnPtr<Shape> createLayoutBoxShape(const FloatRoundedRect&, Writi
ngMode, float margin); | 82 static std::unique_ptr<Shape> createLayoutBoxShape(const FloatRoundedRect&,
WritingMode, float margin); |
83 | 83 |
84 virtual ~Shape() { } | 84 virtual ~Shape() { } |
85 | 85 |
86 virtual LayoutRect shapeMarginLogicalBoundingBox() const = 0; | 86 virtual LayoutRect shapeMarginLogicalBoundingBox() const = 0; |
87 virtual bool isEmpty() const = 0; | 87 virtual bool isEmpty() const = 0; |
88 virtual LineSegment getExcludedInterval(LayoutUnit logicalTop, LayoutUnit lo
gicalHeight) const = 0; | 88 virtual LineSegment getExcludedInterval(LayoutUnit logicalTop, LayoutUnit lo
gicalHeight) const = 0; |
89 | 89 |
90 bool lineOverlapsShapeMarginBounds(LayoutUnit lineTop, LayoutUnit lineHeight
) const { return lineOverlapsBoundingBox(lineTop, lineHeight, shapeMarginLogical
BoundingBox()); } | 90 bool lineOverlapsShapeMarginBounds(LayoutUnit lineTop, LayoutUnit lineHeight
) const { return lineOverlapsBoundingBox(lineTop, lineHeight, shapeMarginLogical
BoundingBox()); } |
91 virtual void buildDisplayPaths(DisplayPaths&) const = 0; | 91 virtual void buildDisplayPaths(DisplayPaths&) const = 0; |
92 | 92 |
93 protected: | 93 protected: |
94 float shapeMargin() const { return m_margin; } | 94 float shapeMargin() const { return m_margin; } |
95 | 95 |
96 private: | 96 private: |
97 bool lineOverlapsBoundingBox(LayoutUnit lineTop, LayoutUnit lineHeight, cons
t LayoutRect& rect) const | 97 bool lineOverlapsBoundingBox(LayoutUnit lineTop, LayoutUnit lineHeight, cons
t LayoutRect& rect) const |
98 { | 98 { |
99 if (rect.isEmpty()) | 99 if (rect.isEmpty()) |
100 return false; | 100 return false; |
101 return (lineTop < rect.maxY() && lineTop + lineHeight > rect.y()) || (!l
ineHeight && lineTop == rect.y()); | 101 return (lineTop < rect.maxY() && lineTop + lineHeight > rect.y()) || (!l
ineHeight && lineTop == rect.y()); |
102 } | 102 } |
103 | 103 |
104 WritingMode m_writingMode; | 104 WritingMode m_writingMode; |
105 float m_margin; | 105 float m_margin; |
106 }; | 106 }; |
107 | 107 |
108 } // namespace blink | 108 } // namespace blink |
109 | 109 |
110 #endif // Shape_h | 110 #endif // Shape_h |
OLD | NEW |