Commit 6192661b authored by vabr's avatar vabr Committed by Commit bot

Reland of Make InsertTextCommand not to apply style for empty selection...

Reland of Make InsertTextCommand not to apply style for empty selection (patchset #1 id:1 of https://codereview.chromium.org/2853213002/ )

Reason for revert:
Hmm, interestingly enough, the tests were still broken in the build which had the revert: https://build.chromium.org/p/chromium.webkit/builders/WebKit%20Linux%20Trusty%20%28dbg%29/builds/1512

So I am relanding it.

Original issue's description:
> Revert of Make InsertTextCommand not to apply style for empty selection (patchset #1 id:1 of https://codereview.chromium.org/2847763004/ )
>
> Reason for revert:
> Speculative revert, this seems to have broken some virtual/gpu/fast/canvas/ tests. More info on the associated bug.
>
> BUG=717389
>
> Original issue's description:
> > Make InsertTextCommand not to apply typing style for empty selection
> >
> > This patch makes |InsertTextCommand::DoApply()| not to call |ApplyStyle()| for
> > applying typing style when selection after inserting text is empty since
> > |ApplyStyle()| doesn't work with empty selection.
> >
> > The issue 714311 and the attached test case insert text into OPTION element to
> > get empty selection after insertion, since we can't place selection inside
> > OPTION element.
> >
> > BUG=714311
> > TEST=run_webkit_unit_tests --gtest_filter=InsertTextCommandTest.WithTypingStyle
> >
> > Review-Url: https://codereview.chromium.org/2847763004
> > Cr-Commit-Position: refs/heads/master@{#468080}
> > Committed: https://chromium.googlesource.com/chromium/src/+/89209614959b6d3b2d4c4e8b015232663b4fcd87
>
> TBR=xiaochengh@chromium.org,yoichio@chromium.org,yosin@chromium.org
> # Not skipping CQ checks because original CL landed more than 1 days ago.
> BUG=714311
>
> Review-Url: https://codereview.chromium.org/2853213002
> Cr-Commit-Position: refs/heads/master@{#468590}
> Committed: https://chromium.googlesource.com/chromium/src/+/5c9d124ac2131f4765f86902ff4cf711ed96c37e

TBR=xiaochengh@chromium.org,yoichio@chromium.org,yosin@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=717389

Review-Url: https://codereview.chromium.org/2854123002
Cr-Commit-Position: refs/heads/master@{#468642}
parent 20f63c58
...@@ -285,6 +285,7 @@ source_set("unit_tests") { ...@@ -285,6 +285,7 @@ source_set("unit_tests") {
"commands/DeleteSelectionCommandTest.cpp", "commands/DeleteSelectionCommandTest.cpp",
"commands/InsertIncrementalTextCommandTest.cpp", "commands/InsertIncrementalTextCommandTest.cpp",
"commands/InsertListCommandTest.cpp", "commands/InsertListCommandTest.cpp",
"commands/InsertTextCommandTest.cpp",
"commands/ReplaceSelectionCommandTest.cpp", "commands/ReplaceSelectionCommandTest.cpp",
"commands/SetCharacterDataCommandTest.cpp", "commands/SetCharacterDataCommandTest.cpp",
"commands/SplitTextNodeCommandTest.cpp", "commands/SplitTextNodeCommandTest.cpp",
......
...@@ -276,7 +276,7 @@ void InsertTextCommand::DoApply(EditingState* editing_state) { ...@@ -276,7 +276,7 @@ void InsertTextCommand::DoApply(EditingState* editing_state) {
GetDocument().GetFrame()->GetEditor().TypingStyle()) { GetDocument().GetFrame()->GetEditor().TypingStyle()) {
typing_style->PrepareToApplyAt(end_position, typing_style->PrepareToApplyAt(end_position,
EditingStyle::kPreserveWritingDirection); EditingStyle::kPreserveWritingDirection);
if (!typing_style->IsEmpty()) { if (!typing_style->IsEmpty() && !EndingSelection().IsNone()) {
ApplyStyle(typing_style, editing_state); ApplyStyle(typing_style, editing_state);
if (editing_state->IsAborted()) if (editing_state->IsAborted())
return; return;
......
// Copyright (c) 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "core/editing/commands/InsertTextCommand.h"
#include "core/editing/EditingTestBase.h"
#include "core/editing/FrameSelection.h"
namespace blink {
class InsertTextCommandTest : public EditingTestBase {};
// http://crbug.com/714311
TEST_F(InsertTextCommandTest, WithTypingStyle) {
SetBodyContent("<div contenteditable=true><option id=sample></option></div>");
Element* const sample = GetDocument().getElementById("sample");
Selection().SetSelection(
SelectionInDOMTree::Builder().Collapse(Position(sample, 0)).Build());
// Register typing style to make |InsertTextCommand| to attempt to apply
// style to inserted text.
GetDocument().execCommand("fontSizeDelta", false, "+3", ASSERT_NO_EXCEPTION);
CompositeEditCommand* const command =
InsertTextCommand::Create(GetDocument(), "x");
command->Apply();
EXPECT_EQ(
"<div contenteditable=\"true\"><option id=\"sample\">x</option></div>",
GetDocument().body()->innerHTML())
<< "Content of OPTION is distributed into shadow node as text"
"without applying typing style.";
}
} // 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