diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-17 17:35:00 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-17 17:35:00 +0000 |
commit | f0ea49bb8d3280a52121666d14cc01ae1e0991e5 (patch) | |
tree | aee9899d9eed86276a704893cad922a4650cbdf9 | |
parent | 41d3846d2f324a140e5e841bad5f53e156b40d15 (diff) | |
download | chromium_src-f0ea49bb8d3280a52121666d14cc01ae1e0991e5.zip chromium_src-f0ea49bb8d3280a52121666d14cc01ae1e0991e5.tar.gz chromium_src-f0ea49bb8d3280a52121666d14cc01ae1e0991e5.tar.bz2 |
Misc. clean up: Rewrap, simplify. Refactored two separate files' calls of TabStrip::SetBackgroundOffset() into a single call in a different place.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/3107012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56377 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/chromeos/frame/browser_view.cc | 52 | ||||
-rw-r--r-- | chrome/browser/chromeos/frame/normal_browser_frame_view.cc | 16 | ||||
-rw-r--r-- | chrome/browser/views/bookmark_bar_view.cc | 13 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.cc | 39 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view_layout.cc | 42 | ||||
-rw-r--r-- | chrome/browser/views/frame/glass_browser_frame_view.cc | 133 | ||||
-rw-r--r-- | chrome/browser/views/frame/opaque_browser_frame_view.cc | 123 |
7 files changed, 172 insertions, 246 deletions
diff --git a/chrome/browser/chromeos/frame/browser_view.cc b/chrome/browser/chromeos/frame/browser_view.cc index 4fe7661..f88f57b 100644 --- a/chrome/browser/chromeos/frame/browser_view.cc +++ b/chrome/browser/chromeos/frame/browser_view.cc @@ -99,17 +99,17 @@ class BrowserViewLayout : public ::BrowserViewLayout { tabstrip_->SetVisible(false); tabstrip_->SetBounds(0, 0, 0, 0); return 0; - } else { - gfx::Rect layout_bounds = - browser_view_->frame()->GetBoundsForTabStrip(tabstrip_); - gfx::Point tabstrip_origin = layout_bounds.origin(); - views::View::ConvertPointToView(browser_view_->GetParent(), browser_view_, - &tabstrip_origin); - layout_bounds.set_origin(tabstrip_origin); - if (browser_view_->UseVerticalTabs()) - return LayoutTitlebarComponentsWithVerticalTabs(layout_bounds); - return LayoutTitlebarComponents(layout_bounds); } + + gfx::Rect tabstrip_bounds( + browser_view_->frame()->GetBoundsForTabStrip(tabstrip_)); + gfx::Point tabstrip_origin = tabstrip_bounds.origin(); + views::View::ConvertPointToView(browser_view_->GetParent(), browser_view_, + &tabstrip_origin); + tabstrip_bounds.set_origin(tabstrip_origin); + return browser_view_->UseVerticalTabs() ? + LayoutTitlebarComponentsWithVerticalTabs(tabstrip_bounds) : + LayoutTitlebarComponents(tabstrip_bounds); } virtual int LayoutToolbar(int top) { @@ -211,37 +211,27 @@ class BrowserViewLayout : public ::BrowserViewLayout { return bounds.y() + toolbar_height; } - // Layouts components in the title bar area (given by - // |bounds|). These include the main menu, the otr avatar icon (in - // incognito window), the tabstrip and the the status area. + // Lays out components in the title bar area (given by |bounds|). These + // include the main menu, the otr avatar icon (in incognito windows), the + // tabstrip and the the status area. int LayoutTitlebarComponents(const gfx::Rect& bounds) { - if (bounds.IsEmpty()) { + if (bounds.IsEmpty()) return 0; - } + tabstrip_->SetVisible(true); otr_avatar_icon_->SetVisible(browser_view_->ShouldShowOffTheRecordAvatar()); status_area_->SetVisible(true); - int bottom = bounds.bottom(); - // Layout status area after tab strip. gfx::Size status_size = status_area_->GetPreferredSize(); - status_area_->SetBounds(bounds.x() + bounds.width() - status_size.width(), - bounds.y(), status_size.width(), - status_size.height()); + status_area_->SetBounds(bounds.right() - status_size.width(), bounds.y(), + status_size.width(), status_size.height()); LayoutOTRAvatar(bounds); - int curx = bounds.x(); - int remaining_width = std::max( - 0, // In case there is no space left. - otr_avatar_icon_->bounds().x() - curx); - - tabstrip_->SetBounds(curx, bounds.y(), remaining_width, bounds.height()); - - gfx::Rect toolbar_bounds = browser_view_->GetToolbarBounds(); - tabstrip_->SetBackgroundOffset( - gfx::Point(curx - toolbar_bounds.x(), bounds.y())); - return bottom; + tabstrip_->SetBounds(bounds.x(), bounds.y(), + std::max(0, otr_avatar_icon_->bounds().x() - bounds.x()), + bounds.height()); + return bounds.bottom(); } // Layouts OTR avatar within the given |bounds|. diff --git a/chrome/browser/chromeos/frame/normal_browser_frame_view.cc b/chrome/browser/chromeos/frame/normal_browser_frame_view.cc index f122a15..6e6362b 100644 --- a/chrome/browser/chromeos/frame/normal_browser_frame_view.cc +++ b/chrome/browser/chromeos/frame/normal_browser_frame_view.cc @@ -328,16 +328,14 @@ 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() - kClientEdgeThickness, - strip_height - kFrameShadowThickness, - toolbar_bounds.x() - kClientEdgeThickness, bottom_y, - toolbar_bounds.width() + (2 * kClientEdgeThickness), - theme_toolbar->height()); + canvas->TileImageInt(*theme_toolbar, toolbar_bounds.x(), + 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(), @@ -362,9 +360,9 @@ void NormalBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) { toolbar_right->width(), bottom_edge_height, false); // Draw the content/toolbar separator. - canvas->DrawLineInt(ResourceBundle::toolbar_separator_color, - toolbar_bounds.x(), toolbar_bounds.bottom() - 1, - toolbar_bounds.right() - 1, toolbar_bounds.bottom() - 1); + canvas->FillRectInt(ResourceBundle::toolbar_separator_color, + toolbar_bounds.x(), toolbar_bounds.bottom() - kClientEdgeThickness, + toolbar_bounds.width(), kClientEdgeThickness); } } // namespace chromeos diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc index 2ea1c66..67a4078 100644 --- a/chrome/browser/views/bookmark_bar_view.cc +++ b/chrome/browser/views/bookmark_bar_view.cc @@ -62,7 +62,7 @@ using views::View; // How much we want the bookmark bar to overlap the toolbar when in its // 'always shown' mode. -static const double kToolbarOverlap = 4.0; +static const int kToolbarOverlap = 4; // Margins around the content. static const int kTopMargin = 1; @@ -395,10 +395,7 @@ BookmarkBarView::BookmarkBarView(Profile* profile, Browser* browser) Init(); SetProfile(profile); - if (IsAlwaysShown()) - size_animation_->Reset(1); - else - size_animation_->Reset(0); + size_animation_->Reset(IsAlwaysShown() ? 1 : 0); } BookmarkBarView::~BookmarkBarView() { @@ -753,8 +750,10 @@ bool BookmarkBarView::OnNewTabPage() const { } int BookmarkBarView::GetToolbarOverlap(bool return_max) { - return static_cast<int>(kToolbarOverlap * - (return_max ? 1.0 : size_animation_->GetCurrentValue())); + if (return_max) + return kToolbarOverlap; + return static_cast<int>(static_cast<double>(kToolbarOverlap) * + size_animation_->GetCurrentValue()); } void BookmarkBarView::AnimationProgressed(const Animation* animation) { diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index daf6b2d..7b12f6a 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -239,27 +239,25 @@ void BookmarkExtensionBackground::Paint(gfx::Canvas* canvas, height = contents->view()->GetContainerSize().height(); NtpBackgroundUtil::PaintBackgroundDetachedMode( host_view_->GetThemeProvider(), canvas, - gfx::Rect(0, 0, host_view_->width(), host_view_->height()), - height); - - SkRect rect; + gfx::Rect(0, 0, host_view_->width(), host_view_->height()), height); // As 'hidden' according to the animation is the full in-tab state, // we invert the value - when current_state is at '0', we expect the // bar to be docked. double current_state = 1 - host_view_->GetAnimationValue(); + double h_padding = + static_cast<double>(BookmarkBarView::kNewtabHorizontalPadding) * + current_state; + double v_padding = + static_cast<double>(BookmarkBarView::kNewtabVerticalPadding) * + current_state; - double h_padding = static_cast<double> - (BookmarkBarView::kNewtabHorizontalPadding) * current_state; - double v_padding = static_cast<double> - (BookmarkBarView::kNewtabVerticalPadding) * current_state; + SkRect rect; double roundness = 0; - - DetachableToolbarView::CalculateContentArea(current_state, - h_padding, v_padding, - &rect, &roundness, host_view_); - DetachableToolbarView::PaintContentAreaBackground( - canvas, tp, rect, roundness); + DetachableToolbarView::CalculateContentArea(current_state, h_padding, + v_padding, &rect, &roundness, host_view_); + DetachableToolbarView::PaintContentAreaBackground(canvas, tp, rect, + roundness); DetachableToolbarView::PaintContentAreaBorder(canvas, tp, rect, roundness); DetachableToolbarView::PaintHorizontalBorder(canvas, host_view_); } else { @@ -273,7 +271,9 @@ void BookmarkExtensionBackground::Paint(gfx::Canvas* canvas, class ResizeCorner : public views::View { public: - ResizeCorner() { } + ResizeCorner() { + EnableCanvasFlippingForRTLUI(true); + } virtual void Paint(gfx::Canvas* canvas) { views::Window* window = GetWindow(); @@ -283,16 +283,8 @@ class ResizeCorner : public views::View { SkBitmap* bitmap = ResourceBundle::GetSharedInstance().GetBitmapNamed( IDR_TEXTAREA_RESIZER); bitmap->buildMipMap(false); - bool rtl_dir = base::i18n::IsRTL(); - 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() { @@ -1875,7 +1867,6 @@ void BrowserView::Init() { } if (AeroPeekManager::Enabled()) { - gfx::Rect bounds(frame_->GetBoundsForTabStrip(tabstrip())); aeropeek_manager_.reset(new AeroPeekManager( frame_->GetWindow()->GetNativeWindow())); browser_->tabstrip_model()->AddObserver(aeropeek_manager_.get()); diff --git a/chrome/browser/views/frame/browser_view_layout.cc b/chrome/browser/views/frame/browser_view_layout.cc index 8af0a07..4267457 100644 --- a/chrome/browser/views/frame/browser_view_layout.cc +++ b/chrome/browser/views/frame/browser_view_layout.cc @@ -65,10 +65,8 @@ gfx::Size BrowserViewLayout::GetMinimumSize() { if (active_bookmark_bar_ && browser()->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR)) { bookmark_bar_size = active_bookmark_bar_->GetMinimumSize(); - bookmark_bar_size.Enlarge( - 0, - -kSeparationLineHeight - - active_bookmark_bar_->GetToolbarOverlap(true)); + bookmark_bar_size.Enlarge(0, -(kSeparationLineHeight + + active_bookmark_bar_->GetToolbarOverlap(true))); } gfx::Size contents_size(contents_split_->GetMinimumSize()); @@ -239,6 +237,11 @@ void BrowserViewLayout::ViewRemoved(views::View* host, views::View* view) { void BrowserViewLayout::Layout(views::View* host) { vertical_layout_rect_ = browser_view_->GetLocalBounds(true); int top = LayoutTabStrip(); + if (browser_view_->IsTabStripVisible() && !browser_view_->UseVerticalTabs()) { + tabstrip_->SetBackgroundOffset(gfx::Point( + tabstrip_->x() - browser_view_->GetToolbarBounds().x(), + tabstrip_->y())); + } top = LayoutToolbar(top); top = LayoutBookmarkAndInfoBars(top); int bottom = LayoutDownloadShelf(browser_view_->height()); @@ -272,27 +275,21 @@ int BrowserViewLayout::LayoutTabStrip() { tabstrip_->SetBounds(0, 0, 0, 0); return 0; } - gfx::Rect layout_bounds = - browser_view_->frame()->GetBoundsForTabStrip(tabstrip_); - - if (browser_view_->UseVerticalTabs()) { - vertical_layout_rect_.Inset( - layout_bounds.width(), 0, 0, 0); - } else { - gfx::Rect toolbar_bounds = browser_view_->GetToolbarBounds(); - tabstrip_->SetBackgroundOffset( - gfx::Point(layout_bounds.x() - toolbar_bounds.x(), - layout_bounds.y())); - } - gfx::Point tabstrip_origin = layout_bounds.origin(); + gfx::Rect tabstrip_bounds( + browser_view_->frame()->GetBoundsForTabStrip(tabstrip_)); + gfx::Point tabstrip_origin(tabstrip_bounds.origin()); views::View::ConvertPointToView(browser_view_->GetParent(), browser_view_, &tabstrip_origin); - layout_bounds.set_origin(tabstrip_origin); + tabstrip_bounds.set_origin(tabstrip_origin); + + if (browser_view_->UseVerticalTabs()) + vertical_layout_rect_.Inset(tabstrip_bounds.width(), 0, 0, 0); + tabstrip_->SetVisible(true); - tabstrip_->SetBounds(layout_bounds); + tabstrip_->SetBounds(tabstrip_bounds); return browser_view_->UseVerticalTabs() ? - layout_bounds.y() : layout_bounds.bottom(); + tabstrip_bounds.y() : tabstrip_bounds.bottom(); } int BrowserViewLayout::LayoutToolbar(int top) { @@ -335,10 +332,8 @@ int BrowserViewLayout::LayoutBookmarkBar(int top) { } int bookmark_bar_height = active_bookmark_bar_->GetPreferredSize().height(); - y -= kSeparationLineHeight + ( - active_bookmark_bar_->IsDetached() ? + y -= kSeparationLineHeight + (active_bookmark_bar_->IsDetached() ? 0 : active_bookmark_bar_->GetToolbarOverlap(false)); - active_bookmark_bar_->SetVisible(true); active_bookmark_bar_->SetBounds(vertical_layout_rect_.x(), y, vertical_layout_rect_.width(), @@ -379,4 +374,3 @@ int BrowserViewLayout::LayoutDownloadShelf(int bottom) { } return bottom; } - diff --git a/chrome/browser/views/frame/glass_browser_frame_view.cc b/chrome/browser/views/frame/glass_browser_frame_view.cc index 47e82ed..6f30e6a 100644 --- a/chrome/browser/views/frame/glass_browser_frame_view.cc +++ b/chrome/browser/views/frame/glass_browser_frame_view.cc @@ -192,7 +192,8 @@ void GlassBrowserFrameView::Paint(gfx::Canvas* canvas) { return; // Nothing is visible, so don't bother to paint. PaintToolbarBackground(canvas); - PaintOTRAvatar(canvas); + if (browser_view_->ShouldShowOffTheRecordAvatar()) + PaintOTRAvatar(canvas); if (!frame_->GetWindow()->IsMaximized()) PaintRestoredClientEdge(canvas); } @@ -227,9 +228,9 @@ int GlassBrowserFrameView::NonClientTopBorderHeight() const { 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 CXSIZEFRAME-thick border + // frame has a 0 frame border around most edges and a CYSIZEFRAME-thick border // at the top (see AeroGlassFrame::OnGetMinMaxInfo()). - return GetSystemMetrics(SM_CXSIZEFRAME) + (browser_view_->IsMaximized() ? + return GetSystemMetrics(SM_CYSIZEFRAME) + (browser_view_->IsMaximized() ? -kTabstripTopShadowThickness : kNonClientRestoredExtraThickness); } @@ -238,8 +239,7 @@ void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) { gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds()); gfx::Point toolbar_origin(toolbar_bounds.origin()); - View::ConvertPointToView(frame_->GetWindow()->GetClientView(), - this, &toolbar_origin); + View::ConvertPointToView(browser_view_, this, &toolbar_origin); toolbar_bounds.set_origin(toolbar_origin); SkBitmap* theme_toolbar = tp->GetBitmapNamed(IDR_THEME_TOOLBAR); @@ -249,51 +249,48 @@ void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) { if (browser_view_->UseVerticalTabs()) { gfx::Rect tabstrip_bounds(browser_view_->tabstrip()->bounds()); gfx::Point tabstrip_origin(tabstrip_bounds.origin()); - View::ConvertPointToView(frame_->GetWindow()->GetClientView(), - this, &tabstrip_origin); + View::ConvertPointToView(browser_view_, this, &tabstrip_origin); tabstrip_bounds.set_origin(tabstrip_origin); int x = tabstrip_bounds.x(); - int y = tabstrip_bounds.y(); + int y = tabstrip_origin.y(); int w = toolbar_bounds.right() - x; - int src_y = Tab::GetMinimumUnselectedSize().height(); - canvas->TileImageInt(*theme_toolbar, 0, src_y, + canvas->TileImageInt(*theme_toolbar, 0, + Tab::GetMinimumUnselectedSize().height(), MirroredLeftPointForRect(toolbar_bounds), y, toolbar_bounds.width(), theme_toolbar->height()); - // Draw left edge. We explicitly set a clip as the image is bigger than just - // the corner. - canvas->Save(); - canvas->ClipRectInt(x - kNonClientBorderThickness, - y - kNonClientBorderThickness, - kNonClientBorderThickness, - kNonClientBorderThickness); - canvas->DrawBitmapInt(*toolbar_left, x - kNonClientBorderThickness, - y - kNonClientBorderThickness); - canvas->Restore(); + // Draw left edge. + int dest_y = y - kNonClientBorderThickness; + canvas->DrawBitmapInt(*toolbar_left, 0, 0, kNonClientBorderThickness, + kNonClientBorderThickness, x - kNonClientBorderThickness, 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, y - kNonClientBorderThickness, w, + canvas->TileImageInt(*toolbar_center, x, dest_y, w, toolbar_center->height()); - // Right edge. Again, we have to clip because of image size. - canvas->Save(); - canvas->ClipRectInt(x + w - kNonClientBorderThickness, - y - kNonClientBorderThickness, - kNonClientBorderThickness, - kNonClientBorderThickness); - canvas->DrawBitmapInt(*tp->GetBitmapNamed(IDR_CONTENT_TOP_RIGHT_CORNER), - x + w, y); - canvas->Restore(); + + // 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, + 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; + int y = toolbar_bounds.y(); int src_y = browser_view_->GetTabStripHeight() - 1; - canvas->TileImageInt(*theme_toolbar, 0, src_y, - toolbar_bounds.x() - 1, toolbar_bounds.y() + 2, - toolbar_bounds.width() + 2, theme_toolbar->height()); + canvas->TileImageInt(*theme_toolbar, 0, src_y, x, + y + (kFrameShadowThickness * 2), + toolbar_bounds.width() + (2 * kClientEdgeThickness), + theme_toolbar->height()); + // Draw rounded corners for the tab. SkBitmap* toolbar_left_mask = tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER_MASK); @@ -307,44 +304,33 @@ void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) { paint.setXfermodeMode(SkXfermode::kDstIn_Mode); // Mask out the top left corner. - int left_x = toolbar_bounds.x() - kContentEdgeShadowThickness - - kClientEdgeThickness; - canvas->DrawBitmapInt(*toolbar_left_mask, - left_x, toolbar_bounds.y(), paint); + 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; - canvas->DrawBitmapInt(*toolbar_right_mask, - right_x, toolbar_bounds.y(), - paint); + canvas->DrawBitmapInt(*toolbar_right_mask, right_x, y, paint); // Draw left edge. - canvas->DrawBitmapInt(*toolbar_left, left_x, toolbar_bounds.y()); + canvas->DrawBitmapInt(*toolbar_left, left_x, y); // Draw center edge. - canvas->TileImageInt(*toolbar_center, left_x + toolbar_left->width(), - toolbar_bounds.y(), - right_x - (left_x + toolbar_left->width()), - toolbar_center->height()); + canvas->TileImageInt(*toolbar_center, left_x + toolbar_left->width(), y, + right_x - (left_x + toolbar_left->width()), toolbar_center->height()); // Right edge. canvas->DrawBitmapInt(*tp->GetBitmapNamed(IDR_CONTENT_TOP_RIGHT_CORNER), - right_x, toolbar_bounds.y()); + right_x, y); } // Draw the content/toolbar separator. - canvas->DrawLineInt(ResourceBundle::toolbar_separator_color, - toolbar_bounds.x(), - toolbar_bounds.bottom() - kClientEdgeThickness, - toolbar_bounds.right(), - toolbar_bounds.bottom() - kClientEdgeThickness); + canvas->FillRectInt(ResourceBundle::toolbar_separator_color, + toolbar_bounds.x(), toolbar_bounds.bottom() - kClientEdgeThickness, + toolbar_bounds.width(), kClientEdgeThickness); } void GlassBrowserFrameView::PaintOTRAvatar(gfx::Canvas* canvas) { - if (!browser_view_->ShouldShowOffTheRecordAvatar()) - return; - SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon(); int src_x = 0; int src_y = (otr_avatar_icon.height() - otr_avatar_bounds_.height()) / 2; @@ -371,57 +357,47 @@ void GlassBrowserFrameView::PaintOTRAvatar(gfx::Canvas* canvas) { void GlassBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { ThemeProvider* tp = GetThemeProvider(); - gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); // The client edges start below the toolbar upper corner images regardless // of how tall the toolbar itself is. int client_area_top = browser_view_->UseVerticalTabs() ? client_area_bounds.y() : - frame_->GetWindow()->GetClientView()->y() + + (frame_->GetWindow()->GetClientView()->y() + browser_view_->GetToolbarBounds().y() + - tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height(); - + tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height()); int client_area_bottom = std::max(client_area_top, height() - NonClientBorderThickness()); int client_area_height = client_area_bottom - client_area_top; + 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 one pixel areas down the sides - // show the right color even if not covered by the toolbar image. + // 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->DrawLineInt(toolbar_color, - client_area_bounds.x() - kClientEdgeThickness, - client_area_top, - client_area_bounds.x() - kClientEdgeThickness, - client_area_bottom - 1 + kClientEdgeThickness); - canvas->DrawLineInt(toolbar_color, - client_area_bounds.x() - kClientEdgeThickness, - client_area_bottom - 1 + kClientEdgeThickness, - client_area_bounds.right() + kClientEdgeThickness, - client_area_bottom - 1 + kClientEdgeThickness); - canvas->DrawLineInt(toolbar_color, - client_area_bounds.right() - 1 + kClientEdgeThickness, - client_area_bottom - 1 + kClientEdgeThickness, - client_area_bounds.right() - 1 + kClientEdgeThickness, - client_area_top); + 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); - SkBitmap* bottom = tp->GetBitmapNamed(IDR_CONTENT_BOTTOM_CENTER); canvas->TileImageInt(*bottom, client_area_bounds.x(), client_area_bottom, client_area_bounds.width(), bottom->height()); - SkBitmap* bottom_left = tp->GetBitmapNamed(IDR_CONTENT_BOTTOM_LEFT_CORNER); canvas->DrawBitmapInt(*bottom_left, 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); @@ -435,6 +411,7 @@ void GlassBrowserFrameView::LayoutOTRAvatar() { // comment in GetBoundsForTabStrip().) if (base::i18n::IsRTL()) otr_x += width() - frame_->GetMinimizeButtonOffset(); + SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon(); int otr_height = browser_view_->IsTabStripVisible() ? otr_avatar_icon.height() : 0; diff --git a/chrome/browser/views/frame/opaque_browser_frame_view.cc b/chrome/browser/views/frame/opaque_browser_frame_view.cc index bb2fcfa..df0b5a2 100644 --- a/chrome/browser/views/frame/opaque_browser_frame_view.cc +++ b/chrome/browser/views/frame/opaque_browser_frame_view.cc @@ -201,9 +201,8 @@ gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip( int tabstrip_y = NonClientTopBorderHeight(); if (!frame_->GetWindow()->IsMaximized() && - !frame_->GetWindow()->IsFullscreen()) { + !frame_->GetWindow()->IsFullscreen()) tabstrip_y += kNonClientRestoredExtraThickness; - } int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ? (otr_avatar_icon_->bounds().right() + kOTRSideSpacing) : @@ -213,8 +212,7 @@ gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip( (frame_->GetWindow()->IsMaximized() ? kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing); return gfx::Rect(tabstrip_x, tabstrip_y, - std::max(0, tabstrip_width), - tabstrip->GetPreferredHeight()); + std::max(0, tabstrip_width), tabstrip->GetPreferredHeight()); } void OpaqueBrowserFrameView::UpdateThrobber(bool running) { @@ -230,7 +228,7 @@ gfx::Size OpaqueBrowserFrameView::GetMinimumSize() { views::WindowDelegate* d = frame_->GetWindow()->GetDelegate(); int min_titlebar_width = (2 * FrameBorderThickness()) + kIconLeftSpacing + - (d->ShouldShowWindowIcon() ? (IconSize() + kTitleLogoSpacing) : 0); + (d->ShouldShowWindowIcon() ? (IconSize() + kTitleLogoSpacing) : 0); #if !defined(OS_CHROMEOS) min_titlebar_width += minimize_button_->GetMinimumSize().width() + @@ -480,16 +478,15 @@ int OpaqueBrowserFrameView::NonClientTopBorderHeight() const { kVerticalTabPadding; } - if (browser_view_->IsTabStripVisible() && window->IsMaximized()) - return FrameBorderThickness() - kTabstripTopShadowThickness; - - return FrameBorderThickness(); + return FrameBorderThickness() - + (browser_view_->IsTabStripVisible() && window->IsMaximized()) ? + kTabstripTopShadowThickness : 0; } int OpaqueBrowserFrameView::CaptionButtonY() 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() ? + return (frame_->GetWindow()->IsMaximized()) ? FrameBorderThickness() : kFrameShadowThickness; } @@ -719,10 +716,9 @@ void OpaqueBrowserFrameView::PaintTitleBar(gfx::Canvas* canvas) { // The window icon is painted by the TabIconView. views::WindowDelegate* d = frame_->GetWindow()->GetDelegate(); if (d->ShouldShowWindowTitle()) { - canvas->DrawStringInt( - d->GetWindowTitle(), BrowserFrame::GetTitleFont(), SK_ColorWHITE, - MirroredLeftPointForRect(title_bounds_), title_bounds_.y(), - title_bounds_.width(), title_bounds_.height()); + canvas->DrawStringInt(d->GetWindowTitle(), BrowserFrame::GetTitleFont(), + SK_ColorWHITE, MirroredLeftPointForRect(title_bounds_), + title_bounds_.y(), title_bounds_.width(), title_bounds_.height()); /* TODO(pkasting): If this window is active, we should also draw a drop * shadow on the title. This is tricky, because we don't want to hardcode a * shadow color (since we want to work with various themes), but we can't @@ -737,8 +733,6 @@ void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) { if (toolbar_bounds.IsEmpty()) return; - ThemeProvider* tp = GetThemeProvider(); - int x, y, w, h; if (browser_view_->UseVerticalTabs()) { gfx::Rect tabstrip_bounds = GetViewBounds(browser_view_->tabstrip(), this); @@ -759,6 +753,7 @@ void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) { // section so that we never break the gradient. int split_point = kFrameShadowThickness * 2; int bottom_y = y + split_point; + ThemeProvider* tp = GetThemeProvider(); SkBitmap* toolbar_left = tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER); int bottom_edge_height = std::min(toolbar_left->height(), h) - split_point; @@ -773,15 +768,11 @@ void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) { tp->GetColor(BrowserThemeProvider::COLOR_TOOLBAR); canvas->FillRectInt(theme_toolbar_color, x, bottom_y, w, bottom_edge_height); - int strip_height = browser_view_->GetTabStripHeight(); SkBitmap* theme_toolbar = tp->GetBitmapNamed(IDR_THEME_TOOLBAR); - - canvas->TileImageInt(*theme_toolbar, - x - kClientEdgeThickness, - strip_height - kFrameShadowThickness, - x - kClientEdgeThickness, bottom_y, - w + (2 * kClientEdgeThickness), - theme_toolbar->height()); + 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()); // Draw rounded corners for the tab. SkBitmap* toolbar_left_mask = @@ -795,24 +786,22 @@ void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) { SkPaint paint; paint.setXfermodeMode(SkXfermode::kDstIn_Mode); - // Make the left edge. - int left_x = x - kClientEdgeThickness - kContentEdgeShadowThickness; - canvas->DrawBitmapInt(*toolbar_left_mask, 0, 0, - toolbar_left_mask->width(), split_point, - left_x, y, - toolbar_left_mask->width(), split_point, false, paint); + // Mask the left edge. + int left_x = x - kContentEdgeShadowThickness; + canvas->DrawBitmapInt(*toolbar_left_mask, 0, 0, toolbar_left_mask->width(), + split_point, left_x, y, toolbar_left_mask->width(), + split_point, false, paint); canvas->DrawBitmapInt(*toolbar_left_mask, 0, toolbar_left_mask->height() - bottom_edge_height, - toolbar_left_mask->width(), bottom_edge_height, - left_x, bottom_y, + toolbar_left_mask->width(), bottom_edge_height, left_x, bottom_y, toolbar_left_mask->width(), bottom_edge_height, false, paint); // Mask the right edge. int right_x = x + w - toolbar_right_mask->width() + kClientEdgeThickness + 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); + canvas->DrawBitmapInt(*toolbar_right_mask, 0, 0, toolbar_right_mask->width(), + split_point, right_x, y, toolbar_right_mask->width(), + split_point, false, paint); canvas->DrawBitmapInt(*toolbar_right_mask, 0, toolbar_right_mask->height() - bottom_edge_height, toolbar_right_mask->width(), bottom_edge_height, right_x, bottom_y, @@ -820,12 +809,11 @@ void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) { canvas->Restore(); canvas->DrawBitmapInt(*toolbar_left, 0, 0, toolbar_left->width(), split_point, - left_x, y, - toolbar_left->width(), split_point, false); + left_x, y, toolbar_left->width(), split_point, false); canvas->DrawBitmapInt(*toolbar_left, 0, toolbar_left->height() - bottom_edge_height, toolbar_left->width(), - bottom_edge_height, left_x, bottom_y, - toolbar_left->width(), bottom_edge_height, false); + bottom_edge_height, left_x, bottom_y, toolbar_left->width(), + bottom_edge_height, false); SkBitmap* toolbar_center = tp->GetBitmapNamed(IDR_CONTENT_TOP_CENTER); @@ -835,19 +823,16 @@ void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) { SkBitmap* toolbar_right = tp->GetBitmapNamed(IDR_CONTENT_TOP_RIGHT_CORNER); canvas->DrawBitmapInt(*toolbar_right, 0, 0, toolbar_right->width(), - split_point, right_x, y, - toolbar_right->width(), split_point, false); + split_point, right_x, y, toolbar_right->width(), split_point, false); canvas->DrawBitmapInt(*toolbar_right, 0, toolbar_right->height() - bottom_edge_height, toolbar_right->width(), - bottom_edge_height, right_x, bottom_y, - toolbar_right->width(), bottom_edge_height, false); + bottom_edge_height, right_x, bottom_y, toolbar_right->width(), + bottom_edge_height, false); // Draw the content/toolbar separator. - canvas->DrawLineInt(ResourceBundle::toolbar_separator_color, - toolbar_bounds.x(), - toolbar_bounds.bottom() - kClientEdgeThickness, - toolbar_bounds.right(), - toolbar_bounds.bottom() - kClientEdgeThickness); + canvas->FillRectInt(ResourceBundle::toolbar_separator_color, + toolbar_bounds.x(), toolbar_bounds.bottom() - kClientEdgeThickness, + toolbar_bounds.width(), kClientEdgeThickness); } void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { @@ -885,55 +870,47 @@ void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { top_right->width(), height, false); // Draw the toolbar color across the top edge. - canvas->DrawLineInt(toolbar_color, + canvas->FillRectInt(toolbar_color, client_area_bounds.x() - kClientEdgeThickness, client_area_top - kClientEdgeThickness, - client_area_bounds.right() + kClientEdgeThickness, - client_area_top - kClientEdgeThickness); + client_area_bounds.width() + (2 * kClientEdgeThickness), + kClientEdgeThickness); } 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 one pixel areas down the sides - // show the right color even if not covered by the toolbar image. - canvas->DrawLineInt(toolbar_color, - client_area_bounds.x() - kClientEdgeThickness, - client_area_top, - client_area_bounds.x() - kClientEdgeThickness, - client_area_bottom - 1 + kClientEdgeThickness); - canvas->DrawLineInt(toolbar_color, - client_area_bounds.x() - kClientEdgeThickness, - client_area_bottom - 1 + kClientEdgeThickness, - client_area_bounds.right() + kClientEdgeThickness, - client_area_bottom - 1 + kClientEdgeThickness); - canvas->DrawLineInt(toolbar_color, - client_area_bounds.right() - 1 + kClientEdgeThickness, - client_area_bottom - 1 + kClientEdgeThickness, - client_area_bounds.right() - 1 + kClientEdgeThickness, - 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); + + // 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->DrawBitmapInt( *tp->GetBitmapNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER), client_area_bounds.right(), client_area_bottom); - SkBitmap* bottom = tp->GetBitmapNamed(IDR_CONTENT_BOTTOM_CENTER); canvas->TileImageInt(*bottom, client_area_bounds.x(), client_area_bottom, client_area_bounds.width(), bottom->height()); - SkBitmap* bottom_left = tp->GetBitmapNamed(IDR_CONTENT_BOTTOM_LEFT_CORNER); canvas->DrawBitmapInt(*bottom_left, 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); + client_area_top, left->width(), client_area_height); } void OpaqueBrowserFrameView::LayoutWindowControls() { |