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/Pasteboard.h>
56 #include <WebCore/Path.h>
57 #include <WebCore/PluginData.h>
58 #include <WebCore/PromisedBlobInfo.h>
59 #include <WebCore/ProtectionSpace.h>
60 #include <WebCore/RectEdges.h>
61 #include <WebCore/Region.h>
62 #include <WebCore/ResourceError.h>
63 #include <WebCore/ResourceLoadStatistics.h>
64 #include <WebCore/ResourceRequest.h>
65 #include <WebCore/ResourceResponse.h>
66 #include <WebCore/ScrollingConstraints.h>
67 #include <WebCore/ScrollingCoordinator.h>
68 #include <WebCore/SearchPopupMenu.h>
69 #include <WebCore/ServiceWorkerClientData.h>
70 #include <WebCore/ServiceWorkerClientIdentifier.h>
71 #include <WebCore/ServiceWorkerData.h>
72 #include <WebCore/TextCheckerClient.h>
73 #include <WebCore/TextIndicator.h>
74 #include <WebCore/TimingFunction.h>
75 #include <WebCore/TransformationMatrix.h>
76 #include <WebCore/URL.h>
77 #include <WebCore/UserStyleSheet.h>
78 #include <WebCore/ViewportArguments.h>
79 #include <WebCore/WindowFeatures.h>
80 #include <pal/SessionID.h>
81 #include <wtf/MonotonicTime.h>
82 #include <wtf/Seconds.h>
83 #include <wtf/text/CString.h>
84 #include <wtf/text/StringHash.h>
87 #include "ArgumentCodersCF.h"
88 #include "ArgumentCodersMac.h"
92 #include <WebCore/FloatQuad.h>
93 #include <WebCore/InspectorOverlay.h>
94 #include <WebCore/SelectionRect.h>
95 #include <WebCore/SharedBuffer.h>
96 #endif // PLATFORM(IOS)
98 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
99 #include <WebCore/MediaPlaybackTargetContext.h>
102 #if ENABLE(MEDIA_SESSION)
103 #include <WebCore/MediaSessionMetadata.h>
106 #if ENABLE(MEDIA_STREAM)
107 #include <WebCore/CaptureDevice.h>
108 #include <WebCore/MediaConstraints.h>
111 using namespace WebCore;
112 using namespace WebKit;
116 static void encodeSharedBuffer(Encoder& encoder, const SharedBuffer* buffer)
118 SharedMemory::Handle handle;
119 uint64_t bufferSize = buffer ? buffer->size() : 0;
120 encoder << bufferSize;
124 auto sharedMemoryBuffer = SharedMemory::allocate(buffer->size());
125 memcpy(sharedMemoryBuffer->data(), buffer->data(), buffer->size());
126 sharedMemoryBuffer->createHandle(handle, SharedMemory::Protection::ReadOnly);
130 static bool decodeSharedBuffer(Decoder& decoder, RefPtr<SharedBuffer>& buffer)
132 uint64_t bufferSize = 0;
133 if (!decoder.decode(bufferSize))
139 SharedMemory::Handle handle;
140 if (!decoder.decode(handle))
143 auto sharedMemoryBuffer = SharedMemory::map(handle, SharedMemory::Protection::ReadOnly);
144 buffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryBuffer->data()), bufferSize);
149 static void encodeTypesAndData(Encoder& encoder, const Vector<String>& types, const Vector<RefPtr<SharedBuffer>>& data)
151 ASSERT(types.size() == data.size());
153 encoder << static_cast<uint64_t>(data.size());
154 for (auto& buffer : data)
155 encodeSharedBuffer(encoder, buffer.get());
158 static bool decodeTypesAndData(Decoder& decoder, Vector<String>& types, Vector<RefPtr<SharedBuffer>>& data)
160 if (!decoder.decode(types))
164 if (!decoder.decode(dataSize))
167 ASSERT(dataSize == types.size());
169 data.resize(dataSize);
170 for (auto& buffer : data)
171 decodeSharedBuffer(decoder, buffer);
176 void ArgumentCoder<MonotonicTime>::encode(Encoder& encoder, const MonotonicTime& time)
178 encoder << time.secondsSinceEpoch().value();
181 bool ArgumentCoder<MonotonicTime>::decode(Decoder& decoder, MonotonicTime& time)
184 if (!decoder.decode(value))
187 time = MonotonicTime::fromRawSeconds(value);
191 void ArgumentCoder<Seconds>::encode(Encoder& encoder, const Seconds& seconds)
193 encoder << seconds.value();
196 bool ArgumentCoder<Seconds>::decode(Decoder& decoder, Seconds& seconds)
199 if (!decoder.decode(value))
202 seconds = Seconds(value);
206 void ArgumentCoder<AffineTransform>::encode(Encoder& encoder, const AffineTransform& affineTransform)
208 SimpleArgumentCoder<AffineTransform>::encode(encoder, affineTransform);
211 bool ArgumentCoder<AffineTransform>::decode(Decoder& decoder, AffineTransform& affineTransform)
213 return SimpleArgumentCoder<AffineTransform>::decode(decoder, affineTransform);
216 void ArgumentCoder<CacheQueryOptions>::encode(Encoder& encoder, const CacheQueryOptions& options)
218 encoder << options.ignoreSearch;
219 encoder << options.ignoreMethod;
220 encoder << options.ignoreVary;
221 encoder << options.cacheName;
224 bool ArgumentCoder<CacheQueryOptions>::decode(Decoder& decoder, CacheQueryOptions& options)
227 if (!decoder.decode(ignoreSearch))
230 if (!decoder.decode(ignoreMethod))
233 if (!decoder.decode(ignoreVary))
236 if (!decoder.decode(cacheName))
239 options.ignoreSearch = ignoreSearch;
240 options.ignoreMethod = ignoreMethod;
241 options.ignoreVary = ignoreVary;
242 options.cacheName = WTFMove(cacheName);
246 void ArgumentCoder<DOMCacheEngine::CacheInfo>::encode(Encoder& encoder, const DOMCacheEngine::CacheInfo& info)
248 encoder << info.identifier;
249 encoder << info.name;
252 auto ArgumentCoder<DOMCacheEngine::CacheInfo>::decode(Decoder& decoder) -> std::optional<DOMCacheEngine::CacheInfo>
254 std::optional<uint64_t> identifier;
255 decoder >> identifier;
259 std::optional<String> name;
264 return {{ WTFMove(*identifier), WTFMove(*name) }};
267 void ArgumentCoder<DOMCacheEngine::Record>::encode(Encoder& encoder, const DOMCacheEngine::Record& record)
269 encoder << record.identifier;
271 encoder << record.requestHeadersGuard;
272 encoder << record.request;
273 encoder << record.options;
274 encoder << record.referrer;
276 encoder << record.responseHeadersGuard;
277 encoder << record.response;
278 encoder << record.updateResponseCounter;
279 encoder << record.responseBodySize;
281 WTF::switchOn(record.responseBody, [&](const Ref<SharedBuffer>& buffer) {
283 encodeSharedBuffer(encoder, buffer.ptr());
284 }, [&](const Ref<FormData>& formData) {
287 formData->encode(encoder);
288 }, [&](const std::nullptr_t&) {
294 std::optional<DOMCacheEngine::Record> ArgumentCoder<DOMCacheEngine::Record>::decode(Decoder& decoder)
297 if (!decoder.decode(identifier))
300 FetchHeaders::Guard requestHeadersGuard;
301 if (!decoder.decode(requestHeadersGuard))
304 WebCore::ResourceRequest request;
305 if (!decoder.decode(request))
308 std::optional<WebCore::FetchOptions> options;
314 if (!decoder.decode(referrer))
317 FetchHeaders::Guard responseHeadersGuard;
318 if (!decoder.decode(responseHeadersGuard))
321 WebCore::ResourceResponse response;
322 if (!decoder.decode(response))
325 uint64_t updateResponseCounter;
326 if (!decoder.decode(updateResponseCounter))
329 uint64_t responseBodySize;
330 if (!decoder.decode(responseBodySize))
333 WebCore::DOMCacheEngine::ResponseBody responseBody;
334 bool hasSharedBufferBody;
335 if (!decoder.decode(hasSharedBufferBody))
338 if (hasSharedBufferBody) {
339 RefPtr<SharedBuffer> buffer;
340 if (!decodeSharedBuffer(decoder, buffer))
343 responseBody = buffer.releaseNonNull();
345 bool hasFormDataBody;
346 if (!decoder.decode(hasFormDataBody))
348 if (hasFormDataBody) {
349 auto formData = FormData::decode(decoder);
352 responseBody = formData.releaseNonNull();
356 return {{ WTFMove(identifier), WTFMove(updateResponseCounter), WTFMove(requestHeadersGuard), WTFMove(request), WTFMove(options.value()), WTFMove(referrer), WTFMove(responseHeadersGuard), WTFMove(response), WTFMove(responseBody), responseBodySize }};
359 void ArgumentCoder<EventTrackingRegions>::encode(Encoder& encoder, const EventTrackingRegions& eventTrackingRegions)
361 encoder << eventTrackingRegions.asynchronousDispatchRegion;
362 encoder << eventTrackingRegions.eventSpecificSynchronousDispatchRegions;
365 bool ArgumentCoder<EventTrackingRegions>::decode(Decoder& decoder, EventTrackingRegions& eventTrackingRegions)
367 Region asynchronousDispatchRegion;
368 if (!decoder.decode(asynchronousDispatchRegion))
370 HashMap<String, Region> eventSpecificSynchronousDispatchRegions;
371 if (!decoder.decode(eventSpecificSynchronousDispatchRegions))
373 eventTrackingRegions.asynchronousDispatchRegion = WTFMove(asynchronousDispatchRegion);
374 eventTrackingRegions.eventSpecificSynchronousDispatchRegions = WTFMove(eventSpecificSynchronousDispatchRegions);
378 void ArgumentCoder<TransformationMatrix>::encode(Encoder& encoder, const TransformationMatrix& transformationMatrix)
380 encoder << transformationMatrix.m11();
381 encoder << transformationMatrix.m12();
382 encoder << transformationMatrix.m13();
383 encoder << transformationMatrix.m14();
385 encoder << transformationMatrix.m21();
386 encoder << transformationMatrix.m22();
387 encoder << transformationMatrix.m23();
388 encoder << transformationMatrix.m24();
390 encoder << transformationMatrix.m31();
391 encoder << transformationMatrix.m32();
392 encoder << transformationMatrix.m33();
393 encoder << transformationMatrix.m34();
395 encoder << transformationMatrix.m41();
396 encoder << transformationMatrix.m42();
397 encoder << transformationMatrix.m43();
398 encoder << transformationMatrix.m44();
401 bool ArgumentCoder<TransformationMatrix>::decode(Decoder& decoder, TransformationMatrix& transformationMatrix)
404 if (!decoder.decode(m11))
407 if (!decoder.decode(m12))
410 if (!decoder.decode(m13))
413 if (!decoder.decode(m14))
417 if (!decoder.decode(m21))
420 if (!decoder.decode(m22))
423 if (!decoder.decode(m23))
426 if (!decoder.decode(m24))
430 if (!decoder.decode(m31))
433 if (!decoder.decode(m32))
436 if (!decoder.decode(m33))
439 if (!decoder.decode(m34))
443 if (!decoder.decode(m41))
446 if (!decoder.decode(m42))
449 if (!decoder.decode(m43))
452 if (!decoder.decode(m44))
455 transformationMatrix.setMatrix(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44);
459 void ArgumentCoder<LinearTimingFunction>::encode(Encoder& encoder, const LinearTimingFunction& timingFunction)
461 encoder.encodeEnum(timingFunction.type());
464 bool ArgumentCoder<LinearTimingFunction>::decode(Decoder&, LinearTimingFunction&)
466 // Type is decoded by the caller. Nothing else to decode.
470 void ArgumentCoder<CubicBezierTimingFunction>::encode(Encoder& encoder, const CubicBezierTimingFunction& timingFunction)
472 encoder.encodeEnum(timingFunction.type());
474 encoder << timingFunction.x1();
475 encoder << timingFunction.y1();
476 encoder << timingFunction.x2();
477 encoder << timingFunction.y2();
479 encoder.encodeEnum(timingFunction.timingFunctionPreset());
482 bool ArgumentCoder<CubicBezierTimingFunction>::decode(Decoder& decoder, CubicBezierTimingFunction& timingFunction)
484 // Type is decoded by the caller.
486 if (!decoder.decode(x1))
490 if (!decoder.decode(y1))
494 if (!decoder.decode(x2))
498 if (!decoder.decode(y2))
501 CubicBezierTimingFunction::TimingFunctionPreset preset;
502 if (!decoder.decodeEnum(preset))
505 timingFunction.setValues(x1, y1, x2, y2);
506 timingFunction.setTimingFunctionPreset(preset);
511 void ArgumentCoder<StepsTimingFunction>::encode(Encoder& encoder, const StepsTimingFunction& timingFunction)
513 encoder.encodeEnum(timingFunction.type());
515 encoder << timingFunction.numberOfSteps();
516 encoder << timingFunction.stepAtStart();
519 bool ArgumentCoder<StepsTimingFunction>::decode(Decoder& decoder, StepsTimingFunction& timingFunction)
521 // Type is decoded by the caller.
523 if (!decoder.decode(numSteps))
527 if (!decoder.decode(stepAtStart))
530 timingFunction.setNumberOfSteps(numSteps);
531 timingFunction.setStepAtStart(stepAtStart);
536 void ArgumentCoder<SpringTimingFunction>::encode(Encoder& encoder, const SpringTimingFunction& timingFunction)
538 encoder.encodeEnum(timingFunction.type());
540 encoder << timingFunction.mass();
541 encoder << timingFunction.stiffness();
542 encoder << timingFunction.damping();
543 encoder << timingFunction.initialVelocity();
546 bool ArgumentCoder<SpringTimingFunction>::decode(Decoder& decoder, SpringTimingFunction& timingFunction)
548 // Type is decoded by the caller.
550 if (!decoder.decode(mass))
554 if (!decoder.decode(stiffness))
558 if (!decoder.decode(damping))
561 double initialVelocity;
562 if (!decoder.decode(initialVelocity))
565 timingFunction.setValues(mass, stiffness, damping, initialVelocity);
570 void ArgumentCoder<FloatPoint>::encode(Encoder& encoder, const FloatPoint& floatPoint)
572 SimpleArgumentCoder<FloatPoint>::encode(encoder, floatPoint);
575 bool ArgumentCoder<FloatPoint>::decode(Decoder& decoder, FloatPoint& floatPoint)
577 return SimpleArgumentCoder<FloatPoint>::decode(decoder, floatPoint);
580 std::optional<FloatPoint> ArgumentCoder<FloatPoint>::decode(Decoder& decoder)
582 FloatPoint floatPoint;
583 if (!SimpleArgumentCoder<FloatPoint>::decode(decoder, floatPoint))
585 return WTFMove(floatPoint);
588 void ArgumentCoder<FloatPoint3D>::encode(Encoder& encoder, const FloatPoint3D& floatPoint)
590 SimpleArgumentCoder<FloatPoint3D>::encode(encoder, floatPoint);
593 bool ArgumentCoder<FloatPoint3D>::decode(Decoder& decoder, FloatPoint3D& floatPoint)
595 return SimpleArgumentCoder<FloatPoint3D>::decode(decoder, floatPoint);
599 void ArgumentCoder<FloatRect>::encode(Encoder& encoder, const FloatRect& floatRect)
601 SimpleArgumentCoder<FloatRect>::encode(encoder, floatRect);
604 bool ArgumentCoder<FloatRect>::decode(Decoder& decoder, FloatRect& floatRect)
606 return SimpleArgumentCoder<FloatRect>::decode(decoder, floatRect);
609 std::optional<FloatRect> ArgumentCoder<FloatRect>::decode(Decoder& decoder)
612 if (!SimpleArgumentCoder<FloatRect>::decode(decoder, floatRect))
614 return WTFMove(floatRect);
618 void ArgumentCoder<FloatBoxExtent>::encode(Encoder& encoder, const FloatBoxExtent& floatBoxExtent)
620 SimpleArgumentCoder<FloatBoxExtent>::encode(encoder, floatBoxExtent);
623 bool ArgumentCoder<FloatBoxExtent>::decode(Decoder& decoder, FloatBoxExtent& floatBoxExtent)
625 return SimpleArgumentCoder<FloatBoxExtent>::decode(decoder, floatBoxExtent);
629 void ArgumentCoder<FloatSize>::encode(Encoder& encoder, const FloatSize& floatSize)
631 SimpleArgumentCoder<FloatSize>::encode(encoder, floatSize);
634 bool ArgumentCoder<FloatSize>::decode(Decoder& decoder, FloatSize& floatSize)
636 return SimpleArgumentCoder<FloatSize>::decode(decoder, floatSize);
640 void ArgumentCoder<FloatRoundedRect>::encode(Encoder& encoder, const FloatRoundedRect& roundedRect)
642 SimpleArgumentCoder<FloatRoundedRect>::encode(encoder, roundedRect);
645 bool ArgumentCoder<FloatRoundedRect>::decode(Decoder& decoder, FloatRoundedRect& roundedRect)
647 return SimpleArgumentCoder<FloatRoundedRect>::decode(decoder, roundedRect);
651 void ArgumentCoder<FloatQuad>::encode(Encoder& encoder, const FloatQuad& floatQuad)
653 SimpleArgumentCoder<FloatQuad>::encode(encoder, floatQuad);
656 std::optional<FloatQuad> ArgumentCoder<FloatQuad>::decode(Decoder& decoder)
659 if (!SimpleArgumentCoder<FloatQuad>::decode(decoder, floatQuad))
661 return WTFMove(floatQuad);
664 void ArgumentCoder<ViewportArguments>::encode(Encoder& encoder, const ViewportArguments& viewportArguments)
666 SimpleArgumentCoder<ViewportArguments>::encode(encoder, viewportArguments);
669 bool ArgumentCoder<ViewportArguments>::decode(Decoder& decoder, ViewportArguments& viewportArguments)
671 return SimpleArgumentCoder<ViewportArguments>::decode(decoder, viewportArguments);
673 #endif // PLATFORM(IOS)
676 void ArgumentCoder<IntPoint>::encode(Encoder& encoder, const IntPoint& intPoint)
678 SimpleArgumentCoder<IntPoint>::encode(encoder, intPoint);
681 bool ArgumentCoder<IntPoint>::decode(Decoder& decoder, IntPoint& intPoint)
683 return SimpleArgumentCoder<IntPoint>::decode(decoder, intPoint);
686 std::optional<WebCore::IntPoint> ArgumentCoder<IntPoint>::decode(Decoder& decoder)
689 if (!SimpleArgumentCoder<IntPoint>::decode(decoder, intPoint))
691 return WTFMove(intPoint);
694 void ArgumentCoder<IntRect>::encode(Encoder& encoder, const IntRect& intRect)
696 SimpleArgumentCoder<IntRect>::encode(encoder, intRect);
699 bool ArgumentCoder<IntRect>::decode(Decoder& decoder, IntRect& intRect)
701 return SimpleArgumentCoder<IntRect>::decode(decoder, intRect);
704 std::optional<IntRect> ArgumentCoder<IntRect>::decode(Decoder& decoder)
707 if (!decode(decoder, rect))
709 return WTFMove(rect);
712 void ArgumentCoder<IntSize>::encode(Encoder& encoder, const IntSize& intSize)
714 SimpleArgumentCoder<IntSize>::encode(encoder, intSize);
717 bool ArgumentCoder<IntSize>::decode(Decoder& decoder, IntSize& intSize)
719 return SimpleArgumentCoder<IntSize>::decode(decoder, intSize);
722 std::optional<IntSize> ArgumentCoder<IntSize>::decode(Decoder& decoder)
725 if (!SimpleArgumentCoder<IntSize>::decode(decoder, intSize))
727 return WTFMove(intSize);
730 void ArgumentCoder<LayoutSize>::encode(Encoder& encoder, const LayoutSize& layoutSize)
732 SimpleArgumentCoder<LayoutSize>::encode(encoder, layoutSize);
735 bool ArgumentCoder<LayoutSize>::decode(Decoder& decoder, LayoutSize& layoutSize)
737 return SimpleArgumentCoder<LayoutSize>::decode(decoder, layoutSize);
741 void ArgumentCoder<LayoutPoint>::encode(Encoder& encoder, const LayoutPoint& layoutPoint)
743 SimpleArgumentCoder<LayoutPoint>::encode(encoder, layoutPoint);
746 bool ArgumentCoder<LayoutPoint>::decode(Decoder& decoder, LayoutPoint& layoutPoint)
748 return SimpleArgumentCoder<LayoutPoint>::decode(decoder, layoutPoint);
752 static void pathEncodeApplierFunction(Encoder& encoder, const PathElement& element)
754 encoder.encodeEnum(element.type);
756 switch (element.type) {
757 case PathElementMoveToPoint: // The points member will contain 1 value.
758 encoder << element.points[0];
760 case PathElementAddLineToPoint: // The points member will contain 1 value.
761 encoder << element.points[0];
763 case PathElementAddQuadCurveToPoint: // The points member will contain 2 values.
764 encoder << element.points[0];
765 encoder << element.points[1];
767 case PathElementAddCurveToPoint: // The points member will contain 3 values.
768 encoder << element.points[0];
769 encoder << element.points[1];
770 encoder << element.points[2];
772 case PathElementCloseSubpath: // The points member will contain no values.
777 void ArgumentCoder<Path>::encode(Encoder& encoder, const Path& path)
779 uint64_t numPoints = 0;
780 path.apply([&numPoints](const PathElement&) {
784 encoder << numPoints;
786 path.apply([&encoder](const PathElement& pathElement) {
787 pathEncodeApplierFunction(encoder, pathElement);
791 bool ArgumentCoder<Path>::decode(Decoder& decoder, Path& path)
794 if (!decoder.decode(numPoints))
799 for (uint64_t i = 0; i < numPoints; ++i) {
801 PathElementType elementType;
802 if (!decoder.decodeEnum(elementType))
805 switch (elementType) {
806 case PathElementMoveToPoint: { // The points member will contain 1 value.
808 if (!decoder.decode(point))
813 case PathElementAddLineToPoint: { // The points member will contain 1 value.
815 if (!decoder.decode(point))
817 path.addLineTo(point);
820 case PathElementAddQuadCurveToPoint: { // The points member will contain 2 values.
821 FloatPoint controlPoint;
822 if (!decoder.decode(controlPoint))
826 if (!decoder.decode(endPoint))
829 path.addQuadCurveTo(controlPoint, endPoint);
832 case PathElementAddCurveToPoint: { // The points member will contain 3 values.
833 FloatPoint controlPoint1;
834 if (!decoder.decode(controlPoint1))
837 FloatPoint controlPoint2;
838 if (!decoder.decode(controlPoint2))
842 if (!decoder.decode(endPoint))
845 path.addBezierCurveTo(controlPoint1, controlPoint2, endPoint);
848 case PathElementCloseSubpath: // The points member will contain no values.
857 void ArgumentCoder<RecentSearch>::encode(Encoder& encoder, const RecentSearch& recentSearch)
859 encoder << recentSearch.string << recentSearch.time;
862 std::optional<RecentSearch> ArgumentCoder<RecentSearch>::decode(Decoder& decoder)
864 std::optional<String> string;
869 std::optional<WallTime> time;
874 return {{ WTFMove(*string), WTFMove(*time) }};
877 template<> struct ArgumentCoder<Region::Span> {
878 static void encode(Encoder&, const Region::Span&);
879 static std::optional<Region::Span> decode(Decoder&);
882 void ArgumentCoder<Region::Span>::encode(Encoder& encoder, const Region::Span& span)
885 encoder << (uint64_t)span.segmentIndex;
888 std::optional<Region::Span> ArgumentCoder<Region::Span>::decode(Decoder& decoder)
891 if (!decoder.decode(span.y))
894 uint64_t segmentIndex;
895 if (!decoder.decode(segmentIndex))
898 span.segmentIndex = segmentIndex;
899 return WTFMove(span);
902 void ArgumentCoder<Region>::encode(Encoder& encoder, const Region& region)
904 encoder.encode(region.shapeSegments());
905 encoder.encode(region.shapeSpans());
908 bool ArgumentCoder<Region>::decode(Decoder& decoder, Region& region)
910 Vector<int> segments;
911 if (!decoder.decode(segments))
914 Vector<Region::Span> spans;
915 if (!decoder.decode(spans))
918 region.setShapeSegments(segments);
919 region.setShapeSpans(spans);
920 region.updateBoundsFromShape();
922 if (!region.isValid())
928 void ArgumentCoder<Length>::encode(Encoder& encoder, const Length& length)
930 SimpleArgumentCoder<Length>::encode(encoder, length);
933 bool ArgumentCoder<Length>::decode(Decoder& decoder, Length& length)
935 return SimpleArgumentCoder<Length>::decode(decoder, length);
939 void ArgumentCoder<ViewportAttributes>::encode(Encoder& encoder, const ViewportAttributes& viewportAttributes)
941 SimpleArgumentCoder<ViewportAttributes>::encode(encoder, viewportAttributes);
944 bool ArgumentCoder<ViewportAttributes>::decode(Decoder& decoder, ViewportAttributes& viewportAttributes)
946 return SimpleArgumentCoder<ViewportAttributes>::decode(decoder, viewportAttributes);
950 void ArgumentCoder<MimeClassInfo>::encode(Encoder& encoder, const MimeClassInfo& mimeClassInfo)
952 encoder << mimeClassInfo.type << mimeClassInfo.desc << mimeClassInfo.extensions;
955 std::optional<MimeClassInfo> ArgumentCoder<MimeClassInfo>::decode(Decoder& decoder)
957 MimeClassInfo mimeClassInfo;
958 if (!decoder.decode(mimeClassInfo.type))
960 if (!decoder.decode(mimeClassInfo.desc))
962 if (!decoder.decode(mimeClassInfo.extensions))
965 return WTFMove(mimeClassInfo);
969 void ArgumentCoder<PluginInfo>::encode(Encoder& encoder, const PluginInfo& pluginInfo)
971 encoder << pluginInfo.name;
972 encoder << pluginInfo.file;
973 encoder << pluginInfo.desc;
974 encoder << pluginInfo.mimes;
975 encoder << pluginInfo.isApplicationPlugin;
976 encoder.encodeEnum(pluginInfo.clientLoadPolicy);
978 encoder << pluginInfo.bundleIdentifier;
979 encoder << pluginInfo.versionString;
983 std::optional<WebCore::PluginInfo> ArgumentCoder<PluginInfo>::decode(Decoder& decoder)
985 PluginInfo pluginInfo;
986 if (!decoder.decode(pluginInfo.name))
988 if (!decoder.decode(pluginInfo.file))
990 if (!decoder.decode(pluginInfo.desc))
992 if (!decoder.decode(pluginInfo.mimes))
994 if (!decoder.decode(pluginInfo.isApplicationPlugin))
996 if (!decoder.decodeEnum(pluginInfo.clientLoadPolicy))
999 if (!decoder.decode(pluginInfo.bundleIdentifier))
1000 return std::nullopt;
1001 if (!decoder.decode(pluginInfo.versionString))
1002 return std::nullopt;
1005 return WTFMove(pluginInfo);
1008 void ArgumentCoder<AuthenticationChallenge>::encode(Encoder& encoder, const AuthenticationChallenge& challenge)
1010 encoder << challenge.protectionSpace() << challenge.proposedCredential() << challenge.previousFailureCount() << challenge.failureResponse() << challenge.error();
1013 bool ArgumentCoder<AuthenticationChallenge>::decode(Decoder& decoder, AuthenticationChallenge& challenge)
1015 ProtectionSpace protectionSpace;
1016 if (!decoder.decode(protectionSpace))
1019 Credential proposedCredential;
1020 if (!decoder.decode(proposedCredential))
1023 unsigned previousFailureCount;
1024 if (!decoder.decode(previousFailureCount))
1027 ResourceResponse failureResponse;
1028 if (!decoder.decode(failureResponse))
1031 ResourceError error;
1032 if (!decoder.decode(error))
1035 challenge = AuthenticationChallenge(protectionSpace, proposedCredential, previousFailureCount, failureResponse, error);
1040 void ArgumentCoder<ProtectionSpace>::encode(Encoder& encoder, const ProtectionSpace& space)
1042 if (space.encodingRequiresPlatformData()) {
1044 encodePlatformData(encoder, space);
1049 encoder << space.host() << space.port() << space.realm();
1050 encoder.encodeEnum(space.authenticationScheme());
1051 encoder.encodeEnum(space.serverType());
1054 bool ArgumentCoder<ProtectionSpace>::decode(Decoder& decoder, ProtectionSpace& space)
1056 bool hasPlatformData;
1057 if (!decoder.decode(hasPlatformData))
1060 if (hasPlatformData)
1061 return decodePlatformData(decoder, space);
1064 if (!decoder.decode(host))
1068 if (!decoder.decode(port))
1072 if (!decoder.decode(realm))
1075 ProtectionSpaceAuthenticationScheme authenticationScheme;
1076 if (!decoder.decodeEnum(authenticationScheme))
1079 ProtectionSpaceServerType serverType;
1080 if (!decoder.decodeEnum(serverType))
1083 space = ProtectionSpace(host, port, serverType, realm, authenticationScheme);
1087 void ArgumentCoder<Credential>::encode(Encoder& encoder, const Credential& credential)
1089 if (credential.encodingRequiresPlatformData()) {
1091 encodePlatformData(encoder, credential);
1096 encoder << credential.user() << credential.password();
1097 encoder.encodeEnum(credential.persistence());
1100 bool ArgumentCoder<Credential>::decode(Decoder& decoder, Credential& credential)
1102 bool hasPlatformData;
1103 if (!decoder.decode(hasPlatformData))
1106 if (hasPlatformData)
1107 return decodePlatformData(decoder, credential);
1110 if (!decoder.decode(user))
1114 if (!decoder.decode(password))
1117 CredentialPersistence persistence;
1118 if (!decoder.decodeEnum(persistence))
1121 credential = Credential(user, password, persistence);
1125 static void encodeImage(Encoder& encoder, Image& image)
1127 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(IntSize(image.size()), { });
1128 bitmap->createGraphicsContext()->drawImage(image, IntPoint());
1130 ShareableBitmap::Handle handle;
1131 bitmap->createHandle(handle);
1136 static bool decodeImage(Decoder& decoder, RefPtr<Image>& image)
1138 ShareableBitmap::Handle handle;
1139 if (!decoder.decode(handle))
1142 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(handle);
1145 image = bitmap->createImage();
1151 static void encodeOptionalImage(Encoder& encoder, Image* image)
1153 bool hasImage = !!image;
1154 encoder << hasImage;
1157 encodeImage(encoder, *image);
1160 static bool decodeOptionalImage(Decoder& decoder, RefPtr<Image>& image)
1165 if (!decoder.decode(hasImage))
1171 return decodeImage(decoder, image);
1175 void ArgumentCoder<Cursor>::encode(Encoder& encoder, const Cursor& cursor)
1177 encoder.encodeEnum(cursor.type());
1179 if (cursor.type() != Cursor::Custom)
1182 if (cursor.image()->isNull()) {
1183 encoder << false; // There is no valid image being encoded.
1188 encodeImage(encoder, *cursor.image());
1189 encoder << cursor.hotSpot();
1190 #if ENABLE(MOUSE_CURSOR_SCALE)
1191 encoder << cursor.imageScaleFactor();
1195 bool ArgumentCoder<Cursor>::decode(Decoder& decoder, Cursor& cursor)
1198 if (!decoder.decodeEnum(type))
1201 if (type > Cursor::Custom)
1204 if (type != Cursor::Custom) {
1205 const Cursor& cursorReference = Cursor::fromType(type);
1206 // Calling platformCursor here will eagerly create the platform cursor for the cursor singletons inside WebCore.
1207 // This will avoid having to re-create the platform cursors over and over.
1208 (void)cursorReference.platformCursor();
1210 cursor = cursorReference;
1214 bool isValidImagePresent;
1215 if (!decoder.decode(isValidImagePresent))
1218 if (!isValidImagePresent) {
1219 cursor = Cursor(&Image::nullImage(), IntPoint());
1223 RefPtr<Image> image;
1224 if (!decodeImage(decoder, image))
1228 if (!decoder.decode(hotSpot))
1231 if (!image->rect().contains(hotSpot))
1234 #if ENABLE(MOUSE_CURSOR_SCALE)
1236 if (!decoder.decode(scale))
1239 cursor = Cursor(image.get(), hotSpot, scale);
1241 cursor = Cursor(image.get(), hotSpot);
1247 void ArgumentCoder<ResourceRequest>::encode(Encoder& encoder, const ResourceRequest& resourceRequest)
1249 encoder << resourceRequest.cachePartition();
1250 encoder << resourceRequest.hiddenFromInspector();
1252 if (resourceRequest.encodingRequiresPlatformData()) {
1254 encodePlatformData(encoder, resourceRequest);
1258 resourceRequest.encodeWithoutPlatformData(encoder);
1261 bool ArgumentCoder<ResourceRequest>::decode(Decoder& decoder, ResourceRequest& resourceRequest)
1263 String cachePartition;
1264 if (!decoder.decode(cachePartition))
1266 resourceRequest.setCachePartition(cachePartition);
1268 bool isHiddenFromInspector;
1269 if (!decoder.decode(isHiddenFromInspector))
1271 resourceRequest.setHiddenFromInspector(isHiddenFromInspector);
1273 bool hasPlatformData;
1274 if (!decoder.decode(hasPlatformData))
1276 if (hasPlatformData)
1277 return decodePlatformData(decoder, resourceRequest);
1279 return resourceRequest.decodeWithoutPlatformData(decoder);
1282 void ArgumentCoder<ResourceError>::encode(Encoder& encoder, const ResourceError& resourceError)
1284 encodePlatformData(encoder, resourceError);
1287 bool ArgumentCoder<ResourceError>::decode(Decoder& decoder, ResourceError& resourceError)
1289 return decodePlatformData(decoder, resourceError);
1294 void ArgumentCoder<SelectionRect>::encode(Encoder& encoder, const SelectionRect& selectionRect)
1296 encoder << selectionRect.rect();
1297 encoder << static_cast<uint32_t>(selectionRect.direction());
1298 encoder << selectionRect.minX();
1299 encoder << selectionRect.maxX();
1300 encoder << selectionRect.maxY();
1301 encoder << selectionRect.lineNumber();
1302 encoder << selectionRect.isLineBreak();
1303 encoder << selectionRect.isFirstOnLine();
1304 encoder << selectionRect.isLastOnLine();
1305 encoder << selectionRect.containsStart();
1306 encoder << selectionRect.containsEnd();
1307 encoder << selectionRect.isHorizontal();
1310 std::optional<SelectionRect> ArgumentCoder<SelectionRect>::decode(Decoder& decoder)
1312 SelectionRect selectionRect;
1314 if (!decoder.decode(rect))
1315 return std::nullopt;
1316 selectionRect.setRect(rect);
1319 if (!decoder.decode(direction))
1320 return std::nullopt;
1321 selectionRect.setDirection((TextDirection)direction);
1324 if (!decoder.decode(intValue))
1325 return std::nullopt;
1326 selectionRect.setMinX(intValue);
1328 if (!decoder.decode(intValue))
1329 return std::nullopt;
1330 selectionRect.setMaxX(intValue);
1332 if (!decoder.decode(intValue))
1333 return std::nullopt;
1334 selectionRect.setMaxY(intValue);
1336 if (!decoder.decode(intValue))
1337 return std::nullopt;
1338 selectionRect.setLineNumber(intValue);
1341 if (!decoder.decode(boolValue))
1342 return std::nullopt;
1343 selectionRect.setIsLineBreak(boolValue);
1345 if (!decoder.decode(boolValue))
1346 return std::nullopt;
1347 selectionRect.setIsFirstOnLine(boolValue);
1349 if (!decoder.decode(boolValue))
1350 return std::nullopt;
1351 selectionRect.setIsLastOnLine(boolValue);
1353 if (!decoder.decode(boolValue))
1354 return std::nullopt;
1355 selectionRect.setContainsStart(boolValue);
1357 if (!decoder.decode(boolValue))
1358 return std::nullopt;
1359 selectionRect.setContainsEnd(boolValue);
1361 if (!decoder.decode(boolValue))
1362 return std::nullopt;
1363 selectionRect.setIsHorizontal(boolValue);
1365 return WTFMove(selectionRect);
1370 void ArgumentCoder<WindowFeatures>::encode(Encoder& encoder, const WindowFeatures& windowFeatures)
1372 encoder << windowFeatures.x;
1373 encoder << windowFeatures.y;
1374 encoder << windowFeatures.width;
1375 encoder << windowFeatures.height;
1376 encoder << windowFeatures.menuBarVisible;
1377 encoder << windowFeatures.statusBarVisible;
1378 encoder << windowFeatures.toolBarVisible;
1379 encoder << windowFeatures.locationBarVisible;
1380 encoder << windowFeatures.scrollbarsVisible;
1381 encoder << windowFeatures.resizable;
1382 encoder << windowFeatures.fullscreen;
1383 encoder << windowFeatures.dialog;
1386 bool ArgumentCoder<WindowFeatures>::decode(Decoder& decoder, WindowFeatures& windowFeatures)
1388 if (!decoder.decode(windowFeatures.x))
1390 if (!decoder.decode(windowFeatures.y))
1392 if (!decoder.decode(windowFeatures.width))
1394 if (!decoder.decode(windowFeatures.height))
1396 if (!decoder.decode(windowFeatures.menuBarVisible))
1398 if (!decoder.decode(windowFeatures.statusBarVisible))
1400 if (!decoder.decode(windowFeatures.toolBarVisible))
1402 if (!decoder.decode(windowFeatures.locationBarVisible))
1404 if (!decoder.decode(windowFeatures.scrollbarsVisible))
1406 if (!decoder.decode(windowFeatures.resizable))
1408 if (!decoder.decode(windowFeatures.fullscreen))
1410 if (!decoder.decode(windowFeatures.dialog))
1416 void ArgumentCoder<Color>::encode(Encoder& encoder, const Color& color)
1418 if (color.isExtended()) {
1420 encoder << color.asExtended().red();
1421 encoder << color.asExtended().green();
1422 encoder << color.asExtended().blue();
1423 encoder << color.asExtended().alpha();
1424 encoder << color.asExtended().colorSpace();
1430 if (!color.isValid()) {
1436 encoder << color.rgb();
1439 bool ArgumentCoder<Color>::decode(Decoder& decoder, Color& color)
1442 if (!decoder.decode(isExtended))
1450 ColorSpace colorSpace;
1451 if (!decoder.decode(red))
1453 if (!decoder.decode(green))
1455 if (!decoder.decode(blue))
1457 if (!decoder.decode(alpha))
1459 if (!decoder.decode(colorSpace))
1461 color = Color(red, green, blue, alpha, colorSpace);
1466 if (!decoder.decode(isValid))
1475 if (!decoder.decode(rgba))
1478 color = Color(rgba);
1482 #if ENABLE(DRAG_SUPPORT)
1483 void ArgumentCoder<DragData>::encode(Encoder& encoder, const DragData& dragData)
1485 encoder << dragData.clientPosition();
1486 encoder << dragData.globalPosition();
1487 encoder.encodeEnum(dragData.draggingSourceOperationMask());
1488 encoder.encodeEnum(dragData.flags());
1490 encoder << dragData.pasteboardName();
1491 encoder << dragData.fileNames();
1493 encoder.encodeEnum(dragData.dragDestinationAction());
1496 bool ArgumentCoder<DragData>::decode(Decoder& decoder, DragData& dragData)
1498 IntPoint clientPosition;
1499 if (!decoder.decode(clientPosition))
1502 IntPoint globalPosition;
1503 if (!decoder.decode(globalPosition))
1506 DragOperation draggingSourceOperationMask;
1507 if (!decoder.decodeEnum(draggingSourceOperationMask))
1510 DragApplicationFlags applicationFlags;
1511 if (!decoder.decodeEnum(applicationFlags))
1514 String pasteboardName;
1515 Vector<String> fileNames;
1517 if (!decoder.decode(pasteboardName))
1520 if (!decoder.decode(fileNames))
1524 DragDestinationAction destinationAction;
1525 if (!decoder.decodeEnum(destinationAction))
1528 dragData = DragData(pasteboardName, clientPosition, globalPosition, draggingSourceOperationMask, applicationFlags, destinationAction);
1529 dragData.setFileNames(fileNames);
1535 void ArgumentCoder<CompositionUnderline>::encode(Encoder& encoder, const CompositionUnderline& underline)
1537 encoder << underline.startOffset;
1538 encoder << underline.endOffset;
1539 encoder << underline.thick;
1540 encoder << underline.color;
1543 std::optional<CompositionUnderline> ArgumentCoder<CompositionUnderline>::decode(Decoder& decoder)
1545 CompositionUnderline underline;
1547 if (!decoder.decode(underline.startOffset))
1548 return std::nullopt;
1549 if (!decoder.decode(underline.endOffset))
1550 return std::nullopt;
1551 if (!decoder.decode(underline.thick))
1552 return std::nullopt;
1553 if (!decoder.decode(underline.color))
1554 return std::nullopt;
1556 return WTFMove(underline);
1559 void ArgumentCoder<DatabaseDetails>::encode(Encoder& encoder, const DatabaseDetails& details)
1561 encoder << details.name();
1562 encoder << details.displayName();
1563 encoder << details.expectedUsage();
1564 encoder << details.currentUsage();
1565 encoder << details.creationTime();
1566 encoder << details.modificationTime();
1569 bool ArgumentCoder<DatabaseDetails>::decode(Decoder& decoder, DatabaseDetails& details)
1572 if (!decoder.decode(name))
1576 if (!decoder.decode(displayName))
1579 uint64_t expectedUsage;
1580 if (!decoder.decode(expectedUsage))
1583 uint64_t currentUsage;
1584 if (!decoder.decode(currentUsage))
1587 double creationTime;
1588 if (!decoder.decode(creationTime))
1591 double modificationTime;
1592 if (!decoder.decode(modificationTime))
1595 details = DatabaseDetails(name, displayName, expectedUsage, currentUsage, creationTime, modificationTime);
1599 void ArgumentCoder<PasteboardCustomData>::encode(Encoder& encoder, const PasteboardCustomData& data)
1601 encoder << data.origin;
1602 encoder << data.orderedTypes;
1603 encoder << data.platformData;
1604 encoder << data.sameOriginCustomData;
1607 bool ArgumentCoder<PasteboardCustomData>::decode(Decoder& decoder, PasteboardCustomData& data)
1609 if (!decoder.decode(data.origin))
1612 if (!decoder.decode(data.orderedTypes))
1615 if (!decoder.decode(data.platformData))
1618 if (!decoder.decode(data.sameOriginCustomData))
1626 void ArgumentCoder<Highlight>::encode(Encoder& encoder, const Highlight& highlight)
1628 encoder << static_cast<uint32_t>(highlight.type);
1629 encoder << highlight.usePageCoordinates;
1630 encoder << highlight.contentColor;
1631 encoder << highlight.contentOutlineColor;
1632 encoder << highlight.paddingColor;
1633 encoder << highlight.borderColor;
1634 encoder << highlight.marginColor;
1635 encoder << highlight.quads;
1638 bool ArgumentCoder<Highlight>::decode(Decoder& decoder, Highlight& highlight)
1641 if (!decoder.decode(type))
1643 highlight.type = (HighlightType)type;
1645 if (!decoder.decode(highlight.usePageCoordinates))
1647 if (!decoder.decode(highlight.contentColor))
1649 if (!decoder.decode(highlight.contentOutlineColor))
1651 if (!decoder.decode(highlight.paddingColor))
1653 if (!decoder.decode(highlight.borderColor))
1655 if (!decoder.decode(highlight.marginColor))
1657 if (!decoder.decode(highlight.quads))
1662 void ArgumentCoder<PasteboardURL>::encode(Encoder& encoder, const PasteboardURL& content)
1664 encoder << content.url;
1665 encoder << content.title;
1668 bool ArgumentCoder<PasteboardURL>::decode(Decoder& decoder, PasteboardURL& content)
1670 if (!decoder.decode(content.url))
1673 if (!decoder.decode(content.title))
1679 void ArgumentCoder<PasteboardWebContent>::encode(Encoder& encoder, const PasteboardWebContent& content)
1681 encoder << content.contentOrigin;
1682 encoder << content.canSmartCopyOrDelete;
1683 encoder << content.dataInStringFormat;
1684 encoder << content.dataInHTMLFormat;
1686 encodeSharedBuffer(encoder, content.dataInWebArchiveFormat.get());
1687 encodeSharedBuffer(encoder, content.dataInRTFDFormat.get());
1688 encodeSharedBuffer(encoder, content.dataInRTFFormat.get());
1689 encodeSharedBuffer(encoder, content.dataInAttributedStringFormat.get());
1691 encodeTypesAndData(encoder, content.clientTypes, content.clientData);
1694 bool ArgumentCoder<PasteboardWebContent>::decode(Decoder& decoder, PasteboardWebContent& content)
1696 if (!decoder.decode(content.contentOrigin))
1698 if (!decoder.decode(content.canSmartCopyOrDelete))
1700 if (!decoder.decode(content.dataInStringFormat))
1702 if (!decoder.decode(content.dataInHTMLFormat))
1704 if (!decodeSharedBuffer(decoder, content.dataInWebArchiveFormat))
1706 if (!decodeSharedBuffer(decoder, content.dataInRTFDFormat))
1708 if (!decodeSharedBuffer(decoder, content.dataInRTFFormat))
1710 if (!decodeSharedBuffer(decoder, content.dataInAttributedStringFormat))
1712 if (!decodeTypesAndData(decoder, content.clientTypes, content.clientData))
1717 void ArgumentCoder<PasteboardImage>::encode(Encoder& encoder, const PasteboardImage& pasteboardImage)
1719 encodeOptionalImage(encoder, pasteboardImage.image.get());
1720 encoder << pasteboardImage.url.url;
1721 encoder << pasteboardImage.url.title;
1722 encoder << pasteboardImage.resourceMIMEType;
1723 encoder << pasteboardImage.suggestedName;
1724 encoder << pasteboardImage.imageSize;
1725 if (pasteboardImage.resourceData)
1726 encodeSharedBuffer(encoder, pasteboardImage.resourceData.get());
1727 encodeTypesAndData(encoder, pasteboardImage.clientTypes, pasteboardImage.clientData);
1730 bool ArgumentCoder<PasteboardImage>::decode(Decoder& decoder, PasteboardImage& pasteboardImage)
1732 if (!decodeOptionalImage(decoder, pasteboardImage.image))
1734 if (!decoder.decode(pasteboardImage.url.url))
1736 if (!decoder.decode(pasteboardImage.url.title))
1738 if (!decoder.decode(pasteboardImage.resourceMIMEType))
1740 if (!decoder.decode(pasteboardImage.suggestedName))
1742 if (!decoder.decode(pasteboardImage.imageSize))
1744 if (!decodeSharedBuffer(decoder, pasteboardImage.resourceData))
1746 if (!decodeTypesAndData(decoder, pasteboardImage.clientTypes, pasteboardImage.clientData))
1754 void ArgumentCoder<PasteboardWebContent>::encode(Encoder& encoder, const PasteboardWebContent& content)
1756 encoder << content.text;
1757 encoder << content.markup;
1760 bool ArgumentCoder<PasteboardWebContent>::decode(Decoder& decoder, PasteboardWebContent& content)
1762 if (!decoder.decode(content.text))
1764 if (!decoder.decode(content.markup))
1768 #endif // PLATFORM(WPE)
1770 void ArgumentCoder<DictationAlternative>::encode(Encoder& encoder, const DictationAlternative& dictationAlternative)
1772 encoder << dictationAlternative.rangeStart;
1773 encoder << dictationAlternative.rangeLength;
1774 encoder << dictationAlternative.dictationContext;
1777 std::optional<DictationAlternative> ArgumentCoder<DictationAlternative>::decode(Decoder& decoder)
1779 std::optional<unsigned> rangeStart;
1780 decoder >> rangeStart;
1782 return std::nullopt;
1784 std::optional<unsigned> rangeLength;
1785 decoder >> rangeLength;
1787 return std::nullopt;
1789 std::optional<uint64_t> dictationContext;
1790 decoder >> dictationContext;
1791 if (!dictationContext)
1792 return std::nullopt;
1794 return {{ WTFMove(*rangeStart), WTFMove(*rangeLength), WTFMove(*dictationContext) }};
1797 void ArgumentCoder<FileChooserSettings>::encode(Encoder& encoder, const FileChooserSettings& settings)
1799 encoder << settings.allowsDirectories;
1800 encoder << settings.allowsMultipleFiles;
1801 encoder << settings.acceptMIMETypes;
1802 encoder << settings.acceptFileExtensions;
1803 encoder << settings.selectedFiles;
1804 #if ENABLE(MEDIA_CAPTURE)
1805 encoder.encodeEnum(settings.mediaCaptureType);
1809 bool ArgumentCoder<FileChooserSettings>::decode(Decoder& decoder, FileChooserSettings& settings)
1811 if (!decoder.decode(settings.allowsDirectories))
1813 if (!decoder.decode(settings.allowsMultipleFiles))
1815 if (!decoder.decode(settings.acceptMIMETypes))
1817 if (!decoder.decode(settings.acceptFileExtensions))
1819 if (!decoder.decode(settings.selectedFiles))
1821 #if ENABLE(MEDIA_CAPTURE)
1822 if (!decoder.decodeEnum(settings.mediaCaptureType))
1830 void ArgumentCoder<GrammarDetail>::encode(Encoder& encoder, const GrammarDetail& detail)
1832 encoder << detail.location;
1833 encoder << detail.length;
1834 encoder << detail.guesses;
1835 encoder << detail.userDescription;
1838 std::optional<GrammarDetail> ArgumentCoder<GrammarDetail>::decode(Decoder& decoder)
1840 std::optional<int> location;
1841 decoder >> location;
1843 return std::nullopt;
1845 std::optional<int> length;
1848 return std::nullopt;
1850 std::optional<Vector<String>> guesses;
1853 return std::nullopt;
1855 std::optional<String> userDescription;
1856 decoder >> userDescription;
1857 if (!userDescription)
1858 return std::nullopt;
1860 return {{ WTFMove(*location), WTFMove(*length), WTFMove(*guesses), WTFMove(*userDescription) }};
1863 void ArgumentCoder<TextCheckingRequestData>::encode(Encoder& encoder, const TextCheckingRequestData& request)
1865 encoder << request.sequence();
1866 encoder << request.text();
1867 encoder << request.mask();
1868 encoder.encodeEnum(request.processType());
1871 bool ArgumentCoder<TextCheckingRequestData>::decode(Decoder& decoder, TextCheckingRequestData& request)
1874 if (!decoder.decode(sequence))
1878 if (!decoder.decode(text))
1881 TextCheckingTypeMask mask;
1882 if (!decoder.decode(mask))
1885 TextCheckingProcessType processType;
1886 if (!decoder.decodeEnum(processType))
1889 request = TextCheckingRequestData(sequence, text, mask, processType);
1893 void ArgumentCoder<TextCheckingResult>::encode(Encoder& encoder, const TextCheckingResult& result)
1895 encoder.encodeEnum(result.type);
1896 encoder << result.location;
1897 encoder << result.length;
1898 encoder << result.details;
1899 encoder << result.replacement;
1902 std::optional<TextCheckingResult> ArgumentCoder<TextCheckingResult>::decode(Decoder& decoder)
1904 TextCheckingType type;
1905 if (!decoder.decodeEnum(type))
1906 return std::nullopt;
1908 std::optional<int> location;
1909 decoder >> location;
1911 return std::nullopt;
1913 std::optional<int> length;
1916 return std::nullopt;
1918 std::optional<Vector<GrammarDetail>> details;
1921 return std::nullopt;
1923 std::optional<String> replacement;
1924 decoder >> replacement;
1926 return std::nullopt;
1928 return {{ WTFMove(type), WTFMove(*location), WTFMove(*length), WTFMove(*details), WTFMove(*replacement) }};
1931 void ArgumentCoder<UserStyleSheet>::encode(Encoder& encoder, const UserStyleSheet& userStyleSheet)
1933 encoder << userStyleSheet.source();
1934 encoder << userStyleSheet.url();
1935 encoder << userStyleSheet.whitelist();
1936 encoder << userStyleSheet.blacklist();
1937 encoder.encodeEnum(userStyleSheet.injectedFrames());
1938 encoder.encodeEnum(userStyleSheet.level());
1941 bool ArgumentCoder<UserStyleSheet>::decode(Decoder& decoder, UserStyleSheet& userStyleSheet)
1944 if (!decoder.decode(source))
1948 if (!decoder.decode(url))
1951 Vector<String> whitelist;
1952 if (!decoder.decode(whitelist))
1955 Vector<String> blacklist;
1956 if (!decoder.decode(blacklist))
1959 UserContentInjectedFrames injectedFrames;
1960 if (!decoder.decodeEnum(injectedFrames))
1963 UserStyleLevel level;
1964 if (!decoder.decodeEnum(level))
1967 userStyleSheet = UserStyleSheet(source, url, WTFMove(whitelist), WTFMove(blacklist), injectedFrames, level);
1971 #if ENABLE(MEDIA_SESSION)
1972 void ArgumentCoder<MediaSessionMetadata>::encode(Encoder& encoder, const MediaSessionMetadata& result)
1974 encoder << result.artist();
1975 encoder << result.album();
1976 encoder << result.title();
1977 encoder << result.artworkURL();
1980 bool ArgumentCoder<MediaSessionMetadata>::decode(Decoder& decoder, MediaSessionMetadata& result)
1982 String artist, album, title;
1984 if (!decoder.decode(artist))
1986 if (!decoder.decode(album))
1988 if (!decoder.decode(title))
1990 if (!decoder.decode(artworkURL))
1992 result = MediaSessionMetadata(title, artist, album, artworkURL);
1997 void ArgumentCoder<ScrollableAreaParameters>::encode(Encoder& encoder, const ScrollableAreaParameters& parameters)
1999 encoder.encodeEnum(parameters.horizontalScrollElasticity);
2000 encoder.encodeEnum(parameters.verticalScrollElasticity);
2002 encoder.encodeEnum(parameters.horizontalScrollbarMode);
2003 encoder.encodeEnum(parameters.verticalScrollbarMode);
2005 encoder << parameters.hasEnabledHorizontalScrollbar;
2006 encoder << parameters.hasEnabledVerticalScrollbar;
2009 bool ArgumentCoder<ScrollableAreaParameters>::decode(Decoder& decoder, ScrollableAreaParameters& params)
2011 if (!decoder.decodeEnum(params.horizontalScrollElasticity))
2013 if (!decoder.decodeEnum(params.verticalScrollElasticity))
2016 if (!decoder.decodeEnum(params.horizontalScrollbarMode))
2018 if (!decoder.decodeEnum(params.verticalScrollbarMode))
2021 if (!decoder.decode(params.hasEnabledHorizontalScrollbar))
2023 if (!decoder.decode(params.hasEnabledVerticalScrollbar))
2029 void ArgumentCoder<FixedPositionViewportConstraints>::encode(Encoder& encoder, const FixedPositionViewportConstraints& viewportConstraints)
2031 encoder << viewportConstraints.alignmentOffset();
2032 encoder << viewportConstraints.anchorEdges();
2034 encoder << viewportConstraints.viewportRectAtLastLayout();
2035 encoder << viewportConstraints.layerPositionAtLastLayout();
2038 bool ArgumentCoder<FixedPositionViewportConstraints>::decode(Decoder& decoder, FixedPositionViewportConstraints& viewportConstraints)
2040 FloatSize alignmentOffset;
2041 if (!decoder.decode(alignmentOffset))
2044 ViewportConstraints::AnchorEdges anchorEdges;
2045 if (!decoder.decode(anchorEdges))
2048 FloatRect viewportRectAtLastLayout;
2049 if (!decoder.decode(viewportRectAtLastLayout))
2052 FloatPoint layerPositionAtLastLayout;
2053 if (!decoder.decode(layerPositionAtLastLayout))
2056 viewportConstraints = FixedPositionViewportConstraints();
2057 viewportConstraints.setAlignmentOffset(alignmentOffset);
2058 viewportConstraints.setAnchorEdges(anchorEdges);
2060 viewportConstraints.setViewportRectAtLastLayout(viewportRectAtLastLayout);
2061 viewportConstraints.setLayerPositionAtLastLayout(layerPositionAtLastLayout);
2066 void ArgumentCoder<StickyPositionViewportConstraints>::encode(Encoder& encoder, const StickyPositionViewportConstraints& viewportConstraints)
2068 encoder << viewportConstraints.alignmentOffset();
2069 encoder << viewportConstraints.anchorEdges();
2071 encoder << viewportConstraints.leftOffset();
2072 encoder << viewportConstraints.rightOffset();
2073 encoder << viewportConstraints.topOffset();
2074 encoder << viewportConstraints.bottomOffset();
2076 encoder << viewportConstraints.constrainingRectAtLastLayout();
2077 encoder << viewportConstraints.containingBlockRect();
2078 encoder << viewportConstraints.stickyBoxRect();
2080 encoder << viewportConstraints.stickyOffsetAtLastLayout();
2081 encoder << viewportConstraints.layerPositionAtLastLayout();
2084 bool ArgumentCoder<StickyPositionViewportConstraints>::decode(Decoder& decoder, StickyPositionViewportConstraints& viewportConstraints)
2086 FloatSize alignmentOffset;
2087 if (!decoder.decode(alignmentOffset))
2090 ViewportConstraints::AnchorEdges anchorEdges;
2091 if (!decoder.decode(anchorEdges))
2095 if (!decoder.decode(leftOffset))
2099 if (!decoder.decode(rightOffset))
2103 if (!decoder.decode(topOffset))
2107 if (!decoder.decode(bottomOffset))
2110 FloatRect constrainingRectAtLastLayout;
2111 if (!decoder.decode(constrainingRectAtLastLayout))
2114 FloatRect containingBlockRect;
2115 if (!decoder.decode(containingBlockRect))
2118 FloatRect stickyBoxRect;
2119 if (!decoder.decode(stickyBoxRect))
2122 FloatSize stickyOffsetAtLastLayout;
2123 if (!decoder.decode(stickyOffsetAtLastLayout))
2126 FloatPoint layerPositionAtLastLayout;
2127 if (!decoder.decode(layerPositionAtLastLayout))
2130 viewportConstraints = StickyPositionViewportConstraints();
2131 viewportConstraints.setAlignmentOffset(alignmentOffset);
2132 viewportConstraints.setAnchorEdges(anchorEdges);
2134 viewportConstraints.setLeftOffset(leftOffset);
2135 viewportConstraints.setRightOffset(rightOffset);
2136 viewportConstraints.setTopOffset(topOffset);
2137 viewportConstraints.setBottomOffset(bottomOffset);
2139 viewportConstraints.setConstrainingRectAtLastLayout(constrainingRectAtLastLayout);
2140 viewportConstraints.setContainingBlockRect(containingBlockRect);
2141 viewportConstraints.setStickyBoxRect(stickyBoxRect);
2143 viewportConstraints.setStickyOffsetAtLastLayout(stickyOffsetAtLastLayout);
2144 viewportConstraints.setLayerPositionAtLastLayout(layerPositionAtLastLayout);
2149 #if !USE(COORDINATED_GRAPHICS)
2150 void ArgumentCoder<FilterOperation>::encode(Encoder& encoder, const FilterOperation& filter)
2152 encoder.encodeEnum(filter.type());
2154 switch (filter.type()) {
2155 case FilterOperation::NONE:
2156 case FilterOperation::REFERENCE:
2157 ASSERT_NOT_REACHED();
2159 case FilterOperation::GRAYSCALE:
2160 case FilterOperation::SEPIA:
2161 case FilterOperation::SATURATE:
2162 case FilterOperation::HUE_ROTATE:
2163 encoder << downcast<BasicColorMatrixFilterOperation>(filter).amount();
2165 case FilterOperation::INVERT:
2166 case FilterOperation::OPACITY:
2167 case FilterOperation::BRIGHTNESS:
2168 case FilterOperation::CONTRAST:
2169 encoder << downcast<BasicComponentTransferFilterOperation>(filter).amount();
2171 case FilterOperation::BLUR:
2172 encoder << downcast<BlurFilterOperation>(filter).stdDeviation();
2174 case FilterOperation::DROP_SHADOW: {
2175 const auto& dropShadowFilter = downcast<DropShadowFilterOperation>(filter);
2176 encoder << dropShadowFilter.location();
2177 encoder << dropShadowFilter.stdDeviation();
2178 encoder << dropShadowFilter.color();
2181 case FilterOperation::DEFAULT:
2182 encoder.encodeEnum(downcast<DefaultFilterOperation>(filter).representedType());
2184 case FilterOperation::PASSTHROUGH:
2189 bool decodeFilterOperation(Decoder& decoder, RefPtr<FilterOperation>& filter)
2191 FilterOperation::OperationType type;
2192 if (!decoder.decodeEnum(type))
2196 case FilterOperation::NONE:
2197 case FilterOperation::REFERENCE:
2198 ASSERT_NOT_REACHED();
2199 decoder.markInvalid();
2201 case FilterOperation::GRAYSCALE:
2202 case FilterOperation::SEPIA:
2203 case FilterOperation::SATURATE:
2204 case FilterOperation::HUE_ROTATE: {
2206 if (!decoder.decode(amount))
2208 filter = BasicColorMatrixFilterOperation::create(amount, type);
2211 case FilterOperation::INVERT:
2212 case FilterOperation::OPACITY:
2213 case FilterOperation::BRIGHTNESS:
2214 case FilterOperation::CONTRAST: {
2216 if (!decoder.decode(amount))
2218 filter = BasicComponentTransferFilterOperation::create(amount, type);
2221 case FilterOperation::BLUR: {
2222 Length stdDeviation;
2223 if (!decoder.decode(stdDeviation))
2225 filter = BlurFilterOperation::create(stdDeviation);
2228 case FilterOperation::DROP_SHADOW: {
2232 if (!decoder.decode(location))
2234 if (!decoder.decode(stdDeviation))
2236 if (!decoder.decode(color))
2238 filter = DropShadowFilterOperation::create(location, stdDeviation, color);
2241 case FilterOperation::DEFAULT: {
2242 FilterOperation::OperationType representedType;
2243 if (!decoder.decodeEnum(representedType))
2245 filter = DefaultFilterOperation::create(representedType);
2248 case FilterOperation::PASSTHROUGH:
2249 filter = PassthroughFilterOperation::create();
2257 void ArgumentCoder<FilterOperations>::encode(Encoder& encoder, const FilterOperations& filters)
2259 encoder << static_cast<uint64_t>(filters.size());
2261 for (const auto& filter : filters.operations())
2265 bool ArgumentCoder<FilterOperations>::decode(Decoder& decoder, FilterOperations& filters)
2267 uint64_t filterCount;
2268 if (!decoder.decode(filterCount))
2271 for (uint64_t i = 0; i < filterCount; ++i) {
2272 RefPtr<FilterOperation> filter;
2273 if (!decodeFilterOperation(decoder, filter))
2275 filters.operations().append(WTFMove(filter));
2280 #endif // !USE(COORDINATED_GRAPHICS)
2282 void ArgumentCoder<BlobPart>::encode(Encoder& encoder, const BlobPart& blobPart)
2284 encoder << static_cast<uint32_t>(blobPart.type());
2285 switch (blobPart.type()) {
2286 case BlobPart::Data:
2287 encoder << blobPart.data();
2289 case BlobPart::Blob:
2290 encoder << blobPart.url();
2295 std::optional<BlobPart> ArgumentCoder<BlobPart>::decode(Decoder& decoder)
2299 std::optional<uint32_t> type;
2302 return std::nullopt;
2305 case BlobPart::Data: {
2306 std::optional<Vector<uint8_t>> data;
2309 return std::nullopt;
2310 blobPart = BlobPart(WTFMove(*data));
2313 case BlobPart::Blob: {
2315 if (!decoder.decode(url))
2316 return std::nullopt;
2317 blobPart = BlobPart(url);
2321 return std::nullopt;
2324 return WTFMove(blobPart);
2327 void ArgumentCoder<TextIndicatorData>::encode(Encoder& encoder, const TextIndicatorData& textIndicatorData)
2329 encoder << textIndicatorData.selectionRectInRootViewCoordinates;
2330 encoder << textIndicatorData.textBoundingRectInRootViewCoordinates;
2331 encoder << textIndicatorData.textRectsInBoundingRectCoordinates;
2332 encoder << textIndicatorData.contentImageWithoutSelectionRectInRootViewCoordinates;
2333 encoder << textIndicatorData.contentImageScaleFactor;
2334 encoder << textIndicatorData.estimatedBackgroundColor;
2335 encoder.encodeEnum(textIndicatorData.presentationTransition);
2336 encoder << static_cast<uint64_t>(textIndicatorData.options);
2338 encodeOptionalImage(encoder, textIndicatorData.contentImage.get());
2339 encodeOptionalImage(encoder, textIndicatorData.contentImageWithHighlight.get());
2340 encodeOptionalImage(encoder, textIndicatorData.contentImageWithoutSelection.get());
2343 std::optional<TextIndicatorData> ArgumentCoder<TextIndicatorData>::decode(Decoder& decoder)
2345 TextIndicatorData textIndicatorData;
2346 if (!decoder.decode(textIndicatorData.selectionRectInRootViewCoordinates))
2347 return std::nullopt;
2349 if (!decoder.decode(textIndicatorData.textBoundingRectInRootViewCoordinates))
2350 return std::nullopt;
2352 if (!decoder.decode(textIndicatorData.textRectsInBoundingRectCoordinates))
2353 return std::nullopt;
2355 if (!decoder.decode(textIndicatorData.contentImageWithoutSelectionRectInRootViewCoordinates))
2356 return std::nullopt;
2358 if (!decoder.decode(textIndicatorData.contentImageScaleFactor))
2359 return std::nullopt;
2361 if (!decoder.decode(textIndicatorData.estimatedBackgroundColor))
2362 return std::nullopt;
2364 if (!decoder.decodeEnum(textIndicatorData.presentationTransition))
2365 return std::nullopt;
2368 if (!decoder.decode(options))
2369 return std::nullopt;
2370 textIndicatorData.options = static_cast<TextIndicatorOptions>(options);
2372 if (!decodeOptionalImage(decoder, textIndicatorData.contentImage))
2373 return std::nullopt;
2375 if (!decodeOptionalImage(decoder, textIndicatorData.contentImageWithHighlight))
2376 return std::nullopt;
2378 if (!decodeOptionalImage(decoder, textIndicatorData.contentImageWithoutSelection))
2379 return std::nullopt;
2381 return WTFMove(textIndicatorData);
2384 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
2385 void ArgumentCoder<MediaPlaybackTargetContext>::encode(Encoder& encoder, const MediaPlaybackTargetContext& target)
2387 bool hasPlatformData = target.encodingRequiresPlatformData();
2388 encoder << hasPlatformData;
2390 int32_t targetType = target.type();
2391 encoder << targetType;
2393 if (target.encodingRequiresPlatformData()) {
2394 encodePlatformData(encoder, target);
2398 ASSERT(targetType == MediaPlaybackTargetContext::MockType);
2399 encoder << target.mockDeviceName();
2400 encoder << static_cast<int32_t>(target.mockState());
2403 bool ArgumentCoder<MediaPlaybackTargetContext>::decode(Decoder& decoder, MediaPlaybackTargetContext& target)
2405 bool hasPlatformData;
2406 if (!decoder.decode(hasPlatformData))
2410 if (!decoder.decode(targetType))
2413 if (hasPlatformData)
2414 return decodePlatformData(decoder, target);
2416 ASSERT(targetType == MediaPlaybackTargetContext::MockType);
2418 String mockDeviceName;
2419 if (!decoder.decode(mockDeviceName))
2423 if (!decoder.decode(mockState))
2426 target = MediaPlaybackTargetContext(mockDeviceName, static_cast<MediaPlaybackTargetContext::State>(mockState));
2431 void ArgumentCoder<DictionaryPopupInfo>::encode(IPC::Encoder& encoder, const DictionaryPopupInfo& info)
2433 encoder << info.origin;
2434 encoder << info.textIndicator;
2437 bool hadOptions = info.options;
2438 encoder << hadOptions;
2440 IPC::encode(encoder, info.options.get());
2442 bool hadAttributedString = info.attributedString;
2443 encoder << hadAttributedString;
2444 if (hadAttributedString)
2445 IPC::encode(encoder, info.attributedString.get());
2449 bool ArgumentCoder<DictionaryPopupInfo>::decode(IPC::Decoder& decoder, DictionaryPopupInfo& result)
2451 if (!decoder.decode(result.origin))
2454 std::optional<TextIndicatorData> textIndicator;
2455 decoder >> textIndicator;
2458 result.textIndicator = WTFMove(*textIndicator);
2462 if (!decoder.decode(hadOptions))
2465 if (!IPC::decode(decoder, result.options))
2468 result.options = nullptr;
2470 bool hadAttributedString;
2471 if (!decoder.decode(hadAttributedString))
2473 if (hadAttributedString) {
2474 if (!IPC::decode(decoder, result.attributedString))
2477 result.attributedString = nullptr;
2482 void ArgumentCoder<ExceptionDetails>::encode(IPC::Encoder& encoder, const ExceptionDetails& info)
2484 encoder << info.message;
2485 encoder << info.lineNumber;
2486 encoder << info.columnNumber;
2487 encoder << info.sourceURL;
2490 bool ArgumentCoder<ExceptionDetails>::decode(IPC::Decoder& decoder, ExceptionDetails& result)
2492 if (!decoder.decode(result.message))
2495 if (!decoder.decode(result.lineNumber))
2498 if (!decoder.decode(result.columnNumber))
2501 if (!decoder.decode(result.sourceURL))
2507 void ArgumentCoder<ResourceLoadStatistics>::encode(Encoder& encoder, const WebCore::ResourceLoadStatistics& statistics)
2509 encoder << statistics.highLevelDomain;
2511 encoder << statistics.lastSeen.secondsSinceEpoch().value();
2514 encoder << statistics.hadUserInteraction;
2515 encoder << statistics.mostRecentUserInteractionTime.secondsSinceEpoch().value();
2516 encoder << statistics.grandfathered;
2519 encoder << statistics.storageAccessUnderTopFrameOrigins;
2522 encoder << statistics.subframeUnderTopFrameOrigins;
2524 // Subresource stats
2525 encoder << statistics.subresourceUnderTopFrameOrigins;
2526 encoder << statistics.subresourceUniqueRedirectsTo;
2528 // Prevalent Resource
2529 encoder << statistics.isPrevalentResource;
2530 encoder << statistics.dataRecordsRemoved;
2533 std::optional<ResourceLoadStatistics> ArgumentCoder<ResourceLoadStatistics>::decode(Decoder& decoder)
2535 ResourceLoadStatistics statistics;
2536 if (!decoder.decode(statistics.highLevelDomain))
2537 return std::nullopt;
2539 double lastSeenTimeAsDouble;
2540 if (!decoder.decode(lastSeenTimeAsDouble))
2541 return std::nullopt;
2542 statistics.lastSeen = WallTime::fromRawSeconds(lastSeenTimeAsDouble);
2545 if (!decoder.decode(statistics.hadUserInteraction))
2546 return std::nullopt;
2548 double mostRecentUserInteractionTimeAsDouble;
2549 if (!decoder.decode(mostRecentUserInteractionTimeAsDouble))
2550 return std::nullopt;
2551 statistics.mostRecentUserInteractionTime = WallTime::fromRawSeconds(mostRecentUserInteractionTimeAsDouble);
2553 if (!decoder.decode(statistics.grandfathered))
2554 return std::nullopt;
2557 if (!decoder.decode(statistics.storageAccessUnderTopFrameOrigins))
2558 return std::nullopt;
2561 if (!decoder.decode(statistics.subframeUnderTopFrameOrigins))
2562 return std::nullopt;
2564 // Subresource stats
2565 if (!decoder.decode(statistics.subresourceUnderTopFrameOrigins))
2566 return std::nullopt;
2568 if (!decoder.decode(statistics.subresourceUniqueRedirectsTo))
2569 return std::nullopt;
2571 // Prevalent Resource
2572 if (!decoder.decode(statistics.isPrevalentResource))
2573 return std::nullopt;
2575 if (!decoder.decode(statistics.dataRecordsRemoved))
2576 return std::nullopt;
2578 return WTFMove(statistics);
2581 #if ENABLE(MEDIA_STREAM)
2582 void ArgumentCoder<MediaConstraints>::encode(Encoder& encoder, const WebCore::MediaConstraints& constraint)
2584 encoder << constraint.mandatoryConstraints
2585 << constraint.advancedConstraints
2586 << constraint.deviceIDHashSalt
2587 << constraint.isValid;
2590 bool ArgumentCoder<MediaConstraints>::decode(Decoder& decoder, WebCore::MediaConstraints& constraints)
2592 std::optional<WebCore::MediaTrackConstraintSetMap> mandatoryConstraints;
2593 decoder >> mandatoryConstraints;
2594 if (!mandatoryConstraints)
2596 constraints.mandatoryConstraints = WTFMove(*mandatoryConstraints);
2597 return decoder.decode(constraints.advancedConstraints)
2598 && decoder.decode(constraints.deviceIDHashSalt)
2599 && decoder.decode(constraints.isValid);
2603 #if ENABLE(INDEXED_DATABASE)
2604 void ArgumentCoder<IDBKeyPath>::encode(Encoder& encoder, const IDBKeyPath& keyPath)
2606 bool isString = WTF::holds_alternative<String>(keyPath);
2607 encoder << isString;
2609 encoder << WTF::get<String>(keyPath);
2611 encoder << WTF::get<Vector<String>>(keyPath);
2614 bool ArgumentCoder<IDBKeyPath>::decode(Decoder& decoder, IDBKeyPath& keyPath)
2617 if (!decoder.decode(isString))
2621 if (!decoder.decode(string))
2625 Vector<String> vector;
2626 if (!decoder.decode(vector))
2634 #if ENABLE(SERVICE_WORKER)
2635 void ArgumentCoder<ServiceWorkerOrClientData>::encode(Encoder& encoder, const ServiceWorkerOrClientData& data)
2637 bool isServiceWorkerData = WTF::holds_alternative<ServiceWorkerData>(data);
2638 encoder << isServiceWorkerData;
2639 if (isServiceWorkerData)
2640 encoder << WTF::get<ServiceWorkerData>(data);
2642 encoder << WTF::get<ServiceWorkerClientData>(data);
2645 bool ArgumentCoder<ServiceWorkerOrClientData>::decode(Decoder& decoder, ServiceWorkerOrClientData& data)
2647 bool isServiceWorkerData;
2648 if (!decoder.decode(isServiceWorkerData))
2650 if (isServiceWorkerData) {
2651 std::optional<ServiceWorkerData> workerData;
2652 decoder >> workerData;
2656 data = WTFMove(*workerData);
2658 std::optional<ServiceWorkerClientData> clientData;
2659 decoder >> clientData;
2663 data = WTFMove(*clientData);
2668 void ArgumentCoder<ServiceWorkerOrClientIdentifier>::encode(Encoder& encoder, const ServiceWorkerOrClientIdentifier& identifier)
2670 bool isServiceWorkerIdentifier = WTF::holds_alternative<ServiceWorkerIdentifier>(identifier);
2671 encoder << isServiceWorkerIdentifier;
2672 if (isServiceWorkerIdentifier)
2673 encoder << WTF::get<ServiceWorkerIdentifier>(identifier);
2675 encoder << WTF::get<ServiceWorkerClientIdentifier>(identifier);
2678 bool ArgumentCoder<ServiceWorkerOrClientIdentifier>::decode(Decoder& decoder, ServiceWorkerOrClientIdentifier& identifier)
2680 bool isServiceWorkerIdentifier;
2681 if (!decoder.decode(isServiceWorkerIdentifier))
2683 if (isServiceWorkerIdentifier) {
2684 std::optional<ServiceWorkerIdentifier> workerIdentifier;
2685 decoder >> workerIdentifier;
2686 if (!workerIdentifier)
2689 identifier = WTFMove(*workerIdentifier);
2691 std::optional<ServiceWorkerClientIdentifier> clientIdentifier;
2692 decoder >> clientIdentifier;
2693 if (!clientIdentifier)
2696 identifier = WTFMove(*clientIdentifier);
2702 #if ENABLE(CSS_SCROLL_SNAP)
2704 void ArgumentCoder<ScrollOffsetRange<float>>::encode(Encoder& encoder, const ScrollOffsetRange<float>& range)
2706 encoder << range.start;
2707 encoder << range.end;
2710 auto ArgumentCoder<ScrollOffsetRange<float>>::decode(Decoder& decoder) -> std::optional<WebCore::ScrollOffsetRange<float>>
2712 WebCore::ScrollOffsetRange<float> range;
2714 if (!decoder.decode(start))
2715 return std::nullopt;
2718 if (!decoder.decode(end))
2719 return std::nullopt;
2721 range.start = start;
2723 return WTFMove(range);
2728 void ArgumentCoder<MediaSelectionOption>::encode(Encoder& encoder, const MediaSelectionOption& option)
2730 encoder << option.displayName;
2731 encoder << option.type;
2734 std::optional<MediaSelectionOption> ArgumentCoder<MediaSelectionOption>::decode(Decoder& decoder)
2736 std::optional<String> displayName;
2737 decoder >> displayName;
2739 return std::nullopt;
2741 std::optional<MediaSelectionOption::Type> type;
2744 return std::nullopt;
2746 return {{ WTFMove(*displayName), WTFMove(*type) }};
2749 void ArgumentCoder<PromisedBlobInfo>::encode(Encoder& encoder, const PromisedBlobInfo& info)
2751 encoder << info.blobURL;
2752 encoder << info.contentType;
2753 encoder << info.filename;
2754 encodeTypesAndData(encoder, info.additionalTypes, info.additionalData);
2757 bool ArgumentCoder<PromisedBlobInfo>::decode(Decoder& decoder, PromisedBlobInfo& info)
2759 if (!decoder.decode(info.blobURL))
2762 if (!decoder.decode(info.contentType))
2765 if (!decoder.decode(info.filename))
2768 if (!decodeTypesAndData(decoder, info.additionalTypes, info.additionalData))