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

Add support for icon_variants and variants in menus and action APIs for Web Extensions. #33130

Merged
merged 1 commit into from
Sep 5, 2024

Conversation

xeenon
Copy link
Contributor

@xeenon xeenon commented Sep 4, 2024

ad1823e

Add support for icon_variants and variants in menus and action APIs for 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

95477d9

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style 🛠 ios 🛠 mac 🛠 wpe ✅ 🛠 wincairo
✅ 🧪 bindings 🛠 ios-sim 🛠 mac-AS-debug 🧪 wpe-wk2 🧪 wincairo-tests
✅ 🧪 webkitperl 🧪 ios-wk2 🧪 api-mac 🧪 api-wpe
🧪 ios-wk2-wpt 🧪 mac-wk1 ✅ 🛠 wpe-cairo
🧪 api-ios 🧪 mac-wk2 🛠 gtk
🛠 vision 🧪 mac-AS-debug-wk2 🧪 gtk-wk2
🛠 vision-sim 🧪 mac-wk2-stress 🧪 api-gtk
⏳ 🧪 vision-wk2 🧪 mac-intel-wk2
✅ 🛠 🧪 unsafe-merge 🛠 tv
🛠 tv-sim
🛠 watch
🛠 watch-sim

@xeenon xeenon self-assigned this Sep 4, 2024
@xeenon xeenon added the WebKit Extensions Bugs related to extension support. label Sep 4, 2024
@xeenon xeenon added the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Sep 5, 2024
…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
@webkit-commit-queue
Copy link
Collaborator

Committed 283219@main (ad1823e): https://commits.webkit.org/283219@main

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

@webkit-commit-queue webkit-commit-queue merged commit ad1823e into WebKit:main Sep 5, 2024
@webkit-commit-queue webkit-commit-queue removed the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Sep 5, 2024
@xeenon xeenon deleted the bug/279135 branch September 10, 2024 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebKit Extensions Bugs related to extension support.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants