summaryrefslogtreecommitdiffstats
path: root/webkit/glue/webcursor.cc
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-09 01:20:38 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-09 01:20:38 +0000
commitcf4e5eb1df0fcbf192584b61e83e0b85cf23a1cf (patch)
treebce3c121d9679666d8acdf73cb082a684cf491e4 /webkit/glue/webcursor.cc
parent710e056bd5005f8d0f9f9d5f4b8623f9c9dd7004 (diff)
downloadchromium_src-cf4e5eb1df0fcbf192584b61e83e0b85cf23a1cf.zip
chromium_src-cf4e5eb1df0fcbf192584b61e83e0b85cf23a1cf.tar.gz
chromium_src-cf4e5eb1df0fcbf192584b61e83e0b85cf23a1cf.tar.bz2
Add support for custom cursors set by windowless plugins. Windowless plugins typically set the cursor in NPP_HandleEvent for WM_MOUSEMOVE.The current implementation looks for the cursor type and if the typedoes not match predefinedcursor types defaults to the pointer cursor.
The fixes are as below:- 1. Marshal the HCURSOR after copying it to ensure that it remains valid. This works as a HCURSOR is a user object and can be used across processes. Ideally we would like to convert it to a skia bitmap but there are issues with converting monochrome cursors. 2. Added support for marshaling platform specific data in the webcursor Serialize/Deserialize functions. This is in the form of functions like InitPlatformData, SerializePlatformData, DeserializePlatformData, etc. which are stubbed out for the other platforms. 3. Mimic webkit windowless plugin behavior where it sets a flag to ignore the next setCursor after HandleEvent of WM_MOUSEMOVE. If we don't do this the cursor keeps changing between a pointerCursor and the cursor set by the plugin which also causes flicker. 4. Fixed the WebCursor::IsEqual function to ensure that it checks all fields for equality. 5. The browser(RenderWidgetHostViewWin) now maintains a WebCursor instance representing the current cursor. Any cursor updates received from the renderer update the current cursor member maintained by the browser. 6. We intercept the SetCursor API for windowless plugins like Flash and Silverlight and remember the cursor being set. We don't invoke the original API as the browser UI thread would do it anyways. This fixes the annoying cursor flicker caused by the windowless flash plugin instance constantly setting the cursor even when the tab is not visible. This fixes bug http://code.google.com/p/chromium/issues/detail?id=3800. Review URL: http://codereview.chromium.org/15088 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7798 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webcursor.cc')
-rw-r--r--webkit/glue/webcursor.cc57
1 files changed, 53 insertions, 4 deletions
diff --git a/webkit/glue/webcursor.cc b/webkit/glue/webcursor.cc
index 4c943c3..76673e5 100644
--- a/webkit/glue/webcursor.cc
+++ b/webkit/glue/webcursor.cc
@@ -14,6 +14,7 @@
WebCursor::WebCursor()
: type_(WebCore::PlatformCursor::typePointer) {
+ InitPlatformData();
}
WebCursor::WebCursor(const WebCore::PlatformCursor& platform_cursor)
@@ -21,10 +22,31 @@ WebCursor::WebCursor(const WebCore::PlatformCursor& platform_cursor)
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 @@ bool WebCursor::Deserialize(const Pickle* pickle, void** iter) {
memcpy(&custom_data_[0], data, data_len);
}
- return true;
+ return DeserializePlatformData(pickle, iter);
}
bool WebCursor::Serialize(Pickle* pickle) const {
@@ -62,7 +84,10 @@ bool WebCursor::Serialize(Pickle* pickle) const {
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::IsCustom() const {
}
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;