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

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: patch for landing Created 7 years, 1 month 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 d1b36dd9fa31f63c24da7c01e216057a9e4ed7d2..61896f179ce5887650f8f09e745edf5f008269c3 100644
--- a/chrome/browser/ui/views/tabs/tab.cc
+++ b/chrome/browser/ui/views/tabs/tab.cc
@@ -43,6 +43,7 @@
#include "ui/gfx/skia_util.h"
#include "ui/gfx/text_elider.h"
#include "ui/views/controls/button/image_button.h"
+#include "ui/views/rect_based_targeting_utils.h"
#include "ui/views/widget/tooltip_manager.h"
#include "ui/views/widget/widget.h"
#include "ui/views/window/non_client_view.h"
@@ -355,21 +356,26 @@ 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 (!views::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));
+ // TODO(tdanderson): Remove this ifdef if rect-based targeting
+ // is turned on by default.
#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.
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.cc ('k') | chrome/browser/ui/views/tabs/tab_strip.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698