Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: chrome/browser/ui/cocoa/dev_tools_controller.mm

Issue 12226086: Alternate NTP: Fix dev tools layout (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/dev_tools_controller_browsertest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #import "chrome/browser/ui/cocoa/dev_tools_controller.h" 5 #import "chrome/browser/ui/cocoa/dev_tools_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include <Cocoa/Cocoa.h> 9 #include <Cocoa/Cocoa.h>
10 10
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 - (NSView*)hitTest:(NSPoint)point { 49 - (NSView*)hitTest:(NSPoint)point {
50 NSPoint viewPoint = [self convertPoint:point fromView:[self superview]]; 50 NSPoint viewPoint = [self convertPoint:point fromView:[self superview]];
51 if (viewPoint.y < topContentOffset_) 51 if (viewPoint.y < topContentOffset_)
52 return nil; 52 return nil;
53 return [super hitTest:point]; 53 return [super hitTest:point];
54 } 54 }
55 55
56 @end 56 @end
57 57
58 // Superview for the dev tools contents view. This class ensures that dev tools
59 // view doesn't overlap the toolbar when split vertically.
60 @interface DevToolsContainerView : NSView
61 @end
62
63 @implementation DevToolsContainerView
64
65 - (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize {
66 NSRect subviewFrame = [self bounds];
67 GraySplitView* splitView =
68 base::mac::ObjCCastStrict<GraySplitView>([self superview]);
69 if ([splitView isVertical])
70 subviewFrame.size.height -= [splitView topContentOffset];
71
72 DCHECK_EQ(1u, [[self subviews] count]);
73 [[[self subviews] lastObject] setFrame:subviewFrame];
74 }
75
76 @end
77
78
79 @interface DevToolsController (Private) 58 @interface DevToolsController (Private)
80 - (void)showDevToolsContainer; 59 - (void)showDevToolsContainer;
81 - (void)hideDevToolsContainer; 60 - (void)hideDevToolsContainer;
82 - (void)updateDevToolsSplitPosition; 61 - (void)updateDevToolsSplitPosition;
83 @end 62 @end
84 63
85 64
86 @implementation DevToolsController 65 @implementation DevToolsController
87 66
88 - (id)init { 67 - (id)init {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 NSArray* subviews = [splitView_ subviews]; 135 NSArray* subviews = [splitView_ subviews];
157 DCHECK_EQ([subviews count], 1u); 136 DCHECK_EQ([subviews count], 1u);
158 WebContents* devToolsContents = devToolsWindow_->web_contents(); 137 WebContents* devToolsContents = devToolsWindow_->web_contents();
159 138
160 // |devToolsView| is a TabContentsViewCocoa object, whose ViewID was 139 // |devToolsView| is a TabContentsViewCocoa object, whose ViewID was
161 // set to VIEW_ID_TAB_CONTAINER initially, so we need to change it to 140 // set to VIEW_ID_TAB_CONTAINER initially, so we need to change it to
162 // VIEW_ID_DEV_TOOLS_DOCKED here. 141 // VIEW_ID_DEV_TOOLS_DOCKED here.
163 NSView* devToolsView = devToolsContents->GetNativeView(); 142 NSView* devToolsView = devToolsContents->GetNativeView();
164 view_id_util::SetID(devToolsView, VIEW_ID_DEV_TOOLS_DOCKED); 143 view_id_util::SetID(devToolsView, VIEW_ID_DEV_TOOLS_DOCKED);
165 144
166 scoped_nsobject<DevToolsContainerView> devToolsContainerView( 145 NSRect containerRect = NSMakeRect(0, 0, 100, 100);
167 [[DevToolsContainerView alloc] initWithFrame:[devToolsView bounds]]); 146 scoped_nsobject<NSView> devToolsContainerView(
147 [[NSView alloc] initWithFrame:containerRect]);
148
149 NSRect devToolsRect = containerRect;
150 if (devToolsWindow_->dock_side() == DEVTOOLS_DOCK_SIDE_RIGHT) {
151 devToolsRect.size.height -= [splitView_ topContentOffset];
152 }
153 [devToolsView setFrame:devToolsRect];
154 [devToolsView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
155
168 [devToolsContainerView addSubview:devToolsView]; 156 [devToolsContainerView addSubview:devToolsView];
169 [splitView_ addSubview:devToolsContainerView]; 157 [splitView_ addSubview:devToolsContainerView];
170 158
171 BOOL isVertical = devToolsWindow_->dock_side() == DEVTOOLS_DOCK_SIDE_RIGHT; 159 BOOL isVertical = devToolsWindow_->dock_side() == DEVTOOLS_DOCK_SIDE_RIGHT;
172 [splitView_ setVertical:isVertical]; 160 [splitView_ setVertical:isVertical];
173 [self updateDevToolsSplitPosition]; 161 [self updateDevToolsSplitPosition];
174 } 162 }
175 163
176 - (void)hideDevToolsContainer { 164 - (void)hideDevToolsContainer {
177 NSArray* subviews = [splitView_ subviews]; 165 NSArray* subviews = [splitView_ subviews];
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 return [splitView_ topContentOffset]; 220 return [splitView_ topContentOffset];
233 } 221 }
234 return proposedPosition; 222 return proposedPosition;
235 } 223 }
236 224
237 -(void)splitViewWillResizeSubviews:(NSNotification *)notification { 225 -(void)splitViewWillResizeSubviews:(NSNotification *)notification {
238 [[splitView_ window] disableScreenUpdatesUntilFlush]; 226 [[splitView_ window] disableScreenUpdatesUntilFlush];
239 } 227 }
240 228
241 @end 229 @end
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/dev_tools_controller_browsertest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698