| 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/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 // RenderWidgetHostViewMac, public: | 228 // RenderWidgetHostViewMac, public: |
| 229 | 229 |
| 230 RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget) | 230 RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget) |
| 231 : render_widget_host_(widget), | 231 : render_widget_host_(widget), |
| 232 about_to_validate_and_paint_(false), | 232 about_to_validate_and_paint_(false), |
| 233 call_set_needs_display_in_rect_pending_(false), | 233 call_set_needs_display_in_rect_pending_(false), |
| 234 last_frame_was_accelerated_(false), | 234 last_frame_was_accelerated_(false), |
| 235 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 235 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
| 236 is_loading_(false), | 236 is_loading_(false), |
| 237 is_hidden_(false), | 237 is_hidden_(false), |
| 238 is_showing_context_menu_(false), | |
| 239 weak_factory_(this), | 238 weak_factory_(this), |
| 240 accelerated_compositing_active_(false), | 239 accelerated_compositing_active_(false), |
| 241 needs_gpu_visibility_update_after_repaint_(false), | 240 needs_gpu_visibility_update_after_repaint_(false), |
| 242 compositing_surface_(gfx::kNullPluginWindow) { | 241 compositing_surface_(gfx::kNullPluginWindow) { |
| 243 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_| | 242 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_| |
| 244 // goes away. Since we autorelease it, our caller must put | 243 // goes away. Since we autorelease it, our caller must put |
| 245 // |GetNativeView()| into the view hierarchy right after calling us. | 244 // |GetNativeView()| into the view hierarchy right after calling us. |
| 246 cocoa_view_ = [[[RenderWidgetHostViewCocoa alloc] | 245 cocoa_view_ = [[[RenderWidgetHostViewCocoa alloc] |
| 247 initWithRenderWidgetHostViewMac:this] autorelease]; | 246 initWithRenderWidgetHostViewMac:this] autorelease]; |
| 248 render_widget_host_->SetView(this); | 247 render_widget_host_->SetView(this); |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 [cocoa_view_ setSelectedRange:range.ToNSRange()]; | 687 [cocoa_view_ setSelectedRange:range.ToNSRange()]; |
| 689 // Updaes markedRange when there is no marked text so that retrieving | 688 // Updaes markedRange when there is no marked text so that retrieving |
| 690 // markedRange immediately after calling setMarkdText: returns the current | 689 // markedRange immediately after calling setMarkdText: returns the current |
| 691 // caret position. | 690 // caret position. |
| 692 if (![cocoa_view_ hasMarkedText]) { | 691 if (![cocoa_view_ hasMarkedText]) { |
| 693 [cocoa_view_ setMarkedRange:range.ToNSRange()]; | 692 [cocoa_view_ setMarkedRange:range.ToNSRange()]; |
| 694 } | 693 } |
| 695 } | 694 } |
| 696 | 695 |
| 697 void RenderWidgetHostViewMac::ShowingContextMenu(bool showing) { | 696 void RenderWidgetHostViewMac::ShowingContextMenu(bool showing) { |
| 698 DCHECK_NE(is_showing_context_menu_, showing); | 697 RenderWidgetHostView::ShowingContextMenu(showing); |
| 699 is_showing_context_menu_ = showing; | |
| 700 | 698 |
| 701 // If the menu was closed, restore the cursor to the saved version initially, | 699 // If the menu was closed, restore the cursor to the saved version initially, |
| 702 // as the renderer will not re-send it if there was no change. | 700 // as the renderer will not re-send it if there was no change. |
| 703 if (!showing) | 701 if (!showing) |
| 704 UpdateCursorIfNecessary(); | 702 UpdateCursorIfNecessary(); |
| 705 | 703 |
| 706 // Create a fake mouse event to inform the render widget that the mouse | 704 // Create a fake mouse event to inform the render widget that the mouse |
| 707 // left or entered. | 705 // left or entered. |
| 708 NSWindow* window = [cocoa_view_ window]; | 706 NSWindow* window = [cocoa_view_ window]; |
| 709 // TODO(asvitkine): If the location outside of the event stream doesn't | 707 // TODO(asvitkine): If the location outside of the event stream doesn't |
| (...skipping 2060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2770 if (!string) return NO; | 2768 if (!string) return NO; |
| 2771 | 2769 |
| 2772 // If the user is currently using an IME, confirm the IME input, | 2770 // If the user is currently using an IME, confirm the IME input, |
| 2773 // and then insert the text from the service, the same as TextEdit and Safari. | 2771 // and then insert the text from the service, the same as TextEdit and Safari. |
| 2774 [self confirmComposition]; | 2772 [self confirmComposition]; |
| 2775 [self insertText:string]; | 2773 [self insertText:string]; |
| 2776 return YES; | 2774 return YES; |
| 2777 } | 2775 } |
| 2778 | 2776 |
| 2779 @end | 2777 @end |
| OLD | NEW |