Commit 54505e8f authored by pfeldman@chromium.org's avatar pfeldman@chromium.org

DevTools: remove unused resizing strategy code paths, make it solely...

DevTools: remove unused resizing strategy code paths, make it solely bounds-based; support hidden inspected contents case.

TBR=tsepez (removing method from devtools dispatcher)
NOTRY=true

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288056 0039d316-1c4b-4281-b951-d872f2087c98
parent 116f4fbd
...@@ -6,80 +6,48 @@ ...@@ -6,80 +6,48 @@
#include <algorithm> #include <algorithm>
DevToolsContentsResizingStrategy::DevToolsContentsResizingStrategy() { DevToolsContentsResizingStrategy::DevToolsContentsResizingStrategy()
} : hide_inspected_contents_(false) {
DevToolsContentsResizingStrategy::DevToolsContentsResizingStrategy(
const gfx::Insets& insets, const gfx::Size& min_size)
: insets_(insets),
min_size_(min_size) {
} }
DevToolsContentsResizingStrategy::DevToolsContentsResizingStrategy( DevToolsContentsResizingStrategy::DevToolsContentsResizingStrategy(
const gfx::Rect& bounds) const gfx::Rect& bounds)
: bounds_(bounds) { : bounds_(bounds),
hide_inspected_contents_(bounds_.IsEmpty() && !bounds_.x() &&
!bounds_.y()) {
} }
void DevToolsContentsResizingStrategy::CopyFrom( void DevToolsContentsResizingStrategy::CopyFrom(
const DevToolsContentsResizingStrategy& strategy) { const DevToolsContentsResizingStrategy& strategy) {
insets_ = strategy.insets();
min_size_ = strategy.min_size();
bounds_ = strategy.bounds(); bounds_ = strategy.bounds();
hide_inspected_contents_ = strategy.hide_inspected_contents();
} }
bool DevToolsContentsResizingStrategy::Equals( bool DevToolsContentsResizingStrategy::Equals(
const DevToolsContentsResizingStrategy& strategy) { const DevToolsContentsResizingStrategy& strategy) {
return insets_ == strategy.insets() && min_size_ == strategy.min_size() && return bounds_ == strategy.bounds() &&
bounds_ == strategy.bounds(); hide_inspected_contents_ == strategy.hide_inspected_contents();
} }
void ApplyDevToolsContentsResizingStrategy( void ApplyDevToolsContentsResizingStrategy(
const DevToolsContentsResizingStrategy& strategy, const DevToolsContentsResizingStrategy& strategy,
const gfx::Size& container_size, 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_devtools_bounds,
gfx::Rect* new_contents_bounds) { gfx::Rect* new_contents_bounds) {
new_devtools_bounds->SetRect( new_devtools_bounds->SetRect(
0, 0, container_size.width(), container_size.height()); 0, 0, container_size.width(), container_size.height());
const gfx::Insets& insets = strategy.insets();
const gfx::Size& min_size = strategy.min_size();
const gfx::Rect& bounds = strategy.bounds(); const gfx::Rect& bounds = strategy.bounds();
if (bounds.size().IsEmpty() && !strategy.hide_inspected_contents()) {
new_contents_bounds->SetRect(
0, 0, container_size.width(), container_size.height());
return;
}
if (!bounds.size().IsEmpty()) {
int left = std::min(bounds.x(), container_size.width()); int left = std::min(bounds.x(), container_size.width());
int top = std::min(bounds.y(), container_size.height()); int top = std::min(bounds.y(), container_size.height());
int width = std::min(bounds.width(), container_size.width() - left); int width = std::min(bounds.width(), container_size.width() - left);
int height = std::min(bounds.height(), container_size.height() - top); int height = std::min(bounds.height(), container_size.height() - top);
new_contents_bounds->SetRect(left, top, width, height); new_contents_bounds->SetRect(left, top, width, height);
return;
}
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);
} }
...@@ -15,28 +15,22 @@ ...@@ -15,28 +15,22 @@
class DevToolsContentsResizingStrategy { class DevToolsContentsResizingStrategy {
public: public:
DevToolsContentsResizingStrategy(); DevToolsContentsResizingStrategy();
DevToolsContentsResizingStrategy( explicit DevToolsContentsResizingStrategy(
const gfx::Insets& insets, const gfx::Rect& bounds);
const gfx::Size& min_size);
explicit DevToolsContentsResizingStrategy(const gfx::Rect& bounds);
void CopyFrom(const DevToolsContentsResizingStrategy& strategy); void CopyFrom(const DevToolsContentsResizingStrategy& strategy);
bool Equals(const DevToolsContentsResizingStrategy& strategy); bool Equals(const DevToolsContentsResizingStrategy& strategy);
const gfx::Insets& insets() const { return insets_; }
const gfx::Size& min_size() const { return min_size_; }
const gfx::Rect& bounds() const { return bounds_; } const gfx::Rect& bounds() const { return bounds_; }
bool hide_inspected_contents() const { return hide_inspected_contents_; }
private: private:
// Insets of contents inside DevTools.
gfx::Insets insets_;
// Minimum size of contents.
gfx::Size min_size_;
// Contents bounds. When non-empty, used instead of insets. // Contents bounds. When non-empty, used instead of insets.
gfx::Rect bounds_; gfx::Rect bounds_;
// Determines whether inspected contents is visible.
bool hide_inspected_contents_;
DISALLOW_COPY_AND_ASSIGN(DevToolsContentsResizingStrategy); DISALLOW_COPY_AND_ASSIGN(DevToolsContentsResizingStrategy);
}; };
...@@ -48,8 +42,6 @@ class DevToolsContentsResizingStrategy { ...@@ -48,8 +42,6 @@ class DevToolsContentsResizingStrategy {
void ApplyDevToolsContentsResizingStrategy( void ApplyDevToolsContentsResizingStrategy(
const DevToolsContentsResizingStrategy& strategy, const DevToolsContentsResizingStrategy& strategy,
const gfx::Size& container_size, 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_devtools_bounds,
gfx::Rect* new_contents_bounds); gfx::Rect* new_contents_bounds);
......
// 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,36 +21,6 @@ bool GetValue(const base::ListValue& list, int pos, bool& value) { ...@@ -21,36 +21,6 @@ bool GetValue(const base::ListValue& list, int pos, bool& value) {
return list.GetBoolean(pos, &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;
}
bool GetValue(const base::ListValue& list, int pos, gfx::Rect& rect) { bool GetValue(const base::ListValue& list, int pos, gfx::Rect& rect) {
const base::DictionaryValue* dict; const base::DictionaryValue* dict;
if (!list.GetDictionary(pos, &dict)) if (!list.GetDictionary(pos, &dict))
...@@ -258,8 +228,6 @@ DevToolsEmbedderMessageDispatcher* ...@@ -258,8 +228,6 @@ DevToolsEmbedderMessageDispatcher*
d->RegisterHandler("closeWindow", &Delegate::CloseWindow, delegate); d->RegisterHandler("closeWindow", &Delegate::CloseWindow, delegate);
d->RegisterHandler("setInspectedPageBounds", d->RegisterHandler("setInspectedPageBounds",
&Delegate::SetInspectedPageBounds, delegate); &Delegate::SetInspectedPageBounds, delegate);
d->RegisterHandler("setContentsResizingStrategy",
&Delegate::SetContentsResizingStrategy, delegate);
d->RegisterHandler("inspectElementCompleted", d->RegisterHandler("inspectElementCompleted",
&Delegate::InspectElementCompleted, delegate); &Delegate::InspectElementCompleted, delegate);
d->RegisterHandler("inspectedURLChanged", d->RegisterHandler("inspectedURLChanged",
......
...@@ -32,8 +32,6 @@ class DevToolsEmbedderMessageDispatcher { ...@@ -32,8 +32,6 @@ class DevToolsEmbedderMessageDispatcher {
virtual void ActivateWindow() = 0; virtual void ActivateWindow() = 0;
virtual void CloseWindow() = 0; virtual void CloseWindow() = 0;
virtual void SetInspectedPageBounds(const gfx::Rect& rect) = 0; virtual void SetInspectedPageBounds(const gfx::Rect& rect) = 0;
virtual void SetContentsResizingStrategy(
const gfx::Insets& insets, const gfx::Size& min_size) = 0;
virtual void InspectElementCompleted() = 0; virtual void InspectElementCompleted() = 0;
virtual void InspectedURLChanged(const std::string& url) = 0; virtual void InspectedURLChanged(const std::string& url) = 0;
virtual void MoveWindow(int x, int y) = 0; virtual void MoveWindow(int x, int y) = 0;
......
...@@ -183,8 +183,6 @@ class DefaultBindingsDelegate : public DevToolsUIBindings::Delegate { ...@@ -183,8 +183,6 @@ class DefaultBindingsDelegate : public DevToolsUIBindings::Delegate {
virtual void ActivateWindow() OVERRIDE; virtual void ActivateWindow() OVERRIDE;
virtual void CloseWindow() OVERRIDE {} virtual void CloseWindow() OVERRIDE {}
virtual void SetInspectedPageBounds(const gfx::Rect& rect) OVERRIDE {} virtual void SetInspectedPageBounds(const gfx::Rect& rect) OVERRIDE {}
virtual void SetContentsResizingStrategy(
const gfx::Insets& insets, const gfx::Size& min_size) OVERRIDE {}
virtual void InspectElementCompleted() OVERRIDE {} virtual void InspectElementCompleted() OVERRIDE {}
virtual void MoveWindow(int x, int y) OVERRIDE {} virtual void MoveWindow(int x, int y) OVERRIDE {}
virtual void SetIsDocked(bool is_docked) OVERRIDE {} virtual void SetIsDocked(bool is_docked) OVERRIDE {}
...@@ -437,11 +435,6 @@ void DevToolsUIBindings::SetInspectedPageBounds(const gfx::Rect& rect) { ...@@ -437,11 +435,6 @@ void DevToolsUIBindings::SetInspectedPageBounds(const gfx::Rect& rect) {
delegate_->SetInspectedPageBounds(rect); delegate_->SetInspectedPageBounds(rect);
} }
void DevToolsUIBindings::SetContentsResizingStrategy(
const gfx::Insets& insets, const gfx::Size& min_size) {
delegate_->SetContentsResizingStrategy(insets, min_size);
}
void DevToolsUIBindings::MoveWindow(int x, int y) { void DevToolsUIBindings::MoveWindow(int x, int y) {
delegate_->MoveWindow(x, y); delegate_->MoveWindow(x, y);
} }
......
...@@ -47,8 +47,6 @@ class DevToolsUIBindings : public content::NotificationObserver, ...@@ -47,8 +47,6 @@ class DevToolsUIBindings : public content::NotificationObserver,
virtual void ActivateWindow() = 0; virtual void ActivateWindow() = 0;
virtual void CloseWindow() = 0; virtual void CloseWindow() = 0;
virtual void SetInspectedPageBounds(const gfx::Rect& rect) = 0; virtual void SetInspectedPageBounds(const gfx::Rect& rect) = 0;
virtual void SetContentsResizingStrategy(
const gfx::Insets& insets, const gfx::Size& min_size) = 0;
virtual void InspectElementCompleted() = 0; virtual void InspectElementCompleted() = 0;
virtual void MoveWindow(int x, int y) = 0; virtual void MoveWindow(int x, int y) = 0;
virtual void SetIsDocked(bool is_docked) = 0; virtual void SetIsDocked(bool is_docked) = 0;
...@@ -94,8 +92,6 @@ class DevToolsUIBindings : public content::NotificationObserver, ...@@ -94,8 +92,6 @@ class DevToolsUIBindings : public content::NotificationObserver,
virtual void ActivateWindow() OVERRIDE; virtual void ActivateWindow() OVERRIDE;
virtual void CloseWindow() OVERRIDE; virtual void CloseWindow() OVERRIDE;
virtual void SetInspectedPageBounds(const gfx::Rect& rect) OVERRIDE; virtual void SetInspectedPageBounds(const gfx::Rect& rect) OVERRIDE;
virtual void SetContentsResizingStrategy(
const gfx::Insets& insets, const gfx::Size& min_size) OVERRIDE;
virtual void InspectElementCompleted() OVERRIDE; virtual void InspectElementCompleted() OVERRIDE;
virtual void InspectedURLChanged(const std::string& url) OVERRIDE; virtual void InspectedURLChanged(const std::string& url) OVERRIDE;
virtual void MoveWindow(int x, int y) OVERRIDE; virtual void MoveWindow(int x, int y) OVERRIDE;
......
...@@ -1015,16 +1015,6 @@ void DevToolsWindow::SetInspectedPageBounds(const gfx::Rect& rect) { ...@@ -1015,16 +1015,6 @@ void DevToolsWindow::SetInspectedPageBounds(const gfx::Rect& rect) {
UpdateBrowserWindow(); UpdateBrowserWindow();
} }
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_resizing_strategy_.CopyFrom(strategy);
UpdateBrowserWindow();
}
void DevToolsWindow::InspectElementCompleted() { void DevToolsWindow::InspectElementCompleted() {
if (!inspect_element_start_time_.is_null()) { if (!inspect_element_start_time_.is_null()) {
UMA_HISTOGRAM_TIMES("DevTools.InspectElement", UMA_HISTOGRAM_TIMES("DevTools.InspectElement",
......
...@@ -272,8 +272,6 @@ class DevToolsWindow : public DevToolsUIBindings::Delegate, ...@@ -272,8 +272,6 @@ class DevToolsWindow : public DevToolsUIBindings::Delegate,
virtual void ActivateWindow() OVERRIDE; virtual void ActivateWindow() OVERRIDE;
virtual void CloseWindow() OVERRIDE; virtual void CloseWindow() OVERRIDE;
virtual void SetInspectedPageBounds(const gfx::Rect& rect) OVERRIDE; virtual void SetInspectedPageBounds(const gfx::Rect& rect) OVERRIDE;
virtual void SetContentsResizingStrategy(
const gfx::Insets& insets, const gfx::Size& min_size) OVERRIDE;
virtual void InspectElementCompleted() OVERRIDE; virtual void InspectElementCompleted() OVERRIDE;
virtual void MoveWindow(int x, int y) OVERRIDE; virtual void MoveWindow(int x, int y) OVERRIDE;
virtual void SetIsDocked(bool is_docked) OVERRIDE; virtual void SetIsDocked(bool is_docked) OVERRIDE;
......
...@@ -43,13 +43,16 @@ using content::WebContents; ...@@ -43,13 +43,16 @@ using content::WebContents;
- (void)setDevToolsView:(NSView*)devToolsView - (void)setDevToolsView:(NSView*)devToolsView
withStrategy:(const DevToolsContentsResizingStrategy&)strategy { withStrategy:(const DevToolsContentsResizingStrategy&)strategy {
strategy_.CopyFrom(strategy); strategy_.CopyFrom(strategy);
if (devToolsView == devToolsView_) {
if (devToolsView == devToolsView_) if (contentsView_)
[contentsView_ setHidden:strategy.hide_inspected_contents()];
return; return;
}
if (devToolsView_) { if (devToolsView_) {
DCHECK_EQ(2u, [[self subviews] count]); DCHECK_EQ(2u, [[self subviews] count]);
[devToolsView_ removeFromSuperview]; [devToolsView_ removeFromSuperview];
[contentsView_ setHidden:NO];
contentsView_ = nil; contentsView_ = nil;
devToolsView_ = nil; devToolsView_ = nil;
} }
...@@ -61,6 +64,8 @@ using content::WebContents; ...@@ -61,6 +64,8 @@ using content::WebContents;
devToolsView_ = devToolsView; devToolsView_ = devToolsView;
// Place DevTools under contents. // Place DevTools under contents.
[self addSubview:devToolsView positioned:NSWindowBelow relativeTo:nil]; [self addSubview:devToolsView positioned:NSWindowBelow relativeTo:nil];
[contentsView_ setHidden:strategy.hide_inspected_contents()];
} }
} }
...@@ -89,8 +94,6 @@ using content::WebContents; ...@@ -89,8 +94,6 @@ using content::WebContents;
gfx::Rect new_contents_bounds; gfx::Rect new_contents_bounds;
ApplyDevToolsContentsResizingStrategy( ApplyDevToolsContentsResizingStrategy(
strategy_, gfx::Size(NSSizeToCGSize([self bounds].size)), strategy_, gfx::Size(NSSizeToCGSize([self bounds].size)),
[self flipNSRectToRect:[devToolsView_ bounds]],
[self flipNSRectToRect:[contentsView_ bounds]],
&new_devtools_bounds, &new_contents_bounds); &new_devtools_bounds, &new_contents_bounds);
[devToolsView_ setFrame:[self flipRectToNSRect:new_devtools_bounds]]; [devToolsView_ setFrame:[self flipRectToNSRect:new_devtools_bounds]];
[contentsView_ setFrame:[self flipRectToNSRect:new_contents_bounds]]; [contentsView_ setFrame:[self flipRectToNSRect:new_contents_bounds]];
......
...@@ -2134,6 +2134,17 @@ void BrowserView::UpdateDevToolsForContents( ...@@ -2134,6 +2134,17 @@ void BrowserView::UpdateDevToolsForContents(
DevToolsContentsResizingStrategy()); DevToolsContentsResizingStrategy());
} }
contents_container_->Layout(); contents_container_->Layout();
if (devtools) {
// When strategy.hide_inspected_contents() returns true, we are hiding
// contents_web_view_ behind the devtools_web_view_. Otherwise,
// contents_web_view_ should be right above the devtools_web_view_.
int devtools_index = contents_container_->GetIndexOf(devtools_web_view_);
int contents_index = contents_container_->GetIndexOf(contents_web_view_);
bool devtools_is_on_top = devtools_index > contents_index;
if (strategy.hide_inspected_contents() != devtools_is_on_top)
contents_container_->ReorderChildView(contents_web_view_, devtools_index);
}
} }
void BrowserView::UpdateUIForContents(WebContents* contents) { void BrowserView::UpdateUIForContents(WebContents* contents) {
......
...@@ -45,15 +45,10 @@ void ContentsLayoutManager::Layout(views::View* contents_container) { ...@@ -45,15 +45,10 @@ void ContentsLayoutManager::Layout(views::View* contents_container) {
int width = contents_container->width(); int width = contents_container->width();
gfx::Size container_size(width, 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_devtools_bounds;
gfx::Rect new_contents_bounds; gfx::Rect new_contents_bounds;
old_devtools_bounds.Offset(0, -top);
old_contents_bounds.Offset(0, -top);
ApplyDevToolsContentsResizingStrategy(strategy_, container_size, ApplyDevToolsContentsResizingStrategy(strategy_, container_size,
old_devtools_bounds, old_contents_bounds,
&new_devtools_bounds, &new_contents_bounds); &new_devtools_bounds, &new_contents_bounds);
new_devtools_bounds.Offset(0, top); new_devtools_bounds.Offset(0, top);
new_contents_bounds.Offset(0, top); new_contents_bounds.Offset(0, top);
......
...@@ -817,7 +817,6 @@ ...@@ -817,7 +817,6 @@
'browser/custom_handlers/protocol_handler_registry_unittest.cc', 'browser/custom_handlers/protocol_handler_registry_unittest.cc',
'browser/diagnostics/diagnostics_model_unittest.cc', 'browser/diagnostics/diagnostics_model_unittest.cc',
'browser/diagnostics/diagnostics_controller_unittest.cc', 'browser/diagnostics/diagnostics_controller_unittest.cc',
'browser/devtools/devtools_contents_resizing_strategy_unittest.cc',
'browser/devtools/devtools_network_controller_unittest.cc', 'browser/devtools/devtools_network_controller_unittest.cc',
'browser/download/all_download_item_notifier_unittest.cc', 'browser/download/all_download_item_notifier_unittest.cc',
'browser/download/chrome_download_manager_delegate_unittest.cc', 'browser/download/chrome_download_manager_delegate_unittest.cc',
...@@ -2536,7 +2535,6 @@ ...@@ -2536,7 +2535,6 @@
'browser/sync/sync_ui_util_unittest.cc', 'browser/sync/sync_ui_util_unittest.cc',
'browser/browser_commands_unittest.cc', 'browser/browser_commands_unittest.cc',
'browser/devtools/devtools_contents_resizing_strategy_unittest.cc',
'browser/download/download_shelf_unittest.cc', 'browser/download/download_shelf_unittest.cc',
'browser/extensions/extension_message_bubble_controller_unittest.cc', 'browser/extensions/extension_message_bubble_controller_unittest.cc',
'browser/extensions/extension_test_message_listener_unittest.cc', 'browser/extensions/extension_test_message_listener_unittest.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