Skip to content

Commit

Permalink
Port ControlPart to the new IPC serialization format
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=268596

Reviewed by Alex Christensen and Darin Adler.

* Source/WebCore/platform/graphics/controls/ButtonPart.h:
(isType):
* Source/WebCore/platform/graphics/controls/ColorWellPart.h:
* Source/WebCore/platform/graphics/controls/ImageControlsButtonPart.h:
* Source/WebCore/platform/graphics/controls/InnerSpinButtonPart.h:
* Source/WebCore/platform/graphics/controls/MenuListButtonPart.h:
(isType):
* Source/WebCore/platform/graphics/controls/MenuListPart.h:
(isType):
* Source/WebCore/platform/graphics/controls/SearchFieldCancelButtonPart.h:
* Source/WebCore/platform/graphics/controls/SearchFieldPart.h:
* Source/WebCore/platform/graphics/controls/SearchFieldResultsPart.h:
(isType):
* Source/WebCore/platform/graphics/controls/SliderThumbPart.h:
(isType):
* Source/WebCore/platform/graphics/controls/TextAreaPart.h:
(isType):
* Source/WebCore/platform/graphics/controls/TextFieldPart.h:
* Source/WebCore/platform/graphics/controls/ToggleButtonPart.h:
(isType):
* Source/WebKit/Scripts/generate-serializers.py:
(SerializedType.__init__):
(SerializedType.can_assert_member_order_is_correct):
* Source/WebKit/Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<ControlPart>::encode): Deleted.
(IPC::ArgumentCoder<ControlPart>::decode): Deleted.
* Source/WebKit/Shared/WebCoreArgumentCoders.h:
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:

Canonical link: https://commits.webkit.org/273997@main
  • Loading branch information
cdumez committed Feb 2, 2024
1 parent b787dd9 commit aff791d
Show file tree
Hide file tree
Showing 17 changed files with 137 additions and 230 deletions.
4 changes: 4 additions & 0 deletions Source/WebCore/platform/graphics/controls/ButtonPart.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,7 @@ class ButtonPart final : public ControlPart {
};

} // namespace WebCore

SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ButtonPart) \
static bool isType(const WebCore::ControlPart& part) { return part.type() == WebCore::StyleAppearance::PushButton || part.type() == WebCore::StyleAppearance::SquareButton || part.type() == WebCore::StyleAppearance::Button || part.type() == WebCore::StyleAppearance::DefaultButton; } \
SPECIALIZE_TYPE_TRAITS_END()
2 changes: 2 additions & 0 deletions Source/WebCore/platform/graphics/controls/ColorWellPart.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,6 @@ class ColorWellPart final : public ControlPart {

} // namespace WebCore

SPECIALIZE_TYPE_TRAITS_CONTROL_PART(ColorWell)

#endif // ENABLE(INPUT_TYPE_COLOR)
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,6 @@ class ImageControlsButtonPart final : public ControlPart {

} // namespace WebCore

SPECIALIZE_TYPE_TRAITS_CONTROL_PART(ImageControlsButton)

#endif // ENABLE(SERVICE_CONTROLS)
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,5 @@ class InnerSpinButtonPart final : public ControlPart {
};

} // namespace WebCore

SPECIALIZE_TYPE_TRAITS_CONTROL_PART(InnerSpinButton)
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,8 @@ class MenuListButtonPart final : public ControlPart {
};

} // namespace WebCore

SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::MenuListButtonPart) \
static bool isType(const WebCore::ControlPart& part) { return part.type() == WebCore::StyleAppearance::MenulistButton; } \
SPECIALIZE_TYPE_TRAITS_END()

4 changes: 4 additions & 0 deletions Source/WebCore/platform/graphics/controls/MenuListPart.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,7 @@ class MenuListPart final : public ControlPart {
};

} // namespace WebCore

SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::MenuListPart) \
static bool isType(const WebCore::ControlPart& part) { return part.type() == WebCore::StyleAppearance::Menulist; } \
SPECIALIZE_TYPE_TRAITS_END()
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,5 @@ class SearchFieldCancelButtonPart final : public ControlPart {
};

} // namespace WebCore

SPECIALIZE_TYPE_TRAITS_CONTROL_PART(SearchFieldCancelButton)
2 changes: 2 additions & 0 deletions Source/WebCore/platform/graphics/controls/SearchFieldPart.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,5 @@ class SearchFieldPart final : public ControlPart {
};

} // namespace WebCore

