Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Web Inspector: Color picker should allow picking a color from any pix…
…el on screen https://bugs.webkit.org/show_bug.cgi?id=124357 rdar://15469621 Reviewed by Devin Rousso. Add the long-missing "eyedropper" for picking a color from the screen to the Color Picker in Web Inspector. This implementation supports both sRGB color space as well as Display P3 (the two colorspaces currently supported by the Web Inspector frontend). The existing value format and gamut is preserved as best as possible while not clamping the color (unless interacting with a color swatch/picker that does not allow changing the format). For example, on macOS the color picker will return a Display-P3 color on supported displays, but the color itself may be representable in sRGB. If the existing color you are overwriting is already in sRGB, that is preserved by converting the system's Display-P3 color into sRGB. If the sampled color can not be represented in sRGB, we update the CSS value to support the new wider gamut of the selected color in order to provide the best fidelity in color matching. The picker is implemented in two places. The first is the Color Picker popovers used in Web Inspector. The second place is as an Option-Click action for inline swatches to allow you to quickly begin color selection without opening the picker itself. * Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js: * Source/WebInspectorUI/UserInterface/Images/Pipette.svg: Added. * Source/WebInspectorUI/UserInterface/Models/Color.js: (WI.Color.prototype.fromStringBestMatchingSuggestedFormatAndGamut): - New convencience "constructor" for creating a color from a String while attempting (or forcing) preservation of an existing format and gamut. * Source/WebInspectorUI/UserInterface/Views/ColorPicker.css: (.color-picker > .color-inputs-wrapper): (.color-picker > .color-inputs-wrapper > .color-inputs): (.color-picker > .color-inputs-wrapper > .color-inputs > div): (.color-picker > .color-inputs-wrapper > .color-inputs > div + div): (.color-picker > .color-inputs-wrapper > .color-inputs input): (.color-picker > .color-inputs-wrapper > .pick-color-from-screen): (.color-picker > .color-inputs-wrapper > .pick-color-from-screen.active): (.color-picker > .color-inputs): Deleted. (.color-picker > .color-inputs > div): Deleted. (.color-picker > .color-inputs > div + div): Deleted. (.color-picker > .color-inputs input): Deleted. * Source/WebInspectorUI/UserInterface/Views/ColorPicker.js: (WI.ColorPicker.async pickColorFromScreen): - Add new static method to picking a color from the screen (so that InlineSwatch can use it), and add a new Pipette icon to begin the modal color picking mode. * Source/WebInspectorUI/UserInterface/Views/InlineSwatch.js: (WI.InlineSwatch.prototype._updateSwatch): - Add Option-Click for color swatches to immediately enter the modal color picking mode. * Source/WebCore/inspector/InspectorFrontendClient.h: * Source/WebCore/inspector/InspectorFrontendClientLocal.h: * Source/WebCore/inspector/InspectorFrontendHost.cpp: (WebCore::InspectorFrontendHost::canPickColorFromScreen): (WebCore::InspectorFrontendHost::pickColorFromScreen): * Source/WebCore/inspector/InspectorFrontendHost.h: * Source/WebCore/inspector/InspectorFrontendHost.idl: * Source/WebKit/UIProcess/Inspector/RemoteWebInspectorUIProxy.cpp: (WebKit::RemoteWebInspectorUIProxy::pickColorFromScreen): (WebKit::RemoteWebInspectorUIProxy::platformPickColorFromScreen): * Source/WebKit/UIProcess/Inspector/RemoteWebInspectorUIProxy.h: * Source/WebKit/UIProcess/Inspector/RemoteWebInspectorUIProxy.messages.in: * Source/WebKit/UIProcess/Inspector/WebInspectorUIProxy.cpp: (WebKit::WebInspectorUIProxy::pickColorFromScreen): (WebKit::WebInspectorUIProxy::platformPickColorFromScreen): * Source/WebKit/UIProcess/Inspector/WebInspectorUIProxy.h: * Source/WebKit/UIProcess/Inspector/WebInspectorUIProxy.messages.in: * Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.cpp: (WebKit::RemoteWebInspectorUI::pickColorFromScreen): * Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.h: * Source/WebKit/WebProcess/Inspector/WebInspectorUI.cpp: (WebKit::WebInspectorUI::pickColorFromScreen): (WebKit::WebInspectorUI::canPickColorFromScreen): * Source/WebKit/WebProcess/Inspector/WebInspectorUI.h: - Add plubming for picking a color from the screen. * Source/WebKit/UIProcess/Inspector/mac/RemoteWebInspectorUIProxyMac.mm: (WebKit::RemoteWebInspectorUIProxy::platformPickColorFromScreen): * Source/WebKit/UIProcess/Inspector/mac/WebInspectorUIProxyMac.mm: (WebKit::WebInspectorUIProxy::platformPickColorFromScreen): - Use NSColorSampler to get the system "pick a color from the screen" UI. * Source/WebKit/UIProcess/Inspector/gtk/RemoteWebInspectorUIProxyGtk.cpp: (WebKit::RemoteWebInspectorUIProxy::platformPickColorFromScreen): * Source/WebKit/UIProcess/Inspector/gtk/WebInspectorUIProxyGtk.cpp: (WebKit::WebInspectorUIProxy::platformPickColorFromScreen): * Source/WebKit/UIProcess/Inspector/win/RemoteWebInspectorUIProxyWin.cpp: (WebKit::RemoteWebInspectorUIProxy::platformPickColorFromScreen): * Source/WebKit/UIProcess/Inspector/win/WebInspectorUIProxyWin.cpp: (WebKit::WebInspectorUIProxy::platformPickColorFromScreen): * Source/WebKit/WebProcess/Inspector/gtk/WebInspectorUIGtk.cpp: (WebKit::WebInspectorUI::canPickColorFromScreen): * Source/WebKit/WebProcess/Inspector/mac/WebInspectorUIMac.mm: (WebKit::WebInspectorUI::canPickColorFromScreen): * Source/WebKit/WebProcess/Inspector/win/WebInspectorUIWin.cpp: (WebKit::WebInspectorUI::canPickColorFromScreen): - Add stubs for Windows/GTK implementations. Canonical link: https://commits.webkit.org/251236@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@295147 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
30 changed files
with
352 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.