diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-11 04:17:09 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-11 04:17:09 +0000 |
commit | 4605be79a582881a1987b79694437be52df959af (patch) | |
tree | 7af8fb26ac5b4561a4fc0f719ba9c7bd3edeb1e7 /webkit/glue/webcursor.cc | |
parent | f36808a850fab540999d041e739fd8b37b144340 (diff) | |
download | chromium_src-4605be79a582881a1987b79694437be52df959af.zip chromium_src-4605be79a582881a1987b79694437be52df959af.tar.gz chromium_src-4605be79a582881a1987b79694437be52df959af.tar.bz2 |
Clamp the hotspot on custom cursors to the custom cursor image's dimensions.
Current behavior:
windows chrome - respect the crazy hotspot
linux chrome - crash
mac chrome - fall back to normal cursor
firefox - clamp the hotspot to the custom cursor image bounds.
So this unifies the behavior of all 3 chrome platforms and matches firefox.
BUG=51709
TEST=see bug for reduction
Review URL: http://codereview.chromium.org/3168003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55669 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webcursor.cc')
-rw-r--r-- | webkit/glue/webcursor.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/webkit/glue/webcursor.cc b/webkit/glue/webcursor.cc index f09372c..8f76ef9 100644 --- a/webkit/glue/webcursor.cc +++ b/webkit/glue/webcursor.cc @@ -57,6 +57,7 @@ void WebCursor::InitFromCursorInfo(const WebCursorInfo& cursor_info) { hotspot_ = cursor_info.hotSpot; if (IsCustom()) SetCustomData(cursor_info.customImage); + ClampHotspot(); } void WebCursor::GetCursorInfo(WebCursorInfo* cursor_info) const { @@ -100,6 +101,7 @@ bool WebCursor::Deserialize(const Pickle* pickle, void** iter) { hotspot_.set_y(hotspot_y); custom_size_.set_width(size_x); custom_size_.set_height(size_y); + ClampHotspot(); custom_data_.clear(); if (data_len > 0) { @@ -192,3 +194,14 @@ void WebCursor::ImageFromCustomData(WebImage* image) const { image->assign(bitmap); } #endif + +void WebCursor::ClampHotspot() { + if (!IsCustom()) + return; + + // Clamp the hotspot to the custom image's dimensions. + hotspot_.set_x(std::max(0, + std::min(custom_size_.width() - 1, hotspot_.x()))); + hotspot_.set_y(std::max(0, + std::min(custom_size_.height() - 1, hotspot_.y()))); +} |