Skip to content

Commit

Permalink
Update serialization for InspectorFrontendClient and PlatformTextTrac…
Browse files Browse the repository at this point in the history
…kData

https://bugs.webkit.org/show_bug.cgi?id=262162
rdar://116098797

Reviewed by Alex Christensen.

* Source/WebCore/inspector/InspectorFrontendClient.h:
(WebCore::InspectorFrontendClient::SaveData::encode const): Deleted.
(WebCore::InspectorFrontendClient::SaveData::decode): Deleted.
* Source/WebCore/platform/graphics/PlatformTextTrack.h:
(WebCore::PlatformTextTrackData::decode): Deleted.
(WebCore::PlatformTextTrackData::encode const): Deleted.
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:

Canonical link: https://commits.webkit.org/268507@main
  • Loading branch information
sheeparegreat authored and achristensen07 committed Sep 27, 2023
1 parent eab6568 commit 77a5b5d
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 114 deletions.
86 changes: 18 additions & 68 deletions Source/WebCore/inspector/InspectorFrontendClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ class FloatRect;
class InspectorFrontendAPIDispatcher;
class Page;

enum class InspectorFrontendClientAppearance : uint8_t {
System,
Light,
Dark,
};

struct InspectorFrontendClientSaveData {
String displayType;
String url;
String content;
bool base64Encoded;
};

