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/Editor.h>
39 #include <WebCore/FileChooser.h>
40 #include <WebCore/FilterOperation.h>
41 #include <WebCore/FilterOperations.h>
42 #include <WebCore/GraphicsContext.h>
43 #include <WebCore/GraphicsLayer.h>
44 #include <WebCore/IDBDatabaseMetadata.h>
45 #include <WebCore/IDBGetResult.h>
46 #include <WebCore/IDBKeyData.h>
47 #include <WebCore/IDBKeyPath.h>
48 #include <WebCore/IDBKeyRangeData.h>
49 #include <WebCore/Image.h>
50 #include <WebCore/Length.h>
51 #include <WebCore/PluginData.h>
52 #include <WebCore/ProtectionSpace.h>
53 #include <WebCore/Region.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/SessionID.h>
60 #include <WebCore/TextCheckerClient.h>
61 #include <WebCore/TimingFunction.h>
62 #include <WebCore/TransformationMatrix.h>
63 #include <WebCore/URL.h>
64 #include <WebCore/UserScript.h>
65 #include <WebCore/UserStyleSheet.h>
66 #include <WebCore/ViewportArguments.h>
67 #include <WebCore/WindowFeatures.h>
68 #include <wtf/text/CString.h>
69 #include <wtf/text/StringHash.h>
72 #include <WebCore/FloatQuad.h>
73 #include <WebCore/Pasteboard.h>
74 #include <WebCore/SelectionRect.h>
75 #include <WebCore/SharedBuffer.h>
76 #endif // PLATFORM(IOS)
78 using namespace WebCore;
79 using namespace WebKit;
83 void ArgumentCoder<AffineTransform>::encode(ArgumentEncoder& encoder, const AffineTransform& affineTransform)
85 SimpleArgumentCoder<AffineTransform>::encode(encoder, affineTransform);
88 bool ArgumentCoder<AffineTransform>::decode(ArgumentDecoder& decoder, AffineTransform& affineTransform)
90 return SimpleArgumentCoder<AffineTransform>::decode(decoder, affineTransform);
93 void ArgumentCoder<TransformationMatrix>::encode(ArgumentEncoder& encoder, const TransformationMatrix& transformationMatrix)
95 SimpleArgumentCoder<TransformationMatrix>::encode(encoder, transformationMatrix);
98 bool ArgumentCoder<TransformationMatrix>::decode(ArgumentDecoder& decoder, TransformationMatrix& transformationMatrix)
100 return SimpleArgumentCoder<TransformationMatrix>::decode(decoder, transformationMatrix);
103 void ArgumentCoder<LinearTimingFunction>::encode(ArgumentEncoder& encoder, const LinearTimingFunction& timingFunction)
105 encoder.encodeEnum(timingFunction.type());
108 bool ArgumentCoder<LinearTimingFunction>::decode(ArgumentDecoder&, LinearTimingFunction&)
110 // Type is decoded by the caller. Nothing else to decode.
114 void ArgumentCoder<CubicBezierTimingFunction>::encode(ArgumentEncoder& encoder, const CubicBezierTimingFunction& timingFunction)
116 encoder.encodeEnum(timingFunction.type());
118 encoder << timingFunction.x1();
119 encoder << timingFunction.y1();
120 encoder << timingFunction.x2();
121 encoder << timingFunction.y2();
123 encoder.encodeEnum(timingFunction.timingFunctionPreset());
126 bool ArgumentCoder<CubicBezierTimingFunction>::decode(ArgumentDecoder& decoder, CubicBezierTimingFunction& timingFunction)
128 // Type is decoded by the caller.
130 if (!decoder.decode(x1))
134 if (!decoder.decode(y1))
138 if (!decoder.decode(x2))
142 if (!decoder.decode(y2))
145 CubicBezierTimingFunction::TimingFunctionPreset preset;
146 if (!decoder.decodeEnum(preset))
149 timingFunction.setValues(x1, y1, x2, y2);
150 timingFunction.setTimingFunctionPreset(preset);
155 void ArgumentCoder<StepsTimingFunction>::encode(ArgumentEncoder& encoder, const StepsTimingFunction& timingFunction)
157 encoder.encodeEnum(timingFunction.type());
159 encoder << timingFunction.numberOfSteps();
160 encoder << timingFunction.stepAtStart();
163 bool ArgumentCoder<StepsTimingFunction>::decode(ArgumentDecoder& decoder, StepsTimingFunction& timingFunction)
165 // Type is decoded by the caller.
167 if (!decoder.decode(numSteps))
171 if (!decoder.decode(stepAtStart))
174 timingFunction.setNumberOfSteps(numSteps);
175 timingFunction.setStepAtStart(stepAtStart);
180 void ArgumentCoder<FloatPoint>::encode(ArgumentEncoder& encoder, const FloatPoint& floatPoint)
182 SimpleArgumentCoder<FloatPoint>::encode(encoder, floatPoint);
185 bool ArgumentCoder<FloatPoint>::decode(ArgumentDecoder& decoder, FloatPoint& floatPoint)
187 return SimpleArgumentCoder<FloatPoint>::decode(decoder, floatPoint);
191 void ArgumentCoder<FloatPoint3D>::encode(ArgumentEncoder& encoder, const FloatPoint3D& floatPoint)
193 SimpleArgumentCoder<FloatPoint3D>::encode(encoder, floatPoint);
196 bool ArgumentCoder<FloatPoint3D>::decode(ArgumentDecoder& decoder, FloatPoint3D& floatPoint)
198 return SimpleArgumentCoder<FloatPoint3D>::decode(decoder, floatPoint);
202 void ArgumentCoder<FloatRect>::encode(ArgumentEncoder& encoder, const FloatRect& floatRect)
204 SimpleArgumentCoder<FloatRect>::encode(encoder, floatRect);
207 bool ArgumentCoder<FloatRect>::decode(ArgumentDecoder& decoder, FloatRect& floatRect)
209 return SimpleArgumentCoder<FloatRect>::decode(decoder, floatRect);
213 void ArgumentCoder<FloatSize>::encode(ArgumentEncoder& encoder, const FloatSize& floatSize)
215 SimpleArgumentCoder<FloatSize>::encode(encoder, floatSize);
218 bool ArgumentCoder<FloatSize>::decode(ArgumentDecoder& decoder, FloatSize& floatSize)
220 return SimpleArgumentCoder<FloatSize>::decode(decoder, floatSize);
225 void ArgumentCoder<FloatQuad>::encode(ArgumentEncoder& encoder, const FloatQuad& floatQuad)
227 SimpleArgumentCoder<FloatQuad>::encode(encoder, floatQuad);
230 bool ArgumentCoder<FloatQuad>::decode(ArgumentDecoder& decoder, FloatQuad& floatQuad)
232 return SimpleArgumentCoder<FloatQuad>::decode(decoder, floatQuad);
235 void ArgumentCoder<ViewportArguments>::encode(ArgumentEncoder& encoder, const ViewportArguments& viewportArguments)
237 SimpleArgumentCoder<ViewportArguments>::encode(encoder, viewportArguments);
240 bool ArgumentCoder<ViewportArguments>::decode(ArgumentDecoder& decoder, ViewportArguments& viewportArguments)
242 return SimpleArgumentCoder<ViewportArguments>::decode(decoder, viewportArguments);
244 #endif // PLATFORM(IOS)
247 void ArgumentCoder<IntPoint>::encode(ArgumentEncoder& encoder, const IntPoint& intPoint)
249 SimpleArgumentCoder<IntPoint>::encode(encoder, intPoint);
252 bool ArgumentCoder<IntPoint>::decode(ArgumentDecoder& decoder, IntPoint& intPoint)
254 return SimpleArgumentCoder<IntPoint>::decode(decoder, intPoint);
258 void ArgumentCoder<IntRect>::encode(ArgumentEncoder& encoder, const IntRect& intRect)
260 SimpleArgumentCoder<IntRect>::encode(encoder, intRect);
263 bool ArgumentCoder<IntRect>::decode(ArgumentDecoder& decoder, IntRect& intRect)
265 return SimpleArgumentCoder<IntRect>::decode(decoder, intRect);
269 void ArgumentCoder<IntSize>::encode(ArgumentEncoder& encoder, const IntSize& intSize)
271 SimpleArgumentCoder<IntSize>::encode(encoder, intSize);
274 bool ArgumentCoder<IntSize>::decode(ArgumentDecoder& decoder, IntSize& intSize)
276 return SimpleArgumentCoder<IntSize>::decode(decoder, intSize);
279 template<> struct ArgumentCoder<Region::Span> {
280 static void encode(ArgumentEncoder&, const Region::Span&);
281 static bool decode(ArgumentDecoder&, Region::Span&);
284 void ArgumentCoder<Region::Span>::encode(ArgumentEncoder& encoder, const Region::Span& span)
287 encoder << (uint64_t)span.segmentIndex;
290 bool ArgumentCoder<Region::Span>::decode(ArgumentDecoder& decoder, Region::Span& span)
292 if (!decoder.decode(span.y))
295 uint64_t segmentIndex;
296 if (!decoder.decode(segmentIndex))
299 span.segmentIndex = segmentIndex;
303 void ArgumentCoder<Region>::encode(ArgumentEncoder& encoder, const Region& region)
305 encoder.encode(region.shapeSegments());
306 encoder.encode(region.shapeSpans());
309 bool ArgumentCoder<Region>::decode(ArgumentDecoder& decoder, Region& region)
311 Vector<int> segments;
312 if (!decoder.decode(segments))
315 Vector<Region::Span> spans;
316 if (!decoder.decode(spans))
319 region.setShapeSegments(segments);
320 region.setShapeSpans(spans);
321 region.updateBoundsFromShape();
323 if (!region.isValid())
329 void ArgumentCoder<Length>::encode(ArgumentEncoder& encoder, const Length& length)
331 SimpleArgumentCoder<Length>::encode(encoder, length);
334 bool ArgumentCoder<Length>::decode(ArgumentDecoder& decoder, Length& length)
336 return SimpleArgumentCoder<Length>::decode(decoder, length);
340 void ArgumentCoder<ViewportAttributes>::encode(ArgumentEncoder& encoder, const ViewportAttributes& viewportAttributes)
342 SimpleArgumentCoder<ViewportAttributes>::encode(encoder, viewportAttributes);
345 bool ArgumentCoder<ViewportAttributes>::decode(ArgumentDecoder& decoder, ViewportAttributes& viewportAttributes)
347 return SimpleArgumentCoder<ViewportAttributes>::decode(decoder, viewportAttributes);
351 void ArgumentCoder<MimeClassInfo>::encode(ArgumentEncoder& encoder, const MimeClassInfo& mimeClassInfo)
353 encoder << mimeClassInfo.type << mimeClassInfo.desc << mimeClassInfo.extensions;
356 bool ArgumentCoder<MimeClassInfo>::decode(ArgumentDecoder& decoder, MimeClassInfo& mimeClassInfo)
358 if (!decoder.decode(mimeClassInfo.type))
360 if (!decoder.decode(mimeClassInfo.desc))
362 if (!decoder.decode(mimeClassInfo.extensions))
369 void ArgumentCoder<PluginInfo>::encode(ArgumentEncoder& encoder, const PluginInfo& pluginInfo)
371 encoder << pluginInfo.name << pluginInfo.file << pluginInfo.desc << pluginInfo.mimes << pluginInfo.isApplicationPlugin;
374 bool ArgumentCoder<PluginInfo>::decode(ArgumentDecoder& decoder, PluginInfo& pluginInfo)
376 if (!decoder.decode(pluginInfo.name))
378 if (!decoder.decode(pluginInfo.file))
380 if (!decoder.decode(pluginInfo.desc))
382 if (!decoder.decode(pluginInfo.mimes))
384 if (!decoder.decode(pluginInfo.isApplicationPlugin))
391 void ArgumentCoder<HTTPHeaderMap>::encode(ArgumentEncoder& encoder, const HTTPHeaderMap& headerMap)
393 encoder << static_cast<const HashMap<AtomicString, String, CaseFoldingHash>&>(headerMap);
396 bool ArgumentCoder<HTTPHeaderMap>::decode(ArgumentDecoder& decoder, HTTPHeaderMap& headerMap)
398 return decoder.decode(static_cast<HashMap<AtomicString, String, CaseFoldingHash>&>(headerMap));
402 void ArgumentCoder<AuthenticationChallenge>::encode(ArgumentEncoder& encoder, const AuthenticationChallenge& challenge)
404 encoder << challenge.protectionSpace() << challenge.proposedCredential() << challenge.previousFailureCount() << challenge.failureResponse() << challenge.error();
407 bool ArgumentCoder<AuthenticationChallenge>::decode(ArgumentDecoder& decoder, AuthenticationChallenge& challenge)
409 ProtectionSpace protectionSpace;
410 if (!decoder.decode(protectionSpace))
413 Credential proposedCredential;
414 if (!decoder.decode(proposedCredential))
417 unsigned previousFailureCount;
418 if (!decoder.decode(previousFailureCount))
421 ResourceResponse failureResponse;
422 if (!decoder.decode(failureResponse))
426 if (!decoder.decode(error))
429 challenge = AuthenticationChallenge(protectionSpace, proposedCredential, previousFailureCount, failureResponse, error);
434 void ArgumentCoder<ProtectionSpace>::encode(ArgumentEncoder& encoder, const ProtectionSpace& space)
436 encoder << space.host() << space.port() << space.realm();
437 encoder.encodeEnum(space.authenticationScheme());
438 encoder.encodeEnum(space.serverType());
441 bool ArgumentCoder<ProtectionSpace>::decode(ArgumentDecoder& decoder, ProtectionSpace& space)
444 if (!decoder.decode(host))
448 if (!decoder.decode(port))
452 if (!decoder.decode(realm))
455 ProtectionSpaceAuthenticationScheme authenticationScheme;
456 if (!decoder.decodeEnum(authenticationScheme))
459 ProtectionSpaceServerType serverType;
460 if (!decoder.decodeEnum(serverType))
463 space = ProtectionSpace(host, port, serverType, realm, authenticationScheme);
467 void ArgumentCoder<Credential>::encode(ArgumentEncoder& encoder, const Credential& credential)
469 encoder << credential.user() << credential.password();
470 encoder.encodeEnum(credential.persistence());
473 bool ArgumentCoder<Credential>::decode(ArgumentDecoder& decoder, Credential& credential)
476 if (!decoder.decode(user))
480 if (!decoder.decode(password))
483 CredentialPersistence persistence;
484 if (!decoder.decodeEnum(persistence))
487 credential = Credential(user, password, persistence);
491 static void encodeImage(ArgumentEncoder& encoder, Image* image)
493 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(IntSize(image->size()), ShareableBitmap::SupportsAlpha);
494 bitmap->createGraphicsContext()->drawImage(image, ColorSpaceDeviceRGB, IntPoint());
496 ShareableBitmap::Handle handle;
497 bitmap->createHandle(handle);
502 static bool decodeImage(ArgumentDecoder& decoder, RefPtr<Image>& image)
504 ShareableBitmap::Handle handle;
505 if (!decoder.decode(handle))
508 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(handle);
511 image = bitmap->createImage();
518 void ArgumentCoder<Cursor>::encode(ArgumentEncoder& encoder, const Cursor& cursor)
520 encoder.encodeEnum(cursor.type());
522 if (cursor.type() != Cursor::Custom)
525 if (cursor.image()->isNull()) {
526 encoder << false; // There is no valid image being encoded.
531 encodeImage(encoder, cursor.image());
532 encoder << cursor.hotSpot();
535 bool ArgumentCoder<Cursor>::decode(ArgumentDecoder& decoder, Cursor& cursor)
538 if (!decoder.decodeEnum(type))
541 if (type > Cursor::Custom)
544 if (type != Cursor::Custom) {
545 const Cursor& cursorReference = Cursor::fromType(type);
546 // Calling platformCursor here will eagerly create the platform cursor for the cursor singletons inside WebCore.
547 // This will avoid having to re-create the platform cursors over and over.
548 (void)cursorReference.platformCursor();
550 cursor = cursorReference;
554 bool isValidImagePresent;
555 if (!decoder.decode(isValidImagePresent))
558 if (!isValidImagePresent) {
559 cursor = Cursor(Image::nullImage(), IntPoint());
564 if (!decodeImage(decoder, image))
568 if (!decoder.decode(hotSpot))
571 if (!image->rect().contains(hotSpot))
574 cursor = Cursor(image.get(), hotSpot);
579 void ArgumentCoder<ResourceRequest>::encode(ArgumentEncoder& encoder, const ResourceRequest& resourceRequest)
581 if (kShouldSerializeWebCoreData) {
582 encoder << resourceRequest.url().string();
583 encoder << resourceRequest.httpMethod();
584 encoder << resourceRequest.httpHeaderFields();
586 // FIXME: Do not encode HTTP message body.
587 // 1. It can be large and thus costly to send across.
588 // 2. It is misleading to provide a body with some requests, while others use body streams, which cannot be serialized at all.
589 FormData* httpBody = resourceRequest.httpBody();
590 encoder << static_cast<bool>(httpBody);
592 encoder << httpBody->flattenToString();
594 encoder << resourceRequest.firstPartyForCookies().string();
597 #if ENABLE(CACHE_PARTITIONING)
598 encoder << resourceRequest.cachePartition();
601 #if ENABLE(INSPECTOR)
602 encoder << resourceRequest.hiddenFromInspector();
605 encodePlatformData(encoder, resourceRequest);
608 bool ArgumentCoder<ResourceRequest>::decode(ArgumentDecoder& decoder, ResourceRequest& resourceRequest)
610 if (kShouldSerializeWebCoreData) {
611 ResourceRequest request;
614 if (!decoder.decode(url))
616 request.setURL(URL(URL(), url));
619 if (!decoder.decode(httpMethod))
621 request.setHTTPMethod(httpMethod);
623 HTTPHeaderMap headers;
624 if (!decoder.decode(headers))
626 request.addHTTPHeaderFields(headers);
629 if (!decoder.decode(hasHTTPBody))
633 if (!decoder.decode(httpBody))
635 request.setHTTPBody(FormData::create(httpBody.utf8()));
638 String firstPartyForCookies;
639 if (!decoder.decode(firstPartyForCookies))
641 request.setFirstPartyForCookies(URL(URL(), firstPartyForCookies));
643 resourceRequest = request;
646 #if ENABLE(CACHE_PARTITIONING)
647 String cachePartition;
648 if (!decoder.decode(cachePartition))
650 resourceRequest.setCachePartition(cachePartition);
653 #if ENABLE(INSPECTOR)
654 bool isHiddenFromInspector;
655 if (!decoder.decode(isHiddenFromInspector))
657 resourceRequest.setHiddenFromInspector(isHiddenFromInspector);
660 return decodePlatformData(decoder, resourceRequest);
663 void ArgumentCoder<ResourceResponse>::encode(ArgumentEncoder& encoder, const ResourceResponse& resourceResponse)
666 bool shouldSerializeWebCoreData = !resourceResponse.platformResponseIsUpToDate();
667 encoder << shouldSerializeWebCoreData;
669 bool shouldSerializeWebCoreData = true;
672 encodePlatformData(encoder, resourceResponse);
674 if (shouldSerializeWebCoreData) {
675 bool responseIsNull = resourceResponse.isNull();
676 encoder << responseIsNull;
680 encoder << resourceResponse.url().string();
681 encoder << static_cast<int32_t>(resourceResponse.httpStatusCode());
682 encoder << resourceResponse.httpHeaderFields();
684 encoder << resourceResponse.mimeType();
685 encoder << resourceResponse.textEncodingName();
686 encoder << static_cast<int64_t>(resourceResponse.expectedContentLength());
687 encoder << resourceResponse.httpStatusText();
688 encoder << resourceResponse.suggestedFilename();
692 bool ArgumentCoder<ResourceResponse>::decode(ArgumentDecoder& decoder, ResourceResponse& resourceResponse)
695 bool hasSerializedWebCoreData;
696 if (!decoder.decode(hasSerializedWebCoreData))
699 bool hasSerializedWebCoreData = true;
702 ResourceResponse response;
704 if (!decodePlatformData(decoder, response))
707 if (hasSerializedWebCoreData) {
709 if (!decoder.decode(responseIsNull))
711 if (responseIsNull) {
712 resourceResponse = ResourceResponse();
717 if (!decoder.decode(url))
719 response.setURL(URL(URL(), url));
721 int32_t httpStatusCode;
722 if (!decoder.decode(httpStatusCode))
724 response.setHTTPStatusCode(httpStatusCode);
726 HTTPHeaderMap headers;
727 if (!decoder.decode(headers))
729 for (HTTPHeaderMap::const_iterator it = headers.begin(), end = headers.end(); it != end; ++it)
730 response.setHTTPHeaderField(it->key, it->value);
733 if (!decoder.decode(mimeType))
735 response.setMimeType(mimeType);
737 String textEncodingName;
738 if (!decoder.decode(textEncodingName))
740 response.setTextEncodingName(textEncodingName);
742 int64_t contentLength;
743 if (!decoder.decode(contentLength))
745 response.setExpectedContentLength(contentLength);
747 String httpStatusText;
748 if (!decoder.decode(httpStatusText))
750 response.setHTTPStatusText(httpStatusText);
752 String suggestedFilename;
753 if (!decoder.decode(suggestedFilename))
755 response.setSuggestedFilename(suggestedFilename);
758 resourceResponse = response;
763 void ArgumentCoder<ResourceError>::encode(ArgumentEncoder& encoder, const ResourceError& resourceError)
765 if (kShouldSerializeWebCoreData) {
766 bool errorIsNull = resourceError.isNull();
767 encoder << errorIsNull;
771 encoder << resourceError.domain();
772 encoder << resourceError.errorCode();
773 encoder << resourceError.failingURL();
774 encoder << resourceError.localizedDescription();
775 encoder << resourceError.isCancellation();
776 encoder << resourceError.isTimeout();
779 encodePlatformData(encoder, resourceError);
782 bool ArgumentCoder<ResourceError>::decode(ArgumentDecoder& decoder, ResourceError& resourceError)
784 if (kShouldSerializeWebCoreData) {
786 if (!decoder.decode(errorIsNull))
789 resourceError = ResourceError();
794 if (!decoder.decode(domain))
798 if (!decoder.decode(errorCode))
802 if (!decoder.decode(failingURL))
805 String localizedDescription;
806 if (!decoder.decode(localizedDescription))
810 if (!decoder.decode(isCancellation))
814 if (!decoder.decode(isTimeout))
817 resourceError = ResourceError(domain, errorCode, failingURL, localizedDescription);
818 resourceError.setIsCancellation(isCancellation);
819 resourceError.setIsTimeout(isTimeout);
822 return decodePlatformData(decoder, resourceError);
827 void ArgumentCoder<SelectionRect>::encode(ArgumentEncoder& encoder, const SelectionRect& selectionRect)
829 encoder << selectionRect.rect();
830 encoder << static_cast<uint32_t>(selectionRect.direction());
831 encoder << selectionRect.minX();
832 encoder << selectionRect.maxX();
833 encoder << selectionRect.maxY();
834 encoder << selectionRect.lineNumber();
835 encoder << selectionRect.isLineBreak();
836 encoder << selectionRect.isFirstOnLine();
837 encoder << selectionRect.isLastOnLine();
838 encoder << selectionRect.containsStart();
839 encoder << selectionRect.containsEnd();
840 encoder << selectionRect.isHorizontal();
843 bool ArgumentCoder<SelectionRect>::decode(ArgumentDecoder& decoder, SelectionRect& selectionRect)
846 if (!decoder.decode(rect))
848 selectionRect.setRect(rect);
851 if (!decoder.decode(direction))
853 selectionRect.setDirection((TextDirection)direction);
856 if (!decoder.decode(intValue))
858 selectionRect.setMinX(intValue);
860 if (!decoder.decode(intValue))
862 selectionRect.setMaxX(intValue);
864 if (!decoder.decode(intValue))
866 selectionRect.setMaxY(intValue);
868 if (!decoder.decode(intValue))
870 selectionRect.setLineNumber(intValue);
873 if (!decoder.decode(boolValue))
875 selectionRect.setIsLineBreak(boolValue);
877 if (!decoder.decode(boolValue))
879 selectionRect.setIsFirstOnLine(boolValue);
881 if (!decoder.decode(boolValue))
883 selectionRect.setIsLastOnLine(boolValue);
885 if (!decoder.decode(boolValue))
887 selectionRect.setContainsStart(boolValue);
889 if (!decoder.decode(boolValue))
891 selectionRect.setContainsEnd(boolValue);
893 if (!decoder.decode(boolValue))
895 selectionRect.setIsHorizontal(boolValue);
902 void ArgumentCoder<WindowFeatures>::encode(ArgumentEncoder& encoder, const WindowFeatures& windowFeatures)
904 encoder << windowFeatures.x;
905 encoder << windowFeatures.y;
906 encoder << windowFeatures.width;
907 encoder << windowFeatures.height;
908 encoder << windowFeatures.xSet;
909 encoder << windowFeatures.ySet;
910 encoder << windowFeatures.widthSet;
911 encoder << windowFeatures.heightSet;
912 encoder << windowFeatures.menuBarVisible;
913 encoder << windowFeatures.statusBarVisible;
914 encoder << windowFeatures.toolBarVisible;
915 encoder << windowFeatures.locationBarVisible;
916 encoder << windowFeatures.scrollbarsVisible;
917 encoder << windowFeatures.resizable;
918 encoder << windowFeatures.fullscreen;
919 encoder << windowFeatures.dialog;
922 bool ArgumentCoder<WindowFeatures>::decode(ArgumentDecoder& decoder, WindowFeatures& windowFeatures)
924 if (!decoder.decode(windowFeatures.x))
926 if (!decoder.decode(windowFeatures.y))
928 if (!decoder.decode(windowFeatures.width))
930 if (!decoder.decode(windowFeatures.height))
932 if (!decoder.decode(windowFeatures.xSet))
934 if (!decoder.decode(windowFeatures.ySet))
936 if (!decoder.decode(windowFeatures.widthSet))
938 if (!decoder.decode(windowFeatures.heightSet))
940 if (!decoder.decode(windowFeatures.menuBarVisible))
942 if (!decoder.decode(windowFeatures.statusBarVisible))
944 if (!decoder.decode(windowFeatures.toolBarVisible))
946 if (!decoder.decode(windowFeatures.locationBarVisible))
948 if (!decoder.decode(windowFeatures.scrollbarsVisible))
950 if (!decoder.decode(windowFeatures.resizable))
952 if (!decoder.decode(windowFeatures.fullscreen))
954 if (!decoder.decode(windowFeatures.dialog))
960 void ArgumentCoder<Color>::encode(ArgumentEncoder& encoder, const Color& color)
962 if (!color.isValid()) {
968 encoder << color.rgb();
971 bool ArgumentCoder<Color>::decode(ArgumentDecoder& decoder, Color& color)
974 if (!decoder.decode(isValid))
983 if (!decoder.decode(rgba))
991 void ArgumentCoder<CompositionUnderline>::encode(ArgumentEncoder& encoder, const CompositionUnderline& underline)
993 encoder << underline.startOffset;
994 encoder << underline.endOffset;
995 encoder << underline.thick;
996 encoder << underline.color;
999 bool ArgumentCoder<CompositionUnderline>::decode(ArgumentDecoder& decoder, CompositionUnderline& underline)
1001 if (!decoder.decode(underline.startOffset))
1003 if (!decoder.decode(underline.endOffset))
1005 if (!decoder.decode(underline.thick))
1007 if (!decoder.decode(underline.color))
1014 void ArgumentCoder<Cookie>::encode(ArgumentEncoder& encoder, const Cookie& cookie)
1016 encoder << cookie.name;
1017 encoder << cookie.value;
1018 encoder << cookie.domain;
1019 encoder << cookie.path;
1020 encoder << cookie.expires;
1021 encoder << cookie.httpOnly;
1022 encoder << cookie.secure;
1023 encoder << cookie.session;
1026 bool ArgumentCoder<Cookie>::decode(ArgumentDecoder& decoder, Cookie& cookie)
1028 if (!decoder.decode(cookie.name))
1030 if (!decoder.decode(cookie.value))
1032 if (!decoder.decode(cookie.domain))
1034 if (!decoder.decode(cookie.path))
1036 if (!decoder.decode(cookie.expires))
1038 if (!decoder.decode(cookie.httpOnly))
1040 if (!decoder.decode(cookie.secure))
1042 if (!decoder.decode(cookie.session))
1049 #if ENABLE(SQL_DATABASE)
1050 void ArgumentCoder<DatabaseDetails>::encode(ArgumentEncoder& encoder, const DatabaseDetails& details)
1052 encoder << details.name();
1053 encoder << details.displayName();
1054 encoder << details.expectedUsage();
1055 encoder << details.currentUsage();
1056 encoder << details.creationTime();
1057 encoder << details.modificationTime();
1060 bool ArgumentCoder<DatabaseDetails>::decode(ArgumentDecoder& decoder, DatabaseDetails& details)
1063 if (!decoder.decode(name))
1067 if (!decoder.decode(displayName))
1070 uint64_t expectedUsage;
1071 if (!decoder.decode(expectedUsage))
1074 uint64_t currentUsage;
1075 if (!decoder.decode(currentUsage))
1078 double creationTime;
1079 if (!decoder.decode(creationTime))
1082 double modificationTime;
1083 if (!decoder.decode(modificationTime))
1086 details = DatabaseDetails(name, displayName, expectedUsage, currentUsage, creationTime, modificationTime);
1094 static void encodeSharedBuffer(ArgumentEncoder& encoder, SharedBuffer* buffer)
1096 SharedMemory::Handle handle;
1097 encoder << (buffer ? static_cast<uint64_t>(buffer->size()): 0);
1099 RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::create(buffer->size());
1100 memcpy(sharedMemoryBuffer->data(), buffer->data(), buffer->size());
1101 sharedMemoryBuffer->createHandle(handle, SharedMemory::ReadOnly);
1106 static bool decodeSharedBuffer(ArgumentDecoder& decoder, RefPtr<SharedBuffer>& buffer)
1108 uint64_t bufferSize = 0;
1109 if (!decoder.decode(bufferSize))
1113 SharedMemory::Handle handle;
1114 if (!decoder.decode(handle))
1117 RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::create(handle, SharedMemory::ReadOnly);
1118 buffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryBuffer->data()), bufferSize);
1124 void ArgumentCoder<PasteboardWebContent>::encode(ArgumentEncoder& encoder, const PasteboardWebContent& content)
1126 encoder << content.canSmartCopyOrDelete;
1127 encoder << content.dataInStringFormat;
1129 encodeSharedBuffer(encoder, content.dataInWebArchiveFormat.get());
1130 encodeSharedBuffer(encoder, content.dataInRTFDFormat.get());
1131 encodeSharedBuffer(encoder, content.dataInRTFFormat.get());
1133 encoder << content.clientTypes;
1134 encoder << static_cast<uint64_t>(content.clientData.size());
1135 for (size_t i = 0; i < content.clientData.size(); i++)
1136 encodeSharedBuffer(encoder, content.clientData[i].get());
1139 bool ArgumentCoder<PasteboardWebContent>::decode(ArgumentDecoder& decoder, PasteboardWebContent& content)
1141 if (!decoder.decode(content.canSmartCopyOrDelete))
1143 if (!decoder.decode(content.dataInStringFormat))
1145 if (!decodeSharedBuffer(decoder, content.dataInWebArchiveFormat))
1147 if (!decodeSharedBuffer(decoder, content.dataInRTFDFormat))
1149 if (!decodeSharedBuffer(decoder, content.dataInRTFFormat))
1151 if (!decoder.decode(content.clientTypes))
1153 uint64_t clientDataSize;
1154 if (!decoder.decode(clientDataSize))
1157 content.clientData.resize(clientDataSize);
1158 for (size_t i = 0; i < clientDataSize; i++)
1159 decodeSharedBuffer(decoder, content.clientData[i]);
1163 void ArgumentCoder<PasteboardImage>::encode(ArgumentEncoder& encoder, const PasteboardImage& pasteboardImage)
1165 encodeImage(encoder, pasteboardImage.image.get());
1166 encoder << pasteboardImage.url.url;
1167 encoder << pasteboardImage.url.title;
1168 encoder << pasteboardImage.resourceMIMEType;
1169 if (pasteboardImage.resourceData)
1170 encodeSharedBuffer(encoder, pasteboardImage.resourceData.get());
1173 bool ArgumentCoder<PasteboardImage>::decode(ArgumentDecoder& decoder, PasteboardImage& pasteboardImage)
1175 if (!decodeImage(decoder, pasteboardImage.image))
1177 if (!decoder.decode(pasteboardImage.url.url))
1179 if (!decoder.decode(pasteboardImage.url.title))
1181 if (!decoder.decode(pasteboardImage.resourceMIMEType))
1183 if (!decodeSharedBuffer(decoder, pasteboardImage.resourceData))
1190 void ArgumentCoder<DictationAlternative>::encode(ArgumentEncoder& encoder, const DictationAlternative& dictationAlternative)
1192 encoder << dictationAlternative.rangeStart;
1193 encoder << dictationAlternative.rangeLength;
1194 encoder << dictationAlternative.dictationContext;
1197 bool ArgumentCoder<DictationAlternative>::decode(ArgumentDecoder& decoder, DictationAlternative& dictationAlternative)
1199 if (!decoder.decode(dictationAlternative.rangeStart))
1201 if (!decoder.decode(dictationAlternative.rangeLength))
1203 if (!decoder.decode(dictationAlternative.dictationContext))
1209 void ArgumentCoder<FileChooserSettings>::encode(ArgumentEncoder& encoder, const FileChooserSettings& settings)
1211 encoder << settings.allowsMultipleFiles;
1212 encoder << settings.acceptMIMETypes;
1213 encoder << settings.selectedFiles;
1214 #if ENABLE(MEDIA_CAPTURE)
1215 encoder << settings.capture;
1219 bool ArgumentCoder<FileChooserSettings>::decode(ArgumentDecoder& decoder, FileChooserSettings& settings)
1221 if (!decoder.decode(settings.allowsMultipleFiles))
1223 if (!decoder.decode(settings.acceptMIMETypes))
1225 if (!decoder.decode(settings.selectedFiles))
1227 #if ENABLE(MEDIA_CAPTURE)
1228 if (!decoder.decode(settings.capture))
1236 void ArgumentCoder<GrammarDetail>::encode(ArgumentEncoder& encoder, const GrammarDetail& detail)
1238 encoder << detail.location;
1239 encoder << detail.length;
1240 encoder << detail.guesses;
1241 encoder << detail.userDescription;
1244 bool ArgumentCoder<GrammarDetail>::decode(ArgumentDecoder& decoder, GrammarDetail& detail)
1246 if (!decoder.decode(detail.location))
1248 if (!decoder.decode(detail.length))
1250 if (!decoder.decode(detail.guesses))
1252 if (!decoder.decode(detail.userDescription))
1258 void ArgumentCoder<TextCheckingRequestData>::encode(ArgumentEncoder& encoder, const TextCheckingRequestData& request)
1260 encoder << request.sequence();
1261 encoder << request.text();
1262 encoder << request.mask();
1263 encoder.encodeEnum(request.processType());
1266 bool ArgumentCoder<TextCheckingRequestData>::decode(ArgumentDecoder& decoder, TextCheckingRequestData& request)
1269 if (!decoder.decode(sequence))
1273 if (!decoder.decode(text))
1276 TextCheckingTypeMask mask;
1277 if (!decoder.decode(mask))
1280 TextCheckingProcessType processType;
1281 if (!decoder.decodeEnum(processType))
1284 request = TextCheckingRequestData(sequence, text, mask, processType);
1288 void ArgumentCoder<TextCheckingResult>::encode(ArgumentEncoder& encoder, const TextCheckingResult& result)
1290 encoder.encodeEnum(result.type);
1291 encoder << result.location;
1292 encoder << result.length;
1293 encoder << result.details;
1294 encoder << result.replacement;
1297 bool ArgumentCoder<TextCheckingResult>::decode(ArgumentDecoder& decoder, TextCheckingResult& result)
1299 if (!decoder.decodeEnum(result.type))
1301 if (!decoder.decode(result.location))
1303 if (!decoder.decode(result.length))
1305 if (!decoder.decode(result.details))
1307 if (!decoder.decode(result.replacement))
1312 void ArgumentCoder<URL>::encode(ArgumentEncoder& encoder, const URL& result)
1314 encoder << result.string();
1317 bool ArgumentCoder<URL>::decode(ArgumentDecoder& decoder, URL& result)
1320 if (!decoder.decode(urlAsString))
1322 result = URL(ParsedURLString, urlAsString);
1326 void ArgumentCoder<UserStyleSheet>::encode(ArgumentEncoder& encoder, const UserStyleSheet& userStyleSheet)
1328 encoder << userStyleSheet.source();
1329 encoder << userStyleSheet.url();
1330 encoder << userStyleSheet.whitelist();
1331 encoder << userStyleSheet.blacklist();
1332 encoder.encodeEnum(userStyleSheet.injectedFrames());
1333 encoder.encodeEnum(userStyleSheet.level());
1336 bool ArgumentCoder<UserStyleSheet>::decode(ArgumentDecoder& decoder, UserStyleSheet& userStyleSheet)
1339 if (!decoder.decode(source))
1343 if (!decoder.decode(url))
1346 Vector<String> whitelist;
1347 if (!decoder.decode(whitelist))
1350 Vector<String> blacklist;
1351 if (!decoder.decode(blacklist))
1354 UserContentInjectedFrames injectedFrames;
1355 if (!decoder.decodeEnum(injectedFrames))
1358 UserStyleLevel level;
1359 if (!decoder.decodeEnum(level))
1362 userStyleSheet = UserStyleSheet(source, url, whitelist, blacklist, injectedFrames, level);
1366 void ArgumentCoder<UserScript>::encode(ArgumentEncoder& encoder, const UserScript& userScript)
1368 encoder << userScript.source();
1369 encoder << userScript.url();
1370 encoder << userScript.whitelist();
1371 encoder << userScript.blacklist();
1372 encoder.encodeEnum(userScript.injectionTime());
1373 encoder.encodeEnum(userScript.injectedFrames());
1376 bool ArgumentCoder<UserScript>::decode(ArgumentDecoder& decoder, UserScript& userScript)
1379 if (!decoder.decode(source))
1383 if (!decoder.decode(url))
1386 Vector<String> whitelist;
1387 if (!decoder.decode(whitelist))
1390 Vector<String> blacklist;
1391 if (!decoder.decode(blacklist))
1394 UserScriptInjectionTime injectionTime;
1395 if (!decoder.decodeEnum(injectionTime))
1398 UserContentInjectedFrames injectedFrames;
1399 if (!decoder.decodeEnum(injectedFrames))
1402 userScript = UserScript(source, url, whitelist, blacklist, injectionTime, injectedFrames);
1406 void ArgumentCoder<ScrollableAreaParameters>::encode(ArgumentEncoder& encoder, const ScrollableAreaParameters& parameters)
1408 encoder.encodeEnum(parameters.horizontalScrollElasticity);
1409 encoder.encodeEnum(parameters.verticalScrollElasticity);
1411 encoder.encodeEnum(parameters.horizontalScrollbarMode);
1412 encoder.encodeEnum(parameters.verticalScrollbarMode);
1414 encoder << parameters.hasEnabledHorizontalScrollbar;
1415 encoder << parameters.hasEnabledVerticalScrollbar;
1418 bool ArgumentCoder<ScrollableAreaParameters>::decode(ArgumentDecoder& decoder, ScrollableAreaParameters& params)
1420 if (!decoder.decodeEnum(params.horizontalScrollElasticity))
1422 if (!decoder.decodeEnum(params.verticalScrollElasticity))
1425 if (!decoder.decodeEnum(params.horizontalScrollbarMode))
1427 if (!decoder.decodeEnum(params.verticalScrollbarMode))
1430 if (!decoder.decode(params.hasEnabledHorizontalScrollbar))
1432 if (!decoder.decode(params.hasEnabledVerticalScrollbar))
1438 void ArgumentCoder<FixedPositionViewportConstraints>::encode(ArgumentEncoder& encoder, const FixedPositionViewportConstraints& viewportConstraints)
1440 encoder << viewportConstraints.alignmentOffset();
1441 encoder << viewportConstraints.anchorEdges();
1443 encoder << viewportConstraints.viewportRectAtLastLayout();
1444 encoder << viewportConstraints.layerPositionAtLastLayout();
1447 bool ArgumentCoder<FixedPositionViewportConstraints>::decode(ArgumentDecoder& decoder, FixedPositionViewportConstraints& viewportConstraints)
1449 FloatSize alignmentOffset;
1450 if (!decoder.decode(alignmentOffset))
1453 ViewportConstraints::AnchorEdges anchorEdges;
1454 if (!decoder.decode(anchorEdges))
1457 FloatRect viewportRectAtLastLayout;
1458 if (!decoder.decode(viewportRectAtLastLayout))
1461 FloatPoint layerPositionAtLastLayout;
1462 if (!decoder.decode(layerPositionAtLastLayout))
1465 viewportConstraints = FixedPositionViewportConstraints();
1466 viewportConstraints.setAlignmentOffset(alignmentOffset);
1467 viewportConstraints.setAnchorEdges(anchorEdges);
1469 viewportConstraints.setViewportRectAtLastLayout(viewportRectAtLastLayout);
1470 viewportConstraints.setLayerPositionAtLastLayout(layerPositionAtLastLayout);
1475 void ArgumentCoder<StickyPositionViewportConstraints>::encode(ArgumentEncoder& encoder, const StickyPositionViewportConstraints& viewportConstraints)
1477 encoder << viewportConstraints.alignmentOffset();
1478 encoder << viewportConstraints.anchorEdges();
1480 encoder << viewportConstraints.leftOffset();
1481 encoder << viewportConstraints.rightOffset();
1482 encoder << viewportConstraints.topOffset();
1483 encoder << viewportConstraints.bottomOffset();
1485 encoder << viewportConstraints.constrainingRectAtLastLayout();
1486 encoder << viewportConstraints.containingBlockRect();
1487 encoder << viewportConstraints.stickyBoxRect();
1489 encoder << viewportConstraints.stickyOffsetAtLastLayout();
1490 encoder << viewportConstraints.layerPositionAtLastLayout();
1493 bool ArgumentCoder<StickyPositionViewportConstraints>::decode(ArgumentDecoder& decoder, StickyPositionViewportConstraints& viewportConstraints)
1495 FloatSize alignmentOffset;
1496 if (!decoder.decode(alignmentOffset))
1499 ViewportConstraints::AnchorEdges anchorEdges;
1500 if (!decoder.decode(anchorEdges))
1504 if (!decoder.decode(leftOffset))
1508 if (!decoder.decode(rightOffset))
1512 if (!decoder.decode(topOffset))
1516 if (!decoder.decode(bottomOffset))
1519 FloatRect constrainingRectAtLastLayout;
1520 if (!decoder.decode(constrainingRectAtLastLayout))
1523 FloatRect containingBlockRect;
1524 if (!decoder.decode(containingBlockRect))
1527 FloatRect stickyBoxRect;
1528 if (!decoder.decode(stickyBoxRect))
1531 FloatSize stickyOffsetAtLastLayout;
1532 if (!decoder.decode(stickyOffsetAtLastLayout))
1535 FloatPoint layerPositionAtLastLayout;
1536 if (!decoder.decode(layerPositionAtLastLayout))
1539 viewportConstraints = StickyPositionViewportConstraints();
1540 viewportConstraints.setAlignmentOffset(alignmentOffset);
1541 viewportConstraints.setAnchorEdges(anchorEdges);
1543 viewportConstraints.setLeftOffset(leftOffset);
1544 viewportConstraints.setRightOffset(rightOffset);
1545 viewportConstraints.setTopOffset(topOffset);
1546 viewportConstraints.setBottomOffset(bottomOffset);
1548 viewportConstraints.setConstrainingRectAtLastLayout(constrainingRectAtLastLayout);
1549 viewportConstraints.setContainingBlockRect(containingBlockRect);
1550 viewportConstraints.setStickyBoxRect(stickyBoxRect);
1552 viewportConstraints.setStickyOffsetAtLastLayout(stickyOffsetAtLastLayout);
1553 viewportConstraints.setLayerPositionAtLastLayout(layerPositionAtLastLayout);
1558 #if ENABLE(CSS_FILTERS) && !USE(COORDINATED_GRAPHICS)
1559 void ArgumentCoder<FilterOperation>::encode(ArgumentEncoder& encoder, const FilterOperation& filter)
1561 encoder.encodeEnum(filter.type());
1563 switch (filter.type()) {
1564 case FilterOperation::NONE:
1565 case FilterOperation::REFERENCE:
1566 ASSERT_NOT_REACHED();
1568 case FilterOperation::GRAYSCALE:
1569 case FilterOperation::SEPIA:
1570 case FilterOperation::SATURATE:
1571 case FilterOperation::HUE_ROTATE:
1572 encoder << toBasicColorMatrixFilterOperation(filter).amount();
1574 case FilterOperation::INVERT:
1575 case FilterOperation::OPACITY:
1576 case FilterOperation::BRIGHTNESS:
1577 case FilterOperation::CONTRAST:
1578 encoder << toBasicComponentTransferFilterOperation(filter).amount();
1580 case FilterOperation::BLUR:
1581 encoder << toBlurFilterOperation(filter).stdDeviation();
1583 case FilterOperation::DROP_SHADOW: {
1584 const auto& dropShadowFilter = toDropShadowFilterOperation(filter);
1585 encoder << dropShadowFilter.location();
1586 encoder << dropShadowFilter.stdDeviation();
1587 encoder << dropShadowFilter.color();
1590 case FilterOperation::DEFAULT:
1591 encoder.encodeEnum(toDefaultFilterOperation(filter).representedType());
1593 case FilterOperation::PASSTHROUGH:
1598 bool decodeFilterOperation(ArgumentDecoder& decoder, RefPtr<FilterOperation>& filter)
1600 FilterOperation::OperationType type;
1601 if (!decoder.decodeEnum(type))
1605 case FilterOperation::NONE:
1606 case FilterOperation::REFERENCE:
1607 ASSERT_NOT_REACHED();
1608 decoder.markInvalid();
1610 case FilterOperation::GRAYSCALE:
1611 case FilterOperation::SEPIA:
1612 case FilterOperation::SATURATE:
1613 case FilterOperation::HUE_ROTATE: {
1615 if (!decoder.decode(amount))
1617 filter = BasicColorMatrixFilterOperation::create(amount, type);
1620 case FilterOperation::INVERT:
1621 case FilterOperation::OPACITY:
1622 case FilterOperation::BRIGHTNESS:
1623 case FilterOperation::CONTRAST: {
1625 if (!decoder.decode(amount))
1627 filter = BasicComponentTransferFilterOperation::create(amount, type);
1630 case FilterOperation::BLUR: {
1631 Length stdDeviation;
1632 if (!decoder.decode(stdDeviation))
1634 filter = BlurFilterOperation::create(stdDeviation);
1637 case FilterOperation::DROP_SHADOW: {
1641 if (!decoder.decode(location))
1643 if (!decoder.decode(stdDeviation))
1645 if (!decoder.decode(color))
1647 filter = DropShadowFilterOperation::create(location, stdDeviation, color);
1650 case FilterOperation::DEFAULT: {
1651 FilterOperation::OperationType representedType;
1652 if (!decoder.decodeEnum(representedType))
1654 filter = DefaultFilterOperation::create(representedType);
1657 case FilterOperation::PASSTHROUGH:
1658 filter = PassthroughFilterOperation::create();
1666 void ArgumentCoder<FilterOperations>::encode(ArgumentEncoder& encoder, const FilterOperations& filters)
1668 encoder << static_cast<uint64_t>(filters.size());
1670 for (const auto& filter : filters.operations())
1674 bool ArgumentCoder<FilterOperations>::decode(ArgumentDecoder& decoder, FilterOperations& filters)
1676 uint64_t filterCount;
1677 if (!decoder.decode(filterCount))
1680 for (uint64_t i = 0; i < filterCount; ++i) {
1681 RefPtr<FilterOperation> filter;
1682 if (!decodeFilterOperation(decoder, filter))
1684 filters.operations().append(std::move(filter));
1689 #endif // ENABLE(CSS_FILTERS) && !USE(COORDINATED_GRAPHICS)
1691 #if ENABLE(INDEXED_DATABASE)
1692 void ArgumentCoder<IDBDatabaseMetadata>::encode(ArgumentEncoder& encoder, const IDBDatabaseMetadata& metadata)
1694 encoder << metadata.name << metadata.id << metadata.version << metadata.maxObjectStoreId << metadata.objectStores;
1697 bool ArgumentCoder<IDBDatabaseMetadata>::decode(ArgumentDecoder& decoder, IDBDatabaseMetadata& metadata)
1699 if (!decoder.decode(metadata.name))
1702 if (!decoder.decode(metadata.id))
1705 if (!decoder.decode(metadata.version))
1708 if (!decoder.decode(metadata.maxObjectStoreId))
1711 if (!decoder.decode(metadata.objectStores))
1717 void ArgumentCoder<IDBIndexMetadata>::encode(ArgumentEncoder& encoder, const IDBIndexMetadata& metadata)
1719 encoder << metadata.name << metadata.id << metadata.keyPath << metadata.unique << metadata.multiEntry;
1722 bool ArgumentCoder<IDBIndexMetadata>::decode(ArgumentDecoder& decoder, IDBIndexMetadata& metadata)
1724 if (!decoder.decode(metadata.name))
1727 if (!decoder.decode(metadata.id))
1730 if (!decoder.decode(metadata.keyPath))
1733 if (!decoder.decode(metadata.unique))
1736 if (!decoder.decode(metadata.multiEntry))
1742 void ArgumentCoder<IDBGetResult>::encode(ArgumentEncoder& encoder, const IDBGetResult& result)
1744 bool nullData = !result.valueBuffer;
1745 encoder << nullData;
1748 encoder << DataReference(reinterpret_cast<const uint8_t*>(result.valueBuffer->data()), result.valueBuffer->size());
1750 encoder << result.keyData << result.keyPath;
1753 bool ArgumentCoder<IDBGetResult>::decode(ArgumentDecoder& decoder, IDBGetResult& result)
1756 if (!decoder.decode(nullData))
1760 result.valueBuffer = nullptr;
1763 if (!decoder.decode(data))
1766 result.valueBuffer = SharedBuffer::create(data.data(), data.size());
1769 if (!decoder.decode(result.keyData))
1772 if (!decoder.decode(result.keyPath))
1778 void ArgumentCoder<IDBKeyData>::encode(ArgumentEncoder& encoder, const IDBKeyData& keyData)
1780 encoder << keyData.isNull;
1784 encoder.encodeEnum(keyData.type);
1786 switch (keyData.type) {
1787 case IDBKey::InvalidType:
1789 case IDBKey::ArrayType:
1790 encoder << keyData.arrayValue;
1792 case IDBKey::StringType:
1793 encoder << keyData.stringValue;
1795 case IDBKey::DateType:
1796 case IDBKey::NumberType:
1797 encoder << keyData.numberValue;
1799 case IDBKey::MaxType:
1800 case IDBKey::MinType:
1801 // MaxType and MinType are only used for comparison to other keys.
1802 // They should never be sent across the wire.
1803 ASSERT_NOT_REACHED();
1808 bool ArgumentCoder<IDBKeyData>::decode(ArgumentDecoder& decoder, IDBKeyData& keyData)
1810 if (!decoder.decode(keyData.isNull))
1816 if (!decoder.decodeEnum(keyData.type))
1819 switch (keyData.type) {
1820 case IDBKey::InvalidType:
1822 case IDBKey::ArrayType:
1823 if (!decoder.decode(keyData.arrayValue))
1826 case IDBKey::StringType:
1827 if (!decoder.decode(keyData.stringValue))
1830 case IDBKey::DateType:
1831 case IDBKey::NumberType:
1832 if (!decoder.decode(keyData.numberValue))
1835 case IDBKey::MaxType:
1836 case IDBKey::MinType:
1837 // MaxType and MinType are only used for comparison to other keys.
1838 // They should never be sent across the wire.
1839 ASSERT_NOT_REACHED();
1840 decoder.markInvalid();
1847 void ArgumentCoder<IDBKeyPath>::encode(ArgumentEncoder& encoder, const IDBKeyPath& keyPath)
1849 encoder.encodeEnum(keyPath.type());
1851 switch (keyPath.type()) {
1852 case IDBKeyPath::NullType:
1854 case IDBKeyPath::StringType:
1855 encoder << keyPath.string();
1857 case IDBKeyPath::ArrayType:
1858 encoder << keyPath.array();
1861 ASSERT_NOT_REACHED();
1865 bool ArgumentCoder<IDBKeyPath>::decode(ArgumentDecoder& decoder, IDBKeyPath& keyPath)
1867 IDBKeyPath::Type type;
1868 if (!decoder.decodeEnum(type))
1872 case IDBKeyPath::NullType:
1873 keyPath = IDBKeyPath();
1876 case IDBKeyPath::StringType: {
1878 if (!decoder.decode(string))
1881 keyPath = IDBKeyPath(string);
1884 case IDBKeyPath::ArrayType: {
1885 Vector<String> array;
1886 if (!decoder.decode(array))
1889 keyPath = IDBKeyPath(array);
1897 void ArgumentCoder<IDBKeyRangeData>::encode(ArgumentEncoder& encoder, const IDBKeyRangeData& keyRange)
1899 encoder << keyRange.isNull;
1900 if (keyRange.isNull)
1903 encoder << keyRange.upperKey << keyRange.lowerKey << keyRange.upperOpen << keyRange.lowerOpen;
1906 bool ArgumentCoder<IDBKeyRangeData>::decode(ArgumentDecoder& decoder, IDBKeyRangeData& keyRange)
1908 if (!decoder.decode(keyRange.isNull))
1911 if (keyRange.isNull)
1914 if (!decoder.decode(keyRange.upperKey))
1917 if (!decoder.decode(keyRange.lowerKey))
1920 if (!decoder.decode(keyRange.upperOpen))
1923 if (!decoder.decode(keyRange.lowerOpen))
1929 void ArgumentCoder<IDBObjectStoreMetadata>::encode(ArgumentEncoder& encoder, const IDBObjectStoreMetadata& metadata)
1931 encoder << metadata.name << metadata.id << metadata.keyPath << metadata.autoIncrement << metadata.maxIndexId << metadata.indexes;
1934 bool ArgumentCoder<IDBObjectStoreMetadata>::decode(ArgumentDecoder& decoder, IDBObjectStoreMetadata& metadata)
1936 if (!decoder.decode(metadata.name))
1939 if (!decoder.decode(metadata.id))
1942 if (!decoder.decode(metadata.keyPath))
1945 if (!decoder.decode(metadata.autoIncrement))
1948 if (!decoder.decode(metadata.maxIndexId))
1951 if (!decoder.decode(metadata.indexes))
1957 #endif // ENABLE(INDEXED_DATABASE)
1959 void ArgumentCoder<SessionID>::encode(ArgumentEncoder& encoder, const SessionID& sessionID)
1961 encoder << sessionID.sessionID();
1964 bool ArgumentCoder<SessionID>::decode(ArgumentDecoder& decoder, SessionID& sessionID)
1967 if (!decoder.decode(session))
1970 sessionID = SessionID(session);