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

Side by Side 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: Style changes fixed for Defect 248426 Created 6 years, 5 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 unified diff | Download patch
OLDNEW
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 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 fullscreen_parent_host_view_(NULL), 481 fullscreen_parent_host_view_(NULL),
482 overlay_view_weak_factory_(this), 482 overlay_view_weak_factory_(this),
483 software_frame_weak_ptr_factory_(this) { 483 software_frame_weak_ptr_factory_(this) {
484 software_frame_manager_.reset(new SoftwareFrameManager( 484 software_frame_manager_.reset(new SoftwareFrameManager(
485 software_frame_weak_ptr_factory_.GetWeakPtr())); 485 software_frame_weak_ptr_factory_.GetWeakPtr()));
486 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_| 486 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_|
487 // goes away. Since we autorelease it, our caller must put 487 // goes away. Since we autorelease it, our caller must put
488 // |GetNativeView()| into the view hierarchy right after calling us. 488 // |GetNativeView()| into the view hierarchy right after calling us.
489 cocoa_view_ = [[[RenderWidgetHostViewCocoa alloc] 489 cocoa_view_ = [[[RenderWidgetHostViewCocoa alloc]
490 initWithRenderWidgetHostViewMac:this] autorelease]; 490 initWithRenderWidgetHostViewMac:this] autorelease];
491
Alexei Svitkine (slow) 2014/06/27 15:54:30 Hmm, I don't understand why the diff looks so. I c
sarka 2014/06/27 16:26:14 This is really strange. I had to throw in an extra
491 background_layer_.reset([[CALayer alloc] init]); 492 background_layer_.reset([[CALayer alloc] init]);
492 [background_layer_ 493 [background_layer_
493 setBackgroundColor:CGColorGetConstantColor(kCGColorWhite)]; 494 setBackgroundColor:CGColorGetConstantColor(kCGColorWhite)];
494 [background_layer_ setGeometryFlipped:YES]; 495 [background_layer_ setGeometryFlipped:YES];
495 [background_layer_ setContentsGravity:kCAGravityTopLeft]; 496 [background_layer_ setContentsGravity:kCAGravityTopLeft];
496 [cocoa_view_ setLayer:background_layer_]; 497 [cocoa_view_ setLayer:background_layer_];
497 [cocoa_view_ setWantsLayer:YES]; 498 [cocoa_view_ setWantsLayer:YES];
498 499
499 render_widget_host_->SetView(this); 500 render_widget_host_->SetView(this);
500 } 501 }
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 } 1082 }
1082 1083
1083 void RenderWidgetHostViewMac::SpeakSelection() { 1084 void RenderWidgetHostViewMac::SpeakSelection() {
1084 if (![NSApp respondsToSelector:@selector(speakString:)]) 1085 if (![NSApp respondsToSelector:@selector(speakString:)])
1085 return; 1086 return;
1086 1087
1087 if (selected_text_.empty() && render_widget_host_) { 1088 if (selected_text_.empty() && render_widget_host_) {
1088 // Route an IPC message to get content as text for a web contents. 1089 // Route an IPC message to get content as text for a web contents.
1089 render_widget_host_->Send(new ViewMsg_GetRenderedText( 1090 render_widget_host_->Send(new ViewMsg_GetRenderedText(
1090 render_widget_host_->GetRoutingID())); 1091 render_widget_host_->GetRoutingID()));
1091 return; 1092 return;
1092 } 1093 }
1093 1094
1094 [NSApp speakString:base::SysUTF8ToNSString(selected_text_)]; 1095 [NSApp speakString:base::SysUTF8ToNSString(selected_text_)];
1095 } 1096 }
1096 1097
1097 bool RenderWidgetHostViewMac::IsSpeaking() const { 1098 bool RenderWidgetHostViewMac::IsSpeaking() const {
1098 return [NSApp respondsToSelector:@selector(isSpeaking)] && 1099 return [NSApp respondsToSelector:@selector(isSpeaking)] &&
1099 [NSApp isSpeaking]; 1100 [NSApp isSpeaking];
1100 } 1101 }
1101 1102
(...skipping 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after
2333 if (self) { 2334 if (self) {
2334 self.acceptsTouchEvents = YES; 2335 self.acceptsTouchEvents = YES;
2335 editCommand_helper_.reset(new RenderWidgetHostViewMacEditCommandHelper); 2336 editCommand_helper_.reset(new RenderWidgetHostViewMacEditCommandHelper);
2336 editCommand_helper_->AddEditingSelectorsToClass([self class]); 2337 editCommand_helper_->AddEditingSelectorsToClass([self class]);
2337 2338
2338 renderWidgetHostView_.reset(r); 2339 renderWidgetHostView_.reset(r);
2339 canBeKeyView_ = YES; 2340 canBeKeyView_ = YES;
2340 focusedPluginIdentifier_ = -1; 2341 focusedPluginIdentifier_ = -1;
2341 renderWidgetHostView_->backing_store_scale_factor_ = 2342 renderWidgetHostView_->backing_store_scale_factor_ =
2342 ui::GetScaleFactorForNativeView(self); 2343 ui::GetScaleFactorForNativeView(self);
2344
2343 // OpenGL support: 2345 // OpenGL support:
2344 if ([self respondsToSelector: 2346 if ([self respondsToSelector:
2345 @selector(setWantsBestResolutionOpenGLSurface:)]) { 2347 @selector(setWantsBestResolutionOpenGLSurface:)]) {
2346 [self setWantsBestResolutionOpenGLSurface:YES]; 2348 [self setWantsBestResolutionOpenGLSurface:YES];
2347 } 2349 }
2348 handlingGlobalFrameDidChange_ = NO; 2350 handlingGlobalFrameDidChange_ = NO;
2349 [[NSNotificationCenter defaultCenter] 2351 [[NSNotificationCenter defaultCenter]
2350 addObserver:self 2352 addObserver:self
2351 selector:@selector(didChangeScreenParameters:) 2353 selector:@selector(didChangeScreenParameters:)
2352 name:NSApplicationDidChangeScreenParametersNotification 2354 name:NSApplicationDidChangeScreenParametersNotification
(...skipping 1640 matching lines...) Expand 10 before | Expand all | Expand 10 after
3993 3995
3994 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding 3996 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding
3995 // regions that are not draggable. (See ControlRegionView in 3997 // regions that are not draggable. (See ControlRegionView in
3996 // native_app_window_cocoa.mm). This requires the render host view to be 3998 // native_app_window_cocoa.mm). This requires the render host view to be
3997 // draggable by default. 3999 // draggable by default.
3998 - (BOOL)mouseDownCanMoveWindow { 4000 - (BOOL)mouseDownCanMoveWindow {
3999 return YES; 4001 return YES;
4000 } 4002 }
4001 4003
4002 @end 4004 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698