Changeset 109022 in webkit
- Timestamp:
- Feb 27, 2012, 2:03:41 PM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/Source/WebCore/ChangeLog ¶
r109020 r109022 1 2012-02-27 Enrica Casucci <enrica@apple.com> 2 3 WebKit2: implement platform strategy to access Pasteboard in the UI process. 4 https://bugs.webkit.org/show_bug.cgi?id=79253 5 <rdar://problem/9971876> 6 7 Reviewed by Alexey Proskuryakov. 8 9 No new tests. No behavior change. 10 11 * platform/mac/PlatformPasteboardMac.mm: 12 (WebCore::PlatformPasteboard::bufferForType): There is no need 13 to create a SharedBuffer object if there is no NSData in the pasteboard 14 for the given pasteboard type. 15 1 16 2012-02-27 Adrienne Walker <enne@google.com> 2 17 -
TabularUnified trunk/Source/WebCore/platform/mac/PlatformPasteboardMac.mm ¶
r108128 r109022 46 46 PassRefPtr<SharedBuffer> PlatformPasteboard::bufferForType(const String& pasteboardType) 47 47 { 48 return SharedBuffer::wrapNSData([[[m_pasteboard.get() dataForType:pasteboardType] copy] autorelease]); 48 NSData *data = [m_pasteboard.get() dataForType:pasteboardType]; 49 if (!data) 50 return 0; 51 return SharedBuffer::wrapNSData([[data copy] autorelease]); 49 52 } 50 53 -
TabularUnified trunk/Source/WebKit2/ChangeLog ¶
r109004 r109022 1 2012-02-27 Enrica Casucci <enrica@apple.com> 2 3 WebKit2: implement platform strategy to access Pasteboard in the UI process. 4 https://bugs.webkit.org/show_bug.cgi?id=79253 5 <rdar://problem/9971876> 6 7 Reviewed by Alexey Proskuryakov. 8 9 * UIProcess/WebContext.h: 10 * UIProcess/WebContext.messages.in: Added messages to access NSPasteboard 11 in the UI process. 12 * UIProcess/mac/WebContextMac.mm: Added methods corresponding to the 13 new messages. 14 (WebKit::WebContext::getPasteboardTypes): 15 (WebKit::WebContext::getPasteboardPathnamesForType): 16 (WebKit::WebContext::getPasteboardStringForType): 17 (WebKit::WebContext::getPasteboardBufferForType): 18 (WebKit::WebContext::pasteboardCopy): 19 (WebKit::WebContext::getPasteboardChangeCount): 20 (WebKit::WebContext::getPasteboardUniqueName): 21 (WebKit::WebContext::getPasteboardColor): 22 (WebKit::WebContext::setPasteboardTypes): 23 (WebKit::WebContext::setPasteboardPathnamesForType): 24 (WebKit::WebContext::setPasteboardStringForType): 25 (WebKit::WebContext::setPasteboardBufferForType): 26 * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp: New implementation of the PasteboardStrategy using message exchange 27 with the UI process. 28 (WebKit::WebPlatformStrategies::getTypes): 29 (WebKit::WebPlatformStrategies::bufferForType): 30 (WebKit::WebPlatformStrategies::getPathnamesForType): 31 (WebKit::WebPlatformStrategies::stringForType): 32 (WebKit::WebPlatformStrategies::copy): 33 (WebKit::WebPlatformStrategies::changeCount): 34 (WebKit::WebPlatformStrategies::uniqueName): 35 (WebKit::WebPlatformStrategies::color): 36 (WebKit::WebPlatformStrategies::setTypes): 37 (WebKit::WebPlatformStrategies::setBufferForType): 38 (WebKit::WebPlatformStrategies::setPathnamesForType): 39 (WebKit::WebPlatformStrategies::setStringForType): 40 1 41 2012-02-27 Dan Bernstein <mitz@apple.com> 2 42 -
TabularUnified trunk/Source/WebKit2/UIProcess/WebContext.h ¶
r103316 r109022 225 225 void didClearPluginSiteData(uint64_t callbackID); 226 226 #endif 227 227 228 #if PLATFORM(MAC) 229 void getPasteboardTypes(const String& pasteboardName, Vector<String>& pasteboardTypes); 230 void getPasteboardPathnamesForType(const String& pasteboardName, const String& pasteboardType, Vector<String>& pathnames); 231 void getPasteboardStringForType(const String& pasteboardName, const String& pasteboardType, String&); 232 void getPasteboardBufferForType(const String& pasteboardName, const String& pasteboardType, SharedMemory::Handle&, uint64_t& size); 233 void pasteboardCopy(const String& fromPasteboard, const String& toPasteboard); 234 void getPasteboardChangeCount(const String& pasteboardName, uint64_t& changeCount); 235 void getPasteboardUniqueName(String& pasteboardName); 236 void getPasteboardColor(const String& pasteboardName, WebCore::Color&); 237 void setPasteboardTypes(const String& pasteboardName, const Vector<String>& pasteboardTypes); 238 void setPasteboardPathnamesForType(const String& pasteboardName, const String& pasteboardType, const Vector<String>& pathnames); 239 void setPasteboardStringForType(const String& pasteboardName, const String& pasteboardType, const String&); 240 void setPasteboardBufferForType(const String& pasteboardName, const String& pasteboardType, const SharedMemory::Handle&, uint64_t size); 241 #endif 242 228 243 void didGetWebCoreStatistics(const StatisticsData&, uint64_t callbackID); 229 244 -
TabularUnified trunk/Source/WebKit2/UIProcess/WebContext.messages.in ¶
r94115 r109022 43 43 DidGetWebCoreStatistics(WebKit::StatisticsData statisticsData, uint64_t callbackID) 44 44 45 #if PLATFORM(MAC) 46 # Pasteboard messages. 47 48 GetPasteboardTypes(WTF::String pasteboardName) -> (Vector<WTF::String> types) 49 GetPasteboardPathnamesForType(WTF::String pasteboardName, WTF::String pasteboardType) -> (Vector<WTF::String> pathnames) 50 GetPasteboardStringForType(WTF::String pasteboardName, WTF::String pasteboardType) -> (WTF::String string) 51 GetPasteboardBufferForType(WTF::String pasteboardName, WTF::String pasteboardType) -> (WebKit::SharedMemory::Handle handle, uint64_t size) 52 PasteboardCopy(WTF::String fromPasteboard, WTF::String toPasteboard) 53 GetPasteboardChangeCount(WTF::String pasteboardName) -> (uint64_t changeCount) 54 GetPasteboardUniqueName() -> (WTF::String pasteboardName) 55 GetPasteboardColor(WTF::String pasteboardName) -> (WebCore::Color color) 56 SetPasteboardTypes(WTF::String pasteboardName, Vector<WTF::String> pasteboardTypes) 57 SetPasteboardPathnamesForType(WTF::String pasteboardName, WTF::String pasteboardType, Vector<WTF::String> pathnames) 58 SetPasteboardStringForType(WTF::String pasteboardName, WTF::String pasteboardType, WTF::String string) 59 SetPasteboardBufferForType(WTF::String pasteboardName, WTF::String pasteboardType, WebKit::SharedMemory::Handle handle, uint64_t size) 60 #endif 45 61 } -
TabularUnified trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm ¶
r108946 r109022 29 29 #import "WebKitSystemInterface.h" 30 30 #import "WebProcessCreationParameters.h" 31 #import <WebCore/Color.h> 31 32 #import <WebCore/FileSystem.h> 33 #import <WebCore/PlatformPasteboard.h> 32 34 #import <sys/param.h> 33 35 … … 156 158 } 157 159 160 void WebContext::getPasteboardTypes(const String& pasteboardName, Vector<String>& pasteboardTypes) 161 { 162 PlatformPasteboard(pasteboardName).getTypes(pasteboardTypes); 163 } 164 165 void WebContext::getPasteboardPathnamesForType(const String& pasteboardName, const String& pasteboardType, Vector<String>& pathnames) 166 { 167 PlatformPasteboard(pasteboardName).getPathnamesForType(pathnames, pasteboardType); 168 } 169 170 void WebContext::getPasteboardStringForType(const String& pasteboardName, const String& pasteboardType, String& string) 171 { 172 string = PlatformPasteboard(pasteboardName).stringForType(pasteboardType); 173 } 174 175 void WebContext::getPasteboardBufferForType(const String& pasteboardName, const String& pasteboardType, SharedMemory::Handle& handle, uint64_t& size) 176 { 177 RefPtr<SharedBuffer> buffer = PlatformPasteboard(pasteboardName).bufferForType(pasteboardType); 178 if (!buffer) 179 return; 180 size = buffer->size(); 181 RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::create(size); 182 memcpy(sharedMemoryBuffer->data(), buffer->data(), size); 183 sharedMemoryBuffer->createHandle(handle, SharedMemory::ReadOnly); 184 } 185 186 void WebContext::pasteboardCopy(const String& fromPasteboard, const String& toPasteboard) 187 { 188 PlatformPasteboard(toPasteboard).copy(fromPasteboard); 189 } 190 191 void WebContext::getPasteboardChangeCount(const String& pasteboardName, uint64_t& changeCount) 192 { 193 changeCount = PlatformPasteboard(pasteboardName).changeCount(); 194 } 195 196 void WebContext::getPasteboardUniqueName(String& pasteboardName) 197 { 198 pasteboardName = PlatformPasteboard::uniqueName(); 199 } 200 201 void WebContext::getPasteboardColor(const String& pasteboardName, WebCore::Color& color) 202 { 203 color = PlatformPasteboard(pasteboardName).color(); 204 } 205 206 void WebContext::setPasteboardTypes(const String& pasteboardName, const Vector<String>& pasteboardTypes) 207 { 208 PlatformPasteboard(pasteboardName).setTypes(pasteboardTypes); 209 } 210 211 void WebContext::setPasteboardPathnamesForType(const String& pasteboardName, const String& pasteboardType, const Vector<String>& pathnames) 212 { 213 PlatformPasteboard(pasteboardName).setPathnamesForType(pathnames, pasteboardType); 214 } 215 216 void WebContext::setPasteboardStringForType(const String& pasteboardName, const String& pasteboardType, const String& string) 217 { 218 PlatformPasteboard(pasteboardName).setStringForType(string, pasteboardType); 219 } 220 221 void WebContext::setPasteboardBufferForType(const String& pasteboardName, const String& pasteboardType, const SharedMemory::Handle& handle, uint64_t size) 222 { 223 if (handle.isNull()) { 224 PlatformPasteboard(pasteboardName).setBufferForType(0, pasteboardType); 225 return; 226 } 227 RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::create(handle, SharedMemory::ReadOnly); 228 RefPtr<SharedBuffer> buffer = SharedBuffer::create(static_cast<unsigned char *>(sharedMemoryBuffer->data()), size); 229 PlatformPasteboard(pasteboardName).setBufferForType(buffer, pasteboardType); 230 } 231 158 232 } // namespace WebKit 159 233 -
TabularUnified trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp ¶
r108101 r109022 138 138 void WebPlatformStrategies::getTypes(Vector<String>& types, const String& pasteboardName) 139 139 { 140 PlatformPasteboard(pasteboardName).getTypes(types); 140 WebProcess::shared().connection()->sendSync(Messages::WebContext::GetPasteboardTypes(pasteboardName), 141 Messages::WebContext::GetPasteboardTypes::Reply(types), 0); 141 142 } 142 143 143 144 PassRefPtr<WebCore::SharedBuffer> WebPlatformStrategies::bufferForType(const String& pasteboardType, const String& pasteboardName) 144 145 { 145 return PlatformPasteboard(pasteboardName).bufferForType(pasteboardType); 146 SharedMemory::Handle handle; 147 uint64_t size = 0; 148 WebProcess::shared().connection()->sendSync(Messages::WebContext::GetPasteboardBufferForType(pasteboardName, pasteboardType), 149 Messages::WebContext::GetPasteboardBufferForType::Reply(handle, size), 0); 150 if (handle.isNull()) 151 return 0; 152 RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::create(handle, SharedMemory::ReadOnly); 153 return SharedBuffer::create(static_cast<unsigned char *>(sharedMemoryBuffer->data()), size); 146 154 } 147 155 148 156 void WebPlatformStrategies::getPathnamesForType(Vector<String>& pathnames, const String& pasteboardType, const String& pasteboardName) 149 157 { 150 PlatformPasteboard(pasteboardName).getPathnamesForType(pathnames, pasteboardType); 158 WebProcess::shared().connection()->sendSync(Messages::WebContext::GetPasteboardPathnamesForType(pasteboardName, pasteboardType), 159 Messages::WebContext::GetPasteboardPathnamesForType::Reply(pathnames), 0); 151 160 } 152 161 153 162 String WebPlatformStrategies::stringForType(const String& pasteboardType, const String& pasteboardName) 154 163 { 155 return PlatformPasteboard(pasteboardName).stringForType(pasteboardType); 164 String value; 165 WebProcess::shared().connection()->sendSync(Messages::WebContext::GetPasteboardStringForType(pasteboardName, pasteboardType), 166 Messages::WebContext::GetPasteboardStringForType::Reply(value), 0); 167 return value; 156 168 } 157 169 158 170 void WebPlatformStrategies::copy(const String& fromPasteboard, const String& toPasteboard) 159 171 { 160 PlatformPasteboard(toPasteboard).copy(fromPasteboard);172 WebProcess::shared().connection()->send(Messages::WebContext::PasteboardCopy(fromPasteboard, toPasteboard), 0); 161 173 } 162 174 163 175 int WebPlatformStrategies::changeCount(const WTF::String &pasteboardName) 164 176 { 165 return PlatformPasteboard(pasteboardName).changeCount(); 177 uint64_t changeCount; 178 WebProcess::shared().connection()->sendSync(Messages::WebContext::GetPasteboardChangeCount(pasteboardName), 179 Messages::WebContext::GetPasteboardChangeCount::Reply(changeCount), 0); 180 return changeCount; 166 181 } 167 182 168 183 String WebPlatformStrategies::uniqueName() 169 184 { 170 return PlatformPasteboard::uniqueName(); 185 String pasteboardName; 186 WebProcess::shared().connection()->sendSync(Messages::WebContext::GetPasteboardUniqueName(), 187 Messages::WebContext::GetPasteboardUniqueName::Reply(pasteboardName), 0); 188 return pasteboardName; 171 189 } 172 190 173 191 Color WebPlatformStrategies::color(const String& pasteboardName) 174 192 { 175 return PlatformPasteboard(pasteboardName).color(); 193 Color color; 194 WebProcess::shared().connection()->sendSync(Messages::WebContext::GetPasteboardColor(pasteboardName), 195 Messages::WebContext::GetPasteboardColor::Reply(color), 0); 196 return color; 176 197 } 177 198 178 199 void WebPlatformStrategies::setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) 179 200 { 180 PlatformPasteboard(pasteboardName).setTypes(pasteboardTypes);201 WebProcess::shared().connection()->send(Messages::WebContext::SetPasteboardTypes(pasteboardName, pasteboardTypes), 0); 181 202 } 182 203 183 204 void WebPlatformStrategies::setBufferForType(PassRefPtr<SharedBuffer> buffer, const String& pasteboardType, const String& pasteboardName) 184 205 { 185 PlatformPasteboard(pasteboardName).setBufferForType(buffer, pasteboardType); 206 SharedMemory::Handle handle; 207 if (buffer) { 208 RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::create(buffer->size()); 209 memcpy(sharedMemoryBuffer->data(), buffer->data(), buffer->size()); 210 sharedMemoryBuffer->createHandle(handle, SharedMemory::ReadOnly); 211 } 212 WebProcess::shared().connection()->send(Messages::WebContext::SetPasteboardBufferForType(pasteboardName, pasteboardType, handle, buffer ? buffer->size() : 0), 0); 186 213 } 187 214 188 215 void WebPlatformStrategies::setPathnamesForType(const Vector<String>& pathnames, const String& pasteboardType, const String& pasteboardName) 189 216 { 190 PlatformPasteboard(pasteboardName).setPathnamesForType(pathnames, pasteboardType);217 WebProcess::shared().connection()->send(Messages::WebContext::SetPasteboardPathnamesForType(pasteboardName, pasteboardType, pathnames), 0); 191 218 } 192 219 193 220 void WebPlatformStrategies::setStringForType(const String& string, const String& pasteboardType, const String& pasteboardName) 194 221 { 195 PlatformPasteboard(pasteboardName).setStringForType(string, pasteboardType);222 WebProcess::shared().connection()->send(Messages::WebContext::SetPasteboardStringForType(pasteboardName, pasteboardType, string), 0); 196 223 } 197 224 #endif
Note:
See TracChangeset
for help on using the changeset viewer.