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

Unified Diff: webkit/glue/webcursor.cc

Issue 15088: Add support for custom cursors set by windowless plugins. Windowless plugins... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 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_gtk.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 7750)
+++ webkit/glue/webcursor.cc (working copy)
@@ -14,6 +14,7 @@
WebCursor::WebCursor()
: type_(WebCore::PlatformCursor::typePointer) {
+ InitPlatformData();
}
WebCursor::WebCursor(const WebCore::PlatformCursor& platform_cursor)
@@ -21,10 +22,31 @@
hotspot_(platform_cursor.hotSpot().x(), platform_cursor.hotSpot().y()) {
if (IsCustom())
SetCustomData(platform_cursor.customImage().get());
+
+ InitPlatformData();
}
+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;
+}
+
bool WebCursor::Deserialize(const Pickle* pickle, void** iter) {
int type, hotspot_x, hotspot_y, size_x, size_y, data_len;
+
const char* data;
// Leave |this| unmodified unless we are going to return success.
@@ -48,7 +70,7 @@
memcpy(&custom_data_[0], data, data_len);
}
- return true;
+ return DeserializePlatformData(pickle, iter);
}
bool WebCursor::Serialize(Pickle* pickle) const {
@@ -62,7 +84,10 @@
const char* data = NULL;
if (!custom_data_.empty())
data = &custom_data_[0];
- return pickle->WriteData(data, custom_data_.size());
+ if (!pickle->WriteData(data, custom_data_.size()))
+ return false;
+
+ return SerializePlatformData(pickle);
}
bool WebCursor::IsCustom() const {
@@ -70,19 +95,43 @@
}
bool WebCursor::IsEqual(const WebCursor& other) const {
- if (!IsCustom())
- return type_ == other.type_;
+ if (type_ != other.type_)
+ return false;
+ if (!IsPlatformDataEqual(other))
+ return false;
+
return hotspot_ == other.hotspot_ &&
custom_size_ == other.custom_size_ &&
custom_data_ == other.custom_data_;
}
+void WebCursor::Clear() {
+ type_ = WebCore::PlatformCursor::typePointer;
+ hotspot_.set_x(0);
+ hotspot_.set_y(0);
+ custom_size_.set_width(0);
+ custom_size_.set_height(0);
+ custom_data_.clear();
+ CleanupPlatformData();
+}
+
+void WebCursor::Copy(const WebCursor& other) {
+ type_ = other.type_;
+ hotspot_ = other.hotspot_;
+ custom_size_ = other.custom_size_;
+ custom_data_ = other.custom_data_;
+ CopyPlatformData(other);
+}
+
#if !defined(OS_MACOSX)
// The Mac version of Chromium is built with PLATFORM(CG) while all other
// versions are PLATFORM(SKIA). We'll keep this Skia implementation here for
// common use and put the Mac implementation in webcursor_mac.mm.
void WebCursor::SetCustomData(WebCore::Image* image) {
+ if (!image)
+ return;
+
WebCore::NativeImagePtr image_ptr = image->nativeImageForCurrentFrame();
if (!image_ptr)
return;
« no previous file with comments | « webkit/glue/webcursor.h ('k') | webkit/glue/webcursor_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698