Changeset 90162 in webkit
- Timestamp:
- Jun 30, 2011, 2:46:35 PM (15 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 7 edited
- 2 copied
-
ChangeLog (modified) (1 diff)
-
GNUmakefile.am (modified) (1 diff)
-
Shared/APIClient.h (modified) (2 diffs)
-
Shared/APIClientTraits.cpp (copied) (copied from trunk/Source/WebKit2/Shared/APIClient.h ) (2 diffs)
-
Shared/APIClientTraits.h (copied) (copied from trunk/Source/WebKit2/Shared/APIClient.h ) (2 diffs)
-
WebKit2.pro (modified) (2 diffs)
-
WebKit2.xcodeproj/project.pbxproj (modified) (5 diffs)
-
WebProcess/InjectedBundle/API/c/WKBundlePage.h (modified) (2 diffs)
-
win/WebKit2.vcproj (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r90161 r90162 1 2011-06-30 Mark Rowe <mrowe@apple.com> 2 3 Reviewed by Anders Carlsson. 4 5 Teach APIClient to correctly handle multiple versions of a client interface. 6 7 If a client struct is not the current version then we can't copy it via assignment 8 since that will read past the end of the smaller, older struct. To deal with this 9 APIClient needs to be aware of the sizes of the older client version structs so that 10 it can copy only the appropriate amount of the struct. 11 12 * Shared/APIClient.h: 13 (WebKit::APIClient::initialize): Assign through to our client if the new in client is the 14 latest version. If an older client version was passed then we zero out our client and memcpy 15 the appropriate number of bytes in to it. This ensures that any new members in the client 16 are initialized to 0. 17 * Shared/APIClientTraits.cpp: 18 * Shared/APIClientTraits.h: Client interfaces are the size of their struct unless otherwise stated. 19 * WebKit2.xcodeproj/project.pbxproj: 20 * WebProcess/InjectedBundle/API/c/WKBundlePage.h: Bump the version and add comments indicating 21 which components belong to which versions. 22 1 23 2011-06-30 Mark Rowe <mrowe@apple.com> 2 24 -
trunk/Source/WebKit2/GNUmakefile.am
r89426 r90162 127 127 Source/WebKit2/PluginProcess/gtk/PluginProcessGtk.cpp \ 128 128 Source/WebKit2/Shared/APIClient.h \ 129 Source/WebKit2/Shared/APIClientTraits.cpp \ 130 Source/WebKit2/Shared/APIClientTraits.h \ 129 131 Source/WebKit2/Shared/API/c/cairo/WKImageCairo.cpp \ 130 132 Source/WebKit2/Shared/API/c/cairo/WKImageCairo.h \ -
trunk/Source/WebKit2/Shared/APIClient.h
r90161 r90162 27 27 #define APIClient_h 28 28 29 #include "APIClientTraits.h" 30 29 31 namespace WebKit { 30 32 31 template<typename T, int> class APIClient {33 template<typename ClientInterface, int currentVersion> class APIClient { 32 34 public: 33 35 APIClient() … … 35 37 initialize(0); 36 38 } 39 40 void initialize(const ClientInterface* client) 41 { 42 COMPILE_ASSERT(sizeof(APIClientTraits<ClientInterface>::interfaceSizesByVersion) / sizeof(size_t) == currentVersion + 1, size_of_some_interfaces_are_unknown); 37 43 38 void initialize(const T* client) 39 { 40 if (client && !client->version) 44 if (client && client->version == currentVersion) { 41 45 m_client = *client; 42 else 43 memset(&m_client, 0, sizeof(m_client)); 46 return; 47 } 48 49 memset(&m_client, 0, sizeof(m_client)); 50 51 if (client) 52 memcpy(&m_client, client, APIClientTraits<ClientInterface>::interfaceSizesByVersion[client->version]); 44 53 } 45 54 46 55 protected: 47 Tm_client;56 ClientInterface m_client; 48 57 }; 49 58 -
trunk/Source/WebKit2/Shared/APIClientTraits.cpp
r90161 r90162 1 1 /* 2 * Copyright (C) 201 0Apple Inc. All rights reserved.2 * Copyright (C) 2011 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #ifndef APIClient_h 27 #define APIClient_h 26 #include "config.h" 27 #include "APIClientTraits.h" 28 29 #include "WKBundlePage.h" 28 30 29 31 namespace WebKit { 30 32 31 template<typename T, int> class APIClient { 32 public: 33 APIClient() 34 { 35 initialize(0); 36 } 37 38 void initialize(const T* client) 39 { 40 if (client && !client->version) 41 m_client = *client; 42 else 43 memset(&m_client, 0, sizeof(m_client)); 44 } 45 46 protected: 47 T m_client; 33 const size_t APIClientTraits<WKBundlePageLoaderClient>::interfaceSizesByVersion[] = { 34 offsetof(WKBundlePageLoaderClient, didLayoutForFrame), 35 sizeof(WKBundlePageLoaderClient) 48 36 }; 49 37 50 38 } // namespace WebKit 51 52 #endif // APIClient_h -
trunk/Source/WebKit2/Shared/APIClientTraits.h
r90161 r90162 1 1 /* 2 * Copyright (C) 201 0Apple Inc. All rights reserved.2 * Copyright (C) 2011 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #ifndef APIClient_h 27 #define APIClient_h 26 #ifndef APIClientTraits_h 27 #define APIClientTraits_h 28 29 #include "WKBundlePage.h" 28 30 29 31 namespace WebKit { 30 32 31 template<typename T, int> class APIClient { 32 public: 33 APIClient() 34 { 35 initialize(0); 36 } 33 template <typename ClientInterface> struct APIClientTraits 34 { 35 static const size_t interfaceSizesByVersion[1]; 36 }; 37 template <typename ClientInterface> const size_t APIClientTraits<ClientInterface>::interfaceSizesByVersion[] = { sizeof(ClientInterface) }; 37 38 38 void initialize(const T* client) 39 { 40 if (client && !client->version) 41 m_client = *client; 42 else 43 memset(&m_client, 0, sizeof(m_client)); 44 } 45 46 protected: 47 T m_client; 39 template<> struct APIClientTraits<WKBundlePageLoaderClient> 40 { 41 static const size_t interfaceSizesByVersion[2]; 48 42 }; 49 43 50 44 } // namespace WebKit 51 45 52 #endif // APIClient _h46 #endif // APIClientTraits_h -
trunk/Source/WebKit2/WebKit2.pro
r89582 r90162 114 114 PluginProcess/PluginProcess.h \ 115 115 PluginProcess/WebProcessConnection.h \ 116 Shared/APIClientTraits.h \ 116 117 Shared/ShareableBitmap.h \ 117 118 Shared/CacheModel.h \ … … 328 329 PluginProcess/qt/PluginControllerProxyQt.cpp \ 329 330 PluginProcess/qt/PluginProcessQt.cpp \ 331 Shared/APIClientTraits.cpp \ 330 332 Shared/Plugins/Netscape/NetscapePluginModule.cpp \ 331 333 Shared/Plugins/Netscape/NetscapePluginModuleNone.cpp \ -
trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
r88967 r90162 391 391 51D130561382EAC000351EDD /* SecItemResponseData.h in Headers */ = {isa = PBXBuildFile; fileRef = 51D130521382EAC000351EDD /* SecItemResponseData.h */; }; 392 392 51D130581382F10500351EDD /* WebProcessProxyMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51D130571382F10500351EDD /* WebProcessProxyMac.mm */; }; 393 5D51845513BCF9CC00C7FF4A /* APIClientTraits.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5D51845313BCF9CC00C7FF4A /* APIClientTraits.cpp */; }; 394 5D51845613BCF9CC00C7FF4A /* APIClientTraits.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D51845413BCF9CC00C7FF4A /* APIClientTraits.h */; }; 393 395 6501BD1A12F1243400E9F248 /* WKBundleInspector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65B86F1712F11D7B00B7DD8A /* WKBundleInspector.cpp */; }; 394 396 659C551E130006410025C0C2 /* InjectedBundlePageResourceLoadClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6546A82913000164000CEB1C /* InjectedBundlePageResourceLoadClient.cpp */; }; … … 1325 1327 51D130521382EAC000351EDD /* SecItemResponseData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SecItemResponseData.h; sourceTree = "<group>"; }; 1326 1328 51D130571382F10500351EDD /* WebProcessProxyMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebProcessProxyMac.mm; sourceTree = "<group>"; }; 1329 5D51845313BCF9CC00C7FF4A /* APIClientTraits.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = APIClientTraits.cpp; sourceTree = "<group>"; }; 1330 5D51845413BCF9CC00C7FF4A /* APIClientTraits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIClientTraits.h; sourceTree = "<group>"; }; 1327 1331 5DAD7294116FF70B00EE5396 /* WebProcess.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = WebProcess.xcconfig; sourceTree = "<group>"; }; 1328 1332 5DAD73F1116FF90C00EE5396 /* BaseTarget.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = BaseTarget.xcconfig; sourceTree = "<group>"; }; … … 2135 2139 1AAE058C1279DCD400852418 /* Plugins */, 2136 2140 1A3DD205125E5A2F004515E6 /* APIClient.h */, 2141 5D51845313BCF9CC00C7FF4A /* APIClientTraits.cpp */, 2142 5D51845413BCF9CC00C7FF4A /* APIClientTraits.h */, 2137 2143 BCF04C8C11FF9B7D00F86A58 /* APIObject.h */, 2138 2144 BC3065F91259344E00E71278 /* CacheModel.h */, … … 3825 3831 93C01DAC139AC91700ED51D7 /* CoreIPCClientRunLoop.h in Headers */, 3826 3832 1A3D610213A7CC2A00F95D4E /* PluginModuleInfo.h in Headers */, 3833 5D51845613BCF9CC00C7FF4A /* APIClientTraits.h in Headers */, 3827 3834 ); 3828 3835 runOnlyForDeploymentPostprocessing = 0; … … 4494 4501 1A3D610113A7CC2A00F95D4E /* PluginModuleInfo.cpp in Sources */, 4495 4502 1A3D610513A7F03A00F95D4E /* ArgumentCoders.cpp in Sources */, 4503 5D51845513BCF9CC00C7FF4A /* APIClientTraits.cpp in Sources */, 4496 4504 ); 4497 4505 runOnlyForDeploymentPostprocessing = 0; -
trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h
r90160 r90162 104 104 int version; 105 105 const void * clientInfo; 106 107 // Version 0. 106 108 WKBundlePageDidStartProvisionalLoadForFrameCallback didStartProvisionalLoadForFrame; 107 109 WKBundlePageDidReceiveServerRedirectForProvisionalLoadForFrameCallback didReceiveServerRedirectForProvisionalLoadForFrame; … … 122 124 WKBundlePageWillPerformClientRedirectForFrameCallback willPerformClientRedirectForFrame; 123 125 WKBundlePageDidHandleOnloadEventsForFrameCallback didHandleOnloadEventsForFrame; 126 127 // Version 1. 124 128 WKBundlePageDidLayoutForFrameCallback didLayoutForFrame; 125 129 }; 126 130 typedef struct WKBundlePageLoaderClient WKBundlePageLoaderClient; 127 131 128 enum { kWKBundlePageLoaderClientCurrentVersion = 0};132 enum { kWKBundlePageLoaderClientCurrentVersion = 1 }; 129 133 130 134 enum { -
trunk/Source/WebKit2/win/WebKit2.vcproj
r89758 r90162 396 396 </File> 397 397 <File 398 RelativePath="..\Shared\APIClientTraits.cpp" 399 > 400 </File> 401 <File 402 RelativePath="..\Shared\APIClientTraits.h" 403 > 404 </File> 405 <File 398 406 RelativePath="..\Shared\APIObject.h" 399 407 >
Note:
See TracChangeset
for help on using the changeset viewer.