Bug 1776680 [wpt PR 34603] - [@container] Test invalidation of font-relative units...
[gecko.git] / gfx / src / nsRect.cpp
blob8f88c9190e2290222b18dc9c6acbfbba2ac6e3dd
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "nsRect.h"
8 #include "mozilla/gfx/Types.h" // for eSideBottom, etc
9 #include "mozilla/CheckedInt.h" // for CheckedInt
10 #include "nsDeviceContext.h" // for nsDeviceContext
11 #include "nsString.h" // for nsAutoString, etc
12 #include "nsMargin.h" // for nsMargin
14 static_assert(
15 (int(mozilla::eSideTop) == 0) && (int(mozilla::eSideRight) == 1) &&
16 (int(mozilla::eSideBottom) == 2) && (int(mozilla::eSideLeft) == 3),
17 "The mozilla::Side sequence must match the nsMargin nscoord sequence");
19 const mozilla::gfx::IntRect& GetMaxSizedIntRect() {
20 static const mozilla::gfx::IntRect r(0, 0, INT32_MAX, INT32_MAX);
21 return r;
24 bool nsRect::Overflows() const {
25 mozilla::CheckedInt<int32_t> xMost = this->x;
26 xMost += this->width;
27 mozilla::CheckedInt<int32_t> yMost = this->y;
28 yMost += this->height;
29 return !xMost.isValid() || !yMost.isValid();