Commit 3bfa277b authored by dgozman@chromium.org's avatar dgozman@chromium.org

[DevTools] Use special resizing strategy instead of insets.

This change:
- adds minimum contents size to be used in layout logic;
- switches to new API methods;
- moves layout logic into resizing strategy to avoid code duplication.

BUG=339425

Review URL: https://codereview.chromium.org/137483007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@248965 0039d316-1c4b-4281-b951-d872f2087c98
parent c39e9efd
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/devtools/devtools_contents_resizing_strategy.h"
DevToolsContentsResizingStrategy::DevToolsContentsResizingStrategy() {
}
DevToolsContentsResizingStrategy::DevToolsContentsResizingStrategy(
const gfx::Insets& insets, const gfx::Size& min_size)
: insets_(insets),
min_size_(min_size) {
}
void DevToolsContentsResizingStrategy::CopyFrom(
const DevToolsContentsResizingStrategy& strategy) {
insets_ = strategy.insets();
min_size_ = strategy.min_size();
}
bool DevToolsContentsResizingStrategy::Equals(
const DevToolsContentsResizingStrategy& strategy) {
return insets_ == strategy.insets() && min_size_ == strategy.min_size();
}
void ApplyDevToolsContentsResizingStrategy(
const DevToolsContentsResizingStrategy& strategy,
const gfx::Size& container_size,
const gfx::Rect& old_devtools_bounds,
const gfx::Rect& old_contents_bounds,
gfx::Rect* new_devtools_bounds,
gfx::Rect* new_contents_bounds) {
new_devtools_bounds->SetRect(
0, 0, container_size.width(), container_size.height());
const gfx::Insets& insets = strategy.insets();
const gfx::Size& min_size = strategy.min_size();
int width = std::max(0, container_size.width() - insets.width());
int left = insets.left();
if (width < min_size.width() && insets.width() > 0) {
int min_width = std::min(min_size.width(), container_size.width());
int insets_width = container_size.width() - min_width;
int insets_decrease = insets.width() - insets_width;
// Decrease both left and right insets proportionally.
left -= insets_decrease * insets.left() / insets.width();
width = min_width;
}
left = std::max(0, std::min(container_size.width(), left));
int height = std::max(0, container_size.height() - insets.height());
int top = insets.top();
if (height < min_size.height() && insets.height() > 0) {
int min_height = std::min(min_size.height(), container_size.height());
int insets_height = container_size.height() - min_height;
int insets_decrease = insets.height() - insets_height;
// Decrease both top and bottom insets proportionally.
top -= insets_decrease * insets.top() / insets.height();
height = min_height;
}
top = std::max(0, std::min(container_size.height(), top));
new_contents_bounds->SetRect(left, top, width, height);
}
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_DEVTOOLS_DEVTOOLS_CONTENTS_RESIZING_STRATEGY_H_
#define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_CONTENTS_RESIZING_STRATEGY_H_
#include "base/basictypes.h"
#include "ui/gfx/insets.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/size.h"
// This class knows how to resize both DevTools and inspected WebContents
// inside a browser window hierarchy.
class DevToolsContentsResizingStrategy {
public:
DevToolsContentsResizingStrategy();
DevToolsContentsResizingStrategy(
const gfx::Insets& insets,
const gfx::Size& min_size);
void CopyFrom(const DevToolsContentsResizingStrategy& strategy);
bool Equals(const DevToolsContentsResizingStrategy& strategy);
const gfx::Insets& insets() const { return insets_; }
const gfx::Size& min_size() const { return min_size_; }
private:
// Insets of contents inside DevTools.
gfx::Insets insets_;
// Minimum size of contents.
gfx::Size min_size_;
DISALLOW_COPY_AND_ASSIGN(DevToolsContentsResizingStrategy);
};
// Applies contents resizing strategy, producing bounds for devtools and
// page contents views. Generally, page contents view is placed atop of devtools
// inside a common parent view, which size should be passed in |container_size|.
// When unknown, providing empty rect as previous devtools and contents bounds
// is allowed.
void ApplyDevToolsContentsResizingStrategy(
const DevToolsContentsResizingStrategy& strategy,
const gfx::Size& container_size,
const gfx::Rect& old_devtools_bounds,
const gfx::Rect& old_contents_bounds,
gfx::Rect* new_devtools_bounds,
gfx::Rect* new_contents_bounds);
#endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_CONTENTS_RESIZING_STRATEGY_H_
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/devtools/devtools_contents_resizing_strategy.h"
#include "testing/gtest/include/gtest/gtest.h"
TEST(DevToolsContentsResizingStrategyTest, ApplyZero) {
DevToolsContentsResizingStrategy zeroStrategy;
gfx::Size container_size(100, 200);
gfx::Rect old_devtools_bounds(0, 0, 100, 200);
gfx::Rect old_contents_bounds(20, 20, 60, 140);
gfx::Rect new_devtools_bounds;
gfx::Rect new_contents_bounds;
ApplyDevToolsContentsResizingStrategy(
zeroStrategy, container_size,
old_devtools_bounds, old_contents_bounds,
&new_devtools_bounds, &new_contents_bounds);
EXPECT_EQ(gfx::Rect(0, 0, 100, 200), new_devtools_bounds);
EXPECT_EQ(gfx::Rect(0, 0, 100, 200), new_contents_bounds);
}
TEST(DevToolsContentsResizingStrategyTest, ApplyInsets) {
DevToolsContentsResizingStrategy strategy(
gfx::Insets(10, 20, 30, 40), gfx::Size(0, 0));
gfx::Size container_size(100, 200);
gfx::Rect old_devtools_bounds(0, 0, 100, 200);
gfx::Rect old_contents_bounds(20, 20, 60, 140);
gfx::Rect new_devtools_bounds;
gfx::Rect new_contents_bounds;
ApplyDevToolsContentsResizingStrategy(
strategy, container_size,
old_devtools_bounds, old_contents_bounds,
&new_devtools_bounds, &new_contents_bounds);
EXPECT_EQ(gfx::Rect(0, 0, 100, 200), new_devtools_bounds);
EXPECT_EQ(gfx::Rect(20, 10, 40, 160), new_contents_bounds);
}
TEST(DevToolsContentsResizingStrategyTest, ApplyMinSize) {
DevToolsContentsResizingStrategy strategy(
gfx::Insets(10, 20, 90, 30), gfx::Size(60, 120));
gfx::Size container_size(100, 200);
gfx::Rect old_devtools_bounds(0, 0, 100, 200);
gfx::Rect old_contents_bounds(20, 20, 60, 140);
gfx::Rect new_devtools_bounds;
gfx::Rect new_contents_bounds;
ApplyDevToolsContentsResizingStrategy(
strategy, container_size,
old_devtools_bounds, old_contents_bounds,
&new_devtools_bounds, &new_contents_bounds);
EXPECT_EQ(gfx::Rect(0, 0, 100, 200), new_devtools_bounds);
EXPECT_EQ(gfx::Rect(16, 8, 60, 120), new_contents_bounds);
}
TEST(DevToolsContentsResizingStrategyTest, ApplyLargeInset) {
DevToolsContentsResizingStrategy strategy(
gfx::Insets(0, 130, 0, 0), gfx::Size(60, 120));
gfx::Size container_size(100, 200);
gfx::Rect old_devtools_bounds(0, 0, 100, 200);
gfx::Rect old_contents_bounds(20, 20, 60, 140);
gfx::Rect new_devtools_bounds;
gfx::Rect new_contents_bounds;
ApplyDevToolsContentsResizingStrategy(
strategy, container_size,
old_devtools_bounds, old_contents_bounds,
&new_devtools_bounds, &new_contents_bounds);
EXPECT_EQ(gfx::Rect(0, 0, 100, 200), new_devtools_bounds);
EXPECT_EQ(gfx::Rect(40, 0, 60, 200), new_contents_bounds);
}
TEST(DevToolsContentsResizingStrategyTest, ApplyTwoLargeInsets) {
DevToolsContentsResizingStrategy strategy(
gfx::Insets(120, 0, 80, 0), gfx::Size(60, 120));
gfx::Size container_size(100, 200);
gfx::Rect old_devtools_bounds(0, 0, 100, 200);
gfx::Rect old_contents_bounds(20, 20, 60, 140);
gfx::Rect new_devtools_bounds;
gfx::Rect new_contents_bounds;
ApplyDevToolsContentsResizingStrategy(
strategy, container_size,
old_devtools_bounds, old_contents_bounds,
&new_devtools_bounds, &new_contents_bounds);
EXPECT_EQ(gfx::Rect(0, 0, 100, 200), new_devtools_bounds);
EXPECT_EQ(gfx::Rect(0, 48, 100, 120), new_contents_bounds);
}
TEST(DevToolsContentsResizingStrategyTest, ApplySmallContainer) {
DevToolsContentsResizingStrategy strategy(
gfx::Insets(10, 10, 10, 10), gfx::Size(120, 230));
gfx::Size container_size(100, 200);
gfx::Rect old_devtools_bounds(0, 0, 100, 200);
gfx::Rect old_contents_bounds(20, 20, 60, 140);
gfx::Rect new_devtools_bounds;
gfx::Rect new_contents_bounds;
ApplyDevToolsContentsResizingStrategy(
strategy, container_size,
old_devtools_bounds, old_contents_bounds,
&new_devtools_bounds, &new_contents_bounds);
EXPECT_EQ(gfx::Rect(0, 0, 100, 200), new_devtools_bounds);
EXPECT_EQ(gfx::Rect(0, 0, 100, 200), new_contents_bounds);
}
......@@ -21,6 +21,36 @@ bool GetValue(const base::ListValue& list, int pos, bool& value) {
return list.GetBoolean(pos, &value);
}
bool GetValue(const base::ListValue& list, int pos, gfx::Insets& insets) {
const base::DictionaryValue* dict;
if (!list.GetDictionary(pos, &dict))
return false;
int top = 0;
int left = 0;
int bottom = 0;
int right = 0;
if (!dict->GetInteger("top", &top) ||
!dict->GetInteger("left", &left) ||
!dict->GetInteger("bottom", &bottom) ||
!dict->GetInteger("right", &right))
return false;
insets.Set(top, left, bottom, right);
return true;
}
bool GetValue(const base::ListValue& list, int pos, gfx::Size& size) {
const base::DictionaryValue* dict;
if (!list.GetDictionary(pos, &dict))
return false;
int width = 0;
int height = 0;
if (!dict->GetInteger("width", &width) ||
!dict->GetInteger("height", &height))
return false;
size.SetSize(width, height);
return true;
}
template <typename T>
struct StorageTraits {
typedef T StorageType;
......@@ -161,6 +191,9 @@ DevToolsEmbedderMessageDispatcher::DevToolsEmbedderMessageDispatcher(
RegisterHandler("setContentsInsets",
BindToListParser(base::Bind(&Delegate::SetContentsInsets,
base::Unretained(delegate))));
RegisterHandler("setContentsResizingStrategy",
BindToListParser(base::Bind(&Delegate::SetContentsResizingStrategy,
base::Unretained(delegate))));
RegisterHandler("inspectElementCompleted",
BindToListParser(base::Bind(&Delegate::InspectElementCompleted,
base::Unretained(delegate))));
......
......@@ -9,6 +9,8 @@
#include <string>
#include "base/callback.h"
#include "ui/gfx/insets.h"
#include "ui/gfx/size.h"
namespace base {
class ListValue;
......@@ -30,6 +32,8 @@ class DevToolsEmbedderMessageDispatcher {
virtual void CloseWindow() = 0;
virtual void SetContentsInsets(
int top, int left, int bottom, int right) = 0;
virtual void SetContentsResizingStrategy(
const gfx::Insets& insets, const gfx::Size& min_size) = 0;
virtual void InspectElementCompleted() = 0;
virtual void MoveWindow(int x, int y) = 0;
virtual void SetIsDocked(bool is_docked) = 0;
......
......@@ -492,8 +492,9 @@ content::RenderViewHost* DevToolsWindow::GetRenderViewHost() {
return web_contents_->GetRenderViewHost();
}
gfx::Insets DevToolsWindow::GetContentsInsets() const {
return contents_insets_;
const DevToolsContentsResizingStrategy&
DevToolsWindow::GetContentsResizingStrategy() const {
return contents_resizing_strategy_;
}
gfx::Size DevToolsWindow::GetMinimumSize() const {
......@@ -997,14 +998,17 @@ void DevToolsWindow::CloseWindow() {
void DevToolsWindow::SetContentsInsets(
int top, int left, int bottom, int right) {
if (contents_insets_.top() == top &&
contents_insets_.left() == left &&
contents_insets_.bottom() == bottom &&
contents_insets_.right() == right) {
gfx::Insets insets(top, left, bottom, right);
SetContentsResizingStrategy(insets, contents_resizing_strategy_.min_size());
}
void DevToolsWindow::SetContentsResizingStrategy(
const gfx::Insets& insets, const gfx::Size& min_size) {
DevToolsContentsResizingStrategy strategy(insets, min_size);
if (contents_resizing_strategy_.Equals(strategy))
return;
}
contents_insets_ = gfx::Insets(top, left, bottom, right);
contents_resizing_strategy_.CopyFrom(strategy);
if (is_docked_) {
// Update inspected window.
BrowserWindow* inspected_window = GetInspectedBrowserWindow();
......
......@@ -12,6 +12,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/string16.h"
#include "chrome/browser/devtools/devtools_contents_resizing_strategy.h"
#include "chrome/browser/devtools/devtools_embedder_message_dispatcher.h"
#include "chrome/browser/devtools/devtools_file_helper.h"
#include "chrome/browser/devtools/devtools_file_system_indexer.h"
......@@ -21,7 +22,6 @@
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/web_contents_delegate.h"
#include "ui/gfx/insets.h"
#include "ui/gfx/size.h"
class Browser;
......@@ -121,9 +121,9 @@ class DevToolsWindow : private content::NotificationObserver,
content::RenderViewHost* GetRenderViewHost();
// Inspected WebContents is placed over DevTools WebContents in docked mode.
// The following methods return the insets of inspected WebContents
// relative to DevTools WebContents.
gfx::Insets GetContentsInsets() const;
// The following method returns the resizing strategy of inspected
// WebContents relative to DevTools WebContents.
const DevToolsContentsResizingStrategy& GetContentsResizingStrategy() const;
// Minimum size of the docked DevTools WebContents. This includes
// the overlaying inspected WebContents size.
......@@ -299,6 +299,8 @@ class DevToolsWindow : private content::NotificationObserver,
virtual void CloseWindow() OVERRIDE;
virtual void SetContentsInsets(
int left, int top, int right, int bottom) OVERRIDE;
virtual void SetContentsResizingStrategy(
const gfx::Insets& insets, const gfx::Size& min_size) OVERRIDE;
virtual void InspectElementCompleted() OVERRIDE;
virtual void MoveWindow(int x, int y) OVERRIDE;
virtual void SetIsDocked(bool is_docked) OVERRIDE;
......@@ -380,7 +382,7 @@ class DevToolsWindow : private content::NotificationObserver,
scoped_refptr<DevToolsFileSystemIndexer::FileSystemIndexingJob> >
IndexingJobsMap;
IndexingJobsMap indexing_jobs_;
gfx::Insets contents_insets_;
DevToolsContentsResizingStrategy contents_resizing_strategy_;
// True if we're in the process of handling a beforeunload event originating
// from the inspected webcontents, see InterceptPageBeforeUnload for details.
bool intercepted_page_beforeunload_;
......
......@@ -16,20 +16,22 @@
#include "chrome/common/pref_names.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
#include "ui/base/cocoa/base_view.h"
#include "ui/base/cocoa/focus_tracker.h"
#include "ui/gfx/size_conversions.h"
using content::WebContents;
@interface DevToolsContainerView : NSView {
gfx::Insets contentsInsets_;
@interface DevToolsContainerView : BaseView {
DevToolsContentsResizingStrategy strategy_;
// Weak references. Ownership via -subviews.
NSView* devToolsView_;
NSView* contentsView_;
}
- (void)setContentsInsets:(const gfx::Insets&)insets;
- (void)setContentsResizingStrategy:
(const DevToolsContentsResizingStrategy&)strategy;
- (void)adjustSubviews;
- (void)showDevTools:(NSView*)devToolsView;
- (void)hideDevTools;
......@@ -39,8 +41,9 @@ using content::WebContents;
@implementation DevToolsContainerView
- (void)setContentsInsets:(const gfx::Insets&)insets {
contentsInsets_ = insets;
- (void)setContentsResizingStrategy:
(const DevToolsContentsResizingStrategy&)strategy {
strategy_.CopyFrom(strategy);
}
- (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize {
......@@ -75,20 +78,15 @@ using content::WebContents;
}
DCHECK_EQ(2u, [[self subviews] count]);
NSRect bounds = [self bounds];
[devToolsView_ setFrame:bounds];
CGFloat width = std::max(static_cast<CGFloat>(0),
NSWidth(bounds) - contentsInsets_.width());
CGFloat height = std::max(static_cast<CGFloat>(0),
NSHeight(bounds) - contentsInsets_.height());
CGFloat left = std::min(static_cast<CGFloat>(contentsInsets_.left()),
NSWidth(bounds));
// Flip top and bottom for NSView geometry.
CGFloat top = std::min(static_cast<CGFloat>(contentsInsets_.bottom()),
NSHeight(bounds));
[contentsView_ setFrame:NSMakeRect(left, top, width, height)];
gfx::Rect new_devtools_bounds;
gfx::Rect new_contents_bounds;
ApplyDevToolsContentsResizingStrategy(
strategy_, gfx::Size(NSSizeToCGSize([self bounds].size)),
[self flipNSRectToRect:[devToolsView_ bounds]],
[self flipNSRectToRect:[contentsView_ bounds]],
&new_devtools_bounds, &new_contents_bounds);
[devToolsView_ setFrame:[self flipRectToNSRect:new_devtools_bounds]];
[contentsView_ setFrame:[self flipRectToNSRect:new_contents_bounds]];
}
@end
......@@ -128,13 +126,15 @@ using content::WebContents;
devToolsWindow_ = newDevToolsWindow;
if (devToolsWindow_) {
gfx::Insets insets = devToolsWindow_->GetContentsInsets();
const DevToolsContentsResizingStrategy& strategy =
devToolsWindow_->GetContentsResizingStrategy();
devToolsWindow_->web_contents()->GetView()->SetOverlayView(
contents->GetView(), gfx::Point(insets.left(), insets.top()));
[devToolsContainerView_ setContentsInsets:insets];
contents->GetView(),
gfx::Point(strategy.insets().left(), strategy.insets().top()));
[devToolsContainerView_ setContentsResizingStrategy:strategy];
} else {
gfx::Insets zeroInsets;
[devToolsContainerView_ setContentsInsets:zeroInsets];
DevToolsContentsResizingStrategy zeroStrategy;
[devToolsContainerView_ setContentsResizingStrategy:zeroStrategy];
}
if (shouldShow)
......
......@@ -2286,8 +2286,9 @@ void BrowserWindowGtk::UpdateDevToolsForContents(WebContents* contents) {
HideDevToolsContainer();
devtools_window_ = new_devtools_window;
contents_insets_ = devtools_window_ ? devtools_window_->GetContentsInsets() :
gfx::Insets();
contents_resizing_strategy_.CopyFrom(devtools_window_ ?
devtools_window_->GetContentsResizingStrategy() :
DevToolsContentsResizingStrategy());
if (should_show)
ShowDevToolsContainer();
......@@ -2312,22 +2313,31 @@ void BrowserWindowGtk::HideDevToolsContainer() {
void BrowserWindowGtk::OnDevToolsContainerSetFloatingPosition(
GtkFloatingContainer* container, GtkAllocation* allocation,
BrowserWindowGtk* browser_window) {
gfx::Insets insets = browser_window->contents_insets_;
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);
GtkAllocation contents_allocation;
gtk_widget_get_allocation(browser_window->contents_container_->widget(),
&contents_allocation);
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;
ApplyDevToolsContentsResizingStrategy(
browser_window->contents_resizing_strategy_, 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);
......
......@@ -533,9 +533,9 @@ class BrowserWindowGtk
// or is inspected with undocked version of DevToolsWindow.
DevToolsWindow* devtools_window_;
// Insets from the sides of devtools_floating_container_ to the sides of
// contents_container_. Non-zero only if docked devtools is visible.
gfx::Insets contents_insets_;
// Resizing strategy of contents_container_ inside
// devtools_floating_container_. Non-empty only if docked devtools is visible.
DevToolsContentsResizingStrategy contents_resizing_strategy_;
// Floating container for devtools_container_ and contents_container_.
// Owned by render_area_vbox_.
......
......@@ -2152,11 +2152,12 @@ void BrowserView::UpdateDevToolsForContents(
if (devtools_window_) {
devtools_web_view_->SetPreferredSize(devtools_window_->GetMinimumSize());
devtools_web_view_->SetVisible(true);
GetContentsLayoutManager()->SetContentsViewInsets(
devtools_window_->GetContentsInsets());
GetContentsLayoutManager()->SetContentsResizingStrategy(
devtools_window_->GetContentsResizingStrategy());
} else {
devtools_web_view_->SetVisible(false);
GetContentsLayoutManager()->SetContentsViewInsets(gfx::Insets());
GetContentsLayoutManager()->SetContentsResizingStrategy(
DevToolsContentsResizingStrategy());
}
contents_container_->Layout();
}
......
......@@ -18,11 +18,12 @@ ContentsLayoutManager::ContentsLayoutManager(
ContentsLayoutManager::~ContentsLayoutManager() {
}
void ContentsLayoutManager::SetContentsViewInsets(const gfx::Insets& insets) {
if (insets_ == insets)
void ContentsLayoutManager::SetContentsResizingStrategy(
const DevToolsContentsResizingStrategy& strategy) {
if (strategy_.Equals(strategy))
return;
insets_ = insets;
strategy_.CopyFrom(strategy);
if (host_)
host_->InvalidateLayout();
}
......@@ -42,15 +43,23 @@ void ContentsLayoutManager::Layout(views::View* contents_container) {
int top = active_top_margin_;
int height = std::max(0, contents_container->height() - top);
int width = contents_container->width();
devtools_view_->SetBounds(0, top, width, height);
int contents_width = std::max(0, width - insets_.width());
int contents_height = std::max(0, height - insets_.height());
contents_view_->SetBounds(
std::min(insets_.left(), width),
top + std::min(insets_.top(), height),
contents_width,
contents_height);
gfx::Size container_size(width, height);
gfx::Rect old_devtools_bounds(devtools_view_->bounds());
gfx::Rect old_contents_bounds(contents_view_->bounds());
gfx::Rect new_devtools_bounds;
gfx::Rect new_contents_bounds;
old_devtools_bounds.Offset(0, -top);
old_contents_bounds.Offset(0, -top);
ApplyDevToolsContentsResizingStrategy(strategy_, container_size,
old_devtools_bounds, old_contents_bounds,
&new_devtools_bounds, &new_contents_bounds);
new_devtools_bounds.Offset(0, top);
new_contents_bounds.Offset(0, top);
devtools_view_->SetBoundsRect(new_devtools_bounds);
contents_view_->SetBoundsRect(new_contents_bounds);
}
gfx::Size ContentsLayoutManager::GetPreferredSize(views::View* host) {
......
......@@ -7,7 +7,7 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "ui/gfx/insets.h"
#include "chrome/browser/devtools/devtools_contents_resizing_strategy.h"
#include "ui/views/layout/layout_manager.h"
// ContentsLayoutManager positions the WebContents and devtools WebContents.
......@@ -20,8 +20,9 @@ class ContentsLayoutManager : public views::LayoutManager {
// pushed down vertically by |margin|.
void SetActiveTopMargin(int margin);
// Sets the contents insets from the sides.
void SetContentsViewInsets(const gfx::Insets& insets);
// Sets the contents resizing strategy.
void SetContentsResizingStrategy(
const DevToolsContentsResizingStrategy& strategy);
// views::LayoutManager overrides:
virtual void Layout(views::View* host) OVERRIDE;
......@@ -35,7 +36,7 @@ class ContentsLayoutManager : public views::LayoutManager {
views::View* host_;
gfx::Insets insets_;
DevToolsContentsResizingStrategy strategy_;
int active_top_margin_;
DISALLOW_COPY_AND_ASSIGN(ContentsLayoutManager);
......
......@@ -168,6 +168,8 @@
'browser/devtools/browser_list_tabcontents_provider.h',
'browser/devtools/devtools_adb_bridge.cc',
'browser/devtools/devtools_adb_bridge.h',
'browser/devtools/devtools_contents_resizing_strategy.cc',
'browser/devtools/devtools_contents_resizing_strategy.h',
'browser/devtools/devtools_embedder_message_dispatcher.cc',
'browser/devtools/devtools_embedder_message_dispatcher.h',
'browser/devtools/devtools_file_helper.cc',
......
......@@ -793,6 +793,7 @@
'browser/custom_handlers/protocol_handler_registry_unittest.cc',
'browser/diagnostics/diagnostics_model_unittest.cc',
'browser/diagnostics/diagnostics_controller_unittest.cc',
'browser/devtools/devtools_contents_resizing_strategy_unittest.cc',
'browser/download/all_download_item_notifier_unittest.cc',
'browser/download/chrome_download_manager_delegate_unittest.cc',
'browser/download/download_history_unittest.cc',
......
......@@ -112,6 +112,8 @@ source_set("debugger") {
"browser/devtools/browser_list_tabcontents_provider.h",
"browser/devtools/devtools_adb_bridge.cc",
"browser/devtools/devtools_adb_bridge.h",
"browser/devtools/devtools_contents_resizing_strategy.cc",
"browser/devtools/devtools_contents_resizing_strategy.h",
"browser/devtools/devtools_embedder_message_dispatcher.cc",
"browser/devtools/devtools_embedder_message_dispatcher.h",
"browser/devtools/devtools_file_helper.cc",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment