Skip to content

Commit

Permalink
Revert "Respect the order of input messages from browser to renderer"
Browse files Browse the repository at this point in the history
This reverts commit 17ab5a8.

Causing build failures.

BUG=619820,601707

Cr-Commit-Position: refs/branch-heads/2743@{crosswalk-project#350}
Cr-Branched-From: 2b3ae3b-refs/heads/master@{#394939}
  • Loading branch information
Alex Mineer committed Jun 14, 2016
1 parent db32c89 commit 18119df
Show file tree
Hide file tree
Showing 16 changed files with 38 additions and 142 deletions.
13 changes: 0 additions & 13 deletions content/browser/frame_host/interstitial_page_impl_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ class TestInterstitialPageDelegate : public InterstitialPageDelegate {
" window.domAutomationController.send("
" window.getSelection().toString());"
"}"
"function set_selection_change_listener() {"
" document.addEventListener('selectionchange',"
" function() { document.title='SELECTION_CHANGED'; })"
"}"
"</script>"
"</head>"
"<body>original body text</body>"
Expand Down Expand Up @@ -283,11 +279,6 @@ class InterstitialPageImplTest : public ContentBrowserTest {
"create_input_and_set_text('" + text + "')");
}

bool SetSelectionChangeListener() {
return ExecuteScript(interstitial_->GetMainFrame(),
"set_selection_change_listener()");
}

std::string PerformCut() {
clipboard_message_watcher_->InitWait();
title_update_watcher_->InitWait("TEXT_CHANGED");
Expand Down Expand Up @@ -317,11 +308,9 @@ class InterstitialPageImplTest : public ContentBrowserTest {
}

void PerformSelectAll() {
title_update_watcher_->InitWait("SELECTION_CHANGED");
RenderFrameHostImpl* rfh =
static_cast<RenderFrameHostImpl*>(interstitial_->GetMainFrame());
rfh->GetRenderWidgetHost()->delegate()->SelectAll();
title_update_watcher_->Wait();
}

private:
Expand Down Expand Up @@ -398,14 +387,12 @@ IN_PROC_BROWSER_TEST_F(InterstitialPageImplTest, Paste) {

IN_PROC_BROWSER_TEST_F(InterstitialPageImplTest, SelectAll) {
SetUpInterstitialPage();
ASSERT_TRUE(SetSelectionChangeListener());

std::string input_text;
ASSERT_TRUE(GetSelection(&input_text));
EXPECT_EQ(std::string(), input_text);

PerformSelectAll();

ASSERT_TRUE(GetSelection(&input_text));
EXPECT_EQ("original body text", input_text);

Expand Down
5 changes: 3 additions & 2 deletions content/browser/renderer_host/ime_adapter_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_view_android.h"
#include "content/common/frame_messages.h"
#include "content/common/input_messages.h"
#include "content/common/view_messages.h"
#include "content/public/browser/browser_thread.h"
Expand Down Expand Up @@ -263,8 +264,8 @@ void ImeAdapterAndroid::SetEditableSelectionOffsets(
if (!rfh)
return;

rfh->Send(new InputMsg_SetEditableSelectionOffsets(rfh->GetRoutingID(), start,
end));
rfh->Send(new FrameMsg_SetEditableSelectionOffsets(rfh->GetRoutingID(),
start, end));
}

void ImeAdapterAndroid::SetCharacterBounds(
Expand Down
6 changes: 6 additions & 0 deletions content/common/frame_messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,12 @@ IPC_MESSAGE_ROUTED4(FrameMsg_JavaScriptExecuteRequestInIsolatedWorld,
bool, /* if true, a reply is requested */
int /* world_id */)

// Selects between the given start and end offsets in the currently focused
// editable field.
IPC_MESSAGE_ROUTED2(FrameMsg_SetEditableSelectionOffsets,
int /* start */,
int /* end */)

// Requests a navigation to the supplied markup, in an iframe with sandbox
// attributes.
IPC_MESSAGE_ROUTED1(FrameMsg_SetupTransitionView,
Expand Down
6 changes: 0 additions & 6 deletions content/common/input_messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,6 @@ IPC_MESSAGE_ROUTED2(InputMsg_ExtendSelectionAndDelete,
int /* before */,
int /* after */)

// Selects between the given start and end offsets in the currently focused
// editable field.
IPC_MESSAGE_ROUTED2(InputMsg_SetEditableSelectionOffsets,
int /* start */,
int /* end */)

// This message sends a string being composed with an input method.
IPC_MESSAGE_ROUTED5(
InputMsg_ImeSetComposition,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1202,30 +1202,6 @@ public CharSequence call() {
}));
}

// Tests that the method call order is kept.
// See crbug.com/601707 for details.
@MediumTest
@Feature({"TextInput"})
public void testSetSelectionCommitTextOrder() throws Exception {
final ChromiumBaseInputConnection connection = mConnection;
runBlockingOnImeThread(new Callable<Void>() {
@Override
public Void call() {
connection.beginBatchEdit();
connection.commitText("hello world", 1);
connection.setSelection(6, 6);
connection.deleteSurroundingText(0, 5);
connection.commitText("'", 1);
connection.commitText("world", 1);
connection.setSelection(7, 7);
connection.setComposingText("", 1);
connection.endBatchEdit();
return null;
}
});
waitAndVerifyUpdateSelection(0, 7, 7, -1, -1);
}

private void performGo(TestCallbackHelperContainer testCallbackHelperContainer)
throws Throwable {
final InputConnection inputConnection = mConnection;
Expand Down
2 changes: 0 additions & 2 deletions content/public/renderer/render_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,6 @@ class CONTENT_EXPORT RenderView : public IPC::Sender {
// Returns the device scale factor for unit tests.
virtual float GetDeviceScaleFactorForTest() const = 0;

virtual bool HasAddedInputHandler() const = 0;

protected:
~RenderView() override {}

Expand Down
4 changes: 2 additions & 2 deletions content/renderer/input/input_event_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ void InputEventFilter::SetIsFlingingInMainThreadEventQueue(int routing_id,
iter->second->set_is_flinging(is_flinging);
}

void InputEventFilter::RegisterRoutingID(int routing_id) {
void InputEventFilter::DidAddInputHandler(int routing_id) {
base::AutoLock locked(routes_lock_);
routes_.insert(routing_id);
route_queues_[routing_id].reset(new MainThreadEventQueue(routing_id, this));
}

void InputEventFilter::UnregisterRoutingID(int routing_id) {
void InputEventFilter::DidRemoveInputHandler(int routing_id) {
base::AutoLock locked(routes_lock_);
routes_.erase(routing_id);
route_queues_.erase(routing_id);
Expand Down
4 changes: 2 additions & 2 deletions content/renderer/input/input_event_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ class CONTENT_EXPORT InputEventFilter : public InputHandlerManagerClient,
// InputHostMsg_HandleInputEvent_ACK.
//
void SetBoundHandler(const Handler& handler) override;
void RegisterRoutingID(int routing_id) override;
void UnregisterRoutingID(int routing_id) override;
void DidAddInputHandler(int routing_id) override;
void DidRemoveInputHandler(int routing_id) override;
void DidOverscroll(int routing_id,
const DidOverscrollParams& params) override;
void DidStartFlinging(int routing_id) override;
Expand Down
10 changes: 5 additions & 5 deletions content/renderer/input/input_event_filter_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ TEST_F(InputEventFilterTest, Basic) {
EXPECT_EQ(0U, event_recorder_.record_count());
EXPECT_EQ(0U, message_recorder_.message_count());

filter_->RegisterRoutingID(kTestRoutingID);
filter_->DidAddInputHandler(kTestRoutingID);

AddEventsToFilter(filter_.get(), kEvents, arraysize(kEvents));
ASSERT_EQ(arraysize(kEvents), ipc_sink_.message_count());
Expand Down Expand Up @@ -253,7 +253,7 @@ TEST_F(InputEventFilterTest, Basic) {
}

TEST_F(InputEventFilterTest, PreserveRelativeOrder) {
filter_->RegisterRoutingID(kTestRoutingID);
filter_->DidAddInputHandler(kTestRoutingID);
event_recorder_.set_send_to_widget(true);


Expand Down Expand Up @@ -316,7 +316,7 @@ TEST_F(InputEventFilterTest, NonBlockingWheel) {
SyntheticWebMouseWheelEventBuilder::Build(30, 30, 0, 53, 1, false),
};

filter_->RegisterRoutingID(kTestRoutingID);
filter_->DidAddInputHandler(kTestRoutingID);
event_recorder_.set_send_to_widget(true);
event_recorder_.set_passive(true);

Expand Down Expand Up @@ -394,7 +394,7 @@ TEST_F(InputEventFilterTest, NonBlockingTouch) {
kEvents[3].PressPoint(10, 10);
kEvents[3].MovePoint(0, 35, 35);

filter_->RegisterRoutingID(kTestRoutingID);
filter_->DidAddInputHandler(kTestRoutingID);
event_recorder_.set_send_to_widget(true);
event_recorder_.set_passive(true);

Expand Down Expand Up @@ -468,7 +468,7 @@ TEST_F(InputEventFilterTest, IntermingledNonBlockingTouch) {
SyntheticWebTouchEvent kBlockingEvents[1];
kBlockingEvents[0].PressPoint(10, 10);

filter_->RegisterRoutingID(kTestRoutingID);
filter_->DidAddInputHandler(kTestRoutingID);
event_recorder_.set_send_to_widget(true);
event_recorder_.set_passive(true);
AddEventsToFilter(filter_.get(), kEvents, arraysize(kEvents));
Expand Down
37 changes: 2 additions & 35 deletions content/renderer/input/input_handler_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void InputHandlerManager::AddInputHandlerOnCompositorThread(
std::unique_ptr<InputHandlerWrapper> wrapper(new InputHandlerWrapper(
this, routing_id, main_task_runner, input_handler, render_view_impl,
enable_smooth_scrolling, enable_wheel_gestures));
client_->RegisterRoutingID(routing_id);
client_->DidAddInputHandler(routing_id);
if (synchronous_handler_proxy_client_) {
synchronous_handler_proxy_client_->DidAddSynchronousHandlerProxy(
routing_id, wrapper->input_handler_proxy());
Expand All @@ -121,47 +121,14 @@ void InputHandlerManager::RemoveInputHandler(int routing_id) {

TRACE_EVENT0("input", "InputHandlerManager::RemoveInputHandler");

client_->UnregisterRoutingID(routing_id);
client_->DidRemoveInputHandler(routing_id);
if (synchronous_handler_proxy_client_) {
synchronous_handler_proxy_client_->DidRemoveSynchronousHandlerProxy(
routing_id);
}
input_handlers_.erase(routing_id);
}

void InputHandlerManager::RegisterRoutingID(int routing_id) {
if (task_runner_->BelongsToCurrentThread()) {
RegisterRoutingIDOnCompositorThread(routing_id);
} else {
task_runner_->PostTask(
FROM_HERE,
base::Bind(&InputHandlerManager::RegisterRoutingIDOnCompositorThread,
base::Unretained(this), routing_id));
}
}

void InputHandlerManager::RegisterRoutingIDOnCompositorThread(int routing_id) {
DCHECK(task_runner_->BelongsToCurrentThread());
client_->RegisterRoutingID(routing_id);
}

void InputHandlerManager::UnregisterRoutingID(int routing_id) {
if (task_runner_->BelongsToCurrentThread()) {
UnregisterRoutingIDOnCompositorThread(routing_id);
} else {
task_runner_->PostTask(
FROM_HERE,
base::Bind(&InputHandlerManager::UnregisterRoutingIDOnCompositorThread,
base::Unretained(this), routing_id));
}
}

void InputHandlerManager::UnregisterRoutingIDOnCompositorThread(
int routing_id) {
DCHECK(task_runner_->BelongsToCurrentThread());
client_->UnregisterRoutingID(routing_id);
}

void InputHandlerManager::ObserveWheelEventAndResultOnMainThread(
int routing_id,
const blink::WebMouseWheelEvent& wheel_event,
Expand Down
6 changes: 0 additions & 6 deletions content/renderer/input/input_handler_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ class CONTENT_EXPORT InputHandlerManager {
bool enable_smooth_scrolling,
bool enable_wheel_gestures);

void RegisterRoutingID(int routing_id);
void UnregisterRoutingID(int routing_id);

void ObserveWheelEventAndResultOnMainThread(
int routing_id,
const blink::WebMouseWheelEvent& wheel_event,
Expand Down Expand Up @@ -104,9 +101,6 @@ class CONTENT_EXPORT InputHandlerManager {
bool enable_smooth_scrolling,
bool enable_wheel_gestures);

void RegisterRoutingIDOnCompositorThread(int routing_id);
void UnregisterRoutingIDOnCompositorThread(int routing_id);

void ObserveWheelEventAndResultOnCompositorThread(
int routing_id,
const blink::WebMouseWheelEvent& wheel_event,
Expand Down
4 changes: 2 additions & 2 deletions content/renderer/input/input_handler_manager_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class CONTENT_EXPORT InputHandlerManagerClient {
virtual void SetBoundHandler(const Handler& handler) = 0;

// Called from the compositor thread.
virtual void RegisterRoutingID(int routing_id) = 0;
virtual void UnregisterRoutingID(int routing_id) = 0;
virtual void DidAddInputHandler(int routing_id) = 0;
virtual void DidRemoveInputHandler(int routing_id) = 0;
virtual void DidOverscroll(int routing_id,
const DidOverscrollParams& params) = 0;
virtual void DidStartFlinging(int routing_id) = 0;
Expand Down
4 changes: 2 additions & 2 deletions content/renderer/mus/compositor_mus_connection_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ class TestInputHandlerManagerClient

// content::InputHandlerManagerClient:
void SetBoundHandler(const Handler& handler) override {}
void RegisterRoutingID(int routing_id) override {}
void UnregisterRoutingID(int routing_id) override {}
void DidAddInputHandler(int routing_id) override {}
void DidRemoveInputHandler(int routing_id) override {}
void DidOverscroll(int routing_id,
const content::DidOverscrollParams& params) override {}
void DidStartFlinging(int routing_id) override {}
Expand Down
21 changes: 2 additions & 19 deletions content/renderer/render_frame_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@
#include "content/renderer/history_serialization.h"
#include "content/renderer/image_downloader/image_downloader_impl.h"
#include "content/renderer/ime_event_guard.h"
#include "content/renderer/input/input_handler_manager.h"
#include "content/renderer/internal_document_state_data.h"
#include "content/renderer/manifest/manifest_manager.h"
#include "content/renderer/media/audio_device_factory.h"
Expand Down Expand Up @@ -1114,13 +1113,6 @@ RenderFrameImpl::~RenderFrameImpl() {
render_view_->UnregisterVideoHoleFrame(this);
#endif

// Unregister from InputHandlerManager. render_thread may be NULL in tests.
RenderThreadImpl* render_thread = RenderThreadImpl::current();
InputHandlerManager* input_handler_manager =
render_thread ? render_thread->input_handler_manager() : nullptr;
if (input_handler_manager)
input_handler_manager->UnregisterRoutingID(GetRoutingID());

if (is_main_frame_) {
// Ensure the RenderView doesn't point to this object, once it is destroyed.
// TODO(nasko): Add a check that the |main_render_frame_| of |render_view_|
Expand Down Expand Up @@ -1181,15 +1173,6 @@ void RenderFrameImpl::Initialize() {
// We delay calling this until we have the WebFrame so that any observer or
// embedder can call GetWebFrame on any RenderFrame.
GetContentClient()->renderer()->RenderFrameCreated(this);

RenderThreadImpl* render_thread = RenderThreadImpl::current();
// render_thread may be NULL in tests.
InputHandlerManager* input_handler_manager =
render_thread ? render_thread->input_handler_manager() : nullptr;
if (input_handler_manager) {
DCHECK(render_view_->HasAddedInputHandler());
input_handler_manager->RegisterRoutingID(GetRoutingID());
}
}

void RenderFrameImpl::InitializeBlameContext(RenderFrameImpl* parent_frame) {
Expand Down Expand Up @@ -1467,8 +1450,6 @@ bool RenderFrameImpl::OnMessageReceived(const IPC::Message& msg) {
OnExtendSelectionAndDelete)
IPC_MESSAGE_HANDLER(InputMsg_SetCompositionFromExistingText,
OnSetCompositionFromExistingText)
IPC_MESSAGE_HANDLER(InputMsg_SetEditableSelectionOffsets,
OnSetEditableSelectionOffsets)
IPC_MESSAGE_HANDLER(InputMsg_ExecuteNoValueEditCommand,
OnExecuteNoValueEditCommand)
IPC_MESSAGE_HANDLER(FrameMsg_CSSInsertRequest, OnCSSInsertRequest)
Expand All @@ -1481,6 +1462,8 @@ bool RenderFrameImpl::OnMessageReceived(const IPC::Message& msg) {
OnJavaScriptExecuteRequestInIsolatedWorld)
IPC_MESSAGE_HANDLER(FrameMsg_VisualStateRequest,
OnVisualStateRequest)
IPC_MESSAGE_HANDLER(FrameMsg_SetEditableSelectionOffsets,
OnSetEditableSelectionOffsets)
IPC_MESSAGE_HANDLER(FrameMsg_Reload, OnReload)
IPC_MESSAGE_HANDLER(FrameMsg_ReloadLoFiImages, OnReloadLoFiImages)
IPC_MESSAGE_HANDLER(FrameMsg_TextSurroundingSelectionRequest,
Expand Down
Loading

0 comments on commit 18119df

Please sign in to comment.