mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-07 05:15:09 +00:00
Bug 1406102 - [intersection-observer] Calculate areas using int64_t. r=dholbert
--HG-- extra : rebase_source : 00202f13b33d74bb686a3eb8103543e5a68f88d8
This commit is contained in:
parent
7df8d7beeb
commit
1e70d2c43e
@ -436,13 +436,15 @@ DOMIntersectionObserver::Update(nsIDocument* aDocument, DOMHighResTimeStamp time
|
||||
}
|
||||
}
|
||||
|
||||
double targetArea = targetRect.Width() * targetRect.Height();
|
||||
double intersectionArea = !intersectionRect ?
|
||||
0 : intersectionRect->Width() * intersectionRect->Height();
|
||||
int64_t targetArea =
|
||||
(int64_t) targetRect.Width() * (int64_t) targetRect.Height();
|
||||
int64_t intersectionArea = !intersectionRect ? 0 :
|
||||
(int64_t) intersectionRect->Width() *
|
||||
(int64_t) intersectionRect->Height();
|
||||
|
||||
double intersectionRatio;
|
||||
if (targetArea > 0.0) {
|
||||
intersectionRatio = intersectionArea / targetArea;
|
||||
intersectionRatio = (double) intersectionArea / (double) targetArea;
|
||||
} else {
|
||||
intersectionRatio = intersectionRect.isSome() ? 1.0 : 0.0;
|
||||
}
|
||||
|
@ -626,6 +626,7 @@ skip-if = toolkit == 'android'
|
||||
skip-if = toolkit == 'android'
|
||||
[test_bug1399603.html]
|
||||
[test_bug1399605.html]
|
||||
[test_bug1406102.html]
|
||||
[test_caretPositionFromPoint.html]
|
||||
[test_change_policy.html]
|
||||
[test_clearTimeoutIntervalNoArg.html]
|
||||
|
38
dom/base/test/test_bug1406102.html
Normal file
38
dom/base/test/test_bug1406102.html
Normal file
@ -0,0 +1,38 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 1406102</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<style type="text/css">
|
||||
html {
|
||||
height: 100%;
|
||||
}
|
||||
body {
|
||||
height: 2866px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1406102">Mozilla Bug 1406102</a>
|
||||
<p id="display"></p>
|
||||
<div id="content">
|
||||
<div id="target"></div>
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
let observer = new IntersectionObserver(function (changes) {
|
||||
ok(changes[0].intersectionRatio > 0, 'intersectionRatio should be greater than zero');
|
||||
SimpleTest.finish();
|
||||
});
|
||||
observer.observe(document.body);
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
<div id="log">
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user