Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: chrome/browser/ui/views/frame/opaque_browser_frame_view.cc

Issue 7071018: Merge 86845 - Fix hittesting in the OpaqueBrowserFrameView for frames without a tabstrip. The Hi... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/742/src/
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/views/frame/glass_browser_frame_view.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/theme_service.h" 9 #include "chrome/browser/themes/theme_service.h"
10 #include "chrome/browser/ui/views/frame/browser_frame.h" 10 #include "chrome/browser/ui/views/frame/browser_frame.h"
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 return FrameBorderThickness(restored) - 215 return FrameBorderThickness(restored) -
216 ((browser_view_->IsTabStripVisible() && !restored && 216 ((browser_view_->IsTabStripVisible() && !restored &&
217 window->IsMaximized()) ? kTabstripTopShadowThickness : 0); 217 window->IsMaximized()) ? kTabstripTopShadowThickness : 0);
218 } 218 }
219 219
220 /////////////////////////////////////////////////////////////////////////////// 220 ///////////////////////////////////////////////////////////////////////////////
221 // OpaqueBrowserFrameView, BrowserNonClientFrameView implementation: 221 // OpaqueBrowserFrameView, BrowserNonClientFrameView implementation:
222 222
223 gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip( 223 gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip(
224 views::View* tabstrip) const { 224 views::View* tabstrip) const {
225 if (!tabstrip) { 225 if (!tabstrip)
226 return gfx::Rect(); 226 return gfx::Rect();
227 }
228 227
229 if (browser_view_->UseVerticalTabs()) { 228 if (browser_view_->UseVerticalTabs()) {
230 gfx::Size ps = tabstrip->GetPreferredSize(); 229 gfx::Size ps = tabstrip->GetPreferredSize();
231 return gfx::Rect(NonClientBorderThickness(), 230 return gfx::Rect(NonClientBorderThickness(),
232 NonClientTopBorderHeight(false, false), ps.width(), 231 NonClientTopBorderHeight(false, false), ps.width(),
233 browser_view_->height()); 232 browser_view_->height());
234 } 233 }
235 234
236 int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ? 235 int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ?
237 (otr_avatar_bounds_.right() + kOTRSideSpacing) : 236 (otr_avatar_bounds_.right() + kOTRSideSpacing) :
238 NonClientBorderThickness() + kTabStripIndent; 237 NonClientBorderThickness() + kTabStripIndent;
239 238
240 int tabstrip_width = minimize_button_->x() - tabstrip_x - 239 int tabstrip_width = minimize_button_->x() - tabstrip_x -
241 (frame_->GetWindow()->IsMaximized() ? 240 (frame_->GetWindow()->IsMaximized() ?
242 kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing); 241 kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing);
243 int tabstrip_height = 0;
244 if (tabstrip)
245 tabstrip_height = tabstrip->GetPreferredSize().height();
246 return gfx::Rect(tabstrip_x, GetHorizontalTabStripVerticalOffset(false), 242 return gfx::Rect(tabstrip_x, GetHorizontalTabStripVerticalOffset(false),
247 std::max(0, tabstrip_width), tabstrip_height); 243 std::max(0, tabstrip_width), tabstrip->GetPreferredSize().height());
248 } 244 }
249 245
250 int OpaqueBrowserFrameView::GetHorizontalTabStripVerticalOffset( 246 int OpaqueBrowserFrameView::GetHorizontalTabStripVerticalOffset(
251 bool restored) const { 247 bool restored) const {
252 return NonClientTopBorderHeight(restored, true) + ((!restored && 248 return NonClientTopBorderHeight(restored, true) + ((!restored &&
253 (frame_->GetWindow()->IsMaximized() || 249 (frame_->GetWindow()->IsMaximized() ||
254 frame_->GetWindow()->IsFullscreen())) ? 250 frame_->GetWindow()->IsFullscreen())) ?
255 0 : kNonClientRestoredExtraThickness); 251 0 : kNonClientRestoredExtraThickness);
256 } 252 }
257 253
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 client_view_bounds_ = CalculateClientAreaBounds(width(), height()); 402 client_view_bounds_ = CalculateClientAreaBounds(width(), height());
407 } 403 }
408 404
409 bool OpaqueBrowserFrameView::HitTest(const gfx::Point& l) const { 405 bool OpaqueBrowserFrameView::HitTest(const gfx::Point& l) const {
410 // If the point is outside the bounds of the client area, claim it. 406 // If the point is outside the bounds of the client area, claim it.
411 bool in_nonclient = NonClientFrameView::HitTest(l); 407 bool in_nonclient = NonClientFrameView::HitTest(l);
412 if (in_nonclient) 408 if (in_nonclient)
413 return in_nonclient; 409 return in_nonclient;
414 410
415 // Otherwise claim it only if it's in a non-tab portion of the tabstrip. 411 // Otherwise claim it only if it's in a non-tab portion of the tabstrip.
416 bool vertical_tabs = browser_view_->UseVerticalTabs(); 412 if (!browser_view_->tabstrip())
417 gfx::Rect tabstrip_bounds = GetBoundsForTabStrip(browser_view_->tabstrip()); 413 return false;
414 gfx::Rect tabstrip_bounds(browser_view_->tabstrip()->bounds());
418 gfx::Point tabstrip_origin(tabstrip_bounds.origin()); 415 gfx::Point tabstrip_origin(tabstrip_bounds.origin());
419 View::ConvertPointToView(frame_->GetWindow()->client_view(), 416 View::ConvertPointToView(frame_->GetWindow()->client_view(),
420 this, &tabstrip_origin); 417 this, &tabstrip_origin);
421 tabstrip_bounds.set_origin(tabstrip_origin); 418 tabstrip_bounds.set_origin(tabstrip_origin);
422 if ((!vertical_tabs && l.y() > tabstrip_bounds.bottom()) || 419 if (browser_view_->UseVerticalTabs() ?
423 (vertical_tabs && l.x() > tabstrip_bounds.right())) { 420 (l.x() > tabstrip_bounds.right()) : (l.y() > tabstrip_bounds.bottom()))
424 return false; 421 return false;
425 }
426 422
427 // We convert from our parent's coordinates since we assume we fill its bounds 423 // We convert from our parent's coordinates since we assume we fill its bounds
428 // completely. We need to do this since we're not a parent of the tabstrip, 424 // completely. We need to do this since we're not a parent of the tabstrip,
429 // meaning ConvertPointToView would otherwise return something bogus. 425 // meaning ConvertPointToView would otherwise return something bogus.
430 gfx::Point browser_view_point(l); 426 gfx::Point browser_view_point(l);
431 View::ConvertPointToView(parent(), browser_view_, &browser_view_point); 427 View::ConvertPointToView(parent(), browser_view_, &browser_view_point);
432 return browser_view_->IsPositionInWindowCaption(browser_view_point); 428 return browser_view_->IsPositionInWindowCaption(browser_view_point);
433 } 429 }
434 430
435 void OpaqueBrowserFrameView::GetAccessibleState( 431 void OpaqueBrowserFrameView::GetAccessibleState(
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 1092
1097 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, 1093 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width,
1098 int height) const { 1094 int height) const {
1099 int top_height = NonClientTopBorderHeight(false, false); 1095 int top_height = NonClientTopBorderHeight(false, false);
1100 int border_thickness = NonClientBorderThickness(); 1096 int border_thickness = NonClientBorderThickness();
1101 return gfx::Rect(border_thickness, top_height, 1097 return gfx::Rect(border_thickness, top_height,
1102 std::max(0, width - (2 * border_thickness)), 1098 std::max(0, width - (2 * border_thickness)),
1103 std::max(0, height - GetReservedHeight() - 1099 std::max(0, height - GetReservedHeight() -
1104 top_height - border_thickness)); 1100 top_height - border_thickness));
1105 } 1101 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/glass_browser_frame_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698