| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 | 94 |
| 95 FloatRoundedRect ExclusionRectangle::shapeMarginBounds() const | 95 FloatRoundedRect ExclusionRectangle::shapeMarginBounds() const |
| 96 { | 96 { |
| 97 if (!m_haveInitializedMarginBounds) { | 97 if (!m_haveInitializedMarginBounds) { |
| 98 m_haveInitializedMarginBounds = true; | 98 m_haveInitializedMarginBounds = true; |
| 99 m_marginBounds = m_bounds.marginBounds(shapeMargin()); | 99 m_marginBounds = m_bounds.marginBounds(shapeMargin()); |
| 100 } | 100 } |
| 101 return m_marginBounds; | 101 return m_marginBounds; |
| 102 } | 102 } |
| 103 | 103 |
| 104 void ExclusionRectangle::getExcludedIntervals(float logicalTop, float logicalHei
ght, SegmentList& result) const | 104 void ExclusionRectangle::getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit
logicalHeight, SegmentList& result) const |
| 105 { | 105 { |
| 106 const FloatRoundedRect& bounds = shapeMarginBounds(); | 106 const FloatRoundedRect& bounds = shapeMarginBounds(); |
| 107 if (bounds.isEmpty()) | 107 if (bounds.isEmpty()) |
| 108 return; | 108 return; |
| 109 | 109 |
| 110 float y1 = logicalTop; | 110 float y1 = logicalTop; |
| 111 float y2 = y1 + logicalHeight; | 111 float y2 = logicalTop + logicalHeight; |
| 112 | 112 |
| 113 if (y2 < bounds.y() || y1 >= bounds.maxY()) | 113 if (y2 < bounds.y() || y1 >= bounds.maxY()) |
| 114 return; | 114 return; |
| 115 | 115 |
| 116 float x1 = bounds.x(); | 116 float x1 = bounds.x(); |
| 117 float x2 = bounds.maxX(); | 117 float x2 = bounds.maxX(); |
| 118 | 118 |
| 119 if (bounds.ry() > 0) { | 119 if (bounds.ry() > 0) { |
| 120 if (y2 < bounds.y() + bounds.ry()) { | 120 if (y2 < bounds.y() + bounds.ry()) { |
| 121 float yi = y2 - bounds.y() - bounds.ry(); | 121 float yi = y2 - bounds.y() - bounds.ry(); |
| 122 float xi = ellipseXIntercept(yi, bounds.rx(), bounds.ry()); | 122 float xi = ellipseXIntercept(yi, bounds.rx(), bounds.ry()); |
| 123 x1 = bounds.x() + bounds.rx() - xi; | 123 x1 = bounds.x() + bounds.rx() - xi; |
| 124 x2 = bounds.maxX() - bounds.rx() + xi; | 124 x2 = bounds.maxX() - bounds.rx() + xi; |
| 125 } else if (y1 > bounds.maxY() - bounds.ry()) { | 125 } else if (y1 > bounds.maxY() - bounds.ry()) { |
| 126 float yi = y1 - (bounds.maxY() - bounds.ry()); | 126 float yi = y1 - (bounds.maxY() - bounds.ry()); |
| 127 float xi = ellipseXIntercept(yi, bounds.rx(), bounds.ry()); | 127 float xi = ellipseXIntercept(yi, bounds.rx(), bounds.ry()); |
| 128 x1 = bounds.x() + bounds.rx() - xi; | 128 x1 = bounds.x() + bounds.rx() - xi; |
| 129 x2 = bounds.maxX() - bounds.rx() + xi; | 129 x2 = bounds.maxX() - bounds.rx() + xi; |
| 130 } | 130 } |
| 131 } | 131 } |
| 132 | 132 |
| 133 result.append(LineSegment(x1, x2)); | 133 result.append(LineSegment(x1, x2)); |
| 134 } | 134 } |
| 135 | 135 |
| 136 void ExclusionRectangle::getIncludedIntervals(float logicalTop, float logicalHei
ght, SegmentList& result) const | 136 void ExclusionRectangle::getIncludedIntervals(LayoutUnit logicalTop, LayoutUnit
logicalHeight, SegmentList& result) const |
| 137 { | 137 { |
| 138 const FloatRoundedRect& bounds = shapePaddingBounds(); | 138 const FloatRoundedRect& bounds = shapePaddingBounds(); |
| 139 if (bounds.isEmpty()) | 139 if (bounds.isEmpty()) |
| 140 return; | 140 return; |
| 141 | 141 |
| 142 float y1 = logicalTop; | 142 float y1 = logicalTop; |
| 143 float y2 = y1 + logicalHeight; | 143 float y2 = logicalTop + logicalHeight; |
| 144 | 144 |
| 145 if (y1 < bounds.y() || y2 > bounds.maxY()) | 145 if (y1 < bounds.y() || y2 > bounds.maxY()) |
| 146 return; | 146 return; |
| 147 | 147 |
| 148 float x1 = bounds.x(); | 148 float x1 = bounds.x(); |
| 149 float x2 = bounds.maxX(); | 149 float x2 = bounds.maxX(); |
| 150 | 150 |
| 151 if (bounds.ry() > 0) { | 151 if (bounds.ry() > 0) { |
| 152 bool y1InterceptsCorner = y1 < bounds.y() + bounds.ry(); | 152 bool y1InterceptsCorner = y1 < bounds.y() + bounds.ry(); |
| 153 bool y2InterceptsCorner = y2 > bounds.maxY() - bounds.ry(); | 153 bool y2InterceptsCorner = y2 > bounds.maxY() - bounds.ry(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 171 | 171 |
| 172 if (y1InterceptsCorner || y2InterceptsCorner) { | 172 if (y1InterceptsCorner || y2InterceptsCorner) { |
| 173 x1 = bounds.x() + bounds.rx() - xi; | 173 x1 = bounds.x() + bounds.rx() - xi; |
| 174 x2 = bounds.maxX() - bounds.rx() + xi; | 174 x2 = bounds.maxX() - bounds.rx() + xi; |
| 175 } | 175 } |
| 176 } | 176 } |
| 177 | 177 |
| 178 result.append(LineSegment(x1, x2)); | 178 result.append(LineSegment(x1, x2)); |
| 179 } | 179 } |
| 180 | 180 |
| 181 bool ExclusionRectangle::firstIncludedIntervalLogicalTop(float minLogicalInterva
lTop, const FloatSize& minLogicalIntervalSize, float& result) const | 181 bool ExclusionRectangle::firstIncludedIntervalLogicalTop(LayoutUnit minLogicalIn
tervalTop, const LayoutSize& minLogicalIntervalSize, LayoutUnit& result) const |
| 182 { | 182 { |
| 183 float minIntervalTop = minLogicalIntervalTop; |
| 184 float minIntervalHeight = minLogicalIntervalSize.height(); |
| 185 float minIntervalWidth = minLogicalIntervalSize.width(); |
| 186 |
| 183 const FloatRoundedRect& bounds = shapePaddingBounds(); | 187 const FloatRoundedRect& bounds = shapePaddingBounds(); |
| 184 if (bounds.isEmpty() || minLogicalIntervalSize.width() > bounds.width()) | 188 if (bounds.isEmpty() || minIntervalWidth > bounds.width()) |
| 185 return false; | 189 return false; |
| 186 | 190 |
| 187 float minY = std::max(bounds.y(), minLogicalIntervalTop); | 191 float minY = std::max(bounds.y(), minIntervalTop); |
| 188 float maxY = minY + minLogicalIntervalSize.height(); | 192 float maxY = minY + minIntervalHeight; |
| 189 | 193 |
| 190 if (maxY > bounds.maxY()) | 194 if (maxY > bounds.maxY()) |
| 191 return false; | 195 return false; |
| 192 | 196 |
| 193 bool intervalOverlapsMinCorner = minY < bounds.y() + bounds.ry(); | 197 bool intervalOverlapsMinCorner = minY < bounds.y() + bounds.ry(); |
| 194 bool intervalOverlapsMaxCorner = maxY > bounds.maxY() - bounds.ry(); | 198 bool intervalOverlapsMaxCorner = maxY > bounds.maxY() - bounds.ry(); |
| 195 | 199 |
| 196 if (!intervalOverlapsMinCorner && !intervalOverlapsMaxCorner) { | 200 if (!intervalOverlapsMinCorner && !intervalOverlapsMaxCorner) { |
| 197 result = minY; | 201 result = minY; |
| 198 return true; | 202 return true; |
| 199 } | 203 } |
| 200 | 204 |
| 201 float centerY = bounds.y() + bounds.height() / 2; | 205 float centerY = bounds.y() + bounds.height() / 2; |
| 202 bool minCornerDefinesX = fabs(centerY - minY) > fabs(centerY - maxY); | 206 bool minCornerDefinesX = fabs(centerY - minY) > fabs(centerY - maxY); |
| 203 bool intervalFitsWithinCorners = minLogicalIntervalSize.width() + 2 * bounds
.rx() <= bounds.width(); | 207 bool intervalFitsWithinCorners = minIntervalWidth + 2 * bounds.rx() <= bound
s.width(); |
| 204 FloatPoint cornerIntercept = bounds.cornerInterceptForWidth(minLogicalInterv
alSize.width()); | 208 FloatPoint cornerIntercept = bounds.cornerInterceptForWidth(minIntervalWidth
); |
| 205 | 209 |
| 206 if (intervalOverlapsMinCorner && (!intervalOverlapsMaxCorner || minCornerDef
inesX)) { | 210 if (intervalOverlapsMinCorner && (!intervalOverlapsMaxCorner || minCornerDef
inesX)) { |
| 207 if (intervalFitsWithinCorners || bounds.y() + cornerIntercept.y() < minY
) { | 211 if (intervalFitsWithinCorners || bounds.y() + cornerIntercept.y() < minY
) { |
| 208 result = minY; | 212 result = minY; |
| 209 return true; | 213 return true; |
| 210 } | 214 } |
| 211 if (minLogicalIntervalSize.height() < bounds.height() - (2 * cornerInter
cept.y())) { | 215 if (minIntervalHeight < bounds.height() - (2 * cornerIntercept.y())) { |
| 212 result = bounds.y() + cornerIntercept.y(); | 216 result = LayoutUnit::fromFloatCeil(bounds.y() + cornerIntercept.y())
; |
| 213 return true; | 217 return true; |
| 214 } | 218 } |
| 215 } | 219 } |
| 216 | 220 |
| 217 if (intervalOverlapsMaxCorner && (!intervalOverlapsMinCorner || !minCornerDe
finesX)) { | 221 if (intervalOverlapsMaxCorner && (!intervalOverlapsMinCorner || !minCornerDe
finesX)) { |
| 218 if (intervalFitsWithinCorners || minY <= bounds.maxY() - cornerIntercep
t.y() - minLogicalIntervalSize.height()) { | 222 if (intervalFitsWithinCorners || minY <= bounds.maxY() - cornerIntercep
t.y() - minIntervalHeight) { |
| 219 result = minY; | 223 result = minY; |
| 220 return true; | 224 return true; |
| 221 } | 225 } |
| 222 } | 226 } |
| 223 | 227 |
| 224 return false; | 228 return false; |
| 225 } | 229 } |
| 226 | 230 |
| 227 } // namespace WebCore | 231 } // namespace WebCore |
| OLD | NEW |