Merge lp:~osomon/oxide/non-ime-initiated-text-edit into lp:~oxide-developers/oxide/oxide.trunk

Proposed by Olivier Tilloy on 2015-06-15
Status: Needs review
Proposed branch: lp:~osomon/oxide/non-ime-initiated-text-edit
Merge into: lp:~oxide-developers/oxide/oxide.trunk
Diff against target: 418 lines (+207/-18)
14 files modified
patches/notify-text-updates.patch (+135/-0)
patches/series (+2/-0)
patches/update-selection-on-non-ime-text-change.patch (+20/-0)
qt/core/browser/oxide_qt_web_view.cc (+5/-1)
qt/core/browser/oxide_qt_web_view.h (+1/-1)
shared/browser/oxide_render_widget_host_view.cc (+24/-4)
shared/browser/oxide_render_widget_host_view.h (+2/-1)
shared/browser/oxide_render_widget_host_view_delegate.h (+2/-1)
shared/browser/oxide_web_view.cc (+5/-3)
shared/browser/oxide_web_view.h (+2/-1)
shared/browser/oxide_web_view_client.cc (+1/-1)
shared/browser/oxide_web_view_client.h (+1/-1)
shared/port/content/browser/render_widget_host_view_oxide.cc (+4/-2)
shared/port/content/browser/render_widget_host_view_oxide.h (+3/-2)
To merge this branch: bzr merge lp:~osomon/oxide/non-ime-initiated-text-edit
Reviewer Review Type Date Requested Status
Chris Coulson 2015-06-15 Needs Fixing on 2015-08-07
Review via email: mp+261971@code.launchpad.net

Commit message

Reset the input method and update the surrounding text reported to the keyboard if a non IME initiated edit was performed on the currently focused node.

To post a comment you must log in.
1030. By Olivier Tilloy on 2015-07-29

Merge the latest changes from trunk and resolve a conflict.

Chris Coulson (chrisccoulson) wrote :

Thanks, I've left a comment inline

review: Needs Fixing

Unmerged revisions

1030. By Olivier Tilloy on 2015-07-29

Merge the latest changes from trunk and resolve a conflict.

1029. By Michael Sheldon on 2015-06-15

Update the surrounding text reported to the keyboard when a text field is changed programmatically.

1028. By Olivier Tilloy on 2015-06-15

Merge the latest changes from trunk and resolve a conflict.

1027. By Olivier Tilloy on 2015-05-28

Refresh patch.

1026. By Olivier Tilloy on 2015-05-28

Merge the latest changes from trunk and resolve a few conflicts.

1025. By Olivier Tilloy on 2015-05-18

Merge the latest changes from trunk and resolve a couple of conflicts.

1024. By Olivier Tilloy on 2015-03-30

Reset the input method if a non IME initiated edit was performed on the currently focused node.

1023. By Olivier Tilloy on 2015-03-30

