Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(326)

Unified Diff: webkit/glue/webcursor.cc

Issue 3244006: Merge 55669 - Clamp the hotspot on custom cursors to the custom cursor image'... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/472/src/
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/glue/webcursor.h ('k') | webkit/glue/webcursor_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/webcursor.cc
===================================================================
--- webkit/glue/webcursor.cc (revision 58015)
+++ webkit/glue/webcursor.cc (working copy)
@@ -57,6 +57,7 @@
hotspot_ = cursor_info.hotSpot;
if (IsCustom())
SetCustomData(cursor_info.customImage);
+ ClampHotspot();
}
void WebCursor::GetCursorInfo(WebCursorInfo* cursor_info) const {
@@ -100,6 +101,7 @@
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 @@
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())));
+}
« no previous file with comments | « webkit/glue/webcursor.h ('k') | webkit/glue/webcursor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698