This document describes an API providing access to a browser supplied eyedropper.
Currently on the web, creative application developers are unable to implement an eyedropper, a tool that allows users to select a color from the pixels on their screen, including the pixels rendered outside of the web page requesting the color data.
This API enables authors to use a browser supplied eyedropper in the construction of custom color pickers.
dictionary ColorSelectionResult { DOMString sRGBHex; };
dictionary ColorSelectionOptions { AbortSignal signal; };
[Exposed=Window, SecureContext] interface EyeDropper { constructor(); Promise<ColorSelectionResult> open(optional ColorSelectionOptions options = {}); };
To {{EyeDropper/open}} an eyedropper, the user agent MUST present a user interface that follows these rules:
Exposing endpoints allowing developers to access unrestricted pixel data from a user's machine presents security challenges. In particular any eyedropper implementation should not allow a web page to "screen scrape" information the user didn't intend to share with the web application, for example, while the user moves the mouse around the screen.
One way to mitigate this threat is to require that pixel data only be made available to the web application when the user takes some explicit action like pressing a mouse button.
Additionally, browsers should provide a clear indication as to when the user has been transitioned into an eyedropper mode, for example by changing the cursor, and provide the means for the user to exit that mode, for example, by pressing an ESC key and not allowing the behavior to be cancelled by the author.
Before allowing a user to select a color, browsers should ensure that the user had a chance to see the UI. This could be accomplished by enforcing a minimum time interval between opening the eyedropper and allowing color selection.
The transition into eyedropper mode should require consumable user activation, for example, clicking on a button from the web page, to help avoid unintentionally revealing pixel data.