Commit 5a38d2f2 authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

IntersectionObserver: Fixes |unobserve| to take effect immediately.

Applies the same fix as https://crrev.com/c/924104 to
IntersectionObserver, too.

Unfortunately, I cannot reproduce the crash for IntersectionObserver,
and I'm not sure if this fix is actually effective or not.  However,
seeing the same fix worked (at least partially) for ResizeObserver,
I'd like to apply the same fix to IntersectionObserver, too.

Bug: 815058
Change-Id: I0e89cd56ab4915457178b38623daadc0be20c927
Reviewed-on: https://chromium-review.googlesource.com/934483
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#539094}
parent 4b96f800
......@@ -273,10 +273,19 @@ void IntersectionObserver::unobserve(Element* target,
if (!target || !target->IntersectionObserverData())
return;
if (IntersectionObservation* observation =
target->IntersectionObserverData()->GetObservationFor(*this)) {
observation->Disconnect();
observations_.erase(observation);
IntersectionObservation* observation =
target->IntersectionObserverData()->GetObservationFor(*this);
if (!observation)
return;
observation->Disconnect();
observations_.erase(observation);
for (size_t i = 0; i < entries_.size(); ++i) {
if (entries_[i]->target() == target) {
entries_.EraseAt(i);
--i;
}
}
}
......
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