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

Side by Side Diff: chrome/browser/ui/views/tabs/tab_strip.cc

Issue 10827198: Change View::HitTest to View::HitTestRect (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/tabs/tab_strip.h" 5 #include "chrome/browser/ui/views/tabs/tab_strip.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windowsx.h> 8 #include <windowsx.h>
9 #endif 9 #endif
10 10
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 }; 259 };
260 260
261 // If |dest| contains the point |point_in_source| the event handler from |dest| 261 // If |dest| contains the point |point_in_source| the event handler from |dest|
262 // is returned. Otherwise NULL is returned. 262 // is returned. Otherwise NULL is returned.
263 views::View* ConvertPointToViewAndGetEventHandler( 263 views::View* ConvertPointToViewAndGetEventHandler(
264 views::View* source, 264 views::View* source,
265 views::View* dest, 265 views::View* dest,
266 const gfx::Point& point_in_source) { 266 const gfx::Point& point_in_source) {
267 gfx::Point dest_point(point_in_source); 267 gfx::Point dest_point(point_in_source);
268 views::View::ConvertPointToView(source, dest, &dest_point); 268 views::View::ConvertPointToView(source, dest, &dest_point);
269 return dest->HitTest(dest_point) ? 269 return dest->HitTest(gfx::Rect(dest_point, gfx::Size(0, 0))) ?
270 dest->GetEventHandlerForPoint(dest_point) : NULL; 270 dest->GetEventHandlerForPoint(dest_point) : NULL;
271 } 271 }
272 272
273 } // namespace 273 } // namespace
274 274
275 /////////////////////////////////////////////////////////////////////////////// 275 ///////////////////////////////////////////////////////////////////////////////
276 // NewTabButton 276 // NewTabButton
277 // 277 //
278 // A subclass of button that hit-tests to the shape of the new tab button and 278 // A subclass of button that hit-tests to the shape of the new tab button and
279 // does custom drawing. 279 // does custom drawing.
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 // bar to get a move action. 846 // bar to get a move action.
847 if (v == this) 847 if (v == this)
848 return true; 848 return true;
849 849
850 // Check to see if the point is within the non-button parts of the new tab 850 // Check to see if the point is within the non-button parts of the new tab
851 // button. The button has a non-rectangular shape, so if it's not in the 851 // button. The button has a non-rectangular shape, so if it's not in the
852 // visual portions of the button we treat it as a click to the caption. 852 // visual portions of the button we treat it as a click to the caption.
853 gfx::Point point_in_newtab_coords(point); 853 gfx::Point point_in_newtab_coords(point);
854 View::ConvertPointToView(this, newtab_button_, &point_in_newtab_coords); 854 View::ConvertPointToView(this, newtab_button_, &point_in_newtab_coords);
855 if (newtab_button_->GetLocalBounds().Contains(point_in_newtab_coords) && 855 if (newtab_button_->GetLocalBounds().Contains(point_in_newtab_coords) &&
856 !newtab_button_->HitTest(point_in_newtab_coords)) { 856 !newtab_button_->HitTest(gfx::Rect(point_in_newtab_coords,
857 gfx::Size(0, 0)))) {
857 return true; 858 return true;
858 } 859 }
859 860
860 // All other regions, including the new Tab button, should be considered part 861 // All other regions, including the new Tab button, should be considered part
861 // of the containing Window's client area so that regular events can be 862 // of the containing Window's client area so that regular events can be
862 // processed for them. 863 // processed for them.
863 return false; 864 return false;
864 } 865 }
865 866
866 void TabStrip::SetBackgroundOffset(const gfx::Point& offset) { 867 void TabStrip::SetBackgroundOffset(const gfx::Point& offset) {
(...skipping 1412 matching lines...) Expand 10 before | Expand all | Expand 10 after
2279 bounds_animator_.SetAnimationDelegate( 2280 bounds_animator_.SetAnimationDelegate(
2280 tab_closing, 2281 tab_closing,
2281 new RemoveTabDelegate(this, tab_closing), 2282 new RemoveTabDelegate(this, tab_closing),
2282 true); 2283 true);
2283 } 2284 }
2284 2285
2285 bool TabStrip::IsPointInTab(Tab* tab, 2286 bool TabStrip::IsPointInTab(Tab* tab,
2286 const gfx::Point& point_in_tabstrip_coords) { 2287 const gfx::Point& point_in_tabstrip_coords) {
2287 gfx::Point point_in_tab_coords(point_in_tabstrip_coords); 2288 gfx::Point point_in_tab_coords(point_in_tabstrip_coords);
2288 View::ConvertPointToView(this, tab, &point_in_tab_coords); 2289 View::ConvertPointToView(this, tab, &point_in_tab_coords);
2289 return tab->HitTest(point_in_tab_coords); 2290 return tab->HitTest(gfx::Rect(point_in_tab_coords, gfx::Size(0, 0)));
2290 } 2291 }
2291 2292
2292 int TabStrip::GetStartXForNormalTabs() const { 2293 int TabStrip::GetStartXForNormalTabs() const {
2293 int mini_tab_count = GetMiniTabCount(); 2294 int mini_tab_count = GetMiniTabCount();
2294 if (mini_tab_count == 0) 2295 if (mini_tab_count == 0)
2295 return 0; 2296 return 0;
2296 return mini_tab_count * (Tab::GetMiniWidth() + tab_h_offset()) + 2297 return mini_tab_count * (Tab::GetMiniWidth() + tab_h_offset()) +
2297 kMiniToNonMiniGap; 2298 kMiniToNonMiniGap;
2298 } 2299 }
2299 2300
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2348 2349
2349 int mini_tab_count = GetMiniTabCount(); 2350 int mini_tab_count = GetMiniTabCount();
2350 int normal_count = tab_count() - mini_tab_count; 2351 int normal_count = tab_count() - mini_tab_count;
2351 if (normal_count <= 1 || normal_count == mini_tab_count) 2352 if (normal_count <= 1 || normal_count == mini_tab_count)
2352 return false; 2353 return false;
2353 int x = GetStartXForNormalTabs(); 2354 int x = GetStartXForNormalTabs();
2354 int available_width = width() - x - new_tab_button_width(); 2355 int available_width = width() - x - new_tab_button_width();
2355 return (Tab::GetTouchWidth() * normal_count + 2356 return (Tab::GetTouchWidth() * normal_count +
2356 tab_h_offset() * (normal_count - 1)) > available_width; 2357 tab_h_offset() * (normal_count - 1)) > available_width;
2357 } 2358 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698