Skip to content

Commit

Permalink
Generate serializers for class LayoutRect, ScreenDataOverrides, Media…
Browse files Browse the repository at this point in the history
…CapabilitiesInfo, MediaStreamRequest

https://bugs.webkit.org/show_bug.cgi?id=247648
rdar://101308191

Reviewed by Alex Christensen.

* Source/WebCore/platform/MediaCapabilitiesInfo.h:
(WebCore::MediaCapabilitiesInfo::encode const): Deleted.
(WebCore::MediaCapabilitiesInfo::decode): Deleted.
* Source/WebCore/platform/graphics/LayoutRect.h:
(WebCore::LayoutRect::encode const): Deleted.
(WebCore::LayoutRect::decode): Deleted.
* Source/WebCore/platform/graphics/VP9Utilities.h:
(WebCore::ScreenDataOverrides::encode const): Deleted.
(WebCore::ScreenDataOverrides::decode): Deleted.
* Source/WebCore/platform/mediastream/MediaStreamRequest.h:
(WebCore::MediaStreamRequest::encode const): Deleted.
(WebCore::MediaStreamRequest::decode): Deleted.
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:

Canonical link: https://commits.webkit.org/256545@main
  • Loading branch information
arunsundarapple authored and achristensen07 committed Nov 10, 2022
1 parent 619e29b commit 3de90cc
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 191 deletions.
1 change: 1 addition & 0 deletions Source/WebCore/Headers.cmake
Expand Up @@ -1686,6 +1686,7 @@ set(WebCore_PRIVATE_FRAMEWORK_HEADERS
platform/graphics/RenderingResourceIdentifier.h
platform/graphics/RenderingMode.h
platform/graphics/RoundedRect.h
platform/graphics/ScreenDataOverrides.h
platform/graphics/ShouldLocalizeAxisNames.h
platform/graphics/SourceBrush.h
platform/graphics/SourceBufferPrivate.h
Expand Down
4 changes: 4 additions & 0 deletions Source/WebCore/WebCore.xcodeproj/project.pbxproj
Expand Up @@ -283,6 +283,7 @@
0C3F1F5B10C8871200D72CE1 /* WebGLUniformLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 0C3F1F5810C8871200D72CE1 /* WebGLUniformLocation.h */; };
0C45342810CDBBFA00869157 /* JSWebGLUniformLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 0C45342610CDBBFA00869157 /* JSWebGLUniformLocation.h */; };
0E7058F41BC5CEDA0045A507 /* SearchPopupMenuCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 0E7058F31BC5CCD70045A507 /* SearchPopupMenuCocoa.h */; settings = {ATTRIBUTES = (Private, ); }; };
0E9C1157291C18A400A2C2F2 /* ScreenDataOverrides.h in Headers */ = {isa = PBXBuildFile; fileRef = 0E9C1155291BF3CC00A2C2F2 /* ScreenDataOverrides.h */; settings = {ATTRIBUTES = (Private, ); }; };
0F03C0741884695E00A5F8CA /* SystemMemory.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F03C0731884695E00A5F8CA /* SystemMemory.h */; };
0F03C0751884805500A5F8CA /* InspectorOverlay.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C522D4A15B478B2009B7C95 /* InspectorOverlay.h */; settings = {ATTRIBUTES = (Private, ); }; };
0F099D0917B968A100FF84B9 /* WebCoreTypedArrayController.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F099D0717B968A100FF84B9 /* WebCoreTypedArrayController.h */; settings = {ATTRIBUTES = (Private, ); }; };
Expand Down Expand Up @@ -6490,6 +6491,7 @@
0DD1F6F0291433EB00B79355 /* GPUCanvasContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPUCanvasContext.h; sourceTree = "<group>"; };
0E7058ED1BC5BC190045A507 /* SearchPopupMenuCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SearchPopupMenuCocoa.mm; sourceTree = "<group>"; };
0E7058F31BC5CCD70045A507 /* SearchPopupMenuCocoa.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SearchPopupMenuCocoa.h; sourceTree = "<group>"; };
0E9C1155291BF3CC00A2C2F2 /* ScreenDataOverrides.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScreenDataOverrides.h; sourceTree = "<group>"; };
0F02245026F15D5F000265C3 /* ScrollbarsController.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollbarsController.cpp; sourceTree = "<group>"; };
0F02245226F15D5F000265C3 /* ScrollbarsController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScrollbarsController.h; sourceTree = "<group>"; };
0F02245326F15D75000265C3 /* ScrollbarsControllerMac.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollbarsControllerMac.mm; sourceTree = "<group>"; };
Expand Down Expand Up @@ -30052,6 +30054,7 @@
729D052E25313E2600422098 /* RenderingResourceIdentifier.h */,
A73F95FC12C97BFE0031AAF9 /* RoundedRect.cpp */,
A73F95FD12C97BFE0031AAF9 /* RoundedRect.h */,
0E9C1155291BF3CC00A2C2F2 /* ScreenDataOverrides.h */,
0F3DD44D12F5EA1B000D9190 /* ShadowBlur.cpp */,
0F3DD44E12F5EA1B000D9190 /* ShadowBlur.h */,
1C4DB02427339E5E007B0AD1 /* ShouldLocalizeAxisNames.h */,
Expand Down Expand Up @@ -38391,6 +38394,7 @@
BCEC01BE0C274DAC009F4EC9 /* Screen.h in Headers */,
070BED98273F415D00583926 /* ScreenCaptureKitCaptureSource.h in Headers */,
073955BB27AB277F009A08D2 /* ScreenCaptureKitSharingSessionManager.h in Headers */,
0E9C1157291C18A400A2C2F2 /* ScreenDataOverrides.h in Headers */,
46AD2CD028E4FD5100040F10 /* ScreenOrientation.h in Headers */,
4625239E28E5034B00082F84 /* ScreenOrientationLockType.h in Headers */,
46DC53BF28EB3D65005376B0 /* ScreenOrientationManager.h in Headers */,
Expand Down
27 changes: 0 additions & 27 deletions Source/WebCore/platform/MediaCapabilitiesDecodingInfo.h
Expand Up @@ -49,39 +49,12 @@ struct MediaCapabilitiesDecodingInfo : MediaCapabilitiesInfo {

MediaCapabilitiesDecodingInfo isolatedCopy() const;

template<class Encoder> void encode(Encoder&) const;
template<class Decoder> static std::optional<MediaCapabilitiesDecodingInfo> decode(Decoder&);
};

