Skip to content

Commit

Permalink
[Editing] Fix null check for block_flow while creating inline contents
Browse files Browse the repository at this point in the history
on extending selection backward.

When selection is extended backward word-wise and block element is part
of the inline item, if the target in |CreateInlineContentsFromBlockFlow|
is part of the Shadow tree but the block_flow is anonymous and outside
the Shadow tree then the target is never reached and as block_flow being
a PseudoNode, makes |first| and |last| as nullptr since the traversal
inside the shadow tree doesn't happen for user agent root. Thus we need
to re-target the target before we create inline contents from block_flow
in this case to avoid the crash and get to the correct target. This CL
fixes this by sending the correct target before calling
|CreateInlineContentsFromBlockFlow| in |ComputeInlineContentsFromNode|.

Bug: 380107555
Change-Id: I40dbb7628ed6dd7ecebd5842ee740c28c7a5037d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6175802
Commit-Queue: Pranav Modi <[email protected]>
Reviewed-by: Kent Tamura <[email protected]>
Reviewed-by: Sambamurthy Bandaru <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1424395}
  • Loading branch information
pranavmodi25 authored and chromium-wpt-export-bot committed Feb 25, 2025
1 parent 570d512 commit d7fa260
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions selection/extend-selection-backward-on-input.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<title>
This test crashes if block_flow is a pseudo node and first or last is null
while creating inline contents from block flow if there is a block_node in an
inline node.
</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function runTest() {
test(() => {
const div = document.createElement("div");
document.body.appendChild(div);
const bold = document.createElement("b");
document.body.appendChild(bold);
const input = document.createElement("input");
bold.appendChild(input);
input.setAttribute("type", "file");
document.execCommand("selectall");
const p = document.createElement("p");
bold.appendChild(p);
window.getSelection().modify("extend", "backward", "word");
}, "Should not crash if block node is in an inline node and block_flow is a pseudo node");
done();
}
window.addEventListener("load", runTest, { once: true });
</script>

0 comments on commit d7fa260

Please sign in to comment.