Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/nsRectAbsolute.h
Line
Count
Source (jump to first uncovered line)
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/. */
6
7
#ifndef NSRECTABSOLUTE_H
8
#define NSRECTABSOLUTE_H
9
10
#include "mozilla/gfx/RectAbsolute.h"
11
#include "nsCoord.h"
12
#include "nsRect.h"
13
14
struct nsRectAbsolute :
15
  public mozilla::gfx::BaseRectAbsolute<nscoord, nsRectAbsolute, nsRect> {
16
  typedef mozilla::gfx::BaseRectAbsolute<nscoord, nsRectAbsolute, nsRect> Super;
17
18
0
  nsRectAbsolute() : Super() {}
19
  nsRectAbsolute(nscoord aX1, nscoord aY1, nscoord aX2, nscoord aY2) :
20
0
      Super(aX1, aY1, aX2, aY2) {}
21
22
  MOZ_ALWAYS_INLINE nscoord SafeWidth() const
23
0
  {
24
0
    int64_t width = right;
25
0
    width -= left;
26
0
    return nscoord(std::min<int64_t>(std::numeric_limits<nscoord>::max(), width));
27
0
  }
28
  MOZ_ALWAYS_INLINE nscoord SafeHeight() const
29
0
  {
30
0
    int64_t height = bottom;
31
0
    height -= top;
32
0
    return nscoord(std::min<int64_t>(std::numeric_limits<nscoord>::max(), height));
33
0
  }
34
35
  nsRect ToNSRect() const
36
0
  {
37
0
    return nsRect(left, top, nscoord(SafeWidth()), nscoord(SafeHeight()));
38
0
  }
39
40
  MOZ_MUST_USE nsRectAbsolute UnsafeUnion(const nsRectAbsolute& aRect) const
41
0
  {
42
0
    return Super::Union(aRect);
43
0
  }
44
45
0
  MOZ_ALWAYS_INLINE void MoveBy(const nsPoint& aPoint) { left += aPoint.x; right += aPoint.x; top += aPoint.y; bottom += aPoint.y; }
46
47
  void Inflate(const nsMargin& aMargin)
48
0
  {
49
0
    left -= aMargin.left;
50
0
    top -= aMargin.top;
51
0
    right += aMargin.right;
52
0
    bottom += aMargin.bottom;
53
0
  }
54
};
55
56
#endif /* NSRECTABSOLUTE_H */