| 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 #include <QuartzCore/QuartzCore.h> | 7 #include <QuartzCore/QuartzCore.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" |
| 10 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.h" |
| 11 #include "base/logging.h" | 12 #include "base/logging.h" |
| 12 #include "base/mac/closure_blocks_leopard_compat.h" | 13 #include "base/mac/closure_blocks_leopard_compat.h" |
| 13 #include "base/mac/mac_util.h" | 14 #include "base/mac/mac_util.h" |
| 14 #include "base/mac/scoped_cftyperef.h" | 15 #include "base/mac/scoped_cftyperef.h" |
| 15 #import "base/mac/scoped_nsautorelease_pool.h" | 16 #import "base/mac/scoped_nsautorelease_pool.h" |
| 16 #import "base/memory/scoped_nsobject.h" | 17 #import "base/memory/scoped_nsobject.h" |
| 17 #include "base/metrics/histogram.h" | 18 #include "base/metrics/histogram.h" |
| 18 #include "base/string_util.h" | 19 #include "base/string_util.h" |
| 19 #include "base/sys_info.h" | 20 #include "base/sys_info.h" |
| (...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 | 783 |
| 783 bool RenderWidgetHostViewMac::IsPopup() const { | 784 bool RenderWidgetHostViewMac::IsPopup() const { |
| 784 return popup_type_ != WebKit::WebPopupTypeNone; | 785 return popup_type_ != WebKit::WebPopupTypeNone; |
| 785 } | 786 } |
| 786 | 787 |
| 787 BackingStore* RenderWidgetHostViewMac::AllocBackingStore( | 788 BackingStore* RenderWidgetHostViewMac::AllocBackingStore( |
| 788 const gfx::Size& size) { | 789 const gfx::Size& size) { |
| 789 return new BackingStoreMac(render_widget_host_, size); | 790 return new BackingStoreMac(render_widget_host_, size); |
| 790 } | 791 } |
| 791 | 792 |
| 792 bool RenderWidgetHostViewMac::CopyFromCompositingSurface( | 793 void RenderWidgetHostViewMac::CopyFromCompositingSurface( |
| 793 const gfx::Size& size, | |
| 794 skia::PlatformCanvas* output) { | |
| 795 if (!compositing_iosurface_.get() || | |
| 796 !compositing_iosurface_->HasIOSurface()) | |
| 797 return false; | |
| 798 | |
| 799 if (!output->initialize(size.width(), size.height(), true)) | |
| 800 return false; | |
| 801 | |
| 802 return compositing_iosurface_->CopyTo( | |
| 803 size, output->getTopDevice()->accessBitmap(true).getPixels()); | |
| 804 } | |
| 805 | |
| 806 void RenderWidgetHostViewMac::AsyncCopyFromCompositingSurface( | |
| 807 const gfx::Size& size, | 794 const gfx::Size& size, |
| 808 skia::PlatformCanvas* output, | 795 skia::PlatformCanvas* output, |
| 809 base::Callback<void(bool)> callback) { | 796 base::Callback<void(bool)> callback) { |
| 810 // TODO(mazda): Implement this. | 797 base::ScopedClosureRunner scoped_callback_runner(base::Bind(callback, false)); |
| 811 NOTIMPLEMENTED(); | 798 if (!compositing_iosurface_.get() || |
| 812 callback.Run(false); | 799 !compositing_iosurface_->HasIOSurface()) |
| 800 return; |
| 801 |
| 802 if (!output->initialize(size.width(), size.height(), true)) |
| 803 return; |
| 804 |
| 805 const bool result = compositing_iosurface_->CopyTo( |
| 806 size, output->getTopDevice()->accessBitmap(true).getPixels()); |
| 807 scoped_callback_runner.Release(); |
| 808 callback.Run(result); |
| 813 } | 809 } |
| 814 | 810 |
| 815 // Sets whether or not to accept first responder status. | 811 // Sets whether or not to accept first responder status. |
| 816 void RenderWidgetHostViewMac::SetTakesFocusOnlyOnMouseDown(bool flag) { | 812 void RenderWidgetHostViewMac::SetTakesFocusOnlyOnMouseDown(bool flag) { |
| 817 [cocoa_view_ setTakesFocusOnlyOnMouseDown:flag]; | 813 [cocoa_view_ setTakesFocusOnlyOnMouseDown:flag]; |
| 818 } | 814 } |
| 819 | 815 |
| 820 void RenderWidgetHostViewMac::ForwardMouseEvent(const WebMouseEvent& event) { | 816 void RenderWidgetHostViewMac::ForwardMouseEvent(const WebMouseEvent& event) { |
| 821 if (render_widget_host_) | 817 if (render_widget_host_) |
| 822 render_widget_host_->ForwardMouseEvent(event); | 818 render_widget_host_->ForwardMouseEvent(event); |
| (...skipping 2074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2897 if (!string) return NO; | 2893 if (!string) return NO; |
| 2898 | 2894 |
| 2899 // If the user is currently using an IME, confirm the IME input, | 2895 // If the user is currently using an IME, confirm the IME input, |
| 2900 // and then insert the text from the service, the same as TextEdit and Safari. | 2896 // and then insert the text from the service, the same as TextEdit and Safari. |
| 2901 [self confirmComposition]; | 2897 [self confirmComposition]; |
| 2902 [self insertText:string]; | 2898 [self insertText:string]; |
| 2903 return YES; | 2899 return YES; |
| 2904 } | 2900 } |
| 2905 | 2901 |
| 2906 @end | 2902 @end |
| OLD | NEW |