inline MediaCapabilitiesDecodingInfo MediaCapabilitiesDecodingInfo::isolatedCopy() const
{
return { MediaCapabilitiesInfo::isolatedCopy(), supportedConfiguration.isolatedCopy() };
}

template<class Encoder>
void MediaCapabilitiesDecodingInfo::encode(Encoder& encoder) const
{
MediaCapabilitiesInfo::encode(encoder);
encoder << supportedConfiguration;
}

template<class Decoder>
std::optional<MediaCapabilitiesDecodingInfo> MediaCapabilitiesDecodingInfo::decode(Decoder& decoder)
{
auto info = MediaCapabilitiesInfo::decode(decoder);
if (!info)
return std::nullopt;

std::optional<MediaDecodingConfiguration> supportedConfiguration;
decoder >> supportedConfiguration;
if (!supportedConfiguration)
return std::nullopt;

return MediaCapabilitiesDecodingInfo(
WTFMove(*info),
WTFMove(*supportedConfiguration)
);
}

} // namespace WebCore

27 changes: 0 additions & 27 deletions Source/WebCore/platform/MediaCapabilitiesEncodingInfo.h
Expand Up @@ -49,39 +49,12 @@ struct MediaCapabilitiesEncodingInfo : MediaCapabilitiesInfo {

MediaCapabilitiesEncodingInfo isolatedCopy() const;

template<class Encoder> void encode(Encoder&) const;
template<class Decoder> static std::optional<MediaCapabilitiesEncodingInfo> decode(Decoder&);
};

inline MediaCapabilitiesEncodingInfo MediaCapabilitiesEncodingInfo::isolatedCopy() const
{
return { MediaCapabilitiesInfo::isolatedCopy(), supportedConfiguration.isolatedCopy() };
}

