Commit 5f6b70eb authored by ekaramad's avatar ekaramad Committed by Commit bot

Track composition range information on the browser side (Android)

This CL implements the logic to track composition range information
from several RenderWidgets on the same page (i.e., pages with OOPIFs) for Android platforms.

The tracking logic is now shared between RenderWidgetHostViewBase and TextInputManager,
while RenderWidgetHostViewAndroid observes TextInputManager for any
changes to the range info in one of the RenderWidgets in the page.
This has already been implemented for Mac
(https://codereview.chromium.org/2235283003/) and Aura
(https://codereview.chromium.org/2132633002/) platforms.

An interactive test is now activated on all platform which will be
handy if/when interactive browser tests run on Android.

BUG=578168, 602723

Review-Url: https://codereview.chromium.org/2612423002
Cr-Commit-Position: refs/heads/master@{#443577}
parent 9d7ae4d5
......@@ -710,10 +710,6 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest,
}
}
// TODO(ekaramad): Some of the following tests should be active on Android as
// well. Enable them when the corresponding feature is implemented for Android
// (https://crbug.com/602723).
#if !defined(OS_ANDROID)
// This test creates a page with multiple child frames and adds an <input> to
// each frame. Then, sequentially, each <input> is focused by sending a tab key.
// Then, after |TextInputState.type| for a view is changed to text, the test
......@@ -751,6 +747,10 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessTextInputManagerTest,
send_tab_set_composition_wait_for_bounds_change(view);
}
// TODO(ekaramad): Some of the following tests should be active on Android as
// well. Enable them when the corresponding feature is implemented for Android
// (https://crbug.com/602723).
#if !defined(OS_ANDROID)
// This test creates a page with multiple child frames and adds an <input> to
// each frame. Then, sequentially, each <input> is focused by sending a tab key.
// Then, after |TextInputState.type| for a view is changed to text, another key
......
......@@ -786,6 +786,22 @@ void RenderWidgetHostViewAndroid::OnUpdateTextInputStateCalled(
state.is_non_ime_change);
}
void RenderWidgetHostViewAndroid::OnImeCompositionRangeChanged(
TextInputManager* text_input_manager,
RenderWidgetHostViewBase* updated_view) {
DCHECK_EQ(text_input_manager_, text_input_manager);
const TextInputManager::CompositionRangeInfo* info =
text_input_manager_->GetCompositionRangeInfo();
if (!info)
return;
std::vector<gfx::RectF> character_bounds;
for (const gfx::Rect& rect : info->character_bounds)
character_bounds.emplace_back(rect);
ime_adapter_android_.SetCharacterBounds(character_bounds);
}
void RenderWidgetHostViewAndroid::UpdateBackgroundColor(SkColor color) {
if (cached_background_color_ == color)
return;
......@@ -908,15 +924,6 @@ void RenderWidgetHostViewAndroid::ImeCancelComposition() {
ime_adapter_android_.CancelComposition();
}
void RenderWidgetHostViewAndroid::ImeCompositionRangeChanged(
const gfx::Range& range,
const std::vector<gfx::Rect>& character_bounds) {
std::vector<gfx::RectF> character_bounds_float;
for (const gfx::Rect& rect : character_bounds) {
character_bounds_float.emplace_back(rect);
}
ime_adapter_android_.SetCharacterBounds(character_bounds_float);
}
void RenderWidgetHostViewAndroid::FocusedNodeChanged(
bool is_editable_node,
......
......@@ -105,9 +105,6 @@ class CONTENT_EXPORT RenderWidgetHostViewAndroid
void UpdateCursor(const WebCursor& cursor) override;
void SetIsLoading(bool is_loading) override;
void ImeCancelComposition() override;
void ImeCompositionRangeChanged(
const gfx::Range& range,
const std::vector<gfx::Rect>& character_bounds) override;
void FocusedNodeChanged(bool is_editable_node,
const gfx::Rect& node_bounds_in_screen) override;
void RenderProcessGone(base::TerminationStatus status,
......@@ -253,6 +250,9 @@ class CONTENT_EXPORT RenderWidgetHostViewAndroid
void OnUpdateTextInputStateCalled(TextInputManager* text_input_manager,
RenderWidgetHostViewBase* updated_view,
bool did_change_state) override;
void OnImeCompositionRangeChanged(
TextInputManager* text_input_manager,
RenderWidgetHostViewBase* updated_view) override;
private:
void RunAckCallbacks();
......
......@@ -488,13 +488,10 @@ void RenderWidgetHostViewBase::ImeCancelComposition() {
void RenderWidgetHostViewBase::ImeCompositionRangeChanged(
const gfx::Range& range,
const std::vector<gfx::Rect>& character_bounds) {
// TODO(ekaramad): Use TextInputManager code paths for IME on other platforms.
#if !defined(OS_ANDROID)
if (GetTextInputManager()) {
GetTextInputManager()->ImeCompositionRangeChanged(this, range,
character_bounds);
}
#endif
}
TextInputManager* RenderWidgetHostViewBase::GetTextInputManager() {
......
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