Commit 526d14e6 authored by tkent's avatar tkent Committed by Commit bot

Fix an assertion failure in FrameSelection::selectAll().

Don't try to make VisibleSelection for elements of which content is not
selectable.

This CL has no user-visible behavior changes because
selectionFromContentsOfNode() created a null VisibleSelection before this CL.

BUG=477839
TEST=automated

Review URL: https://codereview.chromium.org/1647833002

Cr-Commit-Position: refs/heads/master@{#372015}
parent 2c259ad5
...@@ -842,7 +842,7 @@ void FrameSelection::selectAll() ...@@ -842,7 +842,7 @@ void FrameSelection::selectAll()
selectStartTarget = document->body(); selectStartTarget = document->body();
} }
} }
if (!root) if (!root || editingIgnoresContent(root))
return; return;
if (selectStartTarget && !selectStartTarget->dispatchEvent(Event::createCancelableBubble(EventTypeNames::selectstart))) if (selectStartTarget && !selectStartTarget->dispatchEvent(Event::createCancelableBubble(EventTypeNames::selectstart)))
......
...@@ -214,4 +214,12 @@ TEST_F(FrameSelectionTest, setNonDirectionalSelectionIfNeeded) ...@@ -214,4 +214,12 @@ TEST_F(FrameSelectionTest, setNonDirectionalSelectionIfNeeded)
EXPECT_EQ(PositionInComposedTree(bottom, 3), visibleSelectionInComposedTree().end()); EXPECT_EQ(PositionInComposedTree(bottom, 3), visibleSelectionInComposedTree().end());
} }
TEST_F(FrameSelectionTest, SelectAllWithUnselectableRoot)
{
RefPtrWillBeRawPtr<Element> select = document().createElement("select", ASSERT_NO_EXCEPTION);
document().replaceChild(select.get(), document().documentElement());
selection().selectAll();
EXPECT_TRUE(selection().isNone()) << "Nothing should be selected if the content of the documentElement is not selctable.";
}
} // namespace blink } // namespace blink
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment