Skip to content

Commit

Permalink
Revert "Don't show text selection popup menu if current selected text…
Browse files Browse the repository at this point in the history
… is cleared."

This reverts commit e9c5bc1.

Reason for revert: caused crbug.com/841489

Original change's description:
> Don't show text selection popup menu if current selected text is cleared.
> 
> If text selection clear action is just after selecting all text action in editable input box,
> then the state of text selection in renderer is not correct, which causes the selection popup
> menu will be incorrectly shown.
> Fix this issue by checking selection state before popup text selection menu.
> 
> Bug: 817712
> 
> Change-Id: I4dcda47d5f0fe5f20febc2e1def30574c6060724
> Reviewed-on: https://chromium-review.googlesource.com/940290
> Commit-Queue: Antoine Labour <piman@chromium.org>
> Reviewed-by: Changwan Ryu <changwan@chromium.org>
> Reviewed-by: Pedro Amaral <amaralp@chromium.org>
> Reviewed-by: Antoine Labour <piman@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#555099}

TBR=boliu@chromium.org,haraken@chromium.org,changwan@chromium.org,piman@chromium.org,amaralp@chromium.org,zuojinglong@xiaomi.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 817712
Change-Id: I97f01cd58f23939066a2179a819d20534a60123f
Reviewed-on: https://chromium-review.googlesource.com/1054112
Reviewed-by: Changwan Ryu <changwan@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Commit-Queue: Changwan Ryu <changwan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#557617}
  • Loading branch information
galmacky authored and Commit Bot committed May 10, 2018
1 parent ddfd4d8 commit cc7bafb
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 55 deletions.
1 change: 0 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,6 @@ Jihoon Chung <jihoon@gmail.com>
Jihun Brent Kim <devgrapher@gmail.com>
Jin Yang <jin.a.yang@intel.com>
Jincheol Jo <jincheol.jo@navercorp.com>
Jinglong Zuo <zuojinglong@xiaomi.com>
Jingwei Liu <kingweiliu@gmail.com>
Jingyi Wei <wjywbs@gmail.com>
Jinho Bang <jinho.bang@samsung.com>
Expand Down
4 changes: 0 additions & 4 deletions content/renderer/render_frame_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4544,10 +4544,6 @@ void RenderFrameImpl::ShowContextMenu(const blink::WebContextMenuData& data) {
}

void RenderFrameImpl::ShowDeferredContextMenu(const ContextMenuParams& params) {
// TODO (amaralp): Remove this once selection menu race conditions are fixed.
if (selection_text_.empty() && !params.selection_text.empty())
return;

Send(new FrameHostMsg_ContextMenu(routing_id_, params));
}

Expand Down
50 changes: 0 additions & 50 deletions content/renderer/render_view_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
#include "third_party/blink/public/platform/web_gesture_device.h"
#include "third_party/blink/public/platform/web_gesture_event.h"
#include "third_party/blink/public/platform/web_input_event.h"
#include <android/keycodes.h>
#endif

#if defined(OS_WIN)
Expand Down Expand Up @@ -1552,55 +1551,6 @@ TEST_F(RenderViewImplTest, AndroidContextMenuSelectionOrdering) {
ExecuteJavaScriptAndReturnIntValue(check_did_select, &did_select));
EXPECT_EQ(1, did_select);
}

TEST_F(RenderViewImplTest, AndroidContextMenuSelectionCleared) {
// Load an HTML page consisting of an input field.
LoadHTML("<html>"
"<head>"
"</head>"
"<body>"
"<input id=\"test1\" value=\"abcdefghijklmnopqrstuvwxyz\"></input>"
"</body>"
"</html>");

WebGestureEvent gesture_event(WebInputEvent::kGestureTap,
WebInputEvent::kNoModifiers,
ui::EventTimeForNow());
gesture_event.SetPositionInWidget(gfx::PointF(20, 20));

SendWebGestureEvent(gesture_event);

frame()->GetWebFrame()->ExecuteCommand("SelectAll");

blink::WebKeyboardEvent event(blink::WebKeyboardEvent::kRawKeyDown,
blink::WebInputEvent::kNoModifiers,
ui::EventTimeForNow());
event.windows_key_code = ui::VKEY_BACK;
event.native_key_code = AKEYCODE_DEL;
SendWebKeyboardEvent(event);

scoped_refptr<content::MessageLoopRunner> message_loop_runner =
new content::MessageLoopRunner;
blink::scheduler::GetSingleThreadTaskRunnerForTesting()->PostTask(
FROM_HERE, message_loop_runner->QuitClosure());

EXPECT_FALSE(render_thread_->sink().GetUniqueMessageMatching(
FrameHostMsg_ContextMenu::ID));

message_loop_runner->Run();

EXPECT_FALSE(render_thread_->sink().GetUniqueMessageMatching(
FrameHostMsg_ContextMenu::ID));

// Check whether text selection is cleared.
blink::WebInputMethodController* controller =
frame()->GetWebFrame()->GetInputMethodController();
blink::WebTextInputInfo info = controller->TextInputInfo();
EXPECT_EQ(0, info.selection_start);
EXPECT_EQ(0, info.selection_end);
}


#endif

TEST_F(RenderViewImplTest, TestBackForward) {
Expand Down

0 comments on commit cc7bafb

Please sign in to comment.