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

[IntersectionObserver] Speculative fix for bad cast

These are instances where we don't actually need to remove an element from its
tracking document's IntersectionObserverController, because it wasn't being
tracked anyway.

BUG=1007334,1006957

Change-Id: Ia14165402e2a3774a180d0215145d3d46338942c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1828358
Commit-Queue: Stefan Zager <szager@chromium.org>
Reviewed-by: default avatarvmpstr <vmpstr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#700896}
parent 126c42bd
......@@ -2657,10 +2657,11 @@ void Element::RemovedFrom(ContainerNode& insertion_point) {
if (ElementAnimations* element_animations = data->GetElementAnimations())
element_animations->CssAnimations().Cancel();
if (data->IntersectionObserverData()) {
if (was_in_document && data->IntersectionObserverData()) {
data->IntersectionObserverData()->ComputeIntersectionsForTarget(
IntersectionObservation::kExplicitRootObserversNeedUpdate |
IntersectionObservation::kImplicitRootObserversNeedUpdate);
IntersectionObservation::kImplicitRootObserversNeedUpdate |
IntersectionObservation::kIgnoreDelay);
GetDocument().EnsureIntersectionObserverController().RemoveTrackedElement(
*this);
}
......
......@@ -70,7 +70,11 @@ void IntersectionObservation::Disconnect() {
ElementIntersectionObserverData* observer_data =
target_->IntersectionObserverData();
observer_data->RemoveObservation(*Observer());
if (target_->isConnected() &&
// We track connected elements that are either the root of an explicit root
// observer, or the target of an implicit root observer. If the target was
// previously being tracked, but no longer needs to be tracked, then remove
// it.
if (target_->isConnected() && Observer()->RootIsImplicit() &&
!observer_data->IsTargetOfImplicitRootObserver() &&
!observer_data->IsRoot()) {
IntersectionObserverController* controller =
......
......@@ -318,7 +318,8 @@ void IntersectionObserver::observe(Element* target,
// be recorded after observe() is called, even if the target is detached.
observation->ComputeIntersection(
IntersectionObservation::kImplicitRootObserversNeedUpdate |
IntersectionObservation::kExplicitRootObserversNeedUpdate);
IntersectionObservation::kExplicitRootObserversNeedUpdate |
IntersectionObservation::kIgnoreDelay);
}
}
......
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