Add a patch to notify of text updates that were not triggered by user input in the focused element (e.g. programatically clearing a text field).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'patches/notify-text-updates.patch'
2--- patches/notify-text-updates.patch 1970-01-01 00:00:00 +0000
3+++ patches/notify-text-updates.patch 2015-07-29 16:58:05 +0000
4@@ -0,0 +1,135 @@
5+# Description: notify of text updates in the focused element
6+# by activating the Android code in Oxide builds
7+# Bug: https://launchpad.net/bugs/1384357
8+# Author: Olivier Tilloy <olivier.tilloy@canonical.com>
9+
10+diff -r 5e65632068c7 content/common/view_messages.h
11+--- a/content/common/view_messages.h Thu May 28 20:58:31 2015 +0200
12++++ b/content/common/view_messages.h Thu May 28 21:02:38 2015 +0200
13+@@ -945,11 +945,13 @@
14+ bool /* animate */)
15+
16+ IPC_MESSAGE_ROUTED0(ViewMsg_ShowImeIfNeeded)
17++#endif
18+
19+ // Sent by the browser when an IME update that requires acknowledgement has been
20+ // processed on the browser side.
21+ IPC_MESSAGE_ROUTED0(ViewMsg_ImeEventAck)
22+
23++#if defined(OS_ANDROID)
24+ // Extracts the data at the given rect, returning it through the
25+ // ViewHostMsg_SmartClipDataExtracted IPC.
26+ IPC_MESSAGE_ROUTED1(ViewMsg_ExtractSmartClipData,
27+diff -r 5e65632068c7 content/renderer/render_widget.cc
28+--- a/content/renderer/render_widget.cc Thu May 28 20:58:31 2015 +0200
29++++ b/content/renderer/render_widget.cc Thu May 28 21:02:38 2015 +0200
30+@@ -508,9 +508,9 @@
31+ device_scale_factor_(screen_info_.deviceScaleFactor),
32+ current_event_latency_info_(NULL),
33+ next_output_surface_id_(0),
34+-#if defined(OS_ANDROID)
35+ text_field_is_dirty_(false),
36+ outstanding_ime_acks_(0),
37++#if defined(OS_ANDROID)
38+ body_background_color_(SK_ColorWHITE),
39+ #endif
40+ popup_origin_scale_for_emulation_(0.f),
41+@@ -749,8 +749,8 @@
42+ IPC_MESSAGE_HANDLER(ViewMsg_SetSurfaceIdNamespace, OnSetSurfaceIdNamespace)
43+ #if defined(OS_ANDROID)
44+ IPC_MESSAGE_HANDLER(ViewMsg_ShowImeIfNeeded, OnShowImeIfNeeded)
45++#endif
46+ IPC_MESSAGE_HANDLER(ViewMsg_ImeEventAck, OnImeEventAck)
47+-#endif
48+ IPC_MESSAGE_UNHANDLED(handled = false)
49+ IPC_END_MESSAGE_MAP()
50+ return handled;
51+@@ -1768,7 +1768,6 @@
52+ #endif
53+ }
54+
55+-#if defined(OS_ANDROID)
56+ void RenderWidget::IncrementOutstandingImeEventAcks() {
57+ ++outstanding_ime_acks_;
58+ }
59+@@ -1777,10 +1776,9 @@
60+ --outstanding_ime_acks_;
61+ DCHECK(outstanding_ime_acks_ >= 0);
62+ }
63+-#endif
64+
65+ bool RenderWidget::ShouldHandleImeEvent() {
66+-#if defined(OS_ANDROID)
67++#if 1
68+ return !!webwidget_ && outstanding_ime_acks_ == 0;
69+ #else
70+ return !!webwidget_;
71+@@ -1976,9 +1974,7 @@
72+ (text_input_type_ != new_type ||
73+ text_input_info_ != new_info ||
74+ can_compose_inline_ != new_can_compose_inline)
75+-#if defined(OS_ANDROID)
76+ || text_field_is_dirty_
77+-#endif
78+ ) {
79+ ViewHostMsg_TextInputState_Params p;
80+ p.type = new_type;
81+@@ -1993,13 +1989,11 @@
82+ #if defined(USE_AURA)
83+ p.is_non_ime_change = true;
84+ #endif
85+-#if defined(OS_ANDROID)
86+ p.is_non_ime_change = (change_source == FROM_NON_IME) ||
87+ text_field_is_dirty_;
88+ if (p.is_non_ime_change)
89+ IncrementOutstandingImeEventAcks();
90+ text_field_is_dirty_ = false;
91+-#endif
92+ #if defined(USE_AURA)
93+ Send(new ViewHostMsg_TextInputTypeChanged(routing_id(),
94+ new_type,
95+@@ -2373,9 +2367,7 @@
96+ }
97+
98+ void RenderWidget::didUpdateTextOfFocusedElementByNonUserInput() {
99+-#if defined(OS_ANDROID)
100+ text_field_is_dirty_ = true;
101+-#endif
102+ }
103+
104+ bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const {
105+diff -r 5e65632068c7 content/renderer/render_widget.h
106+--- a/content/renderer/render_widget.h Thu May 28 20:58:31 2015 +0200
107++++ b/content/renderer/render_widget.h Thu May 28 21:02:38 2015 +0200
108+@@ -444,7 +444,6 @@
109+ void OnShowImeIfNeeded();
110+ void OnSetSurfaceIdNamespace(uint32_t surface_id_namespace);
111+
112+-#if defined(OS_ANDROID)
113+ // Whenever an IME event that needs an acknowledgement is sent to the browser,
114+ // the number of outstanding IME events that needs acknowledgement should be
115+ // incremented. All IME events will be dropped until we receive an ack from
116+@@ -453,7 +452,6 @@
117+
118+ // Called by the browser process for every required IME acknowledgement.
119+ void OnImeEventAck();
120+-#endif
121+
122+ // Notify the compositor about a change in viewport size. This should be
123+ // used only with auto resize mode WebWidgets, as normal WebWidgets should
124+@@ -768,7 +766,6 @@
125+
126+ uint32 next_output_surface_id_;
127+
128+-#if defined(OS_ANDROID)
129+ // Indicates value in the focused text field is in dirty state, i.e. modified
130+ // by script etc., not by user input.
131+ bool text_field_is_dirty_;
132+@@ -778,6 +775,7 @@
133+ // browser. If this value is not 0 IME events will be dropped.
134+ int outstanding_ime_acks_;
135+
136++#if defined(OS_ANDROID)
137+ // The background color of the document body element. This is used as the
138+ // default background color for filling the screen areas for which we don't
139+ // have the actual content.
140
141=== modified file 'patches/series'
142--- patches/series 2015-06-29 11:25:34 +0000
143+++ patches/series 2015-07-29 16:58:05 +0000
144@@ -34,3 +34,5 @@
145 implement-webrtc-get-cpu-features-arm.patch
146 enable-optional-neon-for-skia.patch
147 add-suggested-filename-to-download-starting-resource-delegate.patch
148+notify-text-updates.patch
149+update-selection-on-non-ime-text-change.patch
150
151=== added file 'patches/update-selection-on-non-ime-text-change.patch'
152--- patches/update-selection-on-non-ime-text-change.patch 1970-01-01 00:00:00 +0000
153+++ patches/update-selection-on-non-ime-text-change.patch 2015-07-29 16:58:05 +0000
154@@ -0,0 +1,20 @@
155+# Description: Update the surrounding text reported to the input method
156+# framework when text has been changed programmatically
157+# Bug: https://launchpad.net/bugs/1384357
158+# Author: Michael Sheldon <michael.sheldon@canonical.com>
159+diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
160+--- a/content/renderer/render_widget.cc
161++++ b/content/renderer/render_widget.cc
162+@@ -1986,8 +1986,11 @@ void RenderWidget::UpdateTextInputState(
163+ #endif
164+ p.is_non_ime_change = (change_source == FROM_NON_IME) ||
165+ text_field_is_dirty_;
166+- if (p.is_non_ime_change)
167++ if (p.is_non_ime_change) {
168+ IncrementOutstandingImeEventAcks();
169++ FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_,
170++ didChangeSelection(false));
171++ }
172+ text_field_is_dirty_ = false;
173+ #if defined(USE_AURA)
174+ Send(new ViewHostMsg_TextInputTypeChanged(routing_id(),
175
176=== modified file 'qt/core/browser/oxide_qt_web_view.cc'
177--- qt/core/browser/oxide_qt_web_view.cc 2015-07-02 11:22:12 +0000
178+++ qt/core/browser/oxide_qt_web_view.cc 2015-07-29 16:58:05 +0000
179@@ -870,11 +870,15 @@
180 client_->EvictCurrentFrame();
181 }
182
183-void WebView::TextInputStateChanged() {
184+void WebView::TextInputStateChanged(bool is_non_ime_change) {
185 if (!HasFocus()) {
186 return;
187 }
188
189+ if (is_non_ime_change) {
190+ QGuiApplication::inputMethod()->reset();
191+ }
192+
193 if (view_->text_input_type() != ui::TEXT_INPUT_TYPE_NONE) {
194 QGuiApplication::inputMethod()->update(
195 static_cast<Qt::InputMethodQueries>(Qt::ImQueryInput | Qt::ImHints));
196
197=== modified file 'qt/core/browser/oxide_qt_web_view.h'
198--- qt/core/browser/oxide_qt_web_view.h 2015-06-17 17:09:45 +0000
199+++ qt/core/browser/oxide_qt_web_view.h 2015-07-29 16:58:05 +0000
200@@ -158,7 +158,7 @@
201 oxide::FilePicker* CreateFilePicker(content::RenderViewHost* rvh) override;
202 void SwapCompositorFrame() override;
203 void EvictCurrentFrame() override;
204- void TextInputStateChanged() override;
205+ void TextInputStateChanged(bool is_non_ime_change) override;
206 void FocusedNodeChanged() override;
207 void SelectionBoundsChanged() override;
208 void ImeCancelComposition() override;
209
210=== modified file 'shared/browser/oxide_render_widget_host_view.cc'
211--- shared/browser/oxide_render_widget_host_view.cc 2015-05-28 23:51:39 +0000
212+++ shared/browser/oxide_render_widget_host_view.cc 2015-07-29 16:58:05 +0000
213@@ -18,6 +18,7 @@
214 #include "oxide_render_widget_host_view.h"
215
216 #include "base/bind.h"
217+#include "base/callback_helpers.h"
218 #include "base/command_line.h"
219 #include "base/logging.h"
220 #include "base/memory/scoped_vector.h"
221@@ -29,6 +30,7 @@
222 #include "cc/quads/render_pass.h"
223 #include "cc/trees/layer_tree_settings.h"
224 #include "content/browser/renderer_host/render_widget_host_impl.h"
225+#include "content/common/view_messages.h"
226 #include "content/public/browser/browser_thread.h"
227 #include "content/public/browser/render_process_host.h"
228 #include "content/public/common/content_switches.h"
229@@ -48,6 +50,15 @@
230 #include "oxide_renderer_frame_evictor.h"
231 #include "oxide_render_widget_host_view_delegate.h"
232
233+namespace {
234+
235+// Sends an acknowledgement to the renderer of a processed IME event.
236+void SendImeEventAck(content::RenderWidgetHostImpl* host) {
237+ host->Send(new ViewMsg_ImeEventAck(host->GetRoutingID()));
238+}
239+
240+}
241+
242 namespace oxide {
243
244 namespace {
245@@ -80,15 +91,23 @@
246
247 void RenderWidgetHostView::OnTextInputStateChanged(
248 ui::TextInputType type,
249- bool show_ime_if_needed) {
250+ bool show_ime_if_needed,
251+ bool is_non_ime_change) {
252+ base::ScopedClosureRunner ack_caller;
253+ if (is_non_ime_change) {
254+ ack_caller.Reset(base::Bind(&SendImeEventAck, host_));
255+ }
256+
257 if (type != current_text_input_type_ ||
258- show_ime_if_needed != show_ime_if_needed_) {
259+ show_ime_if_needed != show_ime_if_needed_ ||
260+ is_non_ime_change) {
261 current_text_input_type_ = type;
262 show_ime_if_needed_ = show_ime_if_needed;
263
264 if (delegate_) {
265 delegate_->TextInputStateChanged(current_text_input_type_,
266- show_ime_if_needed_);
267+ show_ime_if_needed_,
268+ is_non_ime_change);
269 }
270 }
271 }
272@@ -661,7 +680,8 @@
273
274 UpdateCursorOnWebView();
275 delegate_->TextInputStateChanged(current_text_input_type_,
276- show_ime_if_needed_);
277+ show_ime_if_needed_,
278+ true);
279 delegate_->FocusedNodeChanged(focused_node_is_editable_);
280 delegate_->SelectionBoundsChanged(caret_rect_,
281 selection_cursor_position_,
282
283=== modified file 'shared/browser/oxide_render_widget_host_view.h'
284--- shared/browser/oxide_render_widget_host_view.h 2015-05-27 20:56:59 +0000
285+++ shared/browser/oxide_render_widget_host_view.h 2015-07-29 16:58:05 +0000
286@@ -93,7 +93,8 @@
287 private:
288 // content::RenderWidgetHostViewOxide implementation
289 void OnTextInputStateChanged(ui::TextInputType type,
290- bool show_ime_if_needed) final;
291+ bool show_ime_if_needed,
292+ bool is_non_ime_change) final;
293 void OnSelectionBoundsChanged(const gfx::Rect& anchor_rect,
294 const gfx::Rect& focus_rect,
295 bool is_anchor_first) final;
296
297=== modified file 'shared/browser/oxide_render_widget_host_view_delegate.h'
298--- shared/browser/oxide_render_widget_host_view_delegate.h 2015-05-14 15:37:57 +0000
299+++ shared/browser/oxide_render_widget_host_view_delegate.h 2015-07-29 16:58:05 +0000
300@@ -45,7 +45,8 @@
301 virtual void UpdateCursor(const content::WebCursor& cursor) = 0;
302
303 virtual void TextInputStateChanged(ui::TextInputType type,
304- bool show_ime_if_needed) = 0;
305+ bool show_ime_if_needed,
306+ bool is_non_ime_change) = 0;
307
308 virtual void FocusedNodeChanged(bool is_editable_node) = 0;
309
310
311=== modified file 'shared/browser/oxide_web_view.cc'
312--- shared/browser/oxide_web_view.cc 2015-07-28 16:16:53 +0000
313+++ shared/browser/oxide_web_view.cc 2015-07-29 16:58:05 +0000
314@@ -441,16 +441,18 @@
315 }
316
317 void WebView::TextInputStateChanged(ui::TextInputType type,
318- bool show_ime_if_needed) {
319+ bool show_ime_if_needed,
320+ bool is_non_ime_change) {
321 if (type == text_input_type_ &&
322- show_ime_if_needed == show_ime_if_needed_) {
323+ show_ime_if_needed == show_ime_if_needed_ &&
324+ !is_non_ime_change) {
325 return;
326 }
327
328 text_input_type_ = type;
329 show_ime_if_needed_ = show_ime_if_needed;
330
331- client_->TextInputStateChanged();
332+ client_->TextInputStateChanged(is_non_ime_change);
333 }
334
335 void WebView::FocusedNodeChanged(bool is_editable_node) {
336
337=== modified file 'shared/browser/oxide_web_view.h'
338--- shared/browser/oxide_web_view.h 2015-07-07 23:18:27 +0000
339+++ shared/browser/oxide_web_view.h 2015-07-29 16:58:05 +0000
340@@ -389,7 +389,8 @@
341 void EvictCurrentFrame() final;
342 void UpdateCursor(const content::WebCursor& cursor) final;
343 void TextInputStateChanged(ui::TextInputType type,
344- bool show_ime_if_needed) final;
345+ bool show_ime_if_needed,
346+ bool is_non_ime_change) final;
347 void FocusedNodeChanged(bool is_editable_node) final;
348 void ImeCancelComposition() final;
349 void SelectionBoundsChanged(const gfx::Rect& caret_rect,
350
351=== modified file 'shared/browser/oxide_web_view_client.cc'
352--- shared/browser/oxide_web_view_client.cc 2015-06-17 17:09:45 +0000
353+++ shared/browser/oxide_web_view_client.cc 2015-07-29 16:58:05 +0000
354@@ -142,7 +142,7 @@
355
356 void WebViewClient::EvictCurrentFrame() {}
357
358-void WebViewClient::TextInputStateChanged() {}
359+void WebViewClient::TextInputStateChanged(bool is_non_ime_change) {}
360
361 void WebViewClient::FocusedNodeChanged() {}
362
363
364=== modified file 'shared/browser/oxide_web_view_client.h'
365--- shared/browser/oxide_web_view_client.h 2015-06-17 17:09:45 +0000
366+++ shared/browser/oxide_web_view_client.h 2015-07-29 16:58:05 +0000
367@@ -178,7 +178,7 @@
368 // - The implementations of some of these only touch process-global
369 // stuff - should we have an InputMethod singleton in shared/
370 // rather than dumping it all in WebView?
371- virtual void TextInputStateChanged();
372+ virtual void TextInputStateChanged(bool is_non_ime_change);
373
374 virtual void FocusedNodeChanged();
375
376
377=== modified file 'shared/port/content/browser/render_widget_host_view_oxide.cc'
378--- shared/port/content/browser/render_widget_host_view_oxide.cc 2014-10-27 01:38:55 +0000
379+++ shared/port/content/browser/render_widget_host_view_oxide.cc 2015-07-29 16:58:05 +0000
380@@ -1,5 +1,5 @@
381 // vim:expandtab:shiftwidth=2:tabstop=2:
382-// Copyright (C) 2013-2014 Canonical Ltd.
383+// Copyright (C) 2013-2015 Canonical Ltd.
384
385 // This library is free software; you can redistribute it and/or
386 // modify it under the terms of the GNU Lesser General Public
387@@ -35,7 +35,9 @@
388
389 void RenderWidgetHostViewOxide::OnTextInputStateChangedThunk(
390 const ViewHostMsg_TextInputState_Params& params) {
391- OnTextInputStateChanged(params.type, params.show_ime_if_needed);
392+ OnTextInputStateChanged(params.type,
393+ params.show_ime_if_needed,
394+ params.is_non_ime_change);
395 }
396
397 void RenderWidgetHostViewOxide::SelectionBoundsChanged(
398
399=== modified file 'shared/port/content/browser/render_widget_host_view_oxide.h'
400--- shared/port/content/browser/render_widget_host_view_oxide.h 2014-10-27 01:38:55 +0000
401+++ shared/port/content/browser/render_widget_host_view_oxide.h 2015-07-29 16:58:05 +0000
402@@ -1,5 +1,5 @@
403 // vim:expandtab:shiftwidth=2:tabstop=2:
404-// Copyright (C) 2013-2014 Canonical Ltd.
405+// Copyright (C) 2013-2015 Canonical Ltd.
406
407 // This library is free software; you can redistribute it and/or
408 // modify it under the terms of the GNU Lesser General Public
409@@ -48,7 +48,8 @@
410 bool OnMessageReceived(const IPC::Message& msg) final;
411
412 virtual void OnTextInputStateChanged(ui::TextInputType type,
413- bool show_ime_if_needed) = 0;
414+ bool show_ime_if_needed,
415+ bool is_non_ime_change) = 0;
416 virtual void OnSelectionBoundsChanged(const gfx::Rect& anchor_rect,
417 const gfx::Rect& focus_rect,
418 bool is_anchor_first) = 0;

Subscribers

People subscribed via source and target branches