Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1337)

Unified Diff: content/renderer/render_widget.cc

Issue 2608293002: [reland, refactor] - Move textInputInfo() and textInputType() from WebWidget to WebInputMethodContr… (Closed)
Patch Set: Addressing wjmaclean@'s comments Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/render_widget.h ('k') | content/renderer/render_widget_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_widget.cc
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index 4c0fda13bb72976e3dd52db55248cf0bf05495d2..c1bfdf40db9bbcda884934e860d1f0ee5c94f568 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -661,6 +661,10 @@ void RenderWidget::SendOrCrash(IPC::Message* message) {
CHECK(closing_ || result) << "Failed to send message";
}
+bool RenderWidget::ShouldHandleImeEvents() const {
+ return GetWebWidget()->isWebFrameWidget() && has_focus_;
+}
+
void RenderWidget::SetWindowRectSynchronously(
const gfx::Rect& new_window_rect) {
ResizeParams params;
@@ -1034,8 +1038,8 @@ void RenderWidget::UpdateTextInputState(ShowIme show_ime,
return; // Not considered as a text input field in WebKit/Chromium.
blink::WebTextInputInfo new_info;
- if (GetWebWidget())
- new_info = GetWebWidget()->textInputInfo();
+ if (auto* controller = GetInputMethodController())
+ new_info = controller->textInputInfo();
const ui::TextInputMode new_mode =
ConvertWebTextInputMode(new_info.inputMode);
@@ -1504,6 +1508,9 @@ void RenderWidget::OnImeSetComposition(
const std::vector<WebCompositionUnderline>& underlines,
const gfx::Range& replacement_range,
int selection_start, int selection_end) {
+ if (!ShouldHandleImeEvents())
+ return;
+
#if BUILDFLAG(ENABLE_PLUGINS)
if (focused_pepper_plugin_) {
focused_pepper_plugin_->render_frame()->OnImeSetComposition(
@@ -1535,6 +1542,9 @@ void RenderWidget::OnImeSetComposition(
void RenderWidget::OnImeCommitText(const base::string16& text,
const gfx::Range& replacement_range,
int relative_cursor_pos) {
+ if (!ShouldHandleImeEvents())
+ return;
+
#if BUILDFLAG(ENABLE_PLUGINS)
if (focused_pepper_plugin_) {
focused_pepper_plugin_->render_frame()->OnImeCommitText(
@@ -1558,6 +1568,9 @@ void RenderWidget::OnImeCommitText(const base::string16& text,
}
void RenderWidget::OnImeFinishComposingText(bool keep_selection) {
+ if (!ShouldHandleImeEvents())
+ return;
+
#if BUILDFLAG(ENABLE_PLUGINS)
if (focused_pepper_plugin_) {
focused_pepper_plugin_->render_frame()->OnImeFinishComposingText(
@@ -1729,8 +1742,8 @@ ui::TextInputType RenderWidget::GetTextInputType() {
if (focused_pepper_plugin_)
return focused_pepper_plugin_->text_input_type();
#endif
- if (GetWebWidget())
- return ConvertWebTextInputType(GetWebWidget()->textInputType());
+ if (auto* controller = GetInputMethodController())
+ return ConvertWebTextInputType(controller->textInputType());
return ui::TEXT_INPUT_TYPE_NONE;
}
@@ -2111,7 +2124,8 @@ void RenderWidget::didHandleGestureEvent(
UpdateTextInputState(ShowIme::IF_NEEDED, ChangeSource::FROM_NON_IME);
} else if (event.type == WebInputEvent::GestureLongPress) {
DCHECK(GetWebWidget());
- if (GetWebWidget()->textInputInfo().value.isEmpty())
+ blink::WebInputMethodController* controller = GetInputMethodController();
+ if (!controller || controller->textInputInfo().value.isEmpty())
UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME);
else
UpdateTextInputState(ShowIme::IF_NEEDED, ChangeSource::FROM_NON_IME);
@@ -2124,7 +2138,9 @@ void RenderWidget::didHandleGestureEvent(
// TODO(estade): hit test the event against focused node to make sure
// the tap actually hit the focused node.
- blink::WebTextInputType text_input_type = GetWebWidget()->textInputType();
+ blink::WebInputMethodController* controller = GetInputMethodController();
+ blink::WebTextInputType text_input_type =
+ controller ? controller->textInputType() : blink::WebTextInputTypeNone;
Send(new ViewHostMsg_FocusedNodeTouched(
routing_id_, text_input_type != blink::WebTextInputTypeNone));
« no previous file with comments | « content/renderer/render_widget.h ('k') | content/renderer/render_widget_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698