summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-20 00:11:03 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-20 00:11:03 +0000
commitc2809346d25a645d175af044dc28c610fe8e099a (patch)
tree4712639199aa251f562f585d75925720518bdcc9 /webkit
parent29276a11e17ac4932810df8f7945b19b14bafeff (diff)
downloadchromium_src-c2809346d25a645d175af044dc28c610fe8e099a.zip
chromium_src-c2809346d25a645d175af044dc28c610fe8e099a.tar.gz
chromium_src-c2809346d25a645d175af044dc28c610fe8e099a.tar.bz2
Move webcursors code from webkit/ to content.
BUG=265753, 338338, 237249 TEST=content_unittests R=jam@chromium.org, torne@chromium.org TBR=darin Review URL: https://codereview.chromium.org/201473002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@258169 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/common/cursors/DEPS4
-rw-r--r--webkit/common/cursors/webcursor.cc261
-rw-r--r--webkit/common/cursors/webcursor.h195
-rw-r--r--webkit/common/cursors/webcursor_android.cc29
-rw-r--r--webkit/common/cursors/webcursor_aura.cc110
-rw-r--r--webkit/common/cursors/webcursor_aurawin.cc56
-rw-r--r--webkit/common/cursors/webcursor_aurax11.cc85
-rw-r--r--webkit/common/cursors/webcursor_gtk.cc222
-rw-r--r--webkit/common/cursors/webcursor_gtk_data.h311
-rw-r--r--webkit/common/cursors/webcursor_mac.mm395
-rw-r--r--webkit/common/cursors/webcursor_null.cc34
-rw-r--r--webkit/common/cursors/webcursor_unittest.cc230
-rw-r--r--webkit/common/cursors/webcursor_win.cc181
-rw-r--r--webkit/common/webkit_common.gyp22
14 files changed, 0 insertions, 2135 deletions
diff --git a/webkit/common/cursors/DEPS b/webkit/common/cursors/DEPS
deleted file mode 100644
index 9d59ac9..0000000
--- a/webkit/common/cursors/DEPS
+++ /dev/null
@@ -1,4 +0,0 @@
-include_rules = [
- "+third_party/WebKit",
- "+ui/base",
-]
diff --git a/webkit/common/cursors/webcursor.cc b/webkit/common/cursors/webcursor.cc
deleted file mode 100644
index b3036a7..0000000
--- a/webkit/common/cursors/webcursor.cc
+++ /dev/null
@@ -1,261 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "webkit/common/cursors/webcursor.h"
-
-#include "base/logging.h"
-#include "base/pickle.h"
-#include "third_party/WebKit/public/platform/WebImage.h"
-
-using blink::WebCursorInfo;
-
-static const int kMaxCursorDimension = 1024;
-
-WebCursor::WebCursor()
- : type_(WebCursorInfo::TypePointer),
- custom_scale_(1) {
-#if defined(OS_WIN)
- external_cursor_ = NULL;
-#endif
- InitPlatformData();
-}
-
-WebCursor::WebCursor(const CursorInfo& cursor_info)
- : type_(WebCursorInfo::TypePointer) {
-#if defined(OS_WIN)
- external_cursor_ = NULL;
-#endif
- InitPlatformData();
- InitFromCursorInfo(cursor_info);
-}
-
-WebCursor::~WebCursor() {
- Clear();
-}
-
-WebCursor::WebCursor(const WebCursor& other) {
- InitPlatformData();
- Copy(other);
-}
-
-const WebCursor& WebCursor::operator=(const WebCursor& other) {
- if (this == &other)
- return *this;
-
- Clear();
- Copy(other);
- return *this;
-}
-
-void WebCursor::InitFromCursorInfo(const CursorInfo& cursor_info) {
- Clear();
-
-#if defined(OS_WIN)
- if (cursor_info.external_handle) {
- InitFromExternalCursor(cursor_info.external_handle);
- return;
- }
-#endif
-
- type_ = cursor_info.type;
- hotspot_ = cursor_info.hotspot;
- if (IsCustom())
- SetCustomData(cursor_info.custom_image);
- custom_scale_ = cursor_info.image_scale_factor;
- CHECK(custom_scale_ > 0);
- ClampHotspot();
-}
-
-void WebCursor::GetCursorInfo(CursorInfo* cursor_info) const {
- cursor_info->type = static_cast<WebCursorInfo::Type>(type_);
- cursor_info->hotspot = hotspot_;
- ImageFromCustomData(&cursor_info->custom_image);
- cursor_info->image_scale_factor = custom_scale_;
-
-#if defined(OS_WIN)
- cursor_info->external_handle = external_cursor_;
-#endif
-}
-
-bool WebCursor::Deserialize(PickleIterator* iter) {
- int type, hotspot_x, hotspot_y, size_x, size_y, data_len;
- float scale;
- const char* data;
-
- // Leave |this| unmodified unless we are going to return success.
- if (!iter->ReadInt(&type) ||
- !iter->ReadInt(&hotspot_x) ||
- !iter->ReadInt(&hotspot_y) ||
- !iter->ReadLength(&size_x) ||
- !iter->ReadLength(&size_y) ||
- !iter->ReadFloat(&scale) ||
- !iter->ReadData(&data, &data_len))
- return false;
-
- // Ensure the size is sane, and there is enough data.
- if (size_x > kMaxCursorDimension ||
- size_y > kMaxCursorDimension)
- return false;
-
- // Ensure scale isn't ridiculous, and the scaled image size is still sane.
- if (scale < 0.01 || scale > 100 ||
- size_x / scale > kMaxCursorDimension ||
- size_y / scale > kMaxCursorDimension)
- return false;
-
- type_ = type;
-
- if (type == WebCursorInfo::TypeCustom) {
- if (size_x > 0 && size_y > 0) {
- // The * 4 is because the expected format is an array of RGBA pixel
- // values.
- if (size_x * size_y * 4 > data_len)
- return false;
-
- hotspot_.set_x(hotspot_x);
- hotspot_.set_y(hotspot_y);
- custom_size_.set_width(size_x);
- custom_size_.set_height(size_y);
- custom_scale_ = scale;
- ClampHotspot();
-
- custom_data_.clear();
- if (data_len > 0) {
- custom_data_.resize(data_len);
- memcpy(&custom_data_[0], data, data_len);
- }
- }
- }
- return DeserializePlatformData(iter);
-}
-
-bool WebCursor::Serialize(Pickle* pickle) const {
- if (!pickle->WriteInt(type_) ||
- !pickle->WriteInt(hotspot_.x()) ||
- !pickle->WriteInt(hotspot_.y()) ||
- !pickle->WriteInt(custom_size_.width()) ||
- !pickle->WriteInt(custom_size_.height()) ||
- !pickle->WriteFloat(custom_scale_))
- return false;
-
- const char* data = NULL;
- if (!custom_data_.empty())
- data = &custom_data_[0];
- if (!pickle->WriteData(data, custom_data_.size()))
- return false;
-
- return SerializePlatformData(pickle);
-}
-
-bool WebCursor::IsCustom() const {
- return type_ == WebCursorInfo::TypeCustom;
-}
-
-bool WebCursor::IsEqual(const WebCursor& other) const {
- if (type_ != other.type_)
- return false;
-
- if (!IsPlatformDataEqual(other))
- return false;
-
- return hotspot_ == other.hotspot_ &&
- custom_size_ == other.custom_size_ &&
- custom_scale_ == other.custom_scale_ &&
- custom_data_ == other.custom_data_;
-}
-
-#if defined(OS_WIN)
-
-static WebCursorInfo::Type ToCursorType(HCURSOR cursor) {
- static struct {
- HCURSOR cursor;
- WebCursorInfo::Type type;
- } kStandardCursors[] = {
- { LoadCursor(NULL, IDC_ARROW), WebCursorInfo::TypePointer },
- { LoadCursor(NULL, IDC_CROSS), WebCursorInfo::TypeCross },
- { LoadCursor(NULL, IDC_HAND), WebCursorInfo::TypeHand },
- { LoadCursor(NULL, IDC_IBEAM), WebCursorInfo::TypeIBeam },
- { LoadCursor(NULL, IDC_WAIT), WebCursorInfo::TypeWait },
- { LoadCursor(NULL, IDC_HELP), WebCursorInfo::TypeHelp },
- { LoadCursor(NULL, IDC_SIZENESW), WebCursorInfo::TypeNorthEastResize },
- { LoadCursor(NULL, IDC_SIZENWSE), WebCursorInfo::TypeNorthWestResize },
- { LoadCursor(NULL, IDC_SIZENS), WebCursorInfo::TypeNorthSouthResize },
- { LoadCursor(NULL, IDC_SIZEWE), WebCursorInfo::TypeEastWestResize },
- { LoadCursor(NULL, IDC_SIZEALL), WebCursorInfo::TypeMove },
- { LoadCursor(NULL, IDC_APPSTARTING), WebCursorInfo::TypeProgress },
- { LoadCursor(NULL, IDC_NO), WebCursorInfo::TypeNotAllowed },
- };
- for (int i = 0; i < arraysize(kStandardCursors); ++i) {
- if (cursor == kStandardCursors[i].cursor)
- return kStandardCursors[i].type;
- }
- return WebCursorInfo::TypeCustom;
-}
-
-void WebCursor::InitFromExternalCursor(HCURSOR cursor) {
- WebCursorInfo::Type cursor_type = ToCursorType(cursor);
-
- InitFromCursorInfo(CursorInfo(cursor_type));
-
- if (cursor_type == WebCursorInfo::TypeCustom)
- external_cursor_ = cursor;
-}
-
-#endif // defined(OS_WIN)
-
-void WebCursor::Clear() {
- type_ = WebCursorInfo::TypePointer;
- hotspot_.set_x(0);
- hotspot_.set_y(0);
- custom_size_.set_width(0);
- custom_size_.set_height(0);
- custom_scale_ = 1;
- custom_data_.clear();
- CleanupPlatformData();
-}
-
-void WebCursor::Copy(const WebCursor& other) {
- type_ = other.type_;
- hotspot_ = other.hotspot_;
- custom_size_ = other.custom_size_;
- custom_scale_ = other.custom_scale_;
- custom_data_ = other.custom_data_;
- CopyPlatformData(other);
-}
-
-void WebCursor::SetCustomData(const SkBitmap& bitmap) {
- if (bitmap.empty())
- return;
-
- // Fill custom_data_ directly with the NativeImage pixels.
- SkAutoLockPixels bitmap_lock(bitmap);
- custom_data_.resize(bitmap.getSize());
- if (!custom_data_.empty())
- memcpy(&custom_data_[0], bitmap.getPixels(), bitmap.getSize());
- custom_size_.set_width(bitmap.width());
- custom_size_.set_height(bitmap.height());
-}
-
-void WebCursor::ImageFromCustomData(SkBitmap* image) const {
- if (custom_data_.empty())
- return;
-
- image->setConfig(SkBitmap::kARGB_8888_Config,
- custom_size_.width(),
- custom_size_.height());
- if (!image->allocPixels())
- return;
- memcpy(image->getPixels(), &custom_data_[0], custom_data_.size());
-}
-
-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())));
-}
diff --git a/webkit/common/cursors/webcursor.h b/webkit/common/cursors/webcursor.h
deleted file mode 100644
index 7682a0a..0000000
--- a/webkit/common/cursors/webcursor.h
+++ /dev/null
@@ -1,195 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef WEBKIT_COMMON_CURSORS_WEBCURSOR_H_
-#define WEBKIT_COMMON_CURSORS_WEBCURSOR_H_
-
-#include "base/basictypes.h"
-#include "third_party/WebKit/public/platform/WebCursorInfo.h"
-#include "ui/gfx/display.h"
-#include "ui/gfx/native_widget_types.h"
-#include "ui/gfx/point.h"
-#include "ui/gfx/size.h"
-#include "webkit/common/webkit_common_export.h"
-
-#include <vector>
-
-#if defined(USE_AURA)
-#include "ui/base/cursor/cursor.h"
-#endif
-
-#if defined(OS_WIN)
-typedef struct HINSTANCE__* HINSTANCE;
-typedef struct HICON__* HICON;
-typedef HICON HCURSOR;
-#elif defined(TOOLKIT_GTK)
-typedef struct _GdkCursor GdkCursor;
-#elif defined(OS_MACOSX)
-#ifdef __OBJC__
-@class NSCursor;
-#else
-class NSCursor;
-#endif
-#endif
-
-class Pickle;
-class PickleIterator;
-
-// This class encapsulates a cross-platform description of a cursor. Platform
-// specific methods are provided to translate the cross-platform cursor into a
-// platform specific cursor. It is also possible to serialize / de-serialize a
-// WebCursor.
-class WEBKIT_COMMON_EXPORT WebCursor {
- public:
- struct CursorInfo {
- explicit CursorInfo(blink::WebCursorInfo::Type cursor_type)
- : type(cursor_type),
- image_scale_factor(1) {
-#if defined(OS_WIN)
- external_handle = NULL;
-#endif
- }
-
- CursorInfo()
- : type(blink::WebCursorInfo::TypePointer),
- image_scale_factor(1) {
-#if defined(OS_WIN)
- external_handle = NULL;
-#endif
- }
-
- blink::WebCursorInfo::Type type;
- gfx::Point hotspot;
- float image_scale_factor;
- SkBitmap custom_image;
-#if defined(OS_WIN)
- HCURSOR external_handle;
-#endif
- };
-
- WebCursor();
- explicit WebCursor(const CursorInfo& cursor_info);
- ~WebCursor();
-
- // Copy constructor/assignment operator combine.
- WebCursor(const WebCursor& other);
- const WebCursor& operator=(const WebCursor& other);
-
- // Conversion from/to CursorInfo.
- void InitFromCursorInfo(const CursorInfo& cursor_info);
- void GetCursorInfo(CursorInfo* cursor_info) const;
-
- // Serialization / De-serialization
- bool Deserialize(PickleIterator* iter);
- bool Serialize(Pickle* pickle) const;
-
- // Returns true if GetCustomCursor should be used to allocate a platform
- // specific cursor object. Otherwise GetCursor should be used.
- bool IsCustom() const;
-
- // Returns true if the current cursor object contains the same cursor as the
- // cursor object passed in. If the current cursor is a custom cursor, we also
- // compare the bitmaps to verify whether they are equal.
- bool IsEqual(const WebCursor& other) const;
-
- // Returns a native cursor representing the current WebCursor instance.
- gfx::NativeCursor GetNativeCursor();
-
-#if defined(OS_WIN)
- // Initialize this from the given Windows cursor. The caller must ensure that
- // the HCURSOR remains valid by not invoking the DestroyCursor/DestroyIcon
- // APIs on it.
- void InitFromExternalCursor(HCURSOR handle);
-#endif
-
-#if defined(USE_AURA)
- const ui::PlatformCursor GetPlatformCursor();
-
- // Updates |device_scale_factor_| and |rotation_| based on |display|.
- void SetDisplayInfo(const gfx::Display& display);
-
-#elif defined(OS_WIN)
- // Returns a HCURSOR representing the current WebCursor instance.
- // The ownership of the HCURSOR (does not apply to external cursors) remains
- // with the WebCursor instance.
- HCURSOR GetCursor(HINSTANCE module_handle);
-
-#elif defined(TOOLKIT_GTK)
- // Return the stock GdkCursorType for this cursor, or GDK_CURSOR_IS_PIXMAP
- // if it's a custom cursor. Return GDK_LAST_CURSOR to indicate that the cursor
- // should be set to the system default.
- // Returns an int so we don't need to include GDK headers in this header file.
- int GetCursorType() const;
-
- // Return a new GdkCursor* for this cursor. Only valid if GetCursorType
- // returns GDK_CURSOR_IS_PIXMAP.
- GdkCursor* GetCustomCursor();
-#elif defined(OS_MACOSX)
- // Initialize this from the given Cocoa NSCursor.
- void InitFromNSCursor(NSCursor* cursor);
-#endif
-
- private:
- // Copies the contents of the WebCursor instance passed in.
- void Copy(const WebCursor& other);
-
- // Cleans up the WebCursor instance.
- void Clear();
-
- // Platform specific initialization goes here.
- void InitPlatformData();
-
- // Platform specific Serialization / De-serialization
- bool SerializePlatformData(Pickle* pickle) const;
- bool DeserializePlatformData(PickleIterator* iter);
-
- // Returns true if the platform data in the current cursor object
- // matches that of the cursor passed in.
- bool IsPlatformDataEqual(const WebCursor& other) const ;
-
- // Copies platform specific data from the WebCursor instance passed in.
- void CopyPlatformData(const WebCursor& other);
-
- // Platform specific cleanup.
- void CleanupPlatformData();
-
- void SetCustomData(const SkBitmap& image);
- void ImageFromCustomData(SkBitmap* image) const;
-
- // Clamp the hotspot to the custom image's bounds, if this is a custom cursor.
- void ClampHotspot();
-
- // WebCore::PlatformCursor type.
- int type_;
-
- // Hotspot in cursor image in pixels.
- gfx::Point hotspot_;
-
- // Custom cursor data, as 32-bit RGBA.
- // Platform-inspecific because it can be serialized.
- gfx::Size custom_size_; // In pixels.
- float custom_scale_;
- std::vector<char> custom_data_;
-
-#if defined(OS_WIN)
- // An externally generated HCURSOR. We assume that it remains valid, i.e we
- // don't attempt to copy the HCURSOR.
- HCURSOR external_cursor_;
-#endif
-
-#if defined(USE_AURA) && defined(USE_X11)
- // Only used for custom cursors.
- ui::PlatformCursor platform_cursor_;
- float device_scale_factor_;
- gfx::Display::Rotation rotation_;
-#elif defined(OS_WIN)
- // A custom cursor created from custom bitmap data by Webkit.
- HCURSOR custom_cursor_;
-#elif defined(TOOLKIT_GTK)
- // A custom cursor created that should be unref'ed from the destructor.
- GdkCursor* unref_;
-#endif
-};
-
-#endif // WEBKIT_COMMON_CURSORS_WEBCURSOR_H_
diff --git a/webkit/common/cursors/webcursor_android.cc b/webkit/common/cursors/webcursor_android.cc
deleted file mode 100644
index 451ba35..0000000
--- a/webkit/common/cursors/webcursor_android.cc
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "webkit/common/cursors/webcursor.h"
-
-#include "base/logging.h"
-#include "third_party/WebKit/public/platform/WebCursorInfo.h"
-
-void WebCursor::InitPlatformData() {
-}
-
-bool WebCursor::SerializePlatformData(Pickle* pickle) const {
- return true;
-}
-
-bool WebCursor::DeserializePlatformData(PickleIterator* iter) {
- return true;
-}
-
-bool WebCursor::IsPlatformDataEqual(const WebCursor& other) const {
- return true;
-}
-
-void WebCursor::CleanupPlatformData() {
-}
-
-void WebCursor::CopyPlatformData(const WebCursor& other) {
-}
diff --git a/webkit/common/cursors/webcursor_aura.cc b/webkit/common/cursors/webcursor_aura.cc
deleted file mode 100644
index a7378683..0000000
--- a/webkit/common/cursors/webcursor_aura.cc
+++ /dev/null
@@ -1,110 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "webkit/common/cursors/webcursor.h"
-
-#include "base/logging.h"
-#include "third_party/WebKit/public/platform/WebCursorInfo.h"
-#include "ui/base/cursor/cursor.h"
-
-using blink::WebCursorInfo;
-
-gfx::NativeCursor WebCursor::GetNativeCursor() {
- switch (type_) {
- case WebCursorInfo::TypePointer:
- return ui::kCursorPointer;
- case WebCursorInfo::TypeCross:
- return ui::kCursorCross;
- case WebCursorInfo::TypeHand:
- return ui::kCursorHand;
- case WebCursorInfo::TypeIBeam:
- return ui::kCursorIBeam;
- case WebCursorInfo::TypeWait:
- return ui::kCursorWait;
- case WebCursorInfo::TypeHelp:
- return ui::kCursorHelp;
- case WebCursorInfo::TypeEastResize:
- return ui::kCursorEastResize;
- case WebCursorInfo::TypeNorthResize:
- return ui::kCursorNorthResize;
- case WebCursorInfo::TypeNorthEastResize:
- return ui::kCursorNorthEastResize;
- case WebCursorInfo::TypeNorthWestResize:
- return ui::kCursorNorthWestResize;
- case WebCursorInfo::TypeSouthResize:
- return ui::kCursorSouthResize;
- case WebCursorInfo::TypeSouthEastResize:
- return ui::kCursorSouthEastResize;
- case WebCursorInfo::TypeSouthWestResize:
- return ui::kCursorSouthWestResize;
- case WebCursorInfo::TypeWestResize:
- return ui::kCursorWestResize;
- case WebCursorInfo::TypeNorthSouthResize:
- return ui::kCursorNorthSouthResize;
- case WebCursorInfo::TypeEastWestResize:
- return ui::kCursorEastWestResize;
- case WebCursorInfo::TypeNorthEastSouthWestResize:
- return ui::kCursorNorthEastSouthWestResize;
- case WebCursorInfo::TypeNorthWestSouthEastResize:
- return ui::kCursorNorthWestSouthEastResize;
- case WebCursorInfo::TypeColumnResize:
- return ui::kCursorColumnResize;
- case WebCursorInfo::TypeRowResize:
- return ui::kCursorRowResize;
- case WebCursorInfo::TypeMiddlePanning:
- return ui::kCursorMiddlePanning;
- case WebCursorInfo::TypeEastPanning:
- return ui::kCursorEastPanning;
- case WebCursorInfo::TypeNorthPanning:
- return ui::kCursorNorthPanning;
- case WebCursorInfo::TypeNorthEastPanning:
- return ui::kCursorNorthEastPanning;
- case WebCursorInfo::TypeNorthWestPanning:
- return ui::kCursorNorthWestPanning;
- case WebCursorInfo::TypeSouthPanning:
- return ui::kCursorSouthPanning;
- case WebCursorInfo::TypeSouthEastPanning:
- return ui::kCursorSouthEastPanning;
- case WebCursorInfo::TypeSouthWestPanning:
- return ui::kCursorSouthWestPanning;
- case WebCursorInfo::TypeWestPanning:
- return ui::kCursorWestPanning;
- case WebCursorInfo::TypeMove:
- return ui::kCursorMove;
- case WebCursorInfo::TypeVerticalText:
- return ui::kCursorVerticalText;
- case WebCursorInfo::TypeCell:
- return ui::kCursorCell;
- case WebCursorInfo::TypeContextMenu:
- return ui::kCursorContextMenu;
- case WebCursorInfo::TypeAlias:
- return ui::kCursorAlias;
- case WebCursorInfo::TypeProgress:
- return ui::kCursorProgress;
- case WebCursorInfo::TypeNoDrop:
- return ui::kCursorNoDrop;
- case WebCursorInfo::TypeCopy:
- return ui::kCursorCopy;
- case WebCursorInfo::TypeNone:
- return ui::kCursorNone;
- case WebCursorInfo::TypeNotAllowed:
- return ui::kCursorNotAllowed;
- case WebCursorInfo::TypeZoomIn:
- return ui::kCursorZoomIn;
- case WebCursorInfo::TypeZoomOut:
- return ui::kCursorZoomOut;
- case WebCursorInfo::TypeGrab:
- return ui::kCursorGrab;
- case WebCursorInfo::TypeGrabbing:
- return ui::kCursorGrabbing;
- case WebCursorInfo::TypeCustom: {
- ui::Cursor cursor(ui::kCursorCustom);
- cursor.SetPlatformCursor(GetPlatformCursor());
- return cursor;
- }
- default:
- NOTREACHED();
- return gfx::kNullCursor;
- }
-}
diff --git a/webkit/common/cursors/webcursor_aurawin.cc b/webkit/common/cursors/webcursor_aurawin.cc
deleted file mode 100644
index 3fcf4c4..0000000
--- a/webkit/common/cursors/webcursor_aurawin.cc
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "webkit/common/cursors/webcursor.h"
-
-#include <windows.h>
-
-#include "third_party/WebKit/public/platform/WebCursorInfo.h"
-#include "ui/gfx/icon_util.h"
-
-const ui::PlatformCursor WebCursor::GetPlatformCursor() {
- if (!IsCustom())
- return LoadCursor(NULL, IDC_ARROW);
-
- if (custom_cursor_)
- return custom_cursor_;
-
- custom_cursor_ =
- IconUtil::CreateCursorFromDIB(
- custom_size_,
- hotspot_,
- !custom_data_.empty() ? &custom_data_[0] : NULL,
- custom_data_.size());
- return custom_cursor_;
-}
-
-void WebCursor::SetDisplayInfo(const gfx::Display& display) {
- // TODO(winguru): Add support for scaling the cursor.
-}
-
-void WebCursor::InitPlatformData() {
- custom_cursor_ = NULL;
-}
-
-bool WebCursor::SerializePlatformData(Pickle* pickle) const {
- return true;
-}
-
-bool WebCursor::DeserializePlatformData(PickleIterator* iter) {
- return true;
-}
-
-bool WebCursor::IsPlatformDataEqual(const WebCursor& other) const {
- return true;
-}
-
-void WebCursor::CleanupPlatformData() {
- if (custom_cursor_) {
- DestroyIcon(custom_cursor_);
- custom_cursor_ = NULL;
- }
-}
-
-void WebCursor::CopyPlatformData(const WebCursor& other) {
-}
diff --git a/webkit/common/cursors/webcursor_aurax11.cc b/webkit/common/cursors/webcursor_aurax11.cc
deleted file mode 100644
index 0389f06..0000000
--- a/webkit/common/cursors/webcursor_aurax11.cc
+++ /dev/null
@@ -1,85 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "webkit/common/cursors/webcursor.h"
-
-#include <X11/Xcursor/Xcursor.h>
-#include <X11/Xlib.h>
-#include <X11/cursorfont.h>
-
-#include "base/logging.h"
-#include "third_party/WebKit/public/platform/WebCursorInfo.h"
-#include "ui/base/cursor/cursor.h"
-#include "ui/base/cursor/cursor_loader_x11.h"
-#include "ui/base/x/x11_util.h"
-
-const ui::PlatformCursor WebCursor::GetPlatformCursor() {
- if (platform_cursor_)
- return platform_cursor_;
-
- if (custom_data_.size() == 0)
- return 0;
-
- SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config,
- custom_size_.width(), custom_size_.height());
- bitmap.allocPixels();
- memcpy(bitmap.getAddr32(0, 0), custom_data_.data(), custom_data_.size());
- gfx::Point hotspot = hotspot_;
- ui::ScaleAndRotateCursorBitmapAndHotpoint(
- device_scale_factor_, rotation_, &bitmap, &hotspot);
-
- XcursorImage* image = ui::SkBitmapToXcursorImage(&bitmap, hotspot);
- platform_cursor_ = ui::CreateReffedCustomXCursor(image);
- return platform_cursor_;
-}
-
-void WebCursor::SetDisplayInfo(const gfx::Display& display) {
- if (rotation_ == display.rotation() &&
- device_scale_factor_ == display.device_scale_factor())
- return;
-
- device_scale_factor_ = display.device_scale_factor();
- rotation_ = display.rotation();
- if (platform_cursor_)
- ui::UnrefCustomXCursor(platform_cursor_);
- platform_cursor_ = 0;
- // It is not necessary to recreate platform_cursor_ yet, since it will be
- // recreated on demand when GetPlatformCursor is called.
-}
-
-void WebCursor::InitPlatformData() {
- platform_cursor_ = 0;
- device_scale_factor_ = 1.f;
- rotation_ = gfx::Display::ROTATE_0;
-}
-
-bool WebCursor::SerializePlatformData(Pickle* pickle) const {
- return true;
-}
-
-bool WebCursor::DeserializePlatformData(PickleIterator* iter) {
- return true;
-}
-
-bool WebCursor::IsPlatformDataEqual(const WebCursor& other) const {
- return true;
-}
-
-void WebCursor::CleanupPlatformData() {
- if (platform_cursor_) {
- ui::UnrefCustomXCursor(platform_cursor_);
- platform_cursor_ = 0;
- }
-}
-
-void WebCursor::CopyPlatformData(const WebCursor& other) {
- if (platform_cursor_)
- ui::UnrefCustomXCursor(platform_cursor_);
- platform_cursor_ = other.platform_cursor_;
- if (platform_cursor_)
- ui::RefCustomXCursor(platform_cursor_);
-
- device_scale_factor_ = other.device_scale_factor_;
-}
diff --git a/webkit/common/cursors/webcursor_gtk.cc b/webkit/common/cursors/webcursor_gtk.cc
deleted file mode 100644
index eeb3aa9..0000000
--- a/webkit/common/cursors/webcursor_gtk.cc
+++ /dev/null
@@ -1,222 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "webkit/common/cursors/webcursor.h"
-
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
-
-#include "base/logging.h"
-#include "third_party/WebKit/public/platform/WebCursorInfo.h"
-#include "ui/gfx/gtk_util.h"
-
-using blink::WebCursorInfo;
-
-namespace {
-
-// webcursor_gtk_data.h is taken directly from WebKit's CursorGtk.h.
-#include "webkit/common/cursors/webcursor_gtk_data.h"
-
-// This helper function is taken directly from WebKit's CursorGtk.cpp.
-// It attempts to create a custom cursor from the data inlined in
-// webcursor_gtk_data.h.
-GdkCursor* GetInlineCustomCursor(CustomCursorType type) {
- static GdkCursor* CustomCursorsGdk[G_N_ELEMENTS(CustomCursors)];
- GdkCursor* cursor = CustomCursorsGdk[type];
- if (cursor)
- return cursor;
- const CustomCursor& custom = CustomCursors[type];
- cursor = gdk_cursor_new_from_name(gdk_display_get_default(), custom.name);
- if (!cursor) {
- const GdkColor fg = { 0, 0, 0, 0 };
- const GdkColor bg = { 65535, 65535, 65535, 65535 };
- GdkPixmap* source = gdk_bitmap_create_from_data(
- NULL, reinterpret_cast<const gchar*>(custom.bits), 32, 32);
- GdkPixmap* mask = gdk_bitmap_create_from_data(
- NULL, reinterpret_cast<const gchar*>(custom.mask_bits), 32, 32);
- cursor = gdk_cursor_new_from_pixmap(source, mask, &fg, &bg,
- custom.hot_x, custom.hot_y);
- g_object_unref(source);
- g_object_unref(mask);
- }
- CustomCursorsGdk[type] = cursor;
- return cursor;
-}
-
-} // end anonymous namespace
-
-int WebCursor::GetCursorType() const {
- // http://library.gnome.org/devel/gdk/2.12/gdk-Cursors.html has images
- // of the default X theme, but beware that the user's cursor theme can
- // change everything.
- switch (type_) {
- case WebCursorInfo::TypePointer:
- return GDK_LAST_CURSOR;
- case WebCursorInfo::TypeCross:
- return GDK_CROSS;
- case WebCursorInfo::TypeHand:
- return GDK_HAND2;
- case WebCursorInfo::TypeIBeam:
- return GDK_XTERM;
- case WebCursorInfo::TypeWait:
- return GDK_WATCH;
- case WebCursorInfo::TypeHelp:
- return GDK_QUESTION_ARROW;
- case WebCursorInfo::TypeEastResize:
- return GDK_RIGHT_SIDE;
- case WebCursorInfo::TypeNorthResize:
- return GDK_TOP_SIDE;
- case WebCursorInfo::TypeNorthEastResize:
- return GDK_TOP_RIGHT_CORNER;
- case WebCursorInfo::TypeNorthWestResize:
- return GDK_TOP_LEFT_CORNER;
- case WebCursorInfo::TypeSouthResize:
- return GDK_BOTTOM_SIDE;
- case WebCursorInfo::TypeSouthEastResize:
- return GDK_BOTTOM_RIGHT_CORNER;
- case WebCursorInfo::TypeSouthWestResize:
- return GDK_BOTTOM_LEFT_CORNER;
- case WebCursorInfo::TypeWestResize:
- return GDK_LEFT_SIDE;
- case WebCursorInfo::TypeNorthSouthResize:
- return GDK_SB_V_DOUBLE_ARROW;
- case WebCursorInfo::TypeEastWestResize:
- return GDK_SB_H_DOUBLE_ARROW;
- case WebCursorInfo::TypeNorthEastSouthWestResize:
- case WebCursorInfo::TypeNorthWestSouthEastResize:
- // There isn't really a useful cursor available for these.
- return GDK_LAST_CURSOR;
- case WebCursorInfo::TypeColumnResize:
- return GDK_SB_H_DOUBLE_ARROW; // TODO(evanm): is this correct?
- case WebCursorInfo::TypeRowResize:
- return GDK_SB_V_DOUBLE_ARROW; // TODO(evanm): is this correct?
- case WebCursorInfo::TypeMiddlePanning:
- return GDK_FLEUR;
- case WebCursorInfo::TypeEastPanning:
- return GDK_SB_RIGHT_ARROW;
- case WebCursorInfo::TypeNorthPanning:
- return GDK_SB_UP_ARROW;
- case WebCursorInfo::TypeNorthEastPanning:
- return GDK_TOP_RIGHT_CORNER;
- case WebCursorInfo::TypeNorthWestPanning:
- return GDK_TOP_LEFT_CORNER;
- case WebCursorInfo::TypeSouthPanning:
- return GDK_SB_DOWN_ARROW;
- case WebCursorInfo::TypeSouthEastPanning:
- return GDK_BOTTOM_RIGHT_CORNER;
- case WebCursorInfo::TypeSouthWestPanning:
- return GDK_BOTTOM_LEFT_CORNER;
- case WebCursorInfo::TypeWestPanning:
- return GDK_SB_LEFT_ARROW;
- case WebCursorInfo::TypeMove:
- return GDK_FLEUR;
- case WebCursorInfo::TypeVerticalText:
- return GDK_LAST_CURSOR;
- case WebCursorInfo::TypeCell:
- return GDK_LAST_CURSOR;
- case WebCursorInfo::TypeContextMenu:
- return GDK_LAST_CURSOR;
- case WebCursorInfo::TypeAlias:
- return GDK_LAST_CURSOR;
- case WebCursorInfo::TypeProgress:
- return GDK_WATCH;
- case WebCursorInfo::TypeNoDrop:
- return GDK_LAST_CURSOR;
- case WebCursorInfo::TypeCopy:
- return GDK_LAST_CURSOR;
- case WebCursorInfo::TypeNone:
- return GDK_BLANK_CURSOR;
- case WebCursorInfo::TypeNotAllowed:
- return GDK_LAST_CURSOR;
- case WebCursorInfo::TypeZoomIn:
- case WebCursorInfo::TypeZoomOut:
- case WebCursorInfo::TypeGrab:
- case WebCursorInfo::TypeGrabbing:
- case WebCursorInfo::TypeCustom:
- return GDK_CURSOR_IS_PIXMAP;
- }
- NOTREACHED();
- return GDK_LAST_CURSOR;
-}
-
-gfx::NativeCursor WebCursor::GetNativeCursor() {
- int type = GetCursorType();
- if (type == GDK_CURSOR_IS_PIXMAP)
- return GetCustomCursor();
- return gfx::GetCursor(type);
-}
-
-GdkCursor* WebCursor::GetCustomCursor() {
- switch (type_) {
- case WebCursorInfo::TypeZoomIn:
- return GetInlineCustomCursor(CustomCursorZoomIn);
- case WebCursorInfo::TypeZoomOut:
- return GetInlineCustomCursor(CustomCursorZoomOut);
- case WebCursorInfo::TypeGrab:
- return GetInlineCustomCursor(CustomCursorGrab);
- case WebCursorInfo::TypeGrabbing:
- return GetInlineCustomCursor(CustomCursorGrabbing);
- }
-
- if (type_ != WebCursorInfo::TypeCustom) {
- NOTREACHED();
- return NULL;
- }
-
- if (custom_size_.width() == 0 || custom_size_.height() == 0) {
- // Some websites specify cursor images that are 0 sized, such as Bing Maps.
- // Don't crash on this; just use the default cursor.
- return NULL;
- }
-
- SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config,
- custom_size_.width(), custom_size_.height());
- bitmap.allocPixels();
- memcpy(bitmap.getAddr32(0, 0), custom_data_.data(), custom_data_.size());
-
- GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(bitmap);
- GdkCursor* cursor = gdk_cursor_new_from_pixbuf(gdk_display_get_default(),
- pixbuf,
- hotspot_.x(),
- hotspot_.y());
-
- g_object_unref(pixbuf);
-
- if (unref_)
- gdk_cursor_unref(unref_);
- unref_ = cursor;
- return cursor;
-}
-
-void WebCursor::InitPlatformData() {
- unref_ = NULL;
- return;
-}
-
-bool WebCursor::SerializePlatformData(Pickle* pickle) const {
- return true;
-}
-
-bool WebCursor::DeserializePlatformData(PickleIterator* iter) {
- return true;
-}
-
-bool WebCursor::IsPlatformDataEqual(const WebCursor& other) const {
- return true;
-}
-
-void WebCursor::CleanupPlatformData() {
- if (unref_) {
- gdk_cursor_unref(unref_);
- unref_ = NULL;
- }
- return;
-}
-
-void WebCursor::CopyPlatformData(const WebCursor& other) {
- if (other.unref_)
- unref_ = gdk_cursor_ref(other.unref_);
- return;
-}
diff --git a/webkit/common/cursors/webcursor_gtk_data.h b/webkit/common/cursors/webcursor_gtk_data.h
deleted file mode 100644
index c92e026..0000000
--- a/webkit/common/cursors/webcursor_gtk_data.h
+++ /dev/null
@@ -1,311 +0,0 @@
-// This file is a cut'n'paste from WebKit/WebCore/platform/gtk/CursorGtk.h,
-// with slight modifications to fit within Chrome. Its original
-// copyright is below.
-
-// This file intentionally doesn't have a header guard, since it is just
-// data to be used within a C++ file.
-
-/*
- * Copyright (C) 2001 Tim Copperfield <timecop@network.email.ne.jp>
- * Copyright (C) 2007 Christian Dywan <christian@twotoasts.de>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-/*
- These cursors are copied from Mozilla code:
- http://lxr.mozilla.org/mozilla1.8/source/widget/src/gtk2/nsGtkCursors.h
-*/
-
-/* MOZ_CURSOR_VERTICAL_TEXT */
-static const uint8 moz_vertical_text_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00,
- 0x06, 0x60, 0x00, 0x00, 0xfc, 0x3f, 0x00, 0x00, 0x06, 0x60, 0x00, 0x00,
- 0x02, 0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-static const uint8 moz_vertical_text_mask_bits[] = {
- 0x07, 0xe0, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x0f, 0xf0, 0x00, 0x00,
- 0xff, 0xff, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
- 0x0f, 0xf0, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-/* MOZ_CURSOR_CONTEXT_MENU */
-static const uint8 moz_menu_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x0c, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00,
- 0x7c, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0xfd, 0x00, 0x00,
- 0xfc, 0xff, 0x00, 0x00, 0x7c, 0x84, 0x00, 0x00, 0x6c, 0xfc, 0x00, 0x00,
- 0xc4, 0x84, 0x00, 0x00, 0xc0, 0xfc, 0x00, 0x00, 0x80, 0x85, 0x00, 0x00,
- 0x80, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-static const uint8 moz_menu_mask_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
- 0x1e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00,
- 0xfe, 0x00, 0x00, 0x00, 0xfe, 0xfd, 0x00, 0x00, 0xfe, 0xff, 0x01, 0x00,
- 0xfe, 0xff, 0x01, 0x00, 0xfe, 0xff, 0x01, 0x00, 0xfe, 0xfe, 0x01, 0x00,
- 0xee, 0xff, 0x01, 0x00, 0xe4, 0xff, 0x01, 0x00, 0xc0, 0xff, 0x01, 0x00,
- 0xc0, 0xff, 0x01, 0x00, 0x80, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-/* MOZ_CURSOR_COPY */
-static const uint8 moz_copy_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x0c, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00,
- 0x7c, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x00,
- 0xfc, 0x03, 0x00, 0x00, 0x7c, 0x30, 0x00, 0x00, 0x6c, 0x30, 0x00, 0x00,
- 0xc4, 0xfc, 0x00, 0x00, 0xc0, 0xfc, 0x00, 0x00, 0x80, 0x31, 0x00, 0x00,
- 0x80, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-static const uint8 moz_copy_mask_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
- 0x1e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00,
- 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0xfe, 0x03, 0x00, 0x00,
- 0xfe, 0x37, 0x00, 0x00, 0xfe, 0x7b, 0x00, 0x00, 0xfe, 0xfc, 0x00, 0x00,
- 0xee, 0xff, 0x01, 0x00, 0xe4, 0xff, 0x01, 0x00, 0xc0, 0xff, 0x00, 0x00,
- 0xc0, 0x7b, 0x00, 0x00, 0x80, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-/* MOZ_CURSOR_ALIAS */
-static const uint8 moz_alias_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x0c, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00,
- 0x7c, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x00,
- 0xfc, 0x03, 0x00, 0x00, 0x7c, 0xf0, 0x00, 0x00, 0x6c, 0xe0, 0x00, 0x00,
- 0xc4, 0xf0, 0x00, 0x00, 0xc0, 0xb0, 0x00, 0x00, 0x80, 0x19, 0x00, 0x00,
- 0x80, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-static const uint8 moz_alias_mask_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
- 0x1e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00,
- 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0xfe, 0x03, 0x00, 0x00,
- 0xfe, 0xf7, 0x00, 0x00, 0xfe, 0xfb, 0x01, 0x00, 0xfe, 0xf0, 0x01, 0x00,
- 0xee, 0xf9, 0x01, 0x00, 0xe4, 0xf9, 0x01, 0x00, 0xc0, 0xbf, 0x00, 0x00,
- 0xc0, 0x3f, 0x00, 0x00, 0x80, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-/* MOZ_CURSOR_ZOOM_IN */
-static const uint8 moz_zoom_in_bits[] = {
- 0xf0, 0x00, 0x00, 0x00, 0x0c, 0x03, 0x00, 0x00, 0x02, 0x04, 0x00, 0x00,
- 0x62, 0x04, 0x00, 0x00, 0x61, 0x08, 0x00, 0x00, 0xf9, 0x09, 0x00, 0x00,
- 0xf9, 0x09, 0x00, 0x00, 0x61, 0x08, 0x00, 0x00, 0x62, 0x04, 0x00, 0x00,
- 0x02, 0x04, 0x00, 0x00, 0x0c, 0x0f, 0x00, 0x00, 0xf0, 0x1c, 0x00, 0x00,
- 0x00, 0x38, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00,
- 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-static const uint8 moz_zoom_in_mask_bits[] = {
- 0xf0, 0x00, 0x00, 0x00, 0xfc, 0x03, 0x00, 0x00, 0xfe, 0x07, 0x00, 0x00,
- 0xfe, 0x07, 0x00, 0x00, 0xff, 0x0f, 0x00, 0x00, 0xff, 0x0f, 0x00, 0x00,
- 0xff, 0x0f, 0x00, 0x00, 0xff, 0x0f, 0x00, 0x00, 0xfe, 0x07, 0x00, 0x00,
- 0xfe, 0x07, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x00, 0xf0, 0x1c, 0x00, 0x00,
- 0x00, 0x38, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00,
- 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-/* MOZ_CURSOR_ZOOM_OUT */
-static const uint8 moz_zoom_out_bits[] = {
- 0xf0, 0x00, 0x00, 0x00, 0x0c, 0x03, 0x00, 0x00, 0x02, 0x04, 0x00, 0x00,
- 0x02, 0x04, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0xf9, 0x09, 0x00, 0x00,
- 0xf9, 0x09, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x02, 0x04, 0x00, 0x00,
- 0x02, 0x04, 0x00, 0x00, 0x0c, 0x0f, 0x00, 0x00, 0xf0, 0x1c, 0x00, 0x00,
- 0x00, 0x38, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00,
- 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-static const uint8 moz_zoom_out_mask_bits[] = {
- 0xf0, 0x00, 0x00, 0x00, 0xfc, 0x03, 0x00, 0x00, 0xfe, 0x07, 0x00, 0x00,
- 0xfe, 0x07, 0x00, 0x00, 0xff, 0x0f, 0x00, 0x00, 0xff, 0x0f, 0x00, 0x00,
- 0xff, 0x0f, 0x00, 0x00, 0xff, 0x0f, 0x00, 0x00, 0xfe, 0x07, 0x00, 0x00,
- 0xfe, 0x07, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x00, 0xf0, 0x1c, 0x00, 0x00,
- 0x00, 0x38, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00,
- 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-/* MOZ_CURSOR_HAND_GRAB */
-static const uint8 moz_hand_grab_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00,
- 0x60, 0x39, 0x00, 0x00, 0x90, 0x49, 0x00, 0x00, 0x90, 0x49, 0x01, 0x00,
- 0x20, 0xc9, 0x02, 0x00, 0x20, 0x49, 0x02, 0x00, 0x58, 0x40, 0x02, 0x00,
- 0x64, 0x00, 0x02, 0x00, 0x44, 0x00, 0x01, 0x00, 0x08, 0x00, 0x01, 0x00,
- 0x10, 0x00, 0x01, 0x00, 0x10, 0x80, 0x00, 0x00, 0x20, 0x80, 0x00, 0x00,
- 0x40, 0x40, 0x00, 0x00, 0x80, 0x40, 0x00, 0x00, 0x80, 0x40, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-static const uint8 moz_hand_grab_mask_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x60, 0x3f, 0x00, 0x00,
- 0xf0, 0x7f, 0x00, 0x00, 0xf8, 0xff, 0x01, 0x00, 0xf8, 0xff, 0x03, 0x00,
- 0xf0, 0xff, 0x07, 0x00, 0xf8, 0xff, 0x07, 0x00, 0xfc, 0xff, 0x07, 0x00,
- 0xfe, 0xff, 0x07, 0x00, 0xfe, 0xff, 0x03, 0x00, 0xfc, 0xff, 0x03, 0x00,
- 0xf8, 0xff, 0x03, 0x00, 0xf8, 0xff, 0x01, 0x00, 0xf0, 0xff, 0x01, 0x00,
- 0xe0, 0xff, 0x00, 0x00, 0xc0, 0xff, 0x00, 0x00, 0xc0, 0xff, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-/* MOZ_CURSOR_HAND_GRABBING */
-static const uint8 moz_hand_grabbing_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xc0, 0x36, 0x00, 0x00, 0x20, 0xc9, 0x00, 0x00, 0x20, 0x40, 0x01, 0x00,
- 0x40, 0x00, 0x01, 0x00, 0x60, 0x00, 0x01, 0x00, 0x10, 0x00, 0x01, 0x00,
- 0x10, 0x00, 0x01, 0x00, 0x10, 0x80, 0x00, 0x00, 0x20, 0x80, 0x00, 0x00,
- 0x40, 0x40, 0x00, 0x00, 0x80, 0x40, 0x00, 0x00, 0x80, 0x40, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-static const uint8 moz_hand_grabbing_mask_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x36, 0x00, 0x00,
- 0xe0, 0xff, 0x00, 0x00, 0xf0, 0xff, 0x01, 0x00, 0xf0, 0xff, 0x03, 0x00,
- 0xe0, 0xff, 0x03, 0x00, 0xf0, 0xff, 0x03, 0x00, 0xf8, 0xff, 0x03, 0x00,
- 0xf8, 0xff, 0x03, 0x00, 0xf8, 0xff, 0x01, 0x00, 0xf0, 0xff, 0x01, 0x00,
- 0xe0, 0xff, 0x00, 0x00, 0xc0, 0xff, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-enum CustomCursorType {
- CustomCursorCopy = 0,
- CustomCursorAlias,
- CustomCursorContextMenu,
- CustomCursorZoomIn,
- CustomCursorZoomOut,
- CustomCursorVerticalText,
- CustomCursorGrab,
- CustomCursorGrabbing,
-};
-
-typedef struct {
- const char* name;
- const uint8* bits;
- const uint8* mask_bits;
- int hot_x;
- int hot_y;
-} CustomCursor;
-
-// create custom pixmap cursor from cursors in nsGTKCursorData.h
-static const CustomCursor CustomCursors[] = {
- { "copy", moz_copy_bits, moz_copy_mask_bits, 2, 2 },
- { "alias", moz_alias_bits, moz_alias_mask_bits, 2, 2 },
- { "context-menu", moz_menu_bits, moz_menu_mask_bits, 2, 2 },
- { "zoom-in", moz_zoom_in_bits, moz_zoom_in_mask_bits, 6, 6 },
- { "zoom-out", moz_zoom_out_bits, moz_zoom_out_mask_bits, 6, 6 },
- { "vertical-text", moz_vertical_text_bits, moz_vertical_text_mask_bits, 8, 4},
- { "grab", moz_hand_grab_bits, moz_hand_grab_mask_bits, 10, 10 },
- { "grabbing", moz_hand_grabbing_bits, moz_hand_grabbing_mask_bits, 10, 10 }
-};
-
-// This cursor intentionally left out of above structs. It is only used by
-// RenderWidgetHostViewGtk. For an explanation see
-// http://vektor-sigma.livejournal.com/1137.html (where it is referred
-// to as left_ptr_watch).
-
-/* MOZ_CURSOR_SPINNING */
-static const uint8 moz_spinning_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x0c, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00,
- 0x7c, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x00,
- 0xfc, 0x3b, 0x00, 0x00, 0x7c, 0x38, 0x00, 0x00, 0x6c, 0x54, 0x00, 0x00,
- 0xc4, 0xdc, 0x00, 0x00, 0xc0, 0x44, 0x00, 0x00, 0x80, 0x39, 0x00, 0x00,
- 0x80, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-static const uint8 moz_spinning_mask_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
- 0x1e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00,
- 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0xfe, 0x3b, 0x00, 0x00,
- 0xfe, 0x7f, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, 0xfe, 0xfe, 0x00, 0x00,
- 0xee, 0xff, 0x01, 0x00, 0xe4, 0xff, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00,
- 0xc0, 0x7f, 0x00, 0x00, 0x80, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
diff --git a/webkit/common/cursors/webcursor_mac.mm b/webkit/common/cursors/webcursor_mac.mm
deleted file mode 100644
index 4358be0..0000000
--- a/webkit/common/cursors/webcursor_mac.mm
+++ /dev/null
@@ -1,395 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "webkit/common/cursors/webcursor.h"
-
-#import <AppKit/AppKit.h>
-
-#include "base/logging.h"
-#include "base/mac/mac_util.h"
-#include "base/mac/scoped_cftyperef.h"
-#include "grit/webkit_resources.h"
-#include "skia/ext/skia_utils_mac.h"
-#include "third_party/WebKit/public/platform/WebCursorInfo.h"
-#include "third_party/WebKit/public/platform/WebSize.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/gfx/point_conversions.h"
-#include "ui/gfx/size_conversions.h"
-
-
-using blink::WebCursorInfo;
-using blink::WebSize;
-
-// Declare symbols that are part of the 10.7 SDK.
-#if !defined(MAC_OS_X_VERSION_10_7) || \
- MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
-
-@interface NSCursor (LionSDKDeclarations)
-+ (NSCursor*)IBeamCursorForVerticalLayout;
-@end
-
-#endif // MAC_OS_X_VERSION_10_7
-
-// Private interface to CoreCursor, as of Mac OS X 10.7. This is essentially the
-// implementation of WKCursor in WebKitSystemInterface.
-
-enum {
- kArrowCursor = 0,
- kIBeamCursor = 1,
- kMakeAliasCursor = 2,
- kOperationNotAllowedCursor = 3,
- kBusyButClickableCursor = 4,
- kCopyCursor = 5,
- kClosedHandCursor = 11,
- kOpenHandCursor = 12,
- kPointingHandCursor = 13,
- kCountingUpHandCursor = 14,
- kCountingDownHandCursor = 15,
- kCountingUpAndDownHandCursor = 16,
- kResizeLeftCursor = 17,
- kResizeRightCursor = 18,
- kResizeLeftRightCursor = 19,
- kCrosshairCursor = 20,
- kResizeUpCursor = 21,
- kResizeDownCursor = 22,
- kResizeUpDownCursor = 23,
- kContextualMenuCursor = 24,
- kDisappearingItemCursor = 25,
- kVerticalIBeamCursor = 26,
- kResizeEastCursor = 27,
- kResizeEastWestCursor = 28,
- kResizeNortheastCursor = 29,
- kResizeNortheastSouthwestCursor = 30,
- kResizeNorthCursor = 31,
- kResizeNorthSouthCursor = 32,
- kResizeNorthwestCursor = 33,
- kResizeNorthwestSoutheastCursor = 34,
- kResizeSoutheastCursor = 35,
- kResizeSouthCursor = 36,
- kResizeSouthwestCursor = 37,
- kResizeWestCursor = 38,
- kMoveCursor = 39,
- kHelpCursor = 40, // Present on >= 10.7.3.
- kCellCursor = 41, // Present on >= 10.7.3.
- kZoomInCursor = 42, // Present on >= 10.7.3.
- kZoomOutCursor = 43 // Present on >= 10.7.3.
-};
-typedef long long CrCoreCursorType;
-
-@interface CrCoreCursor : NSCursor {
- @private
- CrCoreCursorType type_;
-}
-
-+ (id)cursorWithType:(CrCoreCursorType)type;
-- (id)initWithType:(CrCoreCursorType)type;
-- (CrCoreCursorType)_coreCursorType;
-
-@end
-
-@implementation CrCoreCursor
-
-+ (id)cursorWithType:(CrCoreCursorType)type {
- NSCursor* cursor = [[CrCoreCursor alloc] initWithType:type];
- if ([cursor image])
- return [cursor autorelease];
-
- [cursor release];
- return nil;
-}
-
-- (id)initWithType:(CrCoreCursorType)type {
- if ((self = [super init])) {
- type_ = type;
- }
- return self;
-}
-
-- (CrCoreCursorType)_coreCursorType {
- return type_;
-}
-
-@end
-
-namespace {
-
-NSCursor* LoadCursor(int resource_id, int hotspot_x, int hotspot_y) {
- const gfx::Image& cursor_image =
- ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id);
- DCHECK(!cursor_image.IsEmpty());
- return [[[NSCursor alloc] initWithImage:cursor_image.ToNSImage()
- hotSpot:NSMakePoint(hotspot_x,
- hotspot_y)] autorelease];
-}
-
-// Gets a specified cursor from CoreCursor, falling back to loading it from the
-// image cache if CoreCursor cannot provide it.
-NSCursor* GetCoreCursorWithFallback(CrCoreCursorType type,
- int resource_id,
- int hotspot_x,
- int hotspot_y) {
- if (base::mac::IsOSLionOrLater()) {
- NSCursor* cursor = [CrCoreCursor cursorWithType:type];
- if (cursor)
- return cursor;
- }
-
- return LoadCursor(resource_id, hotspot_x, hotspot_y);
-}
-
-NSCursor* CreateCustomCursor(const std::vector<char>& custom_data,
- const gfx::Size& custom_size,
- float custom_scale,
- const gfx::Point& hotspot) {
- // If the data is missing, leave the backing transparent.
- void* data = NULL;
- size_t data_size = 0;
- if (!custom_data.empty()) {
- // This is safe since we're not going to draw into the context we're
- // creating.
- data = const_cast<char*>(&custom_data[0]);
- data_size = custom_data.size();
- }
-
- // If the size is empty, use a 1x1 transparent image.
- gfx::Size size = custom_size;
- if (size.IsEmpty()) {
- size.SetSize(1, 1);
- data = NULL;
- }
-
- SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height());
- bitmap.allocPixels();
- if (data)
- memcpy(bitmap.getAddr32(0, 0), data, data_size);
- else
- bitmap.eraseARGB(0, 0, 0, 0);
-
- // Convert from pixels to view units.
- if (custom_scale == 0)
- custom_scale = 1;
- NSSize dip_size = NSSizeFromCGSize(gfx::ToFlooredSize(
- gfx::ScaleSize(custom_size, 1 / custom_scale)).ToCGSize());
- NSPoint dip_hotspot = NSPointFromCGPoint(gfx::ToFlooredPoint(
- gfx::ScalePoint(hotspot, 1 / custom_scale)).ToCGPoint());
-
- // Both the image and its representation need to have the same size for
- // cursors to appear in high resolution on retina displays. Note that the
- // size of a representation is not the same as pixelsWide or pixelsHigh.
- NSImage* cursor_image = gfx::SkBitmapToNSImage(bitmap);
- [cursor_image setSize:dip_size];
- [[[cursor_image representations] objectAtIndex:0] setSize:dip_size];
-
- NSCursor* cursor = [[NSCursor alloc] initWithImage:cursor_image
- hotSpot:dip_hotspot];
-
- return [cursor autorelease];
-}
-
-} // namespace
-
-// Match Safari's cursor choices; see platform/mac/CursorMac.mm .
-gfx::NativeCursor WebCursor::GetNativeCursor() {
- switch (type_) {
- case WebCursorInfo::TypePointer:
- return [NSCursor arrowCursor];
- case WebCursorInfo::TypeCross:
- return [NSCursor crosshairCursor];
- case WebCursorInfo::TypeHand:
- // If >= 10.7, the pointingHandCursor has a shadow so use it. Otherwise
- // use the custom one.
- if (base::mac::IsOSLionOrLater())
- return [NSCursor pointingHandCursor];
- else
- return LoadCursor(IDR_LINK_CURSOR, 6, 1);
- case WebCursorInfo::TypeIBeam:
- return [NSCursor IBeamCursor];
- case WebCursorInfo::TypeWait:
- return GetCoreCursorWithFallback(kBusyButClickableCursor,
- IDR_WAIT_CURSOR, 7, 7);
- case WebCursorInfo::TypeHelp:
- return GetCoreCursorWithFallback(kHelpCursor,
- IDR_HELP_CURSOR, 8, 8);
- case WebCursorInfo::TypeEastResize:
- case WebCursorInfo::TypeEastPanning:
- return GetCoreCursorWithFallback(kResizeEastCursor,
- IDR_EAST_RESIZE_CURSOR, 14, 7);
- case WebCursorInfo::TypeNorthResize:
- case WebCursorInfo::TypeNorthPanning:
- return GetCoreCursorWithFallback(kResizeNorthCursor,
- IDR_NORTH_RESIZE_CURSOR, 7, 1);
- case WebCursorInfo::TypeNorthEastResize:
- case WebCursorInfo::TypeNorthEastPanning:
- return GetCoreCursorWithFallback(kResizeNortheastCursor,
- IDR_NORTHEAST_RESIZE_CURSOR, 14, 1);
- case WebCursorInfo::TypeNorthWestResize:
- case WebCursorInfo::TypeNorthWestPanning:
- return GetCoreCursorWithFallback(kResizeNorthwestCursor,
- IDR_NORTHWEST_RESIZE_CURSOR, 0, 0);
- case WebCursorInfo::TypeSouthResize:
- case WebCursorInfo::TypeSouthPanning:
- return GetCoreCursorWithFallback(kResizeSouthCursor,
- IDR_SOUTH_RESIZE_CURSOR, 7, 14);
- case WebCursorInfo::TypeSouthEastResize:
- case WebCursorInfo::TypeSouthEastPanning:
- return GetCoreCursorWithFallback(kResizeSoutheastCursor,
- IDR_SOUTHEAST_RESIZE_CURSOR, 14, 14);
- case WebCursorInfo::TypeSouthWestResize:
- case WebCursorInfo::TypeSouthWestPanning:
- return GetCoreCursorWithFallback(kResizeSouthwestCursor,
- IDR_SOUTHWEST_RESIZE_CURSOR, 1, 14);
- case WebCursorInfo::TypeWestResize:
- case WebCursorInfo::TypeWestPanning:
- return GetCoreCursorWithFallback(kResizeWestCursor,
- IDR_WEST_RESIZE_CURSOR, 1, 7);
- case WebCursorInfo::TypeNorthSouthResize:
- return GetCoreCursorWithFallback(kResizeNorthSouthCursor,
- IDR_NORTHSOUTH_RESIZE_CURSOR, 7, 7);
- case WebCursorInfo::TypeEastWestResize:
- return GetCoreCursorWithFallback(kResizeEastWestCursor,
- IDR_EASTWEST_RESIZE_CURSOR, 7, 7);
- case WebCursorInfo::TypeNorthEastSouthWestResize:
- return GetCoreCursorWithFallback(kResizeNortheastSouthwestCursor,
- IDR_NORTHEASTSOUTHWEST_RESIZE_CURSOR,
- 7, 7);
- case WebCursorInfo::TypeNorthWestSouthEastResize:
- return GetCoreCursorWithFallback(kResizeNorthwestSoutheastCursor,
- IDR_NORTHWESTSOUTHEAST_RESIZE_CURSOR,
- 7, 7);
- case WebCursorInfo::TypeColumnResize:
- return [NSCursor resizeLeftRightCursor];
- case WebCursorInfo::TypeRowResize:
- return [NSCursor resizeUpDownCursor];
- case WebCursorInfo::TypeMiddlePanning:
- case WebCursorInfo::TypeMove:
- return GetCoreCursorWithFallback(kMoveCursor,
- IDR_MOVE_CURSOR, 7, 7);
- case WebCursorInfo::TypeVerticalText:
- // IBeamCursorForVerticalLayout is >= 10.7.
- if ([NSCursor respondsToSelector:@selector(IBeamCursorForVerticalLayout)])
- return [NSCursor IBeamCursorForVerticalLayout];
- else
- return LoadCursor(IDR_VERTICALTEXT_CURSOR, 7, 7);
- case WebCursorInfo::TypeCell:
- return GetCoreCursorWithFallback(kCellCursor,
- IDR_CELL_CURSOR, 7, 7);
- case WebCursorInfo::TypeContextMenu:
- return [NSCursor contextualMenuCursor];
- case WebCursorInfo::TypeAlias:
- return GetCoreCursorWithFallback(kMakeAliasCursor,
- IDR_ALIAS_CURSOR, 11, 3);
- case WebCursorInfo::TypeProgress:
- return GetCoreCursorWithFallback(kBusyButClickableCursor,
- IDR_PROGRESS_CURSOR, 3, 2);
- case WebCursorInfo::TypeNoDrop:
- case WebCursorInfo::TypeNotAllowed:
- return [NSCursor operationNotAllowedCursor];
- case WebCursorInfo::TypeCopy:
- return [NSCursor dragCopyCursor];
- case WebCursorInfo::TypeNone:
- return LoadCursor(IDR_NONE_CURSOR, 7, 7);
- case WebCursorInfo::TypeZoomIn:
- return GetCoreCursorWithFallback(kZoomInCursor,
- IDR_ZOOMIN_CURSOR, 7, 7);
- case WebCursorInfo::TypeZoomOut:
- return GetCoreCursorWithFallback(kZoomOutCursor,
- IDR_ZOOMOUT_CURSOR, 7, 7);
- case WebCursorInfo::TypeGrab:
- return [NSCursor openHandCursor];
- case WebCursorInfo::TypeGrabbing:
- return [NSCursor closedHandCursor];
- case WebCursorInfo::TypeCustom:
- return CreateCustomCursor(
- custom_data_, custom_size_, custom_scale_, hotspot_);
- }
- NOTREACHED();
- return nil;
-}
-
-void WebCursor::InitFromNSCursor(NSCursor* cursor) {
- CursorInfo cursor_info;
-
- if ([cursor isEqual:[NSCursor arrowCursor]]) {
- cursor_info.type = WebCursorInfo::TypePointer;
- } else if ([cursor isEqual:[NSCursor IBeamCursor]]) {
- cursor_info.type = WebCursorInfo::TypeIBeam;
- } else if ([cursor isEqual:[NSCursor crosshairCursor]]) {
- cursor_info.type = WebCursorInfo::TypeCross;
- } else if ([cursor isEqual:[NSCursor pointingHandCursor]]) {
- cursor_info.type = WebCursorInfo::TypeHand;
- } else if ([cursor isEqual:[NSCursor resizeLeftCursor]]) {
- cursor_info.type = WebCursorInfo::TypeWestResize;
- } else if ([cursor isEqual:[NSCursor resizeRightCursor]]) {
- cursor_info.type = WebCursorInfo::TypeEastResize;
- } else if ([cursor isEqual:[NSCursor resizeLeftRightCursor]]) {
- cursor_info.type = WebCursorInfo::TypeEastWestResize;
- } else if ([cursor isEqual:[NSCursor resizeUpCursor]]) {
- cursor_info.type = WebCursorInfo::TypeNorthResize;
- } else if ([cursor isEqual:[NSCursor resizeDownCursor]]) {
- cursor_info.type = WebCursorInfo::TypeSouthResize;
- } else if ([cursor isEqual:[NSCursor resizeUpDownCursor]]) {
- cursor_info.type = WebCursorInfo::TypeNorthSouthResize;
- } else if ([cursor isEqual:[NSCursor openHandCursor]]) {
- cursor_info.type = WebCursorInfo::TypeGrab;
- } else if ([cursor isEqual:[NSCursor closedHandCursor]]) {
- cursor_info.type = WebCursorInfo::TypeGrabbing;
- } else if ([cursor isEqual:[NSCursor operationNotAllowedCursor]]) {
- cursor_info.type = WebCursorInfo::TypeNotAllowed;
- } else if ([cursor isEqual:[NSCursor dragCopyCursor]]) {
- cursor_info.type = WebCursorInfo::TypeCopy;
- } else if ([cursor isEqual:[NSCursor contextualMenuCursor]]) {
- cursor_info.type = WebCursorInfo::TypeContextMenu;
- } else if (
- [NSCursor respondsToSelector:@selector(IBeamCursorForVerticalLayout)] &&
- [cursor isEqual:[NSCursor IBeamCursorForVerticalLayout]]) {
- cursor_info.type = WebCursorInfo::TypeVerticalText;
- } else {
- // Also handles the [NSCursor disappearingItemCursor] case. Quick-and-dirty
- // image conversion; TODO(avi): do better.
- CGImageRef cg_image = nil;
- NSImage* image = [cursor image];
- for (id rep in [image representations]) {
- if ([rep isKindOfClass:[NSBitmapImageRep class]]) {
- cg_image = [rep CGImage];
- break;
- }
- }
-
- if (cg_image) {
- cursor_info.type = WebCursorInfo::TypeCustom;
- NSPoint hot_spot = [cursor hotSpot];
- cursor_info.hotspot = gfx::Point(hot_spot.x, hot_spot.y);
- cursor_info.custom_image = gfx::CGImageToSkBitmap(cg_image);
- } else {
- cursor_info.type = WebCursorInfo::TypePointer;
- }
- }
-
- InitFromCursorInfo(cursor_info);
-}
-
-void WebCursor::InitPlatformData() {
- return;
-}
-
-bool WebCursor::SerializePlatformData(Pickle* pickle) const {
- return true;
-}
-
-bool WebCursor::DeserializePlatformData(PickleIterator* iter) {
- return true;
-}
-
-bool WebCursor::IsPlatformDataEqual(const WebCursor& other) const {
- return true;
-}
-
-void WebCursor::CleanupPlatformData() {
- return;
-}
-
-void WebCursor::CopyPlatformData(const WebCursor& other) {
- return;
-}
diff --git a/webkit/common/cursors/webcursor_null.cc b/webkit/common/cursors/webcursor_null.cc
deleted file mode 100644
index 17fad06..0000000
--- a/webkit/common/cursors/webcursor_null.cc
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "webkit/common/cursors/webcursor.h"
-
-const ui::PlatformCursor WebCursor::GetPlatformCursor() {
- return NULL;
-}
-
-void WebCursor::SetDisplayInfo(const gfx::Display& display) {
- return;
-}
-
-void WebCursor::InitPlatformData() {
-}
-
-bool WebCursor::SerializePlatformData(Pickle* pickle) const {
- return true;
-}
-
-bool WebCursor::DeserializePlatformData(PickleIterator* iter) {
- return true;
-}
-
-bool WebCursor::IsPlatformDataEqual(const WebCursor& other) const {
- return true;
-}
-
-void WebCursor::CleanupPlatformData() {
-}
-
-void WebCursor::CopyPlatformData(const WebCursor& other) {
-}
diff --git a/webkit/common/cursors/webcursor_unittest.cc b/webkit/common/cursors/webcursor_unittest.cc
deleted file mode 100644
index fe78144..0000000
--- a/webkit/common/cursors/webcursor_unittest.cc
+++ /dev/null
@@ -1,230 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/pickle.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/WebKit/public/platform/WebCursorInfo.h"
-#include "webkit/common/cursors/webcursor.h"
-
-using blink::WebCursorInfo;
-
-TEST(WebCursorTest, OKCursorSerialization) {
- WebCursor custom_cursor;
- // This is a valid custom cursor.
- Pickle ok_custom_pickle;
- // Type and hotspots.
- ok_custom_pickle.WriteInt(WebCursorInfo::TypeCustom);
- ok_custom_pickle.WriteInt(0);
- ok_custom_pickle.WriteInt(0);
- // X & Y
- ok_custom_pickle.WriteInt(1);
- ok_custom_pickle.WriteInt(1);
- // Scale
- ok_custom_pickle.WriteFloat(1.0);
- // Data len including enough data for a 1x1 image.
- ok_custom_pickle.WriteInt(4);
- ok_custom_pickle.WriteUInt32(0);
- // Custom Windows message.
- ok_custom_pickle.WriteUInt32(0);
- PickleIterator iter(ok_custom_pickle);
- EXPECT_TRUE(custom_cursor.Deserialize(&iter));
-
-#if defined(TOOLKIT_GTK)
- // On GTK+ using platforms, we should get a real native GdkCursor object back
- // (and the memory used should automatically be freed by the WebCursor object
- // for valgrind tests).
- EXPECT_TRUE(custom_cursor.GetCustomCursor());
-#endif
-}
-
-TEST(WebCursorTest, BrokenCursorSerialization) {
- WebCursor custom_cursor;
- // This custom cursor has not been send with enough data.
- Pickle short_custom_pickle;
- // Type and hotspots.
- short_custom_pickle.WriteInt(WebCursorInfo::TypeCustom);
- short_custom_pickle.WriteInt(0);
- short_custom_pickle.WriteInt(0);
- // X & Y
- short_custom_pickle.WriteInt(1);
- short_custom_pickle.WriteInt(1);
- // Scale
- short_custom_pickle.WriteFloat(1.0);
- // Data len not including enough data for a 1x1 image.
- short_custom_pickle.WriteInt(3);
- short_custom_pickle.WriteUInt32(0);
- PickleIterator iter(short_custom_pickle);
- EXPECT_FALSE(custom_cursor.Deserialize(&iter));
-
- // This custom cursor has enough data but is too big.
- Pickle large_custom_pickle;
- // Type and hotspots.
- large_custom_pickle.WriteInt(WebCursorInfo::TypeCustom);
- large_custom_pickle.WriteInt(0);
- large_custom_pickle.WriteInt(0);
- // X & Y
- static const int kTooBigSize = 4096 + 1;
- large_custom_pickle.WriteInt(kTooBigSize);
- large_custom_pickle.WriteInt(1);
- // Scale
- large_custom_pickle.WriteFloat(1.0);
- // Data len including enough data for a 4097x1 image.
- large_custom_pickle.WriteInt(kTooBigSize * 4);
- for (int i = 0; i < kTooBigSize; ++i)
- large_custom_pickle.WriteUInt32(0);
- iter = PickleIterator(large_custom_pickle);
- EXPECT_FALSE(custom_cursor.Deserialize(&iter));
-
- // This custom cursor uses negative lengths.
- Pickle neg_custom_pickle;
- // Type and hotspots.
- neg_custom_pickle.WriteInt(WebCursorInfo::TypeCustom);
- neg_custom_pickle.WriteInt(0);
- neg_custom_pickle.WriteInt(0);
- // X & Y
- neg_custom_pickle.WriteInt(-1);
- neg_custom_pickle.WriteInt(-1);
- // Scale
- neg_custom_pickle.WriteFloat(1.0);
- // Data len including enough data for a 1x1 image.
- neg_custom_pickle.WriteInt(4);
- neg_custom_pickle.WriteUInt32(0);
- // Custom Windows message.
- neg_custom_pickle.WriteUInt32(0);
- iter = PickleIterator(neg_custom_pickle);
- EXPECT_FALSE(custom_cursor.Deserialize(&iter));
-
- // This custom cursor uses zero scale.
- Pickle scale_zero_custom_pickle;
- // Type and hotspots.
- scale_zero_custom_pickle.WriteInt(WebCursorInfo::TypeCustom);
- scale_zero_custom_pickle.WriteInt(0);
- scale_zero_custom_pickle.WriteInt(0);
- // X & Y
- scale_zero_custom_pickle.WriteInt(1);
- scale_zero_custom_pickle.WriteInt(1);
- // Scale
- scale_zero_custom_pickle.WriteFloat(0);
- // Data len including enough data for a 1x1 image.
- scale_zero_custom_pickle.WriteInt(4);
- scale_zero_custom_pickle.WriteUInt32(0);
- // Custom Windows message.
- scale_zero_custom_pickle.WriteUInt32(0);
- iter = PickleIterator(scale_zero_custom_pickle);
- EXPECT_FALSE(custom_cursor.Deserialize(&iter));
-
- // This custom cursor uses tiny scale.
- Pickle scale_tiny_custom_pickle;
- // Type and hotspots.
- scale_tiny_custom_pickle.WriteInt(WebCursorInfo::TypeCustom);
- scale_tiny_custom_pickle.WriteInt(0);
- scale_tiny_custom_pickle.WriteInt(0);
- // X & Y
- scale_tiny_custom_pickle.WriteInt(1);
- scale_tiny_custom_pickle.WriteInt(1);
- // Scale
- scale_tiny_custom_pickle.WriteFloat(0.001f);
- // Data len including enough data for a 1x1 image.
- scale_tiny_custom_pickle.WriteInt(4);
- scale_tiny_custom_pickle.WriteUInt32(0);
- // Custom Windows message.
- scale_tiny_custom_pickle.WriteUInt32(0);
- iter = PickleIterator(scale_tiny_custom_pickle);
- EXPECT_FALSE(custom_cursor.Deserialize(&iter));
-}
-
-TEST(WebCursorTest, ClampHotspot) {
- WebCursor custom_cursor;
- // This is a valid custom cursor.
- Pickle ok_custom_pickle;
- // Type and hotspots.
- ok_custom_pickle.WriteInt(WebCursorInfo::TypeCustom);
- // Hotspot is invalid --- outside the bounds of the image.
- ok_custom_pickle.WriteInt(5);
- ok_custom_pickle.WriteInt(5);
- // X & Y
- ok_custom_pickle.WriteInt(2);
- ok_custom_pickle.WriteInt(2);
- // Scale
- ok_custom_pickle.WriteFloat(1.0);
- // Data len including enough data for a 2x2 image.
- ok_custom_pickle.WriteInt(4 * 4);
- for (size_t i = 0; i < 4; i++)
- ok_custom_pickle.WriteUInt32(0);
- // Custom Windows message.
- ok_custom_pickle.WriteUInt32(0);
- PickleIterator iter(ok_custom_pickle);
- ASSERT_TRUE(custom_cursor.Deserialize(&iter));
-
- // Convert to WebCursorInfo, make sure the hotspot got clamped.
- WebCursor::CursorInfo info;
- custom_cursor.GetCursorInfo(&info);
- EXPECT_EQ(gfx::Point(1, 1), info.hotspot);
-
- // Set hotspot to an invalid point again, pipe back through WebCursor,
- // and make sure the hotspot got clamped again.
- info.hotspot = gfx::Point(-1, -1);
- custom_cursor.InitFromCursorInfo(info);
- custom_cursor.GetCursorInfo(&info);
- EXPECT_EQ(gfx::Point(0, 0), info.hotspot);
-}
-
-TEST(WebCursorTest, EmptyImage) {
- WebCursor custom_cursor;
- Pickle broken_cursor_pickle;
- broken_cursor_pickle.WriteInt(WebCursorInfo::TypeCustom);
- // Hotspot is at origin
- broken_cursor_pickle.WriteInt(0);
- broken_cursor_pickle.WriteInt(0);
- // X & Y are empty
- broken_cursor_pickle.WriteInt(0);
- broken_cursor_pickle.WriteInt(0);
- // Scale
- broken_cursor_pickle.WriteFloat(1.0);
- // No data for the image since the size is 0.
- broken_cursor_pickle.WriteInt(0);
- // Custom Windows message.
- broken_cursor_pickle.WriteInt(0);
-
- // Make sure we can read this on all platforms; it is technicaally a valid
- // cursor.
- PickleIterator iter(broken_cursor_pickle);
- ASSERT_TRUE(custom_cursor.Deserialize(&iter));
-
-#if defined(TOOLKIT_GTK)
- // On GTK+ using platforms, we make sure that we get NULL back from this
- // method; the relevant GDK methods take NULL as a request to use the default
- // cursor.
- EXPECT_EQ(NULL, custom_cursor.GetCustomCursor());
-#endif
-}
-
-TEST(WebCursorTest, Scale2) {
- WebCursor custom_cursor;
- // This is a valid custom cursor.
- Pickle ok_custom_pickle;
- // Type and hotspots.
- ok_custom_pickle.WriteInt(WebCursorInfo::TypeCustom);
- ok_custom_pickle.WriteInt(0);
- ok_custom_pickle.WriteInt(0);
- // X & Y
- ok_custom_pickle.WriteInt(1);
- ok_custom_pickle.WriteInt(1);
- // Scale - 2 image pixels per UI pixel.
- ok_custom_pickle.WriteFloat(2.0);
- // Data len including enough data for a 1x1 image.
- ok_custom_pickle.WriteInt(4);
- ok_custom_pickle.WriteUInt32(0);
- // Custom Windows message.
- ok_custom_pickle.WriteUInt32(0);
- PickleIterator iter(ok_custom_pickle);
- EXPECT_TRUE(custom_cursor.Deserialize(&iter));
-
-#if defined(TOOLKIT_GTK)
- // On GTK+ using platforms, we should get a real native GdkCursor object back
- // (and the memory used should automatically be freed by the WebCursor object
- // for valgrind tests).
- EXPECT_TRUE(custom_cursor.GetCustomCursor());
-#endif
-}
diff --git a/webkit/common/cursors/webcursor_win.cc b/webkit/common/cursors/webcursor_win.cc
deleted file mode 100644
index e825adf..0000000
--- a/webkit/common/cursors/webcursor_win.cc
+++ /dev/null
@@ -1,181 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/logging.h"
-#include "base/pickle.h"
-#include "grit/ui_unscaled_resources.h"
-#include "third_party/WebKit/public/platform/WebCursorInfo.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-#include "ui/gfx/icon_util.h"
-#include "webkit/common/cursors/webcursor.h"
-
-using blink::WebCursorInfo;
-
-static LPCWSTR ToCursorID(WebCursorInfo::Type type) {
- switch (type) {
- case WebCursorInfo::TypePointer:
- return IDC_ARROW;
- case WebCursorInfo::TypeCross:
- return IDC_CROSS;
- case WebCursorInfo::TypeHand:
- return IDC_HAND;
- case WebCursorInfo::TypeIBeam:
- return IDC_IBEAM;
- case WebCursorInfo::TypeWait:
- return IDC_WAIT;
- case WebCursorInfo::TypeHelp:
- return IDC_HELP;
- case WebCursorInfo::TypeEastResize:
- return IDC_SIZEWE;
- case WebCursorInfo::TypeNorthResize:
- return IDC_SIZENS;
- case WebCursorInfo::TypeNorthEastResize:
- return IDC_SIZENESW;
- case WebCursorInfo::TypeNorthWestResize:
- return IDC_SIZENWSE;
- case WebCursorInfo::TypeSouthResize:
- return IDC_SIZENS;
- case WebCursorInfo::TypeSouthEastResize:
- return IDC_SIZENWSE;
- case WebCursorInfo::TypeSouthWestResize:
- return IDC_SIZENESW;
- case WebCursorInfo::TypeWestResize:
- return IDC_SIZEWE;
- case WebCursorInfo::TypeNorthSouthResize:
- return IDC_SIZENS;
- case WebCursorInfo::TypeEastWestResize:
- return IDC_SIZEWE;
- case WebCursorInfo::TypeNorthEastSouthWestResize:
- return IDC_SIZENESW;
- case WebCursorInfo::TypeNorthWestSouthEastResize:
- return IDC_SIZENWSE;
- case WebCursorInfo::TypeColumnResize:
- return MAKEINTRESOURCE(IDC_COLRESIZE);
- case WebCursorInfo::TypeRowResize:
- return MAKEINTRESOURCE(IDC_ROWRESIZE);
- case WebCursorInfo::TypeMiddlePanning:
- return MAKEINTRESOURCE(IDC_PAN_MIDDLE);
- case WebCursorInfo::TypeEastPanning:
- return MAKEINTRESOURCE(IDC_PAN_EAST);
- case WebCursorInfo::TypeNorthPanning:
- return MAKEINTRESOURCE(IDC_PAN_NORTH);
- case WebCursorInfo::TypeNorthEastPanning:
- return MAKEINTRESOURCE(IDC_PAN_NORTH_EAST);
- case WebCursorInfo::TypeNorthWestPanning:
- return MAKEINTRESOURCE(IDC_PAN_NORTH_WEST);
- case WebCursorInfo::TypeSouthPanning:
- return MAKEINTRESOURCE(IDC_PAN_SOUTH);
- case WebCursorInfo::TypeSouthEastPanning:
- return MAKEINTRESOURCE(IDC_PAN_SOUTH_EAST);
- case WebCursorInfo::TypeSouthWestPanning:
- return MAKEINTRESOURCE(IDC_PAN_SOUTH_WEST);
- case WebCursorInfo::TypeWestPanning:
- return MAKEINTRESOURCE(IDC_PAN_WEST);
- case WebCursorInfo::TypeMove:
- return IDC_SIZEALL;
- case WebCursorInfo::TypeVerticalText:
- return MAKEINTRESOURCE(IDC_VERTICALTEXT);
- case WebCursorInfo::TypeCell:
- return MAKEINTRESOURCE(IDC_CELL);
- case WebCursorInfo::TypeContextMenu:
- return MAKEINTRESOURCE(IDC_ARROW);
- case WebCursorInfo::TypeAlias:
- return MAKEINTRESOURCE(IDC_ALIAS);
- case WebCursorInfo::TypeProgress:
- return IDC_APPSTARTING;
- case WebCursorInfo::TypeNoDrop:
- return IDC_NO;
- case WebCursorInfo::TypeCopy:
- return MAKEINTRESOURCE(IDC_COPYCUR);
- case WebCursorInfo::TypeNone:
- return MAKEINTRESOURCE(IDC_CURSOR_NONE);
- case WebCursorInfo::TypeNotAllowed:
- return IDC_NO;
- case WebCursorInfo::TypeZoomIn:
- return MAKEINTRESOURCE(IDC_ZOOMIN);
- case WebCursorInfo::TypeZoomOut:
- return MAKEINTRESOURCE(IDC_ZOOMOUT);
- case WebCursorInfo::TypeGrab:
- return MAKEINTRESOURCE(IDC_HAND_GRAB);
- case WebCursorInfo::TypeGrabbing:
- return MAKEINTRESOURCE(IDC_HAND_GRABBING);
- }
- NOTREACHED();
- return NULL;
-}
-
-static bool IsSystemCursorID(LPCWSTR cursor_id) {
- return cursor_id >= IDC_ARROW; // See WinUser.h
-}
-
-HCURSOR WebCursor::GetCursor(HINSTANCE module_handle){
- if (!IsCustom()) {
- const wchar_t* cursor_id =
- ToCursorID(static_cast<WebCursorInfo::Type>(type_));
-
- if (IsSystemCursorID(cursor_id))
- module_handle = NULL;
-
- return LoadCursor(module_handle, cursor_id);
- }
-
- if (custom_cursor_) {
- DCHECK(external_cursor_ == NULL);
- return custom_cursor_;
- }
-
- if (external_cursor_)
- return external_cursor_;
-
- custom_cursor_ =
- IconUtil::CreateCursorFromDIB(
- custom_size_,
- hotspot_,
- !custom_data_.empty() ? &custom_data_[0] : NULL,
- custom_data_.size());
- return custom_cursor_;
-}
-
-gfx::NativeCursor WebCursor::GetNativeCursor() {
- return GetCursor(NULL);
-}
-
-void WebCursor::InitPlatformData() {
- custom_cursor_ = NULL;
-}
-
-bool WebCursor::SerializePlatformData(Pickle* pickle) const {
- // There are some issues with converting certain HCURSORS to bitmaps. The
- // HCURSOR being a user object can be marshaled as is.
- // HCURSORs are always 32 bits on Windows, even on 64 bit systems.
- return pickle->WriteUInt32(reinterpret_cast<uint32>(external_cursor_));
-}
-
-bool WebCursor::DeserializePlatformData(PickleIterator* iter) {
- return iter->ReadUInt32(reinterpret_cast<uint32*>(&external_cursor_));
-}
-
-bool WebCursor::IsPlatformDataEqual(const WebCursor& other) const {
- if (!IsCustom())
- return true;
-
- return (external_cursor_ == other.external_cursor_);
-}
-
-void WebCursor::CopyPlatformData(const WebCursor& other) {
- external_cursor_ = other.external_cursor_;
- // The custom_cursor_ member will be initialized to a HCURSOR the next time
- // the GetCursor member function is invoked on this WebCursor instance. The
- // cursor is created using the data in the custom_data_ vector.
- custom_cursor_ = NULL;
-}
-
-void WebCursor::CleanupPlatformData() {
- external_cursor_ = NULL;
-
- if (custom_cursor_) {
- DestroyIcon(custom_cursor_);
- custom_cursor_ = NULL;
- }
-}
diff --git a/webkit/common/webkit_common.gyp b/webkit/common/webkit_common.gyp
index 74c78db..21260c2 100644
--- a/webkit/common/webkit_common.gyp
+++ b/webkit/common/webkit_common.gyp
@@ -39,17 +39,6 @@
],
'sources': [
- 'cursors/webcursor.cc',
- 'cursors/webcursor.h',
- 'cursors/webcursor_android.cc',
- 'cursors/webcursor_aura.cc',
- 'cursors/webcursor_aurawin.cc',
- 'cursors/webcursor_aurax11.cc',
- 'cursors/webcursor_gtk.cc',
- 'cursors/webcursor_gtk_data.h',
- 'cursors/webcursor_mac.mm',
- 'cursors/webcursor_null.cc',
- 'cursors/webcursor_win.cc',
'data_element.cc',
'data_element.h',
'resource_devtools_info.cc',
@@ -70,22 +59,11 @@
],
'sources/': [['exclude', '_x11\\.cc$']],
}],
- ['use_aura==1', {
- 'sources!': [
- 'cursors/webcursor_mac.mm',
- 'cursors/webcursor_win.cc',
- ],
- }],
['use_aura==1 and use_x11==1', {
'dependencies': [
'<(DEPTH)/build/linux/system.gyp:xcursor',
],
}],
- ['use_ozone==0', {
- 'sources!': [
- 'cursors/webcursor_null.cc',
- ],
- }],
['OS=="mac"', {
'link_settings': {
'libraries': [