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

Unified Diff: chrome/browser/ui/gtk/browser_window_gtk.cc

Issue 7121012: DevTools window doesn't restore its minimal size if it's shrinked to zero. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments addressed Created 9 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/gtk/browser_window_gtk.cc
diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc
index f3b9706d6acfcbd2ce44921f4c93a2cadfbc79d2..20a9c8ddcfbd4ff47d2218f1fe4c913d7e47b175 100644
--- a/chrome/browser/ui/gtk/browser_window_gtk.cc
+++ b/chrome/browser/ui/gtk/browser_window_gtk.cc
@@ -101,10 +101,8 @@ namespace {
// The number of milliseconds between loading animation frames.
const int kLoadingAnimationFrameTimeMs = 30;
-// Default height of dev tools pane when docked to the browser window. This
-// matches the value in Views.
-const int kDefaultDevToolsHeight = 200;
-
+// Minimal height of devotools pane or content pane when devtools are docked
+// to the browser window.
const int kMinDevToolsHeight = 50;
const char* kBrowserWindowKey = "__BROWSER_WINDOW_GTK__";
@@ -1299,13 +1297,26 @@ void BrowserWindowGtk::UpdateDevToolsForContents(TabContents* contents) {
bool should_show = old_devtools == NULL && devtools_contents != NULL;
bool should_hide = old_devtools != NULL && devtools_contents == NULL;
+
if (should_show) {
+ // Restore split offset.
+ GtkAllocation contents_rect;
+ gtk_widget_get_allocation(contents_container_->widget(), &contents_rect);
+
+ int split_offset = browser_->profile()->GetPrefs()->
+ GetInteger(prefs::kDevToolsSplitLocation);
+ if (split_offset == -1)
+ split_offset = contents_rect.height * 2 / 3;
+
+ // Make sure user can see both panes.
+ split_offset = std::min(contents_rect.height - kMinDevToolsHeight,
yurys 2011/06/08 08:14:27 Can we handle the case of negative offset explicit
+ std::max(kMinDevToolsHeight, split_offset));
+ gtk_paned_set_position(GTK_PANED(contents_split_), split_offset);
gtk_widget_show(devtools_container_->widget());
} else if (should_hide) {
- // Store split offset when hiding devtools window only.
- gint divider_offset = gtk_paned_get_position(GTK_PANED(contents_split_));
+ gint split_offset = gtk_paned_get_position(GTK_PANED(contents_split_));
browser_->profile()->GetPrefs()->
- SetInteger(prefs::kDevToolsSplitLocation, divider_offset);
+ SetInteger(prefs::kDevToolsSplitLocation, split_offset);
gtk_widget_hide(devtools_container_->widget());
}
}
@@ -1686,17 +1697,7 @@ void BrowserWindowGtk::InitWidgets() {
gtk_paned_pack2(GTK_PANED(contents_split_), devtools_container_->widget(),
FALSE, TRUE);
gtk_box_pack_end(GTK_BOX(render_area_vbox_), contents_split_, TRUE, TRUE, 0);
- // Restore split offset.
- int split_offset = browser_->profile()->GetPrefs()->
- GetInteger(prefs::kDevToolsSplitLocation);
- if (split_offset != -1) {
- if (split_offset < kMinDevToolsHeight)
- split_offset = kMinDevToolsHeight;
- gtk_paned_set_position(GTK_PANED(contents_split_), split_offset);
- } else {
- gtk_widget_set_size_request(devtools_container_->widget(), -1,
- kDefaultDevToolsHeight);
- }
+
gtk_widget_show_all(render_area_floating_container_);
gtk_widget_hide(devtools_container_->widget());
render_area_event_box_ = gtk_event_box_new();

Powered by Google App Engine
This is Rietveld 408576698