Skip to content

Commit

Permalink
[content-visibility] css/css-contain/content-visibility/content-visib…
Browse files Browse the repository at this point in the history
…ility-auto-state-changed-removed.html fails sometimes

https://bugs.webkit.org/show_bug.cgi?id=264414

Reviewed by Simon Fraser.

Change timing of checking whether the element to dispatch ContentVisibilityAutoStateChangeEvent to is connected to the
moment we try to dispatch, rather than the time we queue the dispatching task.

* Source/WebCore/dom/ContentVisibilityDocumentState.cpp:
(WebCore::ContentVisibilityDocumentState::checkRelevancyOfContentVisibilityElement const):

Canonical link: https://commits.webkit.org/271293@main
  • Loading branch information
rwlbuis committed Nov 29, 2023
1 parent 39f82c8 commit 8a4527f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Source/WebCore/dom/ContentVisibilityDocumentState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,13 @@ bool ContentVisibilityDocumentState::checkRelevancyOfContentVisibilityElement(El
auto isSkippedContent = target.isRelevantToUser() ? IsSkippedContent::No : IsSkippedContent::Yes;
target.invalidateStyle();
updateAnimations(target, wasSkippedContent, isSkippedContent);
if (target.isConnected()) {
ContentVisibilityAutoStateChangeEvent::Init init;
init.skipped = isSkippedContent == IsSkippedContent::Yes;
target.queueTaskToDispatchEvent(TaskSource::DOMManipulation, ContentVisibilityAutoStateChangeEvent::create(eventNames().contentvisibilityautostatechangeEvent, init));
}
target.queueTaskKeepingThisNodeAlive(TaskSource::DOMManipulation, [&, isSkippedContent] {
if (target.isConnected()) {
ContentVisibilityAutoStateChangeEvent::Init init;
init.skipped = isSkippedContent == IsSkippedContent::Yes;
target.dispatchEvent(ContentVisibilityAutoStateChangeEvent::create(eventNames().contentvisibilityautostatechangeEvent, init));
}
});
return true;
}

Expand Down

0 comments on commit 8a4527f

Please sign in to comment.