| 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 void RenderWidgetHostViewMac::UpdateCursor(const WebCursor& cursor) { | 489 void RenderWidgetHostViewMac::UpdateCursor(const WebCursor& cursor) { |
| 491 current_cursor_ = cursor; | 490 current_cursor_ = cursor; |
| 492 UpdateCursorIfNecessary(); | 491 UpdateCursorIfNecessary(); |
| 493 } | 492 } |
| 494 | 493 |
| 495 void RenderWidgetHostViewMac::UpdateCursorIfNecessary() { | 494 void RenderWidgetHostViewMac::UpdateCursorIfNecessary() { |
| 496 // Do something special (as Win Chromium does) for arrow cursor while loading | 495 // Do something special (as Win Chromium does) for arrow cursor while loading |
| 497 // a page? TODO(avi): decide | 496 // a page? TODO(avi): decide |
| 498 | 497 |
| 499 // Don't update the cursor if a context menu is being shown. | 498 // Don't update the cursor if a context menu is being shown. |
| 500 if (is_showing_context_menu_) | 499 if (showing_context_menu()) |
| 501 return; | 500 return; |
| 502 | 501 |
| 503 // Can we synchronize to the event stream? Switch to -[NSWindow | 502 // Can we synchronize to the event stream? Switch to -[NSWindow |
| 504 // mouseLocationOutsideOfEventStream] if we cannot. TODO(avi): test and see | 503 // mouseLocationOutsideOfEventStream] if we cannot. TODO(avi): test and see |
| 505 NSEvent* event = [[cocoa_view_ window] currentEvent]; | 504 NSEvent* event = [[cocoa_view_ window] currentEvent]; |
| 506 if ([event window] != [cocoa_view_ window]) | 505 if ([event window] != [cocoa_view_ window]) |
| 507 return; | 506 return; |
| 508 | 507 |
| 509 NSCursor* ns_cursor = current_cursor_.GetCursor(); | 508 NSCursor* ns_cursor = current_cursor_.GetCursor(); |
| 510 [ns_cursor set]; | 509 [ns_cursor set]; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 | 686 |
| 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::SetShowingContextMenu(bool showing) { |
| 698 DCHECK_NE(is_showing_context_menu_, showing); | 697 RenderWidgetHostView::SetShowingContextMenu(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 |