class InspectorFrontendClient : public CanMakeWeakPtr<InspectorFrontendClient> {
public:
enum class DockSide {
Expand Down Expand Up @@ -90,11 +103,8 @@ class InspectorFrontendClient : public CanMakeWeakPtr<InspectorFrontendClient> {
virtual void reopen() = 0;
virtual void resetState() = 0;

enum class Appearance {
System,
Light,
Dark,
};
using Appearance = WebCore::InspectorFrontendClientAppearance;

WEBCORE_EXPORT virtual void setForcedAppearance(Appearance) = 0;

virtual UserInterfaceLayoutDirection userInterfaceLayoutDirection() const = 0;
Expand All @@ -114,15 +124,9 @@ class InspectorFrontendClient : public CanMakeWeakPtr<InspectorFrontendClient> {
SingleFile,
FileVariants,
};
struct SaveData {
String displayType;
String url;
String content;
bool base64Encoded;

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

using SaveData = InspectorFrontendClientSaveData;

virtual bool canSave(SaveMode) = 0;
virtual void save(Vector<SaveData>&&, bool forceSaveAs) = 0;

Expand Down Expand Up @@ -158,58 +162,4 @@ class InspectorFrontendClient : public CanMakeWeakPtr<InspectorFrontendClient> {
WEBCORE_EXPORT virtual bool isUnderTest() = 0;
};

template<class Encoder>
void InspectorFrontendClient::SaveData::encode(Encoder& encoder) const
{
encoder << displayType;
encoder << url;
encoder << content;
encoder << base64Encoded;
}

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

DECODE(displayType, String)
DECODE(url, String)
DECODE(content, String)
DECODE(base64Encoded, bool)

#undef DECODE

return { {
WTFMove(*displayType),
WTFMove(*url),
WTFMove(*content),
WTFMove(*base64Encoded),
} };
}

} // namespace WebCore

namespace WTF {

template<> struct EnumTraits<WebCore::InspectorFrontendClient::Appearance> {
using values = EnumValues<
WebCore::InspectorFrontendClient::Appearance,
WebCore::InspectorFrontendClient::Appearance::System,
WebCore::InspectorFrontendClient::Appearance::Light,
WebCore::InspectorFrontendClient::Appearance::Dark
>;
};

template<> struct EnumTraits<WebCore::InspectorFrontendClient::SaveMode> {
using values = EnumValues<
WebCore::InspectorFrontendClient::SaveMode,
WebCore::InspectorFrontendClient::SaveMode::SingleFile,
WebCore::InspectorFrontendClient::SaveMode::FileVariants
>;
};

} // namespace WTF
34 changes: 0 additions & 34 deletions Source/WebCore/platform/graphics/PlatformTextTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,38 +144,4 @@ class PlatformTextTrack : public RefCounted<PlatformTextTrack> {

} // namespace WebCore

namespace WTF {

template<> struct EnumTraits<WebCore::PlatformTextTrackData::TrackKind> {
using values = EnumValues<
WebCore::PlatformTextTrackData::TrackKind,
WebCore::PlatformTextTrackData::TrackKind::Subtitle,
WebCore::PlatformTextTrackData::TrackKind::Caption,
WebCore::PlatformTextTrackData::TrackKind::Description,
WebCore::PlatformTextTrackData::TrackKind::Chapter,
WebCore::PlatformTextTrackData::TrackKind::MetaData,
WebCore::PlatformTextTrackData::TrackKind::Forced
>;
};

template<> struct EnumTraits<WebCore::PlatformTextTrackData::TrackType> {
using values = EnumValues<
WebCore::PlatformTextTrackData::TrackType,
WebCore::PlatformTextTrackData::TrackType::InBand,
WebCore::PlatformTextTrackData::TrackType::OutOfBand,
WebCore::PlatformTextTrackData::TrackType::Script
>;
};

template<> struct EnumTraits<WebCore::PlatformTextTrackData::TrackMode> {
using values = EnumValues<
WebCore::PlatformTextTrackData::TrackMode,
WebCore::PlatformTextTrackData::TrackMode::Disabled,
WebCore::PlatformTextTrackData::TrackMode::Hidden,
WebCore::PlatformTextTrackData::TrackMode::Showing
>;
};

} // namespace WTF

#endif // ENABLE(VIDEO)
72 changes: 60 additions & 12 deletions Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in
Original file line number Diff line number Diff line change
Expand Up @@ -6007,6 +6007,66 @@ struct WebCore::LinkDecorationFilteringData {
String linkDecoration;
};

header: <WebCore/InspectorFrontendClient.h>
[CustomHeader] enum class WebCore::InspectorFrontendClientAppearance : uint8_t {
System,
Light,
Dark,
};
using WebCore::InspectorFrontendClient::Appearance = WebCore::InspectorFrontendClientAppearance;

[Nested] enum class WebCore::InspectorFrontendClient::SaveMode : uint8_t {
SingleFile,
FileVariants,
};

header: <WebCore/InspectorFrontendClient.h>
[CustomHeader] struct WebCore::InspectorFrontendClientSaveData {
String displayType;
String url;
String content;
bool base64Encoded;
};
using WebCore::InspectorFrontendClient::SaveData = WebCore::InspectorFrontendClientSaveData;

#if ENABLE(VIDEO)
header: <WebCore/PlatformTextTrack.h>
[Nested, CustomHeader] enum class WebCore::PlatformTextTrackData::TrackKind : uint8_t {
Subtitle,
Caption,
Description,
Chapter,
MetaData,
Forced,
};

header: <WebCore/PlatformTextTrack.h>
[Nested, CustomHeader] enum class WebCore::PlatformTextTrackData::TrackType : uint8_t {
InBand,
OutOfBand,
Script,
};

header: <WebCore/PlatformTextTrack.h>
[Nested, CustomHeader] enum class WebCore::PlatformTextTrackData::TrackMode : uint8_t {
Disabled,
Hidden,
Showing,
};

header: <WebCore/PlatformTextTrack.h>
[CustomHeader] struct WebCore::PlatformTextTrackData {
String m_label;
String m_language;
String m_url;
WebCore::PlatformTextTrackData::TrackMode m_mode;
WebCore::PlatformTextTrackData::TrackKind m_kind;
WebCore::PlatformTextTrackData::TrackType m_type;
int m_uniqueId;
bool m_isDefault;
}
#endif // ENABLE(VIDEO)

[WebKitPlatform] struct WebCore::NotificationPayload {
URL defaultActionURL;
String title;
Expand Down Expand Up @@ -6137,18 +6197,6 @@ struct WebCore::NowPlayingInfo {
std::optional<WebCore::NowPlayingInfoArtwork> artwork;
}

header: <WebCore/PlatformTextTrack.h>
[CustomHeader] struct WebCore::PlatformTextTrackData {
String m_label;
String m_language;
String m_url;
WebCore::PlatformTextTrackData::TrackMode m_mode;
WebCore::PlatformTextTrackData::TrackKind m_kind;
WebCore::PlatformTextTrackData::TrackType m_type;
int m_uniqueId;
bool m_isDefault;
}

struct WebCore::VideoConfiguration {
String contentType;
uint32_t width;
Expand Down

0 comments on commit 77a5b5d

Please sign in to comment.