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

Changeset 286049 in webkit


Ignore:
Timestamp:
Nov 18, 2021, 11:30:40 PM (5 years ago)
Author:
commit-queue@webkit.org
Message:

Nullptr crash in SimplifiedBackwardsTextIterator::range() via previousSentencePosition
https://bugs.webkit.org/show_bug.cgi?id=229282

Patch by Frédéric Wang <fwang@igalia.com> on 2021-11-18
Reviewed by Darin Adler.

Source/WebCore:

Constructors of TextIterator and SimplifiedBackwardsTextIterator update layout, which may
make HTMLObjectElement switch to fallback content and invalidate their renderer. As a
consequence their advance() method may incorrectly treat them as replaced elements. This
patch updates the layout at the beginning of FrameSelection::modify and disable post
resolution callbacks in order to prevent this kind of unaverted tree changes while browsing
the tree for selection update.

Test: editing/text-iterator/backward-textiterator-object-crash.html

  • editing/FrameSelection.cpp:

(WebCore::FrameSelection::modify): Update layout and disable post resolution callback, so that
all iterators used during the execution of the function handle <object>s consistently.

LayoutTests:

Add regression test.

  • editing/text-iterator/backward-textiterator-object-crash-expected.txt: Added.
  • editing/text-iterator/backward-textiterator-object-crash.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r286044 r286049  
     12021-11-18  Frédéric Wang  <fwang@igalia.com>
     2
     3        Nullptr crash in SimplifiedBackwardsTextIterator::range() via previousSentencePosition
     4        https://bugs.webkit.org/show_bug.cgi?id=229282
     5
     6        Reviewed by Darin Adler.
     7
     8        Add regression test.
     9
     10        * editing/text-iterator/backward-textiterator-object-crash-expected.txt: Added.
     11        * editing/text-iterator/backward-textiterator-object-crash.html: Added.
     12
    1132021-11-18  Ben Nham  <nham@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r286048 r286049  
     12021-11-18  Frédéric Wang  <fwang@igalia.com>
     2
     3        Nullptr crash in SimplifiedBackwardsTextIterator::range() via previousSentencePosition
     4        https://bugs.webkit.org/show_bug.cgi?id=229282
     5
     6        Reviewed by Darin Adler.
     7
     8        Constructors of TextIterator and SimplifiedBackwardsTextIterator update layout, which may
     9        make HTMLObjectElement switch to fallback content and invalidate their renderer. As a
     10        consequence their advance() method may incorrectly treat them as replaced elements. This
     11        patch updates the layout at the beginning of FrameSelection::modify and disable post
     12        resolution callbacks in order to prevent this kind of unaverted tree changes while browsing
     13        the tree for selection update.
     14
     15        Test: editing/text-iterator/backward-textiterator-object-crash.html
     16
     17        * editing/FrameSelection.cpp:
     18        (WebCore::FrameSelection::modify): Update layout and disable post resolution callback, so that
     19        all iterators used during the execution of the function handle <object>s consistently.
     20
    1212021-11-18  Antoine Quint  <graouts@webkit.org>
    222
  • trunk/Source/WebCore/editing/FrameSelection.cpp

    r285655 r286049  
    7272#include "SpatialNavigation.h"
    7373#include "StyleProperties.h"
     74#include "StyleTreeResolver.h"
    7475#include "TypingCommand.h"
    7576#include "VisibleUnits.h"
     
    13441345
    13451346    willBeModified(alter, direction);
     1347
     1348    // Before modifying selection, update layout and disable post resolution callbacks.
     1349    // That way, unaverted tree changes are avoided while browsing the document.
     1350    auto selectionDocument = m_selection.document();
     1351    if (!selectionDocument)
     1352        return false;
     1353    selectionDocument->updateLayoutIgnorePendingStylesheets();
     1354    Style::PostResolutionCallbackDisabler disabler(*selectionDocument);
    13461355
    13471356    bool reachedBoundary = false;
Note: See TracChangeset for help on using the changeset viewer.