Commit c1ed8403 authored by Yoshifumi Inoue's avatar Yoshifumi Inoue Committed by Commit Bot

Make DeleteSelectionCommand to handle ::first-letter correctly

This patch changes |DeleteSelectionCommand::HandleGeneralDelete()| to use the
clean layout tree for calling |start_node->GetLayoutObject()| after calling
|DeleteTextFromNode()| or |RemoveChildrenInRange()| to avoid removing
|start_node|.


Note: When |Text| node with ::first-letter is modified, Blink detach
layout object from it in |Text::UpdateTextLayoutObject()| to follow
|ShouldUpdateLayoutByReattaching()| which returns true for |true| for
|Text| node with ::first-letter.

Bug: 808516
Change-Id: I7139398ca3938e56960c81c9196bd58e91bed668
Reviewed-on: https://chromium-review.googlesource.com/920051
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarXiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537233}
parent 445d610b
...@@ -677,6 +677,8 @@ void DeleteSelectionCommand::HandleGeneralDelete(EditingState* editing_state) { ...@@ -677,6 +677,8 @@ void DeleteSelectionCommand::HandleGeneralDelete(EditingState* editing_state) {
return; return;
ending_position_ = upstream_start_; ending_position_ = upstream_start_;
} }
// We should update layout to associate |start_node| to layout object.
GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets();
} }
// The selection to delete is all in one node. // The selection to delete is all in one node.
......
...@@ -62,4 +62,21 @@ TEST_F(DeleteSelectionCommandTest, deleteListFromTable) { ...@@ -62,4 +62,21 @@ TEST_F(DeleteSelectionCommandTest, deleteListFromTable) {
.ToOffsetInAnchor()); .ToOffsetInAnchor());
} }
TEST_F(DeleteSelectionCommandTest, ForwardDeleteWithFirstLetter) {
InsertStyleElement("p::first-letter {font-size:200%;}");
Selection().SetSelectionAndEndTyping(
SetSelectionTextToBody("<p contenteditable>a^b|c</p>"));
const bool kNoSmartDelete = false;
const bool kMergeBlocksAfterDelete = true;
const bool kNoExpandForSpecialElements = false;
const bool kSanitizeMarkup = true;
DeleteSelectionCommand& command = *DeleteSelectionCommand::Create(
GetDocument(), kNoSmartDelete, kMergeBlocksAfterDelete,
kNoExpandForSpecialElements, kSanitizeMarkup);
EXPECT_TRUE(command.Apply()) << "the delete command should have succeeded";
EXPECT_EQ("<p contenteditable>a|c</p>",
GetSelectionTextFromBody(Selection().GetSelectionInDOMTree()));
}
} // 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