diff options
author | Michael Spang <spang@chromium.org> | 2015-04-07 10:55:00 -0400 |
---|---|---|
committer | Michael Spang <spang@chromium.org> | 2015-04-07 14:56:08 +0000 |
commit | bbdb5c73d7a5b9dc303a7c194582b0184064b4fc (patch) | |
tree | 43e08a4f7f0f464f55181d976ba4b1a549004d2d | |
parent | 4d95abadb6d081349c9d4e3ffb0036c575e92567 (diff) | |
download | chromium_src-bbdb5c73d7a5b9dc303a7c194582b0184064b4fc.zip chromium_src-bbdb5c73d7a5b9dc303a7c194582b0184064b4fc.tar.gz chromium_src-bbdb5c73d7a5b9dc303a7c194582b0184064b4fc.tar.bz2 |
content: ozone: Limit web cursor size to 64x64
This is the maximum some Chrome OS hardware can support and the maximum
that we historically allowed in X11 builds (see SkBitmapToXcursorImage).
This gives us consistent behavior to what we had before (except that it
only scales once instead of twice).
BUG=471357
TEST=davidwalsh.name/demo/css-custom-cursor.php on link & inspector
color picker cursors are scaled down instead of cropped
Review URL: https://codereview.chromium.org/1055533006
Cr-Commit-Position: refs/heads/master@{#323549}
(cherry picked from commit 9b580384b806134526d7baf6f5f6eff19a8eafdd)
Review URL: https://codereview.chromium.org/1064023002
Cr-Commit-Position: refs/branch-heads/2311@{#442}
Cr-Branched-From: 09b7de5dd7254947cd4306de907274fa63373d48-refs/heads/master@{#317474}
-rw-r--r-- | content/common/cursors/webcursor_ozone.cc | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/content/common/cursors/webcursor_ozone.cc b/content/common/cursors/webcursor_ozone.cc index 39a356d..0a47851 100644 --- a/content/common/cursors/webcursor_ozone.cc +++ b/content/common/cursors/webcursor_ozone.cc @@ -9,6 +9,11 @@ #include "ui/base/cursor/cursor_util.h" #include "ui/ozone/public/cursor_factory_ozone.h" +namespace { +const float kMaxCursorWidth = 64.f; +const float kMaxCursorHeight = 64.f; +} + namespace content { ui::PlatformCursor WebCursor::GetPlatformCursor() { @@ -18,8 +23,14 @@ ui::PlatformCursor WebCursor::GetPlatformCursor() { SkBitmap bitmap; ImageFromCustomData(&bitmap); gfx::Point hotspot = hotspot_; - ui::ScaleAndRotateCursorBitmapAndHotpoint( - device_scale_factor_, rotation_, &bitmap, &hotspot); + + // TODO(spang): Consider allowing larger cursors if the hardware supports it. + float scale = device_scale_factor_ / custom_scale_; + scale = std::min(scale, kMaxCursorWidth / bitmap.width()); + scale = std::min(scale, kMaxCursorHeight / bitmap.height()); + + ui::ScaleAndRotateCursorBitmapAndHotpoint(scale, rotation_, &bitmap, + &hotspot); return ui::CursorFactoryOzone::GetInstance()->CreateImageCursor(bitmap, hotspot); |