SPECIALIZE_TYPE_TRAITS_CONTROL_PART(SearchField)
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,7 @@ class SearchFieldResultsPart final : public ControlPart {
};

} // namespace WebCore

SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::SearchFieldResultsPart) \
static bool isType(const WebCore::ControlPart& part) { return part.type() == WebCore::StyleAppearance::SearchFieldResultsDecoration || part.type() == WebCore::StyleAppearance::SearchFieldResultsButton; } \
SPECIALIZE_TYPE_TRAITS_END()
4 changes: 4 additions & 0 deletions Source/WebCore/platform/graphics/controls/SliderThumbPart.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,7 @@ class SliderThumbPart final : public ControlPart {
};

} // namespace WebCore

SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::SliderThumbPart) \
static bool isType(const WebCore::ControlPart& part) { return part.type() == WebCore::StyleAppearance::SliderThumbHorizontal || part.type() == WebCore::StyleAppearance::SliderThumbVertical; } \
SPECIALIZE_TYPE_TRAITS_END()
4 changes: 4 additions & 0 deletions Source/WebCore/platform/graphics/controls/TextAreaPart.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,7 @@ class TextAreaPart final : public ControlPart {
};

} // namespace WebCore

SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::TextAreaPart) \
static bool isType(const WebCore::ControlPart& part) { return part.type() == WebCore::StyleAppearance::Listbox || part.type() == WebCore::StyleAppearance::TextArea; } \
SPECIALIZE_TYPE_TRAITS_END()
2 changes: 2 additions & 0 deletions Source/WebCore/platform/graphics/controls/TextFieldPart.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,5 @@ class TextFieldPart final : public ControlPart {
};

} // namespace WebCore

SPECIALIZE_TYPE_TRAITS_CONTROL_PART(TextField)
4 changes: 4 additions & 0 deletions Source/WebCore/platform/graphics/controls/ToggleButtonPart.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,7 @@ class ToggleButtonPart final : public ControlPart {
};

} // namespace WebCore

SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToggleButtonPart) \
static bool isType(const WebCore::ControlPart& part) { return part.type() == WebCore::StyleAppearance::Checkbox || part.type() == WebCore::StyleAppearance::Radio; } \
SPECIALIZE_TYPE_TRAITS_END()
6 changes: 6 additions & 0 deletions Source/WebKit/Scripts/generate-serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
# AdditionalEncoder - generate serializers for StreamConnectionEncoder in addition to IPC::Encoder.
# CreateUsing - use a custom function to call instead of the constructor or create.
# CustomHeader - don't include a header based on the struct/class name. Only needed for non-enum types.
# DisableMissingMemberCheck - do not check for attributes that are missed during serialization.
# Alias - this type is not a struct or class, but a typedef.
# Nested - this type is only serialized as a member of its parent, so work around the need for http://wg21.link/P0289 and don't forward declare it in the header.
# RefCounted - deserializer returns a std::optional<Ref<T>> instead of a std::optional<T>.
Expand Down Expand Up @@ -96,6 +97,7 @@ def __init__(self, struct_or_class, cf_type, namespace, name, parent_class_name,
self.members_are_subclasses = False
self.custom_encoder = False
self.support_wkkeyedcoder = False
self.disableMissingMemberCheck = False
if attributes is not None:
for attribute in attributes.split(', '):
if '=' in attribute:
Expand All @@ -119,6 +121,8 @@ def __init__(self, struct_or_class, cf_type, namespace, name, parent_class_name,
self.nested = True
elif attribute == 'RefCounted':
self.return_ref = True
elif attribute == 'DisableMissingMemberCheck':
self.disableMissingMemberCheck = True
elif attribute == 'RValue':
self.rvalue = True
elif attribute == 'WebKitPlatform':
Expand Down Expand Up @@ -167,6 +171,8 @@ def function_name_for_enum(self):
return 'isValidEnum'

def can_assert_member_order_is_correct(self):
if self.disableMissingMemberCheck:
return False
for member in self.members:
if '()' in member.name:
return False
Expand Down
223 changes: 0 additions & 223 deletions Source/WebKit/Shared/WebCoreArgumentCoders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
#include <WebCore/CacheStorageConnection.h>
#include <WebCore/ColorWellPart.h>
#include <WebCore/CompositionUnderline.h>
#include <WebCore/ControlPart.h>
#include <WebCore/Credential.h>
#include <WebCore/Cursor.h>
#include <WebCore/DOMCacheEngine.h>
Expand Down Expand Up @@ -606,226 +605,4 @@ std::optional<WebCore::ScriptBuffer> ArgumentCoder<WebCore::ScriptBuffer>::decod
return std::nullopt;
}

template<typename Encoder>
void ArgumentCoder<ControlPart>::encode(Encoder& encoder, const ControlPart& part)
{
encoder << part.type();

switch (part.type()) {
case WebCore::StyleAppearance::None:
case WebCore::StyleAppearance::Auto:
break;

case WebCore::StyleAppearance::Checkbox:
case WebCore::StyleAppearance::Radio:
case WebCore::StyleAppearance::PushButton:
case WebCore::StyleAppearance::SquareButton:
case WebCore::StyleAppearance::Button:
case WebCore::StyleAppearance::DefaultButton:
case WebCore::StyleAppearance::Listbox:
case WebCore::StyleAppearance::Menulist:
case WebCore::StyleAppearance::MenulistButton:
break;

case WebCore::StyleAppearance::Meter:
encoder << downcast<WebCore::MeterPart>(part);
break;

case WebCore::StyleAppearance::ProgressBar:
encoder << downcast<WebCore::ProgressBarPart>(part);
break;

case WebCore::StyleAppearance::SliderHorizontal:
case WebCore::StyleAppearance::SliderVertical:
encoder << downcast<WebCore::SliderTrackPart>(part);
break;

case WebCore::StyleAppearance::SearchField:
break;

#if ENABLE(APPLE_PAY)
case WebCore::StyleAppearance::ApplePayButton:
encoder << downcast<WebCore::ApplePayButtonPart>(part);
break;
#endif

#if ENABLE(ATTACHMENT_ELEMENT)
case WebCore::StyleAppearance::Attachment:
case WebCore::StyleAppearance::BorderlessAttachment:
#endif
case WebCore::StyleAppearance::TextArea:
case WebCore::StyleAppearance::TextField:
case WebCore::StyleAppearance::CapsLockIndicator:
#if ENABLE(INPUT_TYPE_COLOR)
case WebCore::StyleAppearance::ColorWell:
#endif
#if ENABLE(SERVICE_CONTROLS)
case WebCore::StyleAppearance::ImageControlsButton:
#endif
case WebCore::StyleAppearance::InnerSpinButton:
#if ENABLE(DATALIST_ELEMENT)
case WebCore::StyleAppearance::ListButton:
#endif
case WebCore::StyleAppearance::SearchFieldDecoration:
case WebCore::StyleAppearance::SearchFieldResultsDecoration:
case WebCore::StyleAppearance::SearchFieldResultsButton:
case WebCore::StyleAppearance::SearchFieldCancelButton:
case WebCore::StyleAppearance::SliderThumbHorizontal:
case WebCore::StyleAppearance::SliderThumbVertical:
case WebCore::StyleAppearance::Switch:
break;

case WebCore::StyleAppearance::SwitchThumb:
encoder << downcast<WebCore::SwitchThumbPart>(part);
break;

case WebCore::StyleAppearance::SwitchTrack:
encoder << downcast<WebCore::SwitchTrackPart>(part);
break;
}
}

template
void ArgumentCoder<ControlPart>::encode<Encoder>(Encoder&, const ControlPart&);
template
void ArgumentCoder<ControlPart>::encode<StreamConnectionEncoder>(StreamConnectionEncoder&, const ControlPart&);

std::optional<Ref<ControlPart>> ArgumentCoder<ControlPart>::decode(Decoder& decoder)
{
std::optional<WebCore::StyleAppearance> type;
decoder >> type;
if (!type)
return std::nullopt;

switch (*type) {
case WebCore::StyleAppearance::None:
case WebCore::StyleAppearance::Auto:
break;

case WebCore::StyleAppearance::Checkbox:
case WebCore::StyleAppearance::Radio:
return WebCore::ToggleButtonPart::create(*type);

case WebCore::StyleAppearance::PushButton:
case WebCore::StyleAppearance::SquareButton:
case WebCore::StyleAppearance::Button:
case WebCore::StyleAppearance::DefaultButton:
return WebCore::ButtonPart::create(*type);

case WebCore::StyleAppearance::Menulist:
return WebCore::MenuListPart::create();

case WebCore::StyleAppearance::MenulistButton:
return WebCore::MenuListButtonPart::create();

case WebCore::StyleAppearance::Meter: {
std::optional<Ref<WebCore::MeterPart>> meterPart;
decoder >> meterPart;
if (meterPart)
return WTFMove(*meterPart);
break;
}

case WebCore::StyleAppearance::ProgressBar: {
std::optional<Ref<WebCore::ProgressBarPart>> progressBarPart;
decoder >> progressBarPart;
if (progressBarPart)
return WTFMove(*progressBarPart);
break;
}

case WebCore::StyleAppearance::SliderHorizontal:
case WebCore::StyleAppearance::SliderVertical: {
std::optional<Ref<WebCore::SliderTrackPart>> sliderTrackPart;
decoder >> sliderTrackPart;
if (sliderTrackPart)
return WTFMove(*sliderTrackPart);
break;
}

case WebCore::StyleAppearance::SearchField:
return WebCore::SearchFieldPart::create();

#if ENABLE(APPLE_PAY)
case WebCore::StyleAppearance::ApplePayButton: {
std::optional<Ref<WebCore::ApplePayButtonPart>> applePayButtonPart;
decoder >> applePayButtonPart;
if (applePayButtonPart)
return WTFMove(*applePayButtonPart);
break;
}
#endif

#if ENABLE(ATTACHMENT_ELEMENT)
case WebCore::StyleAppearance::Attachment:
case WebCore::StyleAppearance::BorderlessAttachment:
#endif
break;

case WebCore::StyleAppearance::Listbox:
case WebCore::StyleAppearance::TextArea:
return WebCore::TextAreaPart::create(*type);

case WebCore::StyleAppearance::TextField:
return WebCore::TextFieldPart::create();

case WebCore::StyleAppearance::CapsLockIndicator:
break;

#if ENABLE(INPUT_TYPE_COLOR)
case WebCore::StyleAppearance::ColorWell:
return WebCore::ColorWellPart::create();
#endif
#if ENABLE(SERVICE_CONTROLS)
case WebCore::StyleAppearance::ImageControlsButton:
return WebCore::ImageControlsButtonPart::create();
#endif

case WebCore::StyleAppearance::InnerSpinButton:
return WebCore::InnerSpinButtonPart::create();

#if ENABLE(DATALIST_ELEMENT)
case WebCore::StyleAppearance::ListButton:
break;
#endif

case WebCore::StyleAppearance::SearchFieldDecoration:
break;

case WebCore::StyleAppearance::SearchFieldResultsDecoration:
case WebCore::StyleAppearance::SearchFieldResultsButton:
return WebCore::SearchFieldResultsPart::create(*type);

case WebCore::StyleAppearance::SearchFieldCancelButton:
return WebCore::SearchFieldCancelButtonPart::create();

case WebCore::StyleAppearance::SliderThumbHorizontal:
case WebCore::StyleAppearance::SliderThumbVertical:
return WebCore::SliderThumbPart::create(*type);

case WebCore::StyleAppearance::Switch:
break;

case WebCore::StyleAppearance::SwitchThumb: {
std::optional<Ref<WebCore::SwitchThumbPart>> switchThumbPart;
decoder >> switchThumbPart;
if (switchThumbPart)
return WTFMove(*switchThumbPart);
break;
}

case WebCore::StyleAppearance::SwitchTrack: {
std::optional<Ref<WebCore::SwitchTrackPart>> switchTrackPart;
decoder >> switchTrackPart;
if (switchTrackPart)
return WTFMove(*switchTrackPart);
break;
}

}

ASSERT_NOT_REACHED();
return std::nullopt;
}

} // namespace IPC
7 changes: 0 additions & 7 deletions Source/WebKit/Shared/WebCoreArgumentCoders.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ namespace WebCore {

class AppKitControlSystemImage;
class BlobPart;
class ControlPart;
class Credential;
class Cursor;
class FilterEffect;
Expand Down Expand Up @@ -226,12 +225,6 @@ template<> struct ArgumentCoder<WebCore::ScriptBuffer> {
static std::optional<WebCore::ScriptBuffer> decode(Decoder&);
};

template<> struct ArgumentCoder<WebCore::ControlPart> {
template<typename Encoder>
static void encode(Encoder&, const WebCore::ControlPart&);
static std::optional<Ref<WebCore::ControlPart>> decode(Decoder&);
};

#if ENABLE(DATA_DETECTION)

template<> struct ArgumentCoder<WebCore::DataDetectorElementInfo> {
Expand Down
Loading

0 comments on commit aff791d

Please sign in to comment.