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

Unified Diff: content/renderer/render_view_impl.cc

Issue 2703643004: [TTS] Add an ACK message to SelectWordAroundCaret. (Closed)
Patch Set: Reworked the core code to always return an ACK and check for a null frame. Created 3 years, 7 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/public/android/java/src/org/chromium/content/browser/SmartSelectionClient.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_view_impl.cc
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index 80eba094cebbfc955babe931fb9559c6f4c41477..b6f0c7c31ef365b69fe39fad61ff5914551bd417 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -1280,12 +1280,28 @@ bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) {
}
void RenderViewImpl::OnSelectWordAroundCaret() {
- if (!webview())
- return;
+ // Set default values for the ACK
+ bool did_select = false;
+ int start_adjust = 0;
+ int end_adjust = 0;
- input_handler_->set_handling_input_event(true);
- webview()->FocusedFrame()->SelectWordAroundCaret();
- input_handler_->set_handling_input_event(false);
+ if (webview()) {
+ auto* focused_frame = GetWebView()->FocusedFrame();
aelias_OOO_until_Jul13 2017/05/15 17:46:20 nit: please avoid 'auto' here, type is likely not
Donn Denman 2017/05/15 21:13:14 Done.
+ if (focused_frame) {
+ input_handler_->set_handling_input_event(true);
+ blink::WebRange initial_range = focused_frame->SelectionRange();
+ did_select = focused_frame->SelectWordAroundCaret();
+ if (did_select) {
+ blink::WebRange adjusted_range = focused_frame->SelectionRange();
+ start_adjust =
+ adjusted_range.StartOffset() - initial_range.StartOffset();
+ end_adjust = adjusted_range.EndOffset() - initial_range.EndOffset();
+ }
+ input_handler_->set_handling_input_event(false);
+ }
+ }
+ Send(new ViewHostMsg_SelectWordAroundCaretAck(GetRoutingID(), did_select,
+ start_adjust, end_adjust));
}
void RenderViewImpl::OnUpdateTargetURLAck() {
« no previous file with comments | « content/public/android/java/src/org/chromium/content/browser/SmartSelectionClient.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698