Skip to content
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

[GLib] Make most public types final #8972

Merged
merged 1 commit into from Jan 24, 2023

Conversation

aperezdc
Copy link
Contributor

@aperezdc aperezdc commented Jan 23, 2023

f1f3d52

[GLib] Make most public types final
https://bugs.webkit.org/show_bug.cgi?id=251008

Reviewed by Carlos Garcia Campos.

Add a new WEBKIT_DEFINE_TYPE_WITH_CODE macro, plus two helper macros
with an _IN_2022_API suffix to be used all around the code. These two
macros mark types as final only when ENABLE(2022_GLIB_API) is enabled,
otherwise they behave as the existing ones (leaving the types as
derivable). This will allow in the future to easily search for types
which change between final/non-final, and remove the use of _IN_2022_API
macros when the old API is no longer needed. Also, make sure to require
GLib 2.70 for the new API.

* Source/WTF/wtf/glib/WTFGType.h: Add new macros and switch between
  final/non-final depending on the value of ENABLE(2022_GLIB_API).
* Source/WebKit/Shared/API/glib/WebKitContextMenu.cpp:
* Source/WebKit/Shared/API/glib/WebKitContextMenuItem.cpp:
* Source/WebKit/Shared/API/glib/WebKitURIRequest.cpp:
* Source/WebKit/Shared/API/glib/WebKitURIResponse.cpp:
* Source/WebKit/Shared/API/glib/WebKitUserMessage.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitAuthenticationRequest.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitAutomationSession.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitBackForwardList.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitBackForwardListItem.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitCookieManager.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitDeviceInfoPermissionRequest.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitDownload.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitEditorState.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitFaviconDatabase.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitFileChooserRequest.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitFindController.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitFormSubmissionRequest.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitGeolocationManager.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitGeolocationPermissionRequest.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitMediaKeySystemPermissionRequest.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitNavigationPolicyDecision.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitNotification.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitNotificationPermissionRequest.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitOptionMenu.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitPointerLockPermissionRequest.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitResponsePolicyDecision.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitSecurityManager.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitSettings.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitUserContentFilterStore.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitUserContentManager.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitUserMediaPermissionRequest.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitWebResource.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitWebsiteDataAccessPermissionRequest.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitWebsiteDataManager.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitWindowProperties.cpp:
* Source/WebKit/UIProcess/API/gtk/WebKitColorChooserRequest.cpp:
* Source/WebKit/UIProcess/API/gtk/WebKitPrintOperation.cpp:
* Source/WebKit/UIProcess/API/gtk/WebKitWebInspector.cpp:
* Source/cmake/OptionsGTK.cmake: Require GLib 2.70.0 when
  ENABLE(2022_GLIB_API) is set.
* Source/cmake/OptionsWPE.cmake: Ditto.

Canonical link: https://commits.webkit.org/259270@main

275acb0

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe   πŸ›  πŸ§ͺ win
βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug βœ… πŸ›  gtk βœ… πŸ›  wincairo
βœ… πŸ§ͺ webkitperl   πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac   πŸ§ͺ gtk-wk2
βœ… πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk1 βœ… πŸ§ͺ api-gtk
  πŸ›  πŸ§ͺ jsc βœ… πŸ›  tv βœ… πŸ§ͺ mac-wk2 βœ… πŸ›  jsc-armv7
βœ… πŸ›  πŸ§ͺ jsc-arm64 βœ… πŸ›  tv-sim   πŸ§ͺ mac-AS-debug-wk2 βœ… πŸ§ͺ jsc-armv7-tests
βœ… πŸ›  watch βœ… πŸ§ͺ mac-wk2-stress βœ… πŸ›  jsc-mips
βœ… πŸ›  πŸ§ͺ merge βœ… πŸ›  watch-sim βœ… πŸ§ͺ jsc-mips-tests

@aperezdc aperezdc requested a review from a team as a code owner January 23, 2023 14:19
@aperezdc aperezdc self-assigned this Jan 23, 2023
@aperezdc aperezdc added the WebKit API For issues and bugs in the Web Kit public embedding APIs label Jan 23, 2023
@carlosgcampos
Copy link
Contributor

We need to bump the minimum glib requirements to 2.70 (only for the new api).

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jan 23, 2023
@aperezdc
Copy link
Contributor Author

We need to bump the minimum glib requirements to 2.70 (only for the new api).

Good point, I will update the PR. Also no idea what's going on with the timeout in the WPE EWS builder, I'll see if that happens locally or not.

Comment on lines +54 to +55
#define WEBKIT_DEFINE_FINAL_TYPE_IN_2022_API WEBKIT_DEFINE_TYPE
#define WEBKIT_DEFINE_FINAL_TYPE_WITH_CODE_IN_2022_API WEBKIT_DEFINE_TYPE_WITH_CODE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine, but I'm not sure it's really much benefit? I would just provide two different definitions of WEBKIT_DEFINE_FINAL_TYPE, where it uses G_TYPE_FLAG_FINAL if it's the new API and just doesn't for the old API. That will avoid adding the _IN_2022_API cruft to all the source files.

