Index: chrome/browser/ui/cocoa/dev_tools_controller.mm |
diff --git a/chrome/browser/ui/cocoa/dev_tools_controller.mm b/chrome/browser/ui/cocoa/dev_tools_controller.mm |
index 9ce194040d992c6359fddc164f257c7248d8da95..978d6b6ebaeb83a5f7309a3eb9871167cf7def24 100644 |
--- a/chrome/browser/ui/cocoa/dev_tools_controller.mm |
+++ b/chrome/browser/ui/cocoa/dev_tools_controller.mm |
@@ -30,40 +30,46 @@ using content::WebContents; |
NSView* contentsView_; |
} |
-- (void)setContentsResizingStrategy: |
+- (void)setDevToolsView:(NSView*)devToolsView withStrategy: |
(const DevToolsContentsResizingStrategy&)strategy; |
Alexei Svitkine (slow)
2014/07/15 14:02:19
Nit: Wrap before "withStrategy:" and align the :'s
dgozman
2014/07/15 14:38:41
Done.
|
- (void)adjustSubviews; |
-- (void)showDevTools:(NSView*)devToolsView; |
-- (void)hideDevTools; |
+- (BOOL)hasDevToolsView; |
@end |
@implementation DevToolsContainerView |
-- (void)setContentsResizingStrategy: |
+- (void)setDevToolsView:(NSView*)devToolsView withStrategy: |
Alexei Svitkine (slow)
2014/07/15 14:02:19
Nit: Ditto.
dgozman
2014/07/15 14:38:41
Done.
|
(const DevToolsContentsResizingStrategy&)strategy { |
strategy_.CopyFrom(strategy); |
+ |
+ if (devToolsView == devToolsView_) |
+ return; |
+ |
+ if (devToolsView_) { |
+ DCHECK_EQ(2u, [[self subviews] count]); |
+ [devToolsView_ removeFromSuperview]; |
+ contentsView_ = nil; |
+ devToolsView_ = nil; |
+ } |
+ |
+ if (devToolsView) { |
+ NSArray* subviews = [self subviews]; |
+ DCHECK_EQ(1u, [subviews count]); |
+ contentsView_ = [subviews objectAtIndex:0]; |
+ devToolsView_ = devToolsView; |
+ // Place DevTools under contents. |
+ [self addSubview:devToolsView positioned:NSWindowBelow relativeTo:nil]; |
+ } |
} |
- (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize { |
[self adjustSubviews]; |
} |
-- (void)showDevTools:(NSView*)devToolsView { |
- NSArray* subviews = [self subviews]; |
- DCHECK_EQ(1u, [subviews count]); |
- contentsView_ = [subviews objectAtIndex:0]; |
- devToolsView_ = devToolsView; |
- // Place DevTools under contents. |
- [self addSubview:devToolsView positioned:NSWindowBelow relativeTo:nil]; |
-} |
- |
-- (void)hideDevTools { |
- DCHECK_EQ(2u, [[self subviews] count]); |
- [devToolsView_ removeFromSuperview]; |
- contentsView_ = nil; |
- devToolsView_ = nil; |
+- (BOOL)hasDevToolsView { |
+ return devToolsView_ != nil; |
} |
- (void)adjustSubviews { |
@@ -92,11 +98,6 @@ using content::WebContents; |
@end |
-@interface DevToolsController (Private) |
-- (void)showDevToolsView; |
-- (void)hideDevToolsView; |
-@end |
- |
@implementation DevToolsController |
@@ -122,47 +123,32 @@ using content::WebContents; |
// Make sure we do not draw any transient arrangements of views. |
gfx::ScopedNSDisableScreenUpdates disabler; |
- bool shouldHide = devTools_ && devTools_ != devTools; |
- bool shouldShow = devTools && devTools_ != devTools; |
- |
- if (shouldHide) |
- [self hideDevToolsView]; |
- |
- devTools_ = devTools; |
- if (devTools_) { |
- devTools_->SetOverlayView( |
- contents, |
- gfx::Point(strategy.insets().left(), strategy.insets().top())); |
- [devToolsContainerView_ setContentsResizingStrategy:strategy]; |
- } else { |
- DevToolsContentsResizingStrategy zeroStrategy; |
- [devToolsContainerView_ setContentsResizingStrategy:zeroStrategy]; |
- } |
- |
- if (shouldShow) |
- [self showDevToolsView]; |
- [devToolsContainerView_ adjustSubviews]; |
-} |
+ if (devTools && ![devToolsContainerView_ hasDevToolsView]) { |
+ focusTracker_.reset( |
+ [[FocusTracker alloc] initWithWindow:[devToolsContainerView_ window]]); |
+ } |
-- (void)showDevToolsView { |
- focusTracker_.reset( |
- [[FocusTracker alloc] initWithWindow:[devToolsContainerView_ window]]); |
+ if (!devTools && [devToolsContainerView_ hasDevToolsView]) { |
+ [focusTracker_ restoreFocusInWindow:[devToolsContainerView_ window]]; |
+ focusTracker_.reset(); |
+ } |
- // |devToolsView| is a WebContentsViewCocoa object, whose ViewID was |
- // set to VIEW_ID_TAB_CONTAINER initially, so we need to change it to |
- // VIEW_ID_DEV_TOOLS_DOCKED here. |
- NSView* devToolsView = devTools_->GetNativeView(); |
- view_id_util::SetID(devToolsView, VIEW_ID_DEV_TOOLS_DOCKED); |
+ NSView* devToolsView = devTools ? devTools->GetNativeView() : nil; |
Alexei Svitkine (slow)
2014/07/15 14:02:19
Nit: Given that you have an "if (devTools)" right
dgozman
2014/07/15 14:38:41
Done.
|
+ if (devTools) { |
+ // |devToolsView| is a WebContentsViewCocoa object, whose ViewID was |
+ // set to VIEW_ID_TAB_CONTAINER initially, so we need to change it to |
+ // VIEW_ID_DEV_TOOLS_DOCKED here. |
+ view_id_util::SetID(devToolsView, VIEW_ID_DEV_TOOLS_DOCKED); |
- [devToolsContainerView_ showDevTools:devToolsView]; |
-} |
+ devTools->SetAllowOtherViews(true); |
+ contents->SetAllowOtherViews(true); |
+ } else { |
+ contents->SetAllowOtherViews(false); |
+ } |
-- (void)hideDevToolsView { |
- devTools_->RemoveOverlayView(); |
- [devToolsContainerView_ hideDevTools]; |
- [focusTracker_ restoreFocusInWindow:[devToolsContainerView_ window]]; |
- focusTracker_.reset(); |
+ [devToolsContainerView_ setDevToolsView: devToolsView withStrategy: strategy]; |
Alexei Svitkine (slow)
2014/07/15 14:02:19
Nit: Remove spaces after :'s.
dgozman
2014/07/15 14:38:41
Done.
|
+ [devToolsContainerView_ adjustSubviews]; |
} |
@end |