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

Side by Side Diff: chrome/browser/ui/gtk/browser_window_gtk.cc

Issue 63173016: DevTools: place DevTools WebContents underneath inspected WebContents. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "chrome/browser/ui/gtk/browser_window_gtk.h" 5 #include "chrome/browser/ui/gtk/browser_window_gtk.h"
6 6
7 #include <gdk/gdkkeysyms.h> 7 #include <gdk/gdkkeysyms.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <string> 10 #include <string>
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 : window_(NULL), 218 : window_(NULL),
219 window_has_shown_(false), 219 window_has_shown_(false),
220 window_container_(NULL), 220 window_container_(NULL),
221 window_vbox_(NULL), 221 window_vbox_(NULL),
222 render_area_vbox_(NULL), 222 render_area_vbox_(NULL),
223 render_area_floating_container_(NULL), 223 render_area_floating_container_(NULL),
224 render_area_event_box_(NULL), 224 render_area_event_box_(NULL),
225 toolbar_border_(NULL), 225 toolbar_border_(NULL),
226 browser_(browser), 226 browser_(browser),
227 state_(GDK_WINDOW_STATE_WITHDRAWN), 227 state_(GDK_WINDOW_STATE_WITHDRAWN),
228 devtools_dock_side_(DEVTOOLS_DOCK_SIDE_BOTTOM),
229 devtools_window_(NULL), 228 devtools_window_(NULL),
230 contents_hsplit_(NULL), 229 contents_hsplit_(NULL),
231 contents_vsplit_(NULL), 230 contents_vsplit_(NULL),
232 frame_cursor_(NULL), 231 frame_cursor_(NULL),
233 is_active_(false), 232 is_active_(false),
234 show_state_after_show_(ui::SHOW_STATE_DEFAULT), 233 show_state_after_show_(ui::SHOW_STATE_DEFAULT),
235 suppress_window_raise_(false), 234 suppress_window_raise_(false),
236 accel_group_(NULL), 235 accel_group_(NULL),
237 is_fullscreen_(false) { 236 is_fullscreen_(false) {
238 } 237 }
(...skipping 2028 matching lines...) Expand 10 before | Expand all | Expand 10 after
2267 // changes, we can't consistently repaint the frame at the right time. Instead 2266 // changes, we can't consistently repaint the frame at the right time. Instead
2268 // we always draw the frame as active. 2267 // we always draw the frame as active.
2269 return true; 2268 return true;
2270 } 2269 }
2271 2270
2272 void BrowserWindowGtk::UpdateDevToolsForContents(WebContents* contents) { 2271 void BrowserWindowGtk::UpdateDevToolsForContents(WebContents* contents) {
2273 TRACE_EVENT0("ui::gtk", "BrowserWindowGtk::UpdateDevToolsForContents"); 2272 TRACE_EVENT0("ui::gtk", "BrowserWindowGtk::UpdateDevToolsForContents");
2274 DevToolsWindow* new_devtools_window = contents ? 2273 DevToolsWindow* new_devtools_window = contents ?
2275 DevToolsWindow::GetDockedInstanceForInspectedTab(contents) : NULL; 2274 DevToolsWindow::GetDockedInstanceForInspectedTab(contents) : NULL;
2276 2275
2277 // Fast return in case of the same window having same orientation.
2278 if (devtools_window_ == new_devtools_window && (!new_devtools_window ||
2279 new_devtools_window->dock_side() == devtools_dock_side_)) {
2280 return;
2281 }
2282
2283 // Replace tab contents. 2276 // Replace tab contents.
2284 if (devtools_window_ != new_devtools_window) { 2277 if (devtools_window_ != new_devtools_window) {
2285 if (devtools_window_) 2278 if (devtools_window_)
2286 devtools_container_->DetachTab(devtools_window_->web_contents()); 2279 devtools_container_->DetachTab(devtools_window_->web_contents());
2287 devtools_container_->SetTab( 2280 devtools_container_->SetTab(
2288 new_devtools_window ? new_devtools_window->web_contents() : NULL); 2281 new_devtools_window ? new_devtools_window->web_contents() : NULL);
2289 if (new_devtools_window) { 2282 if (new_devtools_window) {
2290 // WebContentsViewGtk::WasShown is not called when a web contents is shown 2283 // WebContentsViewGtk::WasShown is not called when a web contents is shown
2291 // by anything other than user selecting a Tab. 2284 // by anything other than user selecting a Tab.
2292 // See TabContentsViewViews::OnWindowPosChanged for reference on how it 2285 // See TabContentsViewViews::OnWindowPosChanged for reference on how it
2293 // should be implemented. 2286 // should be implemented.
2294 new_devtools_window->web_contents()->WasShown(); 2287 new_devtools_window->web_contents()->WasShown();
2295 } 2288 }
2296 } 2289 }
2297 2290
2298 // Store last used position. 2291 // Show / hide container if necessary.
2299 if (devtools_window_) { 2292 bool should_hide = devtools_window_ && !new_devtools_window;
2300 GtkAllocation contents_rect; 2293 bool should_show = new_devtools_window && !devtools_window_;
2301 gtk_widget_get_allocation(contents_vsplit_, &contents_rect);
2302 int split_size;
2303 if (devtools_dock_side_ == DEVTOOLS_DOCK_SIDE_RIGHT) {
2304 gtk_widget_style_get(contents_hsplit_, "handle-size", &split_size, NULL);
2305 devtools_window_->SetWidth(
2306 contents_rect.width - split_size -
2307 gtk_paned_get_position(GTK_PANED(contents_hsplit_)));
2308 } else if (devtools_dock_side_ == DEVTOOLS_DOCK_SIDE_BOTTOM) {
2309 gtk_widget_style_get(contents_vsplit_, "handle-size", &split_size, NULL);
2310 devtools_window_->SetHeight(
2311 contents_rect.height - split_size -
2312 gtk_paned_get_position(GTK_PANED(contents_vsplit_)));
2313 }
2314 }
2315
2316 // Show / hide container if necessary. Changing dock orientation is
2317 // hide + show.
2318 bool should_hide = devtools_window_ && (!new_devtools_window ||
2319 devtools_dock_side_ != new_devtools_window->dock_side());
2320 bool should_show = new_devtools_window && (!devtools_window_ || should_hide);
2321 2294
2322 if (should_hide) 2295 if (should_hide)
2323 HideDevToolsContainer(); 2296 HideDevToolsContainer();
2324 2297
2325 devtools_window_ = new_devtools_window; 2298 devtools_window_ = new_devtools_window;
2326 2299
2327 if (should_show) { 2300 if (should_show) {
2328 devtools_dock_side_ = new_devtools_window->dock_side();
2329 ShowDevToolsContainer(); 2301 ShowDevToolsContainer();
2330 } else if (new_devtools_window) { 2302 } else if (new_devtools_window) {
2331 UpdateDevToolsSplitPosition(); 2303 UpdateDevToolsSplitPosition();
2332 } 2304 }
2333 } 2305 }
2334 2306
2335 void BrowserWindowGtk::ShowDevToolsContainer() { 2307 void BrowserWindowGtk::ShowDevToolsContainer() {
2336 if (devtools_dock_side_ == DEVTOOLS_DOCK_SIDE_MINIMIZED) { 2308 gtk_widget_set_size_request(devtools_container_->widget(),
2337 gtk_box_pack_end(GTK_BOX(render_area_vbox_), 2309 devtools_window_->GetMinimumSize().width(),
2338 devtools_container_->widget(), FALSE, FALSE, 0); 2310 devtools_window_->GetMinimumSize().height());
2339 gtk_box_reorder_child(GTK_BOX(render_area_vbox_), 2311 gtk_paned_pack2(GTK_PANED(contents_vsplit_),
2340 devtools_container_->widget(), 0); 2312 devtools_container_->widget(),
2341 } else { 2313 FALSE,
2342 gtk_widget_set_size_request(devtools_container_->widget(), 2314 FALSE);
2343 devtools_window_->GetMinimumWidth(),
2344 devtools_window_->GetMinimumHeight());
2345 bool to_right = devtools_dock_side_ == DEVTOOLS_DOCK_SIDE_RIGHT;
2346 gtk_paned_pack2(GTK_PANED(to_right ? contents_hsplit_ : contents_vsplit_),
2347 devtools_container_->widget(),
2348 FALSE,
2349 FALSE);
2350 }
2351 UpdateDevToolsSplitPosition(); 2315 UpdateDevToolsSplitPosition();
2352 gtk_widget_show(devtools_container_->widget()); 2316 gtk_widget_show(devtools_container_->widget());
2353 } 2317 }
2354 2318
2355 void BrowserWindowGtk::HideDevToolsContainer() { 2319 void BrowserWindowGtk::HideDevToolsContainer() {
2356 gtk_container_remove(GTK_CONTAINER( 2320 gtk_container_remove(GTK_CONTAINER(contents_vsplit_),
2357 devtools_dock_side_ == DEVTOOLS_DOCK_SIDE_RIGHT ? contents_hsplit_ : 2321 devtools_container_->widget());
2358 devtools_dock_side_ == DEVTOOLS_DOCK_SIDE_BOTTOM ? contents_vsplit_ :
2359 render_area_vbox_),
2360 devtools_container_->widget());
2361 gtk_widget_hide(devtools_container_->widget()); 2322 gtk_widget_hide(devtools_container_->widget());
2362 } 2323 }
2363 2324
2364 void BrowserWindowGtk::UpdateDevToolsSplitPosition() { 2325 void BrowserWindowGtk::UpdateDevToolsSplitPosition() {
2365 if (!window_has_shown_) 2326 if (!window_has_shown_)
2366 return; 2327 return;
2367 2328
2368 // This is required if infobar appears/disappears, or devtools container is 2329 // This is required if infobar appears/disappears, or devtools container is
2369 // moved between |render_area_vbox_| and |contents_{v,h}split_|. 2330 // moved between |render_area_vbox_| and |contents_{v,h}split_|.
2370 gtk_container_check_resize(GTK_CONTAINER(render_area_vbox_)); 2331 gtk_container_check_resize(GTK_CONTAINER(render_area_vbox_));
2371 2332
2372 GtkAllocation contents_rect; 2333 GtkAllocation contents_rect;
2373 gtk_widget_get_allocation(contents_vsplit_, &contents_rect); 2334 gtk_widget_get_allocation(contents_vsplit_, &contents_rect);
2374 int split_size; 2335 int split_size;
2375 2336 gtk_widget_style_get(contents_vsplit_, "handle-size", &split_size, NULL);
2376 if (devtools_window_->dock_side() == DEVTOOLS_DOCK_SIDE_RIGHT) { 2337 int split_offset = (contents_rect.height - split_size) / 2;
2377 gtk_widget_style_get(contents_hsplit_, "handle-size", &split_size, NULL); 2338 gtk_paned_set_position(GTK_PANED(contents_vsplit_), split_offset);
2378 int split_offset = contents_rect.width -
2379 devtools_window_->GetWidth(contents_rect.width) - split_size;
2380 gtk_paned_set_position(GTK_PANED(contents_hsplit_), split_offset);
2381 } else if (devtools_window_->dock_side() == DEVTOOLS_DOCK_SIDE_BOTTOM) {
2382 gtk_widget_style_get(contents_vsplit_, "handle-size", &split_size, NULL);
2383 int split_offset = contents_rect.height -
2384 devtools_window_->GetHeight(contents_rect.height) - split_size;
2385 gtk_paned_set_position(GTK_PANED(contents_vsplit_), split_offset);
2386 } else {
2387 gtk_widget_set_size_request(devtools_container_->widget(),
2388 0, devtools_window_->GetMinimizedHeight());
2389 }
2390 } 2339 }
2391 2340
2392 void BrowserWindowGtk::OnUseCustomChromeFrameChanged() { 2341 void BrowserWindowGtk::OnUseCustomChromeFrameChanged() {
2393 UpdateCustomFrame(); 2342 UpdateCustomFrame();
2394 ui::SetHideTitlebarWhenMaximizedProperty( 2343 ui::SetHideTitlebarWhenMaximizedProperty(
2395 ui::GetX11WindowFromGtkWidget(GTK_WIDGET(window_)), 2344 ui::GetX11WindowFromGtkWidget(GTK_WIDGET(window_)),
2396 UseCustomFrame() ? ui::HIDE_TITLEBAR_WHEN_MAXIMIZED : 2345 UseCustomFrame() ? ui::HIDE_TITLEBAR_WHEN_MAXIMIZED :
2397 ui::SHOW_TITLEBAR_WHEN_MAXIMIZED); 2346 ui::SHOW_TITLEBAR_WHEN_MAXIMIZED);
2398 } 2347 }
2399 2348
(...skipping 23 matching lines...) Expand all
2423 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); 2372 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser);
2424 browser_window_gtk->Init(); 2373 browser_window_gtk->Init();
2425 return browser_window_gtk; 2374 return browser_window_gtk;
2426 } 2375 }
2427 2376
2428 // static 2377 // static
2429 chrome::HostDesktopType BrowserWindow::AdjustHostDesktopType( 2378 chrome::HostDesktopType BrowserWindow::AdjustHostDesktopType(
2430 chrome::HostDesktopType desktop_type) { 2379 chrome::HostDesktopType desktop_type) {
2431 return desktop_type; 2380 return desktop_type;
2432 } 2381 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698