| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 139 |
| 140 appendX1Values(intervalsAt(y1), minIntervalWidth, result); | 140 appendX1Values(intervalsAt(y1), minIntervalWidth, result); |
| 141 for (int y = y1 + 1; y < y2; y++) { | 141 for (int y = y1 + 1; y < y2; y++) { |
| 142 if (intervalsAt(y) != intervalsAt(y - 1)) | 142 if (intervalsAt(y) != intervalsAt(y - 1)) |
| 143 appendX1Values(intervalsAt(y), minIntervalWidth, result); | 143 appendX1Values(intervalsAt(y), minIntervalWidth, result); |
| 144 } | 144 } |
| 145 | 145 |
| 146 return true; | 146 return true; |
| 147 } | 147 } |
| 148 | 148 |
| 149 bool RasterShapeIntervals::firstIncludedIntervalY(int minY, const IntSize& minSi
ze, LayoutUnit& result) const | |
| 150 { | |
| 151 minY = std::max<int>(bounds().y(), minY); | |
| 152 | |
| 153 ASSERT(minY >= 0 && minY < size()); | |
| 154 | |
| 155 if (minSize.isEmpty() || minSize.width() > bounds().width()) | |
| 156 return false; | |
| 157 | |
| 158 for (int lineY = minY; lineY <= bounds().maxY() - minSize.height(); lineY++)
{ | |
| 159 Vector<int> intervalX1Values; | |
| 160 if (!getIntervalX1Values(lineY, lineY + minSize.height(), minSize.width(
), intervalX1Values)) | |
| 161 continue; | |
| 162 | |
| 163 std::sort(intervalX1Values.begin(), intervalX1Values.end()); | |
| 164 | |
| 165 IntRect firstFitRect(IntPoint(0, 0), minSize); | |
| 166 for (unsigned i = 0; i < intervalX1Values.size(); i++) { | |
| 167 int lineX = intervalX1Values[i]; | |
| 168 if (i > 0 && lineX == intervalX1Values[i - 1]) | |
| 169 continue; | |
| 170 firstFitRect.setLocation(IntPoint(lineX, lineY)); | |
| 171 if (contains(firstFitRect)) { | |
| 172 result = lineY; | |
| 173 return true; | |
| 174 } | |
| 175 } | |
| 176 } | |
| 177 | |
| 178 return false; | |
| 179 } | |
| 180 | |
| 181 void RasterShapeIntervals::getIncludedIntervals(int y1, int y2, IntShapeInterval
s& result) const | |
| 182 { | |
| 183 ASSERT(y2 >= y1); | |
| 184 | |
| 185 if (y1 < bounds().y() || y2 > bounds().maxY()) | |
| 186 return; | |
| 187 | |
| 188 for (int y = y1; y < y2; y++) { | |
| 189 if (intervalsAt(y).isEmpty()) | |
| 190 return; | |
| 191 } | |
| 192 | |
| 193 result = intervalsAt(y1); | |
| 194 for (int y = y1 + 1; y < y2 && !result.isEmpty(); y++) { | |
| 195 IntShapeIntervals intervals; | |
| 196 IntShapeInterval::intersectShapeIntervals(result, intervalsAt(y), interv
als); | |
| 197 result.swap(intervals); | |
| 198 } | |
| 199 } | |
| 200 | |
| 201 void RasterShapeIntervals::getExcludedIntervals(int y1, int y2, IntShapeInterval
s& result) const | 149 void RasterShapeIntervals::getExcludedIntervals(int y1, int y2, IntShapeInterval
s& result) const |
| 202 { | 150 { |
| 203 ASSERT(y2 >= y1); | 151 ASSERT(y2 >= y1); |
| 204 | 152 |
| 205 if (y2 < bounds().y() || y1 >= bounds().maxY()) | 153 if (y2 < bounds().y() || y1 >= bounds().maxY()) |
| 206 return; | 154 return; |
| 207 | 155 |
| 208 y1 = std::max(y1, bounds().y()); | 156 y1 = std::max(y1, bounds().y()); |
| 209 y2 = std::min(y2, bounds().maxY()); | 157 y2 = std::min(y2, bounds().maxY()); |
| 210 | 158 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 return *m_intervals; | 204 return *m_intervals; |
| 257 | 205 |
| 258 int shapeMarginInt = clampToPositiveInteger(ceil(shapeMargin())); | 206 int shapeMarginInt = clampToPositiveInteger(ceil(shapeMargin())); |
| 259 int maxShapeMarginInt = std::max(m_marginRectSize.width(), m_marginRectSize.
height()) * sqrtf(2); | 207 int maxShapeMarginInt = std::max(m_marginRectSize.width(), m_marginRectSize.
height()) * sqrtf(2); |
| 260 if (!m_marginIntervals) | 208 if (!m_marginIntervals) |
| 261 m_marginIntervals = m_intervals->computeShapeMarginIntervals(std::min(sh
apeMarginInt, maxShapeMarginInt)); | 209 m_marginIntervals = m_intervals->computeShapeMarginIntervals(std::min(sh
apeMarginInt, maxShapeMarginInt)); |
| 262 | 210 |
| 263 return *m_marginIntervals; | 211 return *m_marginIntervals; |
| 264 } | 212 } |
| 265 | 213 |
| 266 const RasterShapeIntervals& RasterShape::paddingIntervals() const | |
| 267 { | |
| 268 ASSERT(shapePadding() >= 0); | |
| 269 if (!shapePadding()) | |
| 270 return *m_intervals; | |
| 271 | |
| 272 // FIXME: Add support for non-zero padding, see https://bugs.webkit.org/show
_bug.cgi?id=116348. | |
| 273 return *m_intervals; | |
| 274 } | |
| 275 | |
| 276 static inline void appendLineSegments(const IntShapeIntervals& intervals, Segmen
tList& result) | 214 static inline void appendLineSegments(const IntShapeIntervals& intervals, Segmen
tList& result) |
| 277 { | 215 { |
| 278 for (unsigned i = 0; i < intervals.size(); i++) | 216 for (unsigned i = 0; i < intervals.size(); i++) |
| 279 result.append(LineSegment(intervals[i].x1(), intervals[i].x2() + 1)); | 217 result.append(LineSegment(intervals[i].x1(), intervals[i].x2() + 1)); |
| 280 } | 218 } |
| 281 | 219 |
| 282 void RasterShape::getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logical
Height, SegmentList& result) const | 220 void RasterShape::getExcludedIntervals(LayoutUnit logicalTop, LayoutUnit logical
Height, SegmentList& result) const |
| 283 { | 221 { |
| 284 const RasterShapeIntervals& intervals = marginIntervals(); | 222 const RasterShapeIntervals& intervals = marginIntervals(); |
| 285 if (intervals.isEmpty()) | 223 if (intervals.isEmpty()) |
| 286 return; | 224 return; |
| 287 | 225 |
| 288 IntShapeIntervals excludedIntervals; | 226 IntShapeIntervals excludedIntervals; |
| 289 intervals.getExcludedIntervals(logicalTop, logicalTop + logicalHeight, exclu
dedIntervals); | 227 intervals.getExcludedIntervals(logicalTop, logicalTop + logicalHeight, exclu
dedIntervals); |
| 290 appendLineSegments(excludedIntervals, result); | 228 appendLineSegments(excludedIntervals, result); |
| 291 } | 229 } |
| 292 | 230 |
| 293 void RasterShape::getIncludedIntervals(LayoutUnit logicalTop, LayoutUnit logical
Height, SegmentList& result) const | |
| 294 { | |
| 295 const RasterShapeIntervals& intervals = paddingIntervals(); | |
| 296 if (intervals.isEmpty()) | |
| 297 return; | |
| 298 | |
| 299 IntShapeIntervals includedIntervals; | |
| 300 intervals.getIncludedIntervals(logicalTop, logicalTop + logicalHeight, inclu
dedIntervals); | |
| 301 appendLineSegments(includedIntervals, result); | |
| 302 } | |
| 303 | |
| 304 bool RasterShape::firstIncludedIntervalLogicalTop(LayoutUnit minLogicalIntervalT
op, const FloatSize& minLogicalIntervalSize, LayoutUnit& result) const | |
| 305 { | |
| 306 const RasterShapeIntervals& intervals = paddingIntervals(); | |
| 307 if (intervals.isEmpty()) | |
| 308 return false; | |
| 309 | |
| 310 return intervals.firstIncludedIntervalY(minLogicalIntervalTop.floor(), floor
edIntSize(minLogicalIntervalSize), result); | |
| 311 } | |
| 312 | |
| 313 } // namespace WebCore | 231 } // namespace WebCore |
| OLD | NEW |