Remove overrides of HitTestRect() which just return false

Some overrides of View::HitTestRect() just return 
false in order to force event-targeting to fail for
that view type and its descendants. Because this 
logic is unrelated to hit-testing against a rectangular
region, remove these overrides and instead override 
View::CanProcessEventsWithinSubtree() to just return 
false.

The relevant classes are:

ProfileImageView
ShelfButton::BarView
ShelfButton::IconView
PasswordRow
BoundedLabel
Label (and Link as a result)

BUG=374303
TEST=none

Review URL: https://codereview.chromium.org/287193002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274366 0039d316-1c4b-4281-b951-d872f2087c98
parent 674b6567
...@@ -123,9 +123,9 @@ class ShelfButton::BarView : public views::ImageView, ...@@ -123,9 +123,9 @@ class ShelfButton::BarView : public views::ImageView,
ShelfButtonAnimation::GetInstance()->RemoveObserver(this); ShelfButtonAnimation::GetInstance()->RemoveObserver(this);
} }
// View // views::View:
virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE { virtual bool CanProcessEventsWithinSubtree() const OVERRIDE {
// Allow Mouse...() messages to go to the parent view. // Send events to the parent view for handling.
return false; return false;
} }
...@@ -201,8 +201,8 @@ ShelfButton::IconView::IconView() : icon_size_(kIconSize) { ...@@ -201,8 +201,8 @@ ShelfButton::IconView::IconView() : icon_size_(kIconSize) {
ShelfButton::IconView::~IconView() { ShelfButton::IconView::~IconView() {
} }
bool ShelfButton::IconView::HitTestRect(const gfx::Rect& rect) const { bool ShelfButton::IconView::CanProcessEventsWithinSubtree() const {
// Return false so that ShelfButton gets all the mouse events. // Return false so that events are sent to ShelfView for handling.
return false; return false;
} }
......
...@@ -82,8 +82,8 @@ class ASH_EXPORT ShelfButton : public views::CustomButton { ...@@ -82,8 +82,8 @@ class ASH_EXPORT ShelfButton : public views::CustomButton {
void set_icon_size(int icon_size) { icon_size_ = icon_size; } void set_icon_size(int icon_size) { icon_size_ = icon_size; }
int icon_size() const { return icon_size_; } int icon_size() const { return icon_size_; }
// views::View overrides. // views::View:
virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE; virtual bool CanProcessEventsWithinSubtree() const OVERRIDE;
private: private:
// Set to non-zero to force icons to be resized to fit within a square, // Set to non-zero to force icons to be resized to fit within a square,
......
...@@ -50,8 +50,9 @@ class PasswordRow : public views::View { ...@@ -50,8 +50,9 @@ class PasswordRow : public views::View {
} }
virtual ~PasswordRow() {} virtual ~PasswordRow() {}
virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE { // views::View:
// Have parent do event handling. virtual bool CanProcessEventsWithinSubtree() const OVERRIDE {
// Send events to the parent view for handling.
return false; return false;
} }
......
...@@ -201,10 +201,12 @@ void EditProfileLink::OnBlur() { ...@@ -201,10 +201,12 @@ void EditProfileLink::OnBlur() {
// them instead. // them instead.
class ProfileImageView : public views::ImageView { class ProfileImageView : public views::ImageView {
public: public:
virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE; // views::View:
virtual bool CanProcessEventsWithinSubtree() const OVERRIDE;
}; };
bool ProfileImageView::HitTestRect(const gfx::Rect& rect) const { bool ProfileImageView::CanProcessEventsWithinSubtree() const {
// Send events to the parent view for handling.
return false; return false;
} }
......
...@@ -333,8 +333,8 @@ void BoundedLabel::Paint(gfx::Canvas* canvas, const views::CullSet& cull_set) { ...@@ -333,8 +333,8 @@ void BoundedLabel::Paint(gfx::Canvas* canvas, const views::CullSet& cull_set) {
label_->Paint(canvas, cull_set); label_->Paint(canvas, cull_set);
} }
bool BoundedLabel::HitTestRect(const gfx::Rect& rect) const { bool BoundedLabel::CanProcessEventsWithinSubtree() const {
return label_->HitTestRect(rect); return label_->CanProcessEventsWithinSubtree();
} }
void BoundedLabel::GetAccessibleState(ui::AXViewState* state) { void BoundedLabel::GetAccessibleState(ui::AXViewState* state) {
......
...@@ -49,13 +49,13 @@ class MESSAGE_CENTER_EXPORT BoundedLabel : public views::View { ...@@ -49,13 +49,13 @@ class MESSAGE_CENTER_EXPORT BoundedLabel : public views::View {
int GetLinesForWidthAndLimit(int width, int limit); int GetLinesForWidthAndLimit(int width, int limit);
gfx::Size GetSizeForWidthAndLines(int width, int lines); gfx::Size GetSizeForWidthAndLines(int width, int lines);
// Overridden from views::View. // views::View:
virtual int GetBaseline() const OVERRIDE; virtual int GetBaseline() const OVERRIDE;
virtual gfx::Size GetPreferredSize() const OVERRIDE; virtual gfx::Size GetPreferredSize() const OVERRIDE;
virtual int GetHeightForWidth(int width) const OVERRIDE; virtual int GetHeightForWidth(int width) const OVERRIDE;
virtual void Paint(gfx::Canvas* canvas, virtual void Paint(gfx::Canvas* canvas,
const views::CullSet& cull_set) OVERRIDE; const views::CullSet& cull_set) OVERRIDE;
virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE; virtual bool CanProcessEventsWithinSubtree() const OVERRIDE;
virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE;
protected: protected:
......
...@@ -289,7 +289,8 @@ View* Label::GetTooltipHandlerForPoint(const gfx::Point& point) { ...@@ -289,7 +289,8 @@ View* Label::GetTooltipHandlerForPoint(const gfx::Point& point) {
return this; return this;
} }
bool Label::HitTestRect(const gfx::Rect& rect) const { bool Label::CanProcessEventsWithinSubtree() const {
// Send events to the parent view for handling.
return false; return false;
} }
......
...@@ -172,7 +172,7 @@ class VIEWS_EXPORT Label : public View { ...@@ -172,7 +172,7 @@ class VIEWS_EXPORT Label : public View {
void set_collapse_when_hidden(bool value) { collapse_when_hidden_ = value; } void set_collapse_when_hidden(bool value) { collapse_when_hidden_ = value; }
bool collapse_when_hidden() const { return collapse_when_hidden_; } bool collapse_when_hidden() const { return collapse_when_hidden_; }
// Overridden from View: // View:
virtual gfx::Insets GetInsets() const OVERRIDE; virtual gfx::Insets GetInsets() const OVERRIDE;
virtual int GetBaseline() const OVERRIDE; virtual int GetBaseline() const OVERRIDE;
// Overridden to compute the size required to display this label. // Overridden to compute the size required to display this label.
...@@ -185,7 +185,7 @@ class VIEWS_EXPORT Label : public View { ...@@ -185,7 +185,7 @@ class VIEWS_EXPORT Label : public View {
virtual int GetHeightForWidth(int w) const OVERRIDE; virtual int GetHeightForWidth(int w) const OVERRIDE;
virtual const char* GetClassName() const OVERRIDE; virtual const char* GetClassName() const OVERRIDE;
virtual View* GetTooltipHandlerForPoint(const gfx::Point& point) OVERRIDE; virtual View* GetTooltipHandlerForPoint(const gfx::Point& point) OVERRIDE;
virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE; virtual bool CanProcessEventsWithinSubtree() const OVERRIDE;
virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE;
// Gets the tooltip text for labels that are wider than their bounds, except // Gets the tooltip text for labels that are wider than their bounds, except
// when the label is multiline, in which case it just returns false (no // when the label is multiline, in which case it just returns false (no
......
...@@ -51,10 +51,10 @@ gfx::NativeCursor Link::GetCursor(const ui::MouseEvent& event) { ...@@ -51,10 +51,10 @@ gfx::NativeCursor Link::GetCursor(const ui::MouseEvent& event) {
return GetNativeHandCursor(); return GetNativeHandCursor();
} }
bool Link::HitTestRect(const gfx::Rect& rect) const { bool Link::CanProcessEventsWithinSubtree() const {
// We need to allow clicks on the link. So we override the implementation in // Links need to be able to accept events (e.g., clicking) even though
// Label and use the default implementation of View. // in general Labels do not.
return View::HitTestRect(rect); return View::CanProcessEventsWithinSubtree();
} }
bool Link::OnMousePressed(const ui::MouseEvent& event) { bool Link::OnMousePressed(const ui::MouseEvent& event) {
......
...@@ -36,7 +36,7 @@ class VIEWS_EXPORT Link : public Label { ...@@ -36,7 +36,7 @@ class VIEWS_EXPORT Link : public Label {
// Label: // Label:
virtual const char* GetClassName() const OVERRIDE; virtual const char* GetClassName() const OVERRIDE;
virtual gfx::NativeCursor GetCursor(const ui::MouseEvent& event) OVERRIDE; virtual gfx::NativeCursor GetCursor(const ui::MouseEvent& event) OVERRIDE;
virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE; virtual bool CanProcessEventsWithinSubtree() const OVERRIDE;
virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;
virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE; virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE;
virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment