Modified: trunk/Source/WebKit2/ChangeLog (88972 => 88973)
--- trunk/Source/WebKit2/ChangeLog 2011-06-15 21:12:20 UTC (rev 88972)
+++ trunk/Source/WebKit2/ChangeLog 2011-06-15 21:39:17 UTC (rev 88973)
@@ -1,5 +1,19 @@
2011-06-15 Anders Carlsson <[email protected]>
+ Reviewed by Sam Weinig.
+
+ Move more argument coders to WebCoreArgumentCoders.cpp
+ https://bugs.webkit.org/show_bug.cgi?id=62755
+
+ * Shared/WebCoreArgumentCoders.cpp:
+ (CoreIPC::::decode):
+ (CoreIPC::::encode):
+ (CoreIPC::encodeImage):
+ (CoreIPC::decodeImage):
+ * Shared/WebCoreArgumentCoders.h:
+
+2011-06-15 Anders Carlsson <[email protected]>
+
Reviewed by Darin Adler.
Add ShareableBitmap::createImage and get rid of WebCoreArgumentCodersCG.cpp
Modified: trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp (88972 => 88973)
--- trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp 2011-06-15 21:12:20 UTC (rev 88972)
+++ trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp 2011-06-15 21:39:17 UTC (rev 88973)
@@ -118,7 +118,7 @@
if (!decoder->decode(error))
return false;
- challenge = WebCore::AuthenticationChallenge(protectionSpace, proposedCredential, previousFailureCount, failureResponse, error);
+ challenge = AuthenticationChallenge(protectionSpace, proposedCredential, previousFailureCount, failureResponse, error);
return true;
}
@@ -154,25 +154,47 @@
if (!decoder->decodeEnum(authenticationScheme))
return false;
- space = WebCore::ProtectionSpace(host, port, serverType, realm, authenticationScheme);
+ space = ProtectionSpace(host, port, serverType, realm, authenticationScheme);
return true;
}
-// For now, these are CG-only. Once other platforms have createImage functions,
-// we can compile these for non-CG builds.
-#if USE(CG)
+void ArgumentCoder<Credential>::encode(ArgumentEncoder* encoder, const Credential& credential)
+{
+ encoder->encode(credential.user());
+ encoder->encode(credential.password());
+ encoder->encodeEnum(credential.persistence());
+}
-void encodeImage(ArgumentEncoder* encoder, Image* image)
+bool ArgumentCoder<Credential>::decode(ArgumentDecoder* decoder, Credential& credential)
{
+ String user;
+ if (!decoder->decode(user))
+ return false;
+
+ String password;
+ if (!decoder->decode(password))
+ return false;
+
+ CredentialPersistence persistence;
+ if (!decoder->decodeEnum(persistence))
+ return false;
+
+ credential = Credential(user, password, persistence);
+ return true;
+}
+
+static void encodeImage(ArgumentEncoder* encoder, Image* image)
+{
RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(image->size(), ShareableBitmap::SupportsAlpha);
bitmap->createGraphicsContext()->drawImage(image, ColorSpaceDeviceRGB, IntPoint());
+
ShareableBitmap::Handle handle;
bitmap->createHandle(handle);
encoder->encode(handle);
}
-bool decodeImage(ArgumentDecoder* decoder, RefPtr<Image>& image)
+static bool decodeImage(ArgumentDecoder* decoder, RefPtr<Image>& image)
{
ShareableBitmap::Handle handle;
if (!decoder->decode(handle))
@@ -186,7 +208,136 @@
return false;
return true;
}
-
-#endif
+#if USE(LAZY_NATIVE_CURSOR)
+void ArgumentCoder<Cursor>::encode(ArgumentEncoder* encoder, const Cursor& cursor)
+{
+ encoder->encodeEnum(cursor.type());
+
+ if (cursor.type() != Cursor::Custom)
+ return;
+
+ encodeImage(encoder, cursor.image());
+ encoder->encode(cursor.hotSpot());
}
+
+bool ArgumentCoder<Cursor>::decode(ArgumentDecoder* decoder, Cursor& cursor)
+{
+ Cursor::Type type;
+ if (!decoder->decodeEnum(type))
+ return false;
+
+ if (type > Cursor::Custom)
+ return false;
+
+ if (type != Cursor::Custom) {
+ cursor = Cursor::fromType(type);
+ return true;
+ }
+
+ RefPtr<Image> image;
+ if (!decodeImage(decoder, image))
+ return false;
+
+ IntPoint hotSpot;
+ if (!decoder->decode(hotSpot))
+ return false;
+
+ if (!image->rect().contains(hotSpot))
+ return false;
+
+ cursor = Cursor(image.get(), hotSpot);
+ return true;
+}
+#endif // USE(LAZY_NATIVE_CURSOR)
+
+
+void ArgumentCoder<WindowFeatures>::encode(ArgumentEncoder* encoder, const WindowFeatures& windowFeatures)
+{
+ encoder->encode(windowFeatures.x);
+ encoder->encode(windowFeatures.y);
+ encoder->encode(windowFeatures.width);
+ encoder->encode(windowFeatures.height);
+ encoder->encode(windowFeatures.xSet);
+ encoder->encode(windowFeatures.ySet);
+ encoder->encode(windowFeatures.widthSet);
+ encoder->encode(windowFeatures.heightSet);
+ encoder->encode(windowFeatures.menuBarVisible);
+ encoder->encode(windowFeatures.statusBarVisible);
+ encoder->encode(windowFeatures.toolBarVisible);
+ encoder->encode(windowFeatures.locationBarVisible);
+ encoder->encode(windowFeatures.scrollbarsVisible);
+ encoder->encode(windowFeatures.resizable);
+ encoder->encode(windowFeatures.fullscreen);
+ encoder->encode(windowFeatures.dialog);
+}
+
+bool ArgumentCoder<WindowFeatures>::decode(ArgumentDecoder* decoder, WindowFeatures& windowFeatures)
+{
+ if (!decoder->decode(windowFeatures.x))
+ return false;
+ if (!decoder->decode(windowFeatures.y))
+ return false;
+ if (!decoder->decode(windowFeatures.width))
+ return false;
+ if (!decoder->decode(windowFeatures.height))
+ return false;
+ if (!decoder->decode(windowFeatures.xSet))
+ return false;
+ if (!decoder->decode(windowFeatures.ySet))
+ return false;
+ if (!decoder->decode(windowFeatures.widthSet))
+ return false;
+ if (!decoder->decode(windowFeatures.heightSet))
+ return false;
+ if (!decoder->decode(windowFeatures.menuBarVisible))
+ return false;
+ if (!decoder->decode(windowFeatures.statusBarVisible))
+ return false;
+ if (!decoder->decode(windowFeatures.toolBarVisible))
+ return false;
+ if (!decoder->decode(windowFeatures.locationBarVisible))
+ return false;
+ if (!decoder->decode(windowFeatures.scrollbarsVisible))
+ return false;
+ if (!decoder->decode(windowFeatures.resizable))
+ return false;
+ if (!decoder->decode(windowFeatures.fullscreen))
+ return false;
+ if (!decoder->decode(windowFeatures.dialog))
+ return false;
+ return true;
+}
+
+
+void ArgumentCoder<Color>::encode(ArgumentEncoder* encoder, const Color& color)
+{
+ if (!color.isValid()) {
+ encoder->encodeBool(false);
+ return;
+ }
+
+ encoder->encodeBool(true);
+ encoder->encode(color.rgb());
+}
+
+bool ArgumentCoder<Color>::decode(ArgumentDecoder* decoder, Color& color)
+{
+ bool isValid;
+ if (!decoder->decode(isValid))
+ return false;
+
+ if (!isValid) {
+ color = Color();
+ return true;
+ }
+
+ RGBA32 rgba;
+ if (!decoder->decode(rgba))
+ return false;
+
+ color = Color(rgba);
+ return true;
+}
+
+} // namespace CoreIPC
Modified: trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.h (88972 => 88973)
--- trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.h 2011-06-15 21:12:20 UTC (rev 88972)
+++ trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.h 2011-06-15 21:39:17 UTC (rev 88973)
@@ -119,82 +119,15 @@
};
template<> struct ArgumentCoder<WebCore::Credential> {
- static void encode(ArgumentEncoder* encoder, const WebCore::Credential& credential)
- {
- encoder->encode(CoreIPC::In(credential.user(), credential.password(), static_cast<uint32_t>(credential.persistence())));
- }
-
- static bool decode(ArgumentDecoder* decoder, WebCore::Credential& credential)
- {
- String user;
- String password;
- int persistence;
- if (!decoder->decode(CoreIPC::Out(user, password, persistence)))
- return false;
-
- credential = WebCore::Credential(user, password, static_cast<WebCore::CredentialPersistence>(persistence));
- return true;
- }
+ static void encode(ArgumentEncoder*, const WebCore::Credential&);
+ static bool decode(ArgumentDecoder*, WebCore::Credential&);
};
#if USE(LAZY_NATIVE_CURSOR)
-
-void encodeImage(ArgumentEncoder*, WebCore::Image*);
-bool decodeImage(ArgumentDecoder*, RefPtr<WebCore::Image>&);
-
template<> struct ArgumentCoder<WebCore::Cursor> {
- static void encode(ArgumentEncoder* encoder, const WebCore::Cursor& cursor)
- {
- WebCore::Cursor::Type type = cursor.type();
-#if !USE(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 USE(CG)
- if (type != WebCore::Cursor::Custom)
- return;
-
- encodeImage(encoder, cursor.image());
- encoder->encode(cursor.hotSpot());
-#endif
- }
-
- static bool decode(ArgumentDecoder* decoder, WebCore::Cursor& 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);
-
- if (type != WebCore::Cursor::Custom) {
- cursor = WebCore::Cursor::fromType(type);
- return true;
- }
-
-#if !USE(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
- }
+ static void encode(ArgumentEncoder*, const WebCore::Cursor&);
+ static bool decode(ArgumentDecoder*, WebCore::Cursor&);
};
-
#endif
// These two functions are implemented in a platform specific manner.
@@ -246,94 +179,13 @@
};
template<> struct ArgumentCoder<WebCore::WindowFeatures> {
- static void encode(ArgumentEncoder* encoder, const WebCore::WindowFeatures& windowFeatures)
- {
- encoder->encode(windowFeatures.x);
- encoder->encode(windowFeatures.y);
- encoder->encode(windowFeatures.width);
- encoder->encode(windowFeatures.height);
- encoder->encode(windowFeatures.xSet);
- encoder->encode(windowFeatures.ySet);
- encoder->encode(windowFeatures.widthSet);
- encoder->encode(windowFeatures.heightSet);
- encoder->encode(windowFeatures.menuBarVisible);
- encoder->encode(windowFeatures.statusBarVisible);
- encoder->encode(windowFeatures.toolBarVisible);
- encoder->encode(windowFeatures.locationBarVisible);
- encoder->encode(windowFeatures.scrollbarsVisible);
- encoder->encode(windowFeatures.resizable);
- encoder->encode(windowFeatures.fullscreen);
- encoder->encode(windowFeatures.dialog);
- }
-
- static bool decode(ArgumentDecoder* decoder, WebCore::WindowFeatures& windowFeatures)
- {
- if (!decoder->decode(windowFeatures.x))
- return false;
- if (!decoder->decode(windowFeatures.y))
- return false;
- if (!decoder->decode(windowFeatures.width))
- return false;
- if (!decoder->decode(windowFeatures.height))
- return false;
- if (!decoder->decode(windowFeatures.xSet))
- return false;
- if (!decoder->decode(windowFeatures.ySet))
- return false;
- if (!decoder->decode(windowFeatures.widthSet))
- return false;
- if (!decoder->decode(windowFeatures.heightSet))
- return false;
- if (!decoder->decode(windowFeatures.menuBarVisible))
- return false;
- if (!decoder->decode(windowFeatures.statusBarVisible))
- return false;
- if (!decoder->decode(windowFeatures.toolBarVisible))
- return false;
- if (!decoder->decode(windowFeatures.locationBarVisible))
- return false;
- if (!decoder->decode(windowFeatures.scrollbarsVisible))
- return false;
- if (!decoder->decode(windowFeatures.resizable))
- return false;
- if (!decoder->decode(windowFeatures.fullscreen))
- return false;
- if (!decoder->decode(windowFeatures.dialog))
- return false;
- return true;
- }
+ static void encode(ArgumentEncoder*, const WebCore::WindowFeatures&);
+ static bool decode(ArgumentDecoder*, WebCore::WindowFeatures&);
};
template<> struct ArgumentCoder<WebCore::Color> {
- static void encode(ArgumentEncoder* encoder, const WebCore::Color& color)
- {
- if (!color.isValid()) {
- encoder->encodeBool(false);
- return;
- }
-
- encoder->encodeBool(true);
- encoder->encode(color.rgb());
- }
-
- static bool decode(ArgumentDecoder* decoder, WebCore::Color& color)
- {
- bool isValid;
- if (!decoder->decode(isValid))
- return false;
-
- if (!isValid) {
- color = WebCore::Color();
- return true;
- }
-
- WebCore::RGBA32 rgba;
- if (!decoder->decode(rgba))
- return false;
-
- color = WebCore::Color(rgba);
- return true;
- }
+ static void encode(ArgumentEncoder*, const WebCore::Color&);
+ static bool decode(ArgumentDecoder*, WebCore::Color&);
};
#if PLATFORM(MAC)