Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 408429b44b242fe62a9d04ba2269786b8e76149b
      
https://github.com/WebKit/WebKit/commit/408429b44b242fe62a9d04ba2269786b8e76149b
  Author: David Kilzer <[email protected]>
  Date:   2026-05-17 (Sun, 17 May 2026)

  Changed paths:
    M Source/WebCore/dom/Document.cpp

  Log Message:
  -----------
  Avoid lazy-allocating UndoManager during Document teardown
<https://bugs.webkit.org/show_bug.cgi?id=314996>
<rdar://177311258>

Reviewed by Chris Dumez.

Skip the call to `protectedUndoManager()->removeAllItems()` in
`Document::willBeRemovedFromFrame()` when `m_undoManager` is null to
avoid lazy-creating an `UndoManager` solely so `removeAllItems()` can
no-op on an empty `HashSet`.

Existing tests cover both branches.

`m_undoManager` is not nullptr (`removeAllItems()` is called):

- editing/undo-manager/undo-manager-add-item.html
- editing/undo-manager/undo-manager-delete-stale-undo-items.html
- editing/undo-manager/undo-manager-item-labels.html
- editing/undo-manager/undo-manager-keeps-wrapper-alive.html
- editing/undo-manager/undo-manager-undo-redo-after-garbage-collection.html

`m_undoManager` is nullptr (the changed branch):

- editing/undo-manager/undo-manager-add-item-exceptions.html
- editing/undo-manager/undo-manager-interfaces.html
- all 39 tests under editing/undo/ (which use `document.execCommand`
  rather than the JS `UndoManager` API)

* Source/WebCore/dom/Document.cpp:
(WebCore::Document::willBeRemovedFromFrame):

Canonical link: https://commits.webkit.org/313393@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to