-
Notifications
You must be signed in to change notification settings - Fork 56
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
Extension Icons for Light/Dark/Custom Theme #229
Comments
I fully support it. However, it seems to me that it should be implemented as a browser-based JS API available for websites as well. The point is that all the problems from the list above are relevant for Favicons. |
I think website favicon and extension icon are not exactly the same problem. Here is a stackoverflow question for website favicon. There are several solution for it. For example, svg favicon with media query, But these solutions do not apply to extensions. Extension icons are declared in manifest.json. And there is no |
Chromium is tracking a similar feature request in issue 893175. A Chromium engineer shared a link to a design doc we were considering in comment 19, but that effort is currently on hold. @xeenon, @zombie, and @mukul-p, it might be worth taking a look at this and sharing feedback either on the doc or on a related issue. |
I see the design doc. It is a static(declarative) way in manifest file. I think it solves 90% of the problems. I think a runtime API should also be provided to solve dynamic problems, because developers can change icon by
|
We can draw some inspiration from ongoing discussion on how to handle this in PWA manifests, see: In general, going for a list of icons versus an object, like Mozilla did with We can go for a syntax like this:
Or adding a |
Firefox implementation can be seen at e.g. https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/action |
For best backwards compatibility, we can consider implementing the
We can then move forward with more breaking changes in regard to icons for Manifest v4. |
I didn't know Firefox's theme_icons before. For me, it's counterintuitive. I prefer dark for icons used in dark theme and light for icons used in light theme. |
@hanguokai This would then be something we can fix once drafting MV4. As for the API to update
Calling this method would overwrite the Currently in Firefox, setIcon will overwrite what is defined in |
The |
Discussion on this issue has been narrowed to the |
For reference, 5 years ago I proposed |
We (Mozilla) are going to add support for As for |
any updates on chrome extension support for dark mode icon? |
It would be nice if SVG icons simply supported Edit: this currently works thanks to Edit2: w3c/csswg-drafts#9872 |
@phaux I agree, that should work in Safari. |
@phaux how about using an env variable for this to provide authors a way to have a fallback in case the browser does not support this feature? |
For my use case, I am dynamically creating the browser icon at runtime. In order to accommodate dark and light modes, I draw different styles to a canvas and then set the icon to the canvas contents. An API design which takes as input both images would be better than needing to detect the theme in a offscreen document, but would still require wasted work painting the unused theme's respective canvas. Preferably media queries would be exposed to service workers, but something like Also, notifications are another surface to consider. |
The tradeoff here is that it means the icons wouldn't be available when the theme first changes, and we couldn't update them at the same time as everything else. I don't think exposing media queries to service workers is off the table but I think we'd be hesitant to encourage doing reactive work based on theme changes, at least in the most common cases :)
For sure! |
@oliverdunk Very much agree with having both dark and light icons available so a theme switch can be made is a good one. However I believe exposing additional metadata for the action icon would be very useful in reducing the icons needed to generate and action icons are as pixel perfect as possible. For example, devicePixelRatio is currently not available in serviceWorkers sadly. Think about a method like {
"size": 16,
"dpi": 2,
"actualSize": 32,
"color_schemes": ["light", "dark"]
}
|
On the topic of DPR, I just realized that the multiple monitor use case is also something to consider. There can be multiple screens with different icon sizes. So for a hypothetical function to get the icon size, you would need to return a set or array of icon sizes. You should then be able to use that with the existing size based As far as I can tell calculating icon sizes for multiple screens is currently not trivally implemented. Should this icon size retrieval topic be filed as a separate issue? |
A new issue would be best. |
https://webkit.org/b/278818 rdar://problem/134885372 Reviewed by NOBODY (OOPS!). Add support for `icon_variants` manifest parsing under the `WK_WEB_EXTENSIONS_ICON_VARIANTS` flag, with optimizations to ensure efficient icon loading. This change introduces `icon_variants` manifest parsing, explicitly supporting different icon sets, such as dark mode icons. To achieve this efficiently, icons are now cached by size, reducing disk I/O by avoiding repeated loads when the browser frequently requests the same icon. The cache is automatically invalidated when device scales change, such as when connecting or disconnecting a display with a different scale factor. Only the necessary icons are loaded based on the specific scale factor of all screens, halving the image loads compared to previous behavior. This ensures that even as more extensions adopt dark mode icons, typical image loads remain at two images (light and dark). Proposal: https://github.com/w3c/webextensions/blob/main/proposals/dark_mode_extension_icons.md WECG issue: w3c/webextensions#229 * Source/WTF/wtf/PlatformEnableCocoa.h: Added ENABLE_WK_WEB_EXTENSIONS_ICON_VARIANTS. * Source/WebCore/en.lproj/Localizable.strings: Updated. * Source/WebKit/Platform/cocoa/CocoaHelpers.h: * Source/WebKit/Platform/cocoa/CocoaHelpers.mm: (WebKit::availableScreenScales): Added. (WebKit::largestDisplayScale): Added. * Source/WebKit/Platform/spi/ios/UIKitSPI.h: * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionActionCocoa.mm: (WebKit::WebExtensionAction::icon): * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionCocoa.mm: (WebKit::WebExtension::icon): (WebKit::WebExtension::actionIcon): (WebKit::WebExtension::populateActionPropertiesIfNeeded): (WebKit::WebExtension::populateSidebarActionProperties): (WebKit::WebExtension::populateSidePanelProperties): (WebKit::WebExtension::imageForPath): (WebKit::WebExtension::bestSizeInIconsDictionary): Added. (WebKit::WebExtension::pathForBestImageInIconsDictionary): (WebKit::WebExtension::bestImageInIconsDictionary): (WebKit::WebExtension::bestImageForIconsDictionaryManifestKey): (WebKit::toColorSchemes): Added. (WebKit::WebExtension::iconsDictionaryForBestIconVariant): Added. (WebKit::WebExtension::bestImageForIconVariants): Added. (WebKit::WebExtension::bestImageForIconVariantsManifestKey): Added. * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionMenuItemCocoa.mm: (WebKit::WebExtensionMenuItem::icon const): * Source/WebKit/UIProcess/Extensions/WebExtension.h: * Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtension.mm: (TestWebKitAPI::TEST(WKWebExtension, MultipleIconVariants)): Added. (TestWebKitAPI::TEST(WKWebExtension, SingleIconVariant)): Added. (TestWebKitAPI::TEST(WKWebExtension, AnySizeIconVariant)): Added. (TestWebKitAPI::TEST(WKWebExtension, NoIconVariants)): Added. (TestWebKitAPI::TEST(WKWebExtension, IconsAndIconVariantsSpecified)): Added. (TestWebKitAPI::TEST(WKWebExtension, ActionIconVariantsMultiple)): Added. (TestWebKitAPI::TEST(WKWebExtension, ActionIconSingleVariant)): Added. (TestWebKitAPI::TEST(WKWebExtension, ActionIconAnySizeVariant)): Added. (TestWebKitAPI::TEST(WKWebExtension, ActionNoIconVariants)): Added. (TestWebKitAPI::TEST(WKWebExtension, ActionIconsAndIconVariantsSpecified)): Added. * Tools/TestWebKitAPI/cocoa/WebExtensionUtilities.h: * Tools/TestWebKitAPI/cocoa/WebExtensionUtilities.mm: (TestWebKitAPI::Util::performWithAppearance): Added. (TestWebKitAPI::Util::pixelColor): Added. (TestWebKitAPI::Util::toSRGBColor): Added. (TestWebKitAPI::Util::compareColors): Added.
https://webkit.org/b/278818 rdar://problem/134885372 Reviewed by NOBODY (OOPS!). Add support for `icon_variants` manifest parsing under the `WK_WEB_EXTENSIONS_ICON_VARIANTS` flag, with optimizations to ensure efficient icon loading. This change introduces `icon_variants` manifest parsing, explicitly supporting different icon sets, such as dark mode icons. To achieve this efficiently, icons are now cached by size, reducing disk I/O by avoiding repeated loads when the browser frequently requests the same icon. The cache is automatically invalidated when device scales change, such as when connecting or disconnecting a display with a different scale factor. Only the necessary icons are loaded based on the specific scale factor of all screens, halving the image loads compared to previous behavior. This ensures that even as more extensions adopt dark mode icons, typical image loads remain at two images (light and dark). Proposal: https://github.com/w3c/webextensions/blob/main/proposals/dark_mode_extension_icons.md WECG issue: w3c/webextensions#229 * Source/WTF/wtf/PlatformEnableCocoa.h: Added ENABLE_WK_WEB_EXTENSIONS_ICON_VARIANTS. * Source/WebCore/en.lproj/Localizable.strings: Updated. * Source/WebKit/Platform/cocoa/CocoaHelpers.h: * Source/WebKit/Platform/cocoa/CocoaHelpers.mm: (WebKit::availableScreenScales): Added. (WebKit::largestDisplayScale): Added. * Source/WebKit/Platform/spi/ios/UIKitSPI.h: * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionActionCocoa.mm: (WebKit::WebExtensionAction::icon): * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionCocoa.mm: (WebKit::WebExtension::icon): (WebKit::WebExtension::actionIcon): (WebKit::WebExtension::populateActionPropertiesIfNeeded): (WebKit::WebExtension::populateSidebarActionProperties): (WebKit::WebExtension::populateSidePanelProperties): (WebKit::WebExtension::imageForPath): (WebKit::WebExtension::bestSizeInIconsDictionary): Added. (WebKit::WebExtension::pathForBestImageInIconsDictionary): (WebKit::WebExtension::bestImageInIconsDictionary): (WebKit::WebExtension::bestImageForIconsDictionaryManifestKey): (WebKit::toColorSchemes): Added. (WebKit::WebExtension::iconsDictionaryForBestIconVariant): Added. (WebKit::WebExtension::bestImageForIconVariants): Added. (WebKit::WebExtension::bestImageForIconVariantsManifestKey): Added. * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionMenuItemCocoa.mm: (WebKit::WebExtensionMenuItem::icon const): * Source/WebKit/UIProcess/Extensions/WebExtension.h: * Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtension.mm: (TestWebKitAPI::TEST(WKWebExtension, MultipleIconVariants)): Added. (TestWebKitAPI::TEST(WKWebExtension, SingleIconVariant)): Added. (TestWebKitAPI::TEST(WKWebExtension, AnySizeIconVariant)): Added. (TestWebKitAPI::TEST(WKWebExtension, NoIconVariants)): Added. (TestWebKitAPI::TEST(WKWebExtension, IconsAndIconVariantsSpecified)): Added. (TestWebKitAPI::TEST(WKWebExtension, ActionIconVariantsMultiple)): Added. (TestWebKitAPI::TEST(WKWebExtension, ActionIconSingleVariant)): Added. (TestWebKitAPI::TEST(WKWebExtension, ActionIconAnySizeVariant)): Added. (TestWebKitAPI::TEST(WKWebExtension, ActionNoIconVariants)): Added. (TestWebKitAPI::TEST(WKWebExtension, ActionIconsAndIconVariantsSpecified)): Added. * Tools/TestWebKitAPI/cocoa/WebExtensionUtilities.h: * Tools/TestWebKitAPI/cocoa/WebExtensionUtilities.mm: (TestWebKitAPI::Util::performWithAppearance): Added. (TestWebKitAPI::Util::pixelColor): Added. (TestWebKitAPI::Util::toSRGBColor): Added. (TestWebKitAPI::Util::compareColors): Added.
https://webkit.org/b/278818 rdar://problem/134885372 Reviewed by NOBODY (OOPS!). Add support for `icon_variants` manifest parsing under the `WK_WEB_EXTENSIONS_ICON_VARIANTS` flag, with optimizations to ensure efficient icon loading. This change introduces `icon_variants` manifest parsing, explicitly supporting different icon sets, such as dark mode icons. To achieve this efficiently, icons are now cached by size, reducing disk I/O by avoiding repeated loads when the browser frequently requests the same icon. The cache is automatically invalidated when device scales change, such as when connecting or disconnecting a display with a different scale factor. Only the necessary icons are loaded based on the specific scale factor of all screens, halving the image loads compared to previous behavior. This ensures that even as more extensions adopt dark mode icons, typical image loads remain at two images (light and dark). Proposal: https://github.com/w3c/webextensions/blob/main/proposals/dark_mode_extension_icons.md WECG issue: w3c/webextensions#229 * Source/WTF/wtf/PlatformEnableCocoa.h: Added ENABLE_WK_WEB_EXTENSIONS_ICON_VARIANTS. * Source/WebCore/en.lproj/Localizable.strings: Updated. * Source/WebKit/Platform/cocoa/CocoaHelpers.h: * Source/WebKit/Platform/cocoa/CocoaHelpers.mm: (WebKit::availableScreenScales): Added. (WebKit::largestDisplayScale): Added. * Source/WebKit/Platform/spi/ios/UIKitSPI.h: * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionActionCocoa.mm: (WebKit::WebExtensionAction::icon): * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionCocoa.mm: (WebKit::WebExtension::icon): (WebKit::WebExtension::actionIcon): (WebKit::WebExtension::populateActionPropertiesIfNeeded): (WebKit::WebExtension::populateSidebarActionProperties): (WebKit::WebExtension::populateSidePanelProperties): (WebKit::WebExtension::imageForPath): (WebKit::WebExtension::bestSizeInIconsDictionary): Added. (WebKit::WebExtension::pathForBestImageInIconsDictionary): (WebKit::WebExtension::bestImageInIconsDictionary): (WebKit::WebExtension::bestImageForIconsDictionaryManifestKey): (WebKit::toColorSchemes): Added. (WebKit::WebExtension::iconsDictionaryForBestIconVariant): Added. (WebKit::WebExtension::bestImageForIconVariants): Added. (WebKit::WebExtension::bestImageForIconVariantsManifestKey): Added. * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionMenuItemCocoa.mm: (WebKit::WebExtensionMenuItem::icon const): * Source/WebKit/UIProcess/Extensions/WebExtension.h: * Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtension.mm: (TestWebKitAPI::TEST(WKWebExtension, MultipleIconVariants)): Added. (TestWebKitAPI::TEST(WKWebExtension, SingleIconVariant)): Added. (TestWebKitAPI::TEST(WKWebExtension, AnySizeIconVariant)): Added. (TestWebKitAPI::TEST(WKWebExtension, NoIconVariants)): Added. (TestWebKitAPI::TEST(WKWebExtension, IconsAndIconVariantsSpecified)): Added. (TestWebKitAPI::TEST(WKWebExtension, ActionIconVariantsMultiple)): Added. (TestWebKitAPI::TEST(WKWebExtension, ActionIconSingleVariant)): Added. (TestWebKitAPI::TEST(WKWebExtension, ActionIconAnySizeVariant)): Added. (TestWebKitAPI::TEST(WKWebExtension, ActionNoIconVariants)): Added. (TestWebKitAPI::TEST(WKWebExtension, ActionIconsAndIconVariantsSpecified)): Added. * Tools/TestWebKitAPI/cocoa/WebExtensionUtilities.h: * Tools/TestWebKitAPI/cocoa/WebExtensionUtilities.mm: (TestWebKitAPI::Util::performWithAppearance): Added. (TestWebKitAPI::Util::pixelColor): Added. (TestWebKitAPI::Util::toSRGBColor): Added. (TestWebKitAPI::Util::compareColors): Added.
https://webkit.org/b/278818 rdar://problem/134885372 Reviewed by NOBODY (OOPS!). Add support for `icon_variants` manifest parsing under the `WK_WEB_EXTENSIONS_ICON_VARIANTS` flag, with optimizations to ensure efficient icon loading. This change introduces `icon_variants` manifest parsing, explicitly supporting different icon sets, such as dark mode icons. To achieve this efficiently, icons are now cached by size, reducing disk I/O by avoiding repeated loads when the browser frequently requests the same icon. The cache is automatically invalidated when device scales change, such as when connecting or disconnecting a display with a different scale factor. Only the necessary icons are loaded based on the specific scale factor of all screens, halving the image loads compared to previous behavior. This ensures that even as more extensions adopt dark mode icons, typical image loads remain at two images (light and dark). Proposal: https://github.com/w3c/webextensions/blob/main/proposals/dark_mode_extension_icons.md WECG issue: w3c/webextensions#229 * Source/WTF/wtf/PlatformEnableCocoa.h: Added ENABLE_WK_WEB_EXTENSIONS_ICON_VARIANTS. * Source/WebCore/en.lproj/Localizable.strings: Updated. * Source/WebKit/Platform/cocoa/CocoaHelpers.h: * Source/WebKit/Platform/cocoa/CocoaHelpers.mm: (WebKit::availableScreenScales): Added. (WebKit::largestDisplayScale): Added. * Source/WebKit/Platform/spi/ios/UIKitSPI.h: * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionActionCocoa.mm: (WebKit::WebExtensionAction::icon): * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionCocoa.mm: (WebKit::WebExtension::icon): (WebKit::WebExtension::actionIcon): (WebKit::WebExtension::populateActionPropertiesIfNeeded): (WebKit::WebExtension::populateSidebarActionProperties): (WebKit::WebExtension::populateSidePanelProperties): (WebKit::WebExtension::imageForPath): (WebKit::WebExtension::bestSizeInIconsDictionary): Added. (WebKit::WebExtension::pathForBestImageInIconsDictionary): (WebKit::WebExtension::bestImageInIconsDictionary): (WebKit::WebExtension::bestImageForIconsDictionaryManifestKey): (WebKit::toColorSchemes): Added. (WebKit::WebExtension::iconsDictionaryForBestIconVariant): Added. (WebKit::WebExtension::bestImageForIconVariants): Added. (WebKit::WebExtension::bestImageForIconVariantsManifestKey): Added. * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionMenuItemCocoa.mm: (WebKit::WebExtensionMenuItem::icon const): * Source/WebKit/UIProcess/Extensions/WebExtension.h: * Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtension.mm: (TestWebKitAPI::TEST(WKWebExtension, MultipleIconVariants)): Added. (TestWebKitAPI::TEST(WKWebExtension, SingleIconVariant)): Added. (TestWebKitAPI::TEST(WKWebExtension, AnySizeIconVariant)): Added. (TestWebKitAPI::TEST(WKWebExtension, NoIconVariants)): Added. (TestWebKitAPI::TEST(WKWebExtension, IconsAndIconVariantsSpecified)): Added. (TestWebKitAPI::TEST(WKWebExtension, ActionIconVariantsMultiple)): Added. (TestWebKitAPI::TEST(WKWebExtension, ActionIconSingleVariant)): Added. (TestWebKitAPI::TEST(WKWebExtension, ActionIconAnySizeVariant)): Added. (TestWebKitAPI::TEST(WKWebExtension, ActionNoIconVariants)): Added. (TestWebKitAPI::TEST(WKWebExtension, ActionIconsAndIconVariantsSpecified)): Added. * Tools/TestWebKitAPI/cocoa/WebExtensionUtilities.h: * Tools/TestWebKitAPI/cocoa/WebExtensionUtilities.mm: (TestWebKitAPI::Util::performWithAppearance): Added. (TestWebKitAPI::Util::pixelColor): Added. (TestWebKitAPI::Util::toSRGBColor): Added. (TestWebKitAPI::Util::compareColors): Added.
https://webkit.org/b/278818 rdar://problem/134885372 Reviewed by NOBODY (OOPS!). Add support for `icon_variants` manifest parsing under the `WK_WEB_EXTENSIONS_ICON_VARIANTS` flag, with optimizations to ensure efficient icon loading. This change introduces `icon_variants` manifest parsing, explicitly supporting different icon sets, such as dark mode icons. To achieve this efficiently, icons are now cached by size, reducing disk I/O by avoiding repeated loads when the browser frequently requests the same icon. The cache is automatically invalidated when device scales change, such as when connecting or disconnecting a display with a different scale factor. Only the necessary icons are loaded based on the specific scale factor of all screens, halving the image loads compared to previous behavior. This ensures that even as more extensions adopt dark mode icons, typical image loads remain at two images (light and dark). Proposal: https://github.com/w3c/webextensions/blob/main/proposals/dark_mode_extension_icons.md WECG issue: w3c/webextensions#229 * Source/WTF/wtf/PlatformEnableCocoa.h: Added ENABLE_WK_WEB_EXTENSIONS_ICON_VARIANTS. * Source/WebCore/en.lproj/Localizable.strings: Updated. * Source/WebKit/Platform/cocoa/CocoaHelpers.h: * Source/WebKit/Platform/cocoa/CocoaHelpers.mm: (WebKit::availableScreenScales): Added. (WebKit::largestDisplayScale): Added. * Source/WebKit/Platform/spi/ios/UIKitSPI.h: * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionActionCocoa.mm: (WebKit::WebExtensionAction::icon): * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionCocoa.mm: (WebKit::WebExtension::icon): (WebKit::WebExtension::actionIcon): (WebKit::WebExtension::populateActionPropertiesIfNeeded): (WebKit::WebExtension::populateSidebarActionProperties): (WebKit::WebExtension::populateSidePanelProperties): (WebKit::WebExtension::imageForPath): (WebKit::WebExtension::bestSizeInIconsDictionary): Added. (WebKit::WebExtension::pathForBestImageInIconsDictionary): (WebKit::WebExtension::bestImageInIconsDictionary): (WebKit::WebExtension::bestImageForIconsDictionaryManifestKey): (WebKit::toColorSchemes): Added. (WebKit::WebExtension::iconsDictionaryForBestIconVariant): Added. (WebKit::WebExtension::bestImageForIconVariants): Added. (WebKit::WebExtension::bestImageForIconVariantsManifestKey): Added. * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionMenuItemCocoa.mm: (WebKit::WebExtensionMenuItem::icon const): * Source/WebKit/UIProcess/Extensions/WebExtension.h: * Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtension.mm: (TestWebKitAPI::TEST(WKWebExtension, MultipleIconVariants)): Added. (TestWebKitAPI::TEST(WKWebExtension, SingleIconVariant)): Added. (TestWebKitAPI::TEST(WKWebExtension, AnySizeIconVariant)): Added. (TestWebKitAPI::TEST(WKWebExtension, NoIconVariants)): Added. (TestWebKitAPI::TEST(WKWebExtension, IconsAndIconVariantsSpecified)): Added. (TestWebKitAPI::TEST(WKWebExtension, ActionIconVariantsMultiple)): Added. (TestWebKitAPI::TEST(WKWebExtension, ActionIconSingleVariant)): Added. (TestWebKitAPI::TEST(WKWebExtension, ActionIconAnySizeVariant)): Added. (TestWebKitAPI::TEST(WKWebExtension, ActionNoIconVariants)): Added. (TestWebKitAPI::TEST(WKWebExtension, ActionIconsAndIconVariantsSpecified)): Added. * Tools/TestWebKitAPI/cocoa/WebExtensionUtilities.h: * Tools/TestWebKitAPI/cocoa/WebExtensionUtilities.mm: (TestWebKitAPI::Util::performWithAppearance): Added. (TestWebKitAPI::Util::pixelColor): Added. (TestWebKitAPI::Util::toSRGBColor): Added. (TestWebKitAPI::Util::compareColors): Added.
https://webkit.org/b/278818 rdar://problem/134885372 Reviewed by Brian Weinstein. Add support for `icon_variants` manifest parsing under the `WK_WEB_EXTENSIONS_ICON_VARIANTS` flag, with optimizations to ensure efficient icon loading. This change introduces `icon_variants` manifest parsing, explicitly supporting different icon sets, such as dark mode icons. To achieve this efficiently, icons are now cached by size, reducing disk I/O by avoiding repeated loads when the browser frequently requests the same icon. The cache is automatically invalidated when device scales change, such as when connecting or disconnecting a display with a different scale factor. Only the necessary icons are loaded based on the specific scale factor of all screens, halving the image loads compared to previous behavior. This ensures that even as more extensions adopt dark mode icons, typical image loads remain at two images (light and dark). Proposal: https://github.com/w3c/webextensions/blob/main/proposals/dark_mode_extension_icons.md WECG issue: w3c/webextensions#229 * Source/WTF/wtf/PlatformEnableCocoa.h: Added ENABLE_WK_WEB_EXTENSIONS_ICON_VARIANTS. * Source/WebCore/en.lproj/Localizable.strings: Updated. * Source/WebKit/Platform/cocoa/CocoaHelpers.h: * Source/WebKit/Platform/cocoa/CocoaHelpers.mm: (WebKit::availableScreenScales): Added. (WebKit::largestDisplayScale): Added. * Source/WebKit/Platform/spi/ios/UIKitSPI.h: * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionActionCocoa.mm: (WebKit::WebExtensionAction::icon): * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionCocoa.mm: (WebKit::WebExtension::icon): (WebKit::WebExtension::actionIcon): (WebKit::WebExtension::populateActionPropertiesIfNeeded): (WebKit::WebExtension::populateSidebarActionProperties): (WebKit::WebExtension::populateSidePanelProperties): (WebKit::WebExtension::imageForPath): (WebKit::WebExtension::bestSizeInIconsDictionary): Added. (WebKit::WebExtension::pathForBestImageInIconsDictionary): (WebKit::WebExtension::bestImageInIconsDictionary): (WebKit::WebExtension::bestImageForIconsDictionaryManifestKey): (WebKit::toColorSchemes): Added. (WebKit::WebExtension::iconsDictionaryForBestIconVariant): Added. (WebKit::WebExtension::bestImageForIconVariants): Added. (WebKit::WebExtension::bestImageForIconVariantsManifestKey): Added. * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionMenuItemCocoa.mm: (WebKit::WebExtensionMenuItem::icon const): * Source/WebKit/UIProcess/Extensions/WebExtension.h: * Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtension.mm: (TestWebKitAPI::TEST(WKWebExtension, MultipleIconVariants)): Added. (TestWebKitAPI::TEST(WKWebExtension, SingleIconVariant)): Added. (TestWebKitAPI::TEST(WKWebExtension, AnySizeIconVariant)): Added. (TestWebKitAPI::TEST(WKWebExtension, NoIconVariants)): Added. (TestWebKitAPI::TEST(WKWebExtension, IconsAndIconVariantsSpecified)): Added. (TestWebKitAPI::TEST(WKWebExtension, ActionIconVariantsMultiple)): Added. (TestWebKitAPI::TEST(WKWebExtension, ActionIconSingleVariant)): Added. (TestWebKitAPI::TEST(WKWebExtension, ActionIconAnySizeVariant)): Added. (TestWebKitAPI::TEST(WKWebExtension, ActionNoIconVariants)): Added. (TestWebKitAPI::TEST(WKWebExtension, ActionIconsAndIconVariantsSpecified)): Added. * Tools/TestWebKitAPI/cocoa/WebExtensionUtilities.h: * Tools/TestWebKitAPI/cocoa/WebExtensionUtilities.mm: (TestWebKitAPI::Util::performWithAppearance): Added. (TestWebKitAPI::Util::pixelColor): Added. (TestWebKitAPI::Util::toSRGBColor): Added. (TestWebKitAPI::Util::compareColors): Added. Canonical link: https://commits.webkit.org/283118@main
…or Web Extensions. https://webkit.org/b/279135 rdar://problem/134885372 Reviewed by NOBODY (OOPS!). Add support for the `icons_variants` key in `menus.create()` and `menus.update()`. Also add support for `variants` key in `action.setIcon()`. Proposal: https://github.com/w3c/webextensions/blob/main/proposals/dark_mode_extension_icons.md WECG issue: w3c/webextensions#229 * Source/WebKit/Shared/Extensions/WebExtensionMenuItem.serialization.in: * Source/WebKit/Shared/Extensions/WebExtensionMenuItemParameters.h: * Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIActionCocoa.mm: (WebKit::WebExtensionContext::actionSetIcon): * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionActionCocoa.mm: (WebKit::WebExtensionAction::clearCustomizations): (WebKit::WebExtensionAction::icon): (WebKit::WebExtensionAction::setIcons): (WebKit::WebExtensionAction::setIconVariants): (WebKit::WebExtensionAction::clearIconCache): (WebKit::WebExtensionAction::setIconsDictionary): Deleted. * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionMenuItemCocoa.mm: (WebKit::WebExtensionMenuItem::WebExtensionMenuItem): (WebKit::WebExtensionMenuItem::minimalParameters const): (WebKit::WebExtensionMenuItem::update): (WebKit::WebExtensionMenuItem::icon const): (WebKit::WebExtensionMenuItem::clearIconCache const): * Source/WebKit/UIProcess/Extensions/WebExtensionAction.h: * Source/WebKit/UIProcess/Extensions/WebExtensionContext.h: * Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in: * Source/WebKit/UIProcess/Extensions/WebExtensionMenuItem.h: * Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIActionCocoa.mm: (WebKit::WebExtensionAPIAction::isValidDimensionKey): (WebKit::WebExtensionAPIAction::parseIconPath): (WebKit::WebExtensionAPIAction::parseIconPathsDictionary): (WebKit::WebExtensionAPIAction::parseIconImageDataDictionary): (WebKit::WebExtensionAPIAction::parseIconVariants): (WebKit::WebExtensionAPIAction::setIcon): * Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIMenusCocoa.mm: (WebKit::WebExtensionAPIMenus::parseCreateAndUpdateProperties): (WebKit::WebExtensionAPIMenus::createMenu): (WebKit::WebExtensionAPIMenus::update): * Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIAction.h: * Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIMenus.h: * Source/WebKit/WebProcess/Extensions/Bindings/Scripts/CodeGeneratorExtensions.pm: (_generateImplementationFile): * Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPIMenus.idl: * Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/xcshareddata/xcschemes/TestWebKitAPI.xcscheme: * Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIAction.mm: (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconWithDataURL)): Renamed. (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconWithVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconWithImageDataAndVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconThrowsWithNoValidVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconWithMixedValidAndInvalidVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconWithAnySizeVariantAndSVGDataURL)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconWithSVGDataURL)): Deleted. * Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIMenus.mm: (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, Errors)): Fixed expectations. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, MenuItemWithIconVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, MenuItemWithImageDataVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, MenuItemWithWithNoValidVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, MenuItemWithMixedValidAndInvalidIconVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, MenuItemWithAnySizeVariantAndSVGDataURL)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, UpdateMenuItemWithIconVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, ClearMenuItemIconVariantsWithNull)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, ClearMenuItemIconVariantsWithEmpty)): Added.
…or Web Extensions. https://webkit.org/b/279135 rdar://problem/134885372 Reviewed by NOBODY (OOPS!). Add support for the `icons_variants` key in `menus.create()` and `menus.update()`. Also add support for `variants` key in `action.setIcon()`. Proposal: https://github.com/w3c/webextensions/blob/main/proposals/dark_mode_extension_icons.md WECG issue: w3c/webextensions#229 * Source/WebKit/Shared/Extensions/WebExtensionMenuItem.serialization.in: * Source/WebKit/Shared/Extensions/WebExtensionMenuItemParameters.h: * Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIActionCocoa.mm: (WebKit::WebExtensionContext::actionSetIcon): * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionActionCocoa.mm: (WebKit::WebExtensionAction::clearCustomizations): (WebKit::WebExtensionAction::icon): (WebKit::WebExtensionAction::setIcons): (WebKit::WebExtensionAction::setIconVariants): (WebKit::WebExtensionAction::clearIconCache): (WebKit::WebExtensionAction::setIconsDictionary): Deleted. * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionMenuItemCocoa.mm: (WebKit::WebExtensionMenuItem::WebExtensionMenuItem): (WebKit::WebExtensionMenuItem::minimalParameters const): (WebKit::WebExtensionMenuItem::update): (WebKit::WebExtensionMenuItem::icon const): (WebKit::WebExtensionMenuItem::clearIconCache const): * Source/WebKit/UIProcess/Extensions/WebExtensionAction.h: * Source/WebKit/UIProcess/Extensions/WebExtensionContext.h: * Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in: * Source/WebKit/UIProcess/Extensions/WebExtensionMenuItem.h: * Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIActionCocoa.mm: (WebKit::WebExtensionAPIAction::isValidDimensionKey): (WebKit::WebExtensionAPIAction::parseIconPath): (WebKit::WebExtensionAPIAction::parseIconPathsDictionary): (WebKit::WebExtensionAPIAction::parseIconImageDataDictionary): (WebKit::WebExtensionAPIAction::parseIconVariants): (WebKit::WebExtensionAPIAction::setIcon): * Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIMenusCocoa.mm: (WebKit::WebExtensionAPIMenus::parseCreateAndUpdateProperties): (WebKit::WebExtensionAPIMenus::createMenu): (WebKit::WebExtensionAPIMenus::update): * Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIAction.h: * Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIMenus.h: * Source/WebKit/WebProcess/Extensions/Bindings/Scripts/CodeGeneratorExtensions.pm: (_generateImplementationFile): * Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPIMenus.idl: * Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIAction.mm: (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconWithDataURL)): Renamed. (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconWithVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconWithImageDataAndVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconThrowsWithNoValidVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconWithMixedValidAndInvalidVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconWithAnySizeVariantAndSVGDataURL)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconWithSVGDataURL)): Deleted. * Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIMenus.mm: (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, Errors)): Fixed expectations. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, MenuItemWithIconVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, MenuItemWithImageDataVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, MenuItemWithWithNoValidVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, MenuItemWithMixedValidAndInvalidIconVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, MenuItemWithAnySizeVariantAndSVGDataURL)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, UpdateMenuItemWithIconVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, ClearMenuItemIconVariantsWithNull)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, ClearMenuItemIconVariantsWithEmpty)): Added.
…or Web Extensions. https://webkit.org/b/279135 rdar://problem/134885372 Reviewed by NOBODY (OOPS!). Add support for the `icons_variants` key in `menus.create()` and `menus.update()`. Also add support for `variants` key in `action.setIcon()`. Proposal: https://github.com/w3c/webextensions/blob/main/proposals/dark_mode_extension_icons.md WECG issue: w3c/webextensions#229 * Source/WebKit/Shared/Extensions/WebExtensionMenuItem.serialization.in: * Source/WebKit/Shared/Extensions/WebExtensionMenuItemParameters.h: * Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIActionCocoa.mm: (WebKit::WebExtensionContext::actionSetIcon): * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionActionCocoa.mm: (WebKit::WebExtensionAction::clearCustomizations): (WebKit::WebExtensionAction::icon): (WebKit::WebExtensionAction::setIcons): (WebKit::WebExtensionAction::setIconVariants): (WebKit::WebExtensionAction::clearIconCache): (WebKit::WebExtensionAction::setIconsDictionary): Deleted. * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionMenuItemCocoa.mm: (WebKit::WebExtensionMenuItem::WebExtensionMenuItem): (WebKit::WebExtensionMenuItem::minimalParameters const): (WebKit::WebExtensionMenuItem::update): (WebKit::WebExtensionMenuItem::icon const): (WebKit::WebExtensionMenuItem::clearIconCache const): * Source/WebKit/UIProcess/Extensions/WebExtensionAction.h: * Source/WebKit/UIProcess/Extensions/WebExtensionContext.h: * Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in: * Source/WebKit/UIProcess/Extensions/WebExtensionMenuItem.h: * Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIActionCocoa.mm: (WebKit::WebExtensionAPIAction::isValidDimensionKey): (WebKit::WebExtensionAPIAction::parseIconPath): (WebKit::WebExtensionAPIAction::parseIconPathsDictionary): (WebKit::WebExtensionAPIAction::parseIconImageDataDictionary): (WebKit::WebExtensionAPIAction::parseIconVariants): (WebKit::WebExtensionAPIAction::setIcon): * Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIMenusCocoa.mm: (WebKit::WebExtensionAPIMenus::parseCreateAndUpdateProperties): (WebKit::WebExtensionAPIMenus::createMenu): (WebKit::WebExtensionAPIMenus::update): * Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIAction.h: * Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIMenus.h: * Source/WebKit/WebProcess/Extensions/Bindings/Scripts/CodeGeneratorExtensions.pm: (_generateImplementationFile): * Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPIMenus.idl: * Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIAction.mm: (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconWithDataURL)): Renamed. (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconWithVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconWithImageDataAndVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconThrowsWithNoValidVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconWithMixedValidAndInvalidVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconWithAnySizeVariantAndSVGDataURL)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconWithSVGDataURL)): Deleted. * Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIMenus.mm: (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, Errors)): Fixed expectations. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, MenuItemWithIconVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, MenuItemWithImageDataVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, MenuItemWithWithNoValidVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, MenuItemWithMixedValidAndInvalidIconVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, MenuItemWithAnySizeVariantAndSVGDataURL)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, UpdateMenuItemWithIconVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, ClearMenuItemIconVariantsWithNull)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, ClearMenuItemIconVariantsWithEmpty)): Added.
…or Web Extensions. https://webkit.org/b/279135 rdar://problem/134885372 Reviewed by NOBODY (OOPS!). Add support for the `icons_variants` key in `menus.create()` and `menus.update()`. Also add support for `variants` key in `action.setIcon()`. Proposal: https://github.com/w3c/webextensions/blob/main/proposals/dark_mode_extension_icons.md WECG issue: w3c/webextensions#229 * Source/WebKit/Shared/Extensions/WebExtensionMenuItem.serialization.in: * Source/WebKit/Shared/Extensions/WebExtensionMenuItemParameters.h: * Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIActionCocoa.mm: (WebKit::WebExtensionContext::actionSetIcon): * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionActionCocoa.mm: (WebKit::WebExtensionAction::clearCustomizations): (WebKit::WebExtensionAction::icon): (WebKit::WebExtensionAction::setIcons): (WebKit::WebExtensionAction::setIconVariants): (WebKit::WebExtensionAction::clearIconCache): (WebKit::WebExtensionAction::setIconsDictionary): Deleted. * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionMenuItemCocoa.mm: (WebKit::WebExtensionMenuItem::WebExtensionMenuItem): (WebKit::WebExtensionMenuItem::minimalParameters const): (WebKit::WebExtensionMenuItem::update): (WebKit::WebExtensionMenuItem::icon const): (WebKit::WebExtensionMenuItem::clearIconCache const): * Source/WebKit/UIProcess/Extensions/WebExtensionAction.h: * Source/WebKit/UIProcess/Extensions/WebExtensionContext.h: * Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in: * Source/WebKit/UIProcess/Extensions/WebExtensionMenuItem.h: * Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIActionCocoa.mm: (WebKit::WebExtensionAPIAction::isValidDimensionKey): (WebKit::WebExtensionAPIAction::parseIconPath): (WebKit::WebExtensionAPIAction::parseIconPathsDictionary): (WebKit::WebExtensionAPIAction::parseIconImageDataDictionary): (WebKit::WebExtensionAPIAction::parseIconVariants): (WebKit::WebExtensionAPIAction::setIcon): * Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIMenusCocoa.mm: (WebKit::WebExtensionAPIMenus::parseCreateAndUpdateProperties): (WebKit::WebExtensionAPIMenus::createMenu): (WebKit::WebExtensionAPIMenus::update): * Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIAction.h: * Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIMenus.h: * Source/WebKit/WebProcess/Extensions/Bindings/Scripts/CodeGeneratorExtensions.pm: (_generateImplementationFile): * Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPIMenus.idl: * Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIAction.mm: (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconWithDataURL)): Renamed. (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconWithVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconWithImageDataAndVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconThrowsWithNoValidVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconWithMixedValidAndInvalidVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconWithAnySizeVariantAndSVGDataURL)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconWithSVGDataURL)): Deleted. * Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIMenus.mm: (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, Errors)): Fixed expectations. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, MenuItemWithIconVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, MenuItemWithImageDataVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, MenuItemWithWithNoValidVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, MenuItemWithMixedValidAndInvalidIconVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, MenuItemWithAnySizeVariantAndSVGDataURL)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, UpdateMenuItemWithIconVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, ClearMenuItemIconVariantsWithNull)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, ClearMenuItemIconVariantsWithEmpty)): Added.
…or Web Extensions. https://webkit.org/b/279135 rdar://problem/134885372 Reviewed by Brian Weinstein. Add support for the `icons_variants` key in `menus.create()` and `menus.update()`. Also add support for `variants` key in `action.setIcon()`. Proposal: https://github.com/w3c/webextensions/blob/main/proposals/dark_mode_extension_icons.md WECG issue: w3c/webextensions#229 * Source/WebKit/Shared/Extensions/WebExtensionMenuItem.serialization.in: * Source/WebKit/Shared/Extensions/WebExtensionMenuItemParameters.h: * Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIActionCocoa.mm: (WebKit::WebExtensionContext::actionSetIcon): * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionActionCocoa.mm: (WebKit::WebExtensionAction::clearCustomizations): (WebKit::WebExtensionAction::icon): (WebKit::WebExtensionAction::setIcons): (WebKit::WebExtensionAction::setIconVariants): (WebKit::WebExtensionAction::clearIconCache): (WebKit::WebExtensionAction::setIconsDictionary): Deleted. * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionMenuItemCocoa.mm: (WebKit::WebExtensionMenuItem::WebExtensionMenuItem): (WebKit::WebExtensionMenuItem::minimalParameters const): (WebKit::WebExtensionMenuItem::update): (WebKit::WebExtensionMenuItem::icon const): (WebKit::WebExtensionMenuItem::clearIconCache const): * Source/WebKit/UIProcess/Extensions/WebExtensionAction.h: * Source/WebKit/UIProcess/Extensions/WebExtensionContext.h: * Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in: * Source/WebKit/UIProcess/Extensions/WebExtensionMenuItem.h: * Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIActionCocoa.mm: (WebKit::WebExtensionAPIAction::isValidDimensionKey): (WebKit::WebExtensionAPIAction::parseIconPath): (WebKit::WebExtensionAPIAction::parseIconPathsDictionary): (WebKit::WebExtensionAPIAction::parseIconImageDataDictionary): (WebKit::WebExtensionAPIAction::parseIconVariants): (WebKit::WebExtensionAPIAction::setIcon): * Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIMenusCocoa.mm: (WebKit::WebExtensionAPIMenus::parseCreateAndUpdateProperties): (WebKit::WebExtensionAPIMenus::createMenu): (WebKit::WebExtensionAPIMenus::update): * Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIAction.h: * Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIMenus.h: * Source/WebKit/WebProcess/Extensions/Bindings/Scripts/CodeGeneratorExtensions.pm: (_generateImplementationFile): * Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPIMenus.idl: * Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIAction.mm: (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconWithDataURL)): Renamed. (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconWithVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconWithImageDataAndVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconThrowsWithNoValidVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconWithMixedValidAndInvalidVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconWithAnySizeVariantAndSVGDataURL)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIAction, SetIconWithSVGDataURL)): Deleted. * Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIMenus.mm: (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, Errors)): Fixed expectations. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, MenuItemWithIconVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, MenuItemWithImageDataVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, MenuItemWithWithNoValidVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, MenuItemWithMixedValidAndInvalidIconVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, MenuItemWithAnySizeVariantAndSVGDataURL)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, UpdateMenuItemWithIconVariants)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, ClearMenuItemIconVariantsWithNull)): Added. (TestWebKitAPI::TEST(WKWebExtensionAPIMenus, ClearMenuItemIconVariantsWithEmpty)): Added. Canonical link: https://commits.webkit.org/283219@main
A little related to issue-216. Besides the text color and background color of the BadgeText, the extension icon itself is also a problem to adapt to various themes (Light/Dark/Custom).
Current state, developers can set static extension icon or dynamic change it by
setIcon()
. But:The text was updated successfully, but these errors were encountered: