Hi floks!

I noticed that both the EFL port and GTK+ port use a 
COMPILE_ASSERT_MATCHING_ENUM macro to make sure that WebCore enum values map to 
API enum values correctly, for example:

COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED, 
NavigationTypeLinkClicked);

This means that we can’t add new enums declarations (unless they’re added at 
the end) without breaking the build.

Instead of doing this (and then just blindly casting between the API layer and 
WebCore enum types), use conversion functions, like this (taken from WebKit2):

> inline WebCore::PageVisibilityState 
> toPageVisibilityState(WKPageVisibilityState wkPageVisibilityState)
> {
>     switch (wkPageVisibilityState) {
>     case kWKPageVisibilityStateVisible:
>         return WebCore::PageVisibilityStateVisible;
>     case kWKPageVisibilityStateHidden:
>         return WebCore::PageVisibilityStateHidden;
>     case kWKPageVisibilityStatePrerender:
>         return WebCore::PageVisibilityStatePrerender;
>     }
> 
>     ASSERT_NOT_REACHED();
>     return WebCore::PageVisibilityStateVisible;
> }

I plan to audit the Mac and Windows ports and look for places where we cast 
between API enum types and WebCore enum types, and I filed 

https://bugs.webkit.org/show_bug.cgi?id=127800 WebKitGTK+ should stop using 
COMPILE_ASSERT_MATCHING_ENUM macros
https://bugs.webkit.org/show_bug.cgi?id=127801 EFL port should stop using 
COMPILE_ASSERT_MATCHING_ENUM macros

for the Mac and EFL ports respectively. I’m happy to answer any questions about 
this.

- Anders

_______________________________________________
webkit-dev mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-dev

Reply via email to