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 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 | 564 |
565 UnlockMouse(); | 565 UnlockMouse(); |
566 | 566 |
567 // Ensure that the browser compositor is destroyed in a safe order. | 567 // Ensure that the browser compositor is destroyed in a safe order. |
568 ShutdownBrowserCompositor(); | 568 ShutdownBrowserCompositor(); |
569 | 569 |
570 // We are owned by RenderWidgetHostViewCocoa, so if we go away before the | 570 // We are owned by RenderWidgetHostViewCocoa, so if we go away before the |
571 // RenderWidgetHost does we need to tell it not to hold a stale pointer to | 571 // RenderWidgetHost does we need to tell it not to hold a stale pointer to |
572 // us. | 572 // us. |
573 if (render_widget_host_) | 573 if (render_widget_host_) |
574 render_widget_host_->SetView(NULL); | 574 render_widget_host_->ViewDestroyed(this); |
575 } | 575 } |
576 | 576 |
577 void RenderWidgetHostViewMac::SetDelegate( | 577 void RenderWidgetHostViewMac::SetDelegate( |
578 NSObject<RenderWidgetHostViewMacDelegate>* delegate) { | 578 NSObject<RenderWidgetHostViewMacDelegate>* delegate) { |
579 [cocoa_view_ setResponderDelegate:delegate]; | 579 [cocoa_view_ setResponderDelegate:delegate]; |
580 } | 580 } |
581 | 581 |
582 void RenderWidgetHostViewMac::SetAllowPauseForResizeOrRepaint(bool allow) { | 582 void RenderWidgetHostViewMac::SetAllowPauseForResizeOrRepaint(bool allow) { |
583 allow_pause_for_resize_or_repaint_ = allow; | 583 allow_pause_for_resize_or_repaint_ = allow; |
584 } | 584 } |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 void RenderWidgetHostViewMac::ImeCompositionRangeChanged( | 967 void RenderWidgetHostViewMac::ImeCompositionRangeChanged( |
968 const gfx::Range& range, | 968 const gfx::Range& range, |
969 const std::vector<gfx::Rect>& character_bounds) { | 969 const std::vector<gfx::Rect>& character_bounds) { |
970 // The RangeChanged message is only sent with valid values. The current | 970 // The RangeChanged message is only sent with valid values. The current |
971 // caret position (start == end) will be sent if there is no IME range. | 971 // caret position (start == end) will be sent if there is no IME range. |
972 [cocoa_view_ setMarkedRange:range.ToNSRange()]; | 972 [cocoa_view_ setMarkedRange:range.ToNSRange()]; |
973 composition_range_ = range; | 973 composition_range_ = range; |
974 composition_bounds_ = character_bounds; | 974 composition_bounds_ = character_bounds; |
975 } | 975 } |
976 | 976 |
977 void RenderWidgetHostViewMac::RenderProcessGone(base::TerminationStatus status, | |
978 int error_code) { | |
979 Destroy(); | |
980 } | |
981 | |
982 void RenderWidgetHostViewMac::Destroy() { | 977 void RenderWidgetHostViewMac::Destroy() { |
983 [[NSNotificationCenter defaultCenter] | 978 [[NSNotificationCenter defaultCenter] |
984 removeObserver:cocoa_view_ | 979 removeObserver:cocoa_view_ |
985 name:NSWindowWillCloseNotification | 980 name:NSWindowWillCloseNotification |
986 object:popup_window_]; | 981 object:popup_window_]; |
987 | 982 |
988 // We've been told to destroy. | 983 // We've been told to destroy. |
989 [cocoa_view_ retain]; | 984 [cocoa_view_ retain]; |
990 [cocoa_view_ removeFromSuperview]; | 985 [cocoa_view_ removeFromSuperview]; |
991 [cocoa_view_ autorelease]; | 986 [cocoa_view_ autorelease]; |
(...skipping 12 matching lines...) Expand all Loading... |
1004 | 999 |
1005 // Delete the delegated frame state, which will reach back into | 1000 // Delete the delegated frame state, which will reach back into |
1006 // render_widget_host_. | 1001 // render_widget_host_. |
1007 ShutdownBrowserCompositor(); | 1002 ShutdownBrowserCompositor(); |
1008 | 1003 |
1009 // We get this call just before |render_widget_host_| deletes | 1004 // We get this call just before |render_widget_host_| deletes |
1010 // itself. But we are owned by |cocoa_view_|, which may be retained | 1005 // itself. But we are owned by |cocoa_view_|, which may be retained |
1011 // by some other code. Examples are WebContentsViewMac's | 1006 // by some other code. Examples are WebContentsViewMac's |
1012 // |latent_focus_view_| and TabWindowController's | 1007 // |latent_focus_view_| and TabWindowController's |
1013 // |cachedContentView_|. | 1008 // |cachedContentView_|. |
| 1009 render_widget_host_->ViewDestroyed(this); |
1014 render_widget_host_ = NULL; | 1010 render_widget_host_ = NULL; |
1015 } | 1011 } |
1016 | 1012 |
1017 // Called from the renderer to tell us what the tooltip text should be. It | 1013 // Called from the renderer to tell us what the tooltip text should be. It |
1018 // calls us frequently so we need to cache the value to prevent doing a lot | 1014 // calls us frequently so we need to cache the value to prevent doing a lot |
1019 // of repeat work. | 1015 // of repeat work. |
1020 void RenderWidgetHostViewMac::SetTooltipText( | 1016 void RenderWidgetHostViewMac::SetTooltipText( |
1021 const base::string16& tooltip_text) { | 1017 const base::string16& tooltip_text) { |
1022 if (tooltip_text != tooltip_text_ && [[cocoa_view_ window] isKeyWindow]) { | 1018 if (tooltip_text != tooltip_text_ && [[cocoa_view_ window] isKeyWindow]) { |
1023 tooltip_text_ = tooltip_text; | 1019 tooltip_text_ = tooltip_text; |
(...skipping 2313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3337 | 3333 |
3338 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3334 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
3339 // regions that are not draggable. (See ControlRegionView in | 3335 // regions that are not draggable. (See ControlRegionView in |
3340 // native_app_window_cocoa.mm). This requires the render host view to be | 3336 // native_app_window_cocoa.mm). This requires the render host view to be |
3341 // draggable by default. | 3337 // draggable by default. |
3342 - (BOOL)mouseDownCanMoveWindow { | 3338 - (BOOL)mouseDownCanMoveWindow { |
3343 return YES; | 3339 return YES; |
3344 } | 3340 } |
3345 | 3341 |
3346 @end | 3342 @end |
OLD | NEW |