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

Unified Diff: chrome/browser/ui/views/tabs/tab.cc

Issue 147623004: Tab close buttons can only be targeted with touch if the whole button is visible (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/tabs/tab.cc
diff --git a/chrome/browser/ui/views/tabs/tab.cc b/chrome/browser/ui/views/tabs/tab.cc
index fa9e9d88a2bf886462a3959999e8debd57b0c552..818ad43bb8c2fe6e6d154ba656daede029a1c270 100644
--- a/chrome/browser/ui/views/tabs/tab.cc
+++ b/chrome/browser/ui/views/tabs/tab.cc
@@ -422,16 +422,24 @@ class Tab::TabCloseButton : public views::ImageButton {
views::View::ConvertRectToTarget(tab_, this, &tab_bounds_f);
gfx::Rect tab_bounds = gfx::ToEnclosingRect(tab_bounds_f);
- // If the button is hidden behind another tab, the hit test mask is empty.
- // Otherwise set the hit test mask to be the contents bounds.
+ // If the hit test request is in response to a gesture, |path| should be
+ // empty unless the entire tab close button is visible to the user. Hit
+ // test requests in response to a mouse event should always set |path|
+ // to be the visible portion of the tab close button, even if it is
+ // partially hidden behind another tab.
path->reset();
- if (tab_bounds.Intersects(button_bounds)) {
- // Include the padding in the hit test mask for touch events.
- if (source == HIT_TEST_SOURCE_TOUCH)
- button_bounds = GetLocalBounds();
-
- // TODO: this isn't quite right, really need to intersect the two regions.
- path->addRect(RectToSkRect(button_bounds));
+ gfx::Rect intersection(gfx::IntersectRects(tab_bounds, button_bounds));
+ if (!intersection.IsEmpty()) {
+#if !defined(OS_WIN)
sky 2014/02/03 20:55:47 Why the ifdef? I also don't understand why we can
tdanderson 2014/02/03 23:08:13 If we always return the intersection, then tabs wi
+ // TODO(tdanderson): Enforce this constraint on Windows once the issue
+ // described in crbug.com/337850 is resolved; the
+ // improper layout/clipping of the tab close button
+ // causes Contains() to always return false.
+ if (source == HIT_TEST_SOURCE_TOUCH &&
+ !tab_bounds.Contains(button_bounds))
+ return;
+#endif
+ path->addRect(RectToSkRect(intersection));
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698