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 20 matching lines...) Expand all Loading... | |
| 31 #include "content/browser/bad_message.h" | 31 #include "content/browser/bad_message.h" |
| 32 #import "content/browser/cocoa/system_hotkey_helper_mac.h" | 32 #import "content/browser/cocoa/system_hotkey_helper_mac.h" |
| 33 #import "content/browser/cocoa/system_hotkey_map.h" | 33 #import "content/browser/cocoa/system_hotkey_map.h" |
| 34 #include "content/browser/compositor/resize_lock.h" | 34 #include "content/browser/compositor/resize_lock.h" |
| 35 #include "content/browser/frame_host/frame_tree.h" | 35 #include "content/browser/frame_host/frame_tree.h" |
| 36 #include "content/browser/frame_host/frame_tree_node.h" | 36 #include "content/browser/frame_host/frame_tree_node.h" |
| 37 #include "content/browser/frame_host/render_frame_host_impl.h" | 37 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 38 #include "content/browser/gpu/compositor_util.h" | 38 #include "content/browser/gpu/compositor_util.h" |
| 39 #include "content/browser/renderer_host/render_view_host_impl.h" | 39 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 40 #include "content/browser/renderer_host/render_widget_helper.h" | 40 #include "content/browser/renderer_host/render_widget_helper.h" |
| 41 #include "content/browser/renderer_host/render_widget_host_delegate.h" | |
| 41 #import "content/browser/renderer_host/render_widget_host_view_mac_dictionary_he lper.h" | 42 #import "content/browser/renderer_host/render_widget_host_view_mac_dictionary_he lper.h" |
| 42 #import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_h elper.h" | 43 #import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_h elper.h" |
| 43 #import "content/browser/renderer_host/text_input_client_mac.h" | 44 #import "content/browser/renderer_host/text_input_client_mac.h" |
| 44 #include "content/common/accessibility_messages.h" | 45 #include "content/common/accessibility_messages.h" |
| 45 #include "content/common/edit_command.h" | 46 #include "content/common/edit_command.h" |
| 46 #include "content/common/gpu/gpu_messages.h" | 47 #include "content/common/gpu/gpu_messages.h" |
| 47 #include "content/common/input_messages.h" | 48 #include "content/common/input_messages.h" |
| 48 #include "content/common/view_messages.h" | 49 #include "content/common/view_messages.h" |
| 49 #include "content/common/webplugin_geometry.h" | 50 #include "content/common/webplugin_geometry.h" |
| 50 #include "content/public/browser/browser_context.h" | 51 #include "content/public/browser/browser_context.h" |
| (...skipping 3198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3249 WebMouseEvent event; | 3250 WebMouseEvent event; |
| 3250 event.type = WebInputEvent::MouseUp; | 3251 event.type = WebInputEvent::MouseUp; |
| 3251 event.button = WebMouseEvent::ButtonLeft; | 3252 event.button = WebMouseEvent::ButtonLeft; |
| 3252 renderWidgetHostView_->ForwardMouseEvent(event); | 3253 renderWidgetHostView_->ForwardMouseEvent(event); |
| 3253 | 3254 |
| 3254 hasOpenMouseDown_ = NO; | 3255 hasOpenMouseDown_ = NO; |
| 3255 } | 3256 } |
| 3256 } | 3257 } |
| 3257 | 3258 |
| 3258 - (void)undo:(id)sender { | 3259 - (void)undo:(id)sender { |
| 3259 WebContents* web_contents = renderWidgetHostView_->GetWebContents(); | 3260 content::RenderWidgetHostDelegate* render_widget_host_delegate = |
| 3260 if (web_contents) | 3261 renderWidgetHostView_->render_widget_host_->GetDelegate(); |
| 3261 web_contents->Undo(); | 3262 render_widget_host_delegate->Undo(); |
|
nasko
2015/05/13 17:24:08
I think it is possible for the delegate of RenderW
lgarron
2015/05/13 21:58:41
I've added a simple `if (!render_widget_host_deleg
nasko
2015/05/14 20:45:23
Why not:
if (render_widget_host_delegate)
rende
| |
| 3262 } | 3263 } |
| 3263 | 3264 |
| 3264 - (void)redo:(id)sender { | 3265 - (void)redo:(id)sender { |
| 3265 WebContents* web_contents = renderWidgetHostView_->GetWebContents(); | 3266 content::RenderWidgetHostDelegate* render_widget_host_delegate = |
| 3266 if (web_contents) | 3267 renderWidgetHostView_->render_widget_host_->GetDelegate(); |
| 3267 web_contents->Redo(); | 3268 render_widget_host_delegate->Redo(); |
| 3268 } | 3269 } |
| 3269 | 3270 |
| 3270 - (void)cut:(id)sender { | 3271 - (void)cut:(id)sender { |
| 3271 WebContents* web_contents = renderWidgetHostView_->GetWebContents(); | 3272 content::RenderWidgetHostDelegate* render_widget_host_delegate = |
| 3272 if (web_contents) | 3273 renderWidgetHostView_->render_widget_host_->GetDelegate(); |
| 3273 web_contents->Cut(); | 3274 render_widget_host_delegate->Cut(); |
| 3274 } | 3275 } |
| 3275 | 3276 |
| 3276 - (void)copy:(id)sender { | 3277 - (void)copy:(id)sender { |
| 3277 WebContents* web_contents = renderWidgetHostView_->GetWebContents(); | 3278 content::RenderWidgetHostDelegate* render_widget_host_delegate = |
| 3278 if (web_contents) | 3279 renderWidgetHostView_->render_widget_host_->GetDelegate(); |
| 3279 web_contents->Copy(); | 3280 render_widget_host_delegate->Copy(); |
| 3280 } | 3281 } |
| 3281 | 3282 |
| 3282 - (void)copyToFindPboard:(id)sender { | 3283 - (void)copyToFindPboard:(id)sender { |
| 3283 WebContents* web_contents = renderWidgetHostView_->GetWebContents(); | 3284 content::RenderWidgetHostDelegate* render_widget_host_delegate = |
| 3284 if (web_contents) | 3285 renderWidgetHostView_->render_widget_host_->GetDelegate(); |
| 3285 web_contents->CopyToFindPboard(); | 3286 render_widget_host_delegate->CopyToFindPboard(); |
| 3286 } | 3287 } |
| 3287 | 3288 |
| 3288 - (void)paste:(id)sender { | 3289 - (void)paste:(id)sender { |
| 3289 WebContents* web_contents = renderWidgetHostView_->GetWebContents(); | 3290 content::RenderWidgetHostDelegate* render_widget_host_delegate = |
| 3290 if (web_contents) | 3291 renderWidgetHostView_->render_widget_host_->GetDelegate(); |
| 3291 web_contents->Paste(); | 3292 render_widget_host_delegate->Paste(); |
| 3292 } | 3293 } |
| 3293 | 3294 |
| 3294 - (void)pasteAndMatchStyle:(id)sender { | 3295 - (void)pasteAndMatchStyle:(id)sender { |
| 3295 WebContents* web_contents = renderWidgetHostView_->GetWebContents(); | 3296 content::RenderWidgetHostDelegate* render_widget_host_delegate = |
| 3296 if (web_contents) | 3297 renderWidgetHostView_->render_widget_host_->GetDelegate(); |
| 3297 web_contents->PasteAndMatchStyle(); | 3298 render_widget_host_delegate->PasteAndMatchStyle(); |
| 3298 } | 3299 } |
| 3299 | 3300 |
| 3300 - (void)selectAll:(id)sender { | 3301 - (void)selectAll:(id)sender { |
| 3301 // editCommand_helper_ adds implementations for most NSResponder methods | 3302 // editCommand_helper_ adds implementations for most NSResponder methods |
| 3302 // dynamically. But the renderer side only sends selection results back to | 3303 // dynamically. But the renderer side only sends selection results back to |
| 3303 // the browser if they were triggered by a keyboard event or went through | 3304 // the browser if they were triggered by a keyboard event or went through |
| 3304 // one of the Select methods on RWH. Since selectAll: is called from the | 3305 // one of the Select methods on RWH. Since selectAll: is called from the |
| 3305 // menu handler, neither is true. | 3306 // menu handler, neither is true. |
| 3306 // Explicitly call SelectAll() here to make sure the renderer returns | 3307 // Explicitly call SelectAll() here to make sure the renderer returns |
| 3307 // selection results. | 3308 // selection results. |
| 3308 WebContents* web_contents = renderWidgetHostView_->GetWebContents(); | 3309 content::RenderWidgetHostDelegate* render_widget_host_delegate = |
| 3309 if (web_contents) | 3310 renderWidgetHostView_->render_widget_host_->GetDelegate(); |
| 3310 web_contents->SelectAll(); | 3311 render_widget_host_delegate->SelectAll(); |
| 3311 } | 3312 } |
| 3312 | 3313 |
| 3313 - (void)startSpeaking:(id)sender { | 3314 - (void)startSpeaking:(id)sender { |
| 3314 GetRenderWidgetHostViewToUse(renderWidgetHostView_.get())->SpeakSelection(); | 3315 GetRenderWidgetHostViewToUse(renderWidgetHostView_.get())->SpeakSelection(); |
| 3315 } | 3316 } |
| 3316 | 3317 |
| 3317 - (void)stopSpeaking:(id)sender { | 3318 - (void)stopSpeaking:(id)sender { |
| 3318 GetRenderWidgetHostViewToUse(renderWidgetHostView_.get())->StopSpeaking(); | 3319 GetRenderWidgetHostViewToUse(renderWidgetHostView_.get())->StopSpeaking(); |
| 3319 } | 3320 } |
| 3320 | 3321 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3484 | 3485 |
| 3485 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3486 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
| 3486 // regions that are not draggable. (See ControlRegionView in | 3487 // regions that are not draggable. (See ControlRegionView in |
| 3487 // native_app_window_cocoa.mm). This requires the render host view to be | 3488 // native_app_window_cocoa.mm). This requires the render host view to be |
| 3488 // draggable by default. | 3489 // draggable by default. |
| 3489 - (BOOL)mouseDownCanMoveWindow { | 3490 - (BOOL)mouseDownCanMoveWindow { |
| 3490 return YES; | 3491 return YES; |
| 3491 } | 3492 } |
| 3492 | 3493 |
| 3493 @end | 3494 @end |
| OLD | NEW |