Diff
Modified: trunk/Source/WebKit2/ChangeLog (90161 => 90162)
--- trunk/Source/WebKit2/ChangeLog 2011-06-30 21:46:31 UTC (rev 90161)
+++ trunk/Source/WebKit2/ChangeLog 2011-06-30 21:46:35 UTC (rev 90162)
@@ -2,6 +2,28 @@
Reviewed by Anders Carlsson.
+ Teach APIClient to correctly handle multiple versions of a client interface.
+
+ If a client struct is not the current version then we can't copy it via assignment
+ since that will read past the end of the smaller, older struct. To deal with this
+ APIClient needs to be aware of the sizes of the older client version structs so that
+ it can copy only the appropriate amount of the struct.
+
+ * Shared/APIClient.h:
+ (WebKit::APIClient::initialize): Assign through to our client if the new in client is the
+ latest version. If an older client version was passed then we zero out our client and memcpy
+ the appropriate number of bytes in to it. This ensures that any new members in the client
+ are initialized to 0.
+ * Shared/APIClientTraits.cpp:
+ * Shared/APIClientTraits.h: Client interfaces are the size of their struct unless otherwise stated.
+ * WebKit2.xcodeproj/project.pbxproj:
+ * WebProcess/InjectedBundle/API/c/WKBundlePage.h: Bump the version and add comments indicating
+ which components belong to which versions.
+
+2011-06-30 Mark Rowe <[email protected]>
+
+ Reviewed by Anders Carlsson.
+
Make the APIClient template aware of the latest client interface version number.
This will be used in an upcoming patch.
Modified: trunk/Source/WebKit2/GNUmakefile.am (90161 => 90162)
--- trunk/Source/WebKit2/GNUmakefile.am 2011-06-30 21:46:31 UTC (rev 90161)
+++ trunk/Source/WebKit2/GNUmakefile.am 2011-06-30 21:46:35 UTC (rev 90162)
@@ -126,6 +126,8 @@
Source/WebKit2/PluginProcess/gtk/PluginControllerProxyGtk.cpp \
Source/WebKit2/PluginProcess/gtk/PluginProcessGtk.cpp \
Source/WebKit2/Shared/APIClient.h \
+ Source/WebKit2/Shared/APIClientTraits.cpp \
+ Source/WebKit2/Shared/APIClientTraits.h \
Source/WebKit2/Shared/API/c/cairo/WKImageCairo.cpp \
Source/WebKit2/Shared/API/c/cairo/WKImageCairo.h \
Source/WebKit2/Shared/API/c/gtk/WKBaseGtk.h \
Modified: trunk/Source/WebKit2/Shared/APIClient.h (90161 => 90162)
--- trunk/Source/WebKit2/Shared/APIClient.h 2011-06-30 21:46:31 UTC (rev 90161)
+++ trunk/Source/WebKit2/Shared/APIClient.h 2011-06-30 21:46:35 UTC (rev 90162)
@@ -26,25 +26,34 @@
#ifndef APIClient_h
#define APIClient_h
+#include "APIClientTraits.h"
+
namespace WebKit {
-template<typename T, int> class APIClient {
+template<typename ClientInterface, int currentVersion> class APIClient {
public:
APIClient()
{
initialize(0);
}
+
+ void initialize(const ClientInterface* client)
+ {
+ COMPILE_ASSERT(sizeof(APIClientTraits<ClientInterface>::interfaceSizesByVersion) / sizeof(size_t) == currentVersion + 1, size_of_some_interfaces_are_unknown);
- void initialize(const T* client)
- {
- if (client && !client->version)
+ if (client && client->version == currentVersion) {
m_client = *client;
- else
- memset(&m_client, 0, sizeof(m_client));
+ return;
+ }
+
+ memset(&m_client, 0, sizeof(m_client));
+
+ if (client)
+ memcpy(&m_client, client, APIClientTraits<ClientInterface>::interfaceSizesByVersion[client->version]);
}
-
+
protected:
- T m_client;
+ ClientInterface m_client;
};
} // namespace WebKit
Copied: trunk/Source/WebKit2/Shared/APIClientTraits.cpp (from rev 90161, trunk/Source/WebKit2/Shared/APIClient.h) (0 => 90162)
--- trunk/Source/WebKit2/Shared/APIClientTraits.cpp (rev 0)
+++ trunk/Source/WebKit2/Shared/APIClientTraits.cpp 2011-06-30 21:46:35 UTC (rev 90162)
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 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
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "APIClientTraits.h"
+
+#include "WKBundlePage.h"
+
+namespace WebKit {
+
+const size_t APIClientTraits<WKBundlePageLoaderClient>::interfaceSizesByVersion[] = {
+ offsetof(WKBundlePageLoaderClient, didLayoutForFrame),
+ sizeof(WKBundlePageLoaderClient)
+};
+
+} // namespace WebKit
Copied: trunk/Source/WebKit2/Shared/APIClientTraits.h (from rev 90161, trunk/Source/WebKit2/Shared/APIClient.h) (0 => 90162)
--- trunk/Source/WebKit2/Shared/APIClientTraits.h (rev 0)
+++ trunk/Source/WebKit2/Shared/APIClientTraits.h 2011-06-30 21:46:35 UTC (rev 90162)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 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
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef APIClientTraits_h
+#define APIClientTraits_h
+
+#include "WKBundlePage.h"
+
+namespace WebKit {
+
+template <typename ClientInterface> struct APIClientTraits
+{
+ static const size_t interfaceSizesByVersion[1];
+};
+template <typename ClientInterface> const size_t APIClientTraits<ClientInterface>::interfaceSizesByVersion[] = { sizeof(ClientInterface) };
+
+template<> struct APIClientTraits<WKBundlePageLoaderClient>
+{
+ static const size_t interfaceSizesByVersion[2];
+};
+
+} // namespace WebKit
+
+#endif // APIClientTraits_h
Modified: trunk/Source/WebKit2/WebKit2.pro (90161 => 90162)
--- trunk/Source/WebKit2/WebKit2.pro 2011-06-30 21:46:31 UTC (rev 90161)
+++ trunk/Source/WebKit2/WebKit2.pro 2011-06-30 21:46:35 UTC (rev 90162)
@@ -113,6 +113,7 @@
PluginProcess/PluginControllerProxy.h \
PluginProcess/PluginProcess.h \
PluginProcess/WebProcessConnection.h \
+ Shared/APIClientTraits.h \
Shared/ShareableBitmap.h \
Shared/CacheModel.h \
Shared/ChildProcess.h \
@@ -327,6 +328,7 @@
PluginProcess/WebProcessConnection.cpp \
PluginProcess/qt/PluginControllerProxyQt.cpp \
PluginProcess/qt/PluginProcessQt.cpp \
+ Shared/APIClientTraits.cpp \
Shared/Plugins/Netscape/NetscapePluginModule.cpp \
Shared/Plugins/Netscape/NetscapePluginModuleNone.cpp \
Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp \
Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (90161 => 90162)
--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2011-06-30 21:46:31 UTC (rev 90161)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2011-06-30 21:46:35 UTC (rev 90162)
@@ -390,6 +390,8 @@
51D130551382EAC000351EDD /* SecItemResponseData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51D130511382EAC000351EDD /* SecItemResponseData.cpp */; };
51D130561382EAC000351EDD /* SecItemResponseData.h in Headers */ = {isa = PBXBuildFile; fileRef = 51D130521382EAC000351EDD /* SecItemResponseData.h */; };
51D130581382F10500351EDD /* WebProcessProxyMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51D130571382F10500351EDD /* WebProcessProxyMac.mm */; };
+ 5D51845513BCF9CC00C7FF4A /* APIClientTraits.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5D51845313BCF9CC00C7FF4A /* APIClientTraits.cpp */; };
+ 5D51845613BCF9CC00C7FF4A /* APIClientTraits.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D51845413BCF9CC00C7FF4A /* APIClientTraits.h */; };
6501BD1A12F1243400E9F248 /* WKBundleInspector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65B86F1712F11D7B00B7DD8A /* WKBundleInspector.cpp */; };
659C551E130006410025C0C2 /* InjectedBundlePageResourceLoadClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6546A82913000164000CEB1C /* InjectedBundlePageResourceLoadClient.cpp */; };
65B86F1E12F11DE300B7DD8A /* WKBundleInspector.h in Headers */ = {isa = PBXBuildFile; fileRef = 65B86F1812F11D7B00B7DD8A /* WKBundleInspector.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -1324,6 +1326,8 @@
51D130511382EAC000351EDD /* SecItemResponseData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SecItemResponseData.cpp; sourceTree = "<group>"; };
51D130521382EAC000351EDD /* SecItemResponseData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SecItemResponseData.h; sourceTree = "<group>"; };
51D130571382F10500351EDD /* WebProcessProxyMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebProcessProxyMac.mm; sourceTree = "<group>"; };
+ 5D51845313BCF9CC00C7FF4A /* APIClientTraits.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = APIClientTraits.cpp; sourceTree = "<group>"; };
+ 5D51845413BCF9CC00C7FF4A /* APIClientTraits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIClientTraits.h; sourceTree = "<group>"; };
5DAD7294116FF70B00EE5396 /* WebProcess.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = WebProcess.xcconfig; sourceTree = "<group>"; };
5DAD73F1116FF90C00EE5396 /* BaseTarget.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = BaseTarget.xcconfig; sourceTree = "<group>"; };
6546A82913000164000CEB1C /* InjectedBundlePageResourceLoadClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundlePageResourceLoadClient.cpp; sourceTree = "<group>"; };
@@ -2134,6 +2138,8 @@
BC111B5A112F628200337BAB /* mac */,
1AAE058C1279DCD400852418 /* Plugins */,
1A3DD205125E5A2F004515E6 /* APIClient.h */,
+ 5D51845313BCF9CC00C7FF4A /* APIClientTraits.cpp */,
+ 5D51845413BCF9CC00C7FF4A /* APIClientTraits.h */,
BCF04C8C11FF9B7D00F86A58 /* APIObject.h */,
BC3065F91259344E00E71278 /* CacheModel.h */,
1A2D956E12848564001EB962 /* ChildProcess.cpp */,
@@ -3824,6 +3830,7 @@
512DF70B138C26C700A22FC6 /* KeychainAttribute.h in Headers */,
93C01DAC139AC91700ED51D7 /* CoreIPCClientRunLoop.h in Headers */,
1A3D610213A7CC2A00F95D4E /* PluginModuleInfo.h in Headers */,
+ 5D51845613BCF9CC00C7FF4A /* APIClientTraits.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -4493,6 +4500,7 @@
93C01DAD139AC91700ED51D7 /* CoreIPCClientRunLoop.mm in Sources */,
1A3D610113A7CC2A00F95D4E /* PluginModuleInfo.cpp in Sources */,
1A3D610513A7F03A00F95D4E /* ArgumentCoders.cpp in Sources */,
+ 5D51845513BCF9CC00C7FF4A /* APIClientTraits.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h (90161 => 90162)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h 2011-06-30 21:46:31 UTC (rev 90161)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h 2011-06-30 21:46:35 UTC (rev 90162)
@@ -103,6 +103,8 @@
struct WKBundlePageLoaderClient {
int version;
const void * clientInfo;
+
+ // Version 0.
WKBundlePageDidStartProvisionalLoadForFrameCallback didStartProvisionalLoadForFrame;
WKBundlePageDidReceiveServerRedirectForProvisionalLoadForFrameCallback didReceiveServerRedirectForProvisionalLoadForFrame;
WKBundlePageDidFailProvisionalLoadWithErrorForFrameCallback didFailProvisionalLoadWithErrorForFrame;
@@ -121,11 +123,13 @@
WKBundlePageDidCancelClientRedirectForFrameCallback didCancelClientRedirectForFrame;
WKBundlePageWillPerformClientRedirectForFrameCallback willPerformClientRedirectForFrame;
WKBundlePageDidHandleOnloadEventsForFrameCallback didHandleOnloadEventsForFrame;
+
+ // Version 1.
WKBundlePageDidLayoutForFrameCallback didLayoutForFrame;
};
typedef struct WKBundlePageLoaderClient WKBundlePageLoaderClient;
-enum { kWKBundlePageLoaderClientCurrentVersion = 0 };
+enum { kWKBundlePageLoaderClientCurrentVersion = 1 };
enum {
WKBundlePagePolicyActionPassThrough,
Modified: trunk/Source/WebKit2/win/WebKit2.vcproj (90161 => 90162)
--- trunk/Source/WebKit2/win/WebKit2.vcproj 2011-06-30 21:46:31 UTC (rev 90161)
+++ trunk/Source/WebKit2/win/WebKit2.vcproj 2011-06-30 21:46:35 UTC (rev 90162)
@@ -395,6 +395,14 @@
>
</File>
<File
+ RelativePath="..\Shared\APIClientTraits.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\Shared\APIClientTraits.h"
+ >
+ </File>
+ <File
RelativePath="..\Shared\APIObject.h"
>
</File>