template<class Encoder>
void MediaCapabilitiesEncodingInfo::encode(Encoder& encoder) const
{
MediaCapabilitiesInfo::encode(encoder);
encoder << supportedConfiguration;
}

template<class Decoder>
std::optional<MediaCapabilitiesEncodingInfo> MediaCapabilitiesEncodingInfo::decode(Decoder& decoder)
{
auto info = MediaCapabilitiesInfo::decode(decoder);
if (!info)
return std::nullopt;

std::optional<MediaEncodingConfiguration> supportedConfiguration;
decoder >> supportedConfiguration;
if (!supportedConfiguration)
return std::nullopt;

return MediaCapabilitiesEncodingInfo(
WTFMove(*info),
WTFMove(*supportedConfiguration)
);
}

} // namespace WebCore

36 changes: 0 additions & 36 deletions Source/WebCore/platform/MediaCapabilitiesInfo.h
Expand Up @@ -35,48 +35,12 @@ struct MediaCapabilitiesInfo {
bool powerEfficient { false };

MediaCapabilitiesInfo isolatedCopy() const;

template<class Encoder> void encode(Encoder&) const;
template<class Decoder> static std::optional<MediaCapabilitiesInfo> decode(Decoder&);
};

inline MediaCapabilitiesInfo MediaCapabilitiesInfo::isolatedCopy() const
{
return *this;
}

template<class Encoder>
void MediaCapabilitiesInfo::encode(Encoder& encoder) const
{
encoder << supported;
encoder << smooth;
encoder << powerEfficient;
}

template<class Decoder>
std::optional<MediaCapabilitiesInfo> MediaCapabilitiesInfo::decode(Decoder& decoder)
{
std::optional<bool> supported;
decoder >> supported;
if (!supported)
return std::nullopt;

std::optional<bool> smooth;
decoder >> smooth;
if (!smooth)
return std::nullopt;

std::optional<bool> powerEfficient;
decoder >> powerEfficient;
if (!powerEfficient)
return std::nullopt;

return {{
*supported,
*smooth,
*powerEfficient,
}};
}

} // namespace WebCore

24 changes: 2 additions & 22 deletions Source/WebCore/platform/graphics/LayoutRect.h
Expand Up @@ -34,6 +34,7 @@
#include "IntRect.h"
#include "LayoutPoint.h"
#include "LengthBox.h"
#include <wtf/ArgumentCoder.h>
#include <wtf/Forward.h>

