diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-03 01:45:08 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-03 01:45:08 +0000 |
commit | fdb0d147252e3034dff2bfa8e83e93ca4c471147 (patch) | |
tree | 58eb49fd4b0aab20a746bc0ff63af9a44c06ca5d /chrome/browser/views | |
parent | 7a32bd0f44d3a85e7dea0a4b1b42d3afa7cab2ad (diff) | |
download | chromium_src-fdb0d147252e3034dff2bfa8e83e93ca4c471147.zip chromium_src-fdb0d147252e3034dff2bfa8e83e93ca4c471147.tar.gz chromium_src-fdb0d147252e3034dff2bfa8e83e93ca4c471147.tar.bz2 |
Revert 37914 - Move ChromeBrowserView* > BrowserView* and ChromeosBrowserView* > chromeos::BrowserView*
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/569019
TBR=ben@chromium.org
Review URL: http://codereview.chromium.org/562030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37928 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r-- | chrome/browser/views/frame/browser_view.cc | 16 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.h | 7 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view_layout_manager.h | 32 | ||||
-rw-r--r-- | chrome/browser/views/frame/chrome_browser_view_layout_manager.cc (renamed from chrome/browser/views/frame/browser_view_layout.cc) | 212 | ||||
-rw-r--r-- | chrome/browser/views/frame/chrome_browser_view_layout_manager.h (renamed from chrome/browser/views/frame/browser_view_layout.h) | 43 |
5 files changed, 168 insertions, 142 deletions
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index 5eb03d3..e02d3d5 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -38,7 +38,7 @@ #include "chrome/browser/views/chrome_views_delegate.h" #include "chrome/browser/views/download_shelf_view.h" #include "chrome/browser/views/extensions/extension_shelf.h" -#include "chrome/browser/views/frame/browser_view_layout.h" +#include "chrome/browser/views/frame/chrome_browser_view_layout_manager.h" #include "chrome/browser/views/frame/browser_extender.h" #include "chrome/browser/views/frame/browser_frame.h" #include "chrome/browser/views/fullscreen_exit_bubble.h" @@ -524,7 +524,7 @@ bool BrowserView::ShouldFindBarBlendWithBookmarksBar() const { } gfx::Rect BrowserView::GetFindBarBoundingBox() const { - return GetBrowserViewLayout()->GetFindBarBoundingBox(); + return GetBrowserViewLayoutManager()->GetFindBarBoundingBox(); } int BrowserView::GetTabStripHeight() const { @@ -658,7 +658,7 @@ void BrowserView::DetachBrowserBubble(BrowserBubble* bubble) { } bool BrowserView::IsPositionInWindowCaption(const gfx::Point& point) { - return GetBrowserViewLayout()->IsPositionInWindowCaption(point); + return GetBrowserViewLayoutManager()->IsPositionInWindowCaption(point); } /////////////////////////////////////////////////////////////////////////////// @@ -1532,11 +1532,11 @@ int BrowserView::NonClientHitTest(const gfx::Point& point) { } #endif - return GetBrowserViewLayout()->NonClientHitTest(point); + return GetBrowserViewLayoutManager()->NonClientHitTest(point); } gfx::Size BrowserView::GetMinimumSize() { - return GetBrowserViewLayout()->GetMinimumSize(); + return GetBrowserViewLayoutManager()->GetMinimumSize(); } /////////////////////////////////////////////////////////////////////////////// @@ -1590,7 +1590,7 @@ void BrowserView::SetAccessibleName(const std::wstring& name) { } views::LayoutManager* BrowserView::CreateLayoutManager() const { - return new BrowserViewLayout; + return new ChromeBrowserViewLayoutManager(); } TabStrip* BrowserView::CreateTabStrip(TabStripModel* model) { @@ -1692,8 +1692,8 @@ void BrowserView::InitSystemMenu() { } #endif -BrowserViewLayout* BrowserView::GetBrowserViewLayout() const { - return static_cast<BrowserViewLayout*>(GetLayoutManager()); +BrowserViewLayoutManager* BrowserView::GetBrowserViewLayoutManager() const { + return static_cast<BrowserViewLayoutManager*>(GetLayoutManager()); } void BrowserView::LayoutStatusBubble(int top) { diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h index 32b4491..516e9bf 100644 --- a/chrome/browser/views/frame/browser_view.h +++ b/chrome/browser/views/frame/browser_view.h @@ -36,7 +36,7 @@ class BookmarkBarView; class Browser; class BrowserBubble; class BrowserExtender; -class BrowserViewLayout; +class BrowserViewLayoutManager; class DownloadShelfView; class EncodingMenuModel; class ExtensionShelf; @@ -388,9 +388,8 @@ class BrowserView : public BrowserWindow, // Creates the system menu. void InitSystemMenu(); #endif - - // Returns the BrowserViewLayout. - BrowserViewLayout* GetBrowserViewLayout() const; + // Returns the BrowserViewLayoutManager. + BrowserViewLayoutManager* GetBrowserViewLayoutManager() const; // Prepare to show the Bookmark Bar for the specified TabContents. Returns // true if the Bookmark Bar can be shown (i.e. it's supported for this diff --git a/chrome/browser/views/frame/browser_view_layout_manager.h b/chrome/browser/views/frame/browser_view_layout_manager.h new file mode 100644 index 0000000..f39b877 --- /dev/null +++ b/chrome/browser/views/frame/browser_view_layout_manager.h @@ -0,0 +1,32 @@ +// Copyright (c) 2010 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_VIEWS_FRAME_BROWSER_VIEW_LAYOUT_MANAGER_H_ +#define CHROME_BROWSER_VIEWS_FRAME_BROWSER_VIEW_LAYOUT_MANAGER_H_ + +#include "base/gfx/size.h" +#include "views/layout_manager.h" + +// An extended LayoutManager to layout components in +// BrowserView. +class BrowserViewLayoutManager : public views::LayoutManager { + public: + // Returns the minimum size of the browser view. + virtual gfx::Size GetMinimumSize() = 0; + + // Returns the bounding box for the find bar. + virtual gfx::Rect GetFindBarBoundingBox() const = 0; + + // Returns true if the specified point(BrowserView coordinates) is in + // in the window caption area of the browser window. + virtual bool IsPositionInWindowCaption(const gfx::Point& point) = 0; + + // Tests to see if the specified |point| (in nonclient view's coordinates) + // is within the views managed by the laymanager. Returns one of + // HitTestCompat enum defined in views/window/hit_test.h. + // See also ClientView::NonClientHitTest. + virtual int NonClientHitTest(const gfx::Point& point) = 0; +}; + +#endif // CHROME_BROWSER_VIEWS_FRAME_BROWSER_VIEW_LAYOUT_MANAGER_H_ diff --git a/chrome/browser/views/frame/browser_view_layout.cc b/chrome/browser/views/frame/chrome_browser_view_layout_manager.cc index e2c5ae1..8994f75 100644 --- a/chrome/browser/views/frame/browser_view_layout.cc +++ b/chrome/browser/views/frame/chrome_browser_view_layout_manager.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/views/frame/browser_view_layout.h" +#include "chrome/browser/views/frame/chrome_browser_view_layout_manager.h" #include "app/gfx/scrollbar_size.h" #include "chrome/browser/find_bar.h" @@ -22,23 +22,16 @@ #include "views/window/hit_test.h" #endif -namespace { - // The visible height of the shadow above the tabs. Clicks in this area are // treated as clicks to the frame, rather than clicks to the tab. -const int kTabShadowSize = 2; +static const int kTabShadowSize = 2; // The vertical overlap between the TabStrip and the Toolbar. -const int kToolbarTabStripVerticalOverlap = 3; +static const int kToolbarTabStripVerticalOverlap = 3; // An offset distance between certain toolbars and the toolbar that preceded // them in layout. -const int kSeparationLineHeight = 1; - -} // namespace - -//////////////////////////////////////////////////////////////////////////////// -// BrowserViewLayout, public: +static const int kSeparationLineHeight = 1; -BrowserViewLayout::BrowserViewLayout() +ChromeBrowserViewLayoutManager::ChromeBrowserViewLayoutManager() : tabstrip_(NULL), toolbar_(NULL), contents_split_(NULL), @@ -51,7 +44,90 @@ BrowserViewLayout::BrowserViewLayout() find_bar_y_(0) { } -gfx::Size BrowserViewLayout::GetMinimumSize() { +////////////////////////////////////////////////////////////////////////////// +// Overridden from LayoutManager. + +void ChromeBrowserViewLayoutManager::Installed(views::View* host) { + toolbar_ = NULL; + contents_split_ = NULL; + contents_container_ = NULL; + infobar_container_ = NULL; + download_shelf_ = NULL; + extension_shelf_ = NULL; + active_bookmark_bar_ = NULL; + tabstrip_ = NULL; + browser_view_ = static_cast<BrowserView*>(host); +} + +void ChromeBrowserViewLayoutManager::Uninstalled(views::View* host) {} + +void ChromeBrowserViewLayoutManager::ViewAdded(views::View* host, + views::View* view) { + switch (view->GetID()) { + case VIEW_ID_CONTENTS_SPLIT: + contents_split_ = view; + contents_container_ = contents_split_->GetChildViewAt(0); + break; + case VIEW_ID_INFO_BAR_CONTAINER: + infobar_container_ = view; + break; + case VIEW_ID_DOWNLOAD_SHELF: + download_shelf_ = static_cast<DownloadShelfView*>(view); + break; + case VIEW_ID_DEV_EXTENSION_SHELF: + extension_shelf_ = static_cast<ExtensionShelf*>(view); + break; + case VIEW_ID_BOOKMARK_BAR: + active_bookmark_bar_ = static_cast<BookmarkBarView*>(view); + break; + case VIEW_ID_TOOLBAR: + toolbar_ = static_cast<ToolbarView*>(view); + break; + case VIEW_ID_TAB_STRIP: + tabstrip_ = static_cast<TabStrip*>(view); + break; + } +} + +void ChromeBrowserViewLayoutManager::ViewRemoved(views::View* host, + views::View* view) { + switch (view->GetID()) { + case VIEW_ID_BOOKMARK_BAR: + active_bookmark_bar_ = NULL; + break; + } +} + +void ChromeBrowserViewLayoutManager::Layout(views::View* host) { + int top = LayoutTabStrip(); + top = LayoutToolbar(top); + top = LayoutBookmarkAndInfoBars(top); + int bottom = LayoutExtensionAndDownloadShelves(); + LayoutTabContents(top, bottom); + // This must be done _after_ we lay out the TabContents since this + // code calls back into us to find the bounding box the find bar + // must be laid out within, and that code depends on the + // TabContentsContainer's bounds being up to date. + if (browser()->HasFindBarController()) { + browser()->GetFindBarController()->find_bar()->MoveWindowIfNecessary( + gfx::Rect(), true); + } + // Align status bubble with the bottom of the contents_container. + browser_view_->LayoutStatusBubble( + top + contents_container_->bounds().height()); + browser_view_->SchedulePaint(); +} + +// Return the preferred size which is the size required to give each +// children their respective preferred size. +gfx::Size ChromeBrowserViewLayoutManager::GetPreferredSize(views::View* host) { + return gfx::Size(); +} + +////////////////////////////////////////////////////////////////////////////// +// Overridden from BrowserViewLayoutManager. + +gfx::Size ChromeBrowserViewLayoutManager::GetMinimumSize() { // TODO(noname): In theory the tabstrip width should probably be // (OTR + tabstrip + caption buttons) width. gfx::Size tabstrip_size( @@ -82,7 +158,7 @@ gfx::Size BrowserViewLayout::GetMinimumSize() { return gfx::Size(min_width, min_height); } -gfx::Rect BrowserViewLayout::GetFindBarBoundingBox() const { +gfx::Rect ChromeBrowserViewLayoutManager::GetFindBarBoundingBox() const { // This function returns the area the Find Bar can be laid out // within. This basically implies the "user-perceived content // area" of the browser window excluding the vertical @@ -116,14 +192,14 @@ gfx::Rect BrowserViewLayout::GetFindBarBoundingBox() const { return bounding_box; } -bool BrowserViewLayout::IsPositionInWindowCaption( +bool ChromeBrowserViewLayoutManager::IsPositionInWindowCaption( const gfx::Point& point) { gfx::Point tabstrip_point(point); views::View::ConvertPointToView(browser_view_, tabstrip_, &tabstrip_point); return tabstrip_->IsPositionInWindowCaption(tabstrip_point); } -int BrowserViewLayout::NonClientHitTest( +int ChromeBrowserViewLayoutManager::NonClientHitTest( const gfx::Point& point) { // Since the TabStrip only renders in some parts of the top of the window, // the un-obscured area is considered to be part of the non-client caption @@ -192,87 +268,9 @@ int BrowserViewLayout::NonClientHitTest( } ////////////////////////////////////////////////////////////////////////////// -// BrowserViewLayout, views::LayoutManager implementation: - -void BrowserViewLayout::Installed(views::View* host) { - toolbar_ = NULL; - contents_split_ = NULL; - contents_container_ = NULL; - infobar_container_ = NULL; - download_shelf_ = NULL; - extension_shelf_ = NULL; - active_bookmark_bar_ = NULL; - tabstrip_ = NULL; - browser_view_ = static_cast<BrowserView*>(host); -} - -void BrowserViewLayout::Uninstalled(views::View* host) {} - -void BrowserViewLayout::ViewAdded(views::View* host, views::View* view) { - switch (view->GetID()) { - case VIEW_ID_CONTENTS_SPLIT: - contents_split_ = view; - contents_container_ = contents_split_->GetChildViewAt(0); - break; - case VIEW_ID_INFO_BAR_CONTAINER: - infobar_container_ = view; - break; - case VIEW_ID_DOWNLOAD_SHELF: - download_shelf_ = static_cast<DownloadShelfView*>(view); - break; - case VIEW_ID_DEV_EXTENSION_SHELF: - extension_shelf_ = static_cast<ExtensionShelf*>(view); - break; - case VIEW_ID_BOOKMARK_BAR: - active_bookmark_bar_ = static_cast<BookmarkBarView*>(view); - break; - case VIEW_ID_TOOLBAR: - toolbar_ = static_cast<ToolbarView*>(view); - break; - case VIEW_ID_TAB_STRIP: - tabstrip_ = static_cast<TabStrip*>(view); - break; - } -} - -void BrowserViewLayout::ViewRemoved(views::View* host, views::View* view) { - switch (view->GetID()) { - case VIEW_ID_BOOKMARK_BAR: - active_bookmark_bar_ = NULL; - break; - } -} - -void BrowserViewLayout::Layout(views::View* host) { - int top = LayoutTabStrip(); - top = LayoutToolbar(top); - top = LayoutBookmarkAndInfoBars(top); - int bottom = LayoutExtensionAndDownloadShelves(); - LayoutTabContents(top, bottom); - // This must be done _after_ we lay out the TabContents since this - // code calls back into us to find the bounding box the find bar - // must be laid out within, and that code depends on the - // TabContentsContainer's bounds being up to date. - if (browser()->HasFindBarController()) { - browser()->GetFindBarController()->find_bar()->MoveWindowIfNecessary( - gfx::Rect(), true); - } - // Align status bubble with the bottom of the contents_container. - browser_view_->LayoutStatusBubble( - top + contents_container_->bounds().height()); - browser_view_->SchedulePaint(); -} - -// Return the preferred size which is the size required to give each -// children their respective preferred size. -gfx::Size BrowserViewLayout::GetPreferredSize(views::View* host) { - return gfx::Size(); -} - -////////////////////////////////////////////////////////////////////////////// -// BrowserViewLayout, private: +// Overridden from ChromeBrowserViewLayoutManager, private: -int BrowserViewLayout::LayoutTabStrip() { +int ChromeBrowserViewLayoutManager::LayoutTabStrip() { if (!browser_view_->IsTabStripVisible()) { tabstrip_->SetVisible(false); tabstrip_->SetBounds(0, 0, 0, 0); @@ -294,7 +292,9 @@ int BrowserViewLayout::LayoutTabStrip() { } } -int BrowserViewLayout::LayoutToolbar(int top) { +// Layout the following controls, starting at |top|, returns the coordinate +// of the bottom of the control, for laying out the next control. +int ChromeBrowserViewLayoutManager::LayoutToolbar(int top) { int browser_view_width = browser_view_->width(); bool visible = browser_view_->IsToolbarVisible(); toolbar_->location_bar()->SetFocusable(visible); @@ -307,7 +307,7 @@ int BrowserViewLayout::LayoutToolbar(int top) { return y + height; } -int BrowserViewLayout::LayoutBookmarkAndInfoBars(int top) { +int ChromeBrowserViewLayoutManager::LayoutBookmarkAndInfoBars(int top) { find_bar_y_ = top + browser_view_->y() - 1; if (active_bookmark_bar_) { // If we're showing the Bookmark bar in detached style, then we @@ -322,7 +322,7 @@ int BrowserViewLayout::LayoutBookmarkAndInfoBars(int top) { return LayoutInfoBar(top); } -int BrowserViewLayout::LayoutTopBar(int top) { +int ChromeBrowserViewLayoutManager::LayoutTopBar(int top) { // This method lays out the the bookmark bar, and, if required, // the extension shelf by its side. The bookmark bar appears on // the right of the extension shelf. If there are too many @@ -378,7 +378,7 @@ int BrowserViewLayout::LayoutTopBar(int top) { return y + bookmark_bar_height; } -int BrowserViewLayout::LayoutInfoBar(int top) { +int ChromeBrowserViewLayoutManager::LayoutInfoBar(int top) { bool visible = browser()->SupportsWindowFeature(Browser::FEATURE_INFOBAR); int height = visible ? infobar_container_->GetPreferredSize().height() : 0; infobar_container_->SetVisible(visible); @@ -388,11 +388,11 @@ int BrowserViewLayout::LayoutInfoBar(int top) { // Layout the TabContents container, between the coordinates |top| and // |bottom|. -void BrowserViewLayout::LayoutTabContents(int top, int bottom) { +void ChromeBrowserViewLayoutManager::LayoutTabContents(int top, int bottom) { contents_split_->SetBounds(0, top, browser_view_->width(), bottom - top); } -int BrowserViewLayout::LayoutExtensionAndDownloadShelves() { +int ChromeBrowserViewLayoutManager::LayoutExtensionAndDownloadShelves() { // If we're showing the Extension bar in detached style, then we // need to show Download shelf _above_ the Extension bar, since // the Extension bar is styled to look like it's part of the page. @@ -410,7 +410,9 @@ int BrowserViewLayout::LayoutExtensionAndDownloadShelves() { return LayoutDownloadShelf(bottom); } -int BrowserViewLayout::LayoutDownloadShelf(int bottom) { +// Layout the Download Shelf, returns the coordinate of the top of the +// control, for laying out the previous control. +int ChromeBrowserViewLayoutManager::LayoutDownloadShelf(int bottom) { // Re-layout the shelf either if it is visible or if it's close animation // is currently running. if (browser_view_->IsDownloadShelfVisible() || @@ -428,7 +430,9 @@ int BrowserViewLayout::LayoutDownloadShelf(int bottom) { return bottom; } -int BrowserViewLayout::LayoutExtensionShelf(int bottom) { +// Layout the Extension Shelf, returns the coordinate of the top of the +// control, for laying out the previous control. +int ChromeBrowserViewLayoutManager::LayoutExtensionShelf(int bottom) { if (!extension_shelf_ || extension_shelf_->IsOnTop()) return bottom; diff --git a/chrome/browser/views/frame/browser_view_layout.h b/chrome/browser/views/frame/chrome_browser_view_layout_manager.h index 33333fa..19334a4 100644 --- a/chrome/browser/views/frame/browser_view_layout.h +++ b/chrome/browser/views/frame/chrome_browser_view_layout_manager.h @@ -2,35 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_VIEWS_FRAME_BROWSER_VIEW_LAYOUT_H_ -#define CHROME_BROWSER_VIEWS_FRAME_BROWSER_VIEW_LAYOUT_H_ +#ifndef CHROME_BROWSER_VIEWS_FRAME_CHROME_BROWSER_VIEW_LAYOUT_MANAGER_H_ +#define CHROME_BROWSER_VIEWS_FRAME_CHROME_BROWSER_VIEW_LAYOUT_MANAGER_H_ +#include "chrome/browser/views/frame/browser_view_layout_manager.h" #include "chrome/browser/views/frame/browser_view.h" -#include "views/layout_manager.h" // The layout manager used in chrome browser. -class BrowserViewLayout : public views::LayoutManager { +class ChromeBrowserViewLayoutManager : public BrowserViewLayoutManager { public: - BrowserViewLayout(); - virtual ~BrowserViewLayout() {} + ChromeBrowserViewLayoutManager(); + virtual ~ChromeBrowserViewLayoutManager() {} - // Returns the minimum size of the browser view. - virtual gfx::Size GetMinimumSize(); - - // Returns the bounding box for the find bar. - virtual gfx::Rect GetFindBarBoundingBox() const; - - // Returns true if the specified point(BrowserView coordinates) is in - // in the window caption area of the browser window. - virtual bool IsPositionInWindowCaption(const gfx::Point& point); - - // Tests to see if the specified |point| (in nonclient view's coordinates) - // is within the views managed by the laymanager. Returns one of - // HitTestCompat enum defined in views/window/hit_test.h. - // See also ClientView::NonClientHitTest. - virtual int NonClientHitTest(const gfx::Point& point); - - // views::LayoutManager overrides: + ////////////////////////////////////////////////////////////////////////////// + // Overridden from LayoutManager. virtual void Installed(views::View* host); virtual void Uninstalled(views::View* host); virtual void ViewAdded(views::View* host, views::View* view); @@ -38,6 +23,13 @@ class BrowserViewLayout : public views::LayoutManager { virtual void Layout(views::View* host); virtual gfx::Size GetPreferredSize(views::View* host); + ////////////////////////////////////////////////////////////////////////////// + // Overridden from BrowserLayoutManager. + virtual gfx::Size GetMinimumSize(); + virtual gfx::Rect GetFindBarBoundingBox() const; + virtual bool IsPositionInWindowCaption(const gfx::Point& point); + virtual int NonClientHitTest(const gfx::Point& point); + protected: Browser* browser() { return browser_view_->browser(); @@ -82,8 +74,7 @@ class BrowserViewLayout : public views::LayoutManager { // The distance the FindBar is from the top of the window, in pixels. int find_bar_y_; - DISALLOW_COPY_AND_ASSIGN(BrowserViewLayout); + DISALLOW_COPY_AND_ASSIGN(ChromeBrowserViewLayoutManager); }; -#endif // CHROME_BROWSER_VIEWS_FRAME_BROWSER_VIEW_LAYOUT_H_ - +#endif // CHROME_BROWSER_VIEWS_FRAME_CHROME_BROWSER_VIEW_LAYOUT_MANAGER_H_ |