OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 2 * Copyright (C) 2013 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 24 matching lines...) Expand all Loading... |
35 namespace WebCore { | 35 namespace WebCore { |
36 | 36 |
37 LayoutRect BoxShape::shapeMarginLogicalBoundingBox() const | 37 LayoutRect BoxShape::shapeMarginLogicalBoundingBox() const |
38 { | 38 { |
39 FloatRect marginBounds(m_bounds.rect()); | 39 FloatRect marginBounds(m_bounds.rect()); |
40 if (shapeMargin() > 0) | 40 if (shapeMargin() > 0) |
41 marginBounds.inflate(shapeMargin()); | 41 marginBounds.inflate(shapeMargin()); |
42 return static_cast<LayoutRect>(marginBounds); | 42 return static_cast<LayoutRect>(marginBounds); |
43 } | 43 } |
44 | 44 |
45 LayoutRect BoxShape::shapePaddingLogicalBoundingBox() const | |
46 { | |
47 FloatRect paddingBounds(m_bounds.rect()); | |
48 if (shapePadding() > 0) | |
49 paddingBounds.inflate(-shapePadding()); | |
50 return static_cast<LayoutRect>(paddingBounds); | |
51 } | |
52 | |
53 FloatRoundedRect BoxShape::shapeMarginBounds() const | 45 FloatRoundedRect BoxShape::shapeMarginBounds() const |
54 { | 46 { |
55 FloatRoundedRect marginBounds(m_bounds); | 47 FloatRoundedRect marginBounds(m_bounds); |
56 if (shapeMargin() > 0) { | 48 if (shapeMargin() > 0) { |
57 marginBounds.inflate(shapeMargin()); | 49 marginBounds.inflate(shapeMargin()); |
58 marginBounds.expandRadii(shapeMargin()); | 50 marginBounds.expandRadii(shapeMargin()); |
59 } | 51 } |
60 return marginBounds; | 52 return marginBounds; |
61 } | 53 } |
62 | 54 |
63 FloatRoundedRect BoxShape::shapePaddingBounds() const | |
64 { | |
65 FloatRoundedRect paddingBounds(m_bounds); | |
66 if (shapePadding() > 0) { | |
67 paddingBounds.inflate(-shapePadding()); | |
68 paddingBounds.expandRadii(-shapePadding()); | |
69 } | |
70 return paddingBounds; | |
71 } | |
72 | |
73 void BoxShape::getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHei
ght, SegmentList& result) const | 55 void BoxShape::getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHei
ght, SegmentList& result) const |
74 { | 56 { |
75 const FloatRoundedRect& marginBounds = shapeMarginBounds(); | 57 const FloatRoundedRect& marginBounds = shapeMarginBounds(); |
76 if (marginBounds.isEmpty() || !lineOverlapsShapeMarginBounds(logicalTop, log
icalHeight)) | 58 if (marginBounds.isEmpty() || !lineOverlapsShapeMarginBounds(logicalTop, log
icalHeight)) |
77 return; | 59 return; |
78 | 60 |
79 float y1 = logicalTop.toFloat(); | 61 float y1 = logicalTop.toFloat(); |
80 float y2 = (logicalTop + logicalHeight).toFloat(); | 62 float y2 = (logicalTop + logicalHeight).toFloat(); |
81 const FloatRect& rect = marginBounds.rect(); | 63 const FloatRect& rect = marginBounds.rect(); |
82 | 64 |
(...skipping 22 matching lines...) Expand all Loading... |
105 | 87 |
106 if (marginBounds.xInterceptsAtY(y2, minXIntercept, maxXIntercept)) { | 88 if (marginBounds.xInterceptsAtY(y2, minXIntercept, maxXIntercept)) { |
107 x1 = std::min<float>(x1, minXIntercept); | 89 x1 = std::min<float>(x1, minXIntercept); |
108 x2 = std::max<float>(x2, maxXIntercept); | 90 x2 = std::max<float>(x2, maxXIntercept); |
109 } | 91 } |
110 | 92 |
111 ASSERT(x2 >= x1); | 93 ASSERT(x2 >= x1); |
112 result.append(LineSegment(x1, x2)); | 94 result.append(LineSegment(x1, x2)); |
113 } | 95 } |
114 | 96 |
115 void BoxShape::getIncludedIntervals(LayoutUnit logicalTop, LayoutUnit logicalHei
ght, SegmentList& result) const | |
116 { | |
117 const FloatRoundedRect& paddingBounds = shapePaddingBounds(); | |
118 if (paddingBounds.isEmpty()) | |
119 return; | |
120 | |
121 float y1 = logicalTop.toFloat(); | |
122 float y2 = (logicalTop + logicalHeight).toFloat(); | |
123 const FloatRect& rect = paddingBounds.rect(); | |
124 | |
125 if (y1 < rect.y() || y2 > rect.maxY()) | |
126 return; | |
127 | |
128 if (!paddingBounds.isRounded()) { | |
129 result.append(LineSegment(rect.x(), rect.maxX())); | |
130 return; | |
131 } | |
132 | |
133 float x1 = rect.x(); | |
134 float x2 = rect.maxX(); | |
135 float minXIntercept; | |
136 float maxXIntercept; | |
137 | |
138 if (paddingBounds.xInterceptsAtY(y1, minXIntercept, maxXIntercept)) { | |
139 x1 = std::max<float>(x1, minXIntercept); | |
140 x2 = std::min<float>(x2, maxXIntercept); | |
141 } | |
142 | |
143 if (paddingBounds.xInterceptsAtY(y2, minXIntercept, maxXIntercept)) { | |
144 x1 = std::max<float>(x1, minXIntercept); | |
145 x2 = std::min<float>(x2, maxXIntercept); | |
146 } | |
147 | |
148 result.append(LineSegment(x1, x2)); | |
149 } | |
150 | |
151 bool BoxShape::firstIncludedIntervalLogicalTop(LayoutUnit minLogicalIntervalTop,
const FloatSize&, LayoutUnit& result) const | |
152 { | |
153 // FIXME: this method is only a stub, https://bugs.webkit.org/show_bug.cgi?i
d=124606. | |
154 | |
155 result = minLogicalIntervalTop; | |
156 return true; | |
157 } | |
158 | |
159 } // namespace WebCore | 97 } // namespace WebCore |
OLD | NEW |