summaryrefslogtreecommitdiffstats
path: root/Source/WebKit2/Shared/WebCoreArgumentCoders.h
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-05-24 11:24:40 +0100
committerBen Murdoch <benm@google.com>2011-06-02 09:53:15 +0100
commit81bc750723a18f21cd17d1b173cd2a4dda9cea6e (patch)
tree7a9e5ed86ff429fd347a25153107221543909b19 /Source/WebKit2/Shared/WebCoreArgumentCoders.h
parent94088a6d336c1dd80a1e734af51e96abcbb689a7 (diff)
downloadexternal_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.zip
external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.gz
external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.bz2
Merge WebKit at r80534: Intial merge by Git
Change-Id: Ia7a83357124c9e1cdb1debf55d9661ec0bd09a61
Diffstat (limited to 'Source/WebKit2/Shared/WebCoreArgumentCoders.h')
-rw-r--r--Source/WebKit2/Shared/WebCoreArgumentCoders.h57
1 files changed, 48 insertions, 9 deletions
diff --git a/Source/WebKit2/Shared/WebCoreArgumentCoders.h b/Source/WebKit2/Shared/WebCoreArgumentCoders.h
index 62c68c7..1679bb6 100644
--- a/Source/WebKit2/Shared/WebCoreArgumentCoders.h
+++ b/Source/WebKit2/Shared/WebCoreArgumentCoders.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,19 +30,23 @@
#include "ArgumentDecoder.h"
#include "ArgumentEncoder.h"
#include "Arguments.h"
+#include "ShareableBitmap.h"
#include <WebCore/AuthenticationChallenge.h>
+#include <WebCore/BitmapImage.h>
#include <WebCore/Credential.h>
#include <WebCore/Cursor.h>
#include <WebCore/DatabaseDetails.h>
#include <WebCore/Editor.h>
#include <WebCore/EditorClient.h>
#include <WebCore/FloatRect.h>
+#include <WebCore/GraphicsContext.h>
#include <WebCore/IntRect.h>
#include <WebCore/KeyboardEvent.h>
#include <WebCore/PluginData.h>
#include <WebCore/ProtectionSpace.h>
#include <WebCore/ResourceError.h>
#include <WebCore/ResourceRequest.h>
+#include <WebCore/TextCheckerClient.h>
#include <WebCore/ViewportArguments.h>
#include <WebCore/WindowFeatures.h>
#include <limits>
@@ -181,14 +185,30 @@ template<> struct ArgumentCoder<WebCore::Credential> {
};
#if USE(LAZY_NATIVE_CURSOR)
+
+void encodeImage(ArgumentEncoder*, WebCore::Image*);
+bool decodeImage(ArgumentDecoder*, RefPtr<WebCore::Image>&);
+RefPtr<WebCore::Image> createImage(WebKit::ShareableBitmap*);
+
template<> struct ArgumentCoder<WebCore::Cursor> {
static void encode(ArgumentEncoder* encoder, const WebCore::Cursor& cursor)
{
- // FIXME: Support custom cursors.
- if (cursor.type() == WebCore::Cursor::Custom)
- encoder->encode(static_cast<uint32_t>(WebCore::Cursor::Pointer));
- else
- encoder->encode(static_cast<uint32_t>(cursor.type()));
+ WebCore::Cursor::Type type = cursor.type();
+#if !PLATFORM(CG)
+ // FIXME: Currently we only have the createImage function implemented for CG.
+ // Once we implement it for other platforms we can remove this conditional,
+ // and the other conditionals below and in WebCoreArgumentCoders.cpp.
+ if (type == WebCore::Cursor::Custom)
+ type = WebCore::Cursor::Pointer;
+#endif
+ encoder->encode(static_cast<uint32_t>(type));
+#if PLATFORM(CG)
+ if (type != WebCore::Cursor::Custom)
+ return;
+
+ encodeImage(encoder, cursor.image());
+ encoder->encode(cursor.hotSpot());
+#endif
}
static bool decode(ArgumentDecoder* decoder, WebCore::Cursor& cursor)
@@ -196,14 +216,33 @@ template<> struct ArgumentCoder<WebCore::Cursor> {
uint32_t typeInt;
if (!decoder->decode(typeInt))
return false;
-
+ if (typeInt > WebCore::Cursor::Custom)
+ return false;
WebCore::Cursor::Type type = static_cast<WebCore::Cursor::Type>(typeInt);
- ASSERT(type != WebCore::Cursor::Custom);
- cursor = WebCore::Cursor::fromType(type);
+ if (type != WebCore::Cursor::Custom) {
+ cursor = WebCore::Cursor::fromType(type);
+ return true;
+ }
+
+#if !PLATFORM(CG)
+ return false;
+#else
+ RefPtr<WebCore::Image> image;
+ if (!decodeImage(decoder, image))
+ return false;
+ WebCore::IntPoint hotSpot;
+ if (!decoder->decode(hotSpot))
+ return false;
+ if (!image->rect().contains(WebCore::IntRect(hotSpot, WebCore::IntSize())))
+ return false;
+
+ cursor = WebCore::Cursor(image.get(), hotSpot);
return true;
+#endif
}
};
+
#endif
// These two functions are implemented in a platform specific manner.