Modernize EnumTraits in components/
Minor
Commit Hash:
51633370fb5ea558e8e721e37e643477c06cddfa
Commit Time: 2026-03-30 09:13:42
Impact Level: Minor
Generated By: webview2-upstream-sentry
Upstream Review:
View Upstream Review 🔗
📋 Summary
This commit is part of a Chromium-wide Mojo EnumTraits modernization refactoring. It changes the FromMojom() method signature from the old output-parameter style (returning bool with result via pointer parameter) to directly returning the target type. For the remote_cocoa part, it modifies two EnumTraits specializations in components/remote_cocoa/common/font_mojom_traits.h:
1. EnumTraits::FromMojom() changed from returning bool + out parameter to directly returning SystemFontType, with invalid input using NOTREACHED().
2. EnumTraits::FromMojom() similarly changed from returning bool + out parameter to directly returning Font::Weight, with invalid input using NOTREACHED().
1. EnumTraits
2. EnumTraits
🎯 Impact Analysis
The impact of this change on WebView2Mac is minor. Key analysis:
1. **Remote Cocoa font Mojo serialization affected**: The modified font_mojom_traits.h is used for Mojo serialization/deserialization of font information in Remote Cocoa cross-process communication. WebView2Mac uses these traits when passing font information between the app shim and browser processes.
2. **API signature change requires sync**: FromMojom()'s signature changed from
3. **Error handling strategy change**: The old FromMojom returned false on invalid input (allowing callers to handle errors), while the new version uses NOTREACHED() to abort. This means receiving an unknown enum value in cross-process communication will crash rather than silently fail. This is a stricter error handling approach for WebView2Mac stability, but won't trigger during normal operation.
4. **Consistent with Chromium-wide refactoring**: This commit touches numerous files across components/, constituting a global API migration. Edge integration must ensure all affected EnumTraits use the new style to avoid Mojo framework version mismatches.
1. **Remote Cocoa font Mojo serialization affected**: The modified font_mojom_traits.h is used for Mojo serialization/deserialization of font information in Remote Cocoa cross-process communication. WebView2Mac uses these traits when passing font information between the app shim and browser processes.
2. **API signature change requires sync**: FromMojom()'s signature changed from
bool FromMojom(MojomType, NativeType*) to NativeType FromMojom(MojomType), a compile-time API change. If Edge repo has any code directly calling these FromMojom methods (typically called automatically by Mojo infrastructure), it needs to be updated. Since these are traits used internally by the Mojo framework, manual calls are uncommon, and compilation will verify correctness upon integration.3. **Error handling strategy change**: The old FromMojom returned false on invalid input (allowing callers to handle errors), while the new version uses NOTREACHED() to abort. This means receiving an unknown enum value in cross-process communication will crash rather than silently fail. This is a stricter error handling approach for WebView2Mac stability, but won't trigger during normal operation.
4. **Consistent with Chromium-wide refactoring**: This commit touches numerous files across components/, constituting a global API migration. Edge integration must ensure all affected EnumTraits use the new style to avoid Mojo framework version mismatches.
Impacted Classes:
mojo::EnumTraits<remote_cocoa::mojom::SystemFont>
mojo::EnumTraits<remote_cocoa::mojom::FontWeight>