OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | |
3 * | |
4 * Redistribution and use in source and binary forms, with or without | |
5 * modification, are permitted provided that the following conditions | |
6 * are met: | |
7 * | |
8 * 1. Redistributions of source code must retain the above | |
9 * copyright notice, this list of conditions and the following | |
10 * disclaimer. | |
11 * 2. Redistributions in binary form must reproduce the above | |
12 * copyright notice, this list of conditions and the following | |
13 * disclaimer in the documentation and/or other materials | |
14 * provided with the distribution. | |
15 * | |
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY | |
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE | |
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, | |
21 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | |
25 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF | |
26 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
27 * SUCH DAMAGE. | |
28 */ | |
29 | |
30 #ifndef ShapeInsideInfo_h | |
31 #define ShapeInsideInfo_h | |
32 | |
33 #include "core/rendering/shapes/ShapeInfo.h" | |
34 #include "wtf/PassOwnPtr.h" | |
35 #include "wtf/Vector.h" | |
36 | |
37 namespace WebCore { | |
38 | |
39 class InlineIterator; | |
40 class RenderBlock; | |
41 class RenderObject; | |
42 | |
43 struct LineSegmentIterator { | |
44 RenderObject* root; | |
45 RenderObject* object; | |
46 unsigned offset; | |
47 LineSegmentIterator(RenderObject* root, RenderObject* object, unsigned offse
t) | |
48 : root(root) | |
49 , object(object) | |
50 , offset(offset) | |
51 { | |
52 } | |
53 }; | |
54 | |
55 struct LineSegmentRange { | |
56 LineSegmentIterator start; | |
57 LineSegmentIterator end; | |
58 LineSegmentRange(const InlineIterator& start, const InlineIterator& end); | |
59 }; | |
60 | |
61 typedef Vector<LineSegmentRange> SegmentRangeList; | |
62 | |
63 class ShapeInsideInfo FINAL : public ShapeInfo<RenderBlock> { | |
64 public: | |
65 static PassOwnPtr<ShapeInsideInfo> createInfo(const RenderBlock& renderer) {
return adoptPtr(new ShapeInsideInfo(renderer)); } | |
66 static bool isEnabledFor(const RenderBlock& renderer); | |
67 | |
68 bool updateSegmentsForLine(LayoutSize lineOffset, LayoutUnit lineHeight); | |
69 bool updateSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight); | |
70 | |
71 bool hasSegments() const | |
72 { | |
73 return lineOverlapsShapeBounds() && m_segments.size(); | |
74 } | |
75 const SegmentList& segments() const | |
76 { | |
77 ASSERT(hasSegments()); | |
78 return m_segments; | |
79 } | |
80 SegmentRangeList& segmentRanges() { return m_segmentRanges; } | |
81 const SegmentRangeList& segmentRanges() const { return m_segmentRanges; } | |
82 const LineSegment* currentSegment() const | |
83 { | |
84 if (!hasSegments()) | |
85 return 0; | |
86 ASSERT(m_segmentRanges.size() < m_segments.size()); | |
87 return &m_segments[m_segmentRanges.size()]; | |
88 } | |
89 void clearSegments() { m_segments.clear(); } | |
90 bool adjustLogicalLineTop(float minSegmentWidth); | |
91 LayoutUnit computeFirstFitPositionForFloat(const FloatSize&) const; | |
92 | |
93 void setNeedsLayout(bool value) { m_needsLayout = value; } | |
94 bool needsLayout() { return m_needsLayout; } | |
95 | |
96 virtual bool lineOverlapsShapeBounds() const OVERRIDE | |
97 { | |
98 return computedShape().lineOverlapsShapePaddingBounds(m_referenceBoxLine
Top, m_lineHeight); | |
99 } | |
100 | |
101 protected: | |
102 virtual LayoutBox referenceBox() const OVERRIDE | |
103 { | |
104 if (shapeValue()->layoutBox() == BoxMissing) | |
105 return ContentBox; | |
106 return shapeValue()->layoutBox(); | |
107 } | |
108 virtual LayoutRect computedShapeLogicalBoundingBox() const OVERRIDE { return
computedShape().shapePaddingLogicalBoundingBox(); } | |
109 virtual ShapeValue* shapeValue() const OVERRIDE; | |
110 virtual void getIntervals(LayoutUnit lineTop, LayoutUnit lineHeight, Segment
List& segments) const OVERRIDE | |
111 { | |
112 return computedShape().getIncludedIntervals(lineTop, lineHeight, segment
s); | |
113 } | |
114 | |
115 virtual const RenderStyle* styleForWritingMode() const OVERRIDE; | |
116 | |
117 private: | |
118 ShapeInsideInfo(const RenderBlock& renderer) | |
119 : ShapeInfo<RenderBlock> (renderer) | |
120 , m_needsLayout(false) | |
121 { } | |
122 | |
123 SegmentRangeList m_segmentRanges; | |
124 bool m_needsLayout; | |
125 SegmentList m_segments; | |
126 }; | |
127 | |
128 } | |
129 #endif | |
OLD | NEW |