summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-19 20:29:07 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-19 20:29:07 +0000
commitc9af00d21e67b4dee15ec54655d30cb9f9139972 (patch)
tree294e2fdc6a7f1b3ef2935b974345d2d24db97af6 /chrome
parentadb0428576b6cdbbc9542319b5af8309057a17d1 (diff)
downloadchromium_src-c9af00d21e67b4dee15ec54655d30cb9f9139972.zip
chromium_src-c9af00d21e67b4dee15ec54655d30cb9f9139972.tar.gz
chromium_src-c9af00d21e67b4dee15ec54655d30cb9f9139972.tar.bz2
Fix numerous alignment problems, both horizontal and vertical, in drawing the browser chrome. This doesn't fix problems with the NTP background image offsets (see bug 51853).
This also makes sure the OTR avatar is reversed in RTL mode, and clipped as usefully as possible when there isn't enough room for the full image. BUG=44157 TEST=Frame, toolbar, bookmark bar, and find bar all look lined up with default and custom themes, restored and maximized, LTR and RTL, side tabs and normal tabs, and in popup and app windows Review URL: http://codereview.chromium.org/3137019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56737 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/chromeos/frame/normal_browser_frame_view.cc35
-rw-r--r--chrome/browser/chromeos/frame/normal_browser_frame_view.h1
-rw-r--r--chrome/browser/views/detachable_toolbar_view.cc23
-rw-r--r--chrome/browser/views/detachable_toolbar_view.h8
-rw-r--r--chrome/browser/views/dropdown_bar_host.cc7
-rw-r--r--chrome/browser/views/dropdown_bar_host.h3
-rw-r--r--chrome/browser/views/find_bar_view.cc20
-rw-r--r--chrome/browser/views/frame/app_panel_browser_frame_view.cc6
-rw-r--r--chrome/browser/views/frame/app_panel_browser_frame_view.h1
-rw-r--r--chrome/browser/views/frame/browser_frame.h7
-rw-r--r--chrome/browser/views/frame/browser_frame_gtk.cc4
-rw-r--r--chrome/browser/views/frame/browser_frame_gtk.h3
-rw-r--r--chrome/browser/views/frame/browser_frame_win.cc24
-rw-r--r--chrome/browser/views/frame/browser_frame_win.h6
-rw-r--r--chrome/browser/views/frame/browser_non_client_frame_view.h8
-rw-r--r--chrome/browser/views/frame/browser_view.cc32
-rw-r--r--chrome/browser/views/frame/browser_view.h13
-rw-r--r--chrome/browser/views/frame/browser_view_layout.cc4
-rw-r--r--chrome/browser/views/frame/glass_browser_frame_view.cc177
-rw-r--r--chrome/browser/views/frame/glass_browser_frame_view.h11
-rw-r--r--chrome/browser/views/frame/opaque_browser_frame_view.cc312
-rw-r--r--chrome/browser/views/frame/opaque_browser_frame_view.h35
-rw-r--r--chrome/browser/views/frame/popup_non_client_frame_view.cc5
-rw-r--r--chrome/browser/views/frame/popup_non_client_frame_view.h3
24 files changed, 390 insertions, 358 deletions
diff --git a/chrome/browser/chromeos/frame/normal_browser_frame_view.cc b/chrome/browser/chromeos/frame/normal_browser_frame_view.cc
index 6e6362b..2878eae 100644
--- a/chrome/browser/chromeos/frame/normal_browser_frame_view.cc
+++ b/chrome/browser/chromeos/frame/normal_browser_frame_view.cc
@@ -91,11 +91,16 @@ gfx::Rect NormalBrowserFrameView::GetBoundsForTabStrip(
return gfx::Rect(border_thickness, NonClientTopBorderHeight(),
ps.width(), browser_view_->height());
}
- return gfx::Rect(border_thickness, NonClientTopBorderHeight(),
+ return gfx::Rect(border_thickness, GetHorizontalTabStripVerticalOffset(false),
std::max(0, width() - (2 * border_thickness)),
tabstrip->GetPreferredHeight());
}
+int NormalBrowserFrameView::GetHorizontalTabStripVerticalOffset(
+ bool restored) const {
+ return NonClientTopBorderHeight();
+}
+
void NormalBrowserFrameView::UpdateThrobber(bool running) {
// No window icon.
}
@@ -256,27 +261,30 @@ void NormalBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) {
// Window frame mode and color
SkBitmap* theme_frame;
- int y = 0;
+ // HACK: This is to properly align the frame background with the tab
+ // background. This was added because when this code was copied from the
+ // opaque frame code, that code didn't correctly handle maximized mode theme
+ // alignment. That bug has since been fixed in a more general but more
+ // complex way in the opaque frame. Since this file is eventually going to
+ // die (see crbug.com/52674), I'm just leaving this here rather than replacing
+ // it with the complex fix.
+ int y = -kCustomFrameBackgroundVerticalOffset;
// Never theme app and popup windows.
if (!browser_view_->IsBrowserTypeNormal()) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
theme_frame = rb.GetBitmapNamed(ShouldPaintAsActive() ?
IDR_FRAME : IDR_FRAME_INACTIVE);
+ y = 0; // These are never themed.
} else if (!browser_view_->IsOffTheRecord()) {
theme_frame = tp->GetBitmapNamed(ShouldPaintAsActive() ?
IDR_THEME_FRAME : IDR_THEME_FRAME_INACTIVE);
- // TODO(oshima): gtk based CHROMEOS is using non custom frame
- // mode which does this adjustment. This should be removed
- // once it's fully migrated to views. -1 is due to the layout
- // difference between views and gtk and will be removed.
- // See http://crbug.com/28580.
- y = -kCustomFrameBackgroundVerticalOffset - 1;
} else {
theme_frame = tp->GetBitmapNamed(ShouldPaintAsActive() ?
IDR_THEME_FRAME_INCOGNITO: IDR_THEME_FRAME_INCOGNITO_INACTIVE);
- y = -kCustomFrameBackgroundVerticalOffset - 1;
}
- // Draw the theme frame.
+ // Draw the theme frame. It must be aligned with the tabstrip as if we were
+ // in restored mode. Note that the top of the tabstrip is
+ // kTabstripTopShadowThickness px off the top of the screen.
canvas->TileImageInt(*theme_frame, 0, y, width(), theme_frame->height());
// Draw the theme frame overlay
@@ -284,7 +292,7 @@ void NormalBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) {
browser_view_->IsBrowserTypeNormal()) {
SkBitmap* theme_overlay = tp->GetBitmapNamed(ShouldPaintAsActive() ?
IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE);
- canvas->DrawBitmapInt(*theme_overlay, 0, 0);
+ canvas->DrawBitmapInt(*theme_overlay, 0, y);
}
if (!browser_view_->IsToolbarVisible()) {
@@ -328,14 +336,13 @@ void NormalBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) {
tp->GetColor(BrowserThemeProvider::COLOR_TOOLBAR);
canvas->FillRectInt(theme_toolbar_color, toolbar_bounds.x(), bottom_y,
toolbar_bounds.width(), bottom_edge_height);
- toolbar_bounds.Inset(-kClientEdgeThickness, 0);
int strip_height = browser_view_->GetTabStripHeight();
SkBitmap* theme_toolbar = tp->GetBitmapNamed(IDR_THEME_TOOLBAR);
canvas->TileImageInt(*theme_toolbar, toolbar_bounds.x(),
- strip_height - kFrameShadowThickness, toolbar_bounds.x(),
- bottom_y, toolbar_bounds.width(), theme_toolbar->height());
+ strip_height - kFrameShadowThickness, toolbar_bounds.x(), bottom_y,
+ toolbar_bounds.width(), theme_toolbar->height());
canvas->DrawBitmapInt(*toolbar_left, 0, 0, toolbar_left->width(), split_point,
toolbar_bounds.x() - toolbar_left->width(), toolbar_bounds.y(),
diff --git a/chrome/browser/chromeos/frame/normal_browser_frame_view.h b/chrome/browser/chromeos/frame/normal_browser_frame_view.h
index 96d27e8..cc73a39 100644
--- a/chrome/browser/chromeos/frame/normal_browser_frame_view.h
+++ b/chrome/browser/chromeos/frame/normal_browser_frame_view.h
@@ -34,6 +34,7 @@ class NormalBrowserFrameView : public BrowserNonClientFrameView,
// Overridden from BrowserNonClientFrameView:
virtual gfx::Rect GetBoundsForTabStrip(BaseTabStrip* tabstrip) const;
+ virtual int GetHorizontalTabStripVerticalOffset(bool restored) const;
virtual void UpdateThrobber(bool running);
virtual gfx::Size GetMinimumSize();
diff --git a/chrome/browser/views/detachable_toolbar_view.cc b/chrome/browser/views/detachable_toolbar_view.cc
index ba44f3d..f7664c2 100644
--- a/chrome/browser/views/detachable_toolbar_view.cc
+++ b/chrome/browser/views/detachable_toolbar_view.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// 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.
@@ -11,6 +11,7 @@
#include "grit/theme_resources.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkShader.h"
+#include "views/window/non_client_view.h"
// How round the 'new tab' style bookmarks bar is.
static const int kNewtabBarRoundness = 5;
@@ -21,21 +22,18 @@ const SkColor DetachableToolbarView::kMiddleDividerColor =
SkColorSetRGB(194, 205, 212);
// static
-void DetachableToolbarView::PaintBackgroundAttachedMode(gfx::Canvas* canvas,
- views::View* view) {
- gfx::Rect bounds =
- view->GetBounds(views::View::APPLY_MIRRORING_TRANSFORMATION);
-
+void DetachableToolbarView::PaintBackgroundAttachedMode(
+ gfx::Canvas* canvas,
+ views::View* view,
+ const gfx::Point& background_origin) {
ThemeProvider* tp = view->GetThemeProvider();
SkColor theme_toolbar_color =
tp->GetColor(BrowserThemeProvider::COLOR_TOOLBAR);
canvas->FillRectInt(theme_toolbar_color, 0, 0,
view->width(), view->height());
-
canvas->TileImageInt(*tp->GetBitmapNamed(IDR_THEME_TOOLBAR),
- view->GetParent()->GetBounds(
- views::View::APPLY_MIRRORING_TRANSFORMATION).x() + bounds.x(),
- bounds.y(), 0, 0, view->width(), view->height());
+ background_origin.x(), background_origin.y(), 0, 0,
+ view->width(), view->height());
}
// static
@@ -57,9 +55,10 @@ void DetachableToolbarView::PaintHorizontalBorder(gfx::Canvas* canvas,
DetachableToolbarView* view) {
// Border can be at the top or at the bottom of the view depending on whether
// the view (bar/shelf) is attached or detached.
- int y = !view->IsDetached() ? view->height() - 1 : 0;
+ int thickness = views::NonClientFrameView::kClientEdgeThickness;
+ int y = view->IsDetached() ? 0 : (view->height() - thickness);
canvas->FillRectInt(ResourceBundle::toolbar_separator_color,
- 0, y, view->width(), 1);
+ 0, y, view->width(), thickness);
}
// static
diff --git a/chrome/browser/views/detachable_toolbar_view.h b/chrome/browser/views/detachable_toolbar_view.h
index d44557c..0211e88 100644
--- a/chrome/browser/views/detachable_toolbar_view.h
+++ b/chrome/browser/views/detachable_toolbar_view.h
@@ -32,10 +32,12 @@ class DetachableToolbarView : public AccessibleToolbarView {
// Gets the current amount of overlap atop the browser toolbar.
virtual int GetToolbarOverlap() const = 0;
- // Paint the background (including the theme image behind content area) when
- // in bar/shelf is attached to the Chrome frame.
+ // Paints the background (including the theme image behind content area) when
+ // the bar/shelf is attached to the top toolbar. |background_origin| is the
+ // origin to use for painting the theme image.
static void PaintBackgroundAttachedMode(gfx::Canvas* canvas,
- views::View* view);
+ views::View* view,
+ const gfx::Point& background_origin);
// Calculate the rect for the content area of the bar/shelf. This is only
// needed when the bar/shelf is detached from the Chrome frame (otherwise the
diff --git a/chrome/browser/views/dropdown_bar_host.cc b/chrome/browser/views/dropdown_bar_host.cc
index d01459e..f756cb2 100644
--- a/chrome/browser/views/dropdown_bar_host.cc
+++ b/chrome/browser/views/dropdown_bar_host.cc
@@ -174,13 +174,6 @@ void DropdownBarHost::AnimationEnded(const Animation* animation) {
}
}
-void DropdownBarHost::GetThemePosition(gfx::Rect* bounds) {
- *bounds = GetDialogPosition(gfx::Rect());
- gfx::Rect toolbar_bounds = browser_view_->GetToolbarBounds();
- gfx::Rect tab_strip_bounds = browser_view_->GetTabStripBounds();
- bounds->Offset(-toolbar_bounds.x(), -tab_strip_bounds.y());
-}
-
////////////////////////////////////////////////////////////////////////////////
// DropdownBarHost protected:
diff --git a/chrome/browser/views/dropdown_bar_host.h b/chrome/browser/views/dropdown_bar_host.h
index 8924456..72b9aac 100644
--- a/chrome/browser/views/dropdown_bar_host.h
+++ b/chrome/browser/views/dropdown_bar_host.h
@@ -78,9 +78,6 @@ class DropdownBarHost : public views::AcceleratorTarget,
virtual void AnimationProgressed(const Animation* animation);
virtual void AnimationEnded(const Animation* animation);
- // Get the offset with which to paint the theme image.
- void GetThemePosition(gfx::Rect* bounds);
-
// During testing we can disable animations by setting this flag to true,
// so that opening and closing the dropdown bar is shown instantly, instead of
// having to poll it while it animates to open/closed status.
diff --git a/chrome/browser/views/find_bar_view.cc b/chrome/browser/views/find_bar_view.cc
index 355a56f..62fa29c 100644
--- a/chrome/browser/views/find_bar_view.cc
+++ b/chrome/browser/views/find_bar_view.cc
@@ -17,6 +17,7 @@
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/views/find_bar_host.h"
+#include "chrome/browser/views/frame/browser_view.h"
#include "chrome/browser/view_ids.h"
#include "gfx/canvas.h"
#include "grit/generated_resources.h"
@@ -25,6 +26,7 @@
#include "views/background.h"
#include "views/controls/button/image_button.h"
#include "views/controls/label.h"
+#include "views/widget/widget.h"
// The amount of whitespace to have before the find button.
static const int kWhiteSpaceAfterMatchCountLabel = 1;
@@ -232,16 +234,26 @@ void FindBarView::SetFocusAndSelection(bool select_all) {
void FindBarView::Paint(gfx::Canvas* canvas) {
SkPaint paint;
+ // Determine the find bar size as well as the offset from which to tile the
+ // toolbar background image. First, get the widget bounds.
+ gfx::Rect bounds;
+ GetWidget()->GetBounds(&bounds, true);
+ // Now convert from screen to parent coordinates.
+ gfx::Point origin(bounds.origin());
+ BrowserView* browser_view = host()->browser_view();
+ ConvertPointToView(NULL, browser_view, &origin);
+ bounds.set_origin(origin);
+ // Finally, calculate the background image tiling offset.
+ origin = browser_view->OffsetPointForToolbarBackgroundImage(origin);
+
// First, we draw the background image for the whole dialog (3 images: left,
// middle and right). Note, that the window region has been set by the
// controller, so the whitespace in the left and right background images is
// actually outside the window region and is therefore not drawn. See
// FindInPageWidgetWin::CreateRoundedWindowEdges() for details.
ThemeProvider* tp = GetThemeProvider();
- gfx::Rect bounds;
- host()->GetThemePosition(&bounds);
- canvas->TileImageInt(*tp->GetBitmapNamed(IDR_THEME_TOOLBAR), bounds.x(),
- bounds.y(), 0, 0, bounds.width(), bounds.height());
+ canvas->TileImageInt(*tp->GetBitmapNamed(IDR_THEME_TOOLBAR), origin.x(),
+ origin.y(), 0, 0, bounds.width(), bounds.height());
// Now flip the canvas for the rest of the graphics if in RTL mode.
canvas->Save();
diff --git a/chrome/browser/views/frame/app_panel_browser_frame_view.cc b/chrome/browser/views/frame/app_panel_browser_frame_view.cc
index b8a1b33..d7efbe9 100644
--- a/chrome/browser/views/frame/app_panel_browser_frame_view.cc
+++ b/chrome/browser/views/frame/app_panel_browser_frame_view.cc
@@ -93,6 +93,12 @@ gfx::Rect AppPanelBrowserFrameView::GetBoundsForTabStrip(
return gfx::Rect();
}
+int AppPanelBrowserFrameView::GetHorizontalTabStripVerticalOffset(
+ bool restored) const {
+ // App panels are not themed and don't need this.
+ return 0;
+}
+
void AppPanelBrowserFrameView::UpdateThrobber(bool running) {
window_icon_->Update();
}
diff --git a/chrome/browser/views/frame/app_panel_browser_frame_view.h b/chrome/browser/views/frame/app_panel_browser_frame_view.h
index f7a7c745..eae6d9b 100644
--- a/chrome/browser/views/frame/app_panel_browser_frame_view.h
+++ b/chrome/browser/views/frame/app_panel_browser_frame_view.h
@@ -35,6 +35,7 @@ class AppPanelBrowserFrameView : public BrowserNonClientFrameView,
// Overridden from BrowserNonClientFrameView:
virtual gfx::Rect GetBoundsForTabStrip(BaseTabStrip* tabstrip) const;
+ virtual int GetHorizontalTabStripVerticalOffset(bool restored) const;
virtual void UpdateThrobber(bool running);
virtual gfx::Size GetMinimumSize();
diff --git a/chrome/browser/views/frame/browser_frame.h b/chrome/browser/views/frame/browser_frame.h
index 5706d6b..0e3b9b2 100644
--- a/chrome/browser/views/frame/browser_frame.h
+++ b/chrome/browser/views/frame/browser_frame.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// 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.
@@ -50,6 +50,11 @@ class BrowserFrame {
// TabStrip.
virtual gfx::Rect GetBoundsForTabStrip(BaseTabStrip* tabstrip) const = 0;
+ // Returns the y coordinate within the window at which the horizontal TabStrip
+ // begins (or would begin). If |restored| is true, this is calculated as if
+ // we were in restored mode regardless of the current mode.
+ virtual int GetHorizontalTabStripVerticalOffset(bool restored) const = 0;
+
// Tells the frame to update the throbber.
virtual void UpdateThrobber(bool running) = 0;
diff --git a/chrome/browser/views/frame/browser_frame_gtk.cc b/chrome/browser/views/frame/browser_frame_gtk.cc
index 5b66885..3a9a1ba 100644
--- a/chrome/browser/views/frame/browser_frame_gtk.cc
+++ b/chrome/browser/views/frame/browser_frame_gtk.cc
@@ -71,6 +71,10 @@ gfx::Rect BrowserFrameGtk::GetBoundsForTabStrip(BaseTabStrip* tabstrip) const {
return browser_frame_view_->GetBoundsForTabStrip(tabstrip);
}
+int BrowserFrameGtk::GetHorizontalTabStripVerticalOffset(bool restored) const {
+ return browser_frame_view_->GetHorizontalTabStripVerticalOffset(restored);
+}
+
void BrowserFrameGtk::UpdateThrobber(bool running) {
browser_frame_view_->UpdateThrobber(running);
}
diff --git a/chrome/browser/views/frame/browser_frame_gtk.h b/chrome/browser/views/frame/browser_frame_gtk.h
index 20a5be2..742eea5 100644
--- a/chrome/browser/views/frame/browser_frame_gtk.h
+++ b/chrome/browser/views/frame/browser_frame_gtk.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// 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.
@@ -31,6 +31,7 @@ class BrowserFrameGtk : public BrowserFrame,
virtual views::Window* GetWindow();
virtual int GetMinimizeButtonOffset() const;
virtual gfx::Rect GetBoundsForTabStrip(BaseTabStrip* tabstrip) const;
+ virtual int GetHorizontalTabStripVerticalOffset(bool restored) const;
virtual void UpdateThrobber(bool running);
virtual void ContinueDraggingDetachedTab();
virtual ThemeProvider* GetThemeProviderForFrame() const;
diff --git a/chrome/browser/views/frame/browser_frame_win.cc b/chrome/browser/views/frame/browser_frame_win.cc
index d018712..22fb3cc 100644
--- a/chrome/browser/views/frame/browser_frame_win.cc
+++ b/chrome/browser/views/frame/browser_frame_win.cc
@@ -67,15 +67,6 @@ void BrowserFrameWin::Init() {
BrowserFrameWin::~BrowserFrameWin() {
}
-int BrowserFrameWin::GetTitleBarHeight() {
- RECT caption = { 0 };
- if (DwmGetWindowAttribute(GetNativeView(), DWMWA_CAPTION_BUTTON_BOUNDS,
- &caption, sizeof(RECT)) == S_OK) {
- return caption.bottom;
- }
- return GetSystemMetrics(SM_CYCAPTION);
-}
-
views::Window* BrowserFrameWin::GetWindow() {
return this;
}
@@ -96,6 +87,10 @@ gfx::Rect BrowserFrameWin::GetBoundsForTabStrip(BaseTabStrip* tabstrip) const {
return browser_frame_view_->GetBoundsForTabStrip(tabstrip);
}
+int BrowserFrameWin::GetHorizontalTabStripVerticalOffset(bool restored) const {
+ return browser_frame_view_->GetHorizontalTabStripVerticalOffset(restored);
+}
+
void BrowserFrameWin::UpdateThrobber(bool running) {
browser_frame_view_->UpdateThrobber(running);
}
@@ -311,13 +306,10 @@ void BrowserFrameWin::UpdateDWMFrame() {
// In maximized mode, we only have a titlebar strip of glass, no side/bottom
// borders.
if (!browser_view_->IsFullscreen()) {
- if (browser_view_->UseVerticalTabs()) {
- margins.cyTopHeight = GetTitleBarHeight();
- } else {
- margins.cyTopHeight =
- GetBoundsForTabStrip(browser_view_->tabstrip()).bottom() +
- kDWMFrameTopOffset;
- }
+ gfx::Rect tabstrip_bounds(
+ GetBoundsForTabStrip(browser_view_->tabstrip()));
+ margins.cyTopHeight = (browser_view_->UseVerticalTabs() ?
+ tabstrip_bounds.y() : tabstrip_bounds.bottom()) + kDWMFrameTopOffset;
}
} else {
// For popup and app windows we want to use the default margins.
diff --git a/chrome/browser/views/frame/browser_frame_win.h b/chrome/browser/views/frame/browser_frame_win.h
index 583eb87..fdc5d62 100644
--- a/chrome/browser/views/frame/browser_frame_win.h
+++ b/chrome/browser/views/frame/browser_frame_win.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// 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.
@@ -36,13 +36,11 @@ class BrowserFrameWin : public BrowserFrame, public views::WindowWin {
BrowserView* browser_view() const { return browser_view_; }
- // Returns the height of the title bar.
- int GetTitleBarHeight();
-
// BrowserFrame implementation.
virtual views::Window* GetWindow();
virtual int GetMinimizeButtonOffset() const;
virtual gfx::Rect GetBoundsForTabStrip(BaseTabStrip* tabstrip) const;
+ virtual int GetHorizontalTabStripVerticalOffset(bool restored) const;
virtual void UpdateThrobber(bool running);
virtual void ContinueDraggingDetachedTab();
virtual ThemeProvider* GetThemeProviderForFrame() const;
diff --git a/chrome/browser/views/frame/browser_non_client_frame_view.h b/chrome/browser/views/frame/browser_non_client_frame_view.h
index ffcde5c..ba8ba40 100644
--- a/chrome/browser/views/frame/browser_non_client_frame_view.h
+++ b/chrome/browser/views/frame/browser_non_client_frame_view.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// 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.
@@ -20,6 +20,12 @@ class BrowserNonClientFrameView : public views::NonClientFrameView {
// Returns the bounds within which the TabStrip should be laid out.
virtual gfx::Rect GetBoundsForTabStrip(BaseTabStrip* tabstrip) const = 0;
+ // Returns the y coordinate within the window at which the horizontal TabStrip
+ // begins, or (in vertical tabs mode) would begin. If |restored| is true,
+ // this is calculated as if we were in restored mode regardless of the current
+ // mode. This is used to correctly align theme images.
+ virtual int GetHorizontalTabStripVerticalOffset(bool restored) const = 0;
+
// Updates the throbber.
virtual void UpdateThrobber(bool running) = 0;
};
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index 65548ef..68c08ef 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -269,7 +269,9 @@ void BookmarkExtensionBackground::Paint(gfx::Canvas* canvas,
if (!toolbar_overlap)
DetachableToolbarView::PaintHorizontalBorder(canvas, host_view_);
} else {
- DetachableToolbarView::PaintBackgroundAttachedMode(canvas, host_view_);
+ DetachableToolbarView::PaintBackgroundAttachedMode(canvas, host_view_,
+ browser_view_->OffsetPointForToolbarBackgroundImage(
+ gfx::Point(host_view_->MirroredX(), host_view_->y())));
if (host_view_->height() >= toolbar_overlap)
DetachableToolbarView::PaintHorizontalBorder(canvas, host_view_);
}
@@ -591,7 +593,16 @@ void BrowserView::WindowMoveOrResizeStarted() {
}
gfx::Rect BrowserView::GetToolbarBounds() const {
- return toolbar_->bounds();
+ gfx::Rect toolbar_bounds(toolbar_->bounds());
+ if (toolbar_bounds.IsEmpty())
+ return toolbar_bounds;
+ // When using vertical tabs, the toolbar appears to extend behind the tab
+ // column.
+ if (UseVerticalTabs())
+ toolbar_bounds.Inset(tabstrip_->x() - toolbar_bounds.x(), 0, 0, 0);
+ // The apparent toolbar edges are outside the "real" toolbar edges.
+ toolbar_bounds.Inset(-views::NonClientFrameView::kClientEdgeThickness, 0);
+ return toolbar_bounds;
}
gfx::Rect BrowserView::GetClientAreaBounds() const {
@@ -619,8 +630,14 @@ int BrowserView::GetTabStripHeight() const {
return IsTabStripVisible() ? tabstrip_->GetPreferredSize().height() : 0;
}
-gfx::Rect BrowserView::GetTabStripBounds() const {
- return frame_->GetBoundsForTabStrip(tabstrip_);
+gfx::Point BrowserView::OffsetPointForToolbarBackgroundImage(
+ const gfx::Point& point) const {
+ // The background image starts tiling horizontally at the window left edge and
+ // vertically at the top edge of the horizontal tab strip (or where it would
+ // be). We expect our parent's origin to be the window origin.
+ gfx::Point window_point(point.Add(gfx::Point(MirroredX(), y())));
+ window_point.Offset(0, -frame_->GetHorizontalTabStripVerticalOffset(false));
+ return window_point;
}
int BrowserView::GetSidebarWidth() const {
@@ -1778,11 +1795,12 @@ void BrowserView::Layout() {
// Send the margins of the "user-perceived content area" of this
// browser window so AeroPeekManager can render a background-tab image in
// the area.
+ // TODO(pkasting) correct content inset??
if (aeropeek_manager_.get()) {
gfx::Insets insets(GetFindBarBoundingBox().y() + 1,
- GetTabStripBounds().x(),
- GetTabStripBounds().x(),
- GetTabStripBounds().x());
+ 0,
+ 0,
+ 0);
aeropeek_manager_->SetContentInsets(insets);
}
#endif
diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h
index a56bbb3..1d77dff 100644
--- a/chrome/browser/views/frame/browser_view.h
+++ b/chrome/browser/views/frame/browser_view.h
@@ -116,7 +116,10 @@ class BrowserView : public BrowserBubbleHost,
// initiated.
void WindowMoveOrResizeStarted();
- // Returns the bounds of the toolbar, in BrowserView coordinates.
+ // Returns the apparent bounds of the toolbar, in BrowserView coordinates.
+ // These differ from |toolbar_.bounds()| in that they match where the toolbar
+ // background image is drawn -- slightly outside the "true" bounds
+ // horizontally, and, when using vertical tabs, behind the tab column.
gfx::Rect GetToolbarBounds() const;
// Returns the bounds of the content area, in the coordinates of the
@@ -140,9 +143,11 @@ class BrowserView : public BrowserBubbleHost,
// avatar icon.
int GetTabStripHeight() const;
- // Returns the bounds of the TabStrip. Used by themed views to determine the
- // offset of IDR_THEME_TOOLBAR.
- gfx::Rect GetTabStripBounds() const;
+ // Takes some view's origin (relative to this BrowserView) and offsets it such
+ // that it can be used as the source origin for seamlessly tiling the toolbar
+ // background image over that view.
+ gfx::Point OffsetPointForToolbarBackgroundImage(
+ const gfx::Point& point) const;
// Returns the width of the currently displayed sidebar or 0.
int GetSidebarWidth() const;
diff --git a/chrome/browser/views/frame/browser_view_layout.cc b/chrome/browser/views/frame/browser_view_layout.cc
index f7d8128..0abd70e 100644
--- a/chrome/browser/views/frame/browser_view_layout.cc
+++ b/chrome/browser/views/frame/browser_view_layout.cc
@@ -246,8 +246,8 @@ void BrowserViewLayout::Layout(views::View* host) {
int top = LayoutTabStrip();
if (browser_view_->IsTabStripVisible() && !browser_view_->UseVerticalTabs()) {
tabstrip_->SetBackgroundOffset(gfx::Point(
- tabstrip_->x() - browser_view_->GetToolbarBounds().x(),
- tabstrip_->y()));
+ tabstrip_->MirroredX() + browser_view_->MirroredX(),
+ browser_view_->frame()->GetHorizontalTabStripVerticalOffset(false)));
}
top = LayoutToolbar(top);
top = LayoutBookmarkAndInfoBars(top);
diff --git a/chrome/browser/views/frame/glass_browser_frame_view.cc b/chrome/browser/views/frame/glass_browser_frame_view.cc
index 6f30e6a..e9f6a41 100644
--- a/chrome/browser/views/frame/glass_browser_frame_view.cc
+++ b/chrome/browser/views/frame/glass_browser_frame_view.cc
@@ -33,9 +33,6 @@ const int kNonClientRestoredExtraThickness = 11;
// In the window corners, the resize areas don't actually expand bigger, but the
// 16 px at the end of the top and bottom edges triggers diagonal resizing.
const int kResizeAreaCornerSize = 16;
-// In maximized mode, the OTR avatar starts 2 px below the top of the screen, so
-// that it doesn't extend into the "3D edge" portion of the titlebar.
-const int kOTRMaximizedTopSpacing = 2;
// The OTR avatar ends 2 px above the bottom of the tabstrip (which, given the
// way the tabstrip draws its bottom edge, will appear like a 1 px gap to the
// user).
@@ -82,8 +79,9 @@ gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip(
BaseTabStrip* tabstrip) const {
if (browser_view_->UseVerticalTabs()) {
gfx::Size ps = tabstrip->GetPreferredSize();
- return gfx::Rect(NonClientBorderThickness(), NonClientTopBorderHeight(),
- ps.width(), browser_view_->height());
+ return gfx::Rect(NonClientBorderThickness(),
+ NonClientTopBorderHeight(false, false), ps.width(),
+ browser_view_->height());
}
int minimize_button_offset = frame_->GetMinimizeButtonOffset();
int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ?
@@ -103,11 +101,16 @@ gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip(
int tabstrip_width = minimize_button_offset - tabstrip_x -
(frame_->GetWindow()->IsMaximized() ?
kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing);
- return gfx::Rect(tabstrip_x, NonClientTopBorderHeight(),
+ return gfx::Rect(tabstrip_x, GetHorizontalTabStripVerticalOffset(false),
std::max(0, tabstrip_width),
tabstrip->GetPreferredHeight());
}
+int GlassBrowserFrameView::GetHorizontalTabStripVerticalOffset(
+ bool restored) const {
+ return NonClientTopBorderHeight(restored, true);
+}
+
void GlassBrowserFrameView::UpdateThrobber(bool running) {
if (throbber_running_) {
if (running) {
@@ -145,7 +148,7 @@ gfx::Rect GlassBrowserFrameView::GetWindowBoundsForClientBounds(
return gfx::Rect(rect);
}
- int top_height = NonClientTopBorderHeight();
+ int top_height = NonClientTopBorderHeight(false, false);
int border_thickness = NonClientBorderThickness();
return gfx::Rect(std::max(0, client_bounds.x() - border_thickness),
std::max(0, client_bounds.y() - top_height),
@@ -222,15 +225,19 @@ int GlassBrowserFrameView::NonClientBorderThickness() const {
kNonClientBorderThickness;
}
-int GlassBrowserFrameView::NonClientTopBorderHeight() const {
- if (frame_->GetWindow()->IsFullscreen())
+int GlassBrowserFrameView::NonClientTopBorderHeight(
+ bool restored,
+ bool ignore_vertical_tabs) const {
+ if (!restored && frame_->GetWindow()->IsFullscreen())
return 0;
- if (browser_view_->UseVerticalTabs())
- return static_cast<BrowserFrameWin*>(frame_)->GetTitleBarHeight();
// We'd like to use FrameBorderThickness() here, but the maximized Aero glass
// frame has a 0 frame border around most edges and a CYSIZEFRAME-thick border
// at the top (see AeroGlassFrame::OnGetMinMaxInfo()).
- return GetSystemMetrics(SM_CYSIZEFRAME) + (browser_view_->IsMaximized() ?
+ if (browser_view_->IsTabStripVisible() && !ignore_vertical_tabs &&
+ browser_view_->UseVerticalTabs())
+ return GetSystemMetrics(SM_CYSIZEFRAME) + GetSystemMetrics(SM_CYCAPTION);
+ return GetSystemMetrics(SM_CYSIZEFRAME) +
+ ((!restored && browser_view_->IsMaximized()) ?
-kTabstripTopShadowThickness : kNonClientRestoredExtraThickness);
}
@@ -241,55 +248,56 @@ void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) {
gfx::Point toolbar_origin(toolbar_bounds.origin());
View::ConvertPointToView(browser_view_, this, &toolbar_origin);
toolbar_bounds.set_origin(toolbar_origin);
+ int x = toolbar_bounds.x();
+ int w = toolbar_bounds.width();
+ int left_x = x - kContentEdgeShadowThickness;
SkBitmap* theme_toolbar = tp->GetBitmapNamed(IDR_THEME_TOOLBAR);
SkBitmap* toolbar_left = tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER);
SkBitmap* toolbar_center = tp->GetBitmapNamed(IDR_CONTENT_TOP_CENTER);
if (browser_view_->UseVerticalTabs()) {
- gfx::Rect tabstrip_bounds(browser_view_->tabstrip()->bounds());
- gfx::Point tabstrip_origin(tabstrip_bounds.origin());
+ gfx::Point tabstrip_origin(browser_view_->tabstrip()->bounds().origin());
View::ConvertPointToView(browser_view_, this, &tabstrip_origin);
- tabstrip_bounds.set_origin(tabstrip_origin);
-
- int x = tabstrip_bounds.x();
int y = tabstrip_origin.y();
- int w = toolbar_bounds.right() - x;
- canvas->TileImageInt(*theme_toolbar, 0,
- Tab::GetMinimumUnselectedSize().height(),
- MirroredLeftPointForRect(toolbar_bounds), y,
- toolbar_bounds.width(), theme_toolbar->height());
+ // Tile the toolbar image starting at the frame edge on the left and where
+ // the horizontal tabstrip would be on the top.
+ canvas->TileImageInt(*theme_toolbar, x,
+ y - GetHorizontalTabStripVerticalOffset(false), x, y,
+ w, theme_toolbar->height());
// Draw left edge.
int dest_y = y - kNonClientBorderThickness;
canvas->DrawBitmapInt(*toolbar_left, 0, 0, kNonClientBorderThickness,
- kNonClientBorderThickness, x - kNonClientBorderThickness, dest_y,
- kNonClientBorderThickness, kNonClientBorderThickness, false);
+ kNonClientBorderThickness, left_x, dest_y,
+ kNonClientBorderThickness, kNonClientBorderThickness,
+ false);
// Draw center edge. We need to draw a while line above the toolbar for the
// image to overlay nicely.
- canvas->FillRectInt(SK_ColorWHITE, x, y - 1, w, 1);
- canvas->TileImageInt(*toolbar_center, x, dest_y, w,
- toolbar_center->height());
+ int center_offset =
+ -kContentEdgeShadowThickness + kNonClientBorderThickness;
+ canvas->FillRectInt(SK_ColorWHITE, x + center_offset, y - 1,
+ w - (2 * center_offset), 1);
+ canvas->TileImageInt(*toolbar_center, x + center_offset, dest_y,
+ w - (2 * center_offset), toolbar_center->height());
// Right edge.
SkBitmap* toolbar_right = tp->GetBitmapNamed(IDR_CONTENT_TOP_RIGHT_CORNER);
canvas->DrawBitmapInt(*toolbar_right,
toolbar_right->width() - kNonClientBorderThickness, 0,
kNonClientBorderThickness, kNonClientBorderThickness,
- x + w - kNonClientBorderThickness, dest_y, kNonClientBorderThickness,
+ x + w - center_offset, dest_y, kNonClientBorderThickness,
kNonClientBorderThickness, false);
} else {
- // Draw the toolbar background, setting src_y of the paint to the tab
- // strip height as the toolbar background begins at the top of the tabs.
- int x = toolbar_bounds.x() - kClientEdgeThickness;
+ // Tile the toolbar image starting at the frame edge on the left and where
+ // the tabstrip is on the top.
int y = toolbar_bounds.y();
- int src_y = browser_view_->GetTabStripHeight() - 1;
- canvas->TileImageInt(*theme_toolbar, 0, src_y, x,
- y + (kFrameShadowThickness * 2),
- toolbar_bounds.width() + (2 * kClientEdgeThickness),
- theme_toolbar->height());
+ int dest_y = y + (kFrameShadowThickness * 2);
+ canvas->TileImageInt(*theme_toolbar, x,
+ dest_y - GetHorizontalTabStripVerticalOffset(false), x,
+ dest_y, w, theme_toolbar->height());
// Draw rounded corners for the tab.
SkBitmap* toolbar_left_mask =
@@ -304,12 +312,11 @@ void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) {
paint.setXfermodeMode(SkXfermode::kDstIn_Mode);
// Mask out the top left corner.
- int left_x = x - kContentEdgeShadowThickness;
canvas->DrawBitmapInt(*toolbar_left_mask, left_x, y, paint);
// Mask out the top right corner.
- int right_x = toolbar_bounds.right() - toolbar_right_mask->width() +
- kContentEdgeShadowThickness + kClientEdgeThickness;
+ int right_x =
+ x + w + kContentEdgeShadowThickness - toolbar_right_mask->width();
canvas->DrawBitmapInt(*toolbar_right_mask, right_x, y, paint);
// Draw left edge.
@@ -326,33 +333,29 @@ void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) {
// Draw the content/toolbar separator.
canvas->FillRectInt(ResourceBundle::toolbar_separator_color,
- toolbar_bounds.x(), toolbar_bounds.bottom() - kClientEdgeThickness,
- toolbar_bounds.width(), kClientEdgeThickness);
+ x + kClientEdgeThickness, toolbar_bounds.bottom() - kClientEdgeThickness,
+ w - (2 * kClientEdgeThickness), kClientEdgeThickness);
}
void GlassBrowserFrameView::PaintOTRAvatar(gfx::Canvas* canvas) {
+ // In RTL mode, the avatar icon should be looking the opposite direction.
+ canvas->Save();
+ if (base::i18n::IsRTL()) {
+ canvas->TranslateInt(width(), 0);
+ canvas->ScaleInt(-1, 1);
+ }
+
SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon();
- int src_x = 0;
- int src_y = (otr_avatar_icon.height() - otr_avatar_bounds_.height()) / 2;
- int dst_x = MirroredLeftPointForRect(otr_avatar_bounds_);
- int dst_y = otr_avatar_bounds_.y();
int w = otr_avatar_bounds_.width();
int h = otr_avatar_bounds_.height();
- if (browser_view_->UseVerticalTabs()) {
- // Only a portion of the otr icon is visible for vertical tabs. Clip it
- // so that it doesn't overlap shadows.
- gfx::Point tabstrip_origin(browser_view_->tabstrip()->bounds().origin());
- View::ConvertPointToView(frame_->GetWindow()->GetClientView(), this,
- &tabstrip_origin);
- canvas->Save();
- canvas->ClipRectInt(dst_x, 2, w, tabstrip_origin.y() - 4);
- canvas->DrawBitmapInt(otr_avatar_icon, src_x, src_y, w, h, dst_x, dst_y,
- w, h, false);
- canvas->Restore();
- } else {
- canvas->DrawBitmapInt(otr_avatar_icon, src_x, src_y, w, h, dst_x, dst_y,
- w, h, false);
- }
+ canvas->DrawBitmapInt(otr_avatar_icon, 0,
+ // Bias the rounding to select a region that's lower rather than higher,
+ // as the shadows at the image top mean the apparent center is below the
+ // real center.
+ ((otr_avatar_icon.height() - otr_avatar_bounds_.height()) + 1) / 2, w, h,
+ otr_avatar_bounds_.x(), otr_avatar_bounds_.y(), w, h, false);
+
+ canvas->Restore();
}
void GlassBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
@@ -370,23 +373,10 @@ void GlassBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
std::max(client_area_top, height() - NonClientBorderThickness());
int client_area_height = client_area_bottom - client_area_top;
+ // Draw the client edge images.
SkBitmap* right = tp->GetBitmapNamed(IDR_CONTENT_RIGHT_SIDE);
canvas->TileImageInt(*right, client_area_bounds.right(), client_area_top,
right->width(), client_area_height);
-
- // Draw the toolbar color so that the client edges show the right color even
- // where not covered by the toolbar image.
- SkColor toolbar_color = tp->GetColor(BrowserThemeProvider::COLOR_TOOLBAR);
- canvas->FillRectInt(toolbar_color,
- client_area_bounds.x() - kClientEdgeThickness, client_area_top,
- kClientEdgeThickness,
- client_area_bottom + kClientEdgeThickness - client_area_top);
- canvas->FillRectInt(toolbar_color, client_area_bounds.x(), client_area_bottom,
- client_area_bounds.width(), kClientEdgeThickness);
- canvas->FillRectInt(toolbar_color, client_area_bounds.right(),
- client_area_top, kClientEdgeThickness,
- client_area_bottom + kClientEdgeThickness - client_area_top);
-
canvas->DrawBitmapInt(
*tp->GetBitmapNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER),
client_area_bounds.right(), client_area_bottom);
@@ -401,6 +391,21 @@ void GlassBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
SkBitmap* left = tp->GetBitmapNamed(IDR_CONTENT_LEFT_SIDE);
canvas->TileImageInt(*left, client_area_bounds.x() - left->width(),
client_area_top, left->width(), client_area_height);
+
+ // Draw the toolbar color so that the client edges show the right color even
+ // where not covered by the toolbar image. NOTE: We do this after drawing the
+ // images because the images are meant to alpha-blend atop the frame whereas
+ // these rects are meant to be fully opaque, without anything overlaid.
+ SkColor toolbar_color = tp->GetColor(BrowserThemeProvider::COLOR_TOOLBAR);
+ canvas->FillRectInt(toolbar_color,
+ client_area_bounds.x() - kClientEdgeThickness, client_area_top,
+ kClientEdgeThickness,
+ client_area_bottom + kClientEdgeThickness - client_area_top);
+ canvas->FillRectInt(toolbar_color, client_area_bounds.x(), client_area_bottom,
+ client_area_bounds.width(), kClientEdgeThickness);
+ canvas->FillRectInt(toolbar_color, client_area_bounds.right(),
+ client_area_top, kClientEdgeThickness,
+ client_area_bottom + kClientEdgeThickness - client_area_top);
}
void GlassBrowserFrameView::LayoutOTRAvatar() {
@@ -413,20 +418,20 @@ void GlassBrowserFrameView::LayoutOTRAvatar() {
otr_x += width() - frame_->GetMinimizeButtonOffset();
SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon();
- int otr_height = browser_view_->IsTabStripVisible() ?
- otr_avatar_icon.height() : 0;
- int otr_y = 0;
+ int otr_bottom, otr_restored_y;
if (browser_view_->UseVerticalTabs()) {
- otr_y = NonClientTopBorderHeight() - otr_avatar_icon.height();
- } else if (browser_view_->IsTabStripVisible()) {
- int top_height = NonClientTopBorderHeight();
- int tabstrip_height =
+ otr_bottom = NonClientTopBorderHeight(false, false) - kOTRBottomSpacing;
+ otr_restored_y = kFrameShadowThickness;
+ } else {
+ otr_bottom = GetHorizontalTabStripVerticalOffset(false) +
browser_view_->GetTabStripHeight() - kOTRBottomSpacing;
- otr_height = frame_->GetWindow()->IsMaximized() ?
- (tabstrip_height - kOTRMaximizedTopSpacing) : otr_avatar_icon.height();
- otr_y = top_height + tabstrip_height - otr_height;
+ otr_restored_y = otr_bottom - otr_avatar_icon.height();
}
- otr_avatar_bounds_.SetRect(otr_x, otr_y, otr_avatar_icon.width(), otr_height);
+ int otr_y = frame_->GetWindow()->IsMaximized() ?
+ (NonClientTopBorderHeight(false, true) + kTabstripTopShadowThickness) :
+ otr_restored_y;
+ otr_avatar_bounds_.SetRect(otr_x, otr_y, otr_avatar_icon.width(),
+ browser_view_->ShouldShowOffTheRecordAvatar() ? (otr_bottom - otr_y) : 0);
}
void GlassBrowserFrameView::LayoutClientView() {
@@ -438,7 +443,7 @@ gfx::Rect GlassBrowserFrameView::CalculateClientAreaBounds(int width,
if (!browser_view_->IsTabStripVisible())
return gfx::Rect(0, 0, this->width(), this->height());
- int top_height = NonClientTopBorderHeight();
+ int top_height = NonClientTopBorderHeight(false, false);
int border_thickness = NonClientBorderThickness();
return gfx::Rect(border_thickness, top_height,
std::max(0, width - (2 * border_thickness)),
diff --git a/chrome/browser/views/frame/glass_browser_frame_view.h b/chrome/browser/views/frame/glass_browser_frame_view.h
index 363e73f..0a39da1 100644
--- a/chrome/browser/views/frame/glass_browser_frame_view.h
+++ b/chrome/browser/views/frame/glass_browser_frame_view.h
@@ -22,6 +22,7 @@ class GlassBrowserFrameView : public BrowserNonClientFrameView {
// Overridden from BrowserNonClientFrameView:
virtual gfx::Rect GetBoundsForTabStrip(BaseTabStrip* tabstrip) const;
+ virtual int GetHorizontalTabStripVerticalOffset(bool restored) const;
virtual void UpdateThrobber(bool running);
// Overridden from views::NonClientFrameView:
@@ -49,8 +50,11 @@ class GlassBrowserFrameView : public BrowserNonClientFrameView {
int NonClientBorderThickness() const;
// Returns the height of the entire nonclient top border, including the window
- // frame, any title area, and any connected client edge.
- int NonClientTopBorderHeight() const;
+ // frame, any title area, and any connected client edge. If |restored| is
+ // true, acts as if the window is restored regardless of the real mode. If
+ // |ignore_vertical_tabs| is true, acts as if vertical tabs are off regardless
+ // of the real state.
+ int NonClientTopBorderHeight(bool restored, bool ignore_vertical_tabs) const;
// Paint various sub-components of this view.
void PaintToolbarBackground(gfx::Canvas* canvas);
@@ -71,9 +75,6 @@ class GlassBrowserFrameView : public BrowserNonClientFrameView {
// Displays the next throbber frame.
void DisplayNextThrobberFrame();
- // The layout rect of the distributor logo, if visible.
- gfx::Rect logo_bounds_;
-
// The layout rect of the OTR avatar icon, if visible.
gfx::Rect otr_avatar_bounds_;
diff --git a/chrome/browser/views/frame/opaque_browser_frame_view.cc b/chrome/browser/views/frame/opaque_browser_frame_view.cc
index 80c2c0b..514a8c7 100644
--- a/chrome/browser/views/frame/opaque_browser_frame_view.cc
+++ b/chrome/browser/views/frame/opaque_browser_frame_view.cc
@@ -32,10 +32,6 @@
#include "views/window/hit_test.h"
#endif
-#if defined(OS_CHROMEOS)
-const int kCustomFrameBackgroundVerticalOffset = 15;
-#endif
-
namespace {
// The frame border is only visible in restored mode and is hardcoded to 4 px on
// each side regardless of the system window border size.
@@ -67,9 +63,6 @@ const int kIconMinimumSize = 16;
const int kIconTitleSpacing = 4;
// There is a 5 px gap between the title text and the caption buttons.
const int kTitleLogoSpacing = 5;
-// In maximized mode, the OTR avatar starts 2 px below the top of the screen, so
-// that it doesn't extend into the "3D edge" portion of the titlebar.
-const int kOTRMaximizedTopSpacing = 2;
// The OTR avatar ends 2 px above the bottom of the tabstrip (which, given the
// way the tabstrip draws its bottom edge, will appear like a 1 px gap to the
// user).
@@ -91,8 +84,6 @@ const int kNewTabCaptionMaximizedSpacing = 16;
// How far to indent the tabstrip from the left side of the screen when there
// is no OTR icon.
const int kTabStripIndent = 1;
-// Padding between the caption and start of vertical tabs.
-const int kVerticalTabPadding = 6;
// Inset from the top of the toolbar/tabstrip to the shadow. Used only for
// vertical tabs.
const int kVerticalTabBorderInset = 3;
@@ -104,7 +95,6 @@ const int kVerticalTabBorderInset = 3;
OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame,
BrowserView* browser_view)
: BrowserNonClientFrameView(),
- otr_avatar_icon_(new views::ImageView()),
ALLOW_THIS_IN_INITIALIZER_LIST(
minimize_button_(new views::ImageButton(this))),
ALLOW_THIS_IN_INITIALIZER_LIST(
@@ -174,8 +164,6 @@ OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame,
close_button_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_CLOSE));
AddChildView(close_button_);
- otr_avatar_icon_->SetImage(browser_view_->GetOTRAvatarIcon());
- AddChildView(otr_avatar_icon_);
// Initializing the TabIconView is expensive, so only do it if we need to.
if (browser_view_->ShouldShowWindowIcon()) {
window_icon_ = new TabIconView(this);
@@ -195,26 +183,30 @@ gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip(
BaseTabStrip* tabstrip) const {
if (browser_view_->UseVerticalTabs()) {
gfx::Size ps = tabstrip->GetPreferredSize();
- return gfx::Rect(NonClientBorderThickness(), NonClientTopBorderHeight(),
- ps.width(), browser_view_->height());
+ return gfx::Rect(NonClientBorderThickness(),
+ NonClientTopBorderHeight(false, false), ps.width(),
+ browser_view_->height());
}
- int tabstrip_y = NonClientTopBorderHeight();
- if (!frame_->GetWindow()->IsMaximized() &&
- !frame_->GetWindow()->IsFullscreen())
- tabstrip_y += kNonClientRestoredExtraThickness;
-
int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ?
- (otr_avatar_icon_->bounds().right() + kOTRSideSpacing) :
+ (otr_avatar_bounds_.right() + kOTRSideSpacing) :
NonClientBorderThickness() + kTabStripIndent;
int tabstrip_width = minimize_button_->x() - tabstrip_x -
(frame_->GetWindow()->IsMaximized() ?
kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing);
- return gfx::Rect(tabstrip_x, tabstrip_y,
+ return gfx::Rect(tabstrip_x, GetHorizontalTabStripVerticalOffset(false),
std::max(0, tabstrip_width), tabstrip->GetPreferredHeight());
}
+int OpaqueBrowserFrameView::GetHorizontalTabStripVerticalOffset(
+ bool restored) const {
+ return NonClientTopBorderHeight(restored, true) + ((!restored &&
+ (frame_->GetWindow()->IsMaximized() ||
+ frame_->GetWindow()->IsFullscreen())) ?
+ 0 : kNonClientRestoredExtraThickness);
+}
+
void OpaqueBrowserFrameView::UpdateThrobber(bool running) {
if (window_icon_)
window_icon_->Update();
@@ -224,10 +216,11 @@ gfx::Size OpaqueBrowserFrameView::GetMinimumSize() {
gfx::Size min_size(browser_view_->GetMinimumSize());
int border_thickness = NonClientBorderThickness();
min_size.Enlarge(2 * border_thickness,
- NonClientTopBorderHeight() + border_thickness);
+ NonClientTopBorderHeight(false, false) + border_thickness);
views::WindowDelegate* d = frame_->GetWindow()->GetDelegate();
- int min_titlebar_width = (2 * FrameBorderThickness()) + kIconLeftSpacing +
+ int min_titlebar_width = (2 * FrameBorderThickness(false)) +
+ kIconLeftSpacing +
(d->ShouldShowWindowIcon() ? (IconSize() + kTitleLogoSpacing) : 0);
#if !defined(OS_CHROMEOS)
min_titlebar_width +=
@@ -256,7 +249,7 @@ bool OpaqueBrowserFrameView::AlwaysUseCustomFrame() const {
gfx::Rect OpaqueBrowserFrameView::GetWindowBoundsForClientBounds(
const gfx::Rect& client_bounds) const {
- int top_height = NonClientTopBorderHeight();
+ int top_height = NonClientTopBorderHeight(false, false);
int border_thickness = NonClientBorderThickness();
return gfx::Rect(std::max(0, client_bounds.x() - border_thickness),
std::max(0, client_bounds.y() - top_height),
@@ -345,34 +338,12 @@ void OpaqueBrowserFrameView::Paint(gfx::Canvas* canvas) {
PaintTitleBar(canvas);
if (browser_view_->IsToolbarVisible())
PaintToolbarBackground(canvas);
+ if (browser_view_->ShouldShowOffTheRecordAvatar())
+ PaintOTRAvatar(canvas);
if (!window->IsMaximized())
PaintRestoredClientEdge(canvas);
}
-void OpaqueBrowserFrameView::PaintChildren(gfx::Canvas* canvas) {
- if (!browser_view_->UseVerticalTabs() || !otr_avatar_icon_->IsVisible()) {
- View::PaintChildren(canvas);
- return;
- }
-
- // The otr icon is clipped for side tabs.
- for (int i = 0, count = GetChildViewCount(); i < count; ++i) {
- View* child = GetChildViewAt(i);
- if (!child) {
- NOTREACHED() << "Should not have a NULL child View for index in bounds";
- continue;
- }
- if (child == otr_avatar_icon_) {
- canvas->Save();
- canvas->ClipRectInt(0, 2, width(), otr_avatar_icon_->height() - 10);
- child->ProcessPaint(canvas);
- canvas->Restore();
- } else {
- child->ProcessPaint(canvas);
- }
- }
-}
-
void OpaqueBrowserFrameView::Layout() {
LayoutWindowControls();
LayoutTitleBar();
@@ -447,56 +418,52 @@ SkBitmap OpaqueBrowserFrameView::GetFavIconForTabIconView() {
///////////////////////////////////////////////////////////////////////////////
// OpaqueBrowserFrameView, private:
-int OpaqueBrowserFrameView::FrameBorderThickness() const {
+int OpaqueBrowserFrameView::FrameBorderThickness(bool restored) const {
views::Window* window = frame_->GetWindow();
- return (window->IsMaximized() || window->IsFullscreen()) ?
+ return (!restored && (window->IsMaximized() || window->IsFullscreen())) ?
0 : kFrameBorderThickness;
}
int OpaqueBrowserFrameView::TopResizeHeight() const {
- return FrameBorderThickness() - kTopResizeAdjust;
+ return FrameBorderThickness(false) - kTopResizeAdjust;
}
int OpaqueBrowserFrameView::NonClientBorderThickness() const {
// When we fill the screen, we don't show a client edge.
views::Window* window = frame_->GetWindow();
- return FrameBorderThickness() +
+ return FrameBorderThickness(false) +
((window->IsMaximized() || window->IsFullscreen()) ?
0 : kClientEdgeThickness);
}
-int OpaqueBrowserFrameView::NonClientTopBorderHeight() const {
+int OpaqueBrowserFrameView::NonClientTopBorderHeight(
+ bool restored,
+ bool ignore_vertical_tabs) const {
views::Window* window = frame_->GetWindow();
- if (window->GetDelegate()->ShouldShowWindowTitle()) {
- return std::max(FrameBorderThickness() + IconSize(),
- CaptionButtonY() + kCaptionButtonHeightWithPadding) +
- TitlebarBottomThickness();
- }
-
- if (browser_view_->IsTabStripVisible() && browser_view_->UseVerticalTabs()) {
- return CaptionButtonY() + minimize_button_->GetPreferredSize().height() +
- kVerticalTabPadding;
+ if (window->GetDelegate()->ShouldShowWindowTitle() ||
+ (browser_view_->IsTabStripVisible() && !ignore_vertical_tabs &&
+ browser_view_->UseVerticalTabs())) {
+ return std::max(FrameBorderThickness(restored) + IconSize(),
+ CaptionButtonY(restored) + kCaptionButtonHeightWithPadding) +
+ TitlebarBottomThickness(restored);
}
- return FrameBorderThickness() -
- ((browser_view_->IsTabStripVisible() && window->IsMaximized()) ?
- kTabstripTopShadowThickness : 0);
+ return FrameBorderThickness(restored) -
+ ((browser_view_->IsTabStripVisible() && !restored &&
+ window->IsMaximized()) ? kTabstripTopShadowThickness : 0);
}
-int OpaqueBrowserFrameView::CaptionButtonY() const {
+int OpaqueBrowserFrameView::CaptionButtonY(bool restored) const {
// Maximized buttons start at window top so that even if their images aren't
// drawn flush with the screen edge, they still obey Fitts' Law.
- return frame_->GetWindow()->IsMaximized() ?
- FrameBorderThickness() : kFrameShadowThickness;
+ return (!restored && frame_->GetWindow()->IsMaximized()) ?
+ FrameBorderThickness(false) : kFrameShadowThickness;
}
-int OpaqueBrowserFrameView::TitlebarBottomThickness() const {
- // When a toolbar is edging the titlebar, it draws its own bottom edge.
- if (browser_view_->IsToolbarVisible())
- return 0;
-
+int OpaqueBrowserFrameView::TitlebarBottomThickness(bool restored) const {
return kTitlebarTopAndBottomEdgeThickness +
- (frame_->GetWindow()->IsMaximized() ? 0 : kClientEdgeThickness);
+ ((!restored && frame_->GetWindow()->IsMaximized()) ?
+ 0 : kClientEdgeThickness);
}
int OpaqueBrowserFrameView::IconSize() const {
@@ -511,7 +478,7 @@ int OpaqueBrowserFrameView::IconSize() const {
gfx::Rect OpaqueBrowserFrameView::IconBounds() const {
int size = IconSize();
- int frame_thickness = FrameBorderThickness();
+ int frame_thickness = FrameBorderThickness(false);
int y;
views::WindowDelegate* d = frame_->GetWindow()->GetDelegate();
if (d->ShouldShowWindowIcon() || d->ShouldShowWindowTitle()) {
@@ -531,8 +498,8 @@ gfx::Rect OpaqueBrowserFrameView::IconBounds() const {
// restored windows) below looks (to the eye) more like additional space
// than does the 3D edge (or nothing at all, for maximized windows) above;
// hence the +1.
- y = unavailable_px_at_top + (NonClientTopBorderHeight() -
- unavailable_px_at_top - size - TitlebarBottomThickness() + 1) / 2;
+ y = unavailable_px_at_top + (NonClientTopBorderHeight(false, false) -
+ unavailable_px_at_top - size - TitlebarBottomThickness(false) + 1) / 2;
} else {
// For "browser mode" windows, we use the native positioning, which is just
// below the top frame border.
@@ -665,7 +632,6 @@ void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) {
// Window frame mode and color
SkBitmap* theme_frame;
- int y = 0;
// Never theme app and popup windows.
if (!browser_view_->IsBrowserTypeNormal()) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
@@ -674,30 +640,24 @@ void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) {
} else if (!browser_view_->IsOffTheRecord()) {
theme_frame = tp->GetBitmapNamed(ShouldPaintAsActive() ?
IDR_THEME_FRAME : IDR_THEME_FRAME_INACTIVE);
-#if defined(OS_CHROMEOS)
- // TODO:(oshima): gtk based CHROMEOS is using non custom frame
- // mode which does this adjustment. This should be removed
- // once it's fully migrated to views. -1 is due to the layout
- // difference between views and gtk and will be removed.
- // See http://crbug.com/28580.
- y = -kCustomFrameBackgroundVerticalOffset - 1;
-#endif
} else {
theme_frame = tp->GetBitmapNamed(ShouldPaintAsActive() ?
IDR_THEME_FRAME_INCOGNITO : IDR_THEME_FRAME_INCOGNITO_INACTIVE);
-#if defined(OS_CHROMEOS)
- y = -kCustomFrameBackgroundVerticalOffset - 1;
-#endif
}
- // Draw the theme frame.
- canvas->TileImageInt(*theme_frame, 0, y, width(), theme_frame->height());
+ // Draw the theme frame. It must be aligned with the tabstrip as if we were
+ // in restored mode. Note that the top of the tabstrip is
+ // kTabstripTopShadowThickness px off the top of the screen.
+ int theme_background_y = -(GetHorizontalTabStripVerticalOffset(true) +
+ kTabstripTopShadowThickness);
+ canvas->TileImageInt(*theme_frame, 0, theme_background_y, width(),
+ theme_frame->height());
// Draw the theme frame overlay
if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) &&
browser_view_->IsBrowserTypeNormal()) {
SkBitmap* theme_overlay = tp->GetBitmapNamed(ShouldPaintAsActive() ?
IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE);
- canvas->DrawBitmapInt(*theme_overlay, 0, 0);
+ canvas->DrawBitmapInt(*theme_overlay, 0, theme_background_y);
}
if (!browser_view_->IsToolbarVisible()) {
@@ -729,20 +689,22 @@ void OpaqueBrowserFrameView::PaintTitleBar(gfx::Canvas* canvas) {
}
void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) {
- gfx::Rect toolbar_bounds = GetViewBounds(browser_view_->toolbar(), this);
+ gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds());
if (toolbar_bounds.IsEmpty())
return;
+ gfx::Point toolbar_origin(toolbar_bounds.origin());
+ ConvertPointToView(browser_view_, this, &toolbar_origin);
+ toolbar_bounds.set_origin(toolbar_origin);
- int x, y, w, h;
+ int x = toolbar_bounds.x();
+ int w = toolbar_bounds.width();
+ int y, h;
if (browser_view_->UseVerticalTabs()) {
- gfx::Rect tabstrip_bounds = GetViewBounds(browser_view_->tabstrip(), this);
- x = tabstrip_bounds.x();
- w = toolbar_bounds.right() - x;
- y = tabstrip_bounds.y() - kVerticalTabBorderInset;
+ gfx::Point tabstrip_origin(browser_view_->tabstrip()->bounds().origin());
+ ConvertPointToView(browser_view_, this, &tabstrip_origin);
+ y = tabstrip_origin.y() - kVerticalTabBorderInset;
h = toolbar_bounds.bottom() - y;
} else {
- x = toolbar_bounds.x();
- w = toolbar_bounds.width();
y = toolbar_bounds.y();
h = toolbar_bounds.bottom();
}
@@ -768,11 +730,12 @@ void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) {
tp->GetColor(BrowserThemeProvider::COLOR_TOOLBAR);
canvas->FillRectInt(theme_toolbar_color, x, bottom_y, w, bottom_edge_height);
+ // Tile the toolbar image starting at the frame edge on the left and where the
+ // horizontal tabstrip is (or would be) on the top.
SkBitmap* theme_toolbar = tp->GetBitmapNamed(IDR_THEME_TOOLBAR);
- int strip_height = browser_view_->GetTabStripHeight();
- canvas->TileImageInt(*theme_toolbar, x - kClientEdgeThickness,
- strip_height - kFrameShadowThickness, x - kClientEdgeThickness, bottom_y,
- w + (2 * kClientEdgeThickness), theme_toolbar->height());
+ canvas->TileImageInt(*theme_toolbar, x,
+ bottom_y - GetHorizontalTabStripVerticalOffset(false), x,
+ bottom_y, w, theme_toolbar->height());
// Draw rounded corners for the tab.
SkBitmap* toolbar_left_mask =
@@ -797,8 +760,8 @@ void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) {
toolbar_left_mask->width(), bottom_edge_height, false, paint);
// Mask the right edge.
- int right_x = x + w - toolbar_right_mask->width() + kClientEdgeThickness +
- kContentEdgeShadowThickness;
+ int right_x =
+ x + w - toolbar_right_mask->width() + kContentEdgeShadowThickness;
canvas->DrawBitmapInt(*toolbar_right_mask, 0, 0, toolbar_right_mask->width(),
split_point, right_x, y, toolbar_right_mask->width(),
split_point, false, paint);
@@ -831,26 +794,52 @@ void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) {
// Draw the content/toolbar separator.
canvas->FillRectInt(ResourceBundle::toolbar_separator_color,
- toolbar_bounds.x(), toolbar_bounds.bottom() - kClientEdgeThickness,
- toolbar_bounds.width(), kClientEdgeThickness);
+ x + kClientEdgeThickness, toolbar_bounds.bottom() - kClientEdgeThickness,
+ w - (2 * kClientEdgeThickness), kClientEdgeThickness);
+}
+
+void OpaqueBrowserFrameView::PaintOTRAvatar(gfx::Canvas* canvas) {
+ // In RTL mode, the avatar icon should be looking the opposite direction.
+ canvas->Save();
+ if (base::i18n::IsRTL()) {
+ canvas->TranslateInt(width(), 0);
+ canvas->ScaleInt(-1, 1);
+ }
+
+ SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon();
+ int w = otr_avatar_bounds_.width();
+ int h = otr_avatar_bounds_.height();
+ canvas->DrawBitmapInt(otr_avatar_icon, 0,
+ // Bias the rounding to select a region that's lower rather than higher,
+ // as the shadows at the image top mean the apparent center is below the
+ // real center.
+ ((otr_avatar_icon.height() - otr_avatar_bounds_.height()) + 1) / 2, w, h,
+ otr_avatar_bounds_.x(), otr_avatar_bounds_.y(), w, h, false);
+
+ canvas->Restore();
}
void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
ThemeProvider* tp = GetThemeProvider();
int client_area_top = frame_->GetWindow()->GetClientView()->y();
+ int image_top = client_area_top;
gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height());
SkColor toolbar_color = tp->GetColor(BrowserThemeProvider::COLOR_TOOLBAR);
if (browser_view_->IsToolbarVisible()) {
- // The client edges start below the toolbar or its corner images, whichever
- // is shorter.
+ // The client edge images always start below the toolbar corner images. The
+ // client edge filled rects start there or at the bottom of the tooolbar,
+ // whichever is shorter.
gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds());
- client_area_top += browser_view_->GetToolbarBounds().y() +
- std::min(tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height(),
- toolbar_bounds.height());
- if (browser_view_->UseVerticalTabs())
+ image_top += toolbar_bounds.y() +
+ tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height();
+ client_area_top = std::min(image_top,
+ client_area_top + toolbar_bounds.bottom() - kClientEdgeThickness);
+ if (browser_view_->UseVerticalTabs()) {
client_area_top -= kVerticalTabBorderInset;
+ image_top -= kVerticalTabBorderInset;
+ }
} else if (!browser_view_->IsTabStripVisible()) {
// The toolbar isn't going to draw a client edge for us, so draw one
// ourselves.
@@ -879,24 +868,13 @@ void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
int client_area_bottom =
std::max(client_area_top, height() - NonClientBorderThickness());
- int client_area_height = client_area_bottom - client_area_top;
-
- // Draw the toolbar color so that the client edges show the right color even
- // where not covered by the toolbar image.
- canvas->FillRectInt(toolbar_color,
- client_area_bounds.x() - kClientEdgeThickness, client_area_top,
- kClientEdgeThickness,
- client_area_bottom + kClientEdgeThickness - client_area_top);
- canvas->FillRectInt(toolbar_color, client_area_bounds.x(), client_area_bottom,
- client_area_bounds.width(), kClientEdgeThickness);
- canvas->FillRectInt(toolbar_color, client_area_bounds.right(),
- client_area_top, kClientEdgeThickness,
- client_area_bottom + kClientEdgeThickness - client_area_top);
+ int image_height = client_area_bottom - image_top;
// Draw the client edge images.
+ // Draw the client edge images.
SkBitmap* right = tp->GetBitmapNamed(IDR_CONTENT_RIGHT_SIDE);
- canvas->TileImageInt(*right, client_area_bounds.right(), client_area_top,
- right->width(), client_area_height);
+ canvas->TileImageInt(*right, client_area_bounds.right(), image_top,
+ right->width(), image_height);
canvas->DrawBitmapInt(
*tp->GetBitmapNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER),
client_area_bounds.right(), client_area_bottom);
@@ -910,21 +888,35 @@ void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
client_area_bounds.x() - bottom_left->width(), client_area_bottom);
SkBitmap* left = tp->GetBitmapNamed(IDR_CONTENT_LEFT_SIDE);
canvas->TileImageInt(*left, client_area_bounds.x() - left->width(),
- client_area_top, left->width(), client_area_height);
+ image_top, left->width(), image_height);
+
+ // Draw the toolbar color so that the client edges show the right color even
+ // where not covered by the toolbar image. NOTE: We do this after drawing the
+ // images because the images are meant to alpha-blend atop the frame whereas
+ // these rects are meant to be fully opaque, without anything overlaid.
+ canvas->FillRectInt(toolbar_color,
+ client_area_bounds.x() - kClientEdgeThickness, client_area_top,
+ kClientEdgeThickness,
+ client_area_bottom + kClientEdgeThickness - client_area_top);
+ canvas->FillRectInt(toolbar_color, client_area_bounds.x(), client_area_bottom,
+ client_area_bounds.width(), kClientEdgeThickness);
+ canvas->FillRectInt(toolbar_color, client_area_bounds.right(),
+ client_area_top, kClientEdgeThickness,
+ client_area_bottom + kClientEdgeThickness - client_area_top);
}
void OpaqueBrowserFrameView::LayoutWindowControls() {
bool is_maximized = frame_->GetWindow()->IsMaximized();
close_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT,
views::ImageButton::ALIGN_BOTTOM);
- int caption_y = CaptionButtonY();
+ int caption_y = CaptionButtonY(false);
// There should always be the same number of non-shadow pixels visible to the
// side of the caption buttons. In maximized mode we extend the rightmost
// button to the screen corner to obey Fitts' Law.
int right_extra_width = is_maximized ?
(kFrameBorderThickness - kFrameShadowThickness) : 0;
gfx::Size close_button_size = close_button_->GetPreferredSize();
- close_button_->SetBounds(width() - FrameBorderThickness() -
+ close_button_->SetBounds(width() - FrameBorderThickness(false) -
right_extra_width - close_button_size.width(), caption_y,
close_button_size.width() + right_extra_width,
close_button_size.height());
@@ -944,9 +936,8 @@ void OpaqueBrowserFrameView::LayoutWindowControls() {
// other places that rely on the bounds. Put it slightly to the right
// of the edge of the view, so that when we remove the spacing it lines
// up with the edge.
- minimize_button_->SetBounds(
- width() - FrameBorderThickness() + kNewTabCaptionMaximizedSpacing,
- 0, 0, 0);
+ minimize_button_->SetBounds(width() - FrameBorderThickness(false) +
+ kNewTabCaptionMaximizedSpacing, 0, 0, 0);
}
return;
@@ -1008,50 +999,29 @@ void OpaqueBrowserFrameView::LayoutTitleBar() {
}
void OpaqueBrowserFrameView::LayoutOTRAvatar() {
- int otr_y = NonClientTopBorderHeight();
- if (!frame_->GetWindow()->IsMaximized() &&
- !frame_->GetWindow()->IsFullscreen()) {
- otr_y += kNonClientRestoredExtraThickness;
- }
- bool visible = browser_view_->ShouldShowOffTheRecordAvatar();
- gfx::Size preferred_size = otr_avatar_icon_->GetPreferredSize();
- int otr_height = 0;
- if (browser_view_->IsTabStripVisible()) {
- if (browser_view_->UseVerticalTabs()) {
- otr_height = preferred_size.height();
- otr_y = -2;
- } else {
- int tabstrip_height =
- browser_view_->GetTabStripHeight() - kOTRBottomSpacing;
- otr_height = frame_->GetWindow()->IsMaximized() ?
- (tabstrip_height - kOTRMaximizedTopSpacing) :
- preferred_size.height();
- otr_y += tabstrip_height - otr_height;
- }
+ SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon();
+ int otr_bottom, otr_restored_y;
+ if (browser_view_->UseVerticalTabs()) {
+ otr_bottom = NonClientTopBorderHeight(false, false) - kOTRBottomSpacing;
+ otr_restored_y = kFrameShadowThickness;
} else {
- visible = false;
+ otr_bottom = GetHorizontalTabStripVerticalOffset(false) +
+ browser_view_->GetTabStripHeight() - kOTRBottomSpacing;
+ otr_restored_y = otr_bottom - otr_avatar_icon.height();
}
- otr_avatar_icon_->SetVisible(visible);
- otr_avatar_icon_->SetBounds(NonClientBorderThickness() + kOTRSideSpacing,
- otr_y, preferred_size.width(), otr_height);
+ int otr_y = frame_->GetWindow()->IsMaximized() ?
+ (NonClientTopBorderHeight(false, true) + kTabstripTopShadowThickness) :
+ otr_restored_y;
+ otr_avatar_bounds_.SetRect(NonClientBorderThickness() + kOTRSideSpacing,
+ otr_y, otr_avatar_icon.width(),
+ browser_view_->ShouldShowOffTheRecordAvatar() ? (otr_bottom - otr_y) : 0);
}
gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width,
int height) const {
- int top_height = NonClientTopBorderHeight();
+ int top_height = NonClientTopBorderHeight(false, false);
int border_thickness = NonClientBorderThickness();
return gfx::Rect(border_thickness, top_height,
std::max(0, width - (2 * border_thickness)),
std::max(0, height - top_height - border_thickness));
}
-
-// static
-gfx::Rect OpaqueBrowserFrameView::GetViewBounds(views::View* src,
- views::View* dst) {
- gfx::Rect bounds(src->bounds());
-
- gfx::Point origin_in_dst(bounds.origin());
- View::ConvertPointToView(src->GetParent(), dst, &origin_in_dst);
- bounds.set_origin(origin_in_dst);
- return bounds;
-}
diff --git a/chrome/browser/views/frame/opaque_browser_frame_view.h b/chrome/browser/views/frame/opaque_browser_frame_view.h
index a2e6543..452c14e 100644
--- a/chrome/browser/views/frame/opaque_browser_frame_view.h
+++ b/chrome/browser/views/frame/opaque_browser_frame_view.h
@@ -33,6 +33,7 @@ class OpaqueBrowserFrameView : public BrowserNonClientFrameView,
// Overridden from BrowserNonClientFrameView:
virtual gfx::Rect GetBoundsForTabStrip(BaseTabStrip* tabstrip) const;
+ virtual int GetHorizontalTabStripVerticalOffset(bool restored) const;
virtual void UpdateThrobber(bool running);
virtual gfx::Size GetMinimumSize();
@@ -50,7 +51,6 @@ class OpaqueBrowserFrameView : public BrowserNonClientFrameView,
// Overridden from views::View:
virtual void Paint(gfx::Canvas* canvas);
- virtual void PaintChildren(gfx::Canvas* canvas);
virtual void Layout();
virtual bool HitTest(const gfx::Point& l) const;
virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
@@ -64,8 +64,9 @@ class OpaqueBrowserFrameView : public BrowserNonClientFrameView,
private:
// Returns the thickness of the border that makes up the window frame edges.
- // This does not include any client edge.
- int FrameBorderThickness() const;
+ // This does not include any client edge. If |restored| is true, acts as if
+ // the window is restored regardless of the real mode.
+ int FrameBorderThickness(bool restored) const;
// Returns the height of the top resize area. This is smaller than the frame
// border height in order to increase the window draggable area.
@@ -76,15 +77,20 @@ class OpaqueBrowserFrameView : public BrowserNonClientFrameView,
int NonClientBorderThickness() const;
// Returns the height of the entire nonclient top border, including the window
- // frame, any title area, and any connected client edge.
- int NonClientTopBorderHeight() const;
+ // frame, any title area, and any connected client edge. If |restored| is
+ // true, acts as if the window is restored regardless of the real mode. If
+ // |ignore_vertical_tabs| is true, acts as if vertical tabs are off regardless
+ // of the real state.
+ int NonClientTopBorderHeight(bool restored, bool ignore_vertical_tabs) const;
- // Returns the y-coordinate of the caption buttons.
- int CaptionButtonY() const;
+ // Returns the y-coordinate of the caption buttons. If |restored| is true,
+ // acts as if the window is restored regardless of the real mode.
+ int CaptionButtonY(bool restored) const;
- // Returns the thickness of the nonclient portion of the 3D edge along the
- // bottom of the titlebar.
- int TitlebarBottomThickness() const;
+ // Returns the thickness of the 3D edge along the bottom of the titlebar. If
+ // |restored| is true, acts as if the window is restored regardless of the
+ // real mode.
+ int TitlebarBottomThickness(bool restored) const;
// Returns the size of the titlebar icon. This is used even when the icon is
// not shown, e.g. to set the titlebar height.
@@ -101,6 +107,7 @@ class OpaqueBrowserFrameView : public BrowserNonClientFrameView,
void PaintMaximizedFrameBorder(gfx::Canvas* canvas);
void PaintTitleBar(gfx::Canvas* canvas);
void PaintToolbarBackground(gfx::Canvas* canvas);
+ void PaintOTRAvatar(gfx::Canvas* canvas);
void PaintRestoredClientEdge(gfx::Canvas* canvas);
// Layout various sub-components of this view.
@@ -111,15 +118,11 @@ class OpaqueBrowserFrameView : public BrowserNonClientFrameView,
// Returns the bounds of the client area for the specified view size.
gfx::Rect CalculateClientAreaBounds(int width, int height) const;
- // Returns the bounds of |src| in the coordinate system of |dst|.
- // TODO(sky): promote this to view.
- static gfx::Rect GetViewBounds(views::View* src, views::View* dst);
-
// The layout rect of the title, if visible.
gfx::Rect title_bounds_;
- // Off the record avatar icon.
- views::ImageView* otr_avatar_icon_;
+ // The layout rect of the OTR avatar icon, if visible.
+ gfx::Rect otr_avatar_bounds_;
// Window controls.
views::ImageButton* minimize_button_;
diff --git a/chrome/browser/views/frame/popup_non_client_frame_view.cc b/chrome/browser/views/frame/popup_non_client_frame_view.cc
index 5d16079..d3b4d96 100644
--- a/chrome/browser/views/frame/popup_non_client_frame_view.cc
+++ b/chrome/browser/views/frame/popup_non_client_frame_view.cc
@@ -50,5 +50,10 @@ gfx::Rect PopupNonClientFrameView::GetBoundsForTabStrip(
return gfx::Rect(0, 0, width(), tabstrip->GetPreferredHeight());
}
+int PopupNonClientFrameView::GetHorizontalTabStripVerticalOffset(
+ bool restored) const {
+ return 0;
+}
+
void PopupNonClientFrameView::UpdateThrobber(bool running) {
}
diff --git a/chrome/browser/views/frame/popup_non_client_frame_view.h b/chrome/browser/views/frame/popup_non_client_frame_view.h
index e403bf3..12982c9 100644
--- a/chrome/browser/views/frame/popup_non_client_frame_view.h
+++ b/chrome/browser/views/frame/popup_non_client_frame_view.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// 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.
@@ -30,6 +30,7 @@ class PopupNonClientFrameView : public BrowserNonClientFrameView {
// BrowserNonClientFrameView:
virtual gfx::Rect GetBoundsForTabStrip(BaseTabStrip* tabstrip) const;
+ virtual int GetHorizontalTabStripVerticalOffset(bool restored) const;
virtual void UpdateThrobber(bool running);
private: