2 * Copyright (C) 2011 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
27 #include "WebCoreArgumentCoders.h"
29 #include "DataReference.h"
30 #include "ShareableBitmap.h"
31 #include <WebCore/AuthenticationChallenge.h>
32 #include <WebCore/CertificateInfo.h>
33 #include <WebCore/Cookie.h>
34 #include <WebCore/Credential.h>
35 #include <WebCore/Cursor.h>
36 #include <WebCore/DatabaseDetails.h>
37 #include <WebCore/DictationAlternative.h>
38 #include <WebCore/DragSession.h>
39 #include <WebCore/Editor.h>
40 #include <WebCore/FileChooser.h>
41 #include <WebCore/FilterOperation.h>
42 #include <WebCore/FilterOperations.h>
43 #include <WebCore/GraphicsContext.h>
44 #include <WebCore/GraphicsLayer.h>
45 #include <WebCore/IDBDatabaseMetadata.h>
46 #include <WebCore/IDBGetResult.h>
47 #include <WebCore/IDBKeyData.h>
48 #include <WebCore/IDBKeyPath.h>
49 #include <WebCore/IDBKeyRangeData.h>
50 #include <WebCore/Image.h>
51 #include <WebCore/Length.h>
52 #include <WebCore/PluginData.h>
53 #include <WebCore/ProtectionSpace.h>
54 #include <WebCore/ResourceError.h>
55 #include <WebCore/ResourceRequest.h>
56 #include <WebCore/ResourceResponse.h>
57 #include <WebCore/ScrollingConstraints.h>
58 #include <WebCore/ScrollingCoordinator.h>
59 #include <WebCore/TextCheckerClient.h>
60 #include <WebCore/TransformationMatrix.h>
61 #include <WebCore/URL.h>
62 #include <WebCore/UserScript.h>
63 #include <WebCore/UserStyleSheet.h>
64 #include <WebCore/ViewportArguments.h>
65 #include <WebCore/WindowFeatures.h>
66 #include <wtf/text/CString.h>
67 #include <wtf/text/StringHash.h>
70 #include <WebCore/FloatQuad.h>
71 #include <WebCore/Pasteboard.h>
72 #include <WebCore/SelectionRect.h>
73 #include <WebCore/SharedBuffer.h>
74 #endif // PLATFORM(IOS)
76 using namespace WebCore;
77 using namespace WebKit;
81 void ArgumentCoder<AffineTransform>::encode(ArgumentEncoder& encoder, const AffineTransform& affineTransform)
83 SimpleArgumentCoder<AffineTransform>::encode(encoder, affineTransform);
86 bool ArgumentCoder<AffineTransform>::decode(ArgumentDecoder& decoder, AffineTransform& affineTransform)
88 return SimpleArgumentCoder<AffineTransform>::decode(decoder, affineTransform);
92 void ArgumentCoder<TransformationMatrix>::encode(ArgumentEncoder& encoder, const TransformationMatrix& transformationMatrix)
94 SimpleArgumentCoder<TransformationMatrix>::encode(encoder, transformationMatrix);
97 bool ArgumentCoder<TransformationMatrix>::decode(ArgumentDecoder& decoder, TransformationMatrix& transformationMatrix)
99 return SimpleArgumentCoder<TransformationMatrix>::decode(decoder, transformationMatrix);
102 void ArgumentCoder<FloatPoint>::encode(ArgumentEncoder& encoder, const FloatPoint& floatPoint)
104 SimpleArgumentCoder<FloatPoint>::encode(encoder, floatPoint);
107 bool ArgumentCoder<FloatPoint>::decode(ArgumentDecoder& decoder, FloatPoint& floatPoint)
109 return SimpleArgumentCoder<FloatPoint>::decode(decoder, floatPoint);
113 void ArgumentCoder<FloatPoint3D>::encode(ArgumentEncoder& encoder, const FloatPoint3D& floatPoint)
115 SimpleArgumentCoder<FloatPoint3D>::encode(encoder, floatPoint);
118 bool ArgumentCoder<FloatPoint3D>::decode(ArgumentDecoder& decoder, FloatPoint3D& floatPoint)
120 return SimpleArgumentCoder<FloatPoint3D>::decode(decoder, floatPoint);
124 void ArgumentCoder<FloatRect>::encode(ArgumentEncoder& encoder, const FloatRect& floatRect)
126 SimpleArgumentCoder<FloatRect>::encode(encoder, floatRect);
129 bool ArgumentCoder<FloatRect>::decode(ArgumentDecoder& decoder, FloatRect& floatRect)
131 return SimpleArgumentCoder<FloatRect>::decode(decoder, floatRect);
135 void ArgumentCoder<FloatSize>::encode(ArgumentEncoder& encoder, const FloatSize& floatSize)
137 SimpleArgumentCoder<FloatSize>::encode(encoder, floatSize);
140 bool ArgumentCoder<FloatSize>::decode(ArgumentDecoder& decoder, FloatSize& floatSize)
142 return SimpleArgumentCoder<FloatSize>::decode(decoder, floatSize);
147 void ArgumentCoder<FloatQuad>::encode(ArgumentEncoder& encoder, const FloatQuad& floatQuad)
149 SimpleArgumentCoder<FloatQuad>::encode(encoder, floatQuad);
152 bool ArgumentCoder<FloatQuad>::decode(ArgumentDecoder& decoder, FloatQuad& floatQuad)
154 return SimpleArgumentCoder<FloatQuad>::decode(decoder, floatQuad);
157 void ArgumentCoder<ViewportArguments>::encode(ArgumentEncoder& encoder, const ViewportArguments& viewportArguments)
159 SimpleArgumentCoder<ViewportArguments>::encode(encoder, viewportArguments);
162 bool ArgumentCoder<ViewportArguments>::decode(ArgumentDecoder& decoder, ViewportArguments& viewportArguments)
164 return SimpleArgumentCoder<ViewportArguments>::decode(decoder, viewportArguments);
166 #endif // PLATFORM(IOS)
169 void ArgumentCoder<IntPoint>::encode(ArgumentEncoder& encoder, const IntPoint& intPoint)
171 SimpleArgumentCoder<IntPoint>::encode(encoder, intPoint);
174 bool ArgumentCoder<IntPoint>::decode(ArgumentDecoder& decoder, IntPoint& intPoint)
176 return SimpleArgumentCoder<IntPoint>::decode(decoder, intPoint);
180 void ArgumentCoder<IntRect>::encode(ArgumentEncoder& encoder, const IntRect& intRect)
182 SimpleArgumentCoder<IntRect>::encode(encoder, intRect);
185 bool ArgumentCoder<IntRect>::decode(ArgumentDecoder& decoder, IntRect& intRect)
187 return SimpleArgumentCoder<IntRect>::decode(decoder, intRect);
191 void ArgumentCoder<IntSize>::encode(ArgumentEncoder& encoder, const IntSize& intSize)
193 SimpleArgumentCoder<IntSize>::encode(encoder, intSize);
196 bool ArgumentCoder<IntSize>::decode(ArgumentDecoder& decoder, IntSize& intSize)
198 return SimpleArgumentCoder<IntSize>::decode(decoder, intSize);
202 void ArgumentCoder<Length>::encode(ArgumentEncoder& encoder, const Length& length)
204 SimpleArgumentCoder<Length>::encode(encoder, length);
207 bool ArgumentCoder<Length>::decode(ArgumentDecoder& decoder, Length& length)
209 return SimpleArgumentCoder<Length>::decode(decoder, length);
213 void ArgumentCoder<ViewportAttributes>::encode(ArgumentEncoder& encoder, const ViewportAttributes& viewportAttributes)
215 SimpleArgumentCoder<ViewportAttributes>::encode(encoder, viewportAttributes);
218 bool ArgumentCoder<ViewportAttributes>::decode(ArgumentDecoder& decoder, ViewportAttributes& viewportAttributes)
220 return SimpleArgumentCoder<ViewportAttributes>::decode(decoder, viewportAttributes);
224 void ArgumentCoder<MimeClassInfo>::encode(ArgumentEncoder& encoder, const MimeClassInfo& mimeClassInfo)
226 encoder << mimeClassInfo.type << mimeClassInfo.desc << mimeClassInfo.extensions;
229 bool ArgumentCoder<MimeClassInfo>::decode(ArgumentDecoder& decoder, MimeClassInfo& mimeClassInfo)
231 if (!decoder.decode(mimeClassInfo.type))
233 if (!decoder.decode(mimeClassInfo.desc))
235 if (!decoder.decode(mimeClassInfo.extensions))
242 void ArgumentCoder<PluginInfo>::encode(ArgumentEncoder& encoder, const PluginInfo& pluginInfo)
244 encoder << pluginInfo.name << pluginInfo.file << pluginInfo.desc << pluginInfo.mimes << pluginInfo.isApplicationPlugin;
247 bool ArgumentCoder<PluginInfo>::decode(ArgumentDecoder& decoder, PluginInfo& pluginInfo)
249 if (!decoder.decode(pluginInfo.name))
251 if (!decoder.decode(pluginInfo.file))
253 if (!decoder.decode(pluginInfo.desc))
255 if (!decoder.decode(pluginInfo.mimes))
257 if (!decoder.decode(pluginInfo.isApplicationPlugin))
264 void ArgumentCoder<HTTPHeaderMap>::encode(ArgumentEncoder& encoder, const HTTPHeaderMap& headerMap)
266 encoder << static_cast<const HashMap<AtomicString, String, CaseFoldingHash>&>(headerMap);
269 bool ArgumentCoder<HTTPHeaderMap>::decode(ArgumentDecoder& decoder, HTTPHeaderMap& headerMap)
271 return decoder.decode(static_cast<HashMap<AtomicString, String, CaseFoldingHash>&>(headerMap));
275 void ArgumentCoder<AuthenticationChallenge>::encode(ArgumentEncoder& encoder, const AuthenticationChallenge& challenge)
277 encoder << challenge.protectionSpace() << challenge.proposedCredential() << challenge.previousFailureCount() << challenge.failureResponse() << challenge.error();
280 bool ArgumentCoder<AuthenticationChallenge>::decode(ArgumentDecoder& decoder, AuthenticationChallenge& challenge)
282 ProtectionSpace protectionSpace;
283 if (!decoder.decode(protectionSpace))
286 Credential proposedCredential;
287 if (!decoder.decode(proposedCredential))
290 unsigned previousFailureCount;
291 if (!decoder.decode(previousFailureCount))
294 ResourceResponse failureResponse;
295 if (!decoder.decode(failureResponse))
299 if (!decoder.decode(error))
302 challenge = AuthenticationChallenge(protectionSpace, proposedCredential, previousFailureCount, failureResponse, error);
307 void ArgumentCoder<ProtectionSpace>::encode(ArgumentEncoder& encoder, const ProtectionSpace& space)
309 encoder << space.host() << space.port() << space.realm();
310 encoder.encodeEnum(space.authenticationScheme());
311 encoder.encodeEnum(space.serverType());
314 bool ArgumentCoder<ProtectionSpace>::decode(ArgumentDecoder& decoder, ProtectionSpace& space)
317 if (!decoder.decode(host))
321 if (!decoder.decode(port))
325 if (!decoder.decode(realm))
328 ProtectionSpaceAuthenticationScheme authenticationScheme;
329 if (!decoder.decodeEnum(authenticationScheme))
332 ProtectionSpaceServerType serverType;
333 if (!decoder.decodeEnum(serverType))
336 space = ProtectionSpace(host, port, serverType, realm, authenticationScheme);
340 void ArgumentCoder<Credential>::encode(ArgumentEncoder& encoder, const Credential& credential)
342 encoder << credential.user() << credential.password();
343 encoder.encodeEnum(credential.persistence());
346 bool ArgumentCoder<Credential>::decode(ArgumentDecoder& decoder, Credential& credential)
349 if (!decoder.decode(user))
353 if (!decoder.decode(password))
356 CredentialPersistence persistence;
357 if (!decoder.decodeEnum(persistence))
360 credential = Credential(user, password, persistence);
364 static void encodeImage(ArgumentEncoder& encoder, Image* image)
366 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(image->size(), ShareableBitmap::SupportsAlpha);
367 bitmap->createGraphicsContext()->drawImage(image, ColorSpaceDeviceRGB, IntPoint());
369 ShareableBitmap::Handle handle;
370 bitmap->createHandle(handle);
375 static bool decodeImage(ArgumentDecoder& decoder, RefPtr<Image>& image)
377 ShareableBitmap::Handle handle;
378 if (!decoder.decode(handle))
381 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(handle);
384 image = bitmap->createImage();
391 void ArgumentCoder<Cursor>::encode(ArgumentEncoder& encoder, const Cursor& cursor)
393 encoder.encodeEnum(cursor.type());
395 if (cursor.type() != Cursor::Custom)
398 if (cursor.image()->isNull()) {
399 encoder << false; // There is no valid image being encoded.
404 encodeImage(encoder, cursor.image());
405 encoder << cursor.hotSpot();
408 bool ArgumentCoder<Cursor>::decode(ArgumentDecoder& decoder, Cursor& cursor)
411 if (!decoder.decodeEnum(type))
414 if (type > Cursor::Custom)
417 if (type != Cursor::Custom) {
418 const Cursor& cursorReference = Cursor::fromType(type);
419 // Calling platformCursor here will eagerly create the platform cursor for the cursor singletons inside WebCore.
420 // This will avoid having to re-create the platform cursors over and over.
421 (void)cursorReference.platformCursor();
423 cursor = cursorReference;
427 bool isValidImagePresent;
428 if (!decoder.decode(isValidImagePresent))
431 if (!isValidImagePresent) {
432 cursor = Cursor(Image::nullImage(), IntPoint());
437 if (!decodeImage(decoder, image))
441 if (!decoder.decode(hotSpot))
444 if (!image->rect().contains(hotSpot))
447 cursor = Cursor(image.get(), hotSpot);
452 void ArgumentCoder<ResourceRequest>::encode(ArgumentEncoder& encoder, const ResourceRequest& resourceRequest)
454 if (kShouldSerializeWebCoreData) {
455 encoder << resourceRequest.url().string();
456 encoder << resourceRequest.httpMethod();
457 encoder << resourceRequest.httpHeaderFields();
459 // FIXME: Do not encode HTTP message body.
460 // 1. It can be large and thus costly to send across.
461 // 2. It is misleading to provide a body with some requests, while others use body streams, which cannot be serialized at all.
462 FormData* httpBody = resourceRequest.httpBody();
463 encoder << static_cast<bool>(httpBody);
465 encoder << httpBody->flattenToString();
467 encoder << resourceRequest.firstPartyForCookies().string();
470 #if ENABLE(CACHE_PARTITIONING)
471 encoder << resourceRequest.cachePartition();
474 encodePlatformData(encoder, resourceRequest);
477 bool ArgumentCoder<ResourceRequest>::decode(ArgumentDecoder& decoder, ResourceRequest& resourceRequest)
479 if (kShouldSerializeWebCoreData) {
480 ResourceRequest request;
483 if (!decoder.decode(url))
485 request.setURL(URL(URL(), url));
488 if (!decoder.decode(httpMethod))
490 request.setHTTPMethod(httpMethod);
492 HTTPHeaderMap headers;
493 if (!decoder.decode(headers))
495 request.addHTTPHeaderFields(headers);
498 if (!decoder.decode(hasHTTPBody))
502 if (!decoder.decode(httpBody))
504 request.setHTTPBody(FormData::create(httpBody.utf8()));
507 String firstPartyForCookies;
508 if (!decoder.decode(firstPartyForCookies))
510 request.setFirstPartyForCookies(URL(URL(), firstPartyForCookies));
512 resourceRequest = request;
515 #if ENABLE(CACHE_PARTITIONING)
516 String cachePartition;
517 if (!decoder.decode(cachePartition))
519 resourceRequest.setCachePartition(cachePartition);
522 return decodePlatformData(decoder, resourceRequest);
525 void ArgumentCoder<ResourceResponse>::encode(ArgumentEncoder& encoder, const ResourceResponse& resourceResponse)
528 bool shouldSerializeWebCoreData = !resourceResponse.platformResponseIsUpToDate();
529 encoder << shouldSerializeWebCoreData;
531 bool shouldSerializeWebCoreData = true;
534 encodePlatformData(encoder, resourceResponse);
536 if (shouldSerializeWebCoreData) {
537 bool responseIsNull = resourceResponse.isNull();
538 encoder << responseIsNull;
542 encoder << resourceResponse.url().string();
543 encoder << static_cast<int32_t>(resourceResponse.httpStatusCode());
544 encoder << resourceResponse.httpHeaderFields();
546 encoder << resourceResponse.mimeType();
547 encoder << resourceResponse.textEncodingName();
548 encoder << static_cast<int64_t>(resourceResponse.expectedContentLength());
549 encoder << resourceResponse.httpStatusText();
550 encoder << resourceResponse.suggestedFilename();
554 bool ArgumentCoder<ResourceResponse>::decode(ArgumentDecoder& decoder, ResourceResponse& resourceResponse)
557 bool hasSerializedWebCoreData;
558 if (!decoder.decode(hasSerializedWebCoreData))
561 bool hasSerializedWebCoreData = true;
564 ResourceResponse response;
566 if (!decodePlatformData(decoder, response))
569 if (hasSerializedWebCoreData) {
571 if (!decoder.decode(responseIsNull))
573 if (responseIsNull) {
574 resourceResponse = ResourceResponse();
579 if (!decoder.decode(url))
581 response.setURL(URL(URL(), url));
583 int32_t httpStatusCode;
584 if (!decoder.decode(httpStatusCode))
586 response.setHTTPStatusCode(httpStatusCode);
588 HTTPHeaderMap headers;
589 if (!decoder.decode(headers))
591 for (HTTPHeaderMap::const_iterator it = headers.begin(), end = headers.end(); it != end; ++it)
592 response.setHTTPHeaderField(it->key, it->value);
595 if (!decoder.decode(mimeType))
597 response.setMimeType(mimeType);
599 String textEncodingName;
600 if (!decoder.decode(textEncodingName))
602 response.setTextEncodingName(textEncodingName);
604 int64_t contentLength;
605 if (!decoder.decode(contentLength))
607 response.setExpectedContentLength(contentLength);
609 String httpStatusText;
610 if (!decoder.decode(httpStatusText))
612 response.setHTTPStatusText(httpStatusText);
614 String suggestedFilename;
615 if (!decoder.decode(suggestedFilename))
617 response.setSuggestedFilename(suggestedFilename);
620 resourceResponse = response;
625 void ArgumentCoder<ResourceError>::encode(ArgumentEncoder& encoder, const ResourceError& resourceError)
627 if (kShouldSerializeWebCoreData) {
628 bool errorIsNull = resourceError.isNull();
629 encoder << errorIsNull;
633 encoder << resourceError.domain();
634 encoder << resourceError.errorCode();
635 encoder << resourceError.failingURL();
636 encoder << resourceError.localizedDescription();
637 encoder << resourceError.isCancellation();
638 encoder << resourceError.isTimeout();
641 encodePlatformData(encoder, resourceError);
644 bool ArgumentCoder<ResourceError>::decode(ArgumentDecoder& decoder, ResourceError& resourceError)
646 if (kShouldSerializeWebCoreData) {
648 if (!decoder.decode(errorIsNull))
651 resourceError = ResourceError();
656 if (!decoder.decode(domain))
660 if (!decoder.decode(errorCode))
664 if (!decoder.decode(failingURL))
667 String localizedDescription;
668 if (!decoder.decode(localizedDescription))
672 if (!decoder.decode(isCancellation))
676 if (!decoder.decode(isTimeout))
679 resourceError = ResourceError(domain, errorCode, failingURL, localizedDescription);
680 resourceError.setIsCancellation(isCancellation);
681 resourceError.setIsTimeout(isTimeout);
684 return decodePlatformData(decoder, resourceError);
689 void ArgumentCoder<SelectionRect>::encode(ArgumentEncoder& encoder, const SelectionRect& selectionRect)
691 encoder << selectionRect.rect();
692 encoder << static_cast<uint32_t>(selectionRect.direction());
693 encoder << selectionRect.minX();
694 encoder << selectionRect.maxX();
695 encoder << selectionRect.maxY();
696 encoder << selectionRect.lineNumber();
697 encoder << selectionRect.isLineBreak();
698 encoder << selectionRect.isFirstOnLine();
699 encoder << selectionRect.isLastOnLine();
700 encoder << selectionRect.containsStart();
701 encoder << selectionRect.containsEnd();
702 encoder << selectionRect.isHorizontal();
705 bool ArgumentCoder<SelectionRect>::decode(ArgumentDecoder& decoder, SelectionRect& selectionRect)
707 WebCore::IntRect rect;
708 if (!decoder.decode(rect))
710 selectionRect.setRect(rect);
713 if (!decoder.decode(direction))
715 selectionRect.setDirection((WebCore::TextDirection)direction);
718 if (!decoder.decode(intValue))
720 selectionRect.setMinX(intValue);
722 if (!decoder.decode(intValue))
724 selectionRect.setMaxX(intValue);
726 if (!decoder.decode(intValue))
728 selectionRect.setMaxY(intValue);
730 if (!decoder.decode(intValue))
732 selectionRect.setLineNumber(intValue);
735 if (!decoder.decode(boolValue))
737 selectionRect.setIsLineBreak(boolValue);
739 if (!decoder.decode(boolValue))
741 selectionRect.setIsFirstOnLine(boolValue);
743 if (!decoder.decode(boolValue))
745 selectionRect.setIsLastOnLine(boolValue);
747 if (!decoder.decode(boolValue))
749 selectionRect.setContainsStart(boolValue);
751 if (!decoder.decode(boolValue))
753 selectionRect.setContainsEnd(boolValue);
755 if (!decoder.decode(boolValue))
757 selectionRect.setIsHorizontal(boolValue);
764 void ArgumentCoder<WindowFeatures>::encode(ArgumentEncoder& encoder, const WindowFeatures& windowFeatures)
766 encoder << windowFeatures.x;
767 encoder << windowFeatures.y;
768 encoder << windowFeatures.width;
769 encoder << windowFeatures.height;
770 encoder << windowFeatures.xSet;
771 encoder << windowFeatures.ySet;
772 encoder << windowFeatures.widthSet;
773 encoder << windowFeatures.heightSet;
774 encoder << windowFeatures.menuBarVisible;
775 encoder << windowFeatures.statusBarVisible;
776 encoder << windowFeatures.toolBarVisible;
777 encoder << windowFeatures.locationBarVisible;
778 encoder << windowFeatures.scrollbarsVisible;
779 encoder << windowFeatures.resizable;
780 encoder << windowFeatures.fullscreen;
781 encoder << windowFeatures.dialog;
784 bool ArgumentCoder<WindowFeatures>::decode(ArgumentDecoder& decoder, WindowFeatures& windowFeatures)
786 if (!decoder.decode(windowFeatures.x))
788 if (!decoder.decode(windowFeatures.y))
790 if (!decoder.decode(windowFeatures.width))
792 if (!decoder.decode(windowFeatures.height))
794 if (!decoder.decode(windowFeatures.xSet))
796 if (!decoder.decode(windowFeatures.ySet))
798 if (!decoder.decode(windowFeatures.widthSet))
800 if (!decoder.decode(windowFeatures.heightSet))
802 if (!decoder.decode(windowFeatures.menuBarVisible))
804 if (!decoder.decode(windowFeatures.statusBarVisible))
806 if (!decoder.decode(windowFeatures.toolBarVisible))
808 if (!decoder.decode(windowFeatures.locationBarVisible))
810 if (!decoder.decode(windowFeatures.scrollbarsVisible))
812 if (!decoder.decode(windowFeatures.resizable))
814 if (!decoder.decode(windowFeatures.fullscreen))
816 if (!decoder.decode(windowFeatures.dialog))
822 void ArgumentCoder<Color>::encode(ArgumentEncoder& encoder, const Color& color)
824 if (!color.isValid()) {
830 encoder << color.rgb();
833 bool ArgumentCoder<Color>::decode(ArgumentDecoder& decoder, Color& color)
836 if (!decoder.decode(isValid))
845 if (!decoder.decode(rgba))
853 void ArgumentCoder<CompositionUnderline>::encode(ArgumentEncoder& encoder, const CompositionUnderline& underline)
855 encoder << underline.startOffset;
856 encoder << underline.endOffset;
857 encoder << underline.thick;
858 encoder << underline.color;
861 bool ArgumentCoder<CompositionUnderline>::decode(ArgumentDecoder& decoder, CompositionUnderline& underline)
863 if (!decoder.decode(underline.startOffset))
865 if (!decoder.decode(underline.endOffset))
867 if (!decoder.decode(underline.thick))
869 if (!decoder.decode(underline.color))
876 void ArgumentCoder<Cookie>::encode(ArgumentEncoder& encoder, const Cookie& cookie)
878 encoder << cookie.name;
879 encoder << cookie.value;
880 encoder << cookie.domain;
881 encoder << cookie.path;
882 encoder << cookie.expires;
883 encoder << cookie.httpOnly;
884 encoder << cookie.secure;
885 encoder << cookie.session;
888 bool ArgumentCoder<Cookie>::decode(ArgumentDecoder& decoder, Cookie& cookie)
890 if (!decoder.decode(cookie.name))
892 if (!decoder.decode(cookie.value))
894 if (!decoder.decode(cookie.domain))
896 if (!decoder.decode(cookie.path))
898 if (!decoder.decode(cookie.expires))
900 if (!decoder.decode(cookie.httpOnly))
902 if (!decoder.decode(cookie.secure))
904 if (!decoder.decode(cookie.session))
911 #if ENABLE(SQL_DATABASE)
912 void ArgumentCoder<DatabaseDetails>::encode(ArgumentEncoder& encoder, const DatabaseDetails& details)
914 encoder << details.name();
915 encoder << details.displayName();
916 encoder << details.expectedUsage();
917 encoder << details.currentUsage();
920 bool ArgumentCoder<DatabaseDetails>::decode(ArgumentDecoder& decoder, DatabaseDetails& details)
923 if (!decoder.decode(name))
927 if (!decoder.decode(displayName))
930 uint64_t expectedUsage;
931 if (!decoder.decode(expectedUsage))
934 uint64_t currentUsage;
935 if (!decoder.decode(currentUsage))
938 details = DatabaseDetails(name, displayName, expectedUsage, currentUsage);
946 static void encodeSharedBuffer(ArgumentEncoder& encoder, SharedBuffer* buffer)
948 SharedMemory::Handle handle;
949 encoder << (buffer ? static_cast<uint64_t>(buffer->size()): 0);
951 RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::create(buffer->size());
952 memcpy(sharedMemoryBuffer->data(), buffer->data(), buffer->size());
953 sharedMemoryBuffer->createHandle(handle, SharedMemory::ReadOnly);
958 static bool decodeSharedBuffer(ArgumentDecoder& decoder, RefPtr<SharedBuffer>& buffer)
960 uint64_t bufferSize = 0;
961 if (!decoder.decode(bufferSize))
965 SharedMemory::Handle handle;
966 if (!decoder.decode(handle))
969 RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::create(handle, SharedMemory::ReadOnly);
970 buffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryBuffer->data()), bufferSize);
976 void ArgumentCoder<PasteboardWebContent>::encode(ArgumentEncoder& encoder, const WebCore::PasteboardWebContent& content)
978 encoder << content.canSmartCopyOrDelete;
979 encoder << content.dataInStringFormat;
981 encodeSharedBuffer(encoder, content.dataInWebArchiveFormat.get());
982 encodeSharedBuffer(encoder, content.dataInRTFDFormat.get());
983 encodeSharedBuffer(encoder, content.dataInRTFFormat.get());
985 encoder << content.clientTypes;
986 encoder << static_cast<uint64_t>(content.clientData.size());
987 for (size_t i = 0; i < content.clientData.size(); i++)
988 encodeSharedBuffer(encoder, content.clientData[i].get());
991 bool ArgumentCoder<PasteboardWebContent>::decode(ArgumentDecoder& decoder, WebCore::PasteboardWebContent& content)
993 if (!decoder.decode(content.canSmartCopyOrDelete))
995 if (!decoder.decode(content.dataInStringFormat))
997 if (!decodeSharedBuffer(decoder, content.dataInWebArchiveFormat))
999 if (!decodeSharedBuffer(decoder, content.dataInRTFDFormat))
1001 if (!decodeSharedBuffer(decoder, content.dataInRTFFormat))
1003 if (!decoder.decode(content.clientTypes))
1005 uint64_t clientDataSize;
1006 if (!decoder.decode(clientDataSize))
1009 content.clientData.resize(clientDataSize);
1010 for (size_t i = 0; i < clientDataSize; i++)
1011 decodeSharedBuffer(decoder, content.clientData[i]);
1015 void ArgumentCoder<PasteboardImage>::encode(ArgumentEncoder& encoder, const WebCore::PasteboardImage& pasteboardImage)
1017 encodeImage(encoder, pasteboardImage.image.get());
1018 encoder << pasteboardImage.url.url;
1019 encoder << pasteboardImage.url.title;
1020 encoder << pasteboardImage.resourceMIMEType;
1021 if (pasteboardImage.resourceData)
1022 encodeSharedBuffer(encoder, pasteboardImage.resourceData.get());
1025 bool ArgumentCoder<PasteboardImage>::decode(ArgumentDecoder& decoder, WebCore::PasteboardImage& pasteboardImage)
1027 if (!decodeImage(decoder, pasteboardImage.image))
1029 if (!decoder.decode(pasteboardImage.url.url))
1031 if (!decoder.decode(pasteboardImage.url.title))
1033 if (!decoder.decode(pasteboardImage.resourceMIMEType))
1035 if (!decodeSharedBuffer(decoder, pasteboardImage.resourceData))
1042 void ArgumentCoder<DictationAlternative>::encode(ArgumentEncoder& encoder, const DictationAlternative& dictationAlternative)
1044 encoder << dictationAlternative.rangeStart;
1045 encoder << dictationAlternative.rangeLength;
1046 encoder << dictationAlternative.dictationContext;
1049 bool ArgumentCoder<DictationAlternative>::decode(ArgumentDecoder& decoder, DictationAlternative& dictationAlternative)
1051 if (!decoder.decode(dictationAlternative.rangeStart))
1053 if (!decoder.decode(dictationAlternative.rangeLength))
1055 if (!decoder.decode(dictationAlternative.dictationContext))
1061 void ArgumentCoder<FileChooserSettings>::encode(ArgumentEncoder& encoder, const FileChooserSettings& settings)
1063 encoder << settings.allowsMultipleFiles;
1064 #if ENABLE(DIRECTORY_UPLOAD)
1065 encoder << settings.allowsDirectoryUpload;
1067 encoder << settings.acceptMIMETypes;
1068 encoder << settings.selectedFiles;
1069 #if ENABLE(MEDIA_CAPTURE)
1070 encoder << settings.capture;
1074 bool ArgumentCoder<FileChooserSettings>::decode(ArgumentDecoder& decoder, FileChooserSettings& settings)
1076 if (!decoder.decode(settings.allowsMultipleFiles))
1078 #if ENABLE(DIRECTORY_UPLOAD)
1079 if (!decoder.decode(settings.allowsDirectoryUpload))
1082 if (!decoder.decode(settings.acceptMIMETypes))
1084 if (!decoder.decode(settings.selectedFiles))
1086 #if ENABLE(MEDIA_CAPTURE)
1087 if (!decoder.decode(settings.capture))
1095 void ArgumentCoder<GrammarDetail>::encode(ArgumentEncoder& encoder, const GrammarDetail& detail)
1097 encoder << detail.location;
1098 encoder << detail.length;
1099 encoder << detail.guesses;
1100 encoder << detail.userDescription;
1103 bool ArgumentCoder<GrammarDetail>::decode(ArgumentDecoder& decoder, GrammarDetail& detail)
1105 if (!decoder.decode(detail.location))
1107 if (!decoder.decode(detail.length))
1109 if (!decoder.decode(detail.guesses))
1111 if (!decoder.decode(detail.userDescription))
1117 void ArgumentCoder<TextCheckingRequestData>::encode(ArgumentEncoder& encoder, const TextCheckingRequestData& request)
1119 encoder << request.sequence();
1120 encoder << request.text();
1121 encoder << request.mask();
1122 encoder.encodeEnum(request.processType());
1125 bool ArgumentCoder<TextCheckingRequestData>::decode(ArgumentDecoder& decoder, TextCheckingRequestData& request)
1128 if (!decoder.decode(sequence))
1132 if (!decoder.decode(text))
1135 TextCheckingTypeMask mask;
1136 if (!decoder.decode(mask))
1139 TextCheckingProcessType processType;
1140 if (!decoder.decodeEnum(processType))
1143 request = TextCheckingRequestData(sequence, text, mask, processType);
1147 void ArgumentCoder<TextCheckingResult>::encode(ArgumentEncoder& encoder, const TextCheckingResult& result)
1149 encoder.encodeEnum(result.type);
1150 encoder << result.location;
1151 encoder << result.length;
1152 encoder << result.details;
1153 encoder << result.replacement;
1156 bool ArgumentCoder<TextCheckingResult>::decode(ArgumentDecoder& decoder, TextCheckingResult& result)
1158 if (!decoder.decodeEnum(result.type))
1160 if (!decoder.decode(result.location))
1162 if (!decoder.decode(result.length))
1164 if (!decoder.decode(result.details))
1166 if (!decoder.decode(result.replacement))
1171 void ArgumentCoder<DragSession>::encode(ArgumentEncoder& encoder, const DragSession& result)
1173 encoder.encodeEnum(result.operation);
1174 encoder << result.mouseIsOverFileInput;
1175 encoder << result.numberOfItemsToBeAccepted;
1178 bool ArgumentCoder<DragSession>::decode(ArgumentDecoder& decoder, DragSession& result)
1180 if (!decoder.decodeEnum(result.operation))
1182 if (!decoder.decode(result.mouseIsOverFileInput))
1184 if (!decoder.decode(result.numberOfItemsToBeAccepted))
1189 void ArgumentCoder<URL>::encode(ArgumentEncoder& encoder, const URL& result)
1191 encoder << result.string();
1194 bool ArgumentCoder<URL>::decode(ArgumentDecoder& decoder, URL& result)
1197 if (!decoder.decode(urlAsString))
1199 result = URL(WebCore::ParsedURLString, urlAsString);
1203 void ArgumentCoder<WebCore::UserStyleSheet>::encode(ArgumentEncoder& encoder, const WebCore::UserStyleSheet& userStyleSheet)
1205 encoder << userStyleSheet.source();
1206 encoder << userStyleSheet.url();
1207 encoder << userStyleSheet.whitelist();
1208 encoder << userStyleSheet.blacklist();
1209 encoder.encodeEnum(userStyleSheet.injectedFrames());
1210 encoder.encodeEnum(userStyleSheet.level());
1213 bool ArgumentCoder<WebCore::UserStyleSheet>::decode(ArgumentDecoder& decoder, WebCore::UserStyleSheet& userStyleSheet)
1216 if (!decoder.decode(source))
1220 if (!decoder.decode(url))
1223 Vector<String> whitelist;
1224 if (!decoder.decode(whitelist))
1227 Vector<String> blacklist;
1228 if (!decoder.decode(blacklist))
1231 WebCore::UserContentInjectedFrames injectedFrames;
1232 if (!decoder.decodeEnum(injectedFrames))
1235 WebCore::UserStyleLevel level;
1236 if (!decoder.decodeEnum(level))
1239 userStyleSheet = WebCore::UserStyleSheet(source, url, whitelist, blacklist, injectedFrames, level);
1243 void ArgumentCoder<WebCore::UserScript>::encode(ArgumentEncoder& encoder, const WebCore::UserScript& userScript)
1245 encoder << userScript.source();
1246 encoder << userScript.url();
1247 encoder << userScript.whitelist();
1248 encoder << userScript.blacklist();
1249 encoder.encodeEnum(userScript.injectionTime());
1250 encoder.encodeEnum(userScript.injectedFrames());
1253 bool ArgumentCoder<WebCore::UserScript>::decode(ArgumentDecoder& decoder, WebCore::UserScript& userScript)
1256 if (!decoder.decode(source))
1260 if (!decoder.decode(url))
1263 Vector<String> whitelist;
1264 if (!decoder.decode(whitelist))
1267 Vector<String> blacklist;
1268 if (!decoder.decode(blacklist))
1271 WebCore::UserScriptInjectionTime injectionTime;
1272 if (!decoder.decodeEnum(injectionTime))
1275 WebCore::UserContentInjectedFrames injectedFrames;
1276 if (!decoder.decodeEnum(injectedFrames))
1279 userScript = WebCore::UserScript(source, url, whitelist, blacklist, injectionTime, injectedFrames);
1283 void ArgumentCoder<WebCore::ScrollableAreaParameters>::encode(ArgumentEncoder& encoder, const WebCore::ScrollableAreaParameters& parameters)
1285 encoder.encodeEnum(parameters.horizontalScrollElasticity);
1286 encoder.encodeEnum(parameters.verticalScrollElasticity);
1288 encoder.encodeEnum(parameters.horizontalScrollbarMode);
1289 encoder.encodeEnum(parameters.verticalScrollbarMode);
1291 encoder << parameters.hasEnabledHorizontalScrollbar;
1292 encoder << parameters.hasEnabledVerticalScrollbar;
1295 bool ArgumentCoder<WebCore::ScrollableAreaParameters>::decode(ArgumentDecoder& decoder, WebCore::ScrollableAreaParameters& params)
1297 if (!decoder.decodeEnum(params.horizontalScrollElasticity))
1299 if (!decoder.decodeEnum(params.verticalScrollElasticity))
1302 if (!decoder.decodeEnum(params.horizontalScrollbarMode))
1304 if (!decoder.decodeEnum(params.verticalScrollbarMode))
1307 if (!decoder.decode(params.hasEnabledHorizontalScrollbar))
1309 if (!decoder.decode(params.hasEnabledVerticalScrollbar))
1315 void ArgumentCoder<WebCore::FixedPositionViewportConstraints>::encode(ArgumentEncoder& encoder, const WebCore::FixedPositionViewportConstraints& viewportConstraints)
1317 encoder << viewportConstraints.alignmentOffset();
1318 encoder << viewportConstraints.anchorEdges();
1320 encoder << viewportConstraints.viewportRectAtLastLayout();
1321 encoder << viewportConstraints.layerPositionAtLastLayout();
1324 bool ArgumentCoder<WebCore::FixedPositionViewportConstraints>::decode(ArgumentDecoder& decoder, WebCore::FixedPositionViewportConstraints& viewportConstraints)
1326 FloatSize alignmentOffset;
1327 if (!decoder.decode(alignmentOffset))
1330 ViewportConstraints::AnchorEdges anchorEdges;
1331 if (!decoder.decode(anchorEdges))
1334 FloatRect viewportRectAtLastLayout;
1335 if (!decoder.decode(viewportRectAtLastLayout))
1338 FloatPoint layerPositionAtLastLayout;
1339 if (!decoder.decode(layerPositionAtLastLayout))
1342 viewportConstraints = WebCore::FixedPositionViewportConstraints();
1343 viewportConstraints.setAlignmentOffset(alignmentOffset);
1344 viewportConstraints.setAnchorEdges(anchorEdges);
1346 viewportConstraints.setViewportRectAtLastLayout(viewportRectAtLastLayout);
1347 viewportConstraints.setLayerPositionAtLastLayout(layerPositionAtLastLayout);
1352 void ArgumentCoder<WebCore::StickyPositionViewportConstraints>::encode(ArgumentEncoder& encoder, const WebCore::StickyPositionViewportConstraints& viewportConstraints)
1354 encoder << viewportConstraints.alignmentOffset();
1355 encoder << viewportConstraints.anchorEdges();
1357 encoder << viewportConstraints.leftOffset();
1358 encoder << viewportConstraints.rightOffset();
1359 encoder << viewportConstraints.topOffset();
1360 encoder << viewportConstraints.bottomOffset();
1362 encoder << viewportConstraints.constrainingRectAtLastLayout();
1363 encoder << viewportConstraints.containingBlockRect();
1364 encoder << viewportConstraints.stickyBoxRect();
1366 encoder << viewportConstraints.stickyOffsetAtLastLayout();
1367 encoder << viewportConstraints.layerPositionAtLastLayout();
1370 bool ArgumentCoder<WebCore::StickyPositionViewportConstraints>::decode(ArgumentDecoder& decoder, WebCore::StickyPositionViewportConstraints& viewportConstraints)
1372 FloatSize alignmentOffset;
1373 if (!decoder.decode(alignmentOffset))
1376 ViewportConstraints::AnchorEdges anchorEdges;
1377 if (!decoder.decode(anchorEdges))
1381 if (!decoder.decode(leftOffset))
1385 if (!decoder.decode(rightOffset))
1389 if (!decoder.decode(topOffset))
1393 if (!decoder.decode(bottomOffset))
1396 FloatRect constrainingRectAtLastLayout;
1397 if (!decoder.decode(constrainingRectAtLastLayout))
1400 FloatRect containingBlockRect;
1401 if (!decoder.decode(containingBlockRect))
1404 FloatRect stickyBoxRect;
1405 if (!decoder.decode(stickyBoxRect))
1408 FloatSize stickyOffsetAtLastLayout;
1409 if (!decoder.decode(stickyOffsetAtLastLayout))
1412 FloatPoint layerPositionAtLastLayout;
1413 if (!decoder.decode(layerPositionAtLastLayout))
1416 viewportConstraints = WebCore::StickyPositionViewportConstraints();
1417 viewportConstraints.setAlignmentOffset(alignmentOffset);
1418 viewportConstraints.setAnchorEdges(anchorEdges);
1420 viewportConstraints.setLeftOffset(leftOffset);
1421 viewportConstraints.setRightOffset(rightOffset);
1422 viewportConstraints.setTopOffset(topOffset);
1423 viewportConstraints.setBottomOffset(bottomOffset);
1425 viewportConstraints.setConstrainingRectAtLastLayout(constrainingRectAtLastLayout);
1426 viewportConstraints.setContainingBlockRect(containingBlockRect);
1427 viewportConstraints.setStickyBoxRect(stickyBoxRect);
1429 viewportConstraints.setStickyOffsetAtLastLayout(stickyOffsetAtLastLayout);
1430 viewportConstraints.setLayerPositionAtLastLayout(layerPositionAtLastLayout);
1435 #if ENABLE(CSS_FILTERS) && !USE(COORDINATED_GRAPHICS)
1436 static void encodeFilterOperation(ArgumentEncoder& encoder, const FilterOperation& filter)
1438 encoder.encodeEnum(filter.type());
1440 switch (filter.type()) {
1441 case FilterOperation::REFERENCE: {
1442 const auto& referenceFilter = static_cast<const ReferenceFilterOperation&>(filter);
1443 encoder << referenceFilter.url();
1444 encoder << referenceFilter.fragment();
1447 case FilterOperation::GRAYSCALE:
1448 case FilterOperation::SEPIA:
1449 case FilterOperation::SATURATE:
1450 case FilterOperation::HUE_ROTATE:
1451 encoder << static_cast<const BasicColorMatrixFilterOperation&>(filter).amount();
1453 case FilterOperation::INVERT:
1454 case FilterOperation::OPACITY:
1455 case FilterOperation::BRIGHTNESS:
1456 case FilterOperation::CONTRAST:
1457 encoder << static_cast<const BasicComponentTransferFilterOperation&>(filter).amount();
1459 case FilterOperation::BLUR:
1460 encoder << static_cast<const BlurFilterOperation&>(filter).stdDeviation();
1462 case FilterOperation::DROP_SHADOW: {
1463 const auto& dropShadowFilter = static_cast<const DropShadowFilterOperation&>(filter);
1464 encoder << dropShadowFilter.location();
1465 encoder << dropShadowFilter.stdDeviation();
1466 encoder << dropShadowFilter.color();
1469 #if ENABLE(CSS_SHADERS)
1470 case FilterOperation::CUSTOM:
1471 case FilterOperation::VALIDATED_CUSTOM:
1472 ASSERT_NOT_REACHED();
1475 case FilterOperation::PASSTHROUGH:
1476 case FilterOperation::NONE:
1481 static bool decodeFilterOperation(ArgumentDecoder& decoder, RefPtr<FilterOperation>& filter)
1483 FilterOperation::OperationType type;
1484 if (!decoder.decodeEnum(type))
1488 case FilterOperation::REFERENCE: {
1491 if (!decoder.decode(url))
1493 if (!decoder.decode(fragment))
1495 filter = ReferenceFilterOperation::create(url, fragment, type);
1498 case FilterOperation::GRAYSCALE:
1499 case FilterOperation::SEPIA:
1500 case FilterOperation::SATURATE:
1501 case FilterOperation::HUE_ROTATE: {
1503 if (!decoder.decode(amount))
1505 filter = BasicColorMatrixFilterOperation::create(amount, type);
1508 case FilterOperation::INVERT:
1509 case FilterOperation::OPACITY:
1510 case FilterOperation::BRIGHTNESS:
1511 case FilterOperation::CONTRAST: {
1513 if (!decoder.decode(amount))
1515 filter = BasicComponentTransferFilterOperation::create(amount, type);
1518 case FilterOperation::BLUR: {
1519 Length stdDeviation;
1520 if (!decoder.decode(stdDeviation))
1522 filter = BlurFilterOperation::create(stdDeviation, type);
1525 case FilterOperation::DROP_SHADOW: {
1529 if (!decoder.decode(location))
1531 if (!decoder.decode(stdDeviation))
1533 if (!decoder.decode(color))
1535 filter = DropShadowFilterOperation::create(location, stdDeviation, color, type);
1538 #if ENABLE(CSS_SHADERS)
1539 case FilterOperation::CUSTOM:
1540 case FilterOperation::VALIDATED_CUSTOM:
1541 ASSERT_NOT_REACHED();
1544 case FilterOperation::PASSTHROUGH:
1545 case FilterOperation::NONE:
1553 void ArgumentCoder<FilterOperations>::encode(ArgumentEncoder& encoder, const FilterOperations& filters)
1555 encoder << static_cast<uint64_t>(filters.size());
1557 for (const auto& filter : filters.operations())
1558 encodeFilterOperation(encoder, *filter);
1561 bool ArgumentCoder<FilterOperations>::decode(ArgumentDecoder& decoder, FilterOperations& filters)
1563 uint64_t filterCount;
1564 if (!decoder.decode(filterCount))
1567 for (uint64_t i = 0; i < filterCount; ++i) {
1568 RefPtr<FilterOperation> filter;
1569 if (!decodeFilterOperation(decoder, filter))
1571 filters.operations().append(std::move(filter));
1576 #endif // ENABLE(CSS_FILTERS) && !USE(COORDINATED_GRAPHICS)
1578 #if ENABLE(INDEXED_DATABASE)
1579 void ArgumentCoder<IDBDatabaseMetadata>::encode(ArgumentEncoder& encoder, const IDBDatabaseMetadata& metadata)
1581 encoder << metadata.name << metadata.id << metadata.version << metadata.maxObjectStoreId << metadata.objectStores;
1584 bool ArgumentCoder<IDBDatabaseMetadata>::decode(ArgumentDecoder& decoder, IDBDatabaseMetadata& metadata)
1586 if (!decoder.decode(metadata.name))
1589 if (!decoder.decode(metadata.id))
1592 if (!decoder.decode(metadata.version))
1595 if (!decoder.decode(metadata.maxObjectStoreId))
1598 if (!decoder.decode(metadata.objectStores))
1604 void ArgumentCoder<IDBIndexMetadata>::encode(ArgumentEncoder& encoder, const IDBIndexMetadata& metadata)
1606 encoder << metadata.name << metadata.id << metadata.keyPath << metadata.unique << metadata.multiEntry;
1609 bool ArgumentCoder<IDBIndexMetadata>::decode(ArgumentDecoder& decoder, IDBIndexMetadata& metadata)
1611 if (!decoder.decode(metadata.name))
1614 if (!decoder.decode(metadata.id))
1617 if (!decoder.decode(metadata.keyPath))
1620 if (!decoder.decode(metadata.unique))
1623 if (!decoder.decode(metadata.multiEntry))
1629 void ArgumentCoder<IDBGetResult>::encode(ArgumentEncoder& encoder, const IDBGetResult& result)
1631 bool nullData = !result.valueBuffer;
1632 encoder << nullData;
1635 encoder << DataReference(reinterpret_cast<const uint8_t*>(result.valueBuffer->data()), result.valueBuffer->size());
1637 encoder << result.keyData << result.keyPath;
1640 bool ArgumentCoder<IDBGetResult>::decode(ArgumentDecoder& decoder, IDBGetResult& result)
1643 if (!decoder.decode(nullData))
1647 result.valueBuffer = nullptr;
1650 if (!decoder.decode(data))
1653 result.valueBuffer = SharedBuffer::create(data.data(), data.size());
1656 if (!decoder.decode(result.keyData))
1659 if (!decoder.decode(result.keyPath))
1665 void ArgumentCoder<IDBKeyData>::encode(ArgumentEncoder& encoder, const IDBKeyData& keyData)
1667 encoder << keyData.isNull;
1671 encoder.encodeEnum(keyData.type);
1673 switch (keyData.type) {
1674 case IDBKey::InvalidType:
1676 case IDBKey::ArrayType:
1677 encoder << keyData.arrayValue;
1679 case IDBKey::StringType:
1680 encoder << keyData.stringValue;
1682 case IDBKey::DateType:
1683 case IDBKey::NumberType:
1684 encoder << keyData.numberValue;
1686 case IDBKey::MinType:
1687 ASSERT_NOT_REACHED();
1692 bool ArgumentCoder<IDBKeyData>::decode(ArgumentDecoder& decoder, IDBKeyData& keyData)
1694 if (!decoder.decode(keyData.isNull))
1700 if (!decoder.decodeEnum(keyData.type))
1703 switch (keyData.type) {
1704 case IDBKey::InvalidType:
1706 case IDBKey::ArrayType:
1707 if (!decoder.decode(keyData.arrayValue))
1710 case IDBKey::StringType:
1711 if (!decoder.decode(keyData.stringValue))
1714 case IDBKey::DateType:
1715 case IDBKey::NumberType:
1716 if (!decoder.decode(keyData.numberValue))
1719 case IDBKey::MinType:
1720 ASSERT_NOT_REACHED();
1727 void ArgumentCoder<IDBKeyPath>::encode(ArgumentEncoder& encoder, const IDBKeyPath& keyPath)
1729 encoder.encodeEnum(keyPath.type());
1731 switch (keyPath.type()) {
1732 case IDBKeyPath::NullType:
1734 case IDBKeyPath::StringType:
1735 encoder << keyPath.string();
1737 case IDBKeyPath::ArrayType:
1738 encoder << keyPath.array();
1741 ASSERT_NOT_REACHED();
1745 bool ArgumentCoder<IDBKeyPath>::decode(ArgumentDecoder& decoder, IDBKeyPath& keyPath)
1747 IDBKeyPath::Type type;
1748 if (!decoder.decodeEnum(type))
1752 case IDBKeyPath::NullType:
1753 keyPath = IDBKeyPath();
1756 case IDBKeyPath::StringType: {
1758 if (!decoder.decode(string))
1761 keyPath = IDBKeyPath(string);
1764 case IDBKeyPath::ArrayType: {
1765 Vector<String> array;
1766 if (!decoder.decode(array))
1769 keyPath = IDBKeyPath(array);
1777 void ArgumentCoder<IDBKeyRangeData>::encode(ArgumentEncoder& encoder, const IDBKeyRangeData& keyRange)
1779 encoder << keyRange.isNull;
1780 if (keyRange.isNull)
1783 encoder << keyRange.upperKey << keyRange.lowerKey << keyRange.upperOpen << keyRange.lowerOpen;
1786 bool ArgumentCoder<IDBKeyRangeData>::decode(ArgumentDecoder& decoder, IDBKeyRangeData& keyRange)
1788 if (!decoder.decode(keyRange.isNull))
1791 if (keyRange.isNull)
1794 if (!decoder.decode(keyRange.upperKey))
1797 if (!decoder.decode(keyRange.lowerKey))
1800 if (!decoder.decode(keyRange.upperOpen))
1803 if (!decoder.decode(keyRange.lowerOpen))
1809 void ArgumentCoder<IDBObjectStoreMetadata>::encode(ArgumentEncoder& encoder, const IDBObjectStoreMetadata& metadata)
1811 encoder << metadata.name << metadata.id << metadata.keyPath << metadata.autoIncrement << metadata.maxIndexId << metadata.indexes;
1814 bool ArgumentCoder<IDBObjectStoreMetadata>::decode(ArgumentDecoder& decoder, IDBObjectStoreMetadata& metadata)
1816 if (!decoder.decode(metadata.name))
1819 if (!decoder.decode(metadata.id))
1822 if (!decoder.decode(metadata.keyPath))
1825 if (!decoder.decode(metadata.autoIncrement))
1828 if (!decoder.decode(metadata.maxIndexId))
1831 if (!decoder.decode(metadata.indexes))