namespace WTF {
Expand All @@ -58,28 +59,6 @@ class LayoutRect {

WEBCORE_EXPORT explicit LayoutRect(const FloatRect&); // don't do this implicitly since it's lossy

template<class Encoder>
void encode(Encoder& encoder) const
{
encoder << m_location << m_size;
}

template<class Decoder>
static std::optional<LayoutRect> decode(Decoder& decoder)
{
std::optional<LayoutPoint> layoutPoint;
decoder >> layoutPoint;
if (!layoutPoint)
return std::nullopt;

std::optional<LayoutSize> layoutSize;
decoder >> layoutSize;
if (!layoutSize)
return std::nullopt;

return {{ *layoutPoint, *layoutSize }};
}

LayoutPoint location() const { return m_location; }
LayoutSize size() const { return m_size; }

Expand Down Expand Up @@ -224,6 +203,7 @@ class LayoutRect {
operator FloatRect() const { return FloatRect(m_location, m_size); }

private:
friend struct IPC::ArgumentCoder<WebCore::LayoutRect, void>;
void setLocationAndSizeFromEdges(LayoutUnit left, LayoutUnit top, LayoutUnit right, LayoutUnit bottom);

LayoutPoint m_location;
Expand Down
46 changes: 46 additions & 0 deletions Source/WebCore/platform/graphics/ScreenDataOverrides.h
@@ -0,0 +1,46 @@
/*
* Copyright (C) 2020-2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#pragma once

namespace WebCore {

struct ScreenDataOverrides {
double width { 0 };
double height { 0 };
double scale { 1 };
};

inline bool operator==(const ScreenDataOverrides& a, const ScreenDataOverrides& b)
{
return a.width == b.width && a.height == b.height && a.scale == b.scale;
}

inline bool operator!=(const ScreenDataOverrides& a, const ScreenDataOverrides& b)
{
return !(a == b);
}

}
42 changes: 1 addition & 41 deletions Source/WebCore/platform/graphics/VP9Utilities.h
Expand Up @@ -25,9 +25,9 @@

#pragma once

#include "ScreenDataOverrides.h"
#include <wtf/text/StringView.h>
#include <wtf/text/WTFString.h>

namespace WebCore {

namespace VPConfigurationLevel {
Expand Down Expand Up @@ -127,45 +127,5 @@ struct VPCodecConfigurationRecord {

WEBCORE_EXPORT std::optional<VPCodecConfigurationRecord> parseVPCodecParameters(StringView codecString);

struct ScreenDataOverrides {
double width { 0 };
double height { 0 };
double scale { 1 };

template<class Encoder>
void encode(Encoder& encoder) const
{
encoder << width;
encoder << height;
encoder << scale;
}

template <class Decoder>
static std::optional<ScreenDataOverrides> decode(Decoder& decoder)
{
#define DECODE(name, type) \
std::optional<type> name; \
decoder >> name; \
if (!name) \
return std::nullopt; \

DECODE(width, double);
DECODE(height, double);
DECODE(scale, double);
#undef DECODE

return {{ WTFMove(*width), WTFMove(*height), WTFMove(*scale) }};
}
};

inline bool operator==(const ScreenDataOverrides& a, const ScreenDataOverrides& b)
{
return a.width == b.width && a.height == b.height && a.scale == b.scale;
}

inline bool operator!=(const ScreenDataOverrides& a, const ScreenDataOverrides& b)
{
return !(a == b);
}

}
48 changes: 10 additions & 38 deletions Source/WebCore/platform/mediastream/MediaStreamRequest.h
Expand Up @@ -35,35 +35,16 @@
namespace WebCore {

struct MediaStreamRequest {
enum class Type { UserMedia, DisplayMedia, DisplayMediaWithAudio };
enum class Type : uint8_t {
UserMedia,
DisplayMedia,
DisplayMediaWithAudio
};
Type type { Type::UserMedia };
MediaConstraints audioConstraints;
MediaConstraints videoConstraints;
bool isUserGesturePriviledged { false };
PageIdentifier pageIdentifier;

template<class Encoder>
void encode(Encoder& encoder) const
{
encoder << type;
encoder << audioConstraints;
encoder << videoConstraints;
encoder << isUserGesturePriviledged;
encoder << pageIdentifier;
}

template <class Decoder> static std::optional<MediaStreamRequest> decode(Decoder& decoder)
{
MediaStreamRequest request;
if (!decoder.decode(request.type)
|| !decoder.decode(request.audioConstraints)
|| !decoder.decode(request.videoConstraints)
|| !decoder.decode(request.isUserGesturePriviledged)
|| !decoder.decode(request.pageIdentifier))
return std::nullopt;

return request;
}
};

} // namespace WebCore
Expand All @@ -73,23 +54,14 @@ struct MediaStreamRequest {
namespace WebCore {

struct MediaStreamRequest {
enum class Type { UserMedia, DisplayMedia, DisplayMediaWithAudio };
enum class Type : uint8_t {
UserMedia,
DisplayMedia,
DisplayMediaWithAudio
};
Type type;
};

} // namespace WebCore

#endif // ENABLE(MEDIA_STREAM)

namespace WTF {

template<> struct EnumTraits<WebCore::MediaStreamRequest::Type> {
using values = EnumValues<
WebCore::MediaStreamRequest::Type,
WebCore::MediaStreamRequest::Type::UserMedia,
WebCore::MediaStreamRequest::Type::DisplayMedia,
WebCore::MediaStreamRequest::Type::DisplayMediaWithAudio
>;
};

} // namespace WTF

0 comments on commit 3de90cc

Please sign in to comment.