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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 typedef Vector<LineSegment> SegmentList; | 54 typedef Vector<LineSegment> SegmentList; |
55 | 55 |
56 | 56 |
57 // A representation of a BasicShape that enables layout code to determine how to
break a line up into segments | 57 // A representation of a BasicShape that enables layout code to determine how to
break a line up into segments |
58 // that will fit within or around a shape. The line is defined by a pair of logi
cal Y coordinates and the | 58 // that will fit within or around a shape. The line is defined by a pair of logi
cal Y coordinates and the |
59 // computed segments are returned as pairs of logical X coordinates. The BasicSh
ape itself is defined in | 59 // computed segments are returned as pairs of logical X coordinates. The BasicSh
ape itself is defined in |
60 // physical coordinates. | 60 // physical coordinates. |
61 | 61 |
62 class Shape { | 62 class Shape { |
63 public: | 63 public: |
64 static PassOwnPtr<Shape> createShape(const BasicShape*, const LayoutSize& lo
gicalBoxSize, WritingMode, Length margin, Length padding); | 64 static PassOwnPtr<Shape> createShape(const BasicShape*, const LayoutSize& lo
gicalBoxSize, WritingMode, Length margin); |
65 static PassOwnPtr<Shape> createRasterShape(Image*, float threshold, const La
youtRect& imageRect, const LayoutRect& marginRect, WritingMode, Length margin, L
ength padding); | 65 static PassOwnPtr<Shape> createRasterShape(Image*, float threshold, const La
youtRect& imageRect, const LayoutRect& marginRect, WritingMode, Length margin); |
66 static PassOwnPtr<Shape> createBoxShape(const RoundedRect&, WritingMode, con
st Length& margin, const Length& padding); | 66 static PassOwnPtr<Shape> createLayoutBoxShape(const RoundedRect&, WritingMod
e, const Length& margin); |
67 | 67 |
68 virtual ~Shape() { } | 68 virtual ~Shape() { } |
69 | 69 |
70 virtual LayoutRect shapeMarginLogicalBoundingBox() const = 0; | 70 virtual LayoutRect shapeMarginLogicalBoundingBox() const = 0; |
71 virtual LayoutRect shapePaddingLogicalBoundingBox() const = 0; | |
72 virtual bool isEmpty() const = 0; | 71 virtual bool isEmpty() const = 0; |
73 virtual void getIncludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalH
eight, SegmentList&) const = 0; | |
74 virtual void getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalH
eight, SegmentList&) const = 0; | 72 virtual void getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalH
eight, SegmentList&) const = 0; |
75 virtual bool firstIncludedIntervalLogicalTop(LayoutUnit minLogicalIntervalTo
p, const FloatSize& minLogicalIntervalSize, LayoutUnit& result) const = 0; | 73 |
76 bool lineOverlapsShapeMarginBounds(LayoutUnit lineTop, LayoutUnit lineHeight
) const { return lineOverlapsBoundingBox(lineTop, lineHeight, shapeMarginLogical
BoundingBox()); } | 74 bool lineOverlapsShapeMarginBounds(LayoutUnit lineTop, LayoutUnit lineHeight
) const { return lineOverlapsBoundingBox(lineTop, lineHeight, shapeMarginLogical
BoundingBox()); } |
77 bool lineOverlapsShapePaddingBounds(LayoutUnit lineTop, LayoutUnit lineHeigh
t) const { return lineOverlapsBoundingBox(lineTop, lineHeight, shapePaddingLogic
alBoundingBox()); } | |
78 | 75 |
79 protected: | 76 protected: |
80 float shapeMargin() const { return m_margin; } | 77 float shapeMargin() const { return m_margin; } |
81 float shapePadding() const { return m_padding; } | |
82 | 78 |
83 private: | 79 private: |
84 bool lineOverlapsBoundingBox(LayoutUnit lineTop, LayoutUnit lineHeight, cons
t LayoutRect& rect) const | 80 bool lineOverlapsBoundingBox(LayoutUnit lineTop, LayoutUnit lineHeight, cons
t LayoutRect& rect) const |
85 { | 81 { |
86 if (rect.isEmpty()) | 82 if (rect.isEmpty()) |
87 return false; | 83 return false; |
88 return (lineTop < rect.maxY() && lineTop + lineHeight > rect.y()) || (!l
ineHeight && lineTop == rect.y()); | 84 return (lineTop < rect.maxY() && lineTop + lineHeight > rect.y()) || (!l
ineHeight && lineTop == rect.y()); |
89 } | 85 } |
90 | 86 |
91 WritingMode m_writingMode; | 87 WritingMode m_writingMode; |
92 float m_margin; | 88 float m_margin; |
93 float m_padding; | |
94 }; | 89 }; |
95 | 90 |
96 } // namespace WebCore | 91 } // namespace WebCore |
97 | 92 |
98 #endif // Shape_h | 93 #endif // Shape_h |
OLD | NEW |