Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h" |
| 6 | 6 |
| 7 #import <objc/runtime.h> | 7 #import <objc/runtime.h> |
| 8 #include <OpenGL/gl.h> | 8 #include <OpenGL/gl.h> |
| 9 #include <QuartzCore/QuartzCore.h> | 9 #include <QuartzCore/QuartzCore.h> |
| 10 | 10 |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 732 DestroyCompositedIOSurfaceLayer(kRemoveLayerFromHierarchy); | 732 DestroyCompositedIOSurfaceLayer(kRemoveLayerFromHierarchy); |
| 733 compositing_iosurface_ = NULL; | 733 compositing_iosurface_ = NULL; |
| 734 compositing_iosurface_context_ = NULL; | 734 compositing_iosurface_context_ = NULL; |
| 735 } | 735 } |
| 736 | 736 |
| 737 bool RenderWidgetHostViewMac::OnMessageReceived(const IPC::Message& message) { | 737 bool RenderWidgetHostViewMac::OnMessageReceived(const IPC::Message& message) { |
| 738 bool handled = true; | 738 bool handled = true; |
| 739 IPC_BEGIN_MESSAGE_MAP(RenderWidgetHostViewMac, message) | 739 IPC_BEGIN_MESSAGE_MAP(RenderWidgetHostViewMac, message) |
| 740 IPC_MESSAGE_HANDLER(ViewHostMsg_PluginFocusChanged, OnPluginFocusChanged) | 740 IPC_MESSAGE_HANDLER(ViewHostMsg_PluginFocusChanged, OnPluginFocusChanged) |
| 741 IPC_MESSAGE_HANDLER(ViewHostMsg_StartPluginIme, OnStartPluginIme) | 741 IPC_MESSAGE_HANDLER(ViewHostMsg_StartPluginIme, OnStartPluginIme) |
| 742 IPC_MESSAGE_HANDLER(ViewMsg_GetRenderedTextCompleted, | |
| 743 OnGetRenderedTextCompleted) | |
| 742 IPC_MESSAGE_UNHANDLED(handled = false) | 744 IPC_MESSAGE_UNHANDLED(handled = false) |
| 743 IPC_END_MESSAGE_MAP() | 745 IPC_END_MESSAGE_MAP() |
| 744 return handled; | 746 return handled; |
| 745 } | 747 } |
| 746 | 748 |
| 747 void RenderWidgetHostViewMac::InitAsChild( | 749 void RenderWidgetHostViewMac::InitAsChild( |
| 748 gfx::NativeView parent_view) { | 750 gfx::NativeView parent_view) { |
| 749 } | 751 } |
| 750 | 752 |
| 751 void RenderWidgetHostViewMac::InitAsPopup( | 753 void RenderWidgetHostViewMac::InitAsPopup( |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 873 | 875 |
| 874 if (!display_link_->GetVSyncParameters(&vsync_timebase_, &vsync_interval_)) { | 876 if (!display_link_->GetVSyncParameters(&vsync_timebase_, &vsync_interval_)) { |
| 875 vsync_timebase_ = base::TimeTicks(); | 877 vsync_timebase_ = base::TimeTicks(); |
| 876 vsync_interval_ = base::TimeDelta(); | 878 vsync_interval_ = base::TimeDelta(); |
| 877 return; | 879 return; |
| 878 } | 880 } |
| 879 | 881 |
| 880 render_widget_host_->UpdateVSyncParameters(vsync_timebase_, vsync_interval_); | 882 render_widget_host_->UpdateVSyncParameters(vsync_timebase_, vsync_interval_); |
| 881 } | 883 } |
| 882 | 884 |
| 885 void RenderWidgetHostViewMac::SpeakText(const std::string &text) { | |
|
dcheng
2014/08/14 17:38:48
Nit: fix alignment of & (& should be by type, not
| |
| 886 [NSApp speakString:base::SysUTF8ToNSString(text)]; | |
| 887 } | |
| 888 | |
| 883 void RenderWidgetHostViewMac::UpdateBackingStoreScaleFactor() { | 889 void RenderWidgetHostViewMac::UpdateBackingStoreScaleFactor() { |
| 884 if (!render_widget_host_) | 890 if (!render_widget_host_) |
| 885 return; | 891 return; |
| 886 | 892 |
| 887 float new_scale_factor = ui::GetScaleFactorForNativeView(cocoa_view_); | 893 float new_scale_factor = ui::GetScaleFactorForNativeView(cocoa_view_); |
| 888 if (new_scale_factor == backing_store_scale_factor_) | 894 if (new_scale_factor == backing_store_scale_factor_) |
| 889 return; | 895 return; |
| 890 backing_store_scale_factor_ = new_scale_factor; | 896 backing_store_scale_factor_ = new_scale_factor; |
| 891 | 897 |
| 892 render_widget_host_->NotifyScreenInfoChanged(); | 898 render_widget_host_->NotifyScreenInfoChanged(); |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1178 [cocoa_view_ setToolTipAtMousePoint:tooltip_nsstring]; | 1184 [cocoa_view_ setToolTipAtMousePoint:tooltip_nsstring]; |
| 1179 } | 1185 } |
| 1180 } | 1186 } |
| 1181 | 1187 |
| 1182 bool RenderWidgetHostViewMac::SupportsSpeech() const { | 1188 bool RenderWidgetHostViewMac::SupportsSpeech() const { |
| 1183 return [NSApp respondsToSelector:@selector(speakString:)] && | 1189 return [NSApp respondsToSelector:@selector(speakString:)] && |
| 1184 [NSApp respondsToSelector:@selector(stopSpeaking:)]; | 1190 [NSApp respondsToSelector:@selector(stopSpeaking:)]; |
| 1185 } | 1191 } |
| 1186 | 1192 |
| 1187 void RenderWidgetHostViewMac::SpeakSelection() { | 1193 void RenderWidgetHostViewMac::SpeakSelection() { |
| 1188 if ([NSApp respondsToSelector:@selector(speakString:)]) | 1194 if (![NSApp respondsToSelector:@selector(speakString:)]) |
| 1189 [NSApp speakString:base::SysUTF8ToNSString(selected_text_)]; | 1195 return; |
| 1196 | |
| 1197 if (selected_text_.empty() && render_widget_host_) { | |
| 1198 // If there's no selection, speak all text. Send an asynchronous IPC | |
| 1199 // request for fetching all the text for a webcontent. | |
| 1200 // ViewMsg_GetRenderedTextCompleted is sent back to IPC Message receiver. | |
| 1201 render_widget_host_->Send(new ViewMsg_GetRenderedText( | |
| 1202 render_widget_host_->GetRoutingID())); | |
| 1203 return; | |
| 1204 } | |
| 1205 | |
| 1206 SpeakText(selected_text_); | |
| 1190 } | 1207 } |
| 1191 | 1208 |
| 1192 bool RenderWidgetHostViewMac::IsSpeaking() const { | 1209 bool RenderWidgetHostViewMac::IsSpeaking() const { |
| 1193 return [NSApp respondsToSelector:@selector(isSpeaking)] && | 1210 return [NSApp respondsToSelector:@selector(isSpeaking)] && |
| 1194 [NSApp isSpeaking]; | 1211 [NSApp isSpeaking]; |
| 1195 } | 1212 } |
| 1196 | 1213 |
| 1197 void RenderWidgetHostViewMac::StopSpeaking() { | 1214 void RenderWidgetHostViewMac::StopSpeaking() { |
| 1198 if ([NSApp respondsToSelector:@selector(stopSpeaking:)]) | 1215 if ([NSApp respondsToSelector:@selector(stopSpeaking:)]) |
| 1199 [NSApp stopSpeaking:cocoa_view_]; | 1216 [NSApp stopSpeaking:cocoa_view_]; |
| (...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2162 | 2179 |
| 2163 void RenderWidgetHostViewMac::OnPluginFocusChanged(bool focused, | 2180 void RenderWidgetHostViewMac::OnPluginFocusChanged(bool focused, |
| 2164 int plugin_id) { | 2181 int plugin_id) { |
| 2165 [cocoa_view_ pluginFocusChanged:(focused ? YES : NO) forPlugin:plugin_id]; | 2182 [cocoa_view_ pluginFocusChanged:(focused ? YES : NO) forPlugin:plugin_id]; |
| 2166 } | 2183 } |
| 2167 | 2184 |
| 2168 void RenderWidgetHostViewMac::OnStartPluginIme() { | 2185 void RenderWidgetHostViewMac::OnStartPluginIme() { |
| 2169 [cocoa_view_ setPluginImeActive:YES]; | 2186 [cocoa_view_ setPluginImeActive:YES]; |
| 2170 } | 2187 } |
| 2171 | 2188 |
| 2189 void RenderWidgetHostViewMac::OnGetRenderedTextCompleted( | |
| 2190 const std::string& text) { | |
| 2191 SpeakText(text); | |
| 2192 } | |
| 2193 | |
| 2172 gfx::Rect RenderWidgetHostViewMac::GetScaledOpenGLPixelRect( | 2194 gfx::Rect RenderWidgetHostViewMac::GetScaledOpenGLPixelRect( |
| 2173 const gfx::Rect& rect) { | 2195 const gfx::Rect& rect) { |
| 2174 gfx::Rect src_gl_subrect = rect; | 2196 gfx::Rect src_gl_subrect = rect; |
| 2175 src_gl_subrect.set_y(GetViewBounds().height() - rect.bottom()); | 2197 src_gl_subrect.set_y(GetViewBounds().height() - rect.bottom()); |
| 2176 | 2198 |
| 2177 return gfx::ToEnclosingRect(gfx::ScaleRect(src_gl_subrect, | 2199 return gfx::ToEnclosingRect(gfx::ScaleRect(src_gl_subrect, |
| 2178 ViewScaleFactor())); | 2200 ViewScaleFactor())); |
| 2179 } | 2201 } |
| 2180 | 2202 |
| 2181 void RenderWidgetHostViewMac::AddPendingLatencyInfo( | 2203 void RenderWidgetHostViewMac::AddPendingLatencyInfo( |
| (...skipping 1890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4072 | 4094 |
| 4073 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 4095 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
| 4074 // regions that are not draggable. (See ControlRegionView in | 4096 // regions that are not draggable. (See ControlRegionView in |
| 4075 // native_app_window_cocoa.mm). This requires the render host view to be | 4097 // native_app_window_cocoa.mm). This requires the render host view to be |
| 4076 // draggable by default. | 4098 // draggable by default. |
| 4077 - (BOOL)mouseDownCanMoveWindow { | 4099 - (BOOL)mouseDownCanMoveWindow { |
| 4078 return YES; | 4100 return YES; |
| 4079 } | 4101 } |
| 4080 | 4102 |
| 4081 @end | 4103 @end |
| OLD | NEW |