summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authortdanderson@chromium.org <tdanderson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-16 01:00:10 +0000
committertdanderson@chromium.org <tdanderson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-16 01:00:10 +0000
commit2e6db30dd6e75716c8f68ec47f7bbcd9985da442 (patch)
tree9946a33eac72e438ab4f15323a94a1660d8c0c45 /ui
parent5f41cb5074d900a8332fd72db387e1d48f92f8f3 (diff)
downloadchromium_src-2e6db30dd6e75716c8f68ec47f7bbcd9985da442.zip
chromium_src-2e6db30dd6e75716c8f68ec47f7bbcd9985da442.tar.gz
chromium_src-2e6db30dd6e75716c8f68ec47f7bbcd9985da442.tar.bz2
Remove remaining overrides of View::HitTestRect()
Remove the remaining overrides of View::HitTestRect() and instead implement View::ViewTargeterDelegate::DoesIntersectRect(). Make View::HitTestRect() non-virtual. BUG=388838 TEST=none Review URL: https://codereview.chromium.org/380813003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283312 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/views/view.cc2
-rw-r--r--ui/views/view.h10
-rw-r--r--ui/views/window/non_client_view.cc22
-rw-r--r--ui/views/window/non_client_view.h11
4 files changed, 25 insertions, 20 deletions
diff --git a/ui/views/view.cc b/ui/views/view.cc
index 0f57d89..2961ed7 100644
--- a/ui/views/view.cc
+++ b/ui/views/view.cc
@@ -948,8 +948,6 @@ bool View::HitTestPoint(const gfx::Point& point) const {
}
bool View::HitTestRect(const gfx::Rect& rect) const {
- // If no ViewTargeter is installed on |this|, use the ViewTargeter installed
- // on our root view instead.
ViewTargeter* view_targeter = targeter();
if (!view_targeter)
view_targeter = GetWidget()->GetRootView()->targeter();
diff --git a/ui/views/view.h b/ui/views/view.h
index 1bdee37..510a6ba 100644
--- a/ui/views/view.h
+++ b/ui/views/view.h
@@ -577,16 +577,14 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
// the cursor is a shared resource.
virtual gfx::NativeCursor GetCursor(const ui::MouseEvent& event);
- // TODO(tdanderson): HitTestPoint() and HitTestRect() will be removed once
- // their logic is moved into ViewTargeter and its
- // derived classes. See crbug.com/355425.
-
// A convenience function which calls HitTestRect() with a rect of size
// 1x1 and an origin of |point|.
bool HitTestPoint(const gfx::Point& point) const;
- // Tests whether |rect| intersects this view's bounds.
- virtual bool HitTestRect(const gfx::Rect& rect) const;
+ // Tests whether |rect| intersects this view's bounds using the ViewTargeter
+ // installed on |this|. If there is no ViewTargeter installed on |this|, the
+ // ViewTargeter installed on the root view is used instead.
+ bool HitTestRect(const gfx::Rect& rect) const;
// Returns true if this view or any of its descendants are permitted to
// be the target of an event.
diff --git a/ui/views/window/non_client_view.cc b/ui/views/window/non_client_view.cc
index e4068db..43b2e70 100644
--- a/ui/views/window/non_client_view.cc
+++ b/ui/views/window/non_client_view.cc
@@ -8,6 +8,7 @@
#include "ui/base/hit_test.h"
#include "ui/gfx/rect_conversions.h"
#include "ui/views/rect_based_targeting_utils.h"
+#include "ui/views/view_targeter.h"
#include "ui/views/widget/root_view.h"
#include "ui/views/widget/widget.h"
#include "ui/views/window/client_view.h"
@@ -301,15 +302,6 @@ int NonClientFrameView::GetHTComponentForFrame(const gfx::Point& point,
}
////////////////////////////////////////////////////////////////////////////////
-// NonClientFrameView, View overrides:
-
-bool NonClientFrameView::HitTestRect(const gfx::Rect& rect) const {
- // For the default case, we assume the non-client frame view never overlaps
- // the client view.
- return !GetWidget()->client_view()->bounds().Intersects(rect);
-}
-
-////////////////////////////////////////////////////////////////////////////////
// NonClientFrameView, protected:
void NonClientFrameView::GetAccessibleState(ui::AXViewState* state) {
@@ -326,6 +318,18 @@ void NonClientFrameView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
}
NonClientFrameView::NonClientFrameView() : inactive_rendering_disabled_(false) {
+ SetEventTargeter(
+ scoped_ptr<views::ViewTargeter>(new views::ViewTargeter(this)));
+}
+
+// ViewTargeterDelegate:
+bool NonClientFrameView::DoesIntersectRect(const View* target,
+ const gfx::Rect& rect) const {
+ CHECK_EQ(target, this);
+
+ // For the default case, we assume the non-client frame view never overlaps
+ // the client view.
+ return !GetWidget()->client_view()->bounds().Intersects(rect);
}
} // namespace views
diff --git a/ui/views/window/non_client_view.h b/ui/views/window/non_client_view.h
index 7718142..9466afa 100644
--- a/ui/views/window/non_client_view.h
+++ b/ui/views/window/non_client_view.h
@@ -6,6 +6,7 @@
#define UI_VIEWS_WINDOW_NON_CLIENT_VIEW_H_
#include "ui/views/view.h"
+#include "ui/views/view_targeter_delegate.h"
namespace gfx {
class Path;
@@ -22,7 +23,8 @@ class ClientView;
// responds to events within the frame portions of the non-client area of a
// window. This view does _not_ contain the ClientView, but rather is a sibling
// of it.
-class VIEWS_EXPORT NonClientFrameView : public View {
+class VIEWS_EXPORT NonClientFrameView : public View,
+ public ViewTargeterDelegate {
public:
// Internal class name.
static const char kViewClassName[];
@@ -78,8 +80,7 @@ class VIEWS_EXPORT NonClientFrameView : public View {
virtual void UpdateWindowIcon() = 0;
virtual void UpdateWindowTitle() = 0;
- // Overridden from View:
- virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE;
+ // View:
virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE;
virtual const char* GetClassName() const OVERRIDE;
@@ -89,6 +90,10 @@ class VIEWS_EXPORT NonClientFrameView : public View {
NonClientFrameView();
private:
+ // ViewTargeterDelegate:
+ virtual bool DoesIntersectRect(const View* target,
+ const gfx::Rect& rect) const OVERRIDE;
+
// Prevents the non-client frame view from being rendered as inactive when
// true.
bool inactive_rendering_disabled_;