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

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

Issue 149753007: Merge 249331 "Tab close buttons can only be targeted with touch ..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1750/src/
Patch Set: Created 6 years, 10 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 | « chrome/browser/ui/views/tabs/tab.h ('k') | chrome/browser/ui/views/tabs/tab_strip.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/tabs/tab.cc
===================================================================
--- chrome/browser/ui/views/tabs/tab.cc (revision 250148)
+++ chrome/browser/ui/views/tabs/tab.cc (working copy)
@@ -422,15 +422,30 @@
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 either the top or bottom of the tab close button is clipped,
+ // do not consider these regions to be part of the button's bounds.
+ int top_overflow = tab_bounds.y() - button_bounds.y();
+ int bottom_overflow = button_bounds.bottom() - tab_bounds.bottom();
+ if (top_overflow > 0)
+ button_bounds.set_y(tab_bounds.y());
+ else if (bottom_overflow > 0)
+ button_bounds.set_height(button_bounds.height() - bottom_overflow);
+
+ // 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.Contains(button_bounds)) {
- // Include the padding in the hit test mask for touch events.
- if (source == HIT_TEST_SOURCE_TOUCH)
- button_bounds = GetLocalBounds();
+ gfx::Rect intersection(gfx::IntersectRects(tab_bounds, button_bounds));
+ if (!intersection.IsEmpty()) {
+ // TODO(tdanderson): Consider always returning the intersection if
+ // the non-rectangular shape of the tabs can be accounted for.
+ if (source == HIT_TEST_SOURCE_TOUCH &&
+ !tab_bounds.Contains(button_bounds))
+ return;
- path->addRect(RectToSkRect(button_bounds));
+ path->addRect(RectToSkRect(intersection));
}
}
« no previous file with comments | « chrome/browser/ui/views/tabs/tab.h ('k') | chrome/browser/ui/views/tabs/tab_strip.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698