diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebKit2/Shared/WebCoreArgumentCoders.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebKit2/Shared/WebCoreArgumentCoders.cpp')
-rw-r--r-- | Source/WebKit2/Shared/WebCoreArgumentCoders.cpp | 1789 |
1 files changed, 1235 insertions, 554 deletions
diff --git a/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp b/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp index 57e7b0370..6166ab6ea 100644 --- a/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp +++ b/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Apple Inc. All rights reserved. + * Copyright (C) 2011-2017 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -29,204 +29,665 @@ #include "DataReference.h" #include "ShareableBitmap.h" #include <WebCore/AuthenticationChallenge.h> +#include <WebCore/BlobPart.h> #include <WebCore/CertificateInfo.h> #include <WebCore/Cookie.h> #include <WebCore/Credential.h> #include <WebCore/Cursor.h> #include <WebCore/DatabaseDetails.h> #include <WebCore/DictationAlternative.h> -#include <WebCore/DragSession.h> +#include <WebCore/DictionaryPopupInfo.h> +#include <WebCore/DragData.h> #include <WebCore/Editor.h> +#include <WebCore/EventTrackingRegions.h> #include <WebCore/FileChooser.h> #include <WebCore/FilterOperation.h> #include <WebCore/FilterOperations.h> #include <WebCore/GraphicsContext.h> #include <WebCore/GraphicsLayer.h> -#include <WebCore/IDBDatabaseMetadata.h> #include <WebCore/IDBGetResult.h> -#include <WebCore/IDBKeyData.h> -#include <WebCore/IDBKeyPath.h> -#include <WebCore/IDBKeyRangeData.h> #include <WebCore/Image.h> +#include <WebCore/JSDOMExceptionHandling.h> #include <WebCore/Length.h> +#include <WebCore/Path.h> #include <WebCore/PluginData.h> #include <WebCore/ProtectionSpace.h> +#include <WebCore/Region.h> #include <WebCore/ResourceError.h> +#include <WebCore/ResourceLoadStatistics.h> #include <WebCore/ResourceRequest.h> #include <WebCore/ResourceResponse.h> #include <WebCore/ScrollingConstraints.h> #include <WebCore/ScrollingCoordinator.h> +#include <WebCore/SearchPopupMenu.h> +#include <WebCore/SessionID.h> #include <WebCore/TextCheckerClient.h> +#include <WebCore/TextIndicator.h> +#include <WebCore/TimingFunction.h> #include <WebCore/TransformationMatrix.h> #include <WebCore/URL.h> #include <WebCore/UserScript.h> #include <WebCore/UserStyleSheet.h> #include <WebCore/ViewportArguments.h> #include <WebCore/WindowFeatures.h> +#include <wtf/MonotonicTime.h> +#include <wtf/Seconds.h> #include <wtf/text/CString.h> #include <wtf/text/StringHash.h> +#if PLATFORM(COCOA) +#include "ArgumentCodersCF.h" +#include "ArgumentCodersMac.h" +#endif + #if PLATFORM(IOS) #include <WebCore/FloatQuad.h> +#include <WebCore/InspectorOverlay.h> #include <WebCore/Pasteboard.h> #include <WebCore/SelectionRect.h> #include <WebCore/SharedBuffer.h> #endif // PLATFORM(IOS) +#if ENABLE(WIRELESS_PLAYBACK_TARGET) +#include <WebCore/MediaPlaybackTargetContext.h> +#endif + +#if ENABLE(MEDIA_SESSION) +#include <WebCore/MediaSessionMetadata.h> +#endif + +#if ENABLE(MEDIA_STREAM) +#include <WebCore/CaptureDevice.h> +#include <WebCore/MediaConstraintsImpl.h> +#endif + using namespace WebCore; using namespace WebKit; namespace IPC { -void ArgumentCoder<AffineTransform>::encode(ArgumentEncoder& encoder, const AffineTransform& affineTransform) +void ArgumentCoder<MonotonicTime>::encode(Encoder& encoder, const MonotonicTime& time) +{ + encoder << time.secondsSinceEpoch().value(); +} + +bool ArgumentCoder<MonotonicTime>::decode(Decoder& decoder, MonotonicTime& time) +{ + double value; + if (!decoder.decode(value)) + return false; + + time = MonotonicTime::fromRawSeconds(value); + return true; +} + +void ArgumentCoder<Seconds>::encode(Encoder& encoder, const Seconds& seconds) +{ + encoder << seconds.value(); +} + +bool ArgumentCoder<Seconds>::decode(Decoder& decoder, Seconds& seconds) +{ + double value; + if (!decoder.decode(value)) + return false; + + seconds = Seconds(value); + return true; +} + +void ArgumentCoder<AffineTransform>::encode(Encoder& encoder, const AffineTransform& affineTransform) { SimpleArgumentCoder<AffineTransform>::encode(encoder, affineTransform); } -bool ArgumentCoder<AffineTransform>::decode(ArgumentDecoder& decoder, AffineTransform& affineTransform) +bool ArgumentCoder<AffineTransform>::decode(Decoder& decoder, AffineTransform& affineTransform) { return SimpleArgumentCoder<AffineTransform>::decode(decoder, affineTransform); } +void ArgumentCoder<EventTrackingRegions>::encode(Encoder& encoder, const EventTrackingRegions& eventTrackingRegions) +{ + encoder << eventTrackingRegions.asynchronousDispatchRegion; + encoder << eventTrackingRegions.eventSpecificSynchronousDispatchRegions; +} -void ArgumentCoder<TransformationMatrix>::encode(ArgumentEncoder& encoder, const TransformationMatrix& transformationMatrix) +bool ArgumentCoder<EventTrackingRegions>::decode(Decoder& decoder, EventTrackingRegions& eventTrackingRegions) { - SimpleArgumentCoder<TransformationMatrix>::encode(encoder, transformationMatrix); + Region asynchronousDispatchRegion; + if (!decoder.decode(asynchronousDispatchRegion)) + return false; + HashMap<String, Region> eventSpecificSynchronousDispatchRegions; + if (!decoder.decode(eventSpecificSynchronousDispatchRegions)) + return false; + eventTrackingRegions.asynchronousDispatchRegion = WTFMove(asynchronousDispatchRegion); + eventTrackingRegions.eventSpecificSynchronousDispatchRegions = WTFMove(eventSpecificSynchronousDispatchRegions); + return true; } -bool ArgumentCoder<TransformationMatrix>::decode(ArgumentDecoder& decoder, TransformationMatrix& transformationMatrix) +void ArgumentCoder<TransformationMatrix>::encode(Encoder& encoder, const TransformationMatrix& transformationMatrix) { - return SimpleArgumentCoder<TransformationMatrix>::decode(decoder, transformationMatrix); + encoder << transformationMatrix.m11(); + encoder << transformationMatrix.m12(); + encoder << transformationMatrix.m13(); + encoder << transformationMatrix.m14(); + + encoder << transformationMatrix.m21(); + encoder << transformationMatrix.m22(); + encoder << transformationMatrix.m23(); + encoder << transformationMatrix.m24(); + + encoder << transformationMatrix.m31(); + encoder << transformationMatrix.m32(); + encoder << transformationMatrix.m33(); + encoder << transformationMatrix.m34(); + + encoder << transformationMatrix.m41(); + encoder << transformationMatrix.m42(); + encoder << transformationMatrix.m43(); + encoder << transformationMatrix.m44(); } -void ArgumentCoder<FloatPoint>::encode(ArgumentEncoder& encoder, const FloatPoint& floatPoint) +bool ArgumentCoder<TransformationMatrix>::decode(Decoder& decoder, TransformationMatrix& transformationMatrix) +{ + double m11; + if (!decoder.decode(m11)) + return false; + double m12; + if (!decoder.decode(m12)) + return false; + double m13; + if (!decoder.decode(m13)) + return false; + double m14; + if (!decoder.decode(m14)) + return false; + + double m21; + if (!decoder.decode(m21)) + return false; + double m22; + if (!decoder.decode(m22)) + return false; + double m23; + if (!decoder.decode(m23)) + return false; + double m24; + if (!decoder.decode(m24)) + return false; + + double m31; + if (!decoder.decode(m31)) + return false; + double m32; + if (!decoder.decode(m32)) + return false; + double m33; + if (!decoder.decode(m33)) + return false; + double m34; + if (!decoder.decode(m34)) + return false; + + double m41; + if (!decoder.decode(m41)) + return false; + double m42; + if (!decoder.decode(m42)) + return false; + double m43; + if (!decoder.decode(m43)) + return false; + double m44; + if (!decoder.decode(m44)) + return false; + + transformationMatrix.setMatrix(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44); + return true; +} + +void ArgumentCoder<LinearTimingFunction>::encode(Encoder& encoder, const LinearTimingFunction& timingFunction) +{ + encoder.encodeEnum(timingFunction.type()); +} + +bool ArgumentCoder<LinearTimingFunction>::decode(Decoder&, LinearTimingFunction&) +{ + // Type is decoded by the caller. Nothing else to decode. + return true; +} + +void ArgumentCoder<CubicBezierTimingFunction>::encode(Encoder& encoder, const CubicBezierTimingFunction& timingFunction) +{ + encoder.encodeEnum(timingFunction.type()); + + encoder << timingFunction.x1(); + encoder << timingFunction.y1(); + encoder << timingFunction.x2(); + encoder << timingFunction.y2(); + + encoder.encodeEnum(timingFunction.timingFunctionPreset()); +} + +bool ArgumentCoder<CubicBezierTimingFunction>::decode(Decoder& decoder, CubicBezierTimingFunction& timingFunction) +{ + // Type is decoded by the caller. + double x1; + if (!decoder.decode(x1)) + return false; + + double y1; + if (!decoder.decode(y1)) + return false; + + double x2; + if (!decoder.decode(x2)) + return false; + + double y2; + if (!decoder.decode(y2)) + return false; + + CubicBezierTimingFunction::TimingFunctionPreset preset; + if (!decoder.decodeEnum(preset)) + return false; + + timingFunction.setValues(x1, y1, x2, y2); + timingFunction.setTimingFunctionPreset(preset); + + return true; +} + +void ArgumentCoder<StepsTimingFunction>::encode(Encoder& encoder, const StepsTimingFunction& timingFunction) +{ + encoder.encodeEnum(timingFunction.type()); + + encoder << timingFunction.numberOfSteps(); + encoder << timingFunction.stepAtStart(); +} + +bool ArgumentCoder<StepsTimingFunction>::decode(Decoder& decoder, StepsTimingFunction& timingFunction) +{ + // Type is decoded by the caller. + int numSteps; + if (!decoder.decode(numSteps)) + return false; + + bool stepAtStart; + if (!decoder.decode(stepAtStart)) + return false; + + timingFunction.setNumberOfSteps(numSteps); + timingFunction.setStepAtStart(stepAtStart); + + return true; +} + +void ArgumentCoder<SpringTimingFunction>::encode(Encoder& encoder, const SpringTimingFunction& timingFunction) +{ + encoder.encodeEnum(timingFunction.type()); + + encoder << timingFunction.mass(); + encoder << timingFunction.stiffness(); + encoder << timingFunction.damping(); + encoder << timingFunction.initialVelocity(); +} + +bool ArgumentCoder<SpringTimingFunction>::decode(Decoder& decoder, SpringTimingFunction& timingFunction) +{ + // Type is decoded by the caller. + double mass; + if (!decoder.decode(mass)) + return false; + + double stiffness; + if (!decoder.decode(stiffness)) + return false; + + double damping; + if (!decoder.decode(damping)) + return false; + + double initialVelocity; + if (!decoder.decode(initialVelocity)) + return false; + + timingFunction.setValues(mass, stiffness, damping, initialVelocity); + + return true; +} + +void ArgumentCoder<FloatPoint>::encode(Encoder& encoder, const FloatPoint& floatPoint) { SimpleArgumentCoder<FloatPoint>::encode(encoder, floatPoint); } -bool ArgumentCoder<FloatPoint>::decode(ArgumentDecoder& decoder, FloatPoint& floatPoint) +bool ArgumentCoder<FloatPoint>::decode(Decoder& decoder, FloatPoint& floatPoint) { return SimpleArgumentCoder<FloatPoint>::decode(decoder, floatPoint); } -void ArgumentCoder<FloatPoint3D>::encode(ArgumentEncoder& encoder, const FloatPoint3D& floatPoint) +void ArgumentCoder<FloatPoint3D>::encode(Encoder& encoder, const FloatPoint3D& floatPoint) { SimpleArgumentCoder<FloatPoint3D>::encode(encoder, floatPoint); } -bool ArgumentCoder<FloatPoint3D>::decode(ArgumentDecoder& decoder, FloatPoint3D& floatPoint) +bool ArgumentCoder<FloatPoint3D>::decode(Decoder& decoder, FloatPoint3D& floatPoint) { return SimpleArgumentCoder<FloatPoint3D>::decode(decoder, floatPoint); } -void ArgumentCoder<FloatRect>::encode(ArgumentEncoder& encoder, const FloatRect& floatRect) +void ArgumentCoder<FloatRect>::encode(Encoder& encoder, const FloatRect& floatRect) { SimpleArgumentCoder<FloatRect>::encode(encoder, floatRect); } -bool ArgumentCoder<FloatRect>::decode(ArgumentDecoder& decoder, FloatRect& floatRect) +bool ArgumentCoder<FloatRect>::decode(Decoder& decoder, FloatRect& floatRect) { return SimpleArgumentCoder<FloatRect>::decode(decoder, floatRect); } -void ArgumentCoder<FloatSize>::encode(ArgumentEncoder& encoder, const FloatSize& floatSize) +void ArgumentCoder<FloatSize>::encode(Encoder& encoder, const FloatSize& floatSize) { SimpleArgumentCoder<FloatSize>::encode(encoder, floatSize); } -bool ArgumentCoder<FloatSize>::decode(ArgumentDecoder& decoder, FloatSize& floatSize) +bool ArgumentCoder<FloatSize>::decode(Decoder& decoder, FloatSize& floatSize) { return SimpleArgumentCoder<FloatSize>::decode(decoder, floatSize); } +void ArgumentCoder<FloatRoundedRect>::encode(Encoder& encoder, const FloatRoundedRect& roundedRect) +{ + SimpleArgumentCoder<FloatRoundedRect>::encode(encoder, roundedRect); +} + +bool ArgumentCoder<FloatRoundedRect>::decode(Decoder& decoder, FloatRoundedRect& roundedRect) +{ + return SimpleArgumentCoder<FloatRoundedRect>::decode(decoder, roundedRect); +} + #if PLATFORM(IOS) -void ArgumentCoder<FloatQuad>::encode(ArgumentEncoder& encoder, const FloatQuad& floatQuad) +void ArgumentCoder<FloatQuad>::encode(Encoder& encoder, const FloatQuad& floatQuad) { SimpleArgumentCoder<FloatQuad>::encode(encoder, floatQuad); } -bool ArgumentCoder<FloatQuad>::decode(ArgumentDecoder& decoder, FloatQuad& floatQuad) +bool ArgumentCoder<FloatQuad>::decode(Decoder& decoder, FloatQuad& floatQuad) { return SimpleArgumentCoder<FloatQuad>::decode(decoder, floatQuad); } -void ArgumentCoder<ViewportArguments>::encode(ArgumentEncoder& encoder, const ViewportArguments& viewportArguments) +void ArgumentCoder<ViewportArguments>::encode(Encoder& encoder, const ViewportArguments& viewportArguments) { SimpleArgumentCoder<ViewportArguments>::encode(encoder, viewportArguments); } -bool ArgumentCoder<ViewportArguments>::decode(ArgumentDecoder& decoder, ViewportArguments& viewportArguments) +bool ArgumentCoder<ViewportArguments>::decode(Decoder& decoder, ViewportArguments& viewportArguments) { return SimpleArgumentCoder<ViewportArguments>::decode(decoder, viewportArguments); } #endif // PLATFORM(IOS) -void ArgumentCoder<IntPoint>::encode(ArgumentEncoder& encoder, const IntPoint& intPoint) +void ArgumentCoder<IntPoint>::encode(Encoder& encoder, const IntPoint& intPoint) { SimpleArgumentCoder<IntPoint>::encode(encoder, intPoint); } -bool ArgumentCoder<IntPoint>::decode(ArgumentDecoder& decoder, IntPoint& intPoint) +bool ArgumentCoder<IntPoint>::decode(Decoder& decoder, IntPoint& intPoint) { return SimpleArgumentCoder<IntPoint>::decode(decoder, intPoint); } -void ArgumentCoder<IntRect>::encode(ArgumentEncoder& encoder, const IntRect& intRect) +void ArgumentCoder<IntRect>::encode(Encoder& encoder, const IntRect& intRect) { SimpleArgumentCoder<IntRect>::encode(encoder, intRect); } -bool ArgumentCoder<IntRect>::decode(ArgumentDecoder& decoder, IntRect& intRect) +bool ArgumentCoder<IntRect>::decode(Decoder& decoder, IntRect& intRect) { return SimpleArgumentCoder<IntRect>::decode(decoder, intRect); } -void ArgumentCoder<IntSize>::encode(ArgumentEncoder& encoder, const IntSize& intSize) +void ArgumentCoder<IntSize>::encode(Encoder& encoder, const IntSize& intSize) { SimpleArgumentCoder<IntSize>::encode(encoder, intSize); } -bool ArgumentCoder<IntSize>::decode(ArgumentDecoder& decoder, IntSize& intSize) +bool ArgumentCoder<IntSize>::decode(Decoder& decoder, IntSize& intSize) { return SimpleArgumentCoder<IntSize>::decode(decoder, intSize); } -void ArgumentCoder<Length>::encode(ArgumentEncoder& encoder, const Length& length) +void ArgumentCoder<LayoutSize>::encode(Encoder& encoder, const LayoutSize& layoutSize) +{ + SimpleArgumentCoder<LayoutSize>::encode(encoder, layoutSize); +} + +bool ArgumentCoder<LayoutSize>::decode(Decoder& decoder, LayoutSize& layoutSize) +{ + return SimpleArgumentCoder<LayoutSize>::decode(decoder, layoutSize); +} + + +void ArgumentCoder<LayoutPoint>::encode(Encoder& encoder, const LayoutPoint& layoutPoint) +{ + SimpleArgumentCoder<LayoutPoint>::encode(encoder, layoutPoint); +} + +bool ArgumentCoder<LayoutPoint>::decode(Decoder& decoder, LayoutPoint& layoutPoint) +{ + return SimpleArgumentCoder<LayoutPoint>::decode(decoder, layoutPoint); +} + + +static void pathEncodeApplierFunction(Encoder& encoder, const PathElement& element) +{ + encoder.encodeEnum(element.type); + + switch (element.type) { + case PathElementMoveToPoint: // The points member will contain 1 value. + encoder << element.points[0]; + break; + case PathElementAddLineToPoint: // The points member will contain 1 value. + encoder << element.points[0]; + break; + case PathElementAddQuadCurveToPoint: // The points member will contain 2 values. + encoder << element.points[0]; + encoder << element.points[1]; + break; + case PathElementAddCurveToPoint: // The points member will contain 3 values. + encoder << element.points[0]; + encoder << element.points[1]; + encoder << element.points[2]; + break; + case PathElementCloseSubpath: // The points member will contain no values. + break; + } +} + +void ArgumentCoder<Path>::encode(Encoder& encoder, const Path& path) +{ + uint64_t numPoints = 0; + path.apply([&numPoints](const PathElement&) { + ++numPoints; + }); + + encoder << numPoints; + + path.apply([&encoder](const PathElement& pathElement) { + pathEncodeApplierFunction(encoder, pathElement); + }); +} + +bool ArgumentCoder<Path>::decode(Decoder& decoder, Path& path) +{ + uint64_t numPoints; + if (!decoder.decode(numPoints)) + return false; + + path.clear(); + + for (uint64_t i = 0; i < numPoints; ++i) { + + PathElementType elementType; + if (!decoder.decodeEnum(elementType)) + return false; + + switch (elementType) { + case PathElementMoveToPoint: { // The points member will contain 1 value. + FloatPoint point; + if (!decoder.decode(point)) + return false; + path.moveTo(point); + break; + } + case PathElementAddLineToPoint: { // The points member will contain 1 value. + FloatPoint point; + if (!decoder.decode(point)) + return false; + path.addLineTo(point); + break; + } + case PathElementAddQuadCurveToPoint: { // The points member will contain 2 values. + FloatPoint controlPoint; + if (!decoder.decode(controlPoint)) + return false; + + FloatPoint endPoint; + if (!decoder.decode(endPoint)) + return false; + + path.addQuadCurveTo(controlPoint, endPoint); + break; + } + case PathElementAddCurveToPoint: { // The points member will contain 3 values. + FloatPoint controlPoint1; + if (!decoder.decode(controlPoint1)) + return false; + + FloatPoint controlPoint2; + if (!decoder.decode(controlPoint2)) + return false; + + FloatPoint endPoint; + if (!decoder.decode(endPoint)) + return false; + + path.addBezierCurveTo(controlPoint1, controlPoint2, endPoint); + break; + } + case PathElementCloseSubpath: // The points member will contain no values. + path.closeSubpath(); + break; + } + } + + return true; +} + +void ArgumentCoder<RecentSearch>::encode(Encoder& encoder, const RecentSearch& recentSearch) +{ + encoder << recentSearch.string << recentSearch.time; +} + +bool ArgumentCoder<RecentSearch>::decode(Decoder& decoder, RecentSearch& recentSearch) +{ + if (!decoder.decode(recentSearch.string)) + return false; + + if (!decoder.decode(recentSearch.time)) + return false; + + return true; +} + +template<> struct ArgumentCoder<Region::Span> { + static void encode(Encoder&, const Region::Span&); + static bool decode(Decoder&, Region::Span&); +}; + +void ArgumentCoder<Region::Span>::encode(Encoder& encoder, const Region::Span& span) +{ + encoder << span.y; + encoder << (uint64_t)span.segmentIndex; +} + +bool ArgumentCoder<Region::Span>::decode(Decoder& decoder, Region::Span& span) +{ + if (!decoder.decode(span.y)) + return false; + + uint64_t segmentIndex; + if (!decoder.decode(segmentIndex)) + return false; + + span.segmentIndex = segmentIndex; + return true; +} + +void ArgumentCoder<Region>::encode(Encoder& encoder, const Region& region) +{ + encoder.encode(region.shapeSegments()); + encoder.encode(region.shapeSpans()); +} + +bool ArgumentCoder<Region>::decode(Decoder& decoder, Region& region) +{ + Vector<int> segments; + if (!decoder.decode(segments)) + return false; + + Vector<Region::Span> spans; + if (!decoder.decode(spans)) + return false; + + region.setShapeSegments(segments); + region.setShapeSpans(spans); + region.updateBoundsFromShape(); + + if (!region.isValid()) + return false; + + return true; +} + +void ArgumentCoder<Length>::encode(Encoder& encoder, const Length& length) { SimpleArgumentCoder<Length>::encode(encoder, length); } -bool ArgumentCoder<Length>::decode(ArgumentDecoder& decoder, Length& length) +bool ArgumentCoder<Length>::decode(Decoder& decoder, Length& length) { return SimpleArgumentCoder<Length>::decode(decoder, length); } -void ArgumentCoder<ViewportAttributes>::encode(ArgumentEncoder& encoder, const ViewportAttributes& viewportAttributes) +void ArgumentCoder<ViewportAttributes>::encode(Encoder& encoder, const ViewportAttributes& viewportAttributes) { SimpleArgumentCoder<ViewportAttributes>::encode(encoder, viewportAttributes); } -bool ArgumentCoder<ViewportAttributes>::decode(ArgumentDecoder& decoder, ViewportAttributes& viewportAttributes) +bool ArgumentCoder<ViewportAttributes>::decode(Decoder& decoder, ViewportAttributes& viewportAttributes) { return SimpleArgumentCoder<ViewportAttributes>::decode(decoder, viewportAttributes); } -void ArgumentCoder<MimeClassInfo>::encode(ArgumentEncoder& encoder, const MimeClassInfo& mimeClassInfo) +void ArgumentCoder<MimeClassInfo>::encode(Encoder& encoder, const MimeClassInfo& mimeClassInfo) { encoder << mimeClassInfo.type << mimeClassInfo.desc << mimeClassInfo.extensions; } -bool ArgumentCoder<MimeClassInfo>::decode(ArgumentDecoder& decoder, MimeClassInfo& mimeClassInfo) +bool ArgumentCoder<MimeClassInfo>::decode(Decoder& decoder, MimeClassInfo& mimeClassInfo) { if (!decoder.decode(mimeClassInfo.type)) return false; @@ -239,12 +700,21 @@ bool ArgumentCoder<MimeClassInfo>::decode(ArgumentDecoder& decoder, MimeClassInf } -void ArgumentCoder<PluginInfo>::encode(ArgumentEncoder& encoder, const PluginInfo& pluginInfo) +void ArgumentCoder<PluginInfo>::encode(Encoder& encoder, const PluginInfo& pluginInfo) { - encoder << pluginInfo.name << pluginInfo.file << pluginInfo.desc << pluginInfo.mimes << pluginInfo.isApplicationPlugin; + encoder << pluginInfo.name; + encoder << pluginInfo.file; + encoder << pluginInfo.desc; + encoder << pluginInfo.mimes; + encoder << pluginInfo.isApplicationPlugin; + encoder.encodeEnum(pluginInfo.clientLoadPolicy); +#if PLATFORM(MAC) + encoder << pluginInfo.bundleIdentifier; + encoder << pluginInfo.versionString; +#endif } - -bool ArgumentCoder<PluginInfo>::decode(ArgumentDecoder& decoder, PluginInfo& pluginInfo) + +bool ArgumentCoder<PluginInfo>::decode(Decoder& decoder, PluginInfo& pluginInfo) { if (!decoder.decode(pluginInfo.name)) return false; @@ -256,28 +726,24 @@ bool ArgumentCoder<PluginInfo>::decode(ArgumentDecoder& decoder, PluginInfo& plu return false; if (!decoder.decode(pluginInfo.isApplicationPlugin)) return false; + if (!decoder.decodeEnum(pluginInfo.clientLoadPolicy)) + return false; +#if PLATFORM(MAC) + if (!decoder.decode(pluginInfo.bundleIdentifier)) + return false; + if (!decoder.decode(pluginInfo.versionString)) + return false; +#endif return true; } - -void ArgumentCoder<HTTPHeaderMap>::encode(ArgumentEncoder& encoder, const HTTPHeaderMap& headerMap) -{ - encoder << static_cast<const HashMap<AtomicString, String, CaseFoldingHash>&>(headerMap); -} - -bool ArgumentCoder<HTTPHeaderMap>::decode(ArgumentDecoder& decoder, HTTPHeaderMap& headerMap) -{ - return decoder.decode(static_cast<HashMap<AtomicString, String, CaseFoldingHash>&>(headerMap)); -} - - -void ArgumentCoder<AuthenticationChallenge>::encode(ArgumentEncoder& encoder, const AuthenticationChallenge& challenge) +void ArgumentCoder<AuthenticationChallenge>::encode(Encoder& encoder, const AuthenticationChallenge& challenge) { encoder << challenge.protectionSpace() << challenge.proposedCredential() << challenge.previousFailureCount() << challenge.failureResponse() << challenge.error(); } -bool ArgumentCoder<AuthenticationChallenge>::decode(ArgumentDecoder& decoder, AuthenticationChallenge& challenge) +bool ArgumentCoder<AuthenticationChallenge>::decode(Decoder& decoder, AuthenticationChallenge& challenge) { ProtectionSpace protectionSpace; if (!decoder.decode(protectionSpace)) @@ -304,15 +770,29 @@ bool ArgumentCoder<AuthenticationChallenge>::decode(ArgumentDecoder& decoder, Au } -void ArgumentCoder<ProtectionSpace>::encode(ArgumentEncoder& encoder, const ProtectionSpace& space) +void ArgumentCoder<ProtectionSpace>::encode(Encoder& encoder, const ProtectionSpace& space) { + if (space.encodingRequiresPlatformData()) { + encoder << true; + encodePlatformData(encoder, space); + return; + } + + encoder << false; encoder << space.host() << space.port() << space.realm(); encoder.encodeEnum(space.authenticationScheme()); encoder.encodeEnum(space.serverType()); } -bool ArgumentCoder<ProtectionSpace>::decode(ArgumentDecoder& decoder, ProtectionSpace& space) +bool ArgumentCoder<ProtectionSpace>::decode(Decoder& decoder, ProtectionSpace& space) { + bool hasPlatformData; + if (!decoder.decode(hasPlatformData)) + return false; + + if (hasPlatformData) + return decodePlatformData(decoder, space); + String host; if (!decoder.decode(host)) return false; @@ -337,14 +817,28 @@ bool ArgumentCoder<ProtectionSpace>::decode(ArgumentDecoder& decoder, Protection return true; } -void ArgumentCoder<Credential>::encode(ArgumentEncoder& encoder, const Credential& credential) +void ArgumentCoder<Credential>::encode(Encoder& encoder, const Credential& credential) { + if (credential.encodingRequiresPlatformData()) { + encoder << true; + encodePlatformData(encoder, credential); + return; + } + + encoder << false; encoder << credential.user() << credential.password(); encoder.encodeEnum(credential.persistence()); } -bool ArgumentCoder<Credential>::decode(ArgumentDecoder& decoder, Credential& credential) +bool ArgumentCoder<Credential>::decode(Decoder& decoder, Credential& credential) { + bool hasPlatformData; + if (!decoder.decode(hasPlatformData)) + return false; + + if (hasPlatformData) + return decodePlatformData(decoder, credential); + String user; if (!decoder.decode(user)) return false; @@ -361,10 +855,10 @@ bool ArgumentCoder<Credential>::decode(ArgumentDecoder& decoder, Credential& cre return true; } -static void encodeImage(ArgumentEncoder& encoder, Image* image) +static void encodeImage(Encoder& encoder, Image& image) { - RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(image->size(), ShareableBitmap::SupportsAlpha); - bitmap->createGraphicsContext()->drawImage(image, ColorSpaceDeviceRGB, IntPoint()); + RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(IntSize(image.size()), ShareableBitmap::SupportsAlpha); + bitmap->createGraphicsContext()->drawImage(image, IntPoint()); ShareableBitmap::Handle handle; bitmap->createHandle(handle); @@ -372,7 +866,7 @@ static void encodeImage(ArgumentEncoder& encoder, Image* image) encoder << handle; } -static bool decodeImage(ArgumentDecoder& decoder, RefPtr<Image>& image) +static bool decodeImage(Decoder& decoder, RefPtr<Image>& image) { ShareableBitmap::Handle handle; if (!decoder.decode(handle)) @@ -387,8 +881,31 @@ static bool decodeImage(ArgumentDecoder& decoder, RefPtr<Image>& image) return true; } +static void encodeOptionalImage(Encoder& encoder, Image* image) +{ + bool hasImage = !!image; + encoder << hasImage; + + if (hasImage) + encodeImage(encoder, *image); +} + +static bool decodeOptionalImage(Decoder& decoder, RefPtr<Image>& image) +{ + image = nullptr; + + bool hasImage; + if (!decoder.decode(hasImage)) + return false; + + if (!hasImage) + return true; + + return decodeImage(decoder, image); +} + #if !PLATFORM(IOS) -void ArgumentCoder<Cursor>::encode(ArgumentEncoder& encoder, const Cursor& cursor) +void ArgumentCoder<Cursor>::encode(Encoder& encoder, const Cursor& cursor) { encoder.encodeEnum(cursor.type()); @@ -401,11 +918,14 @@ void ArgumentCoder<Cursor>::encode(ArgumentEncoder& encoder, const Cursor& curso } encoder << true; - encodeImage(encoder, cursor.image()); + encodeImage(encoder, *cursor.image()); encoder << cursor.hotSpot(); +#if ENABLE(MOUSE_CURSOR_SCALE) + encoder << cursor.imageScaleFactor(); +#endif } -bool ArgumentCoder<Cursor>::decode(ArgumentDecoder& decoder, Cursor& cursor) +bool ArgumentCoder<Cursor>::decode(Decoder& decoder, Cursor& cursor) { Cursor::Type type; if (!decoder.decodeEnum(type)) @@ -444,249 +964,67 @@ bool ArgumentCoder<Cursor>::decode(ArgumentDecoder& decoder, Cursor& cursor) if (!image->rect().contains(hotSpot)) return false; +#if ENABLE(MOUSE_CURSOR_SCALE) + float scale; + if (!decoder.decode(scale)) + return false; + + cursor = Cursor(image.get(), hotSpot, scale); +#else cursor = Cursor(image.get(), hotSpot); +#endif return true; } #endif -void ArgumentCoder<ResourceRequest>::encode(ArgumentEncoder& encoder, const ResourceRequest& resourceRequest) +void ArgumentCoder<ResourceRequest>::encode(Encoder& encoder, const ResourceRequest& resourceRequest) { - if (kShouldSerializeWebCoreData) { - encoder << resourceRequest.url().string(); - encoder << resourceRequest.httpMethod(); - encoder << resourceRequest.httpHeaderFields(); - - // FIXME: Do not encode HTTP message body. - // 1. It can be large and thus costly to send across. - // 2. It is misleading to provide a body with some requests, while others use body streams, which cannot be serialized at all. - FormData* httpBody = resourceRequest.httpBody(); - encoder << static_cast<bool>(httpBody); - if (httpBody) - encoder << httpBody->flattenToString(); - - encoder << resourceRequest.firstPartyForCookies().string(); - } - -#if ENABLE(CACHE_PARTITIONING) encoder << resourceRequest.cachePartition(); -#endif + encoder << resourceRequest.hiddenFromInspector(); - encodePlatformData(encoder, resourceRequest); + if (resourceRequest.encodingRequiresPlatformData()) { + encoder << true; + encodePlatformData(encoder, resourceRequest); + return; + } + encoder << false; + resourceRequest.encodeWithoutPlatformData(encoder); } -bool ArgumentCoder<ResourceRequest>::decode(ArgumentDecoder& decoder, ResourceRequest& resourceRequest) +bool ArgumentCoder<ResourceRequest>::decode(Decoder& decoder, ResourceRequest& resourceRequest) { - if (kShouldSerializeWebCoreData) { - ResourceRequest request; - - String url; - if (!decoder.decode(url)) - return false; - request.setURL(URL(URL(), url)); - - String httpMethod; - if (!decoder.decode(httpMethod)) - return false; - request.setHTTPMethod(httpMethod); - - HTTPHeaderMap headers; - if (!decoder.decode(headers)) - return false; - request.addHTTPHeaderFields(headers); - - bool hasHTTPBody; - if (!decoder.decode(hasHTTPBody)) - return false; - if (hasHTTPBody) { - String httpBody; - if (!decoder.decode(httpBody)) - return false; - request.setHTTPBody(FormData::create(httpBody.utf8())); - } - - String firstPartyForCookies; - if (!decoder.decode(firstPartyForCookies)) - return false; - request.setFirstPartyForCookies(URL(URL(), firstPartyForCookies)); - - resourceRequest = request; - } - -#if ENABLE(CACHE_PARTITIONING) String cachePartition; if (!decoder.decode(cachePartition)) return false; resourceRequest.setCachePartition(cachePartition); -#endif - - return decodePlatformData(decoder, resourceRequest); -} - -void ArgumentCoder<ResourceResponse>::encode(ArgumentEncoder& encoder, const ResourceResponse& resourceResponse) -{ -#if PLATFORM(MAC) - bool shouldSerializeWebCoreData = !resourceResponse.platformResponseIsUpToDate(); - encoder << shouldSerializeWebCoreData; -#else - bool shouldSerializeWebCoreData = true; -#endif - - encodePlatformData(encoder, resourceResponse); - - if (shouldSerializeWebCoreData) { - bool responseIsNull = resourceResponse.isNull(); - encoder << responseIsNull; - if (responseIsNull) - return; - - encoder << resourceResponse.url().string(); - encoder << static_cast<int32_t>(resourceResponse.httpStatusCode()); - encoder << resourceResponse.httpHeaderFields(); - encoder << resourceResponse.mimeType(); - encoder << resourceResponse.textEncodingName(); - encoder << static_cast<int64_t>(resourceResponse.expectedContentLength()); - encoder << resourceResponse.httpStatusText(); - encoder << resourceResponse.suggestedFilename(); - } -} - -bool ArgumentCoder<ResourceResponse>::decode(ArgumentDecoder& decoder, ResourceResponse& resourceResponse) -{ -#if PLATFORM(MAC) - bool hasSerializedWebCoreData; - if (!decoder.decode(hasSerializedWebCoreData)) + bool isHiddenFromInspector; + if (!decoder.decode(isHiddenFromInspector)) return false; -#else - bool hasSerializedWebCoreData = true; -#endif - - ResourceResponse response; + resourceRequest.setHiddenFromInspector(isHiddenFromInspector); - if (!decodePlatformData(decoder, response)) + bool hasPlatformData; + if (!decoder.decode(hasPlatformData)) return false; + if (hasPlatformData) + return decodePlatformData(decoder, resourceRequest); - if (hasSerializedWebCoreData) { - bool responseIsNull; - if (!decoder.decode(responseIsNull)) - return false; - if (responseIsNull) { - resourceResponse = ResourceResponse(); - return true; - } - - String url; - if (!decoder.decode(url)) - return false; - response.setURL(URL(URL(), url)); - - int32_t httpStatusCode; - if (!decoder.decode(httpStatusCode)) - return false; - response.setHTTPStatusCode(httpStatusCode); - - HTTPHeaderMap headers; - if (!decoder.decode(headers)) - return false; - for (HTTPHeaderMap::const_iterator it = headers.begin(), end = headers.end(); it != end; ++it) - response.setHTTPHeaderField(it->key, it->value); - - String mimeType; - if (!decoder.decode(mimeType)) - return false; - response.setMimeType(mimeType); - - String textEncodingName; - if (!decoder.decode(textEncodingName)) - return false; - response.setTextEncodingName(textEncodingName); - - int64_t contentLength; - if (!decoder.decode(contentLength)) - return false; - response.setExpectedContentLength(contentLength); - - String httpStatusText; - if (!decoder.decode(httpStatusText)) - return false; - response.setHTTPStatusText(httpStatusText); - - String suggestedFilename; - if (!decoder.decode(suggestedFilename)) - return false; - response.setSuggestedFilename(suggestedFilename); - } - - resourceResponse = response; - - return true; + return resourceRequest.decodeWithoutPlatformData(decoder); } -void ArgumentCoder<ResourceError>::encode(ArgumentEncoder& encoder, const ResourceError& resourceError) +void ArgumentCoder<ResourceError>::encode(Encoder& encoder, const ResourceError& resourceError) { - if (kShouldSerializeWebCoreData) { - bool errorIsNull = resourceError.isNull(); - encoder << errorIsNull; - if (errorIsNull) - return; - - encoder << resourceError.domain(); - encoder << resourceError.errorCode(); - encoder << resourceError.failingURL(); - encoder << resourceError.localizedDescription(); - encoder << resourceError.isCancellation(); - encoder << resourceError.isTimeout(); - } - encodePlatformData(encoder, resourceError); } -bool ArgumentCoder<ResourceError>::decode(ArgumentDecoder& decoder, ResourceError& resourceError) +bool ArgumentCoder<ResourceError>::decode(Decoder& decoder, ResourceError& resourceError) { - if (kShouldSerializeWebCoreData) { - bool errorIsNull; - if (!decoder.decode(errorIsNull)) - return false; - if (errorIsNull) { - resourceError = ResourceError(); - return true; - } - - String domain; - if (!decoder.decode(domain)) - return false; - - int errorCode; - if (!decoder.decode(errorCode)) - return false; - - String failingURL; - if (!decoder.decode(failingURL)) - return false; - - String localizedDescription; - if (!decoder.decode(localizedDescription)) - return false; - - bool isCancellation; - if (!decoder.decode(isCancellation)) - return false; - - bool isTimeout; - if (!decoder.decode(isTimeout)) - return false; - - resourceError = ResourceError(domain, errorCode, failingURL, localizedDescription); - resourceError.setIsCancellation(isCancellation); - resourceError.setIsTimeout(isTimeout); - } - return decodePlatformData(decoder, resourceError); } #if PLATFORM(IOS) -void ArgumentCoder<SelectionRect>::encode(ArgumentEncoder& encoder, const SelectionRect& selectionRect) +void ArgumentCoder<SelectionRect>::encode(Encoder& encoder, const SelectionRect& selectionRect) { encoder << selectionRect.rect(); encoder << static_cast<uint32_t>(selectionRect.direction()); @@ -702,9 +1040,9 @@ void ArgumentCoder<SelectionRect>::encode(ArgumentEncoder& encoder, const Select encoder << selectionRect.isHorizontal(); } -bool ArgumentCoder<SelectionRect>::decode(ArgumentDecoder& decoder, SelectionRect& selectionRect) +bool ArgumentCoder<SelectionRect>::decode(Decoder& decoder, SelectionRect& selectionRect) { - WebCore::IntRect rect; + IntRect rect; if (!decoder.decode(rect)) return false; selectionRect.setRect(rect); @@ -712,7 +1050,7 @@ bool ArgumentCoder<SelectionRect>::decode(ArgumentDecoder& decoder, SelectionRec uint32_t direction; if (!decoder.decode(direction)) return false; - selectionRect.setDirection((WebCore::TextDirection)direction); + selectionRect.setDirection((TextDirection)direction); int intValue; if (!decoder.decode(intValue)) @@ -761,16 +1099,12 @@ bool ArgumentCoder<SelectionRect>::decode(ArgumentDecoder& decoder, SelectionRec #endif -void ArgumentCoder<WindowFeatures>::encode(ArgumentEncoder& encoder, const WindowFeatures& windowFeatures) +void ArgumentCoder<WindowFeatures>::encode(Encoder& encoder, const WindowFeatures& windowFeatures) { encoder << windowFeatures.x; encoder << windowFeatures.y; encoder << windowFeatures.width; encoder << windowFeatures.height; - encoder << windowFeatures.xSet; - encoder << windowFeatures.ySet; - encoder << windowFeatures.widthSet; - encoder << windowFeatures.heightSet; encoder << windowFeatures.menuBarVisible; encoder << windowFeatures.statusBarVisible; encoder << windowFeatures.toolBarVisible; @@ -781,7 +1115,7 @@ void ArgumentCoder<WindowFeatures>::encode(ArgumentEncoder& encoder, const Windo encoder << windowFeatures.dialog; } -bool ArgumentCoder<WindowFeatures>::decode(ArgumentDecoder& decoder, WindowFeatures& windowFeatures) +bool ArgumentCoder<WindowFeatures>::decode(Decoder& decoder, WindowFeatures& windowFeatures) { if (!decoder.decode(windowFeatures.x)) return false; @@ -791,14 +1125,6 @@ bool ArgumentCoder<WindowFeatures>::decode(ArgumentDecoder& decoder, WindowFeatu return false; if (!decoder.decode(windowFeatures.height)) return false; - if (!decoder.decode(windowFeatures.xSet)) - return false; - if (!decoder.decode(windowFeatures.ySet)) - return false; - if (!decoder.decode(windowFeatures.widthSet)) - return false; - if (!decoder.decode(windowFeatures.heightSet)) - return false; if (!decoder.decode(windowFeatures.menuBarVisible)) return false; if (!decoder.decode(windowFeatures.statusBarVisible)) @@ -819,8 +1145,20 @@ bool ArgumentCoder<WindowFeatures>::decode(ArgumentDecoder& decoder, WindowFeatu } -void ArgumentCoder<Color>::encode(ArgumentEncoder& encoder, const Color& color) +void ArgumentCoder<Color>::encode(Encoder& encoder, const Color& color) { + if (color.isExtended()) { + encoder << true; + encoder << color.asExtended().red(); + encoder << color.asExtended().green(); + encoder << color.asExtended().blue(); + encoder << color.asExtended().alpha(); + encoder << color.asExtended().colorSpace(); + return; + } + + encoder << false; + if (!color.isValid()) { encoder << false; return; @@ -830,8 +1168,32 @@ void ArgumentCoder<Color>::encode(ArgumentEncoder& encoder, const Color& color) encoder << color.rgb(); } -bool ArgumentCoder<Color>::decode(ArgumentDecoder& decoder, Color& color) +bool ArgumentCoder<Color>::decode(Decoder& decoder, Color& color) { + bool isExtended; + if (!decoder.decode(isExtended)) + return false; + + if (isExtended) { + float red; + float green; + float blue; + float alpha; + ColorSpace colorSpace; + if (!decoder.decode(red)) + return false; + if (!decoder.decode(green)) + return false; + if (!decoder.decode(blue)) + return false; + if (!decoder.decode(alpha)) + return false; + if (!decoder.decode(colorSpace)) + return false; + color = Color(red, green, blue, alpha, colorSpace); + return true; + } + bool isValid; if (!decoder.decode(isValid)) return false; @@ -849,8 +1211,58 @@ bool ArgumentCoder<Color>::decode(ArgumentDecoder& decoder, Color& color) return true; } +#if ENABLE(DRAG_SUPPORT) +void ArgumentCoder<DragData>::encode(Encoder& encoder, const DragData& dragData) +{ + encoder << dragData.clientPosition(); + encoder << dragData.globalPosition(); + encoder.encodeEnum(dragData.draggingSourceOperationMask()); + encoder.encodeEnum(dragData.flags()); +#if PLATFORM(COCOA) + encoder << dragData.pasteboardName(); +#endif +#if PLATFORM(MAC) + encoder << dragData.fileNames(); +#endif +} + +bool ArgumentCoder<DragData>::decode(Decoder& decoder, DragData& dragData) +{ + IntPoint clientPosition; + if (!decoder.decode(clientPosition)) + return false; + + IntPoint globalPosition; + if (!decoder.decode(globalPosition)) + return false; + + DragOperation draggingSourceOperationMask; + if (!decoder.decodeEnum(draggingSourceOperationMask)) + return false; + + DragApplicationFlags applicationFlags; + if (!decoder.decodeEnum(applicationFlags)) + return false; + + String pasteboardName; +#if PLATFORM(COCOA) + if (!decoder.decode(pasteboardName)) + return false; +#endif + Vector<String> fileNames; +#if PLATFORM(MAC) + if (!decoder.decode(fileNames)) + return false; +#endif + + dragData = DragData(pasteboardName, clientPosition, globalPosition, draggingSourceOperationMask, applicationFlags); + dragData.setFileNames(fileNames); + + return true; +} +#endif -void ArgumentCoder<CompositionUnderline>::encode(ArgumentEncoder& encoder, const CompositionUnderline& underline) +void ArgumentCoder<CompositionUnderline>::encode(Encoder& encoder, const CompositionUnderline& underline) { encoder << underline.startOffset; encoder << underline.endOffset; @@ -858,7 +1270,7 @@ void ArgumentCoder<CompositionUnderline>::encode(ArgumentEncoder& encoder, const encoder << underline.color; } -bool ArgumentCoder<CompositionUnderline>::decode(ArgumentDecoder& decoder, CompositionUnderline& underline) +bool ArgumentCoder<CompositionUnderline>::decode(Decoder& decoder, CompositionUnderline& underline) { if (!decoder.decode(underline.startOffset)) return false; @@ -873,7 +1285,7 @@ bool ArgumentCoder<CompositionUnderline>::decode(ArgumentDecoder& decoder, Compo } -void ArgumentCoder<Cookie>::encode(ArgumentEncoder& encoder, const Cookie& cookie) +void ArgumentCoder<Cookie>::encode(Encoder& encoder, const Cookie& cookie) { encoder << cookie.name; encoder << cookie.value; @@ -885,7 +1297,7 @@ void ArgumentCoder<Cookie>::encode(ArgumentEncoder& encoder, const Cookie& cooki encoder << cookie.session; } -bool ArgumentCoder<Cookie>::decode(ArgumentDecoder& decoder, Cookie& cookie) +bool ArgumentCoder<Cookie>::decode(Decoder& decoder, Cookie& cookie) { if (!decoder.decode(cookie.name)) return false; @@ -907,9 +1319,7 @@ bool ArgumentCoder<Cookie>::decode(ArgumentDecoder& decoder, Cookie& cookie) return true; } - -#if ENABLE(SQL_DATABASE) -void ArgumentCoder<DatabaseDetails>::encode(ArgumentEncoder& encoder, const DatabaseDetails& details) +void ArgumentCoder<DatabaseDetails>::encode(Encoder& encoder, const DatabaseDetails& details) { encoder << details.name(); encoder << details.displayName(); @@ -919,7 +1329,7 @@ void ArgumentCoder<DatabaseDetails>::encode(ArgumentEncoder& encoder, const Data encoder << details.modificationTime(); } -bool ArgumentCoder<DatabaseDetails>::decode(ArgumentDecoder& decoder, DatabaseDetails& details) +bool ArgumentCoder<DatabaseDetails>::decode(Decoder& decoder, DatabaseDetails& details) { String name; if (!decoder.decode(name)) @@ -949,23 +1359,57 @@ bool ArgumentCoder<DatabaseDetails>::decode(ArgumentDecoder& decoder, DatabaseDe return true; } -#endif - #if PLATFORM(IOS) -static void encodeSharedBuffer(ArgumentEncoder& encoder, SharedBuffer* buffer) +void ArgumentCoder<Highlight>::encode(Encoder& encoder, const Highlight& highlight) +{ + encoder << static_cast<uint32_t>(highlight.type); + encoder << highlight.usePageCoordinates; + encoder << highlight.contentColor; + encoder << highlight.contentOutlineColor; + encoder << highlight.paddingColor; + encoder << highlight.borderColor; + encoder << highlight.marginColor; + encoder << highlight.quads; +} + +bool ArgumentCoder<Highlight>::decode(Decoder& decoder, Highlight& highlight) +{ + uint32_t type; + if (!decoder.decode(type)) + return false; + highlight.type = (HighlightType)type; + + if (!decoder.decode(highlight.usePageCoordinates)) + return false; + if (!decoder.decode(highlight.contentColor)) + return false; + if (!decoder.decode(highlight.contentOutlineColor)) + return false; + if (!decoder.decode(highlight.paddingColor)) + return false; + if (!decoder.decode(highlight.borderColor)) + return false; + if (!decoder.decode(highlight.marginColor)) + return false; + if (!decoder.decode(highlight.quads)) + return false; + return true; +} + +static void encodeSharedBuffer(Encoder& encoder, SharedBuffer* buffer) { SharedMemory::Handle handle; encoder << (buffer ? static_cast<uint64_t>(buffer->size()): 0); if (buffer) { - RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::create(buffer->size()); + RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::allocate(buffer->size()); memcpy(sharedMemoryBuffer->data(), buffer->data(), buffer->size()); - sharedMemoryBuffer->createHandle(handle, SharedMemory::ReadOnly); + sharedMemoryBuffer->createHandle(handle, SharedMemory::Protection::ReadOnly); encoder << handle; } } -static bool decodeSharedBuffer(ArgumentDecoder& decoder, RefPtr<SharedBuffer>& buffer) +static bool decodeSharedBuffer(Decoder& decoder, RefPtr<SharedBuffer>& buffer) { uint64_t bufferSize = 0; if (!decoder.decode(bufferSize)) @@ -976,14 +1420,14 @@ static bool decodeSharedBuffer(ArgumentDecoder& decoder, RefPtr<SharedBuffer>& b if (!decoder.decode(handle)) return false; - RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::create(handle, SharedMemory::ReadOnly); + RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::map(handle, SharedMemory::Protection::ReadOnly); buffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryBuffer->data()), bufferSize); } return true; } -void ArgumentCoder<PasteboardWebContent>::encode(ArgumentEncoder& encoder, const WebCore::PasteboardWebContent& content) +void ArgumentCoder<PasteboardWebContent>::encode(Encoder& encoder, const PasteboardWebContent& content) { encoder << content.canSmartCopyOrDelete; encoder << content.dataInStringFormat; @@ -998,7 +1442,7 @@ void ArgumentCoder<PasteboardWebContent>::encode(ArgumentEncoder& encoder, const encodeSharedBuffer(encoder, content.clientData[i].get()); } -bool ArgumentCoder<PasteboardWebContent>::decode(ArgumentDecoder& decoder, WebCore::PasteboardWebContent& content) +bool ArgumentCoder<PasteboardWebContent>::decode(Decoder& decoder, PasteboardWebContent& content) { if (!decoder.decode(content.canSmartCopyOrDelete)) return false; @@ -1022,9 +1466,9 @@ bool ArgumentCoder<PasteboardWebContent>::decode(ArgumentDecoder& decoder, WebCo return true; } -void ArgumentCoder<PasteboardImage>::encode(ArgumentEncoder& encoder, const WebCore::PasteboardImage& pasteboardImage) +void ArgumentCoder<PasteboardImage>::encode(Encoder& encoder, const PasteboardImage& pasteboardImage) { - encodeImage(encoder, pasteboardImage.image.get()); + encodeOptionalImage(encoder, pasteboardImage.image.get()); encoder << pasteboardImage.url.url; encoder << pasteboardImage.url.title; encoder << pasteboardImage.resourceMIMEType; @@ -1032,9 +1476,9 @@ void ArgumentCoder<PasteboardImage>::encode(ArgumentEncoder& encoder, const WebC encodeSharedBuffer(encoder, pasteboardImage.resourceData.get()); } -bool ArgumentCoder<PasteboardImage>::decode(ArgumentDecoder& decoder, WebCore::PasteboardImage& pasteboardImage) +bool ArgumentCoder<PasteboardImage>::decode(Decoder& decoder, PasteboardImage& pasteboardImage) { - if (!decodeImage(decoder, pasteboardImage.image)) + if (!decodeOptionalImage(decoder, pasteboardImage.image)) return false; if (!decoder.decode(pasteboardImage.url.url)) return false; @@ -1049,14 +1493,14 @@ bool ArgumentCoder<PasteboardImage>::decode(ArgumentDecoder& decoder, WebCore::P #endif -void ArgumentCoder<DictationAlternative>::encode(ArgumentEncoder& encoder, const DictationAlternative& dictationAlternative) +void ArgumentCoder<DictationAlternative>::encode(Encoder& encoder, const DictationAlternative& dictationAlternative) { encoder << dictationAlternative.rangeStart; encoder << dictationAlternative.rangeLength; encoder << dictationAlternative.dictationContext; } -bool ArgumentCoder<DictationAlternative>::decode(ArgumentDecoder& decoder, DictationAlternative& dictationAlternative) +bool ArgumentCoder<DictationAlternative>::decode(Decoder& decoder, DictationAlternative& dictationAlternative) { if (!decoder.decode(dictationAlternative.rangeStart)) return false; @@ -1068,33 +1512,26 @@ bool ArgumentCoder<DictationAlternative>::decode(ArgumentDecoder& decoder, Dicta } -void ArgumentCoder<FileChooserSettings>::encode(ArgumentEncoder& encoder, const FileChooserSettings& settings) +void ArgumentCoder<FileChooserSettings>::encode(Encoder& encoder, const FileChooserSettings& settings) { encoder << settings.allowsMultipleFiles; -#if ENABLE(DIRECTORY_UPLOAD) - encoder << settings.allowsDirectoryUpload; -#endif encoder << settings.acceptMIMETypes; encoder << settings.selectedFiles; #if ENABLE(MEDIA_CAPTURE) - encoder << settings.capture; + encoder.encodeEnum(settings.mediaCaptureType); #endif } -bool ArgumentCoder<FileChooserSettings>::decode(ArgumentDecoder& decoder, FileChooserSettings& settings) +bool ArgumentCoder<FileChooserSettings>::decode(Decoder& decoder, FileChooserSettings& settings) { if (!decoder.decode(settings.allowsMultipleFiles)) return false; -#if ENABLE(DIRECTORY_UPLOAD) - if (!decoder.decode(settings.allowsDirectoryUpload)) - return false; -#endif if (!decoder.decode(settings.acceptMIMETypes)) return false; if (!decoder.decode(settings.selectedFiles)) return false; #if ENABLE(MEDIA_CAPTURE) - if (!decoder.decode(settings.capture)) + if (!decoder.decodeEnum(settings.mediaCaptureType)) return false; #endif @@ -1102,7 +1539,7 @@ bool ArgumentCoder<FileChooserSettings>::decode(ArgumentDecoder& decoder, FileCh } -void ArgumentCoder<GrammarDetail>::encode(ArgumentEncoder& encoder, const GrammarDetail& detail) +void ArgumentCoder<GrammarDetail>::encode(Encoder& encoder, const GrammarDetail& detail) { encoder << detail.location; encoder << detail.length; @@ -1110,7 +1547,7 @@ void ArgumentCoder<GrammarDetail>::encode(ArgumentEncoder& encoder, const Gramma encoder << detail.userDescription; } -bool ArgumentCoder<GrammarDetail>::decode(ArgumentDecoder& decoder, GrammarDetail& detail) +bool ArgumentCoder<GrammarDetail>::decode(Decoder& decoder, GrammarDetail& detail) { if (!decoder.decode(detail.location)) return false; @@ -1124,7 +1561,7 @@ bool ArgumentCoder<GrammarDetail>::decode(ArgumentDecoder& decoder, GrammarDetai return true; } -void ArgumentCoder<TextCheckingRequestData>::encode(ArgumentEncoder& encoder, const TextCheckingRequestData& request) +void ArgumentCoder<TextCheckingRequestData>::encode(Encoder& encoder, const TextCheckingRequestData& request) { encoder << request.sequence(); encoder << request.text(); @@ -1132,7 +1569,7 @@ void ArgumentCoder<TextCheckingRequestData>::encode(ArgumentEncoder& encoder, co encoder.encodeEnum(request.processType()); } -bool ArgumentCoder<TextCheckingRequestData>::decode(ArgumentDecoder& decoder, TextCheckingRequestData& request) +bool ArgumentCoder<TextCheckingRequestData>::decode(Decoder& decoder, TextCheckingRequestData& request) { int sequence; if (!decoder.decode(sequence)) @@ -1154,7 +1591,7 @@ bool ArgumentCoder<TextCheckingRequestData>::decode(ArgumentDecoder& decoder, Te return true; } -void ArgumentCoder<TextCheckingResult>::encode(ArgumentEncoder& encoder, const TextCheckingResult& result) +void ArgumentCoder<TextCheckingResult>::encode(Encoder& encoder, const TextCheckingResult& result) { encoder.encodeEnum(result.type); encoder << result.location; @@ -1163,7 +1600,7 @@ void ArgumentCoder<TextCheckingResult>::encode(ArgumentEncoder& encoder, const T encoder << result.replacement; } -bool ArgumentCoder<TextCheckingResult>::decode(ArgumentDecoder& decoder, TextCheckingResult& result) +bool ArgumentCoder<TextCheckingResult>::decode(Decoder& decoder, TextCheckingResult& result) { if (!decoder.decodeEnum(result.type)) return false; @@ -1178,39 +1615,21 @@ bool ArgumentCoder<TextCheckingResult>::decode(ArgumentDecoder& decoder, TextChe return true; } -void ArgumentCoder<DragSession>::encode(ArgumentEncoder& encoder, const DragSession& result) -{ - encoder.encodeEnum(result.operation); - encoder << result.mouseIsOverFileInput; - encoder << result.numberOfItemsToBeAccepted; -} - -bool ArgumentCoder<DragSession>::decode(ArgumentDecoder& decoder, DragSession& result) -{ - if (!decoder.decodeEnum(result.operation)) - return false; - if (!decoder.decode(result.mouseIsOverFileInput)) - return false; - if (!decoder.decode(result.numberOfItemsToBeAccepted)) - return false; - return true; -} - -void ArgumentCoder<URL>::encode(ArgumentEncoder& encoder, const URL& result) +void ArgumentCoder<URL>::encode(Encoder& encoder, const URL& result) { encoder << result.string(); } -bool ArgumentCoder<URL>::decode(ArgumentDecoder& decoder, URL& result) +bool ArgumentCoder<URL>::decode(Decoder& decoder, URL& result) { String urlAsString; if (!decoder.decode(urlAsString)) return false; - result = URL(WebCore::ParsedURLString, urlAsString); + result = URL(ParsedURLString, urlAsString); return true; } -void ArgumentCoder<WebCore::UserStyleSheet>::encode(ArgumentEncoder& encoder, const WebCore::UserStyleSheet& userStyleSheet) +void ArgumentCoder<UserStyleSheet>::encode(Encoder& encoder, const UserStyleSheet& userStyleSheet) { encoder << userStyleSheet.source(); encoder << userStyleSheet.url(); @@ -1220,7 +1639,7 @@ void ArgumentCoder<WebCore::UserStyleSheet>::encode(ArgumentEncoder& encoder, co encoder.encodeEnum(userStyleSheet.level()); } -bool ArgumentCoder<WebCore::UserStyleSheet>::decode(ArgumentDecoder& decoder, WebCore::UserStyleSheet& userStyleSheet) +bool ArgumentCoder<UserStyleSheet>::decode(Decoder& decoder, UserStyleSheet& userStyleSheet) { String source; if (!decoder.decode(source)) @@ -1238,19 +1657,45 @@ bool ArgumentCoder<WebCore::UserStyleSheet>::decode(ArgumentDecoder& decoder, We if (!decoder.decode(blacklist)) return false; - WebCore::UserContentInjectedFrames injectedFrames; + UserContentInjectedFrames injectedFrames; if (!decoder.decodeEnum(injectedFrames)) return false; - WebCore::UserStyleLevel level; + UserStyleLevel level; if (!decoder.decodeEnum(level)) return false; - userStyleSheet = WebCore::UserStyleSheet(source, url, whitelist, blacklist, injectedFrames, level); + userStyleSheet = UserStyleSheet(source, url, WTFMove(whitelist), WTFMove(blacklist), injectedFrames, level); return true; } -void ArgumentCoder<WebCore::UserScript>::encode(ArgumentEncoder& encoder, const WebCore::UserScript& userScript) +#if ENABLE(MEDIA_SESSION) +void ArgumentCoder<MediaSessionMetadata>::encode(Encoder& encoder, const MediaSessionMetadata& result) +{ + encoder << result.artist(); + encoder << result.album(); + encoder << result.title(); + encoder << result.artworkURL(); +} + +bool ArgumentCoder<MediaSessionMetadata>::decode(Decoder& decoder, MediaSessionMetadata& result) +{ + String artist, album, title; + URL artworkURL; + if (!decoder.decode(artist)) + return false; + if (!decoder.decode(album)) + return false; + if (!decoder.decode(title)) + return false; + if (!decoder.decode(artworkURL)) + return false; + result = MediaSessionMetadata(title, artist, album, artworkURL); + return true; +} +#endif + +void ArgumentCoder<UserScript>::encode(Encoder& encoder, const UserScript& userScript) { encoder << userScript.source(); encoder << userScript.url(); @@ -1260,7 +1705,7 @@ void ArgumentCoder<WebCore::UserScript>::encode(ArgumentEncoder& encoder, const encoder.encodeEnum(userScript.injectedFrames()); } -bool ArgumentCoder<WebCore::UserScript>::decode(ArgumentDecoder& decoder, WebCore::UserScript& userScript) +bool ArgumentCoder<UserScript>::decode(Decoder& decoder, UserScript& userScript) { String source; if (!decoder.decode(source)) @@ -1278,19 +1723,19 @@ bool ArgumentCoder<WebCore::UserScript>::decode(ArgumentDecoder& decoder, WebCor if (!decoder.decode(blacklist)) return false; - WebCore::UserScriptInjectionTime injectionTime; + UserScriptInjectionTime injectionTime; if (!decoder.decodeEnum(injectionTime)) return false; - WebCore::UserContentInjectedFrames injectedFrames; + UserContentInjectedFrames injectedFrames; if (!decoder.decodeEnum(injectedFrames)) return false; - userScript = WebCore::UserScript(source, url, whitelist, blacklist, injectionTime, injectedFrames); + userScript = UserScript(source, url, WTFMove(whitelist), WTFMove(blacklist), injectionTime, injectedFrames); return true; } -void ArgumentCoder<WebCore::ScrollableAreaParameters>::encode(ArgumentEncoder& encoder, const WebCore::ScrollableAreaParameters& parameters) +void ArgumentCoder<ScrollableAreaParameters>::encode(Encoder& encoder, const ScrollableAreaParameters& parameters) { encoder.encodeEnum(parameters.horizontalScrollElasticity); encoder.encodeEnum(parameters.verticalScrollElasticity); @@ -1302,7 +1747,7 @@ void ArgumentCoder<WebCore::ScrollableAreaParameters>::encode(ArgumentEncoder& e encoder << parameters.hasEnabledVerticalScrollbar; } -bool ArgumentCoder<WebCore::ScrollableAreaParameters>::decode(ArgumentDecoder& decoder, WebCore::ScrollableAreaParameters& params) +bool ArgumentCoder<ScrollableAreaParameters>::decode(Decoder& decoder, ScrollableAreaParameters& params) { if (!decoder.decodeEnum(params.horizontalScrollElasticity)) return false; @@ -1322,7 +1767,7 @@ bool ArgumentCoder<WebCore::ScrollableAreaParameters>::decode(ArgumentDecoder& d return true; } -void ArgumentCoder<WebCore::FixedPositionViewportConstraints>::encode(ArgumentEncoder& encoder, const WebCore::FixedPositionViewportConstraints& viewportConstraints) +void ArgumentCoder<FixedPositionViewportConstraints>::encode(Encoder& encoder, const FixedPositionViewportConstraints& viewportConstraints) { encoder << viewportConstraints.alignmentOffset(); encoder << viewportConstraints.anchorEdges(); @@ -1331,7 +1776,7 @@ void ArgumentCoder<WebCore::FixedPositionViewportConstraints>::encode(ArgumentEn encoder << viewportConstraints.layerPositionAtLastLayout(); } -bool ArgumentCoder<WebCore::FixedPositionViewportConstraints>::decode(ArgumentDecoder& decoder, WebCore::FixedPositionViewportConstraints& viewportConstraints) +bool ArgumentCoder<FixedPositionViewportConstraints>::decode(Decoder& decoder, FixedPositionViewportConstraints& viewportConstraints) { FloatSize alignmentOffset; if (!decoder.decode(alignmentOffset)) @@ -1349,7 +1794,7 @@ bool ArgumentCoder<WebCore::FixedPositionViewportConstraints>::decode(ArgumentDe if (!decoder.decode(layerPositionAtLastLayout)) return false; - viewportConstraints = WebCore::FixedPositionViewportConstraints(); + viewportConstraints = FixedPositionViewportConstraints(); viewportConstraints.setAlignmentOffset(alignmentOffset); viewportConstraints.setAnchorEdges(anchorEdges); @@ -1359,7 +1804,7 @@ bool ArgumentCoder<WebCore::FixedPositionViewportConstraints>::decode(ArgumentDe return true; } -void ArgumentCoder<WebCore::StickyPositionViewportConstraints>::encode(ArgumentEncoder& encoder, const WebCore::StickyPositionViewportConstraints& viewportConstraints) +void ArgumentCoder<StickyPositionViewportConstraints>::encode(Encoder& encoder, const StickyPositionViewportConstraints& viewportConstraints) { encoder << viewportConstraints.alignmentOffset(); encoder << viewportConstraints.anchorEdges(); @@ -1377,7 +1822,7 @@ void ArgumentCoder<WebCore::StickyPositionViewportConstraints>::encode(ArgumentE encoder << viewportConstraints.layerPositionAtLastLayout(); } -bool ArgumentCoder<WebCore::StickyPositionViewportConstraints>::decode(ArgumentDecoder& decoder, WebCore::StickyPositionViewportConstraints& viewportConstraints) +bool ArgumentCoder<StickyPositionViewportConstraints>::decode(Decoder& decoder, StickyPositionViewportConstraints& viewportConstraints) { FloatSize alignmentOffset; if (!decoder.decode(alignmentOffset)) @@ -1423,7 +1868,7 @@ bool ArgumentCoder<WebCore::StickyPositionViewportConstraints>::decode(ArgumentD if (!decoder.decode(layerPositionAtLastLayout)) return false; - viewportConstraints = WebCore::StickyPositionViewportConstraints(); + viewportConstraints = StickyPositionViewportConstraints(); viewportConstraints.setAlignmentOffset(alignmentOffset); viewportConstraints.setAnchorEdges(anchorEdges); @@ -1442,63 +1887,58 @@ bool ArgumentCoder<WebCore::StickyPositionViewportConstraints>::decode(ArgumentD return true; } -#if ENABLE(CSS_FILTERS) && !USE(COORDINATED_GRAPHICS) -static void encodeFilterOperation(ArgumentEncoder& encoder, const FilterOperation& filter) +#if !USE(COORDINATED_GRAPHICS) +void ArgumentCoder<FilterOperation>::encode(Encoder& encoder, const FilterOperation& filter) { encoder.encodeEnum(filter.type()); switch (filter.type()) { - case FilterOperation::REFERENCE: { - const auto& referenceFilter = static_cast<const ReferenceFilterOperation&>(filter); - encoder << referenceFilter.url(); - encoder << referenceFilter.fragment(); + case FilterOperation::NONE: + case FilterOperation::REFERENCE: + ASSERT_NOT_REACHED(); break; - } case FilterOperation::GRAYSCALE: case FilterOperation::SEPIA: case FilterOperation::SATURATE: case FilterOperation::HUE_ROTATE: - encoder << static_cast<const BasicColorMatrixFilterOperation&>(filter).amount(); + encoder << downcast<BasicColorMatrixFilterOperation>(filter).amount(); break; case FilterOperation::INVERT: case FilterOperation::OPACITY: case FilterOperation::BRIGHTNESS: case FilterOperation::CONTRAST: - encoder << static_cast<const BasicComponentTransferFilterOperation&>(filter).amount(); + encoder << downcast<BasicComponentTransferFilterOperation>(filter).amount(); break; case FilterOperation::BLUR: - encoder << static_cast<const BlurFilterOperation&>(filter).stdDeviation(); + encoder << downcast<BlurFilterOperation>(filter).stdDeviation(); break; case FilterOperation::DROP_SHADOW: { - const auto& dropShadowFilter = static_cast<const DropShadowFilterOperation&>(filter); + const auto& dropShadowFilter = downcast<DropShadowFilterOperation>(filter); encoder << dropShadowFilter.location(); encoder << dropShadowFilter.stdDeviation(); encoder << dropShadowFilter.color(); break; } + case FilterOperation::DEFAULT: + encoder.encodeEnum(downcast<DefaultFilterOperation>(filter).representedType()); + break; case FilterOperation::PASSTHROUGH: - case FilterOperation::NONE: break; - }; + } } -static bool decodeFilterOperation(ArgumentDecoder& decoder, RefPtr<FilterOperation>& filter) +bool decodeFilterOperation(Decoder& decoder, RefPtr<FilterOperation>& filter) { FilterOperation::OperationType type; if (!decoder.decodeEnum(type)) return false; switch (type) { - case FilterOperation::REFERENCE: { - String url; - String fragment; - if (!decoder.decode(url)) - return false; - if (!decoder.decode(fragment)) - return false; - filter = ReferenceFilterOperation::create(url, fragment, type); - break; - } + case FilterOperation::NONE: + case FilterOperation::REFERENCE: + ASSERT_NOT_REACHED(); + decoder.markInvalid(); + return false; case FilterOperation::GRAYSCALE: case FilterOperation::SEPIA: case FilterOperation::SATURATE: @@ -1523,7 +1963,7 @@ static bool decodeFilterOperation(ArgumentDecoder& decoder, RefPtr<FilterOperati Length stdDeviation; if (!decoder.decode(stdDeviation)) return false; - filter = BlurFilterOperation::create(stdDeviation, type); + filter = BlurFilterOperation::create(stdDeviation); break; } case FilterOperation::DROP_SHADOW: { @@ -1536,27 +1976,34 @@ static bool decodeFilterOperation(ArgumentDecoder& decoder, RefPtr<FilterOperati return false; if (!decoder.decode(color)) return false; - filter = DropShadowFilterOperation::create(location, stdDeviation, color, type); + filter = DropShadowFilterOperation::create(location, stdDeviation, color); + break; + } + case FilterOperation::DEFAULT: { + FilterOperation::OperationType representedType; + if (!decoder.decodeEnum(representedType)) + return false; + filter = DefaultFilterOperation::create(representedType); break; } case FilterOperation::PASSTHROUGH: - case FilterOperation::NONE: + filter = PassthroughFilterOperation::create(); break; - }; - + } + return true; } -void ArgumentCoder<FilterOperations>::encode(ArgumentEncoder& encoder, const FilterOperations& filters) +void ArgumentCoder<FilterOperations>::encode(Encoder& encoder, const FilterOperations& filters) { encoder << static_cast<uint64_t>(filters.size()); for (const auto& filter : filters.operations()) - encodeFilterOperation(encoder, *filter); + encoder << *filter; } -bool ArgumentCoder<FilterOperations>::decode(ArgumentDecoder& decoder, FilterOperations& filters) +bool ArgumentCoder<FilterOperations>::decode(Decoder& decoder, FilterOperations& filters) { uint64_t filterCount; if (!decoder.decode(filterCount)) @@ -1566,271 +2013,505 @@ bool ArgumentCoder<FilterOperations>::decode(ArgumentDecoder& decoder, FilterOpe RefPtr<FilterOperation> filter; if (!decodeFilterOperation(decoder, filter)) return false; - filters.operations().append(std::move(filter)); + filters.operations().append(WTFMove(filter)); } return true; } -#endif // ENABLE(CSS_FILTERS) && !USE(COORDINATED_GRAPHICS) +#endif // !USE(COORDINATED_GRAPHICS) -#if ENABLE(INDEXED_DATABASE) -void ArgumentCoder<IDBDatabaseMetadata>::encode(ArgumentEncoder& encoder, const IDBDatabaseMetadata& metadata) +void ArgumentCoder<SessionID>::encode(Encoder& encoder, const SessionID& sessionID) { - encoder << metadata.name << metadata.id << metadata.version << metadata.maxObjectStoreId << metadata.objectStores; + encoder << sessionID.sessionID(); } -bool ArgumentCoder<IDBDatabaseMetadata>::decode(ArgumentDecoder& decoder, IDBDatabaseMetadata& metadata) +bool ArgumentCoder<SessionID>::decode(Decoder& decoder, SessionID& sessionID) { - if (!decoder.decode(metadata.name)) + uint64_t session; + if (!decoder.decode(session)) return false; - if (!decoder.decode(metadata.id)) - return false; + sessionID = SessionID(session); - if (!decoder.decode(metadata.version)) - return false; + return true; +} + +void ArgumentCoder<BlobPart>::encode(Encoder& encoder, const BlobPart& blobPart) +{ + encoder << static_cast<uint32_t>(blobPart.type()); + switch (blobPart.type()) { + case BlobPart::Data: + encoder << blobPart.data(); + break; + case BlobPart::Blob: + encoder << blobPart.url(); + break; + } +} - if (!decoder.decode(metadata.maxObjectStoreId)) +bool ArgumentCoder<BlobPart>::decode(Decoder& decoder, BlobPart& blobPart) +{ + uint32_t type; + if (!decoder.decode(type)) return false; - if (!decoder.decode(metadata.objectStores)) + switch (type) { + case BlobPart::Data: { + Vector<uint8_t> data; + if (!decoder.decode(data)) + return false; + blobPart = BlobPart(WTFMove(data)); + break; + } + case BlobPart::Blob: { + URL url; + if (!decoder.decode(url)) + return false; + blobPart = BlobPart(url); + break; + } + default: return false; + } return true; } -void ArgumentCoder<IDBIndexMetadata>::encode(ArgumentEncoder& encoder, const IDBIndexMetadata& metadata) +void ArgumentCoder<TextIndicatorData>::encode(Encoder& encoder, const TextIndicatorData& textIndicatorData) { - encoder << metadata.name << metadata.id << metadata.keyPath << metadata.unique << metadata.multiEntry; + encoder << textIndicatorData.selectionRectInRootViewCoordinates; + encoder << textIndicatorData.textBoundingRectInRootViewCoordinates; + encoder << textIndicatorData.textRectsInBoundingRectCoordinates; + encoder << textIndicatorData.contentImageScaleFactor; + encoder.encodeEnum(textIndicatorData.presentationTransition); + encoder << static_cast<uint64_t>(textIndicatorData.options); + + encodeOptionalImage(encoder, textIndicatorData.contentImage.get()); + encodeOptionalImage(encoder, textIndicatorData.contentImageWithHighlight.get()); } -bool ArgumentCoder<IDBIndexMetadata>::decode(ArgumentDecoder& decoder, IDBIndexMetadata& metadata) +bool ArgumentCoder<TextIndicatorData>::decode(Decoder& decoder, TextIndicatorData& textIndicatorData) { - if (!decoder.decode(metadata.name)) + if (!decoder.decode(textIndicatorData.selectionRectInRootViewCoordinates)) + return false; + + if (!decoder.decode(textIndicatorData.textBoundingRectInRootViewCoordinates)) + return false; + + if (!decoder.decode(textIndicatorData.textRectsInBoundingRectCoordinates)) return false; - if (!decoder.decode(metadata.id)) + if (!decoder.decode(textIndicatorData.contentImageScaleFactor)) return false; - if (!decoder.decode(metadata.keyPath)) + if (!decoder.decodeEnum(textIndicatorData.presentationTransition)) return false; - if (!decoder.decode(metadata.unique)) + uint64_t options; + if (!decoder.decode(options)) return false; + textIndicatorData.options = static_cast<TextIndicatorOptions>(options); - if (!decoder.decode(metadata.multiEntry)) + if (!decodeOptionalImage(decoder, textIndicatorData.contentImage)) + return false; + + if (!decodeOptionalImage(decoder, textIndicatorData.contentImageWithHighlight)) return false; return true; } -void ArgumentCoder<IDBGetResult>::encode(ArgumentEncoder& encoder, const IDBGetResult& result) +#if ENABLE(WIRELESS_PLAYBACK_TARGET) +void ArgumentCoder<MediaPlaybackTargetContext>::encode(Encoder& encoder, const MediaPlaybackTargetContext& target) { - bool nullData = !result.valueBuffer; - encoder << nullData; + bool hasPlatformData = target.encodingRequiresPlatformData(); + encoder << hasPlatformData; + + int32_t targetType = target.type(); + encoder << targetType; - if (!nullData) - encoder << DataReference(reinterpret_cast<const uint8_t*>(result.valueBuffer->data()), result.valueBuffer->size()); + if (target.encodingRequiresPlatformData()) { + encodePlatformData(encoder, target); + return; + } - encoder << result.keyData << result.keyPath; + ASSERT(targetType == MediaPlaybackTargetContext::MockType); + encoder << target.mockDeviceName(); + encoder << static_cast<int32_t>(target.mockState()); } -bool ArgumentCoder<IDBGetResult>::decode(ArgumentDecoder& decoder, IDBGetResult& result) +bool ArgumentCoder<MediaPlaybackTargetContext>::decode(Decoder& decoder, MediaPlaybackTargetContext& target) { - bool nullData; - if (!decoder.decode(nullData)) + bool hasPlatformData; + if (!decoder.decode(hasPlatformData)) return false; - if (nullData) - result.valueBuffer = nullptr; - else { - DataReference data; - if (!decoder.decode(data)) - return false; + int32_t targetType; + if (!decoder.decode(targetType)) + return false; - result.valueBuffer = SharedBuffer::create(data.data(), data.size()); - } + if (hasPlatformData) + return decodePlatformData(decoder, target); + + ASSERT(targetType == MediaPlaybackTargetContext::MockType); - if (!decoder.decode(result.keyData)) + String mockDeviceName; + if (!decoder.decode(mockDeviceName)) return false; - if (!decoder.decode(result.keyPath)) + int32_t mockState; + if (!decoder.decode(mockState)) return false; + target = MediaPlaybackTargetContext(mockDeviceName, static_cast<MediaPlaybackTargetContext::State>(mockState)); return true; } +#endif -void ArgumentCoder<IDBKeyData>::encode(ArgumentEncoder& encoder, const IDBKeyData& keyData) +void ArgumentCoder<DictionaryPopupInfo>::encode(IPC::Encoder& encoder, const DictionaryPopupInfo& info) { - encoder << keyData.isNull; - if (keyData.isNull) - return; + encoder << info.origin; + encoder << info.textIndicator; - encoder.encodeEnum(keyData.type); +#if PLATFORM(COCOA) + bool hadOptions = info.options; + encoder << hadOptions; + if (hadOptions) + IPC::encode(encoder, info.options.get()); - switch (keyData.type) { - case IDBKey::InvalidType: - break; - case IDBKey::ArrayType: - encoder << keyData.arrayValue; - break; - case IDBKey::StringType: - encoder << keyData.stringValue; - break; - case IDBKey::DateType: - case IDBKey::NumberType: - encoder << keyData.numberValue; - break; - case IDBKey::MinType: - ASSERT_NOT_REACHED(); - break; - } + bool hadAttributedString = info.attributedString; + encoder << hadAttributedString; + if (hadAttributedString) + IPC::encode(encoder, info.attributedString.get()); +#endif } -bool ArgumentCoder<IDBKeyData>::decode(ArgumentDecoder& decoder, IDBKeyData& keyData) +bool ArgumentCoder<DictionaryPopupInfo>::decode(IPC::Decoder& decoder, DictionaryPopupInfo& result) { - if (!decoder.decode(keyData.isNull)) + if (!decoder.decode(result.origin)) return false; - if (keyData.isNull) - return true; - - if (!decoder.decodeEnum(keyData.type)) + if (!decoder.decode(result.textIndicator)) return false; - switch (keyData.type) { - case IDBKey::InvalidType: - break; - case IDBKey::ArrayType: - if (!decoder.decode(keyData.arrayValue)) - return false; - break; - case IDBKey::StringType: - if (!decoder.decode(keyData.stringValue)) +#if PLATFORM(COCOA) + bool hadOptions; + if (!decoder.decode(hadOptions)) + return false; + if (hadOptions) { + if (!IPC::decode(decoder, result.options)) return false; - break; - case IDBKey::DateType: - case IDBKey::NumberType: - if (!decoder.decode(keyData.numberValue)) + } else + result.options = nullptr; + + bool hadAttributedString; + if (!decoder.decode(hadAttributedString)) + return false; + if (hadAttributedString) { + if (!IPC::decode(decoder, result.attributedString)) return false; - break; - case IDBKey::MinType: - ASSERT_NOT_REACHED(); + } else + result.attributedString = nullptr; +#endif + return true; +} + +void ArgumentCoder<ExceptionDetails>::encode(IPC::Encoder& encoder, const ExceptionDetails& info) +{ + encoder << info.message; + encoder << info.lineNumber; + encoder << info.columnNumber; + encoder << info.sourceURL; +} + +bool ArgumentCoder<ExceptionDetails>::decode(IPC::Decoder& decoder, ExceptionDetails& result) +{ + if (!decoder.decode(result.message)) + return false; + + if (!decoder.decode(result.lineNumber)) + return false; + + if (!decoder.decode(result.columnNumber)) + return false; + + if (!decoder.decode(result.sourceURL)) return false; - } return true; } -void ArgumentCoder<IDBKeyPath>::encode(ArgumentEncoder& encoder, const IDBKeyPath& keyPath) +void ArgumentCoder<ResourceLoadStatistics>::encode(Encoder& encoder, const WebCore::ResourceLoadStatistics& statistics) { - encoder.encodeEnum(keyPath.type()); - - switch (keyPath.type()) { - case IDBKeyPath::NullType: - break; - case IDBKeyPath::StringType: - encoder << keyPath.string(); - break; - case IDBKeyPath::ArrayType: - encoder << keyPath.array(); - break; - default: - ASSERT_NOT_REACHED(); - } + encoder << statistics.highLevelDomain; + + // User interaction + encoder << statistics.hadUserInteraction; + encoder << statistics.mostRecentUserInteraction; + encoder << statistics.grandfathered; + + // Top frame stats + encoder << statistics.topFrameHasBeenNavigatedToBefore; + encoder << statistics.topFrameHasBeenRedirectedTo; + encoder << statistics.topFrameHasBeenRedirectedFrom; + encoder << statistics.topFrameInitialLoadCount; + encoder << statistics.topFrameHasBeenNavigatedTo; + encoder << statistics.topFrameHasBeenNavigatedFrom; + + // Subframe stats + encoder << statistics.subframeHasBeenLoadedBefore; + encoder << statistics.subframeHasBeenRedirectedTo; + encoder << statistics.subframeHasBeenRedirectedFrom; + encoder << statistics.subframeSubResourceCount; + encoder << statistics.subframeUnderTopFrameOrigins; + encoder << statistics.subframeUniqueRedirectsTo; + encoder << statistics.subframeHasBeenNavigatedTo; + encoder << statistics.subframeHasBeenNavigatedFrom; + + // Subresource stats + encoder << statistics.subresourceHasBeenRedirectedFrom; + encoder << statistics.subresourceHasBeenRedirectedTo; + encoder << statistics.subresourceHasBeenSubresourceCount; + encoder << statistics.subresourceHasBeenSubresourceCountDividedByTotalNumberOfOriginsVisited; + encoder << statistics.subresourceUnderTopFrameOrigins; + encoder << statistics.subresourceUniqueRedirectsTo; + + // Prevalent Resource + encoder << statistics.redirectedToOtherPrevalentResourceOrigins; + encoder << statistics.isPrevalentResource; + encoder << statistics.dataRecordsRemoved; } -bool ArgumentCoder<IDBKeyPath>::decode(ArgumentDecoder& decoder, IDBKeyPath& keyPath) +bool ArgumentCoder<ResourceLoadStatistics>::decode(Decoder& decoder, WebCore::ResourceLoadStatistics& statistics) { - IDBKeyPath::Type type; - if (!decoder.decodeEnum(type)) + if (!decoder.decode(statistics.highLevelDomain)) + return false; + + // User interaction + if (!decoder.decode(statistics.hadUserInteraction)) return false; - switch (type) { - case IDBKeyPath::NullType: - keyPath = IDBKeyPath(); - return true; + if (!decoder.decode(statistics.mostRecentUserInteraction)) + return false; - case IDBKeyPath::StringType: { - String string; - if (!decoder.decode(string)) - return false; + if (!decoder.decode(statistics.grandfathered)) + return false; + + // Top frame stats + if (!decoder.decode(statistics.topFrameHasBeenNavigatedToBefore)) + return false; + + if (!decoder.decode(statistics.topFrameHasBeenRedirectedTo)) + return false; + + if (!decoder.decode(statistics.topFrameHasBeenRedirectedFrom)) + return false; + + if (!decoder.decode(statistics.topFrameInitialLoadCount)) + return false; + + if (!decoder.decode(statistics.topFrameHasBeenNavigatedTo)) + return false; + + if (!decoder.decode(statistics.topFrameHasBeenNavigatedFrom)) + return false; + + // Subframe stats + if (!decoder.decode(statistics.subframeHasBeenLoadedBefore)) + return false; + + if (!decoder.decode(statistics.subframeHasBeenRedirectedTo)) + return false; + + if (!decoder.decode(statistics.subframeHasBeenRedirectedFrom)) + return false; + + if (!decoder.decode(statistics.subframeSubResourceCount)) + return false; + + if (!decoder.decode(statistics.subframeUnderTopFrameOrigins)) + return false; - keyPath = IDBKeyPath(string); - return true; - } - case IDBKeyPath::ArrayType: { - Vector<String> array; - if (!decoder.decode(array)) - return false; + if (!decoder.decode(statistics.subframeUniqueRedirectsTo)) + return false; + + if (!decoder.decode(statistics.subframeHasBeenNavigatedTo)) + return false; + + if (!decoder.decode(statistics.subframeHasBeenNavigatedFrom)) + return false; + + // Subresource stats + if (!decoder.decode(statistics.subresourceHasBeenRedirectedFrom)) + return false; + + if (!decoder.decode(statistics.subresourceHasBeenRedirectedTo)) + return false; + + if (!decoder.decode(statistics.subresourceHasBeenSubresourceCount)) + return false; + + if (!decoder.decode(statistics.subresourceHasBeenSubresourceCountDividedByTotalNumberOfOriginsVisited)) + return false; + + if (!decoder.decode(statistics.subresourceUnderTopFrameOrigins)) + return false; - keyPath = IDBKeyPath(array); - return true; - } - default: + if (!decoder.decode(statistics.subresourceUniqueRedirectsTo)) return false; - } + + // Prevalent Resource + if (!decoder.decode(statistics.redirectedToOtherPrevalentResourceOrigins)) + return false; + + if (!decoder.decode(statistics.isPrevalentResource)) + return false; + + if (!decoder.decode(statistics.dataRecordsRemoved)) + return false; + + return true; } -void ArgumentCoder<IDBKeyRangeData>::encode(ArgumentEncoder& encoder, const IDBKeyRangeData& keyRange) +#if ENABLE(MEDIA_STREAM) +void ArgumentCoder<MediaConstraintsData>::encode(Encoder& encoder, const WebCore::MediaConstraintsData& constraint) { - encoder << keyRange.isNull; - if (keyRange.isNull) - return; + encoder << constraint.mandatoryConstraints; + + auto& advancedConstraints = constraint.advancedConstraints; + encoder << static_cast<uint64_t>(advancedConstraints.size()); + for (const auto& advancedConstraint : advancedConstraints) + encoder << advancedConstraint; - encoder << keyRange.upperKey << keyRange.lowerKey << keyRange.upperOpen << keyRange.lowerOpen; + encoder << constraint.isValid; } -bool ArgumentCoder<IDBKeyRangeData>::decode(ArgumentDecoder& decoder, IDBKeyRangeData& keyRange) +bool ArgumentCoder<MediaConstraintsData>::decode(Decoder& decoder, WebCore::MediaConstraintsData& constraints) { - if (!decoder.decode(keyRange.isNull)) + MediaTrackConstraintSetMap mandatoryConstraints; + if (!decoder.decode(mandatoryConstraints)) return false; - if (keyRange.isNull) - return true; - - if (!decoder.decode(keyRange.upperKey)) + uint64_t advancedCount; + if (!decoder.decode(advancedCount)) return false; - if (!decoder.decode(keyRange.lowerKey)) - return false; + Vector<MediaTrackConstraintSetMap> advancedConstraints; + advancedConstraints.reserveInitialCapacity(advancedCount); + for (size_t i = 0; i < advancedCount; ++i) { + MediaTrackConstraintSetMap map; + if (!decoder.decode(map)) + return false; - if (!decoder.decode(keyRange.upperOpen)) - return false; + advancedConstraints.uncheckedAppend(WTFMove(map)); + } - if (!decoder.decode(keyRange.lowerOpen)) + bool isValid; + if (!decoder.decode(isValid)) return false; + constraints.mandatoryConstraints = WTFMove(mandatoryConstraints); + constraints.advancedConstraints = WTFMove(advancedConstraints); + constraints.isValid = isValid; + return true; } -void ArgumentCoder<IDBObjectStoreMetadata>::encode(ArgumentEncoder& encoder, const IDBObjectStoreMetadata& metadata) +void ArgumentCoder<CaptureDevice>::encode(Encoder& encoder, const WebCore::CaptureDevice& device) { - encoder << metadata.name << metadata.id << metadata.keyPath << metadata.autoIncrement << metadata.maxIndexId << metadata.indexes; + encoder << device.persistentId(); + encoder << device.label(); + encoder << device.groupId(); + encoder << device.enabled(); + encoder.encodeEnum(device.type()); } -bool ArgumentCoder<IDBObjectStoreMetadata>::decode(ArgumentDecoder& decoder, IDBObjectStoreMetadata& metadata) +bool ArgumentCoder<CaptureDevice>::decode(Decoder& decoder, WebCore::CaptureDevice& device) { - if (!decoder.decode(metadata.name)) + String persistentId; + if (!decoder.decode(persistentId)) + return false; + + String label; + if (!decoder.decode(label)) + return false; + + String groupId; + if (!decoder.decode(groupId)) return false; - if (!decoder.decode(metadata.id)) + bool enabled; + if (!decoder.decode(enabled)) return false; - if (!decoder.decode(metadata.keyPath)) + CaptureDevice::DeviceType type; + if (!decoder.decodeEnum(type)) return false; - if (!decoder.decode(metadata.autoIncrement)) + device.setPersistentId(persistentId); + device.setLabel(label); + device.setGroupId(groupId); + device.setType(type); + device.setEnabled(enabled); + + return true; +} +#endif + +#if ENABLE(INDEXED_DATABASE) +void ArgumentCoder<IDBKeyPath>::encode(Encoder& encoder, const IDBKeyPath& keyPath) +{ + bool isString = WTF::holds_alternative<String>(keyPath); + encoder << isString; + if (isString) + encoder << WTF::get<String>(keyPath); + else + encoder << WTF::get<Vector<String>>(keyPath); +} + +bool ArgumentCoder<IDBKeyPath>::decode(Decoder& decoder, IDBKeyPath& keyPath) +{ + bool isString; + if (!decoder.decode(isString)) return false; + if (isString) { + String string; + if (!decoder.decode(string)) + return false; + keyPath = string; + } else { + Vector<String> vector; + if (!decoder.decode(vector)) + return false; + keyPath = vector; + } + return true; +} +#endif + +#if ENABLE(CSS_SCROLL_SNAP) - if (!decoder.decode(metadata.maxIndexId)) +void ArgumentCoder<ScrollOffsetRange<float>>::encode(Encoder& encoder, const ScrollOffsetRange<float>& range) +{ + encoder << range.start; + encoder << range.end; +} + +bool ArgumentCoder<ScrollOffsetRange<float>>::decode(Decoder& decoder, ScrollOffsetRange<float>& range) +{ + float start; + if (!decoder.decode(start)) return false; - if (!decoder.decode(metadata.indexes)) + float end; + if (!decoder.decode(end)) return false; + range.start = start; + range.end = end; return true; } + #endif } // namespace IPC |