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

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

Issue 22891016: Add support for rect-based event targeting in views (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments addressed Created 7 years, 3 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
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 fde98892ecf4e44523e02ef81c9d4da247d205dc..a18c842a8b3c22fada0d54f8054634edab93b1ee 100644
--- a/chrome/browser/ui/views/tabs/tab.cc
+++ b/chrome/browser/ui/views/tabs/tab.cc
@@ -251,6 +251,8 @@ const double kProjectingFaviconResizeScale = 0.75;
// Scale to resize the projection sheet glow by.
const double kProjectingGlowResizeScale = 2.0;
+const char kTabCloseButtonName[] = "TabCloseButton";
+
void DrawIconAtLocation(gfx::Canvas* canvas,
const gfx::ImageSkia& image,
int image_offset,
@@ -360,21 +362,24 @@ class Tab::TabCloseButton : public views::ImageButton {
virtual ~TabCloseButton() {}
// Overridden from views::View.
- virtual View* GetEventHandlerForPoint(const gfx::Point& point) OVERRIDE {
+ virtual View* GetEventHandlerForRect(const gfx::Rect& rect) OVERRIDE {
+ if (!View::UsePointBasedTargeting(rect))
+ return View::GetEventHandlerForRect(rect);
+
// Ignore the padding set on the button.
- gfx::Rect rect = GetContentsBounds();
- rect.set_x(GetMirroredXForRect(rect));
+ gfx::Rect contents_bounds = GetContentsBounds();
+ contents_bounds.set_x(GetMirroredXForRect(contents_bounds));
#if defined(USE_ASH)
// Include the padding in hit-test for touch events.
if (aura::Env::GetInstance()->is_touch_down())
- rect = GetLocalBounds();
+ contents_bounds = GetLocalBounds();
#elif defined(OS_WIN)
// TODO(sky): Use local-bounds if a touch-point is active.
// http://crbug.com/145258
#endif
- return rect.Contains(point) ? this : parent();
+ return contents_bounds.Intersects(rect) ? this : parent();
}
// Overridden from views::View.
@@ -417,6 +422,10 @@ class Tab::TabCloseButton : public views::ImageButton {
event->SetHandled();
}
+ virtual const char* GetClassName() const OVERRIDE {
+ return kTabCloseButtonName;
+ }
+
private:
Tab* tab_;

Powered by Google App Engine
This is Rietveld 408576698