diff options
author | mad@chromium.org <mad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-12 14:46:17 +0000 |
---|---|---|
committer | mad@chromium.org <mad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-12 14:46:17 +0000 |
commit | f21c613a0ab52b707f8a2effacda74c77f4448ea (patch) | |
tree | 09051d286db764a71b97bc01f35765e607b4d20f /chrome/browser/views/frame/browser_view.cc | |
parent | 822cfc93fe52974b904b7f184c5448dee5d281c5 (diff) | |
download | chromium_src-f21c613a0ab52b707f8a2effacda74c77f4448ea.zip chromium_src-f21c613a0ab52b707f8a2effacda74c77f4448ea.tar.gz chromium_src-f21c613a0ab52b707f8a2effacda74c77f4448ea.tar.bz2 |
This is an attempt at finding the reason for the page_cycler slowness caused by
the new resize corner. Local experiment led me to believe that it is WebKit
that is slower when we specify a resize corner area.
To validate this hypothesis, I always return an empty rect to WebKit, but I
still compute and push the rect to the render widget and I also draw the bitmap
even if this will cause it to be drawn on top of the scroll bars when there is
only one.
TBR=brettw
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9654 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/frame/browser_view.cc')
-rw-r--r-- | chrome/browser/views/frame/browser_view.cc | 115 |
1 files changed, 108 insertions, 7 deletions
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index e57b2cc..8ccb3e5 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -47,12 +47,15 @@ #include "chrome/common/resource_bundle.h" #include "chrome/common/win_util.h" #include "chrome/views/hwnd_notification_source.h" +#include "chrome/views/native_scroll_bar.h" #include "chrome/views/non_client_view.h" #include "chrome/views/view.h" #include "chrome/views/window.h" #include "chromium_strings.h" #include "generated_resources.h" +#include "webkit_resources.h" + using base::TimeDelta; @@ -86,7 +89,11 @@ static const int kLoadingAnimationFrameTimeMs = 30; // If not -1, windows are shown with this state. static int explicit_show_state = -1; -static const struct { bool separator; int command; int label; } kMenuLayout[] = { +static const struct { + bool separator; + int command; + int label; +} kMenuLayout[] = { { true, 0, 0 }, { false, IDC_TASK_MANAGER, IDS_TASK_MANAGER }, { true, 0, 0 }, @@ -111,6 +118,53 @@ static const struct { bool separator; int command; int label; } kMenuLayout[] = }; /////////////////////////////////////////////////////////////////////////////// +// ResizeCorner, private: + +class ResizeCorner : public views::View { + public: + ResizeCorner() {} + virtual void Paint(ChromeCanvas* canvas) { + SkBitmap * bitmap = ResourceBundle::GetSharedInstance().GetBitmapNamed( + IDR_TEXTAREA_RESIZER); + bitmap->buildMipMap(false); + bool rtl_dir = (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT); + if (rtl_dir) { + canvas->TranslateInt(width(), 0); + canvas->ScaleInt(-1, 1); + canvas->save(); + } + canvas->DrawBitmapInt(*bitmap, width() - bitmap->width(), + height() - bitmap->height()); + if (rtl_dir) + canvas->restore(); + } + + static gfx::Size GetSize() { + return gfx::Size(views::NativeScrollBar::GetVerticalScrollBarWidth(), + views::NativeScrollBar::GetHorizontalScrollBarHeight()); + } + + virtual gfx::Size GetPreferredSize() { + return GetSize(); + } + + virtual void Layout() { + views::View* parent_view = GetParent(); + if (parent_view) { + gfx::Size ps = GetPreferredSize(); + // No need to handle Right to left text direction here, + // our parent must take care of it for us... + SetBounds(parent_view->width() - ps.width(), + parent_view->height() - ps.height(), ps.width(), ps.height()); + } + } + + private: + DISALLOW_COPY_AND_ASSIGN(ResizeCorner); +}; + + +/////////////////////////////////////////////////////////////////////////////// // BrowserView, public: // static @@ -119,7 +173,7 @@ void BrowserView::SetShowState(int state) { } BrowserView::BrowserView(Browser* browser) - : ClientView(NULL, NULL), + : views::ClientView(NULL, NULL), frame_(NULL), browser_(browser), active_bookmark_bar_(NULL), @@ -177,7 +231,7 @@ void BrowserView::WindowMoved() { // Cancel any tabstrip animations, some of them may be invalidated by the // window being repositioned. // Comment out for one cycle to see if this fixes dist tests. - //tabstrip_->DestroyDragController(); + // tabstrip_->DestroyDragController(); status_bubble_->Reposition(); @@ -491,7 +545,7 @@ gfx::Rect BrowserView::GetNormalBounds() const { return gfx::Rect(wp.rcNormalPosition); } -bool BrowserView::IsMaximized() { +bool BrowserView::IsMaximized() const { return frame_->GetWindow()->IsMaximized(); } @@ -535,6 +589,32 @@ bool BrowserView::IsBookmarkBarVisible() const { return bookmark_bar_view_->GetPreferredSize().height() > 1; } +gfx::Rect BrowserView::GetRootWindowResizerRect() const { + // There is no resize corner when we are maximized + if (IsMaximized()) + return gfx::Rect(); + + // We don't specify a resize corner size if we have a bottom shelf either. + // This is because we take care of drawing the resize corner on top of that + // shelf, so we don't want others to do it for us in this case. + // Currently, the only visible bottom shelf is the download shelf. + // Other tests should be added here if we add more bottom shelves. + TabContents* current_tab = browser_->GetSelectedTabContents(); + if (current_tab && current_tab->IsDownloadShelfVisible()) { + DownloadShelfView* download_shelf = current_tab->GetDownloadShelfView(); + if (download_shelf && download_shelf->IsShowing()) + return gfx::Rect(); + } + + gfx::Rect client_rect = contents_container_->bounds(); + gfx::Size resize_corner_size = ResizeCorner::GetSize(); + int x = client_rect.width() - resize_corner_size.width(); + if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) + x = 0; + return gfx::Rect(x, client_rect.height() - resize_corner_size.height(), + resize_corner_size.width(), resize_corner_size.height()); +} + void BrowserView::ToggleBookmarkBar() { BookmarkBarView::ToggleWhenVisible(browser_->profile()); } @@ -887,6 +967,24 @@ int BrowserView::NonClientHitTest(const gfx::Point& point) { // area of the window. So we need to treat hit-tests in these regions as // hit-tests of the titlebar. + // There is not resize corner when we are maximised + if (!IsMaximized()) { + CRect client_rect; + ::GetClientRect(frame_->GetWindow()->GetHWND(), &client_rect); + gfx::Size resize_corner_size = ResizeCorner::GetSize(); + gfx::Rect resize_corner_rect(client_rect.right - resize_corner_size.width(), + client_rect.bottom - resize_corner_size.height(), + resize_corner_size.width(), resize_corner_size.height()); + bool rtl_dir = (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT); + if (rtl_dir) + resize_corner_rect.set_x(0); + if (resize_corner_rect.Contains(point)) { + if (rtl_dir) + return HTBOTTOMLEFT; + return HTBOTTOMRIGHT; + } + } + // Determine if the TabStrip exists and is capable of being clicked on. We // might be a popup window without a TabStrip, or the TabStrip could be // animating. @@ -940,7 +1038,7 @@ int BrowserView::NonClientHitTest(const gfx::Point& point) { return HTNOWHERE; // If the point is somewhere else, delegate to the default implementation. - return ClientView::NonClientHitTest(point); + return views::ClientView::NonClientHitTest(point); } /////////////////////////////////////////////////////////////////////////////// @@ -1119,7 +1217,7 @@ int BrowserView::LayoutBookmarkAndInfoBars(int top) { return LayoutBookmarkBar(top); } - // If we're showing a regular bookmark bar and it's not below an infobar, + // If we're showing a regular bookmark bar and it's not below an infobar, // make it overlap the toolbar so that the bar items can be drawn higher. if (active_bookmark_bar_) top -= bookmark_bar_view_->GetToolbarOverlap(); @@ -1200,8 +1298,11 @@ bool BrowserView::MaybeShowInfoBar(TabContents* contents) { bool BrowserView::MaybeShowDownloadShelf(TabContents* contents) { views::View* new_shelf = NULL; - if (contents && contents->IsDownloadShelfVisible()) + if (contents && contents->IsDownloadShelfVisible()) { new_shelf = contents->GetDownloadShelfView(); + if (new_shelf != active_download_shelf_) + new_shelf->AddChildView(new ResizeCorner()); + } return UpdateChildViewAndLayout(new_shelf, &active_download_shelf_); } |