Would that conflict with what you've got planned next?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought of that first, but then it seemed to me quite obscure that a WEBKIT_DEFINE_FINAL_TYPE macro won't create a final type when ENABLE(2022_GLIB_API) is offβ€”it feels very wrong and will be confusing. So I did the extra indirection with the _IN_2022_API suffix for clarity.

@aperezdc aperezdc removed the merging-blocked Applied to prevent a change from being merged label Jan 23, 2023
@aperezdc
Copy link
Contributor Author

We need to bump the minimum glib requirements to 2.70 (only for the new api).

Good point, I will update the PR. Also no idea what's going on with the timeout in the WPE EWS builder, I'll see if that happens locally or not.

The lockup was caused by marking WebKitHitTestResult as final: it turns out that this type has a WebKitWebHitTestResult (in Source/WebKit/WebProcess/InjectedBundle/API/glib/WebKitWebHitTestResult.cpp) and the introspection scanner sometimes goes bananas when it sees a subclass of a final type πŸ™ƒβ€”PR updated accordingly.

@mcatanzaro
Copy link
Contributor

Would probably be nicer for WebKitWebHitTestResult to use composition rather than inheritance, but I certainly don't expect you to change that here....

@aperezdc
Copy link
Contributor Author

Would probably be nicer for WebKitWebHitTestResult to use composition rather than inheritance, but I certainly don't expect you to change that here....

Let's do it as a separate issue, I have filed #251075 for that.

@aperezdc aperezdc added the merge-queue Applied to send a pull request to merge-queue label Jan 24, 2023
https://bugs.webkit.org/show_bug.cgi?id=251008

Reviewed by Carlos Garcia Campos.

Add a new WEBKIT_DEFINE_TYPE_WITH_CODE macro, plus two helper macros
with an _IN_2022_API suffix to be used all around the code. These two
macros mark types as final only when ENABLE(2022_GLIB_API) is enabled,
otherwise they behave as the existing ones (leaving the types as
derivable). This will allow in the future to easily search for types
which change between final/non-final, and remove the use of _IN_2022_API
macros when the old API is no longer needed. Also, make sure to require
GLib 2.70 for the new API.

* Source/WTF/wtf/glib/WTFGType.h: Add new macros and switch between
  final/non-final depending on the value of ENABLE(2022_GLIB_API).
* Source/WebKit/Shared/API/glib/WebKitContextMenu.cpp:
* Source/WebKit/Shared/API/glib/WebKitContextMenuItem.cpp:
* Source/WebKit/Shared/API/glib/WebKitURIRequest.cpp:
* Source/WebKit/Shared/API/glib/WebKitURIResponse.cpp:
* Source/WebKit/Shared/API/glib/WebKitUserMessage.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitAuthenticationRequest.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitAutomationSession.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitBackForwardList.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitBackForwardListItem.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitCookieManager.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitDeviceInfoPermissionRequest.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitDownload.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitEditorState.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitFaviconDatabase.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitFileChooserRequest.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitFindController.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitFormSubmissionRequest.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitGeolocationManager.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitGeolocationPermissionRequest.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitMediaKeySystemPermissionRequest.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitNavigationPolicyDecision.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitNotification.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitNotificationPermissionRequest.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitOptionMenu.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitPointerLockPermissionRequest.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitResponsePolicyDecision.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitSecurityManager.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitSettings.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitUserContentFilterStore.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitUserContentManager.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitUserMediaPermissionRequest.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitWebResource.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitWebsiteDataAccessPermissionRequest.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitWebsiteDataManager.cpp:
* Source/WebKit/UIProcess/API/glib/WebKitWindowProperties.cpp:
* Source/WebKit/UIProcess/API/gtk/WebKitColorChooserRequest.cpp:
* Source/WebKit/UIProcess/API/gtk/WebKitPrintOperation.cpp:
* Source/WebKit/UIProcess/API/gtk/WebKitWebInspector.cpp:
* Source/cmake/OptionsGTK.cmake: Require GLib 2.70.0 when
  ENABLE(2022_GLIB_API) is set.
* Source/cmake/OptionsWPE.cmake: Ditto.

Canonical link: https://commits.webkit.org/259270@main
@webkit-commit-queue
Copy link
Collaborator

Committed 259270@main (f1f3d52): https://commits.webkit.org/259270@main

Reviewed commits have been landed. Closing PR #8972 and removing active labels.

@webkit-early-warning-system webkit-early-warning-system merged commit f1f3d52 into WebKit:main Jan 24, 2023
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Jan 24, 2023
@aperezdc aperezdc deleted the glib-final-types branch January 24, 2023 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebKit API For issues and bugs in the Web Kit public embedding APIs
Projects
None yet
6 participants