| 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 <QuartzCore/QuartzCore.h> | 8 #include <QuartzCore/QuartzCore.h> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/callback_helpers.h" | 12 #include "base/callback_helpers.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/debug/crash_logging.h" | 14 #include "base/debug/crash_logging.h" |
| 15 #include "base/debug/trace_event.h" | 15 #include "base/debug/trace_event.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/mac/mac_util.h" | 17 #include "base/mac/mac_util.h" |
| 18 #include "base/mac/scoped_cftyperef.h" | 18 #include "base/mac/scoped_cftyperef.h" |
| 19 #import "base/mac/scoped_nsobject.h" | 19 #import "base/mac/scoped_nsobject.h" |
| 20 #include "base/mac/sdk_forward_declarations.h" | 20 #include "base/mac/sdk_forward_declarations.h" |
| 21 #include "base/message_loop/message_loop.h" | 21 #include "base/message_loop/message_loop.h" |
| 22 #include "base/metrics/histogram.h" | 22 #include "base/metrics/histogram.h" |
| 23 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
| 24 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
| 25 #include "base/strings/sys_string_conversions.h" | 25 #include "base/strings/sys_string_conversions.h" |
| 26 #include "base/strings/utf_string_conversions.h" | 26 #include "base/strings/utf_string_conversions.h" |
| 27 #include "base/sys_info.h" | 27 #include "base/sys_info.h" |
| 28 #import "content/browser/accessibility/browser_accessibility_cocoa.h" | 28 #import "content/browser/accessibility/browser_accessibility_cocoa.h" |
| 29 #include "content/browser/accessibility/browser_accessibility_manager_mac.h" | 29 #include "content/browser/accessibility/browser_accessibility_manager_mac.h" |
| 30 #include "content/browser/frame_host/frame_tree.h" |
| 31 #include "content/browser/frame_host/frame_tree_node.h" |
| 32 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 30 #include "content/browser/renderer_host/backing_store_mac.h" | 33 #include "content/browser/renderer_host/backing_store_mac.h" |
| 31 #include "content/browser/renderer_host/backing_store_manager.h" | 34 #include "content/browser/renderer_host/backing_store_manager.h" |
| 32 #include "content/browser/renderer_host/compositing_iosurface_context_mac.h" | 35 #include "content/browser/renderer_host/compositing_iosurface_context_mac.h" |
| 33 #include "content/browser/renderer_host/compositing_iosurface_layer_mac.h" | 36 #include "content/browser/renderer_host/compositing_iosurface_layer_mac.h" |
| 34 #include "content/browser/renderer_host/compositing_iosurface_mac.h" | 37 #include "content/browser/renderer_host/compositing_iosurface_mac.h" |
| 35 #include "content/browser/renderer_host/render_view_host_impl.h" | 38 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 36 #import "content/browser/renderer_host/render_widget_host_view_mac_dictionary_he
lper.h" | 39 #import "content/browser/renderer_host/render_widget_host_view_mac_dictionary_he
lper.h" |
| 37 #import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_h
elper.h" | 40 #import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_h
elper.h" |
| 38 #import "content/browser/renderer_host/text_input_client_mac.h" | 41 #import "content/browser/renderer_host/text_input_client_mac.h" |
| 39 #include "content/common/accessibility_messages.h" | 42 #include "content/common/accessibility_messages.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 65 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" | 68 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
| 66 #include "ui/gfx/screen.h" | 69 #include "ui/gfx/screen.h" |
| 67 #include "ui/gfx/size_conversions.h" | 70 #include "ui/gfx/size_conversions.h" |
| 68 #include "ui/gl/gl_switches.h" | 71 #include "ui/gl/gl_switches.h" |
| 69 #include "ui/gl/io_surface_support_mac.h" | 72 #include "ui/gl/io_surface_support_mac.h" |
| 70 | 73 |
| 71 using content::BackingStoreMac; | 74 using content::BackingStoreMac; |
| 72 using content::BrowserAccessibility; | 75 using content::BrowserAccessibility; |
| 73 using content::BrowserAccessibilityManager; | 76 using content::BrowserAccessibilityManager; |
| 74 using content::EditCommand; | 77 using content::EditCommand; |
| 78 using content::FrameTreeNode; |
| 75 using content::NativeWebKeyboardEvent; | 79 using content::NativeWebKeyboardEvent; |
| 80 using content::RenderFrameHost; |
| 81 using content::RenderViewHost; |
| 76 using content::RenderViewHostImpl; | 82 using content::RenderViewHostImpl; |
| 77 using content::RenderWidgetHostImpl; | 83 using content::RenderWidgetHostImpl; |
| 78 using content::RenderWidgetHostViewMac; | 84 using content::RenderWidgetHostViewMac; |
| 79 using content::RenderWidgetHostViewMacEditCommandHelper; | 85 using content::RenderWidgetHostViewMacEditCommandHelper; |
| 80 using content::TextInputClientMac; | 86 using content::TextInputClientMac; |
| 81 using blink::WebInputEvent; | 87 using blink::WebInputEvent; |
| 82 using blink::WebInputEventFactory; | 88 using blink::WebInputEventFactory; |
| 83 using blink::WebMouseEvent; | 89 using blink::WebMouseEvent; |
| 84 using blink::WebMouseWheelEvent; | 90 using blink::WebMouseWheelEvent; |
| 85 | 91 |
| (...skipping 1621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1707 request_range.start() > composition_range_.end() || | 1713 request_range.start() > composition_range_.end() || |
| 1708 request_range.end() > composition_range_.end()) { | 1714 request_range.end() > composition_range_.end()) { |
| 1709 return gfx::Range::InvalidRange(); | 1715 return gfx::Range::InvalidRange(); |
| 1710 } | 1716 } |
| 1711 | 1717 |
| 1712 return gfx::Range( | 1718 return gfx::Range( |
| 1713 request_range.start() - composition_range_.start(), | 1719 request_range.start() - composition_range_.start(), |
| 1714 request_range.end() - composition_range_.start()); | 1720 request_range.end() - composition_range_.start()); |
| 1715 } | 1721 } |
| 1716 | 1722 |
| 1723 RenderFrameHost* RenderWidgetHostViewMac::GetFocusedFrame() { |
| 1724 if (!render_widget_host_->IsRenderView()) |
| 1725 return NULL; |
| 1726 |
| 1727 RenderViewHost* rvh = RenderViewHost::From(render_widget_host_); |
| 1728 RenderFrameHostImpl* rfh = |
| 1729 static_cast<RenderFrameHostImpl*>(rvh->GetMainFrame()); |
| 1730 FrameTreeNode* focused_frame = |
| 1731 rfh->frame_tree_node()->frame_tree()->GetFocusedFrame(); |
| 1732 if (!focused_frame) |
| 1733 return NULL; |
| 1734 |
| 1735 return focused_frame->current_frame_host(); |
| 1736 } |
| 1737 |
| 1717 bool RenderWidgetHostViewMac::GetCachedFirstRectForCharacterRange( | 1738 bool RenderWidgetHostViewMac::GetCachedFirstRectForCharacterRange( |
| 1718 NSRange range, | 1739 NSRange range, |
| 1719 NSRect* rect, | 1740 NSRect* rect, |
| 1720 NSRange* actual_range) { | 1741 NSRange* actual_range) { |
| 1721 DCHECK(rect); | 1742 DCHECK(rect); |
| 1722 // This exists to make IMEs more responsive, see http://crbug.com/115920 | 1743 // This exists to make IMEs more responsive, see http://crbug.com/115920 |
| 1723 TRACE_EVENT0("browser", | 1744 TRACE_EVENT0("browser", |
| 1724 "RenderWidgetHostViewMac::GetFirstRectForCharacterRange"); | 1745 "RenderWidgetHostViewMac::GetFirstRectForCharacterRange"); |
| 1725 | 1746 |
| 1726 // If requested range is same as caret location, we can just return it. | 1747 // If requested range is same as caret location, we can just return it. |
| (...skipping 2233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3960 } | 3981 } |
| 3961 | 3982 |
| 3962 - (void)redo:(id)sender { | 3983 - (void)redo:(id)sender { |
| 3963 if (renderWidgetHostView_->render_widget_host_->IsRenderView()) { | 3984 if (renderWidgetHostView_->render_widget_host_->IsRenderView()) { |
| 3964 static_cast<RenderViewHostImpl*>( | 3985 static_cast<RenderViewHostImpl*>( |
| 3965 renderWidgetHostView_->render_widget_host_)->Redo(); | 3986 renderWidgetHostView_->render_widget_host_)->Redo(); |
| 3966 } | 3987 } |
| 3967 } | 3988 } |
| 3968 | 3989 |
| 3969 - (void)cut:(id)sender { | 3990 - (void)cut:(id)sender { |
| 3970 if (renderWidgetHostView_->render_widget_host_->IsRenderView()) { | 3991 RenderFrameHost* host = renderWidgetHostView_->GetFocusedFrame(); |
| 3971 static_cast<RenderViewHostImpl*>( | 3992 if (host) |
| 3972 renderWidgetHostView_->render_widget_host_)->Cut(); | 3993 host->Cut(); |
| 3973 } | |
| 3974 } | 3994 } |
| 3975 | 3995 |
| 3976 - (void)copy:(id)sender { | 3996 - (void)copy:(id)sender { |
| 3977 if (renderWidgetHostView_->render_widget_host_->IsRenderView()) { | 3997 RenderFrameHost* host = renderWidgetHostView_->GetFocusedFrame(); |
| 3978 static_cast<RenderViewHostImpl*>( | 3998 if (host) |
| 3979 renderWidgetHostView_->render_widget_host_)->Copy(); | 3999 host->Copy(); |
| 3980 } | |
| 3981 } | 4000 } |
| 3982 | 4001 |
| 3983 - (void)copyToFindPboard:(id)sender { | 4002 - (void)copyToFindPboard:(id)sender { |
| 3984 if (renderWidgetHostView_->render_widget_host_->IsRenderView()) { | 4003 if (renderWidgetHostView_->render_widget_host_->IsRenderView()) { |
| 3985 static_cast<RenderViewHostImpl*>( | 4004 static_cast<RenderViewHostImpl*>( |
| 3986 renderWidgetHostView_->render_widget_host_)->CopyToFindPboard(); | 4005 renderWidgetHostView_->render_widget_host_)->CopyToFindPboard(); |
| 3987 } | 4006 } |
| 3988 } | 4007 } |
| 3989 | 4008 |
| 3990 - (void)paste:(id)sender { | 4009 - (void)paste:(id)sender { |
| 3991 if (renderWidgetHostView_->render_widget_host_->IsRenderView()) { | 4010 RenderFrameHost* host = renderWidgetHostView_->GetFocusedFrame(); |
| 3992 static_cast<RenderViewHostImpl*>( | 4011 if (host) |
| 3993 renderWidgetHostView_->render_widget_host_)->Paste(); | 4012 host->Paste(); |
| 3994 } | |
| 3995 } | 4013 } |
| 3996 | 4014 |
| 3997 - (void)pasteAndMatchStyle:(id)sender { | 4015 - (void)pasteAndMatchStyle:(id)sender { |
| 3998 if (renderWidgetHostView_->render_widget_host_->IsRenderView()) { | 4016 if (renderWidgetHostView_->render_widget_host_->IsRenderView()) { |
| 3999 static_cast<RenderViewHostImpl*>( | 4017 static_cast<RenderViewHostImpl*>( |
| 4000 renderWidgetHostView_->render_widget_host_)->PasteAndMatchStyle(); | 4018 renderWidgetHostView_->render_widget_host_)->PasteAndMatchStyle(); |
| 4001 } | 4019 } |
| 4002 } | 4020 } |
| 4003 | 4021 |
| 4004 - (void)selectAll:(id)sender { | 4022 - (void)selectAll:(id)sender { |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4246 CGColorGetConstantColor(kCGColorWhite)); | 4264 CGColorGetConstantColor(kCGColorWhite)); |
| 4247 CGContextFillRect(context, clipRect); | 4265 CGContextFillRect(context, clipRect); |
| 4248 } | 4266 } |
| 4249 } | 4267 } |
| 4250 | 4268 |
| 4251 - (void)disableRendering { | 4269 - (void)disableRendering { |
| 4252 renderWidgetHostView_ = NULL; | 4270 renderWidgetHostView_ = NULL; |
| 4253 } | 4271 } |
| 4254 | 4272 |
| 4255 @end // implementation SoftwareLayer | 4273 @end // implementation SoftwareLayer |
| OLD | NEW |