summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views
diff options
context:
space:
mode:
authorbeng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-16 00:37:56 +0000
committerbeng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-16 00:37:56 +0000
commit82739cfe200335e53c66b36e6b467c32294f7ef0 (patch)
tree32436525bb71a6ac93124da4e1dcc4b8c0bc48ed /chrome/browser/views
parent0ae7d14ea97bdb4170948521144de57059eb4eeb (diff)
downloadchromium_src-82739cfe200335e53c66b36e6b467c32294f7ef0.zip
chromium_src-82739cfe200335e53c66b36e6b467c32294f7ef0.tar.gz
chromium_src-82739cfe200335e53c66b36e6b467c32294f7ef0.tar.bz2
Allow Views to support an optional hit-test mask. Make hittest use this.
Make GetViewForPoint call HitTest instead of rolling its own crude hit testing. Update custom-shaped views to use this framework instead of overriding hittest themselves. B=2273 Review URL: http://codereview.chromium.org/3051 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2255 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r--chrome/browser/views/tabs/tab.cc11
-rw-r--r--chrome/browser/views/tabs/tab.h4
-rw-r--r--chrome/browser/views/tabs/tab_strip.cc12
3 files changed, 12 insertions, 15 deletions
diff --git a/chrome/browser/views/tabs/tab.cc b/chrome/browser/views/tabs/tab.cc
index bf5dc89..ec2ec29 100644
--- a/chrome/browser/views/tabs/tab.cc
+++ b/chrome/browser/views/tabs/tab.cc
@@ -126,11 +126,12 @@ bool Tab::IsSelected() const {
///////////////////////////////////////////////////////////////////////////////
// Tab, ChromeViews::View overrides:
-bool Tab::HitTest(const CPoint &l) const {
- gfx::Path path;
- MakePathForTab(&path);
- ScopedHRGN rgn(path.CreateHRGN());
- return !!PtInRegion(rgn, l.x, l.y);
+bool Tab::HasHitTestMask() const {
+ return true;
+}
+
+void Tab::GetHitTestMask(gfx::Path* mask) const {
+ MakePathForTab(mask);
}
bool Tab::OnMousePressed(const ChromeViews::MouseEvent& event) {
diff --git a/chrome/browser/views/tabs/tab.h b/chrome/browser/views/tabs/tab.h
index 753e1a9..369a39d 100644
--- a/chrome/browser/views/tabs/tab.h
+++ b/chrome/browser/views/tabs/tab.h
@@ -84,10 +84,10 @@ class Tab : public TabRenderer,
// TabRenderer overrides:
virtual bool IsSelected() const;
- // ChromeViews::View overrides:
- virtual bool HitTest(const CPoint &l) const;
private:
// ChromeViews::View overrides:
+ virtual bool HasHitTestMask() const;
+ virtual void GetHitTestMask(gfx::Path* mask) const;
virtual bool OnMousePressed(const ChromeViews::MouseEvent& event);
virtual bool OnMouseDragged(const ChromeViews::MouseEvent& event);
virtual void OnMouseReleased(const ChromeViews::MouseEvent& event,
diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc
index 748b9e7..6182e9b 100644
--- a/chrome/browser/views/tabs/tab_strip.cc
+++ b/chrome/browser/views/tabs/tab_strip.cc
@@ -67,15 +67,10 @@ class NewTabButton : public ChromeViews::Button {
protected:
// Overridden from ChromeViews::View:
- virtual bool HitTest(const CPoint &l) const {
- gfx::Path path;
- MakePathForButton(&path);
- ScopedHRGN rgn(path.CreateHRGN());
- return !!PtInRegion(rgn, l.x, l.y);
+ virtual bool HasHitTestMask() const {
+ return true;
}
-
- private:
- void MakePathForButton(gfx::Path* path) const {
+ virtual void GetHitTestMask(gfx::Path* path) const {
DCHECK(path);
SkScalar h = SkIntToScalar(GetHeight());
@@ -95,6 +90,7 @@ class NewTabButton : public ChromeViews::Button {
path->close();
}
+ private:
DISALLOW_COPY_AND_ASSIGN(NewTabButton);
};