| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/views/frame/opaque_browser_frame_view.h" | 5 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/themes/browser_theme_provider.h" | 9 #include "chrome/browser/themes/browser_theme_provider.h" |
| 10 #include "chrome/browser/ui/views/frame/browser_frame.h" | 10 #include "chrome/browser/ui/views/frame/browser_frame.h" |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 client_view_bounds.y() + client_view_bounds.height(), | 194 client_view_bounds.y() + client_view_bounds.height(), |
| 195 client_view_bounds.width(), | 195 client_view_bounds.width(), |
| 196 GetReservedHeight()); | 196 GetReservedHeight()); |
| 197 } | 197 } |
| 198 | 198 |
| 199 /////////////////////////////////////////////////////////////////////////////// | 199 /////////////////////////////////////////////////////////////////////////////// |
| 200 // OpaqueBrowserFrameView, BrowserNonClientFrameView implementation: | 200 // OpaqueBrowserFrameView, BrowserNonClientFrameView implementation: |
| 201 | 201 |
| 202 gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip( | 202 gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip( |
| 203 views::View* tabstrip) const { | 203 views::View* tabstrip) const { |
| 204 if (!tabstrip) { |
| 205 return gfx::Rect(); |
| 206 } |
| 207 |
| 204 if (browser_view_->UseVerticalTabs()) { | 208 if (browser_view_->UseVerticalTabs()) { |
| 205 gfx::Size ps = tabstrip->GetPreferredSize(); | 209 gfx::Size ps = tabstrip->GetPreferredSize(); |
| 206 return gfx::Rect(NonClientBorderThickness(), | 210 return gfx::Rect(NonClientBorderThickness(), |
| 207 NonClientTopBorderHeight(false, false), ps.width(), | 211 NonClientTopBorderHeight(false, false), ps.width(), |
| 208 browser_view_->height()); | 212 browser_view_->height()); |
| 209 } | 213 } |
| 210 | 214 |
| 211 int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ? | 215 int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ? |
| 212 (otr_avatar_bounds_.right() + kOTRSideSpacing) : | 216 (otr_avatar_bounds_.right() + kOTRSideSpacing) : |
| 213 NonClientBorderThickness() + kTabStripIndent; | 217 NonClientBorderThickness() + kTabStripIndent; |
| 214 | 218 |
| 215 int tabstrip_width = minimize_button_->x() - tabstrip_x - | 219 int tabstrip_width = minimize_button_->x() - tabstrip_x - |
| 216 (frame_->GetWindow()->IsMaximized() ? | 220 (frame_->GetWindow()->IsMaximized() ? |
| 217 kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing); | 221 kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing); |
| 222 int tabstrip_height = 0; |
| 223 if (tabstrip) |
| 224 tabstrip_height = tabstrip->GetPreferredSize().height(); |
| 218 return gfx::Rect(tabstrip_x, GetHorizontalTabStripVerticalOffset(false), | 225 return gfx::Rect(tabstrip_x, GetHorizontalTabStripVerticalOffset(false), |
| 219 std::max(0, tabstrip_width), | 226 std::max(0, tabstrip_width), tabstrip_height); |
| 220 tabstrip->GetPreferredSize().height()); | |
| 221 } | 227 } |
| 222 | 228 |
| 223 int OpaqueBrowserFrameView::GetHorizontalTabStripVerticalOffset( | 229 int OpaqueBrowserFrameView::GetHorizontalTabStripVerticalOffset( |
| 224 bool restored) const { | 230 bool restored) const { |
| 225 return NonClientTopBorderHeight(restored, true) + ((!restored && | 231 return NonClientTopBorderHeight(restored, true) + ((!restored && |
| 226 (frame_->GetWindow()->IsMaximized() || | 232 (frame_->GetWindow()->IsMaximized() || |
| 227 frame_->GetWindow()->IsFullscreen())) ? | 233 frame_->GetWindow()->IsFullscreen())) ? |
| 228 0 : kNonClientRestoredExtraThickness); | 234 0 : kNonClientRestoredExtraThickness); |
| 229 } | 235 } |
| 230 | 236 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 } | 386 } |
| 381 | 387 |
| 382 bool OpaqueBrowserFrameView::HitTest(const gfx::Point& l) const { | 388 bool OpaqueBrowserFrameView::HitTest(const gfx::Point& l) const { |
| 383 // If the point is outside the bounds of the client area, claim it. | 389 // If the point is outside the bounds of the client area, claim it. |
| 384 bool in_nonclient = NonClientFrameView::HitTest(l); | 390 bool in_nonclient = NonClientFrameView::HitTest(l); |
| 385 if (in_nonclient) | 391 if (in_nonclient) |
| 386 return in_nonclient; | 392 return in_nonclient; |
| 387 | 393 |
| 388 // Otherwise claim it only if it's in a non-tab portion of the tabstrip. | 394 // Otherwise claim it only if it's in a non-tab portion of the tabstrip. |
| 389 bool vertical_tabs = browser_view_->UseVerticalTabs(); | 395 bool vertical_tabs = browser_view_->UseVerticalTabs(); |
| 390 gfx::Rect tabstrip_bounds = browser_view_->tabstrip()->bounds(); | 396 gfx::Rect tabstrip_bounds = GetBoundsForTabStrip(browser_view_->tabstrip()); |
| 391 gfx::Point tabstrip_origin(tabstrip_bounds.origin()); | 397 gfx::Point tabstrip_origin(tabstrip_bounds.origin()); |
| 392 View::ConvertPointToView(frame_->GetWindow()->client_view(), | 398 View::ConvertPointToView(frame_->GetWindow()->client_view(), |
| 393 this, &tabstrip_origin); | 399 this, &tabstrip_origin); |
| 394 tabstrip_bounds.set_origin(tabstrip_origin); | 400 tabstrip_bounds.set_origin(tabstrip_origin); |
| 395 if ((!vertical_tabs && l.y() > tabstrip_bounds.bottom()) || | 401 if ((!vertical_tabs && l.y() > tabstrip_bounds.bottom()) || |
| 396 (vertical_tabs && l.x() > tabstrip_bounds.right())) { | 402 (vertical_tabs && l.x() > tabstrip_bounds.right())) { |
| 397 return false; | 403 return false; |
| 398 } | 404 } |
| 399 | 405 |
| 400 // We convert from our parent's coordinates since we assume we fill its bounds | 406 // We convert from our parent's coordinates since we assume we fill its bounds |
| (...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1067 | 1073 |
| 1068 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, | 1074 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, |
| 1069 int height) const { | 1075 int height) const { |
| 1070 int top_height = NonClientTopBorderHeight(false, false); | 1076 int top_height = NonClientTopBorderHeight(false, false); |
| 1071 int border_thickness = NonClientBorderThickness(); | 1077 int border_thickness = NonClientBorderThickness(); |
| 1072 return gfx::Rect(border_thickness, top_height, | 1078 return gfx::Rect(border_thickness, top_height, |
| 1073 std::max(0, width - (2 * border_thickness)), | 1079 std::max(0, width - (2 * border_thickness)), |
| 1074 std::max(0, height - GetReservedHeight() - | 1080 std::max(0, height - GetReservedHeight() - |
| 1075 top_height - border_thickness)); | 1081 top_height - border_thickness)); |
| 1076 } | 1082 } |
| OLD | NEW |