Title: [288260] releases/WebKitGTK/webkit-2.34
- Revision
- 288260
- Author
- [email protected]
- Date
- 2022-01-19 17:35:06 -0800 (Wed, 19 Jan 2022)
Log Message
Merge r286049 - Nullptr crash in SimplifiedBackwardsTextIterator::range() via previousSentencePosition
https://bugs.webkit.org/show_bug.cgi?id=229282
Patch by Frédéric Wang <[email protected]> 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.
Modified Paths
Added Paths
Diff
Modified: releases/WebKitGTK/webkit-2.34/LayoutTests/ChangeLog (288259 => 288260)
--- releases/WebKitGTK/webkit-2.34/LayoutTests/ChangeLog 2022-01-20 01:34:57 UTC (rev 288259)
+++ releases/WebKitGTK/webkit-2.34/LayoutTests/ChangeLog 2022-01-20 01:35:06 UTC (rev 288260)
@@ -1,3 +1,15 @@
+2021-11-18 Frédéric Wang <[email protected]>
+
+ Nullptr crash in SimplifiedBackwardsTextIterator::range() via previousSentencePosition
+ https://bugs.webkit.org/show_bug.cgi?id=229282
+
+ Reviewed by Darin Adler.
+
+ Add regression test.
+
+ * editing/text-iterator/backward-textiterator-object-crash-expected.txt: Added.
+ * editing/text-iterator/backward-textiterator-object-crash.html: Added.
+
2021-11-15 Gabriel Nava Marino <[email protected]>
nullptr deref in CompositeEditCommand::insertNodeAt
Added: releases/WebKitGTK/webkit-2.34/LayoutTests/editing/text-iterator/backward-textiterator-object-crash-expected.txt (0 => 288260)
--- releases/WebKitGTK/webkit-2.34/LayoutTests/editing/text-iterator/backward-textiterator-object-crash-expected.txt (rev 0)
+++ releases/WebKitGTK/webkit-2.34/LayoutTests/editing/text-iterator/backward-textiterator-object-crash-expected.txt 2022-01-20 01:35:06 UTC (rev 288260)
@@ -0,0 +1 @@
+This test passes if it does not crash.
Added: releases/WebKitGTK/webkit-2.34/LayoutTests/editing/text-iterator/backward-textiterator-object-crash.html (0 => 288260)
--- releases/WebKitGTK/webkit-2.34/LayoutTests/editing/text-iterator/backward-textiterator-object-crash.html (rev 0)
+++ releases/WebKitGTK/webkit-2.34/LayoutTests/editing/text-iterator/backward-textiterator-object-crash.html 2022-01-20 01:35:06 UTC (rev 288260)
@@ -0,0 +1,13 @@
+<script>
+ _onload_ = () => {
+ if (window.testRunner)
+ testRunner.dumpAsText();
+ document.documentElement.removeChild(document.head);
+ let input = document.createElement('input');
+ document.documentElement.appendChild(input);
+ getSelection().setBaseAndExtent(input, 0, input, 0);
+ document.body.innerHTML = "<object><object><object><object><div></div></object></object></object></object>";
+ getSelection().modify('move', 'backward', 'sentence');
+ document.body.innerHTML = "This test passes if it does not crash.";
+ };
+</script>
Modified: releases/WebKitGTK/webkit-2.34/Source/WebCore/ChangeLog (288259 => 288260)
--- releases/WebKitGTK/webkit-2.34/Source/WebCore/ChangeLog 2022-01-20 01:34:57 UTC (rev 288259)
+++ releases/WebKitGTK/webkit-2.34/Source/WebCore/ChangeLog 2022-01-20 01:35:06 UTC (rev 288260)
@@ -1,3 +1,23 @@
+2021-11-18 Frédéric Wang <[email protected]>
+
+ Nullptr crash in SimplifiedBackwardsTextIterator::range() via previousSentencePosition
+ https://bugs.webkit.org/show_bug.cgi?id=229282
+
+ Reviewed by Darin Adler.
+
+ 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.
+
2021-11-15 Gabriel Nava Marino <[email protected]>
nullptr deref in CompositeEditCommand::insertNodeAt
Modified: releases/WebKitGTK/webkit-2.34/Source/WebCore/editing/FrameSelection.cpp (288259 => 288260)
--- releases/WebKitGTK/webkit-2.34/Source/WebCore/editing/FrameSelection.cpp 2022-01-20 01:34:57 UTC (rev 288259)
+++ releases/WebKitGTK/webkit-2.34/Source/WebCore/editing/FrameSelection.cpp 2022-01-20 01:35:06 UTC (rev 288260)
@@ -70,6 +70,7 @@
#include "SimpleRange.h"
#include "SpatialNavigation.h"
#include "StyleProperties.h"
+#include "StyleTreeResolver.h"
#include "TypingCommand.h"
#include "VisibleUnits.h"
#include <stdio.h>
@@ -1343,6 +1344,14 @@
willBeModified(alter, direction);
+ // Before modifying selection, update layout and disable post resolution callbacks.
+ // That way, unaverted tree changes are avoided while browsing the document.
+ auto selectionDocument = m_selection.document();
+ if (!selectionDocument)
+ return false;
+ selectionDocument->updateLayoutIgnorePendingStylesheets();
+ Style::PostResolutionCallbackDisabler disabler(*selectionDocument);
+
bool reachedBoundary = false;
bool wasRange = m_selection.isRange();
Position originalStartPosition = m_selection.start();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes