⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 277425 in webkit


Ignore:
Timestamp:
May 12, 2021, 11:45:07 PM (5 years ago)
Author:
commit-queue@webkit.org
Message:

RELEASE_ASSERT(m_selection->isNone()) fails in Document::removedLastRef
https://bugs.webkit.org/show_bug.cgi?id=225434

Patch by Frederic Wang <fwang@igalia.com> on 2021-05-12
Reviewed by Ryosuke Niwa.

Document::removedLastRef asserts that the document's selection is not set. However, setting
that selection is possible in FrameSelection::setSelectionWithoutUpdatingAppearance when the
document has not been destroyed yet but is already detached from its frame. This patch
instead clears the selection in that case.

No new tests.

  • editing/FrameSelection.cpp:

(WebCore::FrameSelection::setSelectionWithoutUpdatingAppearance): Clears the selection when
newSelection is in a detached document. Given the other conditions, this is actually
checking equivalent to !m_document->frame().

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r277424 r277425  
     12021-05-12  Frederic Wang  <fwang@igalia.com>
     2
     3        RELEASE_ASSERT(m_selection->isNone()) fails in Document::removedLastRef
     4        https://bugs.webkit.org/show_bug.cgi?id=225434
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Document::removedLastRef asserts that the document's selection is not set. However, setting
     9        that selection is possible in FrameSelection::setSelectionWithoutUpdatingAppearance when the
     10        document has not been destroyed yet but is already detached from its frame. This patch
     11        instead clears the selection in that case.
     12
     13        No new tests.
     14
     15        * editing/FrameSelection.cpp:
     16        (WebCore::FrameSelection::setSelectionWithoutUpdatingAppearance): Clears the selection when
     17        newSelection is in a detached document. Given the other conditions, this is actually
     18        checking equivalent to !m_document->frame().
     19
    1202021-05-12  Peng Liu  <peng.liu6@apple.com>
    221
  • trunk/Source/WebCore/editing/FrameSelection.cpp

    r277069 r277425  
    364364        }
    365365
    366         if (!m_document || !m_document->frame()) {
     366        if (!m_document) {
    367367            m_selection = newSelection;
    368368            updateAssociatedLiveRange();
     
    372372        bool selectionEndpointsBelongToMultipleDocuments = newSelection.base().document() && !newSelection.document();
    373373        bool selectionIsInAnotherDocument = newSelection.document() && newSelection.document() != m_document.get();
    374         if (selectionEndpointsBelongToMultipleDocuments || selectionIsInAnotherDocument) {
     374        bool selectionIsInDetachedDocument = newSelection.document() && !newSelection.document()->frame();
     375        if (selectionEndpointsBelongToMultipleDocuments || selectionIsInAnotherDocument || selectionIsInDetachedDocument) {
    375376            clear();
    376377            return false;
Note: See TracChangeset for help on using the changeset viewer.