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

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

Issue 7071001: Fix hittesting in the OpaqueBrowserFrameView for frames without a tabstrip. The HitTest() functi... (Closed) Base URL: svn://chrome-svn/chrome/trunk/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/command_line.h" 7 #include "base/command_line.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/prefs/pref_service.h" 10 #include "chrome/browser/prefs/pref_service.h"
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 return FrameBorderThickness(restored) - 252 return FrameBorderThickness(restored) -
253 ((browser_view_->IsTabStripVisible() && !restored && 253 ((browser_view_->IsTabStripVisible() && !restored &&
254 frame_->IsMaximized()) ? kTabstripTopShadowThickness : 0); 254 frame_->IsMaximized()) ? kTabstripTopShadowThickness : 0);
255 } 255 }
256 256
257 /////////////////////////////////////////////////////////////////////////////// 257 ///////////////////////////////////////////////////////////////////////////////
258 // OpaqueBrowserFrameView, BrowserNonClientFrameView implementation: 258 // OpaqueBrowserFrameView, BrowserNonClientFrameView implementation:
259 259
260 gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip( 260 gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip(
261 views::View* tabstrip) const { 261 views::View* tabstrip) const {
262 if (!tabstrip) { 262 if (!tabstrip)
263 return gfx::Rect(); 263 return gfx::Rect();
264 }
265 264
266 if (browser_view_->UseVerticalTabs()) { 265 if (browser_view_->UseVerticalTabs()) {
267 gfx::Size ps = tabstrip->GetPreferredSize(); 266 gfx::Size ps = tabstrip->GetPreferredSize();
268 return gfx::Rect(NonClientBorderThickness(), 267 return gfx::Rect(NonClientBorderThickness(),
269 NonClientTopBorderHeight(false, false), ps.width(), 268 NonClientTopBorderHeight(false, false), ps.width(),
270 browser_view_->height()); 269 browser_view_->height());
271 } 270 }
272 271
273 int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ? 272 int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ?
274 (otr_avatar_bounds_.right() + kOTRSideSpacing) : 273 (otr_avatar_bounds_.right() + kOTRSideSpacing) :
275 NonClientBorderThickness() + kTabStripIndent; 274 NonClientBorderThickness() + kTabStripIndent;
276 275
277 int maximized_spacing = 276 int maximized_spacing =
278 kNewTabCaptionMaximizedSpacing + 277 kNewTabCaptionMaximizedSpacing +
279 (show_profile_button() && profile_button_->IsVisible() ? 278 (show_profile_button() && profile_button_->IsVisible() ?
280 profile_button_->GetPreferredSize().width() + 279 profile_button_->GetPreferredSize().width() +
281 ProfileMenuButton::kProfileTagHorizontalSpacing : 0); 280 ProfileMenuButton::kProfileTagHorizontalSpacing : 0);
282 int tabstrip_width = minimize_button_->x() - tabstrip_x - 281 int tabstrip_width = minimize_button_->x() - tabstrip_x -
283 (frame_->IsMaximized() ? 282 (frame_->IsMaximized() ?
284 maximized_spacing : kNewTabCaptionRestoredSpacing); 283 maximized_spacing : kNewTabCaptionRestoredSpacing);
285 int tabstrip_height = 0;
286 if (tabstrip)
287 tabstrip_height = tabstrip->GetPreferredSize().height();
288 return gfx::Rect(tabstrip_x, GetHorizontalTabStripVerticalOffset(false), 284 return gfx::Rect(tabstrip_x, GetHorizontalTabStripVerticalOffset(false),
289 std::max(0, tabstrip_width), tabstrip_height); 285 std::max(0, tabstrip_width), tabstrip->GetPreferredSize().height());
290 } 286 }
291 287
292 int OpaqueBrowserFrameView::GetHorizontalTabStripVerticalOffset( 288 int OpaqueBrowserFrameView::GetHorizontalTabStripVerticalOffset(
293 bool restored) const { 289 bool restored) const {
294 return NonClientTopBorderHeight(restored, true) + ((!restored && 290 return NonClientTopBorderHeight(restored, true) + ((!restored &&
295 (frame_->IsMaximized() || 291 (frame_->IsMaximized() ||
296 frame_->IsFullscreen())) ? 292 frame_->IsFullscreen())) ?
297 0 : kNonClientRestoredExtraThickness); 293 0 : kNonClientRestoredExtraThickness);
298 } 294 }
299 295
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 client_view_bounds_ = CalculateClientAreaBounds(width(), height()); 442 client_view_bounds_ = CalculateClientAreaBounds(width(), height());
447 } 443 }
448 444
449 bool OpaqueBrowserFrameView::HitTest(const gfx::Point& l) const { 445 bool OpaqueBrowserFrameView::HitTest(const gfx::Point& l) const {
450 // If the point is outside the bounds of the client area, claim it. 446 // If the point is outside the bounds of the client area, claim it.
451 bool in_nonclient = NonClientFrameView::HitTest(l); 447 bool in_nonclient = NonClientFrameView::HitTest(l);
452 if (in_nonclient) 448 if (in_nonclient)
453 return in_nonclient; 449 return in_nonclient;
454 450
455 // Otherwise claim it only if it's in a non-tab portion of the tabstrip. 451 // Otherwise claim it only if it's in a non-tab portion of the tabstrip.
456 bool vertical_tabs = browser_view_->UseVerticalTabs(); 452 if (!browser_view_->tabstrip())
457 gfx::Rect tabstrip_bounds = GetBoundsForTabStrip(browser_view_->tabstrip()); 453 return false;
454 gfx::Rect tabstrip_bounds(browser_view_->tabstrip()->bounds());
458 gfx::Point tabstrip_origin(tabstrip_bounds.origin()); 455 gfx::Point tabstrip_origin(tabstrip_bounds.origin());
459 View::ConvertPointToView(frame_->client_view(), this, &tabstrip_origin); 456 View::ConvertPointToView(frame_->client_view(), this, &tabstrip_origin);
460 tabstrip_bounds.set_origin(tabstrip_origin); 457 tabstrip_bounds.set_origin(tabstrip_origin);
461 if ((!vertical_tabs && l.y() > tabstrip_bounds.bottom()) || 458 if (browser_view_->UseVerticalTabs() ?
462 (vertical_tabs && l.x() > tabstrip_bounds.right())) { 459 (l.x() > tabstrip_bounds.right()) : (l.y() > tabstrip_bounds.bottom()))
463 return false; 460 return false;
464 }
465 461
466 // Claim it only if we're also not in the compact navigation buttons. 462 // Claim it only if we're also not in the compact navigation buttons.
467 if (browser_view_->UseCompactNavigationBar()) { 463 if (browser_view_->UseCompactNavigationBar() &&
468 if (ConvertedContainsCheck(browser_view_->GetCompactNavigationBarBounds(), 464 (ConvertedContainsCheck(browser_view_->GetCompactNavigationBarBounds(),
469 frame_->client_view(), 465 frame_->client_view(), this, l) ||
470 static_cast<const View*>(this), 466 ConvertedContainsCheck(browser_view_->GetCompactOptionsBarBounds(),
471 l)) { 467 frame_->client_view(), this, l)))
472 return false; 468 return false;
473 }
474 if (ConvertedContainsCheck(browser_view_->GetCompactOptionsBarBounds(),
475 frame_->client_view(),
476 static_cast<const View*>(this),
477 l)) {
478 return false;
479 }
480 }
481 469
482 // We convert from our parent's coordinates since we assume we fill its bounds 470 // We convert from our parent's coordinates since we assume we fill its bounds
483 // completely. We need to do this since we're not a parent of the tabstrip, 471 // completely. We need to do this since we're not a parent of the tabstrip,
484 // meaning ConvertPointToView would otherwise return something bogus. 472 // meaning ConvertPointToView would otherwise return something bogus.
485 gfx::Point browser_view_point(l); 473 gfx::Point browser_view_point(l);
486 View::ConvertPointToView(parent(), browser_view_, &browser_view_point); 474 View::ConvertPointToView(parent(), browser_view_, &browser_view_point);
487 return browser_view_->IsPositionInWindowCaption(browser_view_point); 475 return browser_view_->IsPositionInWindowCaption(browser_view_point);
488 } 476 }
489 477
490 void OpaqueBrowserFrameView::GetAccessibleState( 478 void OpaqueBrowserFrameView::GetAccessibleState(
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
1209 std::max(0, width - (2 * border_thickness)), 1197 std::max(0, width - (2 * border_thickness)),
1210 std::max(0, height - GetReservedHeight() - 1198 std::max(0, height - GetReservedHeight() -
1211 top_height - border_thickness)); 1199 top_height - border_thickness));
1212 } 1200 }
1213 1201
1214 void OpaqueBrowserFrameView::RegisterLoginNotifications() { 1202 void OpaqueBrowserFrameView::RegisterLoginNotifications() {
1215 PrefService* pref_service = browser_view_->browser()->profile()->GetPrefs(); 1203 PrefService* pref_service = browser_view_->browser()->profile()->GetPrefs();
1216 DCHECK(pref_service); 1204 DCHECK(pref_service);
1217 username_pref_.Init(prefs::kGoogleServicesUsername, pref_service, this); 1205 username_pref_.Init(prefs::kGoogleServicesUsername, pref_service, this);
1218 } 1206 }
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