Bug 1866777 - Disable test_race_cache_with_network.js on windows opt for frequent...
[gecko.git] / gfx / src / nsRectAbsolute.h
blob6d9f718893e85c6c267dc9bd2f72cfdc77d5eb24
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 #ifndef NSRECTABSOLUTE_H
8 #define NSRECTABSOLUTE_H
10 #include "mozilla/gfx/RectAbsolute.h"
11 #include "nsCoord.h"
12 #include "nsMargin.h"
13 #include "nsRect.h"
15 struct nsRectAbsolute
16 : public mozilla::gfx::BaseRectAbsolute<nscoord, nsRectAbsolute, nsPoint,
17 nsRect> {
18 typedef mozilla::gfx::BaseRectAbsolute<nscoord, nsRectAbsolute, nsPoint,
19 nsRect>
20 Super;
22 nsRectAbsolute() {}
23 nsRectAbsolute(nscoord aX1, nscoord aY1, nscoord aX2, nscoord aY2)
24 : Super(aX1, aY1, aX2, aY2) {}
26 MOZ_ALWAYS_INLINE nscoord SafeWidth() const {
27 int64_t width = right;
28 width -= left;
29 return nscoord(
30 std::min<int64_t>(std::numeric_limits<nscoord>::max(), width));
32 MOZ_ALWAYS_INLINE nscoord SafeHeight() const {
33 int64_t height = bottom;
34 height -= top;
35 return nscoord(
36 std::min<int64_t>(std::numeric_limits<nscoord>::max(), height));
39 nsRect ToNSRect() const {
40 return nsRect(left, top, nscoord(SafeWidth()), nscoord(SafeHeight()));
43 [[nodiscard]] nsRectAbsolute UnsafeUnion(const nsRectAbsolute& aRect) const {
44 return Super::Union(aRect);
47 void Inflate(const nsMargin& aMargin) {
48 left -= aMargin.left;
49 top -= aMargin.top;
50 right += aMargin.right;
51 bottom += aMargin.bottom;
55 #endif /* NSRECTABSOLUTE_H */