tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit c264672892dc13242a131017ea95d736f6fed69e
parent f0f9dd8b09757cd9c5c51573d05adfb389e169dc
Author: Hiroyuki Ikezoe <hikezoe.birchill@mozilla.com>
Date:   Sat,  4 Oct 2025 02:06:06 +0000

Bug 1992305 - Use std::numeric_limits::lowest() rather than std::numeric_limits::min(). r=gfx-reviewers,nical

For floating point min() returns minimum **positive** value.

Differential Revision: https://phabricator.services.mozilla.com/D267343

Diffstat:
Mgfx/2d/BaseRect.h | 4++--
Mgfx/tests/gtest/TestRect.cpp | 24++++++++++++++++++++++++
2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/gfx/2d/BaseRect.h b/gfx/2d/BaseRect.h @@ -329,7 +329,7 @@ struct BaseRect { x = limit - aDx < x ? limit : x + aDx; width = (limit - aDx < x2 ? limit : x2 + aDx) - x; } else { - T limit = std::numeric_limits<T>::min(); + T limit = std::numeric_limits<T>::lowest(); x = limit - aDx > x ? limit : x + aDx; width = (limit - aDx > x2 ? limit : x2 + aDx) - x; } @@ -341,7 +341,7 @@ struct BaseRect { y = limit - aDy < y ? limit : y + aDy; height = (limit - aDy < y2 ? limit : y2 + aDy) - y; } else { - T limit = std::numeric_limits<T>::min(); + T limit = std::numeric_limits<T>::lowest(); y = limit - aDy > y ? limit : y + aDy; height = (limit - aDy > y2 ? limit : y2 + aDy) - y; } diff --git a/gfx/tests/gtest/TestRect.cpp b/gfx/tests/gtest/TestRect.cpp @@ -26,6 +26,7 @@ using mozilla::ScreenIntCoord; using mozilla::gfx::IntPoint; using mozilla::gfx::IntRect; using mozilla::gfx::IntRectAbsolute; +using mozilla::gfx::Rect; static_assert(std::is_constructible_v<CSSIntSize, CSSIntCoord, CSSIntCoord>); static_assert( @@ -711,3 +712,26 @@ TEST(Gfx, ClampPoint) EXPECT_EQ(Empty.ClampPoint(IntPoint(1, -1)), IntPoint(0, 0)); EXPECT_EQ(Empty.ClampPoint(IntPoint(1, 1)), IntPoint(0, 0)); } + +TEST(Gfx, SafeMoveBy) +{ + IntRect intRect(0, 0, 10, 10); + intRect.SafeMoveByX(10); + intRect.SafeMoveByY(10); + EXPECT_EQ(intRect, IntRect(10, 10, 10, 10)); + + intRect = IntRect(0, 0, 10, 10); + intRect.SafeMoveByX(-10); + intRect.SafeMoveByY(-10); + EXPECT_EQ(intRect, IntRect(-10, -10, 10, 10)); + + Rect rect(0, 0, 10, 10); + rect.SafeMoveByX(10); + rect.SafeMoveByY(10); + EXPECT_EQ(rect, Rect(10, 10, 10, 10)); + + rect = Rect(0, 0, 10, 10); + rect.SafeMoveByX(-10); + rect.SafeMoveByY(-10); + EXPECT_EQ(rect, Rect(-10, -10, 10, 10)); +}