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

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: Revised patch with tests added 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->HitTestPoint(dest_point) ?
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 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 // bar to get a move action. 857 // bar to get a move action.
858 if (v == this) 858 if (v == this)
859 return true; 859 return true;
860 860
861 // Check to see if the point is within the non-button parts of the new tab 861 // Check to see if the point is within the non-button parts of the new tab
862 // button. The button has a non-rectangular shape, so if it's not in the 862 // button. The button has a non-rectangular shape, so if it's not in the
863 // visual portions of the button we treat it as a click to the caption. 863 // visual portions of the button we treat it as a click to the caption.
864 gfx::Point point_in_newtab_coords(point); 864 gfx::Point point_in_newtab_coords(point);
865 View::ConvertPointToView(this, newtab_button_, &point_in_newtab_coords); 865 View::ConvertPointToView(this, newtab_button_, &point_in_newtab_coords);
866 if (newtab_button_->GetLocalBounds().Contains(point_in_newtab_coords) && 866 if (newtab_button_->GetLocalBounds().Contains(point_in_newtab_coords) &&
867 !newtab_button_->HitTest(point_in_newtab_coords)) { 867 !newtab_button_->HitTestPoint(point_in_newtab_coords)) {
868 return true; 868 return true;
869 } 869 }
870 870
871 // All other regions, including the new Tab button, should be considered part 871 // All other regions, including the new Tab button, should be considered part
872 // of the containing Window's client area so that regular events can be 872 // of the containing Window's client area so that regular events can be
873 // processed for them. 873 // processed for them.
874 return false; 874 return false;
875 } 875 }
876 876
877 void TabStrip::SetBackgroundOffset(const gfx::Point& offset) { 877 void TabStrip::SetBackgroundOffset(const gfx::Point& offset) {
(...skipping 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after
2291 bounds_animator_.SetAnimationDelegate( 2291 bounds_animator_.SetAnimationDelegate(
2292 tab_closing, 2292 tab_closing,
2293 new RemoveTabDelegate(this, tab_closing), 2293 new RemoveTabDelegate(this, tab_closing),
2294 true); 2294 true);
2295 } 2295 }
2296 2296
2297 bool TabStrip::IsPointInTab(Tab* tab, 2297 bool TabStrip::IsPointInTab(Tab* tab,
2298 const gfx::Point& point_in_tabstrip_coords) { 2298 const gfx::Point& point_in_tabstrip_coords) {
2299 gfx::Point point_in_tab_coords(point_in_tabstrip_coords); 2299 gfx::Point point_in_tab_coords(point_in_tabstrip_coords);
2300 View::ConvertPointToView(this, tab, &point_in_tab_coords); 2300 View::ConvertPointToView(this, tab, &point_in_tab_coords);
2301 return tab->HitTest(point_in_tab_coords); 2301 return tab->HitTestPoint(point_in_tab_coords);
2302 } 2302 }
2303 2303
2304 int TabStrip::GetStartXForNormalTabs() const { 2304 int TabStrip::GetStartXForNormalTabs() const {
2305 int mini_tab_count = GetMiniTabCount(); 2305 int mini_tab_count = GetMiniTabCount();
2306 if (mini_tab_count == 0) 2306 if (mini_tab_count == 0)
2307 return 0; 2307 return 0;
2308 return mini_tab_count * (Tab::GetMiniWidth() + tab_h_offset()) + 2308 return mini_tab_count * (Tab::GetMiniWidth() + tab_h_offset()) +
2309 kMiniToNonMiniGap; 2309 kMiniToNonMiniGap;
2310 } 2310 }
2311 2311
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2360 2360
2361 int mini_tab_count = GetMiniTabCount(); 2361 int mini_tab_count = GetMiniTabCount();
2362 int normal_count = tab_count() - mini_tab_count; 2362 int normal_count = tab_count() - mini_tab_count;
2363 if (normal_count <= 1 || normal_count == mini_tab_count) 2363 if (normal_count <= 1 || normal_count == mini_tab_count)
2364 return false; 2364 return false;
2365 int x = GetStartXForNormalTabs(); 2365 int x = GetStartXForNormalTabs();
2366 int available_width = width() - x - new_tab_button_width(); 2366 int available_width = width() - x - new_tab_button_width();
2367 return (Tab::GetTouchWidth() * normal_count + 2367 return (Tab::GetTouchWidth() * normal_count +
2368 tab_h_offset() * (normal_count - 1)) > available_width; 2368 tab_h_offset() * (normal_count - 1)) > available_width;
2369 } 2369 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698