-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AXNotification enum ought to be an X macro #25805
AXNotification enum ought to be an X macro #25805
Conversation
EWS run on previous version of this PR (hash 78460d1) |
78460d1
to
1ebd6fc
Compare
EWS run on previous version of this PR (hash 1ebd6fc) |
1ebd6fc
to
b0f75c2
Compare
EWS run on previous version of this PR (hash b0f75c2) |
Background: #23035 (comment) Basically, it may or may not actually be beneficial for us to upstream our current AX impl, since it differs so much from other platforms, but if we could X-macro-ify |
b0f75c2
to
4da9cac
Compare
EWS run on previous version of this PR (hash 4da9cac) |
@@ -139,6 +139,110 @@ class AccessibilityReplacedText { | |||
VisiblePositionIndexRange m_replacedRange; | |||
}; | |||
|
|||
#define WEBCORE_AXNOTIFICATION_KEYS_DEFAULT(macro) \ | |||
macro(AccessKeyChanged) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks strictly worse. I don't understand why we want to adopt this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I linked the explanation above but I can link it again here: #23035 (comment)
Introducing WebKit/UIProcess/API/C/WKAXTypes.h
with enums like...
enum AXNotification {
// must be same as WebCore::AXObjectCache::AXNotification
kWKAXAccessKeyChanged,
...
};
typedef uint32_t WKAXNotification;
...and extending WebKit/UIProcess/API/C/WKAPICast.h
with casts like...
inline WKAXNotification toAPI(WebCore::AXObjectCache::AXNotification notification)
{
switch (notification) {
case WebCore::AXObjectCache::AXNotification::AXAccessKeyChanged:
return kWKAXAccessKeyChanged;
...
}
}
...feels rather hard to justify if only one platform is planning to use these casts.
Since the idea is just to ensure that the API casts get updated whenever the WebCore enums get updated, the ideal situation would be to have this happen automatically, without requiring developers to be conscious of it. This automation is achieved by X macros, which allow us to do an exhaustive switch
on a enum without being concerned with the specific values of that enum changing. Indeed, forgetting about any platform-specific needs, in AXLogger, we're able to reduce a switch
from 286 lines to just 8, and those 8 lines needn't be touched the next time AXNotification changes.
I understand that while this is commonplace in JSC (looks like we may have almost 200 of them), it surely feels quite foreign in WebCore. But I'm not sure of a different tool that fits this problem so well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like I've overestimated how foreign this actually is outside of JSC. We have X macros defined in...
Source/WebCore/bindings/js/WebCoreBuiltinNames.h
Source/WebCore/cssjit/SelectorCompiler.cpp
Source/WebCore/html/parser/HTMLDocumentParserFastPath.cpp
Source/WebCore/inspector/InspectorCanvasCallTracer.h
Source/WebCore/inspector/InstrumentingAgents.h
Source/WebCore/page/ResourceUsageData.h
Source/WebCore/platform/CommonAtomStrings.h
Source/WebCore/platform/Logging.h
Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h
Source/WebCore/platform/graphics/texmap/TextureMapperShaderProgram.h
Source/WebCore/PAL/pal/Logging.h
Source/WebKit/Platform/Logging.h
Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
Source/WTF/wtf/Logging.h
Source/WTF/wtf/SystemTracing.h
Tools/TestRunnerShared/EventSerialization/mac/EventSerializerMac.mm
Tools/TestWebKitAPI/Tests/WebCore/DisplayListRecorderTests.cpp
...and a few more files which are GTK/WPE-specific.
So I revoke my hedging; this is not only the right tool for the job, it's also a perfectly normal thing for us to do.
4da9cac
to
0bc8bf0
Compare
EWS run on previous version of this PR (hash 0bc8bf0) |
Per @darinadler's suggestion on Slack, I've removed the |
0bc8bf0
to
bb5fd9b
Compare
EWS run on previous version of this PR (hash bb5fd9b) |
stream << "AXTextCompositionEnded"; | ||
#define WEBCORE_LOG_AXNOTIFICATION(name) \ | ||
case AXObjectCache::AXNotification::name: \ | ||
stream << #name; \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we put βAXβ #name
here then we could leave all the repeated AX out of the macro arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea!
AXDraggingEnteredDropZone, | ||
AXDraggingDropped, | ||
AXDraggingExitedDropZone | ||
#define WEBCORE_DEFINE_AXNOTIFICATION_ENUM(name) name, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here AX##name
.
bb5fd9b
to
e9b308b
Compare
e9b308b
to
f65af2a
Compare
EWS run on current version of this PR (hash f65af2a) |
https://bugs.webkit.org/show_bug.cgi?id=270893 Reviewed by Darin Adler. AXNotification is a giant and frequently updated enum. Every time it is updated, exhaustive switch statements must be updated accordingly. This is a very appropriate place for an X macro -- selfishly, it will help PlayStation port avoid build breaks (since we handle this enum in WKAPICast), but irrespective of platform, it also means that AXLogger won't need to be updated each time AXNotification is updated. * Source/WebCore/accessibility/AXLogger.cpp: (WebCore::operator<<): * Source/WebCore/accessibility/AXObjectCache.h: Canonical link: https://commits.webkit.org/276393@main
f65af2a
to
129ce14
Compare
Committed 276393@main (129ce14): https://commits.webkit.org/276393@main Reviewed commits have been landed. Closing PR #25805 and removing active labels. |
129ce14
f65af2a
π§ͺ wpe-wk2π§ͺ ios-wk2-wpt