diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-05 05:41:09 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-05 05:41:09 +0000 |
commit | a52ca4671f27eb2eae418eecea0e5db58ff7bf08 (patch) | |
tree | c1a1c922e2eba3ee67750b6a62837741ac5311b3 /views/view.cc | |
parent | 848cd2743e2c4135976acf975b15e6f3c18edf8c (diff) | |
download | chromium_src-a52ca4671f27eb2eae418eecea0e5db58ff7bf08.zip chromium_src-a52ca4671f27eb2eae418eecea0e5db58ff7bf08.tar.gz chromium_src-a52ca4671f27eb2eae418eecea0e5db58ff7bf08.tar.bz2 |
Implement some basic functionality in RootView and View.
Review URL: http://codereview.chromium.org/119231
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17714 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/view.cc')
-rw-r--r-- | views/view.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/views/view.cc b/views/view.cc index f817f1c..1730bb9 100644 --- a/views/view.cc +++ b/views/view.cc @@ -11,6 +11,7 @@ #include "app/drag_drop_types.h" #include "app/gfx/canvas.h" +#include "app/gfx/path.h" #include "app/l10n_util.h" #include "base/logging.h" #include "base/message_loop.h" @@ -402,6 +403,29 @@ gfx::NativeCursor View::GetCursorForPoint(Event::EventType event_type, int x, return NULL; } +bool View::HitTest(const gfx::Point& l) const { + if (l.x() >= 0 && l.x() < static_cast<int>(width()) && + l.y() >= 0 && l.y() < static_cast<int>(height())) { + if (HasHitTestMask()) { + gfx::Path mask; + GetHitTestMask(&mask); +#if defined(OS_WIN) + ScopedHRGN rgn(mask.CreateHRGN()); + return !!PtInRegion(rgn, l.x(), l.y()); +#elif defined(OS_LINUX) + GdkRegion* region = mask.CreateGdkRegion(); + bool result = gdk_region_point_in(region, l.x(), l.y()); + gdk_region_destroy(region); + return result; +#endif + } + // No mask, but inside our bounds. + return true; + } + // Outside our bounds. + return false; +} + void View::SetContextMenuController(ContextMenuController* menu_controller) { context_menu_controller_ = menu_controller; } |