| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/views/frame/opaque_browser_frame_view.h" | 5 #include "chrome/browser/views/frame/opaque_browser_frame_view.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "app/theme_provider.h" | 9 #include "app/theme_provider.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "views/window/window_shape.h" | 29 #include "views/window/window_shape.h" |
| 30 | 30 |
| 31 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
| 32 #include "app/win_util.h" | 32 #include "app/win_util.h" |
| 33 #endif | 33 #endif |
| 34 | 34 |
| 35 #if defined(OS_LINUX) | 35 #if defined(OS_LINUX) |
| 36 #include "views/window/hit_test.h" | 36 #include "views/window/hit_test.h" |
| 37 #endif | 37 #endif |
| 38 | 38 |
| 39 #if defined(OS_CHROMEOS) | |
| 40 const int kCustomFrameBackgroundVerticalOffset = 15; | |
| 41 #endif | |
| 42 | |
| 43 namespace { | 39 namespace { |
| 44 // The frame border is only visible in restored mode and is hardcoded to 4 px on | 40 // The frame border is only visible in restored mode and is hardcoded to 4 px on |
| 45 // each side regardless of the system window border size. | 41 // each side regardless of the system window border size. |
| 46 const int kFrameBorderThickness = 4; | 42 const int kFrameBorderThickness = 4; |
| 47 // Besides the frame border, there's another 11 px of empty space atop the | 43 // Besides the frame border, there's another 11 px of empty space atop the |
| 48 // window in restored mode, to use to drag the window around. | 44 // window in restored mode, to use to drag the window around. |
| 49 const int kNonClientRestoredExtraThickness = 11; | 45 const int kNonClientRestoredExtraThickness = 11; |
| 50 // While resize areas on Windows are normally the same size as the window | 46 // While resize areas on Windows are normally the same size as the window |
| 51 // borders, our top area is shrunk by 1 px to make it easier to move the window | 47 // borders, our top area is shrunk by 1 px to make it easier to move the window |
| 52 // around with our thinner top grabbable strip. (Incidentally, our side and | 48 // around with our thinner top grabbable strip. (Incidentally, our side and |
| (...skipping 11 matching lines...) Expand all Loading... |
| 64 // The titlebar has a 2 px 3D edge along the top and bottom. | 60 // The titlebar has a 2 px 3D edge along the top and bottom. |
| 65 const int kTitlebarTopAndBottomEdgeThickness = 2; | 61 const int kTitlebarTopAndBottomEdgeThickness = 2; |
| 66 // The icon is inset 2 px from the left frame border. | 62 // The icon is inset 2 px from the left frame border. |
| 67 const int kIconLeftSpacing = 2; | 63 const int kIconLeftSpacing = 2; |
| 68 // The icon never shrinks below 16 px on a side. | 64 // The icon never shrinks below 16 px on a side. |
| 69 const int kIconMinimumSize = 16; | 65 const int kIconMinimumSize = 16; |
| 70 // There is a 4 px gap between the icon and the title text. | 66 // There is a 4 px gap between the icon and the title text. |
| 71 const int kIconTitleSpacing = 4; | 67 const int kIconTitleSpacing = 4; |
| 72 // There is a 5 px gap between the title text and the caption buttons. | 68 // There is a 5 px gap between the title text and the caption buttons. |
| 73 const int kTitleLogoSpacing = 5; | 69 const int kTitleLogoSpacing = 5; |
| 74 // In maximized mode, the OTR avatar starts 2 px below the top of the screen, so | |
| 75 // that it doesn't extend into the "3D edge" portion of the titlebar. | |
| 76 const int kOTRMaximizedTopSpacing = 2; | |
| 77 // The OTR avatar ends 2 px above the bottom of the tabstrip (which, given the | 70 // The OTR avatar ends 2 px above the bottom of the tabstrip (which, given the |
| 78 // way the tabstrip draws its bottom edge, will appear like a 1 px gap to the | 71 // way the tabstrip draws its bottom edge, will appear like a 1 px gap to the |
| 79 // user). | 72 // user). |
| 80 const int kOTRBottomSpacing = 2; | 73 const int kOTRBottomSpacing = 2; |
| 81 // There are 2 px on each side of the OTR avatar (between the frame border and | 74 // There are 2 px on each side of the OTR avatar (between the frame border and |
| 82 // it on the left, and between it and the tabstrip on the right). | 75 // it on the left, and between it and the tabstrip on the right). |
| 83 const int kOTRSideSpacing = 2; | 76 const int kOTRSideSpacing = 2; |
| 84 // The top 1 px of the tabstrip is shadow; in maximized mode we push this off | 77 // The top 1 px of the tabstrip is shadow; in maximized mode we push this off |
| 85 // the top of the screen so the tabs appear flush against the screen edge. | 78 // the top of the screen so the tabs appear flush against the screen edge. |
| 86 const int kTabstripTopShadowThickness = 1; | 79 const int kTabstripTopShadowThickness = 1; |
| 87 // In restored mode, the New Tab button isn't at the same height as the caption | 80 // In restored mode, the New Tab button isn't at the same height as the caption |
| 88 // buttons, but the space will look cluttered if it actually slides under them, | 81 // buttons, but the space will look cluttered if it actually slides under them, |
| 89 // so we stop it when the gap between the two is down to 5 px. | 82 // so we stop it when the gap between the two is down to 5 px. |
| 90 const int kNewTabCaptionRestoredSpacing = 5; | 83 const int kNewTabCaptionRestoredSpacing = 5; |
| 91 // In maximized mode, where the New Tab button and the caption buttons are at | 84 // In maximized mode, where the New Tab button and the caption buttons are at |
| 92 // similar vertical coordinates, we need to reserve a larger, 16 px gap to avoid | 85 // similar vertical coordinates, we need to reserve a larger, 16 px gap to avoid |
| 93 // looking too cluttered. | 86 // looking too cluttered. |
| 94 const int kNewTabCaptionMaximizedSpacing = 16; | 87 const int kNewTabCaptionMaximizedSpacing = 16; |
| 95 // How far to indent the tabstrip from the left side of the screen when there | 88 // How far to indent the tabstrip from the left side of the screen when there |
| 96 // is no OTR icon. | 89 // is no OTR icon. |
| 97 const int kTabStripIndent = 1; | 90 const int kTabStripIndent = 1; |
| 98 // Spacing between extension app icon/title and tab strip. | 91 // Spacing between extension app icon/title and tab strip. |
| 99 const int kExtensionAppTabStripLeftSpacing = 10; | 92 const int kExtensionAppTabStripLeftSpacing = 10; |
| 100 // Padding between the caption and start of vertical tabs. | |
| 101 const int kVerticalTabPadding = 6; | |
| 102 // Inset from the top of the toolbar/tabstrip to the shadow. Used only for | 93 // Inset from the top of the toolbar/tabstrip to the shadow. Used only for |
| 103 // vertical tabs. | 94 // vertical tabs. |
| 104 const int kVerticalTabBorderInset = 3; | 95 const int kVerticalTabBorderInset = 3; |
| 105 } | 96 } |
| 106 | 97 |
| 107 /////////////////////////////////////////////////////////////////////////////// | 98 /////////////////////////////////////////////////////////////////////////////// |
| 108 // OpaqueBrowserFrameView, public: | 99 // OpaqueBrowserFrameView, public: |
| 109 | 100 |
| 110 OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame, | 101 OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame, |
| 111 BrowserView* browser_view) | 102 BrowserView* browser_view) |
| 112 : BrowserNonClientFrameView(), | 103 : BrowserNonClientFrameView(), |
| 113 otr_avatar_icon_(new views::ImageView()), | |
| 114 ALLOW_THIS_IN_INITIALIZER_LIST( | 104 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 115 minimize_button_(new views::ImageButton(this))), | 105 minimize_button_(new views::ImageButton(this))), |
| 116 ALLOW_THIS_IN_INITIALIZER_LIST( | 106 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 117 maximize_button_(new views::ImageButton(this))), | 107 maximize_button_(new views::ImageButton(this))), |
| 118 ALLOW_THIS_IN_INITIALIZER_LIST( | 108 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 119 restore_button_(new views::ImageButton(this))), | 109 restore_button_(new views::ImageButton(this))), |
| 120 ALLOW_THIS_IN_INITIALIZER_LIST( | 110 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 121 close_button_(new views::ImageButton(this))), | 111 close_button_(new views::ImageButton(this))), |
| 122 window_icon_(NULL), | 112 window_icon_(NULL), |
| 123 frame_(frame), | 113 frame_(frame), |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 tp->GetBitmapNamed(IDR_CLOSE_H)); | 163 tp->GetBitmapNamed(IDR_CLOSE_H)); |
| 174 close_button_->SetImage(views::CustomButton::BS_PUSHED, | 164 close_button_->SetImage(views::CustomButton::BS_PUSHED, |
| 175 tp->GetBitmapNamed(IDR_CLOSE_P)); | 165 tp->GetBitmapNamed(IDR_CLOSE_P)); |
| 176 if (browser_view_->IsBrowserTypeNormal()) { | 166 if (browser_view_->IsBrowserTypeNormal()) { |
| 177 close_button_->SetBackground(color, background, | 167 close_button_->SetBackground(color, background, |
| 178 tp->GetBitmapNamed(IDR_CLOSE_BUTTON_MASK)); | 168 tp->GetBitmapNamed(IDR_CLOSE_BUTTON_MASK)); |
| 179 } | 169 } |
| 180 close_button_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_CLOSE)); | 170 close_button_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_CLOSE)); |
| 181 AddChildView(close_button_); | 171 AddChildView(close_button_); |
| 182 | 172 |
| 183 otr_avatar_icon_->SetImage(browser_view_->GetOTRAvatarIcon()); | |
| 184 AddChildView(otr_avatar_icon_); | |
| 185 // Initializing the TabIconView is expensive, so only do it if we need to. | 173 // Initializing the TabIconView is expensive, so only do it if we need to. |
| 186 if (browser_view_->ShouldShowWindowIcon()) { | 174 if (browser_view_->ShouldShowWindowIcon()) { |
| 187 window_icon_ = new TabIconView(this); | 175 window_icon_ = new TabIconView(this); |
| 188 window_icon_->set_is_light(true); | 176 window_icon_->set_is_light(true); |
| 189 AddChildView(window_icon_); | 177 AddChildView(window_icon_); |
| 190 window_icon_->Update(); | 178 window_icon_->Update(); |
| 191 } | 179 } |
| 192 } | 180 } |
| 193 | 181 |
| 194 OpaqueBrowserFrameView::~OpaqueBrowserFrameView() { | 182 OpaqueBrowserFrameView::~OpaqueBrowserFrameView() { |
| 195 } | 183 } |
| 196 | 184 |
| 197 /////////////////////////////////////////////////////////////////////////////// | 185 /////////////////////////////////////////////////////////////////////////////// |
| 198 // OpaqueBrowserFrameView, BrowserNonClientFrameView implementation: | 186 // OpaqueBrowserFrameView, BrowserNonClientFrameView implementation: |
| 199 | 187 |
| 200 gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip( | 188 gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip( |
| 201 BaseTabStrip* tabstrip) const { | 189 BaseTabStrip* tabstrip) const { |
| 202 if (browser_view_->UseVerticalTabs()) { | 190 if (browser_view_->UseVerticalTabs()) { |
| 203 gfx::Size ps = tabstrip->GetPreferredSize(); | 191 gfx::Size ps = tabstrip->GetPreferredSize(); |
| 204 return gfx::Rect(NonClientBorderThickness(), NonClientTopBorderHeight(), | 192 return gfx::Rect(NonClientBorderThickness(), |
| 205 ps.width(), browser_view_->height()); | 193 NonClientTopBorderHeight(false, false), ps.width(), |
| 194 browser_view_->height()); |
| 206 } | 195 } |
| 207 | 196 |
| 208 int tabstrip_y = NonClientTopBorderHeight(); | |
| 209 if (!frame_->GetWindow()->IsMaximized() && | |
| 210 !frame_->GetWindow()->IsFullscreen()) | |
| 211 tabstrip_y += kNonClientRestoredExtraThickness; | |
| 212 | |
| 213 int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ? | 197 int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ? |
| 214 (otr_avatar_icon_->bounds().right() + kOTRSideSpacing) : | 198 (otr_avatar_bounds_.right() + kOTRSideSpacing) : |
| 215 NonClientBorderThickness() + kTabStripIndent; | 199 NonClientBorderThickness() + kTabStripIndent; |
| 216 | 200 |
| 217 int tabstrip_width = minimize_button_->x() - tabstrip_x - | 201 int tabstrip_width = minimize_button_->x() - tabstrip_x - |
| 218 (frame_->GetWindow()->IsMaximized() ? | 202 (frame_->GetWindow()->IsMaximized() ? |
| 219 kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing); | 203 kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing); |
| 220 | 204 |
| 221 if (browser_view_->browser()->type() == Browser::TYPE_EXTENSION_APP) { | 205 if (browser_view_->browser()->type() == Browser::TYPE_EXTENSION_APP) { |
| 222 int tabstrip_offset = browser_view_->extension_app_title()->x() + | 206 int tabstrip_offset = browser_view_->extension_app_title()->x() + |
| 223 browser_view_->extension_app_title()->width() + | 207 browser_view_->extension_app_title()->width() + |
| 224 kExtensionAppTabStripLeftSpacing; | 208 kExtensionAppTabStripLeftSpacing; |
| 225 | 209 |
| 226 tabstrip_x += tabstrip_offset; | 210 tabstrip_x += tabstrip_offset; |
| 227 tabstrip_width -= tabstrip_offset; | 211 tabstrip_width -= tabstrip_offset; |
| 228 } | 212 } |
| 229 | 213 |
| 230 return gfx::Rect(tabstrip_x, tabstrip_y, | 214 return gfx::Rect(tabstrip_x, GetHorizontalTabStripVerticalOffset(false), |
| 231 std::max(0, tabstrip_width), tabstrip->GetPreferredHeight()); | 215 std::max(0, tabstrip_width), tabstrip->GetPreferredHeight()); |
| 232 } | 216 } |
| 233 | 217 |
| 218 int OpaqueBrowserFrameView::GetHorizontalTabStripVerticalOffset( |
| 219 bool restored) const { |
| 220 return NonClientTopBorderHeight(restored, true) + ((!restored && |
| 221 (frame_->GetWindow()->IsMaximized() || |
| 222 frame_->GetWindow()->IsFullscreen())) ? |
| 223 0 : kNonClientRestoredExtraThickness); |
| 224 } |
| 225 |
| 234 void OpaqueBrowserFrameView::UpdateThrobber(bool running) { | 226 void OpaqueBrowserFrameView::UpdateThrobber(bool running) { |
| 235 if (window_icon_) | 227 if (window_icon_) |
| 236 window_icon_->Update(); | 228 window_icon_->Update(); |
| 237 } | 229 } |
| 238 | 230 |
| 239 gfx::Size OpaqueBrowserFrameView::GetMinimumSize() { | 231 gfx::Size OpaqueBrowserFrameView::GetMinimumSize() { |
| 240 gfx::Size min_size(browser_view_->GetMinimumSize()); | 232 gfx::Size min_size(browser_view_->GetMinimumSize()); |
| 241 int border_thickness = NonClientBorderThickness(); | 233 int border_thickness = NonClientBorderThickness(); |
| 242 min_size.Enlarge(2 * border_thickness, | 234 min_size.Enlarge(2 * border_thickness, |
| 243 NonClientTopBorderHeight() + border_thickness); | 235 NonClientTopBorderHeight(false, false) + border_thickness); |
| 244 | 236 |
| 245 views::WindowDelegate* d = frame_->GetWindow()->GetDelegate(); | 237 views::WindowDelegate* d = frame_->GetWindow()->GetDelegate(); |
| 246 int min_titlebar_width = (2 * FrameBorderThickness()) + kIconLeftSpacing + | 238 int min_titlebar_width = (2 * FrameBorderThickness(false)) + |
| 239 kIconLeftSpacing + |
| 247 (d->ShouldShowWindowIcon() ? (IconSize() + kTitleLogoSpacing) : 0); | 240 (d->ShouldShowWindowIcon() ? (IconSize() + kTitleLogoSpacing) : 0); |
| 248 #if !defined(OS_CHROMEOS) | 241 #if !defined(OS_CHROMEOS) |
| 249 min_titlebar_width += | 242 min_titlebar_width += |
| 250 minimize_button_->GetMinimumSize().width() + | 243 minimize_button_->GetMinimumSize().width() + |
| 251 restore_button_->GetMinimumSize().width() + | 244 restore_button_->GetMinimumSize().width() + |
| 252 close_button_->GetMinimumSize().width(); | 245 close_button_->GetMinimumSize().width(); |
| 253 #endif | 246 #endif |
| 254 min_size.set_width(std::max(min_size.width(), min_titlebar_width)); | 247 min_size.set_width(std::max(min_size.width(), min_titlebar_width)); |
| 255 return min_size; | 248 return min_size; |
| 256 } | 249 } |
| 257 | 250 |
| 258 /////////////////////////////////////////////////////////////////////////////// | 251 /////////////////////////////////////////////////////////////////////////////// |
| 259 // OpaqueBrowserFrameView, views::NonClientFrameView implementation: | 252 // OpaqueBrowserFrameView, views::NonClientFrameView implementation: |
| 260 | 253 |
| 261 gfx::Rect OpaqueBrowserFrameView::GetBoundsForClientView() const { | 254 gfx::Rect OpaqueBrowserFrameView::GetBoundsForClientView() const { |
| 262 return client_view_bounds_; | 255 return client_view_bounds_; |
| 263 } | 256 } |
| 264 | 257 |
| 265 bool OpaqueBrowserFrameView::AlwaysUseNativeFrame() const { | 258 bool OpaqueBrowserFrameView::AlwaysUseNativeFrame() const { |
| 266 return frame_->AlwaysUseNativeFrame(); | 259 return frame_->AlwaysUseNativeFrame(); |
| 267 } | 260 } |
| 268 | 261 |
| 269 bool OpaqueBrowserFrameView::AlwaysUseCustomFrame() const { | 262 bool OpaqueBrowserFrameView::AlwaysUseCustomFrame() const { |
| 270 return true; | 263 return true; |
| 271 } | 264 } |
| 272 | 265 |
| 273 gfx::Rect OpaqueBrowserFrameView::GetWindowBoundsForClientBounds( | 266 gfx::Rect OpaqueBrowserFrameView::GetWindowBoundsForClientBounds( |
| 274 const gfx::Rect& client_bounds) const { | 267 const gfx::Rect& client_bounds) const { |
| 275 int top_height = NonClientTopBorderHeight(); | 268 int top_height = NonClientTopBorderHeight(false, false); |
| 276 int border_thickness = NonClientBorderThickness(); | 269 int border_thickness = NonClientBorderThickness(); |
| 277 return gfx::Rect(std::max(0, client_bounds.x() - border_thickness), | 270 return gfx::Rect(std::max(0, client_bounds.x() - border_thickness), |
| 278 std::max(0, client_bounds.y() - top_height), | 271 std::max(0, client_bounds.y() - top_height), |
| 279 client_bounds.width() + (2 * border_thickness), | 272 client_bounds.width() + (2 * border_thickness), |
| 280 client_bounds.height() + top_height + border_thickness); | 273 client_bounds.height() + top_height + border_thickness); |
| 281 } | 274 } |
| 282 | 275 |
| 283 int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) { | 276 int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) { |
| 284 if (!bounds().Contains(point)) | 277 if (!bounds().Contains(point)) |
| 285 return HTNOWHERE; | 278 return HTNOWHERE; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 if (window->IsFullscreen()) | 347 if (window->IsFullscreen()) |
| 355 return; // Nothing is visible, so don't bother to paint. | 348 return; // Nothing is visible, so don't bother to paint. |
| 356 | 349 |
| 357 if (window->IsMaximized()) | 350 if (window->IsMaximized()) |
| 358 PaintMaximizedFrameBorder(canvas); | 351 PaintMaximizedFrameBorder(canvas); |
| 359 else | 352 else |
| 360 PaintRestoredFrameBorder(canvas); | 353 PaintRestoredFrameBorder(canvas); |
| 361 PaintTitleBar(canvas); | 354 PaintTitleBar(canvas); |
| 362 if (browser_view_->IsToolbarVisible()) | 355 if (browser_view_->IsToolbarVisible()) |
| 363 PaintToolbarBackground(canvas); | 356 PaintToolbarBackground(canvas); |
| 357 if (browser_view_->ShouldShowOffTheRecordAvatar()) |
| 358 PaintOTRAvatar(canvas); |
| 364 if (!window->IsMaximized()) | 359 if (!window->IsMaximized()) |
| 365 PaintRestoredClientEdge(canvas); | 360 PaintRestoredClientEdge(canvas); |
| 366 } | 361 } |
| 367 | 362 |
| 368 void OpaqueBrowserFrameView::PaintChildren(gfx::Canvas* canvas) { | |
| 369 if (!browser_view_->UseVerticalTabs() || !otr_avatar_icon_->IsVisible()) { | |
| 370 View::PaintChildren(canvas); | |
| 371 return; | |
| 372 } | |
| 373 | |
| 374 // The otr icon is clipped for side tabs. | |
| 375 for (int i = 0, count = GetChildViewCount(); i < count; ++i) { | |
| 376 View* child = GetChildViewAt(i); | |
| 377 if (!child) { | |
| 378 NOTREACHED() << "Should not have a NULL child View for index in bounds"; | |
| 379 continue; | |
| 380 } | |
| 381 if (child == otr_avatar_icon_) { | |
| 382 canvas->Save(); | |
| 383 canvas->ClipRectInt(0, 2, width(), otr_avatar_icon_->height() - 10); | |
| 384 child->ProcessPaint(canvas); | |
| 385 canvas->Restore(); | |
| 386 } else { | |
| 387 child->ProcessPaint(canvas); | |
| 388 } | |
| 389 } | |
| 390 } | |
| 391 | |
| 392 void OpaqueBrowserFrameView::Layout() { | 363 void OpaqueBrowserFrameView::Layout() { |
| 393 LayoutWindowControls(); | 364 LayoutWindowControls(); |
| 394 LayoutTitleBar(); | 365 LayoutTitleBar(); |
| 395 LayoutOTRAvatar(); | 366 LayoutOTRAvatar(); |
| 396 client_view_bounds_ = CalculateClientAreaBounds(width(), height()); | 367 client_view_bounds_ = CalculateClientAreaBounds(width(), height()); |
| 397 } | 368 } |
| 398 | 369 |
| 399 bool OpaqueBrowserFrameView::HitTest(const gfx::Point& l) const { | 370 bool OpaqueBrowserFrameView::HitTest(const gfx::Point& l) const { |
| 400 // If the point is outside the bounds of the client area, claim it. | 371 // If the point is outside the bounds of the client area, claim it. |
| 401 bool in_nonclient = NonClientFrameView::HitTest(l); | 372 bool in_nonclient = NonClientFrameView::HitTest(l); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 return current_tab ? current_tab->is_loading() : false; | 427 return current_tab ? current_tab->is_loading() : false; |
| 457 } | 428 } |
| 458 | 429 |
| 459 SkBitmap OpaqueBrowserFrameView::GetFavIconForTabIconView() { | 430 SkBitmap OpaqueBrowserFrameView::GetFavIconForTabIconView() { |
| 460 return frame_->GetWindow()->GetDelegate()->GetWindowIcon(); | 431 return frame_->GetWindow()->GetDelegate()->GetWindowIcon(); |
| 461 } | 432 } |
| 462 | 433 |
| 463 /////////////////////////////////////////////////////////////////////////////// | 434 /////////////////////////////////////////////////////////////////////////////// |
| 464 // OpaqueBrowserFrameView, private: | 435 // OpaqueBrowserFrameView, private: |
| 465 | 436 |
| 466 int OpaqueBrowserFrameView::FrameBorderThickness() const { | 437 int OpaqueBrowserFrameView::FrameBorderThickness(bool restored) const { |
| 467 views::Window* window = frame_->GetWindow(); | 438 views::Window* window = frame_->GetWindow(); |
| 468 return (window->IsMaximized() || window->IsFullscreen()) ? | 439 return (!restored && (window->IsMaximized() || window->IsFullscreen())) ? |
| 469 0 : kFrameBorderThickness; | 440 0 : kFrameBorderThickness; |
| 470 } | 441 } |
| 471 | 442 |
| 472 int OpaqueBrowserFrameView::TopResizeHeight() const { | 443 int OpaqueBrowserFrameView::TopResizeHeight() const { |
| 473 return FrameBorderThickness() - kTopResizeAdjust; | 444 return FrameBorderThickness(false) - kTopResizeAdjust; |
| 474 } | 445 } |
| 475 | 446 |
| 476 int OpaqueBrowserFrameView::NonClientBorderThickness() const { | 447 int OpaqueBrowserFrameView::NonClientBorderThickness() const { |
| 477 // When we fill the screen, we don't show a client edge. | 448 // When we fill the screen, we don't show a client edge. |
| 478 views::Window* window = frame_->GetWindow(); | 449 views::Window* window = frame_->GetWindow(); |
| 479 return FrameBorderThickness() + | 450 return FrameBorderThickness(false) + |
| 480 ((window->IsMaximized() || window->IsFullscreen()) ? | 451 ((window->IsMaximized() || window->IsFullscreen()) ? |
| 481 0 : kClientEdgeThickness); | 452 0 : kClientEdgeThickness); |
| 482 } | 453 } |
| 483 | 454 |
| 484 int OpaqueBrowserFrameView::NonClientTopBorderHeight() const { | 455 int OpaqueBrowserFrameView::NonClientTopBorderHeight( |
| 456 bool restored, |
| 457 bool ignore_vertical_tabs) const { |
| 485 views::Window* window = frame_->GetWindow(); | 458 views::Window* window = frame_->GetWindow(); |
| 486 if (window->GetDelegate()->ShouldShowWindowTitle()) { | 459 if (window->GetDelegate()->ShouldShowWindowTitle() || |
| 487 return std::max(FrameBorderThickness() + IconSize(), | 460 (browser_view_->IsTabStripVisible() && !ignore_vertical_tabs && |
| 488 CaptionButtonY() + kCaptionButtonHeightWithPadding) + | 461 browser_view_->UseVerticalTabs())) { |
| 489 TitlebarBottomThickness(); | 462 return std::max(FrameBorderThickness(restored) + IconSize(), |
| 463 CaptionButtonY(restored) + kCaptionButtonHeightWithPadding) + |
| 464 TitlebarBottomThickness(restored); |
| 490 } | 465 } |
| 491 | 466 |
| 492 if (browser_view_->IsTabStripVisible() && browser_view_->UseVerticalTabs()) { | 467 return FrameBorderThickness(restored) - |
| 493 return CaptionButtonY() + minimize_button_->GetPreferredSize().height() + | 468 ((browser_view_->IsTabStripVisible() && !restored && |
| 494 kVerticalTabPadding; | 469 window->IsMaximized()) ? kTabstripTopShadowThickness : 0); |
| 495 } | |
| 496 | |
| 497 return FrameBorderThickness() - | |
| 498 ((browser_view_->IsTabStripVisible() && window->IsMaximized()) ? | |
| 499 kTabstripTopShadowThickness : 0); | |
| 500 } | 470 } |
| 501 | 471 |
| 502 int OpaqueBrowserFrameView::CaptionButtonY() const { | 472 int OpaqueBrowserFrameView::CaptionButtonY(bool restored) const { |
| 503 // Maximized buttons start at window top so that even if their images aren't | 473 // Maximized buttons start at window top so that even if their images aren't |
| 504 // drawn flush with the screen edge, they still obey Fitts' Law. | 474 // drawn flush with the screen edge, they still obey Fitts' Law. |
| 505 return frame_->GetWindow()->IsMaximized() ? | 475 return (!restored && frame_->GetWindow()->IsMaximized()) ? |
| 506 FrameBorderThickness() : kFrameShadowThickness; | 476 FrameBorderThickness(false) : kFrameShadowThickness; |
| 507 } | 477 } |
| 508 | 478 |
| 509 int OpaqueBrowserFrameView::TitlebarBottomThickness() const { | 479 int OpaqueBrowserFrameView::TitlebarBottomThickness(bool restored) const { |
| 510 // When a toolbar is edging the titlebar, it draws its own bottom edge. | |
| 511 if (browser_view_->IsToolbarVisible()) | |
| 512 return 0; | |
| 513 | |
| 514 return kTitlebarTopAndBottomEdgeThickness + | 480 return kTitlebarTopAndBottomEdgeThickness + |
| 515 (frame_->GetWindow()->IsMaximized() ? 0 : kClientEdgeThickness); | 481 ((!restored && frame_->GetWindow()->IsMaximized()) ? |
| 482 0 : kClientEdgeThickness); |
| 516 } | 483 } |
| 517 | 484 |
| 518 int OpaqueBrowserFrameView::IconSize() const { | 485 int OpaqueBrowserFrameView::IconSize() const { |
| 519 #if defined(OS_WIN) | 486 #if defined(OS_WIN) |
| 520 // This metric scales up if either the titlebar height or the titlebar font | 487 // This metric scales up if either the titlebar height or the titlebar font |
| 521 // size are increased. | 488 // size are increased. |
| 522 return GetSystemMetrics(SM_CYSMICON); | 489 return GetSystemMetrics(SM_CYSMICON); |
| 523 #else | 490 #else |
| 524 return std::max(BrowserFrame::GetTitleFont().height(), kIconMinimumSize); | 491 return std::max(BrowserFrame::GetTitleFont().height(), kIconMinimumSize); |
| 525 #endif | 492 #endif |
| 526 } | 493 } |
| 527 | 494 |
| 528 gfx::Rect OpaqueBrowserFrameView::IconBounds() const { | 495 gfx::Rect OpaqueBrowserFrameView::IconBounds() const { |
| 529 int size = IconSize(); | 496 int size = IconSize(); |
| 530 int frame_thickness = FrameBorderThickness(); | 497 int frame_thickness = FrameBorderThickness(false); |
| 531 int y; | 498 int y; |
| 532 views::WindowDelegate* d = frame_->GetWindow()->GetDelegate(); | 499 views::WindowDelegate* d = frame_->GetWindow()->GetDelegate(); |
| 533 if (d->ShouldShowWindowIcon() || d->ShouldShowWindowTitle()) { | 500 if (d->ShouldShowWindowIcon() || d->ShouldShowWindowTitle()) { |
| 534 // Our frame border has a different "3D look" than Windows'. Theirs has a | 501 // Our frame border has a different "3D look" than Windows'. Theirs has a |
| 535 // more complex gradient on the top that they push their icon/title below; | 502 // more complex gradient on the top that they push their icon/title below; |
| 536 // then the maximized window cuts this off and the icon/title are centered | 503 // then the maximized window cuts this off and the icon/title are centered |
| 537 // in the remaining space. Because the apparent shape of our border is | 504 // in the remaining space. Because the apparent shape of our border is |
| 538 // simpler, using the same positioning makes things look slightly uncentered | 505 // simpler, using the same positioning makes things look slightly uncentered |
| 539 // with restored windows, so when the window is restored, instead of | 506 // with restored windows, so when the window is restored, instead of |
| 540 // calculating the remaining space from below the frame border, we calculate | 507 // calculating the remaining space from below the frame border, we calculate |
| 541 // from below the 3D edge. | 508 // from below the 3D edge. |
| 542 int unavailable_px_at_top = frame_->GetWindow()->IsMaximized() ? | 509 int unavailable_px_at_top = frame_->GetWindow()->IsMaximized() ? |
| 543 frame_thickness : kTitlebarTopAndBottomEdgeThickness; | 510 frame_thickness : kTitlebarTopAndBottomEdgeThickness; |
| 544 // When the icon is shorter than the minimum space we reserve for the | 511 // When the icon is shorter than the minimum space we reserve for the |
| 545 // caption button, we vertically center it. We want to bias rounding to put | 512 // caption button, we vertically center it. We want to bias rounding to put |
| 546 // extra space above the icon, since the 3D edge (+ client edge, for | 513 // extra space above the icon, since the 3D edge (+ client edge, for |
| 547 // restored windows) below looks (to the eye) more like additional space | 514 // restored windows) below looks (to the eye) more like additional space |
| 548 // than does the 3D edge (or nothing at all, for maximized windows) above; | 515 // than does the 3D edge (or nothing at all, for maximized windows) above; |
| 549 // hence the +1. | 516 // hence the +1. |
| 550 y = unavailable_px_at_top + (NonClientTopBorderHeight() - | 517 y = unavailable_px_at_top + (NonClientTopBorderHeight(false, false) - |
| 551 unavailable_px_at_top - size - TitlebarBottomThickness() + 1) / 2; | 518 unavailable_px_at_top - size - TitlebarBottomThickness(false) + 1) / 2; |
| 552 } else { | 519 } else { |
| 553 // For "browser mode" windows, we use the native positioning, which is just | 520 // For "browser mode" windows, we use the native positioning, which is just |
| 554 // below the top frame border. | 521 // below the top frame border. |
| 555 y = frame_thickness; | 522 y = frame_thickness; |
| 556 } | 523 } |
| 557 return gfx::Rect(frame_thickness + kIconLeftSpacing, y, size, size); | 524 return gfx::Rect(frame_thickness + kIconLeftSpacing, y, size, size); |
| 558 } | 525 } |
| 559 | 526 |
| 560 void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) { | 527 void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) { |
| 561 ThemeProvider* tp = GetThemeProvider(); | 528 ThemeProvider* tp = GetThemeProvider(); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 height() - top_left_height - bottom_left_corner->height()); | 641 height() - top_left_height - bottom_left_corner->height()); |
| 675 } | 642 } |
| 676 | 643 |
| 677 | 644 |
| 678 void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) { | 645 void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) { |
| 679 ThemeProvider* tp = GetThemeProvider(); | 646 ThemeProvider* tp = GetThemeProvider(); |
| 680 views::Window* window = frame_->GetWindow(); | 647 views::Window* window = frame_->GetWindow(); |
| 681 | 648 |
| 682 // Window frame mode and color | 649 // Window frame mode and color |
| 683 SkBitmap* theme_frame; | 650 SkBitmap* theme_frame; |
| 684 int y = 0; | |
| 685 // Never theme app and popup windows. | 651 // Never theme app and popup windows. |
| 686 if (!browser_view_->IsBrowserTypeNormal()) { | 652 if (!browser_view_->IsBrowserTypeNormal()) { |
| 687 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 653 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 688 theme_frame = rb.GetBitmapNamed(ShouldPaintAsActive() ? | 654 theme_frame = rb.GetBitmapNamed(ShouldPaintAsActive() ? |
| 689 IDR_FRAME : IDR_FRAME_INACTIVE); | 655 IDR_FRAME : IDR_FRAME_INACTIVE); |
| 690 } else if (!browser_view_->IsOffTheRecord()) { | 656 } else if (!browser_view_->IsOffTheRecord()) { |
| 691 theme_frame = tp->GetBitmapNamed(ShouldPaintAsActive() ? | 657 theme_frame = tp->GetBitmapNamed(ShouldPaintAsActive() ? |
| 692 IDR_THEME_FRAME : IDR_THEME_FRAME_INACTIVE); | 658 IDR_THEME_FRAME : IDR_THEME_FRAME_INACTIVE); |
| 693 #if defined(OS_CHROMEOS) | |
| 694 // TODO:(oshima): gtk based CHROMEOS is using non custom frame | |
| 695 // mode which does this adjustment. This should be removed | |
| 696 // once it's fully migrated to views. -1 is due to the layout | |
| 697 // difference between views and gtk and will be removed. | |
| 698 // See http://crbug.com/28580. | |
| 699 y = -kCustomFrameBackgroundVerticalOffset - 1; | |
| 700 #endif | |
| 701 } else { | 659 } else { |
| 702 theme_frame = tp->GetBitmapNamed(ShouldPaintAsActive() ? | 660 theme_frame = tp->GetBitmapNamed(ShouldPaintAsActive() ? |
| 703 IDR_THEME_FRAME_INCOGNITO : IDR_THEME_FRAME_INCOGNITO_INACTIVE); | 661 IDR_THEME_FRAME_INCOGNITO : IDR_THEME_FRAME_INCOGNITO_INACTIVE); |
| 704 #if defined(OS_CHROMEOS) | |
| 705 y = -kCustomFrameBackgroundVerticalOffset - 1; | |
| 706 #endif | |
| 707 } | 662 } |
| 708 // Draw the theme frame. | 663 // Draw the theme frame. It must be aligned with the tabstrip as if we were |
| 709 canvas->TileImageInt(*theme_frame, 0, y, width(), theme_frame->height()); | 664 // in restored mode. Note that the top of the tabstrip is |
| 665 // kTabstripTopShadowThickness px off the top of the screen. |
| 666 int theme_background_y = -(GetHorizontalTabStripVerticalOffset(true) + |
| 667 kTabstripTopShadowThickness); |
| 668 canvas->TileImageInt(*theme_frame, 0, theme_background_y, width(), |
| 669 theme_frame->height()); |
| 710 | 670 |
| 711 // Draw the theme frame overlay | 671 // Draw the theme frame overlay |
| 712 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && | 672 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && |
| 713 browser_view_->IsBrowserTypeNormal()) { | 673 browser_view_->IsBrowserTypeNormal()) { |
| 714 SkBitmap* theme_overlay = tp->GetBitmapNamed(ShouldPaintAsActive() ? | 674 SkBitmap* theme_overlay = tp->GetBitmapNamed(ShouldPaintAsActive() ? |
| 715 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE); | 675 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE); |
| 716 canvas->DrawBitmapInt(*theme_overlay, 0, 0); | 676 canvas->DrawBitmapInt(*theme_overlay, 0, theme_background_y); |
| 717 } | 677 } |
| 718 | 678 |
| 719 if (!browser_view_->IsToolbarVisible()) { | 679 if (!browser_view_->IsToolbarVisible()) { |
| 720 // There's no toolbar to edge the frame border, so we need to draw a bottom | 680 // There's no toolbar to edge the frame border, so we need to draw a bottom |
| 721 // edge. The graphic we use for this has a built in client edge, so we clip | 681 // edge. The graphic we use for this has a built in client edge, so we clip |
| 722 // it off the bottom. | 682 // it off the bottom. |
| 723 SkBitmap* top_center = | 683 SkBitmap* top_center = |
| 724 tp->GetBitmapNamed(IDR_APP_TOP_CENTER); | 684 tp->GetBitmapNamed(IDR_APP_TOP_CENTER); |
| 725 int edge_height = top_center->height() - kClientEdgeThickness; | 685 int edge_height = top_center->height() - kClientEdgeThickness; |
| 726 canvas->TileImageInt(*top_center, 0, | 686 canvas->TileImageInt(*top_center, 0, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 738 /* TODO(pkasting): If this window is active, we should also draw a drop | 698 /* TODO(pkasting): If this window is active, we should also draw a drop |
| 739 * shadow on the title. This is tricky, because we don't want to hardcode a | 699 * shadow on the title. This is tricky, because we don't want to hardcode a |
| 740 * shadow color (since we want to work with various themes), but we can't | 700 * shadow color (since we want to work with various themes), but we can't |
| 741 * alpha-blend either (since the Windows text APIs don't really do this). | 701 * alpha-blend either (since the Windows text APIs don't really do this). |
| 742 * So we'd need to sample the background color at the right location and | 702 * So we'd need to sample the background color at the right location and |
| 743 * synthesize a good shadow color. */ | 703 * synthesize a good shadow color. */ |
| 744 } | 704 } |
| 745 } | 705 } |
| 746 | 706 |
| 747 void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) { | 707 void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) { |
| 748 gfx::Rect toolbar_bounds = GetViewBounds(browser_view_->toolbar(), this); | 708 gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds()); |
| 749 if (toolbar_bounds.IsEmpty()) | 709 if (toolbar_bounds.IsEmpty()) |
| 750 return; | 710 return; |
| 711 gfx::Point toolbar_origin(toolbar_bounds.origin()); |
| 712 ConvertPointToView(browser_view_, this, &toolbar_origin); |
| 713 toolbar_bounds.set_origin(toolbar_origin); |
| 751 | 714 |
| 752 int x, y, w, h; | 715 int x = toolbar_bounds.x(); |
| 716 int w = toolbar_bounds.width(); |
| 717 int y, h; |
| 753 if (browser_view_->UseVerticalTabs()) { | 718 if (browser_view_->UseVerticalTabs()) { |
| 754 gfx::Rect tabstrip_bounds = GetViewBounds(browser_view_->tabstrip(), this); | 719 gfx::Point tabstrip_origin(browser_view_->tabstrip()->bounds().origin()); |
| 755 x = tabstrip_bounds.x(); | 720 ConvertPointToView(browser_view_, this, &tabstrip_origin); |
| 756 w = toolbar_bounds.right() - x; | 721 y = tabstrip_origin.y() - kVerticalTabBorderInset; |
| 757 y = tabstrip_bounds.y() - kVerticalTabBorderInset; | |
| 758 h = toolbar_bounds.bottom() - y; | 722 h = toolbar_bounds.bottom() - y; |
| 759 } else { | 723 } else { |
| 760 x = toolbar_bounds.x(); | |
| 761 w = toolbar_bounds.width(); | |
| 762 y = toolbar_bounds.y(); | 724 y = toolbar_bounds.y(); |
| 763 h = toolbar_bounds.bottom(); | 725 h = toolbar_bounds.bottom(); |
| 764 } | 726 } |
| 765 | 727 |
| 766 // Gross hack: We split the toolbar images into two pieces, since sometimes | 728 // Gross hack: We split the toolbar images into two pieces, since sometimes |
| 767 // (popup mode) the toolbar isn't tall enough to show the whole image. The | 729 // (popup mode) the toolbar isn't tall enough to show the whole image. The |
| 768 // split happens between the top shadow section and the bottom gradient | 730 // split happens between the top shadow section and the bottom gradient |
| 769 // section so that we never break the gradient. | 731 // section so that we never break the gradient. |
| 770 int split_point = kFrameShadowThickness * 2; | 732 int split_point = kFrameShadowThickness * 2; |
| 771 int bottom_y = y + split_point; | 733 int bottom_y = y + split_point; |
| 772 ThemeProvider* tp = GetThemeProvider(); | 734 ThemeProvider* tp = GetThemeProvider(); |
| 773 SkBitmap* toolbar_left = tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER); | 735 SkBitmap* toolbar_left = tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER); |
| 774 int bottom_edge_height = std::min(toolbar_left->height(), h) - split_point; | 736 int bottom_edge_height = std::min(toolbar_left->height(), h) - split_point; |
| 775 | 737 |
| 776 // Split our canvas out so we can mask out the corners of the toolbar | 738 // Split our canvas out so we can mask out the corners of the toolbar |
| 777 // without masking out the frame. | 739 // without masking out the frame. |
| 778 canvas->SaveLayerAlpha( | 740 canvas->SaveLayerAlpha( |
| 779 255, gfx::Rect(x - kClientEdgeThickness, y, w + kClientEdgeThickness * 3, | 741 255, gfx::Rect(x - kClientEdgeThickness, y, w + kClientEdgeThickness * 3, |
| 780 h)); | 742 h)); |
| 781 canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); | 743 canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); |
| 782 | 744 |
| 783 SkColor theme_toolbar_color = | 745 SkColor theme_toolbar_color = |
| 784 tp->GetColor(BrowserThemeProvider::COLOR_TOOLBAR); | 746 tp->GetColor(BrowserThemeProvider::COLOR_TOOLBAR); |
| 785 canvas->FillRectInt(theme_toolbar_color, x, bottom_y, w, bottom_edge_height); | 747 canvas->FillRectInt(theme_toolbar_color, x, bottom_y, w, bottom_edge_height); |
| 786 | 748 |
| 749 // Tile the toolbar image starting at the frame edge on the left and where the |
| 750 // horizontal tabstrip is (or would be) on the top. |
| 787 SkBitmap* theme_toolbar = tp->GetBitmapNamed(IDR_THEME_TOOLBAR); | 751 SkBitmap* theme_toolbar = tp->GetBitmapNamed(IDR_THEME_TOOLBAR); |
| 788 int strip_height = browser_view_->GetTabStripHeight(); | 752 canvas->TileImageInt(*theme_toolbar, x, |
| 789 canvas->TileImageInt(*theme_toolbar, x - kClientEdgeThickness, | 753 bottom_y - GetHorizontalTabStripVerticalOffset(false), x, |
| 790 strip_height - kFrameShadowThickness, x - kClientEdgeThickness, bottom_y, | 754 bottom_y, w, theme_toolbar->height()); |
| 791 w + (2 * kClientEdgeThickness), theme_toolbar->height()); | |
| 792 | 755 |
| 793 // Draw rounded corners for the tab. | 756 // Draw rounded corners for the tab. |
| 794 SkBitmap* toolbar_left_mask = | 757 SkBitmap* toolbar_left_mask = |
| 795 tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER_MASK); | 758 tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER_MASK); |
| 796 SkBitmap* toolbar_right_mask = | 759 SkBitmap* toolbar_right_mask = |
| 797 tp->GetBitmapNamed(IDR_CONTENT_TOP_RIGHT_CORNER_MASK); | 760 tp->GetBitmapNamed(IDR_CONTENT_TOP_RIGHT_CORNER_MASK); |
| 798 | 761 |
| 799 // We mask out the corners by using the DestinationIn transfer mode, | 762 // We mask out the corners by using the DestinationIn transfer mode, |
| 800 // which keeps the RGB pixels from the destination and the alpha from | 763 // which keeps the RGB pixels from the destination and the alpha from |
| 801 // the source. | 764 // the source. |
| 802 SkPaint paint; | 765 SkPaint paint; |
| 803 paint.setXfermodeMode(SkXfermode::kDstIn_Mode); | 766 paint.setXfermodeMode(SkXfermode::kDstIn_Mode); |
| 804 | 767 |
| 805 // Mask the left edge. | 768 // Mask the left edge. |
| 806 int left_x = x - kContentEdgeShadowThickness; | 769 int left_x = x - kContentEdgeShadowThickness; |
| 807 canvas->DrawBitmapInt(*toolbar_left_mask, 0, 0, toolbar_left_mask->width(), | 770 canvas->DrawBitmapInt(*toolbar_left_mask, 0, 0, toolbar_left_mask->width(), |
| 808 split_point, left_x, y, toolbar_left_mask->width(), | 771 split_point, left_x, y, toolbar_left_mask->width(), |
| 809 split_point, false, paint); | 772 split_point, false, paint); |
| 810 canvas->DrawBitmapInt(*toolbar_left_mask, 0, | 773 canvas->DrawBitmapInt(*toolbar_left_mask, 0, |
| 811 toolbar_left_mask->height() - bottom_edge_height, | 774 toolbar_left_mask->height() - bottom_edge_height, |
| 812 toolbar_left_mask->width(), bottom_edge_height, left_x, bottom_y, | 775 toolbar_left_mask->width(), bottom_edge_height, left_x, bottom_y, |
| 813 toolbar_left_mask->width(), bottom_edge_height, false, paint); | 776 toolbar_left_mask->width(), bottom_edge_height, false, paint); |
| 814 | 777 |
| 815 // Mask the right edge. | 778 // Mask the right edge. |
| 816 int right_x = x + w - toolbar_right_mask->width() + kClientEdgeThickness + | 779 int right_x = |
| 817 kContentEdgeShadowThickness; | 780 x + w - toolbar_right_mask->width() + kContentEdgeShadowThickness; |
| 818 canvas->DrawBitmapInt(*toolbar_right_mask, 0, 0, toolbar_right_mask->width(), | 781 canvas->DrawBitmapInt(*toolbar_right_mask, 0, 0, toolbar_right_mask->width(), |
| 819 split_point, right_x, y, toolbar_right_mask->width(), | 782 split_point, right_x, y, toolbar_right_mask->width(), |
| 820 split_point, false, paint); | 783 split_point, false, paint); |
| 821 canvas->DrawBitmapInt(*toolbar_right_mask, 0, | 784 canvas->DrawBitmapInt(*toolbar_right_mask, 0, |
| 822 toolbar_right_mask->height() - bottom_edge_height, | 785 toolbar_right_mask->height() - bottom_edge_height, |
| 823 toolbar_right_mask->width(), bottom_edge_height, right_x, bottom_y, | 786 toolbar_right_mask->width(), bottom_edge_height, right_x, bottom_y, |
| 824 toolbar_right_mask->width(), bottom_edge_height, false, paint); | 787 toolbar_right_mask->width(), bottom_edge_height, false, paint); |
| 825 canvas->Restore(); | 788 canvas->Restore(); |
| 826 | 789 |
| 827 canvas->DrawBitmapInt(*toolbar_left, 0, 0, toolbar_left->width(), split_point, | 790 canvas->DrawBitmapInt(*toolbar_left, 0, 0, toolbar_left->width(), split_point, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 840 SkBitmap* toolbar_right = tp->GetBitmapNamed(IDR_CONTENT_TOP_RIGHT_CORNER); | 803 SkBitmap* toolbar_right = tp->GetBitmapNamed(IDR_CONTENT_TOP_RIGHT_CORNER); |
| 841 canvas->DrawBitmapInt(*toolbar_right, 0, 0, toolbar_right->width(), | 804 canvas->DrawBitmapInt(*toolbar_right, 0, 0, toolbar_right->width(), |
| 842 split_point, right_x, y, toolbar_right->width(), split_point, false); | 805 split_point, right_x, y, toolbar_right->width(), split_point, false); |
| 843 canvas->DrawBitmapInt(*toolbar_right, 0, | 806 canvas->DrawBitmapInt(*toolbar_right, 0, |
| 844 toolbar_right->height() - bottom_edge_height, toolbar_right->width(), | 807 toolbar_right->height() - bottom_edge_height, toolbar_right->width(), |
| 845 bottom_edge_height, right_x, bottom_y, toolbar_right->width(), | 808 bottom_edge_height, right_x, bottom_y, toolbar_right->width(), |
| 846 bottom_edge_height, false); | 809 bottom_edge_height, false); |
| 847 | 810 |
| 848 // Draw the content/toolbar separator. | 811 // Draw the content/toolbar separator. |
| 849 canvas->FillRectInt(ResourceBundle::toolbar_separator_color, | 812 canvas->FillRectInt(ResourceBundle::toolbar_separator_color, |
| 850 toolbar_bounds.x(), toolbar_bounds.bottom() - kClientEdgeThickness, | 813 x + kClientEdgeThickness, toolbar_bounds.bottom() - kClientEdgeThickness, |
| 851 toolbar_bounds.width(), kClientEdgeThickness); | 814 w - (2 * kClientEdgeThickness), kClientEdgeThickness); |
| 815 } |
| 816 |
| 817 void OpaqueBrowserFrameView::PaintOTRAvatar(gfx::Canvas* canvas) { |
| 818 // In RTL mode, the avatar icon should be looking the opposite direction. |
| 819 canvas->Save(); |
| 820 if (base::i18n::IsRTL()) { |
| 821 canvas->TranslateInt(width(), 0); |
| 822 canvas->ScaleInt(-1, 1); |
| 823 } |
| 824 |
| 825 SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon(); |
| 826 int w = otr_avatar_bounds_.width(); |
| 827 int h = otr_avatar_bounds_.height(); |
| 828 canvas->DrawBitmapInt(otr_avatar_icon, 0, |
| 829 // Bias the rounding to select a region that's lower rather than higher, |
| 830 // as the shadows at the image top mean the apparent center is below the |
| 831 // real center. |
| 832 ((otr_avatar_icon.height() - otr_avatar_bounds_.height()) + 1) / 2, w, h, |
| 833 otr_avatar_bounds_.x(), otr_avatar_bounds_.y(), w, h, false); |
| 834 |
| 835 canvas->Restore(); |
| 852 } | 836 } |
| 853 | 837 |
| 854 void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { | 838 void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { |
| 855 ThemeProvider* tp = GetThemeProvider(); | 839 ThemeProvider* tp = GetThemeProvider(); |
| 856 int client_area_top = frame_->GetWindow()->GetClientView()->y(); | 840 int client_area_top = frame_->GetWindow()->GetClientView()->y(); |
| 841 int image_top = client_area_top; |
| 857 | 842 |
| 858 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); | 843 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); |
| 859 SkColor toolbar_color = tp->GetColor(BrowserThemeProvider::COLOR_TOOLBAR); | 844 SkColor toolbar_color = tp->GetColor(BrowserThemeProvider::COLOR_TOOLBAR); |
| 860 | 845 |
| 861 if (browser_view_->IsToolbarVisible()) { | 846 if (browser_view_->IsToolbarVisible()) { |
| 862 // The client edges start below the toolbar or its corner images, whichever | 847 // The client edge images always start below the toolbar corner images. The |
| 863 // is shorter. | 848 // client edge filled rects start there or at the bottom of the tooolbar, |
| 849 // whichever is shorter. |
| 864 gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds()); | 850 gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds()); |
| 865 client_area_top += browser_view_->GetToolbarBounds().y() + | 851 image_top += toolbar_bounds.y() + |
| 866 std::min(tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height(), | 852 tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height(); |
| 867 toolbar_bounds.height()); | 853 client_area_top = std::min(image_top, |
| 868 if (browser_view_->UseVerticalTabs()) | 854 client_area_top + toolbar_bounds.bottom() - kClientEdgeThickness); |
| 855 if (browser_view_->UseVerticalTabs()) { |
| 869 client_area_top -= kVerticalTabBorderInset; | 856 client_area_top -= kVerticalTabBorderInset; |
| 857 image_top -= kVerticalTabBorderInset; |
| 858 } |
| 870 } else if (!browser_view_->IsTabStripVisible()) { | 859 } else if (!browser_view_->IsTabStripVisible()) { |
| 871 // The toolbar isn't going to draw a client edge for us, so draw one | 860 // The toolbar isn't going to draw a client edge for us, so draw one |
| 872 // ourselves. | 861 // ourselves. |
| 873 SkBitmap* top_left = tp->GetBitmapNamed(IDR_APP_TOP_LEFT); | 862 SkBitmap* top_left = tp->GetBitmapNamed(IDR_APP_TOP_LEFT); |
| 874 SkBitmap* top_center = tp->GetBitmapNamed(IDR_APP_TOP_CENTER); | 863 SkBitmap* top_center = tp->GetBitmapNamed(IDR_APP_TOP_CENTER); |
| 875 SkBitmap* top_right = tp->GetBitmapNamed(IDR_APP_TOP_RIGHT); | 864 SkBitmap* top_right = tp->GetBitmapNamed(IDR_APP_TOP_RIGHT); |
| 876 int top_edge_y = client_area_top - top_center->height(); | 865 int top_edge_y = client_area_top - top_center->height(); |
| 877 int height = client_area_top - top_edge_y; | 866 int height = client_area_top - top_edge_y; |
| 878 | 867 |
| 879 canvas->DrawBitmapInt(*top_left, 0, 0, top_left->width(), height, | 868 canvas->DrawBitmapInt(*top_left, 0, 0, top_left->width(), height, |
| 880 client_area_bounds.x() - top_left->width(), top_edge_y, | 869 client_area_bounds.x() - top_left->width(), top_edge_y, |
| 881 top_left->width(), height, false); | 870 top_left->width(), height, false); |
| 882 canvas->TileImageInt(*top_center, 0, 0, client_area_bounds.x(), top_edge_y, | 871 canvas->TileImageInt(*top_center, 0, 0, client_area_bounds.x(), top_edge_y, |
| 883 client_area_bounds.width(), std::min(height, top_center->height())); | 872 client_area_bounds.width(), std::min(height, top_center->height())); |
| 884 canvas->DrawBitmapInt(*top_right, 0, 0, top_right->width(), height, | 873 canvas->DrawBitmapInt(*top_right, 0, 0, top_right->width(), height, |
| 885 client_area_bounds.right(), top_edge_y, | 874 client_area_bounds.right(), top_edge_y, |
| 886 top_right->width(), height, false); | 875 top_right->width(), height, false); |
| 887 | 876 |
| 888 // Draw the toolbar color across the top edge. | 877 // Draw the toolbar color across the top edge. |
| 889 canvas->FillRectInt(toolbar_color, | 878 canvas->FillRectInt(toolbar_color, |
| 890 client_area_bounds.x() - kClientEdgeThickness, | 879 client_area_bounds.x() - kClientEdgeThickness, |
| 891 client_area_top - kClientEdgeThickness, | 880 client_area_top - kClientEdgeThickness, |
| 892 client_area_bounds.width() + (2 * kClientEdgeThickness), | 881 client_area_bounds.width() + (2 * kClientEdgeThickness), |
| 893 kClientEdgeThickness); | 882 kClientEdgeThickness); |
| 894 } | 883 } |
| 895 | 884 |
| 896 int client_area_bottom = | 885 int client_area_bottom = |
| 897 std::max(client_area_top, height() - NonClientBorderThickness()); | 886 std::max(client_area_top, height() - NonClientBorderThickness()); |
| 898 int client_area_height = client_area_bottom - client_area_top; | 887 int image_height = client_area_bottom - image_top; |
| 899 | |
| 900 // Draw the toolbar color so that the client edges show the right color even | |
| 901 // where not covered by the toolbar image. | |
| 902 canvas->FillRectInt(toolbar_color, | |
| 903 client_area_bounds.x() - kClientEdgeThickness, client_area_top, | |
| 904 kClientEdgeThickness, | |
| 905 client_area_bottom + kClientEdgeThickness - client_area_top); | |
| 906 canvas->FillRectInt(toolbar_color, client_area_bounds.x(), client_area_bottom, | |
| 907 client_area_bounds.width(), kClientEdgeThickness); | |
| 908 canvas->FillRectInt(toolbar_color, client_area_bounds.right(), | |
| 909 client_area_top, kClientEdgeThickness, | |
| 910 client_area_bottom + kClientEdgeThickness - client_area_top); | |
| 911 | 888 |
| 912 // Draw the client edge images. | 889 // Draw the client edge images. |
| 890 // Draw the client edge images. |
| 913 SkBitmap* right = tp->GetBitmapNamed(IDR_CONTENT_RIGHT_SIDE); | 891 SkBitmap* right = tp->GetBitmapNamed(IDR_CONTENT_RIGHT_SIDE); |
| 914 canvas->TileImageInt(*right, client_area_bounds.right(), client_area_top, | 892 canvas->TileImageInt(*right, client_area_bounds.right(), image_top, |
| 915 right->width(), client_area_height); | 893 right->width(), image_height); |
| 916 canvas->DrawBitmapInt( | 894 canvas->DrawBitmapInt( |
| 917 *tp->GetBitmapNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER), | 895 *tp->GetBitmapNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER), |
| 918 client_area_bounds.right(), client_area_bottom); | 896 client_area_bounds.right(), client_area_bottom); |
| 919 SkBitmap* bottom = tp->GetBitmapNamed(IDR_CONTENT_BOTTOM_CENTER); | 897 SkBitmap* bottom = tp->GetBitmapNamed(IDR_CONTENT_BOTTOM_CENTER); |
| 920 canvas->TileImageInt(*bottom, client_area_bounds.x(), | 898 canvas->TileImageInt(*bottom, client_area_bounds.x(), |
| 921 client_area_bottom, client_area_bounds.width(), | 899 client_area_bottom, client_area_bounds.width(), |
| 922 bottom->height()); | 900 bottom->height()); |
| 923 SkBitmap* bottom_left = | 901 SkBitmap* bottom_left = |
| 924 tp->GetBitmapNamed(IDR_CONTENT_BOTTOM_LEFT_CORNER); | 902 tp->GetBitmapNamed(IDR_CONTENT_BOTTOM_LEFT_CORNER); |
| 925 canvas->DrawBitmapInt(*bottom_left, | 903 canvas->DrawBitmapInt(*bottom_left, |
| 926 client_area_bounds.x() - bottom_left->width(), client_area_bottom); | 904 client_area_bounds.x() - bottom_left->width(), client_area_bottom); |
| 927 SkBitmap* left = tp->GetBitmapNamed(IDR_CONTENT_LEFT_SIDE); | 905 SkBitmap* left = tp->GetBitmapNamed(IDR_CONTENT_LEFT_SIDE); |
| 928 canvas->TileImageInt(*left, client_area_bounds.x() - left->width(), | 906 canvas->TileImageInt(*left, client_area_bounds.x() - left->width(), |
| 929 client_area_top, left->width(), client_area_height); | 907 image_top, left->width(), image_height); |
| 908 |
| 909 // Draw the toolbar color so that the client edges show the right color even |
| 910 // where not covered by the toolbar image. NOTE: We do this after drawing the |
| 911 // images because the images are meant to alpha-blend atop the frame whereas |
| 912 // these rects are meant to be fully opaque, without anything overlaid. |
| 913 canvas->FillRectInt(toolbar_color, |
| 914 client_area_bounds.x() - kClientEdgeThickness, client_area_top, |
| 915 kClientEdgeThickness, |
| 916 client_area_bottom + kClientEdgeThickness - client_area_top); |
| 917 canvas->FillRectInt(toolbar_color, client_area_bounds.x(), client_area_bottom, |
| 918 client_area_bounds.width(), kClientEdgeThickness); |
| 919 canvas->FillRectInt(toolbar_color, client_area_bounds.right(), |
| 920 client_area_top, kClientEdgeThickness, |
| 921 client_area_bottom + kClientEdgeThickness - client_area_top); |
| 930 } | 922 } |
| 931 | 923 |
| 932 void OpaqueBrowserFrameView::LayoutWindowControls() { | 924 void OpaqueBrowserFrameView::LayoutWindowControls() { |
| 933 bool is_maximized = frame_->GetWindow()->IsMaximized(); | 925 bool is_maximized = frame_->GetWindow()->IsMaximized(); |
| 934 close_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT, | 926 close_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT, |
| 935 views::ImageButton::ALIGN_BOTTOM); | 927 views::ImageButton::ALIGN_BOTTOM); |
| 936 int caption_y = CaptionButtonY(); | 928 int caption_y = CaptionButtonY(false); |
| 937 // There should always be the same number of non-shadow pixels visible to the | 929 // There should always be the same number of non-shadow pixels visible to the |
| 938 // side of the caption buttons. In maximized mode we extend the rightmost | 930 // side of the caption buttons. In maximized mode we extend the rightmost |
| 939 // button to the screen corner to obey Fitts' Law. | 931 // button to the screen corner to obey Fitts' Law. |
| 940 int right_extra_width = is_maximized ? | 932 int right_extra_width = is_maximized ? |
| 941 (kFrameBorderThickness - kFrameShadowThickness) : 0; | 933 (kFrameBorderThickness - kFrameShadowThickness) : 0; |
| 942 gfx::Size close_button_size = close_button_->GetPreferredSize(); | 934 gfx::Size close_button_size = close_button_->GetPreferredSize(); |
| 943 close_button_->SetBounds(width() - FrameBorderThickness() - | 935 close_button_->SetBounds(width() - FrameBorderThickness(false) - |
| 944 right_extra_width - close_button_size.width(), caption_y, | 936 right_extra_width - close_button_size.width(), caption_y, |
| 945 close_button_size.width() + right_extra_width, | 937 close_button_size.width() + right_extra_width, |
| 946 close_button_size.height()); | 938 close_button_size.height()); |
| 947 | 939 |
| 948 #if defined(OS_CHROMEOS) | 940 #if defined(OS_CHROMEOS) |
| 949 minimize_button_->SetVisible(!is_maximized); | 941 minimize_button_->SetVisible(!is_maximized); |
| 950 restore_button_->SetVisible(!is_maximized); | 942 restore_button_->SetVisible(!is_maximized); |
| 951 maximize_button_->SetVisible(!is_maximized); | 943 maximize_button_->SetVisible(!is_maximized); |
| 952 | 944 |
| 953 if (browser_view_->browser()->type() == Browser::TYPE_DEVTOOLS) | 945 if (browser_view_->browser()->type() == Browser::TYPE_DEVTOOLS) |
| 954 close_button_->SetVisible(true); | 946 close_button_->SetVisible(true); |
| 955 else | 947 else |
| 956 close_button_->SetVisible(!is_maximized); | 948 close_button_->SetVisible(!is_maximized); |
| 957 | 949 |
| 958 if (is_maximized) { | 950 if (is_maximized) { |
| 959 // Set the bounds of the minimize button so that we don't have to change | 951 // Set the bounds of the minimize button so that we don't have to change |
| 960 // other places that rely on the bounds. Put it slightly to the right | 952 // other places that rely on the bounds. Put it slightly to the right |
| 961 // of the edge of the view, so that when we remove the spacing it lines | 953 // of the edge of the view, so that when we remove the spacing it lines |
| 962 // up with the edge. | 954 // up with the edge. |
| 963 minimize_button_->SetBounds( | 955 minimize_button_->SetBounds(width() - FrameBorderThickness(false) + |
| 964 width() - FrameBorderThickness() + kNewTabCaptionMaximizedSpacing, 0, 0, | 956 kNewTabCaptionMaximizedSpacing, 0, 0, 0); |
| 965 0); | |
| 966 return; | 957 return; |
| 967 } | 958 } |
| 968 #endif | 959 #endif |
| 969 | 960 |
| 970 // When the window is restored, we show a maximized button; otherwise, we show | 961 // When the window is restored, we show a maximized button; otherwise, we show |
| 971 // a restore button. | 962 // a restore button. |
| 972 bool is_restored = !is_maximized && !frame_->GetWindow()->IsMinimized(); | 963 bool is_restored = !is_maximized && !frame_->GetWindow()->IsMinimized(); |
| 973 views::ImageButton* invisible_button = is_restored ? | 964 views::ImageButton* invisible_button = is_restored ? |
| 974 restore_button_ : maximize_button_; | 965 restore_button_ : maximize_button_; |
| 975 invisible_button->SetVisible(false); | 966 invisible_button->SetVisible(false); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1013 // already biased downwards (see IconBounds()) and helps prevent descenders | 1004 // already biased downwards (see IconBounds()) and helps prevent descenders |
| 1014 // on the title from overlapping the 3D edge at the bottom of the titlebar. | 1005 // on the title from overlapping the 3D edge at the bottom of the titlebar. |
| 1015 title_bounds_.SetRect(title_x, | 1006 title_bounds_.SetRect(title_x, |
| 1016 icon_bounds.y() + ((icon_bounds.height() - title_height - 1) / 2), | 1007 icon_bounds.y() + ((icon_bounds.height() - title_height - 1) / 2), |
| 1017 std::max(0, minimize_button_->x() - kTitleLogoSpacing - title_x), | 1008 std::max(0, minimize_button_->x() - kTitleLogoSpacing - title_x), |
| 1018 title_height); | 1009 title_height); |
| 1019 } | 1010 } |
| 1020 } | 1011 } |
| 1021 | 1012 |
| 1022 void OpaqueBrowserFrameView::LayoutOTRAvatar() { | 1013 void OpaqueBrowserFrameView::LayoutOTRAvatar() { |
| 1023 int otr_y = NonClientTopBorderHeight(); | 1014 SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon(); |
| 1024 if (!frame_->GetWindow()->IsMaximized() && | 1015 int otr_bottom, otr_restored_y; |
| 1025 !frame_->GetWindow()->IsFullscreen()) { | 1016 if (browser_view_->UseVerticalTabs()) { |
| 1026 otr_y += kNonClientRestoredExtraThickness; | 1017 otr_bottom = NonClientTopBorderHeight(false, false) - kOTRBottomSpacing; |
| 1018 otr_restored_y = kFrameShadowThickness; |
| 1019 } else { |
| 1020 otr_bottom = GetHorizontalTabStripVerticalOffset(false) + |
| 1021 browser_view_->GetTabStripHeight() - kOTRBottomSpacing; |
| 1022 otr_restored_y = otr_bottom - otr_avatar_icon.height(); |
| 1027 } | 1023 } |
| 1028 bool visible = browser_view_->ShouldShowOffTheRecordAvatar(); | 1024 int otr_y = frame_->GetWindow()->IsMaximized() ? |
| 1029 gfx::Size preferred_size = otr_avatar_icon_->GetPreferredSize(); | 1025 (NonClientTopBorderHeight(false, true) + kTabstripTopShadowThickness) : |
| 1030 int otr_height = 0; | 1026 otr_restored_y; |
| 1031 if (browser_view_->IsTabStripVisible()) { | 1027 otr_avatar_bounds_.SetRect(NonClientBorderThickness() + kOTRSideSpacing, |
| 1032 if (browser_view_->UseVerticalTabs()) { | 1028 otr_y, otr_avatar_icon.width(), |
| 1033 otr_height = preferred_size.height(); | 1029 browser_view_->ShouldShowOffTheRecordAvatar() ? (otr_bottom - otr_y) : 0); |
| 1034 otr_y = -2; | |
| 1035 } else { | |
| 1036 int tabstrip_height = | |
| 1037 browser_view_->GetTabStripHeight() - kOTRBottomSpacing; | |
| 1038 otr_height = frame_->GetWindow()->IsMaximized() ? | |
| 1039 (tabstrip_height - kOTRMaximizedTopSpacing) : | |
| 1040 preferred_size.height(); | |
| 1041 otr_y += tabstrip_height - otr_height; | |
| 1042 } | |
| 1043 } else { | |
| 1044 visible = false; | |
| 1045 } | |
| 1046 otr_avatar_icon_->SetVisible(visible); | |
| 1047 otr_avatar_icon_->SetBounds(NonClientBorderThickness() + kOTRSideSpacing, | |
| 1048 otr_y, preferred_size.width(), otr_height); | |
| 1049 } | 1030 } |
| 1050 | 1031 |
| 1051 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, | 1032 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, |
| 1052 int height) const { | 1033 int height) const { |
| 1053 int top_height = NonClientTopBorderHeight(); | 1034 int top_height = NonClientTopBorderHeight(false, false); |
| 1054 int border_thickness = NonClientBorderThickness(); | 1035 int border_thickness = NonClientBorderThickness(); |
| 1055 return gfx::Rect(border_thickness, top_height, | 1036 return gfx::Rect(border_thickness, top_height, |
| 1056 std::max(0, width - (2 * border_thickness)), | 1037 std::max(0, width - (2 * border_thickness)), |
| 1057 std::max(0, height - top_height - border_thickness)); | 1038 std::max(0, height - top_height - border_thickness)); |
| 1058 } | 1039 } |
| 1059 | |
| 1060 // static | |
| 1061 gfx::Rect OpaqueBrowserFrameView::GetViewBounds(views::View* src, | |
| 1062 views::View* dst) { | |
| 1063 gfx::Rect bounds(src->bounds()); | |
| 1064 | |
| 1065 gfx::Point origin_in_dst(bounds.origin()); | |
| 1066 View::ConvertPointToView(src->GetParent(), dst, &origin_in_dst); | |
| 1067 bounds.set_origin(origin_in_dst); | |
| 1068 return bounds; | |
| 1069 } | |
| OLD | NEW |