2 * Copyright (C) 2011-2017 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/BlobPart.h>
33 #include <WebCore/CacheQueryOptions.h>
34 #include <WebCore/CertificateInfo.h>
35 #include <WebCore/CompositionUnderline.h>
36 #include <WebCore/Credential.h>
37 #include <WebCore/Cursor.h>
38 #include <WebCore/DatabaseDetails.h>
39 #include <WebCore/DictationAlternative.h>
40 #include <WebCore/DictionaryPopupInfo.h>
41 #include <WebCore/DragData.h>
42 #include <WebCore/EventTrackingRegions.h>
43 #include <WebCore/FetchOptions.h>
44 #include <WebCore/FileChooser.h>
45 #include <WebCore/FilterOperation.h>
46 #include <WebCore/FilterOperations.h>
47 #include <WebCore/GraphicsContext.h>
48 #include <WebCore/GraphicsLayer.h>
49 #include <WebCore/IDBGetResult.h>
50 #include <WebCore/Image.h>
51 #include <WebCore/JSDOMExceptionHandling.h>
52 #include <WebCore/Length.h>
53 #include <WebCore/LengthBox.h>
54 #include <WebCore/MediaSelectionOption.h>
55 #include <WebCore/Path.h>
56 #include <WebCore/PluginData.h>
57 #include <WebCore/ProtectionSpace.h>
58 #include <WebCore/Region.h>
59 #include <WebCore/ResourceError.h>
60 #include <WebCore/ResourceLoadStatistics.h>
61 #include <WebCore/ResourceRequest.h>
62 #include <WebCore/ResourceResponse.h>
63 #include <WebCore/ScrollingConstraints.h>
64 #include <WebCore/ScrollingCoordinator.h>
65 #include <WebCore/SearchPopupMenu.h>
66 #include <WebCore/TextCheckerClient.h>
67 #include <WebCore/TextIndicator.h>
68 #include <WebCore/TimingFunction.h>
69 #include <WebCore/TransformationMatrix.h>
70 #include <WebCore/URL.h>
71 #include <WebCore/UserStyleSheet.h>
72 #include <WebCore/ViewportArguments.h>
73 #include <WebCore/WindowFeatures.h>
74 #include <pal/SessionID.h>
75 #include <wtf/MonotonicTime.h>
76 #include <wtf/Seconds.h>
77 #include <wtf/text/CString.h>
78 #include <wtf/text/StringHash.h>
81 #include "ArgumentCodersCF.h"
82 #include "ArgumentCodersMac.h"
86 #include <WebCore/FloatQuad.h>
87 #include <WebCore/InspectorOverlay.h>
88 #include <WebCore/SelectionRect.h>
89 #include <WebCore/SharedBuffer.h>
90 #endif // PLATFORM(IOS)
92 #if PLATFORM(IOS) || PLATFORM(WPE)
93 #include <WebCore/Pasteboard.h>
96 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
97 #include <WebCore/MediaPlaybackTargetContext.h>
100 #if ENABLE(MEDIA_SESSION)
101 #include <WebCore/MediaSessionMetadata.h>
104 #if ENABLE(MEDIA_STREAM)
105 #include <WebCore/CaptureDevice.h>
106 #include <WebCore/MediaConstraints.h>
109 using namespace WebCore;
110 using namespace WebKit;
114 static void encodeSharedBuffer(Encoder& encoder, const SharedBuffer* buffer)
116 SharedMemory::Handle handle;
117 uint64_t bufferSize = buffer ? buffer->size() : 0;
118 encoder << bufferSize;
122 auto sharedMemoryBuffer = SharedMemory::allocate(buffer->size());
123 memcpy(sharedMemoryBuffer->data(), buffer->data(), buffer->size());
124 sharedMemoryBuffer->createHandle(handle, SharedMemory::Protection::ReadOnly);
128 static bool decodeSharedBuffer(Decoder& decoder, RefPtr<SharedBuffer>& buffer)
130 uint64_t bufferSize = 0;
131 if (!decoder.decode(bufferSize))
137 SharedMemory::Handle handle;
138 if (!decoder.decode(handle))
141 auto sharedMemoryBuffer = SharedMemory::map(handle, SharedMemory::Protection::ReadOnly);
142 buffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryBuffer->data()), bufferSize);
147 void ArgumentCoder<MonotonicTime>::encode(Encoder& encoder, const MonotonicTime& time)
149 encoder << time.secondsSinceEpoch().value();
152 bool ArgumentCoder<MonotonicTime>::decode(Decoder& decoder, MonotonicTime& time)
155 if (!decoder.decode(value))
158 time = MonotonicTime::fromRawSeconds(value);
162 void ArgumentCoder<Seconds>::encode(Encoder& encoder, const Seconds& seconds)
164 encoder << seconds.value();
167 bool ArgumentCoder<Seconds>::decode(Decoder& decoder, Seconds& seconds)
170 if (!decoder.decode(value))
173 seconds = Seconds(value);
177 void ArgumentCoder<AffineTransform>::encode(Encoder& encoder, const AffineTransform& affineTransform)
179 SimpleArgumentCoder<AffineTransform>::encode(encoder, affineTransform);
182 bool ArgumentCoder<AffineTransform>::decode(Decoder& decoder, AffineTransform& affineTransform)
184 return SimpleArgumentCoder<AffineTransform>::decode(decoder, affineTransform);
187 void ArgumentCoder<CacheQueryOptions>::encode(Encoder& encoder, const CacheQueryOptions& options)
189 encoder << options.ignoreSearch;
190 encoder << options.ignoreMethod;
191 encoder << options.ignoreVary;
192 encoder << options.cacheName;
195 bool ArgumentCoder<CacheQueryOptions>::decode(Decoder& decoder, CacheQueryOptions& options)
198 if (!decoder.decode(ignoreSearch))
201 if (!decoder.decode(ignoreMethod))
204 if (!decoder.decode(ignoreVary))
207 if (!decoder.decode(cacheName))
210 options.ignoreSearch = ignoreSearch;
211 options.ignoreMethod = ignoreMethod;
212 options.ignoreVary = ignoreVary;
213 options.cacheName = WTFMove(cacheName);
217 void ArgumentCoder<DOMCache::CacheInfo>::encode(Encoder& encoder, const DOMCache::CacheInfo& info)
219 encoder << info.identifier;
220 encoder << info.name;
223 bool ArgumentCoder<DOMCache::CacheInfo>::decode(Decoder& decoder, DOMCache::CacheInfo& record)
226 if (!decoder.decode(identifier))
230 if (!decoder.decode(name))
233 record.identifier = identifier;
234 record.name = WTFMove(name);
239 void ArgumentCoder<DOMCache::Record>::encode(Encoder& encoder, const DOMCache::Record& record)
241 encoder << record.identifier;
243 encoder << record.requestHeadersGuard;
244 encoder << record.request;
245 encoder << record.options;
246 encoder << record.referrer;
248 encoder << record.responseHeadersGuard;
249 encoder << record.response;
250 encoder << record.updateResponseCounter;
252 WTF::switchOn(record.responseBody, [&](const Ref<SharedBuffer>& buffer) {
254 encodeSharedBuffer(encoder, buffer.ptr());
255 }, [&](const Ref<FormData>& formData) {
258 formData->encode(encoder);
259 }, [&](const std::nullptr_t&) {
265 bool ArgumentCoder<DOMCache::Record>::decode(Decoder& decoder, DOMCache::Record& record)
268 if (!decoder.decode(identifier))
271 FetchHeaders::Guard requestHeadersGuard;
272 if (!decoder.decode(requestHeadersGuard))
275 WebCore::ResourceRequest request;
276 if (!decoder.decode(request))
279 WebCore::FetchOptions options;
280 if (!decoder.decode(options))
284 if (!decoder.decode(referrer))
287 FetchHeaders::Guard responseHeadersGuard;
288 if (!decoder.decode(responseHeadersGuard))
291 WebCore::ResourceResponse response;
292 if (!decoder.decode(response))
295 uint64_t updateResponseCounter;
296 if (!decoder.decode(updateResponseCounter))
299 WebCore::DOMCache::ResponseBody responseBody;
300 bool hasSharedBufferBody;
301 if (!decoder.decode(hasSharedBufferBody))
304 if (hasSharedBufferBody) {
305 RefPtr<SharedBuffer> buffer;
306 if (!decodeSharedBuffer(decoder, buffer))
309 responseBody = buffer.releaseNonNull();
311 bool hasFormDataBody;
312 if (!decoder.decode(hasFormDataBody))
314 if (hasFormDataBody) {
315 auto formData = FormData::decode(decoder);
318 responseBody = formData.releaseNonNull();
322 record.identifier = identifier;
323 record.requestHeadersGuard = requestHeadersGuard;
324 record.request = WTFMove(request);
325 record.options = WTFMove(options);
326 record.referrer = WTFMove(referrer);
328 record.responseHeadersGuard = responseHeadersGuard;
329 record.response = WTFMove(response);
330 record.updateResponseCounter = updateResponseCounter;
331 record.responseBody = WTFMove(responseBody);
336 void ArgumentCoder<EventTrackingRegions>::encode(Encoder& encoder, const EventTrackingRegions& eventTrackingRegions)
338 encoder << eventTrackingRegions.asynchronousDispatchRegion;
339 encoder << eventTrackingRegions.eventSpecificSynchronousDispatchRegions;
342 bool ArgumentCoder<EventTrackingRegions>::decode(Decoder& decoder, EventTrackingRegions& eventTrackingRegions)
344 Region asynchronousDispatchRegion;
345 if (!decoder.decode(asynchronousDispatchRegion))
347 HashMap<String, Region> eventSpecificSynchronousDispatchRegions;
348 if (!decoder.decode(eventSpecificSynchronousDispatchRegions))
350 eventTrackingRegions.asynchronousDispatchRegion = WTFMove(asynchronousDispatchRegion);
351 eventTrackingRegions.eventSpecificSynchronousDispatchRegions = WTFMove(eventSpecificSynchronousDispatchRegions);
355 void ArgumentCoder<TransformationMatrix>::encode(Encoder& encoder, const TransformationMatrix& transformationMatrix)
357 encoder << transformationMatrix.m11();
358 encoder << transformationMatrix.m12();
359 encoder << transformationMatrix.m13();
360 encoder << transformationMatrix.m14();
362 encoder << transformationMatrix.m21();
363 encoder << transformationMatrix.m22();
364 encoder << transformationMatrix.m23();
365 encoder << transformationMatrix.m24();
367 encoder << transformationMatrix.m31();
368 encoder << transformationMatrix.m32();
369 encoder << transformationMatrix.m33();
370 encoder << transformationMatrix.m34();
372 encoder << transformationMatrix.m41();
373 encoder << transformationMatrix.m42();
374 encoder << transformationMatrix.m43();
375 encoder << transformationMatrix.m44();
378 bool ArgumentCoder<TransformationMatrix>::decode(Decoder& decoder, TransformationMatrix& transformationMatrix)
381 if (!decoder.decode(m11))
384 if (!decoder.decode(m12))
387 if (!decoder.decode(m13))
390 if (!decoder.decode(m14))
394 if (!decoder.decode(m21))
397 if (!decoder.decode(m22))
400 if (!decoder.decode(m23))
403 if (!decoder.decode(m24))
407 if (!decoder.decode(m31))
410 if (!decoder.decode(m32))
413 if (!decoder.decode(m33))
416 if (!decoder.decode(m34))
420 if (!decoder.decode(m41))
423 if (!decoder.decode(m42))
426 if (!decoder.decode(m43))
429 if (!decoder.decode(m44))
432 transformationMatrix.setMatrix(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44);
436 void ArgumentCoder<LinearTimingFunction>::encode(Encoder& encoder, const LinearTimingFunction& timingFunction)
438 encoder.encodeEnum(timingFunction.type());
441 bool ArgumentCoder<LinearTimingFunction>::decode(Decoder&, LinearTimingFunction&)
443 // Type is decoded by the caller. Nothing else to decode.
447 void ArgumentCoder<CubicBezierTimingFunction>::encode(Encoder& encoder, const CubicBezierTimingFunction& timingFunction)
449 encoder.encodeEnum(timingFunction.type());
451 encoder << timingFunction.x1();
452 encoder << timingFunction.y1();
453 encoder << timingFunction.x2();
454 encoder << timingFunction.y2();
456 encoder.encodeEnum(timingFunction.timingFunctionPreset());
459 bool ArgumentCoder<CubicBezierTimingFunction>::decode(Decoder& decoder, CubicBezierTimingFunction& timingFunction)
461 // Type is decoded by the caller.
463 if (!decoder.decode(x1))
467 if (!decoder.decode(y1))
471 if (!decoder.decode(x2))
475 if (!decoder.decode(y2))
478 CubicBezierTimingFunction::TimingFunctionPreset preset;
479 if (!decoder.decodeEnum(preset))
482 timingFunction.setValues(x1, y1, x2, y2);
483 timingFunction.setTimingFunctionPreset(preset);
488 void ArgumentCoder<StepsTimingFunction>::encode(Encoder& encoder, const StepsTimingFunction& timingFunction)
490 encoder.encodeEnum(timingFunction.type());
492 encoder << timingFunction.numberOfSteps();
493 encoder << timingFunction.stepAtStart();
496 bool ArgumentCoder<StepsTimingFunction>::decode(Decoder& decoder, StepsTimingFunction& timingFunction)
498 // Type is decoded by the caller.
500 if (!decoder.decode(numSteps))
504 if (!decoder.decode(stepAtStart))
507 timingFunction.setNumberOfSteps(numSteps);
508 timingFunction.setStepAtStart(stepAtStart);
513 void ArgumentCoder<SpringTimingFunction>::encode(Encoder& encoder, const SpringTimingFunction& timingFunction)
515 encoder.encodeEnum(timingFunction.type());
517 encoder << timingFunction.mass();
518 encoder << timingFunction.stiffness();
519 encoder << timingFunction.damping();
520 encoder << timingFunction.initialVelocity();
523 bool ArgumentCoder<SpringTimingFunction>::decode(Decoder& decoder, SpringTimingFunction& timingFunction)
525 // Type is decoded by the caller.
527 if (!decoder.decode(mass))
531 if (!decoder.decode(stiffness))
535 if (!decoder.decode(damping))
538 double initialVelocity;
539 if (!decoder.decode(initialVelocity))
542 timingFunction.setValues(mass, stiffness, damping, initialVelocity);
547 void ArgumentCoder<FloatPoint>::encode(Encoder& encoder, const FloatPoint& floatPoint)
549 SimpleArgumentCoder<FloatPoint>::encode(encoder, floatPoint);
552 bool ArgumentCoder<FloatPoint>::decode(Decoder& decoder, FloatPoint& floatPoint)
554 return SimpleArgumentCoder<FloatPoint>::decode(decoder, floatPoint);
558 void ArgumentCoder<FloatPoint3D>::encode(Encoder& encoder, const FloatPoint3D& floatPoint)
560 SimpleArgumentCoder<FloatPoint3D>::encode(encoder, floatPoint);
563 bool ArgumentCoder<FloatPoint3D>::decode(Decoder& decoder, FloatPoint3D& floatPoint)
565 return SimpleArgumentCoder<FloatPoint3D>::decode(decoder, floatPoint);
569 void ArgumentCoder<FloatRect>::encode(Encoder& encoder, const FloatRect& floatRect)
571 SimpleArgumentCoder<FloatRect>::encode(encoder, floatRect);
574 bool ArgumentCoder<FloatRect>::decode(Decoder& decoder, FloatRect& floatRect)
576 return SimpleArgumentCoder<FloatRect>::decode(decoder, floatRect);
580 void ArgumentCoder<FloatBoxExtent>::encode(Encoder& encoder, const FloatBoxExtent& floatBoxExtent)
582 SimpleArgumentCoder<FloatBoxExtent>::encode(encoder, floatBoxExtent);
585 bool ArgumentCoder<FloatBoxExtent>::decode(Decoder& decoder, FloatBoxExtent& floatBoxExtent)
587 return SimpleArgumentCoder<FloatBoxExtent>::decode(decoder, floatBoxExtent);
591 void ArgumentCoder<FloatSize>::encode(Encoder& encoder, const FloatSize& floatSize)
593 SimpleArgumentCoder<FloatSize>::encode(encoder, floatSize);
596 bool ArgumentCoder<FloatSize>::decode(Decoder& decoder, FloatSize& floatSize)
598 return SimpleArgumentCoder<FloatSize>::decode(decoder, floatSize);
602 void ArgumentCoder<FloatRoundedRect>::encode(Encoder& encoder, const FloatRoundedRect& roundedRect)
604 SimpleArgumentCoder<FloatRoundedRect>::encode(encoder, roundedRect);
607 bool ArgumentCoder<FloatRoundedRect>::decode(Decoder& decoder, FloatRoundedRect& roundedRect)
609 return SimpleArgumentCoder<FloatRoundedRect>::decode(decoder, roundedRect);
613 void ArgumentCoder<FloatQuad>::encode(Encoder& encoder, const FloatQuad& floatQuad)
615 SimpleArgumentCoder<FloatQuad>::encode(encoder, floatQuad);
618 bool ArgumentCoder<FloatQuad>::decode(Decoder& decoder, FloatQuad& floatQuad)
620 return SimpleArgumentCoder<FloatQuad>::decode(decoder, floatQuad);
623 void ArgumentCoder<ViewportArguments>::encode(Encoder& encoder, const ViewportArguments& viewportArguments)
625 SimpleArgumentCoder<ViewportArguments>::encode(encoder, viewportArguments);
628 bool ArgumentCoder<ViewportArguments>::decode(Decoder& decoder, ViewportArguments& viewportArguments)
630 return SimpleArgumentCoder<ViewportArguments>::decode(decoder, viewportArguments);
632 #endif // PLATFORM(IOS)
635 void ArgumentCoder<IntPoint>::encode(Encoder& encoder, const IntPoint& intPoint)
637 SimpleArgumentCoder<IntPoint>::encode(encoder, intPoint);
640 bool ArgumentCoder<IntPoint>::decode(Decoder& decoder, IntPoint& intPoint)
642 return SimpleArgumentCoder<IntPoint>::decode(decoder, intPoint);
646 void ArgumentCoder<IntRect>::encode(Encoder& encoder, const IntRect& intRect)
648 SimpleArgumentCoder<IntRect>::encode(encoder, intRect);
651 bool ArgumentCoder<IntRect>::decode(Decoder& decoder, IntRect& intRect)
653 return SimpleArgumentCoder<IntRect>::decode(decoder, intRect);
657 void ArgumentCoder<IntSize>::encode(Encoder& encoder, const IntSize& intSize)
659 SimpleArgumentCoder<IntSize>::encode(encoder, intSize);
662 bool ArgumentCoder<IntSize>::decode(Decoder& decoder, IntSize& intSize)
664 return SimpleArgumentCoder<IntSize>::decode(decoder, intSize);
668 void ArgumentCoder<LayoutSize>::encode(Encoder& encoder, const LayoutSize& layoutSize)
670 SimpleArgumentCoder<LayoutSize>::encode(encoder, layoutSize);
673 bool ArgumentCoder<LayoutSize>::decode(Decoder& decoder, LayoutSize& layoutSize)
675 return SimpleArgumentCoder<LayoutSize>::decode(decoder, layoutSize);
679 void ArgumentCoder<LayoutPoint>::encode(Encoder& encoder, const LayoutPoint& layoutPoint)
681 SimpleArgumentCoder<LayoutPoint>::encode(encoder, layoutPoint);
684 bool ArgumentCoder<LayoutPoint>::decode(Decoder& decoder, LayoutPoint& layoutPoint)
686 return SimpleArgumentCoder<LayoutPoint>::decode(decoder, layoutPoint);
690 static void pathEncodeApplierFunction(Encoder& encoder, const PathElement& element)
692 encoder.encodeEnum(element.type);
694 switch (element.type) {
695 case PathElementMoveToPoint: // The points member will contain 1 value.
696 encoder << element.points[0];
698 case PathElementAddLineToPoint: // The points member will contain 1 value.
699 encoder << element.points[0];
701 case PathElementAddQuadCurveToPoint: // The points member will contain 2 values.
702 encoder << element.points[0];
703 encoder << element.points[1];
705 case PathElementAddCurveToPoint: // The points member will contain 3 values.
706 encoder << element.points[0];
707 encoder << element.points[1];
708 encoder << element.points[2];
710 case PathElementCloseSubpath: // The points member will contain no values.
715 void ArgumentCoder<Path>::encode(Encoder& encoder, const Path& path)
717 uint64_t numPoints = 0;
718 path.apply([&numPoints](const PathElement&) {
722 encoder << numPoints;
724 path.apply([&encoder](const PathElement& pathElement) {
725 pathEncodeApplierFunction(encoder, pathElement);
729 bool ArgumentCoder<Path>::decode(Decoder& decoder, Path& path)
732 if (!decoder.decode(numPoints))
737 for (uint64_t i = 0; i < numPoints; ++i) {
739 PathElementType elementType;
740 if (!decoder.decodeEnum(elementType))
743 switch (elementType) {
744 case PathElementMoveToPoint: { // The points member will contain 1 value.
746 if (!decoder.decode(point))
751 case PathElementAddLineToPoint: { // The points member will contain 1 value.
753 if (!decoder.decode(point))
755 path.addLineTo(point);
758 case PathElementAddQuadCurveToPoint: { // The points member will contain 2 values.
759 FloatPoint controlPoint;
760 if (!decoder.decode(controlPoint))
764 if (!decoder.decode(endPoint))
767 path.addQuadCurveTo(controlPoint, endPoint);
770 case PathElementAddCurveToPoint: { // The points member will contain 3 values.
771 FloatPoint controlPoint1;
772 if (!decoder.decode(controlPoint1))
775 FloatPoint controlPoint2;
776 if (!decoder.decode(controlPoint2))
780 if (!decoder.decode(endPoint))
783 path.addBezierCurveTo(controlPoint1, controlPoint2, endPoint);
786 case PathElementCloseSubpath: // The points member will contain no values.
795 void ArgumentCoder<RecentSearch>::encode(Encoder& encoder, const RecentSearch& recentSearch)
797 encoder << recentSearch.string << recentSearch.time;
800 bool ArgumentCoder<RecentSearch>::decode(Decoder& decoder, RecentSearch& recentSearch)
802 if (!decoder.decode(recentSearch.string))
805 if (!decoder.decode(recentSearch.time))
811 template<> struct ArgumentCoder<Region::Span> {
812 static void encode(Encoder&, const Region::Span&);
813 static bool decode(Decoder&, Region::Span&);
816 void ArgumentCoder<Region::Span>::encode(Encoder& encoder, const Region::Span& span)
819 encoder << (uint64_t)span.segmentIndex;
822 bool ArgumentCoder<Region::Span>::decode(Decoder& decoder, Region::Span& span)
824 if (!decoder.decode(span.y))
827 uint64_t segmentIndex;
828 if (!decoder.decode(segmentIndex))
831 span.segmentIndex = segmentIndex;
835 void ArgumentCoder<Region>::encode(Encoder& encoder, const Region& region)
837 encoder.encode(region.shapeSegments());
838 encoder.encode(region.shapeSpans());
841 bool ArgumentCoder<Region>::decode(Decoder& decoder, Region& region)
843 Vector<int> segments;
844 if (!decoder.decode(segments))
847 Vector<Region::Span> spans;
848 if (!decoder.decode(spans))
851 region.setShapeSegments(segments);
852 region.setShapeSpans(spans);
853 region.updateBoundsFromShape();
855 if (!region.isValid())
861 void ArgumentCoder<Length>::encode(Encoder& encoder, const Length& length)
863 SimpleArgumentCoder<Length>::encode(encoder, length);
866 bool ArgumentCoder<Length>::decode(Decoder& decoder, Length& length)
868 return SimpleArgumentCoder<Length>::decode(decoder, length);
872 void ArgumentCoder<ViewportAttributes>::encode(Encoder& encoder, const ViewportAttributes& viewportAttributes)
874 SimpleArgumentCoder<ViewportAttributes>::encode(encoder, viewportAttributes);
877 bool ArgumentCoder<ViewportAttributes>::decode(Decoder& decoder, ViewportAttributes& viewportAttributes)
879 return SimpleArgumentCoder<ViewportAttributes>::decode(decoder, viewportAttributes);
883 void ArgumentCoder<MimeClassInfo>::encode(Encoder& encoder, const MimeClassInfo& mimeClassInfo)
885 encoder << mimeClassInfo.type << mimeClassInfo.desc << mimeClassInfo.extensions;
888 bool ArgumentCoder<MimeClassInfo>::decode(Decoder& decoder, MimeClassInfo& mimeClassInfo)
890 if (!decoder.decode(mimeClassInfo.type))
892 if (!decoder.decode(mimeClassInfo.desc))
894 if (!decoder.decode(mimeClassInfo.extensions))
901 void ArgumentCoder<PluginInfo>::encode(Encoder& encoder, const PluginInfo& pluginInfo)
903 encoder << pluginInfo.name;
904 encoder << pluginInfo.file;
905 encoder << pluginInfo.desc;
906 encoder << pluginInfo.mimes;
907 encoder << pluginInfo.isApplicationPlugin;
908 encoder.encodeEnum(pluginInfo.clientLoadPolicy);
910 encoder << pluginInfo.bundleIdentifier;
911 encoder << pluginInfo.versionString;
915 bool ArgumentCoder<PluginInfo>::decode(Decoder& decoder, PluginInfo& pluginInfo)
917 if (!decoder.decode(pluginInfo.name))
919 if (!decoder.decode(pluginInfo.file))
921 if (!decoder.decode(pluginInfo.desc))
923 if (!decoder.decode(pluginInfo.mimes))
925 if (!decoder.decode(pluginInfo.isApplicationPlugin))
927 if (!decoder.decodeEnum(pluginInfo.clientLoadPolicy))
930 if (!decoder.decode(pluginInfo.bundleIdentifier))
932 if (!decoder.decode(pluginInfo.versionString))
939 void ArgumentCoder<AuthenticationChallenge>::encode(Encoder& encoder, const AuthenticationChallenge& challenge)
941 encoder << challenge.protectionSpace() << challenge.proposedCredential() << challenge.previousFailureCount() << challenge.failureResponse() << challenge.error();
944 bool ArgumentCoder<AuthenticationChallenge>::decode(Decoder& decoder, AuthenticationChallenge& challenge)
946 ProtectionSpace protectionSpace;
947 if (!decoder.decode(protectionSpace))
950 Credential proposedCredential;
951 if (!decoder.decode(proposedCredential))
954 unsigned previousFailureCount;
955 if (!decoder.decode(previousFailureCount))
958 ResourceResponse failureResponse;
959 if (!decoder.decode(failureResponse))
963 if (!decoder.decode(error))
966 challenge = AuthenticationChallenge(protectionSpace, proposedCredential, previousFailureCount, failureResponse, error);
971 void ArgumentCoder<ProtectionSpace>::encode(Encoder& encoder, const ProtectionSpace& space)
973 if (space.encodingRequiresPlatformData()) {
975 encodePlatformData(encoder, space);
980 encoder << space.host() << space.port() << space.realm();
981 encoder.encodeEnum(space.authenticationScheme());
982 encoder.encodeEnum(space.serverType());
985 bool ArgumentCoder<ProtectionSpace>::decode(Decoder& decoder, ProtectionSpace& space)
987 bool hasPlatformData;
988 if (!decoder.decode(hasPlatformData))
992 return decodePlatformData(decoder, space);
995 if (!decoder.decode(host))
999 if (!decoder.decode(port))
1003 if (!decoder.decode(realm))
1006 ProtectionSpaceAuthenticationScheme authenticationScheme;
1007 if (!decoder.decodeEnum(authenticationScheme))
1010 ProtectionSpaceServerType serverType;
1011 if (!decoder.decodeEnum(serverType))
1014 space = ProtectionSpace(host, port, serverType, realm, authenticationScheme);
1018 void ArgumentCoder<Credential>::encode(Encoder& encoder, const Credential& credential)
1020 if (credential.encodingRequiresPlatformData()) {
1022 encodePlatformData(encoder, credential);
1027 encoder << credential.user() << credential.password();
1028 encoder.encodeEnum(credential.persistence());
1031 bool ArgumentCoder<Credential>::decode(Decoder& decoder, Credential& credential)
1033 bool hasPlatformData;
1034 if (!decoder.decode(hasPlatformData))
1037 if (hasPlatformData)
1038 return decodePlatformData(decoder, credential);
1041 if (!decoder.decode(user))
1045 if (!decoder.decode(password))
1048 CredentialPersistence persistence;
1049 if (!decoder.decodeEnum(persistence))
1052 credential = Credential(user, password, persistence);
1056 static void encodeImage(Encoder& encoder, Image& image)
1058 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(IntSize(image.size()), { });
1059 bitmap->createGraphicsContext()->drawImage(image, IntPoint());
1061 ShareableBitmap::Handle handle;
1062 bitmap->createHandle(handle);
1067 static bool decodeImage(Decoder& decoder, RefPtr<Image>& image)
1069 ShareableBitmap::Handle handle;
1070 if (!decoder.decode(handle))
1073 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(handle);
1076 image = bitmap->createImage();
1082 static void encodeOptionalImage(Encoder& encoder, Image* image)
1084 bool hasImage = !!image;
1085 encoder << hasImage;
1088 encodeImage(encoder, *image);
1091 static bool decodeOptionalImage(Decoder& decoder, RefPtr<Image>& image)
1096 if (!decoder.decode(hasImage))
1102 return decodeImage(decoder, image);
1106 void ArgumentCoder<Cursor>::encode(Encoder& encoder, const Cursor& cursor)
1108 encoder.encodeEnum(cursor.type());
1110 if (cursor.type() != Cursor::Custom)
1113 if (cursor.image()->isNull()) {
1114 encoder << false; // There is no valid image being encoded.
1119 encodeImage(encoder, *cursor.image());
1120 encoder << cursor.hotSpot();
1121 #if ENABLE(MOUSE_CURSOR_SCALE)
1122 encoder << cursor.imageScaleFactor();
1126 bool ArgumentCoder<Cursor>::decode(Decoder& decoder, Cursor& cursor)
1129 if (!decoder.decodeEnum(type))
1132 if (type > Cursor::Custom)
1135 if (type != Cursor::Custom) {
1136 const Cursor& cursorReference = Cursor::fromType(type);
1137 // Calling platformCursor here will eagerly create the platform cursor for the cursor singletons inside WebCore.
1138 // This will avoid having to re-create the platform cursors over and over.
1139 (void)cursorReference.platformCursor();
1141 cursor = cursorReference;
1145 bool isValidImagePresent;
1146 if (!decoder.decode(isValidImagePresent))
1149 if (!isValidImagePresent) {
1150 cursor = Cursor(&Image::nullImage(), IntPoint());
1154 RefPtr<Image> image;
1155 if (!decodeImage(decoder, image))
1159 if (!decoder.decode(hotSpot))
1162 if (!image->rect().contains(hotSpot))
1165 #if ENABLE(MOUSE_CURSOR_SCALE)
1167 if (!decoder.decode(scale))
1170 cursor = Cursor(image.get(), hotSpot, scale);
1172 cursor = Cursor(image.get(), hotSpot);
1178 void ArgumentCoder<ResourceRequest>::encode(Encoder& encoder, const ResourceRequest& resourceRequest)
1180 encoder << resourceRequest.cachePartition();
1181 encoder << resourceRequest.hiddenFromInspector();
1183 if (resourceRequest.encodingRequiresPlatformData()) {
1185 encodePlatformData(encoder, resourceRequest);
1189 resourceRequest.encodeWithoutPlatformData(encoder);
1192 bool ArgumentCoder<ResourceRequest>::decode(Decoder& decoder, ResourceRequest& resourceRequest)
1194 String cachePartition;
1195 if (!decoder.decode(cachePartition))
1197 resourceRequest.setCachePartition(cachePartition);
1199 bool isHiddenFromInspector;
1200 if (!decoder.decode(isHiddenFromInspector))
1202 resourceRequest.setHiddenFromInspector(isHiddenFromInspector);
1204 bool hasPlatformData;
1205 if (!decoder.decode(hasPlatformData))
1207 if (hasPlatformData)
1208 return decodePlatformData(decoder, resourceRequest);
1210 return resourceRequest.decodeWithoutPlatformData(decoder);
1213 void ArgumentCoder<ResourceError>::encode(Encoder& encoder, const ResourceError& resourceError)
1215 encodePlatformData(encoder, resourceError);
1218 bool ArgumentCoder<ResourceError>::decode(Decoder& decoder, ResourceError& resourceError)
1220 return decodePlatformData(decoder, resourceError);
1225 void ArgumentCoder<SelectionRect>::encode(Encoder& encoder, const SelectionRect& selectionRect)
1227 encoder << selectionRect.rect();
1228 encoder << static_cast<uint32_t>(selectionRect.direction());
1229 encoder << selectionRect.minX();
1230 encoder << selectionRect.maxX();
1231 encoder << selectionRect.maxY();
1232 encoder << selectionRect.lineNumber();
1233 encoder << selectionRect.isLineBreak();
1234 encoder << selectionRect.isFirstOnLine();
1235 encoder << selectionRect.isLastOnLine();
1236 encoder << selectionRect.containsStart();
1237 encoder << selectionRect.containsEnd();
1238 encoder << selectionRect.isHorizontal();
1241 bool ArgumentCoder<SelectionRect>::decode(Decoder& decoder, SelectionRect& selectionRect)
1244 if (!decoder.decode(rect))
1246 selectionRect.setRect(rect);
1249 if (!decoder.decode(direction))
1251 selectionRect.setDirection((TextDirection)direction);
1254 if (!decoder.decode(intValue))
1256 selectionRect.setMinX(intValue);
1258 if (!decoder.decode(intValue))
1260 selectionRect.setMaxX(intValue);
1262 if (!decoder.decode(intValue))
1264 selectionRect.setMaxY(intValue);
1266 if (!decoder.decode(intValue))
1268 selectionRect.setLineNumber(intValue);
1271 if (!decoder.decode(boolValue))
1273 selectionRect.setIsLineBreak(boolValue);
1275 if (!decoder.decode(boolValue))
1277 selectionRect.setIsFirstOnLine(boolValue);
1279 if (!decoder.decode(boolValue))
1281 selectionRect.setIsLastOnLine(boolValue);
1283 if (!decoder.decode(boolValue))
1285 selectionRect.setContainsStart(boolValue);
1287 if (!decoder.decode(boolValue))
1289 selectionRect.setContainsEnd(boolValue);
1291 if (!decoder.decode(boolValue))
1293 selectionRect.setIsHorizontal(boolValue);
1300 void ArgumentCoder<WindowFeatures>::encode(Encoder& encoder, const WindowFeatures& windowFeatures)
1302 encoder << windowFeatures.x;
1303 encoder << windowFeatures.y;
1304 encoder << windowFeatures.width;
1305 encoder << windowFeatures.height;
1306 encoder << windowFeatures.menuBarVisible;
1307 encoder << windowFeatures.statusBarVisible;
1308 encoder << windowFeatures.toolBarVisible;
1309 encoder << windowFeatures.locationBarVisible;
1310 encoder << windowFeatures.scrollbarsVisible;
1311 encoder << windowFeatures.resizable;
1312 encoder << windowFeatures.fullscreen;
1313 encoder << windowFeatures.dialog;
1316 bool ArgumentCoder<WindowFeatures>::decode(Decoder& decoder, WindowFeatures& windowFeatures)
1318 if (!decoder.decode(windowFeatures.x))
1320 if (!decoder.decode(windowFeatures.y))
1322 if (!decoder.decode(windowFeatures.width))
1324 if (!decoder.decode(windowFeatures.height))
1326 if (!decoder.decode(windowFeatures.menuBarVisible))
1328 if (!decoder.decode(windowFeatures.statusBarVisible))
1330 if (!decoder.decode(windowFeatures.toolBarVisible))
1332 if (!decoder.decode(windowFeatures.locationBarVisible))
1334 if (!decoder.decode(windowFeatures.scrollbarsVisible))
1336 if (!decoder.decode(windowFeatures.resizable))
1338 if (!decoder.decode(windowFeatures.fullscreen))
1340 if (!decoder.decode(windowFeatures.dialog))
1346 void ArgumentCoder<Color>::encode(Encoder& encoder, const Color& color)
1348 if (color.isExtended()) {
1350 encoder << color.asExtended().red();
1351 encoder << color.asExtended().green();
1352 encoder << color.asExtended().blue();
1353 encoder << color.asExtended().alpha();
1354 encoder << color.asExtended().colorSpace();
1360 if (!color.isValid()) {
1366 encoder << color.rgb();
1369 bool ArgumentCoder<Color>::decode(Decoder& decoder, Color& color)
1372 if (!decoder.decode(isExtended))
1380 ColorSpace colorSpace;
1381 if (!decoder.decode(red))
1383 if (!decoder.decode(green))
1385 if (!decoder.decode(blue))
1387 if (!decoder.decode(alpha))
1389 if (!decoder.decode(colorSpace))
1391 color = Color(red, green, blue, alpha, colorSpace);
1396 if (!decoder.decode(isValid))
1405 if (!decoder.decode(rgba))
1408 color = Color(rgba);
1412 #if ENABLE(DRAG_SUPPORT)
1413 void ArgumentCoder<DragData>::encode(Encoder& encoder, const DragData& dragData)
1415 encoder << dragData.clientPosition();
1416 encoder << dragData.globalPosition();
1417 encoder.encodeEnum(dragData.draggingSourceOperationMask());
1418 encoder.encodeEnum(dragData.flags());
1420 encoder << dragData.pasteboardName();
1421 encoder << dragData.fileNames();
1423 encoder.encodeEnum(dragData.dragDestinationAction());
1426 bool ArgumentCoder<DragData>::decode(Decoder& decoder, DragData& dragData)
1428 IntPoint clientPosition;
1429 if (!decoder.decode(clientPosition))
1432 IntPoint globalPosition;
1433 if (!decoder.decode(globalPosition))
1436 DragOperation draggingSourceOperationMask;
1437 if (!decoder.decodeEnum(draggingSourceOperationMask))
1440 DragApplicationFlags applicationFlags;
1441 if (!decoder.decodeEnum(applicationFlags))
1444 String pasteboardName;
1445 Vector<String> fileNames;
1447 if (!decoder.decode(pasteboardName))
1450 if (!decoder.decode(fileNames))
1454 DragDestinationAction destinationAction;
1455 if (!decoder.decodeEnum(destinationAction))
1458 dragData = DragData(pasteboardName, clientPosition, globalPosition, draggingSourceOperationMask, applicationFlags, destinationAction);
1459 dragData.setFileNames(fileNames);
1465 void ArgumentCoder<CompositionUnderline>::encode(Encoder& encoder, const CompositionUnderline& underline)
1467 encoder << underline.startOffset;
1468 encoder << underline.endOffset;
1469 encoder << underline.thick;
1470 encoder << underline.color;
1473 bool ArgumentCoder<CompositionUnderline>::decode(Decoder& decoder, CompositionUnderline& underline)
1475 if (!decoder.decode(underline.startOffset))
1477 if (!decoder.decode(underline.endOffset))
1479 if (!decoder.decode(underline.thick))
1481 if (!decoder.decode(underline.color))
1487 void ArgumentCoder<DatabaseDetails>::encode(Encoder& encoder, const DatabaseDetails& details)
1489 encoder << details.name();
1490 encoder << details.displayName();
1491 encoder << details.expectedUsage();
1492 encoder << details.currentUsage();
1493 encoder << details.creationTime();
1494 encoder << details.modificationTime();
1497 bool ArgumentCoder<DatabaseDetails>::decode(Decoder& decoder, DatabaseDetails& details)
1500 if (!decoder.decode(name))
1504 if (!decoder.decode(displayName))
1507 uint64_t expectedUsage;
1508 if (!decoder.decode(expectedUsage))
1511 uint64_t currentUsage;
1512 if (!decoder.decode(currentUsage))
1515 double creationTime;
1516 if (!decoder.decode(creationTime))
1519 double modificationTime;
1520 if (!decoder.decode(modificationTime))
1523 details = DatabaseDetails(name, displayName, expectedUsage, currentUsage, creationTime, modificationTime);
1529 void ArgumentCoder<Highlight>::encode(Encoder& encoder, const Highlight& highlight)
1531 encoder << static_cast<uint32_t>(highlight.type);
1532 encoder << highlight.usePageCoordinates;
1533 encoder << highlight.contentColor;
1534 encoder << highlight.contentOutlineColor;
1535 encoder << highlight.paddingColor;
1536 encoder << highlight.borderColor;
1537 encoder << highlight.marginColor;
1538 encoder << highlight.quads;
1541 bool ArgumentCoder<Highlight>::decode(Decoder& decoder, Highlight& highlight)
1544 if (!decoder.decode(type))
1546 highlight.type = (HighlightType)type;
1548 if (!decoder.decode(highlight.usePageCoordinates))
1550 if (!decoder.decode(highlight.contentColor))
1552 if (!decoder.decode(highlight.contentOutlineColor))
1554 if (!decoder.decode(highlight.paddingColor))
1556 if (!decoder.decode(highlight.borderColor))
1558 if (!decoder.decode(highlight.marginColor))
1560 if (!decoder.decode(highlight.quads))
1565 void ArgumentCoder<PasteboardURL>::encode(Encoder& encoder, const PasteboardURL& content)
1567 encoder << content.url;
1568 encoder << content.title;
1571 bool ArgumentCoder<PasteboardURL>::decode(Decoder& decoder, PasteboardURL& content)
1573 if (!decoder.decode(content.url))
1576 if (!decoder.decode(content.title))
1582 static void encodeClientTypesAndData(Encoder& encoder, const Vector<String>& types, const Vector<RefPtr<SharedBuffer>>& data)
1584 ASSERT(types.size() == data.size());
1586 encoder << static_cast<uint64_t>(data.size());
1587 for (auto& buffer : data)
1588 encodeSharedBuffer(encoder, buffer.get());
1591 static bool decodeClientTypesAndData(Decoder& decoder, Vector<String>& types, Vector<RefPtr<SharedBuffer>>& data)
1593 if (!decoder.decode(types))
1597 if (!decoder.decode(dataSize))
1600 ASSERT(dataSize == types.size());
1602 data.resize(dataSize);
1603 for (auto& buffer : data)
1604 decodeSharedBuffer(decoder, buffer);
1609 void ArgumentCoder<PasteboardWebContent>::encode(Encoder& encoder, const PasteboardWebContent& content)
1611 encoder << content.canSmartCopyOrDelete;
1612 encoder << content.dataInStringFormat;
1614 encodeSharedBuffer(encoder, content.dataInWebArchiveFormat.get());
1615 encodeSharedBuffer(encoder, content.dataInRTFDFormat.get());
1616 encodeSharedBuffer(encoder, content.dataInRTFFormat.get());
1617 encodeSharedBuffer(encoder, content.dataInAttributedStringFormat.get());
1619 encodeClientTypesAndData(encoder, content.clientTypes, content.clientData);
1622 bool ArgumentCoder<PasteboardWebContent>::decode(Decoder& decoder, PasteboardWebContent& content)
1624 if (!decoder.decode(content.canSmartCopyOrDelete))
1626 if (!decoder.decode(content.dataInStringFormat))
1628 if (!decodeSharedBuffer(decoder, content.dataInWebArchiveFormat))
1630 if (!decodeSharedBuffer(decoder, content.dataInRTFDFormat))
1632 if (!decodeSharedBuffer(decoder, content.dataInRTFFormat))
1634 if (!decodeSharedBuffer(decoder, content.dataInAttributedStringFormat))
1636 if (!decodeClientTypesAndData(decoder, content.clientTypes, content.clientData))
1641 void ArgumentCoder<PasteboardImage>::encode(Encoder& encoder, const PasteboardImage& pasteboardImage)
1643 encodeOptionalImage(encoder, pasteboardImage.image.get());
1644 encoder << pasteboardImage.url.url;
1645 encoder << pasteboardImage.url.title;
1646 encoder << pasteboardImage.resourceMIMEType;
1647 encoder << pasteboardImage.suggestedName;
1648 encoder << pasteboardImage.imageSize;
1649 if (pasteboardImage.resourceData)
1650 encodeSharedBuffer(encoder, pasteboardImage.resourceData.get());
1651 encodeClientTypesAndData(encoder, pasteboardImage.clientTypes, pasteboardImage.clientData);
1654 bool ArgumentCoder<PasteboardImage>::decode(Decoder& decoder, PasteboardImage& pasteboardImage)
1656 if (!decodeOptionalImage(decoder, pasteboardImage.image))
1658 if (!decoder.decode(pasteboardImage.url.url))
1660 if (!decoder.decode(pasteboardImage.url.title))
1662 if (!decoder.decode(pasteboardImage.resourceMIMEType))
1664 if (!decoder.decode(pasteboardImage.suggestedName))
1666 if (!decoder.decode(pasteboardImage.imageSize))
1668 if (!decodeSharedBuffer(decoder, pasteboardImage.resourceData))
1670 if (!decodeClientTypesAndData(decoder, pasteboardImage.clientTypes, pasteboardImage.clientData))
1678 void ArgumentCoder<PasteboardWebContent>::encode(Encoder& encoder, const PasteboardWebContent& content)
1680 encoder << content.text;
1681 encoder << content.markup;
1684 bool ArgumentCoder<PasteboardWebContent>::decode(Decoder& decoder, PasteboardWebContent& content)
1686 if (!decoder.decode(content.text))
1688 if (!decoder.decode(content.markup))
1692 #endif // PLATFORM(WPE)
1694 void ArgumentCoder<DictationAlternative>::encode(Encoder& encoder, const DictationAlternative& dictationAlternative)
1696 encoder << dictationAlternative.rangeStart;
1697 encoder << dictationAlternative.rangeLength;
1698 encoder << dictationAlternative.dictationContext;
1701 bool ArgumentCoder<DictationAlternative>::decode(Decoder& decoder, DictationAlternative& dictationAlternative)
1703 if (!decoder.decode(dictationAlternative.rangeStart))
1705 if (!decoder.decode(dictationAlternative.rangeLength))
1707 if (!decoder.decode(dictationAlternative.dictationContext))
1713 void ArgumentCoder<FileChooserSettings>::encode(Encoder& encoder, const FileChooserSettings& settings)
1715 encoder << settings.allowsMultipleFiles;
1716 encoder << settings.acceptMIMETypes;
1717 encoder << settings.acceptFileExtensions;
1718 encoder << settings.selectedFiles;
1719 #if ENABLE(MEDIA_CAPTURE)
1720 encoder.encodeEnum(settings.mediaCaptureType);
1724 bool ArgumentCoder<FileChooserSettings>::decode(Decoder& decoder, FileChooserSettings& settings)
1726 if (!decoder.decode(settings.allowsMultipleFiles))
1728 if (!decoder.decode(settings.acceptMIMETypes))
1730 if (!decoder.decode(settings.acceptFileExtensions))
1732 if (!decoder.decode(settings.selectedFiles))
1734 #if ENABLE(MEDIA_CAPTURE)
1735 if (!decoder.decodeEnum(settings.mediaCaptureType))
1743 void ArgumentCoder<GrammarDetail>::encode(Encoder& encoder, const GrammarDetail& detail)
1745 encoder << detail.location;
1746 encoder << detail.length;
1747 encoder << detail.guesses;
1748 encoder << detail.userDescription;
1751 bool ArgumentCoder<GrammarDetail>::decode(Decoder& decoder, GrammarDetail& detail)
1753 if (!decoder.decode(detail.location))
1755 if (!decoder.decode(detail.length))
1757 if (!decoder.decode(detail.guesses))
1759 if (!decoder.decode(detail.userDescription))
1765 void ArgumentCoder<TextCheckingRequestData>::encode(Encoder& encoder, const TextCheckingRequestData& request)
1767 encoder << request.sequence();
1768 encoder << request.text();
1769 encoder << request.mask();
1770 encoder.encodeEnum(request.processType());
1773 bool ArgumentCoder<TextCheckingRequestData>::decode(Decoder& decoder, TextCheckingRequestData& request)
1776 if (!decoder.decode(sequence))
1780 if (!decoder.decode(text))
1783 TextCheckingTypeMask mask;
1784 if (!decoder.decode(mask))
1787 TextCheckingProcessType processType;
1788 if (!decoder.decodeEnum(processType))
1791 request = TextCheckingRequestData(sequence, text, mask, processType);
1795 void ArgumentCoder<TextCheckingResult>::encode(Encoder& encoder, const TextCheckingResult& result)
1797 encoder.encodeEnum(result.type);
1798 encoder << result.location;
1799 encoder << result.length;
1800 encoder << result.details;
1801 encoder << result.replacement;
1804 bool ArgumentCoder<TextCheckingResult>::decode(Decoder& decoder, TextCheckingResult& result)
1806 if (!decoder.decodeEnum(result.type))
1808 if (!decoder.decode(result.location))
1810 if (!decoder.decode(result.length))
1812 if (!decoder.decode(result.details))
1814 if (!decoder.decode(result.replacement))
1819 void ArgumentCoder<URL>::encode(Encoder& encoder, const URL& result)
1821 encoder << result.string();
1824 bool ArgumentCoder<URL>::decode(Decoder& decoder, URL& result)
1827 if (!decoder.decode(urlAsString))
1829 result = URL(ParsedURLString, urlAsString);
1833 void ArgumentCoder<UserStyleSheet>::encode(Encoder& encoder, const UserStyleSheet& userStyleSheet)
1835 encoder << userStyleSheet.source();
1836 encoder << userStyleSheet.url();
1837 encoder << userStyleSheet.whitelist();
1838 encoder << userStyleSheet.blacklist();
1839 encoder.encodeEnum(userStyleSheet.injectedFrames());
1840 encoder.encodeEnum(userStyleSheet.level());
1843 bool ArgumentCoder<UserStyleSheet>::decode(Decoder& decoder, UserStyleSheet& userStyleSheet)
1846 if (!decoder.decode(source))
1850 if (!decoder.decode(url))
1853 Vector<String> whitelist;
1854 if (!decoder.decode(whitelist))
1857 Vector<String> blacklist;
1858 if (!decoder.decode(blacklist))
1861 UserContentInjectedFrames injectedFrames;
1862 if (!decoder.decodeEnum(injectedFrames))
1865 UserStyleLevel level;
1866 if (!decoder.decodeEnum(level))
1869 userStyleSheet = UserStyleSheet(source, url, WTFMove(whitelist), WTFMove(blacklist), injectedFrames, level);
1873 #if ENABLE(MEDIA_SESSION)
1874 void ArgumentCoder<MediaSessionMetadata>::encode(Encoder& encoder, const MediaSessionMetadata& result)
1876 encoder << result.artist();
1877 encoder << result.album();
1878 encoder << result.title();
1879 encoder << result.artworkURL();
1882 bool ArgumentCoder<MediaSessionMetadata>::decode(Decoder& decoder, MediaSessionMetadata& result)
1884 String artist, album, title;
1886 if (!decoder.decode(artist))
1888 if (!decoder.decode(album))
1890 if (!decoder.decode(title))
1892 if (!decoder.decode(artworkURL))
1894 result = MediaSessionMetadata(title, artist, album, artworkURL);
1899 void ArgumentCoder<ScrollableAreaParameters>::encode(Encoder& encoder, const ScrollableAreaParameters& parameters)
1901 encoder.encodeEnum(parameters.horizontalScrollElasticity);
1902 encoder.encodeEnum(parameters.verticalScrollElasticity);
1904 encoder.encodeEnum(parameters.horizontalScrollbarMode);
1905 encoder.encodeEnum(parameters.verticalScrollbarMode);
1907 encoder << parameters.hasEnabledHorizontalScrollbar;
1908 encoder << parameters.hasEnabledVerticalScrollbar;
1911 bool ArgumentCoder<ScrollableAreaParameters>::decode(Decoder& decoder, ScrollableAreaParameters& params)
1913 if (!decoder.decodeEnum(params.horizontalScrollElasticity))
1915 if (!decoder.decodeEnum(params.verticalScrollElasticity))
1918 if (!decoder.decodeEnum(params.horizontalScrollbarMode))
1920 if (!decoder.decodeEnum(params.verticalScrollbarMode))
1923 if (!decoder.decode(params.hasEnabledHorizontalScrollbar))
1925 if (!decoder.decode(params.hasEnabledVerticalScrollbar))
1931 void ArgumentCoder<FixedPositionViewportConstraints>::encode(Encoder& encoder, const FixedPositionViewportConstraints& viewportConstraints)
1933 encoder << viewportConstraints.alignmentOffset();
1934 encoder << viewportConstraints.anchorEdges();
1936 encoder << viewportConstraints.viewportRectAtLastLayout();
1937 encoder << viewportConstraints.layerPositionAtLastLayout();
1940 bool ArgumentCoder<FixedPositionViewportConstraints>::decode(Decoder& decoder, FixedPositionViewportConstraints& viewportConstraints)
1942 FloatSize alignmentOffset;
1943 if (!decoder.decode(alignmentOffset))
1946 ViewportConstraints::AnchorEdges anchorEdges;
1947 if (!decoder.decode(anchorEdges))
1950 FloatRect viewportRectAtLastLayout;
1951 if (!decoder.decode(viewportRectAtLastLayout))
1954 FloatPoint layerPositionAtLastLayout;
1955 if (!decoder.decode(layerPositionAtLastLayout))
1958 viewportConstraints = FixedPositionViewportConstraints();
1959 viewportConstraints.setAlignmentOffset(alignmentOffset);
1960 viewportConstraints.setAnchorEdges(anchorEdges);
1962 viewportConstraints.setViewportRectAtLastLayout(viewportRectAtLastLayout);
1963 viewportConstraints.setLayerPositionAtLastLayout(layerPositionAtLastLayout);
1968 void ArgumentCoder<StickyPositionViewportConstraints>::encode(Encoder& encoder, const StickyPositionViewportConstraints& viewportConstraints)
1970 encoder << viewportConstraints.alignmentOffset();
1971 encoder << viewportConstraints.anchorEdges();
1973 encoder << viewportConstraints.leftOffset();
1974 encoder << viewportConstraints.rightOffset();
1975 encoder << viewportConstraints.topOffset();
1976 encoder << viewportConstraints.bottomOffset();
1978 encoder << viewportConstraints.constrainingRectAtLastLayout();
1979 encoder << viewportConstraints.containingBlockRect();
1980 encoder << viewportConstraints.stickyBoxRect();
1982 encoder << viewportConstraints.stickyOffsetAtLastLayout();
1983 encoder << viewportConstraints.layerPositionAtLastLayout();
1986 bool ArgumentCoder<StickyPositionViewportConstraints>::decode(Decoder& decoder, StickyPositionViewportConstraints& viewportConstraints)
1988 FloatSize alignmentOffset;
1989 if (!decoder.decode(alignmentOffset))
1992 ViewportConstraints::AnchorEdges anchorEdges;
1993 if (!decoder.decode(anchorEdges))
1997 if (!decoder.decode(leftOffset))
2001 if (!decoder.decode(rightOffset))
2005 if (!decoder.decode(topOffset))
2009 if (!decoder.decode(bottomOffset))
2012 FloatRect constrainingRectAtLastLayout;
2013 if (!decoder.decode(constrainingRectAtLastLayout))
2016 FloatRect containingBlockRect;
2017 if (!decoder.decode(containingBlockRect))
2020 FloatRect stickyBoxRect;
2021 if (!decoder.decode(stickyBoxRect))
2024 FloatSize stickyOffsetAtLastLayout;
2025 if (!decoder.decode(stickyOffsetAtLastLayout))
2028 FloatPoint layerPositionAtLastLayout;
2029 if (!decoder.decode(layerPositionAtLastLayout))
2032 viewportConstraints = StickyPositionViewportConstraints();
2033 viewportConstraints.setAlignmentOffset(alignmentOffset);
2034 viewportConstraints.setAnchorEdges(anchorEdges);
2036 viewportConstraints.setLeftOffset(leftOffset);
2037 viewportConstraints.setRightOffset(rightOffset);
2038 viewportConstraints.setTopOffset(topOffset);
2039 viewportConstraints.setBottomOffset(bottomOffset);
2041 viewportConstraints.setConstrainingRectAtLastLayout(constrainingRectAtLastLayout);
2042 viewportConstraints.setContainingBlockRect(containingBlockRect);
2043 viewportConstraints.setStickyBoxRect(stickyBoxRect);
2045 viewportConstraints.setStickyOffsetAtLastLayout(stickyOffsetAtLastLayout);
2046 viewportConstraints.setLayerPositionAtLastLayout(layerPositionAtLastLayout);
2051 #if !USE(COORDINATED_GRAPHICS)
2052 void ArgumentCoder<FilterOperation>::encode(Encoder& encoder, const FilterOperation& filter)
2054 encoder.encodeEnum(filter.type());
2056 switch (filter.type()) {
2057 case FilterOperation::NONE:
2058 case FilterOperation::REFERENCE:
2059 ASSERT_NOT_REACHED();
2061 case FilterOperation::GRAYSCALE:
2062 case FilterOperation::SEPIA:
2063 case FilterOperation::SATURATE:
2064 case FilterOperation::HUE_ROTATE:
2065 encoder << downcast<BasicColorMatrixFilterOperation>(filter).amount();
2067 case FilterOperation::INVERT:
2068 case FilterOperation::OPACITY:
2069 case FilterOperation::BRIGHTNESS:
2070 case FilterOperation::CONTRAST:
2071 encoder << downcast<BasicComponentTransferFilterOperation>(filter).amount();
2073 case FilterOperation::BLUR:
2074 encoder << downcast<BlurFilterOperation>(filter).stdDeviation();
2076 case FilterOperation::DROP_SHADOW: {
2077 const auto& dropShadowFilter = downcast<DropShadowFilterOperation>(filter);
2078 encoder << dropShadowFilter.location();
2079 encoder << dropShadowFilter.stdDeviation();
2080 encoder << dropShadowFilter.color();
2083 case FilterOperation::DEFAULT:
2084 encoder.encodeEnum(downcast<DefaultFilterOperation>(filter).representedType());
2086 case FilterOperation::PASSTHROUGH:
2091 bool decodeFilterOperation(Decoder& decoder, RefPtr<FilterOperation>& filter)
2093 FilterOperation::OperationType type;
2094 if (!decoder.decodeEnum(type))
2098 case FilterOperation::NONE:
2099 case FilterOperation::REFERENCE:
2100 ASSERT_NOT_REACHED();
2101 decoder.markInvalid();
2103 case FilterOperation::GRAYSCALE:
2104 case FilterOperation::SEPIA:
2105 case FilterOperation::SATURATE:
2106 case FilterOperation::HUE_ROTATE: {
2108 if (!decoder.decode(amount))
2110 filter = BasicColorMatrixFilterOperation::create(amount, type);
2113 case FilterOperation::INVERT:
2114 case FilterOperation::OPACITY:
2115 case FilterOperation::BRIGHTNESS:
2116 case FilterOperation::CONTRAST: {
2118 if (!decoder.decode(amount))
2120 filter = BasicComponentTransferFilterOperation::create(amount, type);
2123 case FilterOperation::BLUR: {
2124 Length stdDeviation;
2125 if (!decoder.decode(stdDeviation))
2127 filter = BlurFilterOperation::create(stdDeviation);
2130 case FilterOperation::DROP_SHADOW: {
2134 if (!decoder.decode(location))
2136 if (!decoder.decode(stdDeviation))
2138 if (!decoder.decode(color))
2140 filter = DropShadowFilterOperation::create(location, stdDeviation, color);
2143 case FilterOperation::DEFAULT: {
2144 FilterOperation::OperationType representedType;
2145 if (!decoder.decodeEnum(representedType))
2147 filter = DefaultFilterOperation::create(representedType);
2150 case FilterOperation::PASSTHROUGH:
2151 filter = PassthroughFilterOperation::create();
2159 void ArgumentCoder<FilterOperations>::encode(Encoder& encoder, const FilterOperations& filters)
2161 encoder << static_cast<uint64_t>(filters.size());
2163 for (const auto& filter : filters.operations())
2167 bool ArgumentCoder<FilterOperations>::decode(Decoder& decoder, FilterOperations& filters)
2169 uint64_t filterCount;
2170 if (!decoder.decode(filterCount))
2173 for (uint64_t i = 0; i < filterCount; ++i) {
2174 RefPtr<FilterOperation> filter;
2175 if (!decodeFilterOperation(decoder, filter))
2177 filters.operations().append(WTFMove(filter));
2182 #endif // !USE(COORDINATED_GRAPHICS)
2184 void ArgumentCoder<BlobPart>::encode(Encoder& encoder, const BlobPart& blobPart)
2186 encoder << static_cast<uint32_t>(blobPart.type());
2187 switch (blobPart.type()) {
2188 case BlobPart::Data:
2189 encoder << blobPart.data();
2191 case BlobPart::Blob:
2192 encoder << blobPart.url();
2197 bool ArgumentCoder<BlobPart>::decode(Decoder& decoder, BlobPart& blobPart)
2200 if (!decoder.decode(type))
2204 case BlobPart::Data: {
2205 Vector<uint8_t> data;
2206 if (!decoder.decode(data))
2208 blobPart = BlobPart(WTFMove(data));
2211 case BlobPart::Blob: {
2213 if (!decoder.decode(url))
2215 blobPart = BlobPart(url);
2225 void ArgumentCoder<TextIndicatorData>::encode(Encoder& encoder, const TextIndicatorData& textIndicatorData)
2227 encoder << textIndicatorData.selectionRectInRootViewCoordinates;
2228 encoder << textIndicatorData.textBoundingRectInRootViewCoordinates;
2229 encoder << textIndicatorData.textRectsInBoundingRectCoordinates;
2230 encoder << textIndicatorData.contentImageWithoutSelectionRectInRootViewCoordinates;
2231 encoder << textIndicatorData.contentImageScaleFactor;
2232 encoder << textIndicatorData.estimatedBackgroundColor;
2233 encoder.encodeEnum(textIndicatorData.presentationTransition);
2234 encoder << static_cast<uint64_t>(textIndicatorData.options);
2236 encodeOptionalImage(encoder, textIndicatorData.contentImage.get());
2237 encodeOptionalImage(encoder, textIndicatorData.contentImageWithHighlight.get());
2238 encodeOptionalImage(encoder, textIndicatorData.contentImageWithoutSelection.get());
2241 bool ArgumentCoder<TextIndicatorData>::decode(Decoder& decoder, TextIndicatorData& textIndicatorData)
2243 if (!decoder.decode(textIndicatorData.selectionRectInRootViewCoordinates))
2246 if (!decoder.decode(textIndicatorData.textBoundingRectInRootViewCoordinates))
2249 if (!decoder.decode(textIndicatorData.textRectsInBoundingRectCoordinates))
2252 if (!decoder.decode(textIndicatorData.contentImageWithoutSelectionRectInRootViewCoordinates))
2255 if (!decoder.decode(textIndicatorData.contentImageScaleFactor))
2258 if (!decoder.decode(textIndicatorData.estimatedBackgroundColor))
2261 if (!decoder.decodeEnum(textIndicatorData.presentationTransition))
2265 if (!decoder.decode(options))
2267 textIndicatorData.options = static_cast<TextIndicatorOptions>(options);
2269 if (!decodeOptionalImage(decoder, textIndicatorData.contentImage))
2272 if (!decodeOptionalImage(decoder, textIndicatorData.contentImageWithHighlight))
2275 if (!decodeOptionalImage(decoder, textIndicatorData.contentImageWithoutSelection))
2281 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
2282 void ArgumentCoder<MediaPlaybackTargetContext>::encode(Encoder& encoder, const MediaPlaybackTargetContext& target)
2284 bool hasPlatformData = target.encodingRequiresPlatformData();
2285 encoder << hasPlatformData;
2287 int32_t targetType = target.type();
2288 encoder << targetType;
2290 if (target.encodingRequiresPlatformData()) {
2291 encodePlatformData(encoder, target);
2295 ASSERT(targetType == MediaPlaybackTargetContext::MockType);
2296 encoder << target.mockDeviceName();
2297 encoder << static_cast<int32_t>(target.mockState());
2300 bool ArgumentCoder<MediaPlaybackTargetContext>::decode(Decoder& decoder, MediaPlaybackTargetContext& target)
2302 bool hasPlatformData;
2303 if (!decoder.decode(hasPlatformData))
2307 if (!decoder.decode(targetType))
2310 if (hasPlatformData)
2311 return decodePlatformData(decoder, target);
2313 ASSERT(targetType == MediaPlaybackTargetContext::MockType);
2315 String mockDeviceName;
2316 if (!decoder.decode(mockDeviceName))
2320 if (!decoder.decode(mockState))
2323 target = MediaPlaybackTargetContext(mockDeviceName, static_cast<MediaPlaybackTargetContext::State>(mockState));
2328 void ArgumentCoder<DictionaryPopupInfo>::encode(IPC::Encoder& encoder, const DictionaryPopupInfo& info)
2330 encoder << info.origin;
2331 encoder << info.textIndicator;
2334 bool hadOptions = info.options;
2335 encoder << hadOptions;
2337 IPC::encode(encoder, info.options.get());
2339 bool hadAttributedString = info.attributedString;
2340 encoder << hadAttributedString;
2341 if (hadAttributedString)
2342 IPC::encode(encoder, info.attributedString.get());
2346 bool ArgumentCoder<DictionaryPopupInfo>::decode(IPC::Decoder& decoder, DictionaryPopupInfo& result)
2348 if (!decoder.decode(result.origin))
2351 if (!decoder.decode(result.textIndicator))
2356 if (!decoder.decode(hadOptions))
2359 if (!IPC::decode(decoder, result.options))
2362 result.options = nullptr;
2364 bool hadAttributedString;
2365 if (!decoder.decode(hadAttributedString))
2367 if (hadAttributedString) {
2368 if (!IPC::decode(decoder, result.attributedString))
2371 result.attributedString = nullptr;
2376 void ArgumentCoder<ExceptionDetails>::encode(IPC::Encoder& encoder, const ExceptionDetails& info)
2378 encoder << info.message;
2379 encoder << info.lineNumber;
2380 encoder << info.columnNumber;
2381 encoder << info.sourceURL;
2384 bool ArgumentCoder<ExceptionDetails>::decode(IPC::Decoder& decoder, ExceptionDetails& result)
2386 if (!decoder.decode(result.message))
2389 if (!decoder.decode(result.lineNumber))
2392 if (!decoder.decode(result.columnNumber))
2395 if (!decoder.decode(result.sourceURL))
2401 void ArgumentCoder<ResourceLoadStatistics>::encode(Encoder& encoder, const WebCore::ResourceLoadStatistics& statistics)
2403 encoder << statistics.highLevelDomain;
2405 encoder << statistics.lastSeen.secondsSinceEpoch().value();
2408 encoder << statistics.hadUserInteraction;
2409 encoder << statistics.mostRecentUserInteractionTime.secondsSinceEpoch().value();
2410 encoder << statistics.grandfathered;
2413 encoder << statistics.subframeUnderTopFrameOrigins;
2415 // Subresource stats
2416 encoder << statistics.subresourceUnderTopFrameOrigins;
2417 encoder << statistics.subresourceUniqueRedirectsTo;
2419 // Prevalent Resource
2420 encoder << statistics.isPrevalentResource;
2421 encoder << statistics.dataRecordsRemoved;
2424 bool ArgumentCoder<ResourceLoadStatistics>::decode(Decoder& decoder, WebCore::ResourceLoadStatistics& statistics)
2426 if (!decoder.decode(statistics.highLevelDomain))
2429 double lastSeenTimeAsDouble;
2430 if (!decoder.decode(lastSeenTimeAsDouble))
2432 statistics.lastSeen = WallTime::fromRawSeconds(lastSeenTimeAsDouble);
2435 if (!decoder.decode(statistics.hadUserInteraction))
2438 double mostRecentUserInteractionTimeAsDouble;
2439 if (!decoder.decode(mostRecentUserInteractionTimeAsDouble))
2441 statistics.mostRecentUserInteractionTime = WallTime::fromRawSeconds(mostRecentUserInteractionTimeAsDouble);
2443 if (!decoder.decode(statistics.grandfathered))
2447 if (!decoder.decode(statistics.subframeUnderTopFrameOrigins))
2450 // Subresource stats
2451 if (!decoder.decode(statistics.subresourceUnderTopFrameOrigins))
2454 if (!decoder.decode(statistics.subresourceUniqueRedirectsTo))
2457 // Prevalent Resource
2458 if (!decoder.decode(statistics.isPrevalentResource))
2461 if (!decoder.decode(statistics.dataRecordsRemoved))
2467 #if ENABLE(MEDIA_STREAM)
2468 void ArgumentCoder<MediaConstraints>::encode(Encoder& encoder, const WebCore::MediaConstraints& constraint)
2470 encoder << constraint.mandatoryConstraints
2471 << constraint.advancedConstraints
2472 << constraint.deviceIDHashSalt
2473 << constraint.isValid;
2476 bool ArgumentCoder<MediaConstraints>::decode(Decoder& decoder, WebCore::MediaConstraints& constraints)
2478 return decoder.decode(constraints.mandatoryConstraints)
2479 && decoder.decode(constraints.advancedConstraints)
2480 && decoder.decode(constraints.deviceIDHashSalt)
2481 && decoder.decode(constraints.isValid);
2484 void ArgumentCoder<CaptureDevice>::encode(Encoder& encoder, const WebCore::CaptureDevice& device)
2486 encoder << device.persistentId();
2487 encoder << device.label();
2488 encoder << device.groupId();
2489 encoder << device.enabled();
2490 encoder.encodeEnum(device.type());
2493 bool ArgumentCoder<CaptureDevice>::decode(Decoder& decoder, WebCore::CaptureDevice& device)
2495 String persistentId;
2496 if (!decoder.decode(persistentId))
2500 if (!decoder.decode(label))
2504 if (!decoder.decode(groupId))
2508 if (!decoder.decode(enabled))
2511 CaptureDevice::DeviceType type;
2512 if (!decoder.decodeEnum(type))
2515 device.setPersistentId(persistentId);
2516 device.setLabel(label);
2517 device.setGroupId(groupId);
2518 device.setType(type);
2519 device.setEnabled(enabled);
2525 #if ENABLE(INDEXED_DATABASE)
2526 void ArgumentCoder<IDBKeyPath>::encode(Encoder& encoder, const IDBKeyPath& keyPath)
2528 bool isString = WTF::holds_alternative<String>(keyPath);
2529 encoder << isString;
2531 encoder << WTF::get<String>(keyPath);
2533 encoder << WTF::get<Vector<String>>(keyPath);
2536 bool ArgumentCoder<IDBKeyPath>::decode(Decoder& decoder, IDBKeyPath& keyPath)
2539 if (!decoder.decode(isString))
2543 if (!decoder.decode(string))
2547 Vector<String> vector;
2548 if (!decoder.decode(vector))
2556 #if ENABLE(CSS_SCROLL_SNAP)
2558 void ArgumentCoder<ScrollOffsetRange<float>>::encode(Encoder& encoder, const ScrollOffsetRange<float>& range)
2560 encoder << range.start;
2561 encoder << range.end;
2564 bool ArgumentCoder<ScrollOffsetRange<float>>::decode(Decoder& decoder, ScrollOffsetRange<float>& range)
2567 if (!decoder.decode(start))
2571 if (!decoder.decode(end))
2574 range.start = start;
2581 void ArgumentCoder<MediaSelectionOption>::encode(Encoder& encoder, const MediaSelectionOption& option)
2583 encoder << option.displayName;
2584 encoder << option.type;
2587 bool ArgumentCoder<MediaSelectionOption>::decode(Decoder& decoder, MediaSelectionOption& option)
2589 if (!decoder.decode(option.displayName))
2592 if (!decoder.decode(option.type))