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

Unified Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

Issue 342143004: Defect 248426: Speak rendered text when no selection is made on Mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Using WebLocalFrame::contentAsText() for fetching rendered text Created 6 years, 6 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/browser/renderer_host/render_widget_host_view_mac.h ('k') | content/common/view_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/render_widget_host_view_mac.mm
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm
index dce9a5eb1710d8043513812c5f27338d1d4be664..cb62dff10d09b12cd9e3a79c8d9b1b5088cddcea 100644
--- a/content/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
@@ -470,7 +470,6 @@ RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget)
// |GetNativeView()| into the view hierarchy right after calling us.
cocoa_view_ = [[[RenderWidgetHostViewCocoa alloc]
initWithRenderWidgetHostViewMac:this] autorelease];
-
background_layer_.reset([[CALayer alloc] init]);
[background_layer_
setBackgroundColor:CGColorGetConstantColor(kCGColorWhite)];
@@ -634,6 +633,8 @@ bool RenderWidgetHostViewMac::OnMessageReceived(const IPC::Message& message) {
IPC_BEGIN_MESSAGE_MAP(RenderWidgetHostViewMac, message)
IPC_MESSAGE_HANDLER(ViewHostMsg_PluginFocusChanged, OnPluginFocusChanged)
IPC_MESSAGE_HANDLER(ViewHostMsg_StartPluginIme, OnStartPluginIme)
+ IPC_MESSAGE_HANDLER(ViewMsg_GetRenderedTextCompleted,
+ OnGetRenderedTextCompleted)
Alexei Svitkine (slow) 2014/06/23 14:35:15 Nit: Align.
sarka 2014/06/25 05:16:47 Done.
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
@@ -1060,6 +1061,14 @@ bool RenderWidgetHostViewMac::SupportsSpeech() const {
}
void RenderWidgetHostViewMac::SpeakSelection() {
+ if (selected_text_.empty()) {
+ if (render_widget_host_) {
Alexei Svitkine (slow) 2014/06/23 14:35:15 Nit: Combine with previous if.
sarka 2014/06/25 05:16:47 Done.
+ // Route an IPC message to get content as text for a web contents.
+ render_widget_host_->Send(new ViewMsg_GetRenderedText(
+ render_widget_host_->GetRoutingID()));
+ return;
+ }
+ }
if ([NSApp respondsToSelector:@selector(speakString:)])
[NSApp speakString:base::SysUTF8ToNSString(selected_text_)];
}
@@ -1070,6 +1079,9 @@ bool RenderWidgetHostViewMac::IsSpeaking() const {
}
void RenderWidgetHostViewMac::StopSpeaking() {
+ // Clear selected text when StopSpeaking is called
Alexei Svitkine (slow) 2014/06/23 14:35:16 Why? |selected_text_| is supposed to be tracking w
sarka 2014/06/25 05:16:47 Done.
+ if (selected_text_.size())
+ selected_text_.clear();
if ([NSApp respondsToSelector:@selector(stopSpeaking:)])
[NSApp stopSpeaking:cocoa_view_];
}
@@ -2051,6 +2063,16 @@ void RenderWidgetHostViewMac::OnStartPluginIme() {
[cocoa_view_ setPluginImeActive:YES];
}
+void RenderWidgetHostViewMac::OnGetRenderedTextCompleted(const std::string& text) {
Alexei Svitkine (slow) 2014/06/23 14:35:15 Nit: This is over 80 chars, wrap at the (
sarka 2014/06/25 05:16:48 Done.
+ // Let TTS speak the text returned from call back
+ if (text.empty())
+ return;
+
+ if ([NSApp respondsToSelector:@selector(speakString:)])
+ [NSApp speakString:base::SysUTF8ToNSString(text)];
Alexei Svitkine (slow) 2014/06/23 14:35:15 Nit: Indent 2 less.
sarka 2014/06/25 05:16:47 Done.
+
Alexei Svitkine (slow) 2014/06/23 14:35:15 Nit: Remove empty line.
sarka 2014/06/25 05:16:47 Done.
+}
+
gfx::Rect RenderWidgetHostViewMac::GetScaledOpenGLPixelRect(
const gfx::Rect& rect) {
gfx::Rect src_gl_subrect = rect;
@@ -2279,7 +2301,6 @@ void RenderWidgetHostViewMac::AcceleratedLayerDidDrawFrame(bool succeeded) {
focusedPluginIdentifier_ = -1;
renderWidgetHostView_->backing_store_scale_factor_ =
ui::GetScaleFactorForNativeView(self);
-
Alexei Svitkine (slow) 2014/06/23 14:35:15 Nit: Revert unnecessary whitespace change.
sarka 2014/06/25 05:16:47 Done.
// OpenGL support:
if ([self respondsToSelector:
@selector(setWantsBestResolutionOpenGLSurface:)]) {
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_mac.h ('k') | content/common/view_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698