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

Unified Diff: chrome/browser/ui/views/frame/browser_view.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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/frame/browser_view.cc
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index 614912143d273fc68672fa3752c4b488d8c4dad5..362cf803261061ef87a27fa945a8491e847a4ab1 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -69,6 +69,7 @@
#include "chrome/browser/ui/views/frame/browser_view_layout.h"
#include "chrome/browser/ui/views/frame/browser_view_layout_delegate.h"
#include "chrome/browser/ui/views/frame/contents_container.h"
+#include "chrome/browser/ui/views/frame/devtools_container.h"
#include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
#include "chrome/browser/ui/views/frame/native_browser_frame_factory.h"
#include "chrome/browser/ui/views/frame/top_container_view.h"
@@ -417,8 +418,6 @@ BrowserView::BrowserView()
contents_web_view_(NULL),
devtools_container_(NULL),
contents_container_(NULL),
- contents_split_(NULL),
- devtools_dock_side_(DEVTOOLS_DOCK_SIDE_BOTTOM),
devtools_window_(NULL),
initialized_(false),
in_process_fullscreen_(false),
@@ -510,7 +509,7 @@ BrowserView* BrowserView::GetBrowserViewForBrowser(const Browser* browser) {
}
void BrowserView::InitStatusBubble() {
- status_bubble_.reset(new StatusBubbleViews(contents_container_));
+ status_bubble_.reset(new StatusBubbleViews(contents_web_view_));
}
gfx::Rect BrowserView::GetToolbarBounds() const {
@@ -1021,7 +1020,7 @@ void BrowserView::ToolbarSizeChanged(bool is_animating) {
// wrapping it will do it.
if ((call_state == NORMAL) && !is_animating) {
contents_web_view_->InvalidateLayout();
- contents_split_->Layout();
+ contents_container_->Layout();
}
}
@@ -1288,7 +1287,7 @@ void BrowserView::WebContentsFocused(WebContents* contents) {
if (contents_web_view_->GetWebContents() == contents)
contents_web_view_->OnWebContentsFocused(contents);
else
- devtools_container_->OnWebContentsFocused(contents);
+ devtools_web_view_->OnWebContentsFocused(contents);
}
void BrowserView::ShowWebsiteSettings(Profile* profile,
@@ -1750,8 +1749,8 @@ void BrowserView::GetAccessiblePanes(std::vector<views::View*>* panes) {
if (download_shelf_.get())
panes->push_back(download_shelf_.get());
panes->push_back(GetTabContentsContainerView());
- if (devtools_container_->visible())
- panes->push_back(devtools_container_);
+ if (devtools_web_view_->visible())
+ panes->push_back(devtools_web_view_);
}
///////////////////////////////////////////////////////////////////////////////
@@ -1951,29 +1950,18 @@ void BrowserView::InitViews() {
contents_web_view_->SetEmbedFullscreenWidgetMode(
implicit_cast<content::WebContentsDelegate*>(browser_.get())->
EmbedsFullscreenWidget());
- contents_container_ = new ContentsContainer(contents_web_view_);
- SkColor bg_color = GetWidget()->GetThemeProvider()->
- GetColor(ThemeProperties::COLOR_TOOLBAR);
+ devtools_web_view_ = new views::WebView(browser_->profile());
+ devtools_web_view_->set_id(VIEW_ID_DEV_TOOLS_DOCKED);
+ devtools_web_view_->SetVisible(false);
- devtools_container_ = new views::WebView(browser_->profile());
- devtools_container_->set_id(VIEW_ID_DEV_TOOLS_DOCKED);
- devtools_container_->SetVisible(false);
+ devtools_container_ = new DevToolsContainer(
+ contents_web_view_, devtools_web_view_);
+ contents_container_ = new ContentsContainer(devtools_container_);
views::View* contents_container_view = contents_container_;
-
- contents_split_ = new views::SingleSplitView(
- contents_container_view,
- devtools_container_,
- views::SingleSplitView::VERTICAL_SPLIT,
- this);
- contents_split_->set_id(VIEW_ID_CONTENTS_SPLIT);
- contents_split_->SetAccessibleName(
- l10n_util::GetStringUTF16(IDS_ACCNAME_WEB_CONTENTS));
- contents_split_->set_background(
- views::Background::CreateSolidBackground(bg_color));
- AddChildView(contents_split_);
- set_contents_view(contents_split_);
+ AddChildView(contents_container_view);
+ set_contents_view(contents_container_view);
InitStatusBubble();
@@ -2012,7 +2000,6 @@ void BrowserView::InitViews() {
tabstrip_,
toolbar_,
infobar_container_,
- contents_split_,
contents_container_,
immersive_mode_controller_.get());
SetLayoutManager(browser_view_layout);
@@ -2152,98 +2139,40 @@ bool BrowserView::MaybeShowInfoBar(WebContents* contents) {
void BrowserView::UpdateDevToolsForContents(WebContents* web_contents) {
DevToolsWindow* new_devtools_window = web_contents ?
DevToolsWindow::GetDockedInstanceForInspectedTab(web_contents) : NULL;
- // Fast return in case of the same window having same orientation.
- if (devtools_window_ == new_devtools_window) {
- if (!new_devtools_window ||
- (new_devtools_window->dock_side() == devtools_dock_side_)) {
- return;
- }
- }
// Replace tab contents.
if (devtools_window_ != new_devtools_window) {
- devtools_container_->SetWebContents(
+ devtools_web_view_->SetWebContents(
new_devtools_window ? new_devtools_window->web_contents() : NULL);
}
- // Store last used position.
- if (devtools_window_) {
- int split_size = contents_split_->GetDividerSize();
- if (devtools_dock_side_ == DEVTOOLS_DOCK_SIDE_RIGHT) {
- devtools_window_->SetWidth(contents_split_->width() -
- split_size - contents_split_->divider_offset());
- } else if (devtools_dock_side_ == DEVTOOLS_DOCK_SIDE_BOTTOM) {
- devtools_window_->SetHeight(contents_split_->height() -
- split_size - contents_split_->divider_offset());
- }
- }
-
- // Show / hide container if necessary. Changing dock orientation is
- // hide + show.
- bool should_hide = devtools_window_ && (!new_devtools_window ||
- devtools_dock_side_ != new_devtools_window->dock_side());
- bool should_show = new_devtools_window && (!devtools_window_ || should_hide);
-
- if (should_hide)
- HideDevToolsContainer();
-
- devtools_window_ = new_devtools_window;
-
- if (should_show) {
- devtools_dock_side_ = new_devtools_window->dock_side();
- ShowDevToolsContainer();
- } else if (new_devtools_window) {
- UpdateDevToolsSplitPosition();
- contents_split_->Layout();
- }
-}
-
-void BrowserView::ShowDevToolsContainer() {
- if (!devtools_focus_tracker_.get()) {
+ if (!devtools_window_ && new_devtools_window &&
+ !devtools_focus_tracker_.get()) {
// Install devtools focus tracker when dev tools window is shown for the
// first time.
devtools_focus_tracker_.reset(
- new views::ExternalFocusTracker(devtools_container_,
+ new views::ExternalFocusTracker(devtools_web_view_,
GetFocusManager()));
}
- gfx::Size min_devtools_size(devtools_window_->GetMinimumWidth(),
- devtools_window_->GetMinimumHeight());
- devtools_container_->SetPreferredSize(min_devtools_size);
-
- devtools_container_->SetVisible(true);
- devtools_dock_side_ = devtools_window_->dock_side();
- bool dock_to_right = devtools_dock_side_ == DEVTOOLS_DOCK_SIDE_RIGHT;
- contents_split_->set_orientation(
- dock_to_right ? views::SingleSplitView::HORIZONTAL_SPLIT
- : views::SingleSplitView::VERTICAL_SPLIT);
- UpdateDevToolsSplitPosition();
- contents_split_->InvalidateLayout();
- Layout();
-}
-
-void BrowserView::HideDevToolsContainer() {
// Restore focus to the last focused view when hiding devtools window.
- devtools_focus_tracker_->FocusLastFocusedExternalView();
- devtools_container_->SetVisible(false);
- contents_split_->InvalidateLayout();
- Layout();
-}
+ if (devtools_window_ && !new_devtools_window &&
+ devtools_focus_tracker_.get()) {
+ devtools_focus_tracker_->FocusLastFocusedExternalView();
+ devtools_focus_tracker_.reset();
+ }
-void BrowserView::UpdateDevToolsSplitPosition() {
- contents_split_->set_resize_disabled(
- devtools_window_->dock_side() == DEVTOOLS_DOCK_SIDE_MINIMIZED);
- int split_size = contents_split_->GetDividerSize();
- if (devtools_window_->dock_side() == DEVTOOLS_DOCK_SIDE_RIGHT) {
- int split_offset = contents_split_->width() - split_size -
- devtools_window_->GetWidth(contents_split_->width());
- contents_split_->set_divider_offset(split_offset);
+ devtools_window_ = new_devtools_window;
+ if (devtools_window_) {
+ devtools_web_view_->SetPreferredSize(devtools_window_->GetMinimumSize());
+ devtools_web_view_->SetVisible(true);
+ devtools_container_->SetContentsViewOffsets(
+ devtools_window_->GetTopLeftContentsOffset(),
+ devtools_window_->GetBottomRightContentsOffset());
} else {
- int height = devtools_window_->dock_side() == DEVTOOLS_DOCK_SIDE_MINIMIZED ?
- devtools_window_->GetMinimizedHeight() :
- devtools_window_->GetHeight(contents_split_->height());
- int split_offset = contents_split_->height() - split_size - height;
- contents_split_->set_divider_offset(split_offset);
+ devtools_web_view_->SetVisible(false);
+ devtools_container_->SetContentsViewOffsets(
+ gfx::Size(), gfx::Size());
}
}

Powered by Google App Engine
This is Rietveld 408576698