Commit f8bf3f03 authored by Stefan Zager's avatar Stefan Zager Committed by Commit Bot

[IntersectionObserver] Don't snap bounding rects

These rects should mirror the behavior of getBoundingClientRect,
which doesn't snap.

BUG=758587,737228

Change-Id: If735df6bd24414dfbbd58dce01dc2a90f71df381
Reviewed-on: https://chromium-review.googlesource.com/951640Reviewed-by: default avatarSteve Kobes <skobes@chromium.org>
Commit-Queue: Stefan Zager <szager@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542548}
parent c0615961
...@@ -15,7 +15,7 @@ iframe { ...@@ -15,7 +15,7 @@ iframe {
} }
</style> </style>
<iframe id="iframe" srcdoc="<div id='target' style='width:1000px;height:1000px;'></div>"></iframe> <iframe id="iframe" srcdoc="<div id='target' style='margin:0.5px;width:1000px;height:1000px;'></div>"></iframe>
<script> <script>
var target; var target;
...@@ -37,7 +37,7 @@ iframe.onload = function() { ...@@ -37,7 +37,7 @@ iframe.onload = function() {
entries = entries.concat(observer.takeRecords()); entries = entries.concat(observer.takeRecords());
assert_equals(entries.length, 0, "No initial notifications."); assert_equals(entries.length, 0, "No initial notifications.");
runTestCycle(test0, "First rAF should generate notification."); runTestCycle(test0, "First rAF should generate notification.");
}, "IntersectionObserverEntry.boundingClientRect should match target.boundingClientRect()"); }, "IntersectionObserverEntry.boundingClientRect should match target.getBoundingClientRect()");
}; };
function test0() { function test0() {
......
...@@ -73,12 +73,12 @@ void IntersectionObservation::ComputeIntersectionObservations( ...@@ -73,12 +73,12 @@ void IntersectionObservation::ComputeIntersectionObservations(
CHECK(new_threshold_index < kMaxThresholdIndex); CHECK(new_threshold_index < kMaxThresholdIndex);
if (last_threshold_index_ != new_threshold_index) { if (last_threshold_index_ != new_threshold_index) {
IntRect snapped_root_bounds = geometry.RootIntRect(); FloatRect snapped_root_bounds(geometry.RootRect());
IntRect* root_bounds_pointer = FloatRect* root_bounds_pointer =
should_report_root_bounds_ ? &snapped_root_bounds : nullptr; should_report_root_bounds_ ? &snapped_root_bounds : nullptr;
IntersectionObserverEntry* new_entry = new IntersectionObserverEntry( IntersectionObserverEntry* new_entry = new IntersectionObserverEntry(
timestamp, new_visible_ratio, geometry.TargetIntRect(), timestamp, new_visible_ratio, FloatRect(geometry.TargetRect()),
root_bounds_pointer, geometry.IntersectionIntRect(), root_bounds_pointer, FloatRect(geometry.IntersectionRect()),
geometry.DoesIntersect(), Target()); geometry.DoesIntersect(), Target());
Observer()->EnqueueIntersectionObserverEntry(*new_entry); Observer()->EnqueueIntersectionObserverEntry(*new_entry);
SetLastThresholdIndex(new_threshold_index); SetLastThresholdIndex(new_threshold_index);
......
...@@ -11,17 +11,18 @@ namespace blink { ...@@ -11,17 +11,18 @@ namespace blink {
IntersectionObserverEntry::IntersectionObserverEntry( IntersectionObserverEntry::IntersectionObserverEntry(
DOMHighResTimeStamp time, DOMHighResTimeStamp time,
double intersection_ratio, double intersection_ratio,
const IntRect& bounding_client_rect, const FloatRect& bounding_client_rect,
const IntRect* root_bounds, const FloatRect* root_bounds,
const IntRect& intersection_rect, const FloatRect& intersection_rect,
bool is_intersecting, bool is_intersecting,
Element* target) Element* target)
: time_(time), : time_(time),
intersection_ratio_(intersection_ratio), intersection_ratio_(intersection_ratio),
bounding_client_rect_(DOMRectReadOnly::FromIntRect(bounding_client_rect)), bounding_client_rect_(
root_bounds_(root_bounds ? DOMRectReadOnly::FromIntRect(*root_bounds) DOMRectReadOnly::FromFloatRect(bounding_client_rect)),
root_bounds_(root_bounds ? DOMRectReadOnly::FromFloatRect(*root_bounds)
: nullptr), : nullptr),
intersection_rect_(DOMRectReadOnly::FromIntRect(intersection_rect)), intersection_rect_(DOMRectReadOnly::FromFloatRect(intersection_rect)),
target_(target), target_(target),
is_intersecting_(is_intersecting) is_intersecting_(is_intersecting)
......
...@@ -21,9 +21,9 @@ class IntersectionObserverEntry final : public ScriptWrappable { ...@@ -21,9 +21,9 @@ class IntersectionObserverEntry final : public ScriptWrappable {
public: public:
IntersectionObserverEntry(DOMHighResTimeStamp timestamp, IntersectionObserverEntry(DOMHighResTimeStamp timestamp,
double intersection_ratio, double intersection_ratio,
const IntRect& bounding_client_rect, const FloatRect& bounding_client_rect,
const IntRect* root_bounds, const FloatRect* root_bounds,
const IntRect& intersection_rect, const FloatRect& intersection_rect,
bool is_intersecting, bool is_intersecting,
Element*); Element*);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment