Skip to content

Commit

Permalink
unionRect(const Vector<LayoutRect>&) behaves incorrectly with empty r…
Browse files Browse the repository at this point in the history
…ects

https://bugs.webkit.org/show_bug.cgi?id=259674
rdar://113183595

Reviewed by Alan Baradlay.

unionRect(const Vector<LayoutRect>&) behaves incorrectly if the input vector contains
a single zero-size rect with a non-zero location; it will union with the empty rect,
and therefore return the empty rect.

This is not known to change any behavior, but a future change in bug 259672
will exercise this code.

* Source/WebCore/platform/graphics/LayoutRect.cpp:
(WebCore::unionRect):

Canonical link: https://commits.webkit.org/266479@main
  • Loading branch information
smfr committed Aug 1, 2023
1 parent 76ed648 commit 0ab8911
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Source/WebCore/platform/graphics/LayoutRect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,12 @@ void LayoutRect::expandToInfiniteX()

LayoutRect unionRect(const Vector<LayoutRect>& rects)
{
LayoutRect result;
if (rects.isEmpty())
return { };

LayoutRect result = rects[0];
size_t count = rects.size();
for (size_t i = 0; i < count; ++i)
for (size_t i = 1; i < count; ++i)
result.unite(rects[i]);

return result;
Expand Down

0 comments on commit 0ab8911

Please sign in to comment.