summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/permissions-policy/experimental-features/resources/vertical-scroll.js
blob: 88835cc6024f2a17c405a1760064e9145fb63d62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
function rectMaxY(rect) {
  return rect.height + rect.y;
}

function rectMaxX(rect) {
  return rect.width + rect.x;
}

function isEmptyRect(rect) {
  return !rect.width || !rect.height;
}

// Returns true if the given rectangles intersect.
function rects_intersect(rect1, rect2) {
  if (isEmptyRect(rect1) || isEmptyRect(rect2))
    return false;
  return rect1.x < rectMaxX(rect2) &&
         rect2.x < rectMaxX(rect1) &&
         rect1.y < rectMaxY(rect2) &&
         rect2.y < rectMaxY(rect1);
}

function rectToString(rect) {
  return `Location: (${rect.x}, ${rect.y}) Size: (${rect.width}, ${rect.height})`;
}