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

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

Issue 137483007: [DevTools] Use special resizing strategy instead of insets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 11 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 c038e11eec3ffac823ac159ed50f8c7da3581b37..5bbc2a630cdfaa188e48860ef94f8182712802db 100644
--- a/chrome/browser/ui/gtk/browser_window_gtk.cc
+++ b/chrome/browser/ui/gtk/browser_window_gtk.cc
@@ -2280,8 +2280,9 @@ void BrowserWindowGtk::UpdateDevToolsForContents(WebContents* contents) {
HideDevToolsContainer();
devtools_window_ = new_devtools_window;
- contents_insets_ = devtools_window_ ? devtools_window_->GetContentsInsets() :
- gfx::Insets();
+ contents_resizing_strategy_ = devtools_window_ ?
+ devtools_window_->GetContentsResizingStrategy() :
+ DevToolsContentsResizingStrategy();
if (should_show)
ShowDevToolsContainer();
@@ -2306,22 +2307,30 @@ void BrowserWindowGtk::HideDevToolsContainer() {
void BrowserWindowGtk::OnDevToolsContainerSetFloatingPosition(
GtkFloatingContainer* container, GtkAllocation* allocation,
BrowserWindowGtk* browser_window) {
- gfx::Insets insets = browser_window->contents_insets_;
+ GtkAllocation contents_allocation;
+ gtk_widget_get_allocation(browser_window->contents_container_->widget(),
+ &contents_allocation);
- int contents_width = std::max(0, allocation->width - insets.width());
- int contents_height = std::max(0, allocation->height - insets.height());
- int contents_x = std::min(insets.left(), allocation->width);
- int contents_y = std::min(insets.top(), allocation->height);
+ gfx::Size container_size(allocation->width, allocation->height);
+ gfx::Rect old_devtools_bounds(0, 0, allocation->width, allocation->height);
+ gfx::Rect old_contents_bounds(contents_allocation.x, contents_allocation.y,
+ contents_allocation.width, contents_allocation.height);
+ gfx::Rect new_devtools_bounds;
+ gfx::Rect new_contents_bounds;
+
+ browser_window->contents_resizing_strategy_.Apply(container_size,
+ old_devtools_bounds, old_contents_bounds,
+ &new_devtools_bounds, &new_contents_bounds);
gtk_widget_set_size_request(browser_window->contents_container_->widget(),
- contents_width, contents_height);
+ new_contents_bounds.width(), new_contents_bounds.height());
GValue value = { 0, };
g_value_init(&value, G_TYPE_INT);
- g_value_set_int(&value, contents_x);
+ g_value_set_int(&value, new_contents_bounds.x());
gtk_container_child_set_property(GTK_CONTAINER(container),
browser_window->contents_container_->widget(), "x", &value);
- g_value_set_int(&value, contents_y);
+ g_value_set_int(&value, new_contents_bounds.y());
gtk_container_child_set_property(GTK_CONTAINER(container),
browser_window->contents_container_->widget(), "y", &value);
g_value_unset(&value);

Powered by Google App Engine
This is Rietveld 408576698