-
Notifications
You must be signed in to change notification settings - Fork 37
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 Web Custom format #175
Conversation
@annevk @mbrodesser This PR has the web prefix changes. PTAL. Thanks! |
This patch addresses the changes proposed by the EditingWG[1] and agreed upon by all browser vendors. We are removing the `unsanitized` option, and instead, adding custom format support for MIME types that have "web " prefix in them. Added few wpt tests to test these changes. Below is a summary of the changes in this CL: 1. Removed `unsanitized` option from read/write methods. 2. If the custom format doesn't have a "web " prefix, then clipboard read/write fails. 3. Transient user activation is applicable to all supported formats - text/html, text/plain, image/png and web custom formats. 4. There are two "buckets" of clipboard formats. One for the well-known formats and the other for the web custom format. If the author doesn't specify the web format explicitly, then they don't get access to it. This means, we won't write web custom formats for well-known types implicitly if authors have not indicated that during the write call via a "web " prefix (e.g. "web text/html"). Same applies for reading web custom formats for well-known types- if there aren't any formats in the web custom format map, then we won't return any web custom formats i.e. text/html won't be automatically converted into "web text/html". Spec: w3c/clipboard-apis#175 Explainer: https://github.com/w3c/editing/blob/gh-pages/docs/clipboard-pickling/explainer.md i2p: https://groups.google.com/a/chromium.org/g/blink-dev/c/Lo7WBM_v_LY/m/LncCKkXeAwAJ 1. Github issue: w3c/clipboard-apis#165 Bug: 106449 Change-Id: I86aae6a662089efeede2a01ac87cb698e9646df5
This patch addresses the changes proposed by the EditingWG[1] and agreed upon by all browser vendors. We are removing the `unsanitized` option, and instead, adding custom format support for MIME types that have "web " prefix in them. Added few wpt tests to test these changes. Below is a summary of the changes in this CL: 1. Removed `unsanitized` option from read/write methods. 2. If the custom format doesn't have a "web " prefix, then clipboard read/write fails. 3. Transient user activation is applicable to all supported formats - text/html, text/plain, image/png and web custom formats. 4. There are two "buckets" of clipboard formats. One for the well-known formats and the other for the web custom format. If the author doesn't specify the web format explicitly, then they don't get access to it. This means, we won't write web custom formats for well-known types implicitly if authors have not indicated that during the write call via a "web " prefix (e.g. "web text/html"). Same applies for reading web custom formats for well-known types- if there aren't any formats in the web custom format map, then we won't return any web custom formats i.e. text/html won't be automatically converted into "web text/html". Spec: w3c/clipboard-apis#175 Explainer: https://github.com/w3c/editing/blob/gh-pages/docs/clipboard-pickling/explainer.md i2p: https://groups.google.com/a/chromium.org/g/blink-dev/c/Lo7WBM_v_LY/m/LncCKkXeAwAJ 1. Github issue: w3c/clipboard-apis#165 Bug: 106449 Change-Id: I86aae6a662089efeede2a01ac87cb698e9646df5
This patch addresses the changes proposed by the EditingWG[1] and agreed upon by all browser vendors. We are removing the `unsanitized` option, and instead, adding custom format support for MIME types that have "web " prefix in them. Added few wpt tests to test these changes. Below is a summary of the changes in this CL: 1. Removed `unsanitized` option from read/write methods. 2. If the custom format doesn't have a "web " prefix, then clipboard read/write fails. 3. Transient user activation is applicable to all supported formats - text/html, text/plain, image/png and web custom formats. 4. There are two "buckets" of clipboard formats. One for the well-known formats and the other for the web custom format. If the author doesn't specify the web format explicitly, then they don't get access to it. This means, we won't write web custom formats for well-known types implicitly if authors have not indicated that during the write call via a "web " prefix (e.g. "web text/html"). Same applies for reading web custom formats for well-known types- if there aren't any formats in the web custom format map, then we won't return any web custom formats i.e. text/html won't be automatically converted into "web text/html". Spec: w3c/clipboard-apis#175 Explainer: https://github.com/w3c/editing/blob/gh-pages/docs/clipboard-pickling/explainer.md i2p: https://groups.google.com/a/chromium.org/g/blink-dev/c/Lo7WBM_v_LY/m/LncCKkXeAwAJ 1. Github issue: w3c/clipboard-apis#165 Bug: 106449 Change-Id: I86aae6a662089efeede2a01ac87cb698e9646df5
This patch addresses the changes proposed by the EditingWG[1] and agreed upon by all browser vendors. We are removing the `unsanitized` option, and instead, adding custom format support for MIME types that have "web " prefix in them. Added few wpt tests to test these changes. Below is a summary of the changes in this CL: 1. Removed `unsanitized` option from read/write methods. 2. If the custom format doesn't have a "web " prefix, then clipboard read/write fails. 3. Transient user activation is applicable to all supported formats - text/html, text/plain, image/png and web custom formats. 4. There are two "buckets" of clipboard formats. One for the well-known formats and the other for the web custom format. If the author doesn't specify the web format explicitly, then they don't get access to it. This means, we won't write web custom formats for well-known types implicitly if authors have not indicated that during the write call via a "web " prefix (e.g. "web text/html"). Same applies for reading web custom formats for well-known types- if there aren't any formats in the web custom format map, then we won't return any web custom formats i.e. text/html won't be automatically converted into "web text/html". Spec: w3c/clipboard-apis#175 Explainer: https://github.com/w3c/editing/blob/gh-pages/docs/clipboard-pickling/explainer.md i2p: https://groups.google.com/a/chromium.org/g/blink-dev/c/Lo7WBM_v_LY/m/LncCKkXeAwAJ 1. Github issue: w3c/clipboard-apis#165 Bug: 106449 Change-Id: I86aae6a662089efeede2a01ac87cb698e9646df5
This patch addresses the changes proposed by the EditingWG[1] and agreed upon by all browser vendors. We are removing the `unsanitized` option, and instead, adding custom format support for MIME types that have "web " prefix in them. Added few wpt tests to test these changes. Below is a summary of the changes in this CL: 1. Removed `unsanitized` option from read/write methods. 2. If the custom format doesn't have a "web " prefix, then clipboard read/write fails. 3. Transient user activation is applicable to all supported formats - text/html, text/plain, image/png and web custom formats. 4. There are two "buckets" of clipboard formats. One for the well-known formats and the other for the web custom format. If the author doesn't specify the web format explicitly, then they don't get access to it. This means, we won't write web custom formats for well-known types implicitly if authors have not indicated that during the write call via a "web " prefix (e.g. "web text/html"). Same applies for reading web custom formats for well-known types- if there aren't any formats in the web custom format map, then we won't return any web custom formats i.e. text/html won't be automatically converted into "web text/html". Spec: w3c/clipboard-apis#175 Explainer: https://github.com/w3c/editing/blob/gh-pages/docs/clipboard-pickling/explainer.md i2p: https://groups.google.com/a/chromium.org/g/blink-dev/c/Lo7WBM_v_LY/m/LncCKkXeAwAJ 1. Github issue: w3c/clipboard-apis#165 Bug: 106449 Change-Id: I86aae6a662089efeede2a01ac87cb698e9646df5
3780878
to
897ad31
Compare
Upon doing code inspection in Gecko we found that the legacy clipboard API might have some support for custom types as well. @EdgarChen is investigating this. We don't really want to end up with a situation where we have two incompatible custom types APIs. It might be that other browsers have something similar as there were at least some hints of cross-browser collaboration? |
@annevk Chromium and Safari have browser specific custom type that is undocumented and doesn't interop with other apps. The format parsing rules are convoluted since it uses browser specific pickling types for serialization/deserialization. This proposal aims to standardize the web custom formats and the format structure so its well documented and is interop across apps on a platform. This doesn't affect the existing pickling types. In Firefox, I see that it allows writing custom types in setData, but I don't see any restriction on the number of custom types that can be registered. This is a major security issue on Windows and Linux because of the restriction on the number of clipboard formats that can be registered with the OS. This proposal addresses this issue by introducing a fixed set of web custom formats and a map that maps the mime types to native web custom formats. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes! I think if you address these comments I'll be ready to approve for a merge.
index.bs
Outdated
<h3 id="to-read-unsanitized-format"><dfn>read unsanitized format</dfn></h3> | ||
|
||
: Input | ||
:: |mimeType|, a string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why don't you call this |customFormatKey| and include the parse a mime-type steps in this algorithm to transform that into a "web " prefixed and parsed name that can be used to construct the clipboard item. the name you construct should probably be an output parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, to make it clear what's an acceptable key, when parsing a mime-type, you actually use the ParseMimeTypeWithoutParameter function in Chromium, so can you clarify in the steps that you take the type and sub-type and concatenate those outputs from the parse a mime-type algorithm with '/', but throw away the parameters?
https://chromium-review.googlesource.com/c/chromium/src/+/3650952
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lastly, the parse a mime type can fail (by returning failure per the spec) so can you clarify that if failure is returned what you will do? I believe this function should also return failure and then you simply don't append anything to the collection of data used to construct the clipboarditems that will be given to the author.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be a bit more resilient to the parsing mime type errors, I added steps to ignore the mime types that returned failure during parsing.
index.bs
Outdated
@@ -786,7 +786,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn; | |||
|
|||
1. Abort these steps. | |||
|
|||
1. Let |data| be a copy of the [=system clipboard data=] represented as [=clipboard items=]. For the MIME types defined in the [=mandatory data types=] list, |data| MAY be sanitized, but image/png format has unsanitized payload to preserve meta data. | |||
1. Let |data| be a copy of the [=system clipboard data=] represented as [=clipboard items=]. For the MIME types defined in the [=mandatory data types=] list, |data| MAY be sanitized, but image/png format has unsanitized payload to preserve meta data. For the [=/MIME type=]s that have a "web "("web" followed by U+0020 SPACE) prefix, [=read unsanitized format=] from the [=system clipboard=] and append the content of the format to |data|. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This step is getting a bit long and does a lot. Also, it sounds like if data is a copy of the system clipboard data that there will be more than just the mandatory mime-types and web custom formats in data.
I believe we want a loop over the mandatory data types where we insert each into a data object that will be used to construct a single clipboarditem with multiple representations corresponding to each of those types.
Additionally, we want a step here to first read the JSON from the Web Custom Format Map, and then we can loop over its keys too. For each key we can obtain the name of the format corresponding to that mime-type on the system clipboard, read it, and then add its blob to data using a new key that is the result of running the key we got from the JSON through the parse a mime-type algorithm with "web " prepended.
Most of that can happen in the read helper function you have defined. Consider returning the "web " prefixed and parsed name from that method in addition to the blob itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two additional nits:
- Be sure to include MAY be sanitized as a step as you iterate over the mandatory data types to preserve what you added in your previous PR.
- Instead of looping over mandatory data types, you can loop over a set of data types supported by the user agent as a well-known format, which must at least include the mandatory data types listed in this spec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added these additional steps.
index.bs
Outdated
|
||
1. If |idx| is greater than 100, then break from this loop. | ||
|
||
1. Insert the |webCustomFormatMap| into the [=system clipboard=]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should say something like insert the JSON serialized representation of |webCustomFormatMap| into the clipboard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a step above to insert the mime type as key and |webCustomFormatIdx| as value into the |webCustomFormatMapString| using a JSON serializer.
index.bs
Outdated
|
||
1. Let |webCustomFormatIdx| be the result of appending |idx| to |webCustomFormat|. | ||
|
||
1. Insert |mimeType| as key and |webCustomFormatIdx| as value into the |webCustomFormatMap|. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before inserting mimeType, you should be stripping the "web " prefix. I think the what follows the space is guaranteed to be a parsed as a mime-type value per the steps in the construction of the clipboarditem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we didn't update the ClipboardItem constuctor. We have a step in there that runs the parse a mime-type algorithm, but it needs to test and allow for "web " prefixes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Do we care about the interop across legacy clipboard API and async clipboard API for custom type? E.g. write custom type via legacy clipboard API and read via async clipboard API, or vice versa. |
@EdgarChen The async clipboard API model is fairly different, so I'm not sure if we can interop with legacy types. The web custom types are stored inside a JSON map structure, with fixed number of native web clipboard formats, and a well-defined format structure that helps the native apps parse the content of the format. At least in Chromium, the parsing of the custom types requires browser specific pickle types to serialize and deserialize the content, so it's not possible to add support for this format to the new web custom format. |
This patch addresses the changes proposed by the EditingWG[1] and agreed upon by all browser vendors. We are removing the `unsanitized` option, and instead, adding custom format support for MIME types that have "web " prefix in them. Added few wpt tests to test these changes. Below is a summary of the changes in this CL: 1. Removed `unsanitized` option from read/write methods. 2. If the custom format doesn't have a "web " prefix, then clipboard read/write fails. 3. Transient user activation is applicable to all supported formats - text/html, text/plain, image/png and web custom formats. 4. There are two "buckets" of clipboard formats. One for the well-known formats and the other for the web custom format. If the author doesn't specify the web format explicitly, then they don't get access to it. This means, we won't write web custom formats for well-known types implicitly if authors have not indicated that during the write call via a "web " prefix (e.g. "web text/html"). Same applies for reading web custom formats for well-known types- if there aren't any formats in the web custom format map, then we won't return any web custom formats i.e. text/html won't be automatically converted into "web text/html". Spec: w3c/clipboard-apis#175 Explainer: https://github.com/w3c/editing/blob/gh-pages/docs/clipboard-pickling/explainer.md i2p: https://groups.google.com/a/chromium.org/g/blink-dev/c/Lo7WBM_v_LY/m/LncCKkXeAwAJ i2s: https://groups.google.com/a/chromium.org/g/blink-dev/c/k2rgX-4Cigc/m/P0RijrpzBAAJ?utm_medium=email&utm_source=footer&pli=1 1. Github issue: w3c/clipboard-apis#165 Bug: 106449 Change-Id: I86aae6a662089efeede2a01ac87cb698e9646df5
This patch addresses the changes proposed by the EditingWG[1] and agreed upon by all browser vendors. We are removing the `unsanitized` option, and instead, adding custom format support for MIME types that have "web " prefix in them. Added few wpt tests to test these changes. Below is a summary of the changes in this CL: 1. Removed `unsanitized` option from read/write methods. 2. If the custom format doesn't have a "web " prefix, then clipboard read/write fails. 3. Transient user activation is applicable to all supported formats - text/html, text/plain, image/png and web custom formats. 4. There are two "buckets" of clipboard formats. One for the well-known formats and the other for the web custom format. If the author doesn't specify the web format explicitly, then they don't get access to it. This means, we won't write web custom formats for well-known types implicitly if authors have not indicated that during the write call via a "web " prefix (e.g. "web text/html"). Same applies for reading web custom formats for well-known types- if there aren't any formats in the web custom format map, then we won't return any web custom formats i.e. text/html won't be automatically converted into "web text/html". Spec: w3c/clipboard-apis#175 Explainer: https://github.com/w3c/editing/blob/gh-pages/docs/clipboard-pickling/explainer.md i2p: https://groups.google.com/a/chromium.org/g/blink-dev/c/Lo7WBM_v_LY/m/LncCKkXeAwAJ i2s: https://groups.google.com/a/chromium.org/g/blink-dev/c/k2rgX-4Cigc/m/P0RijrpzBAAJ?utm_medium=email&utm_source=footer&pli=1 1. Github issue: w3c/clipboard-apis#165 Bug: 106449 Change-Id: I86aae6a662089efeede2a01ac87cb698e9646df5
This patch addresses the changes proposed by the EditingWG[1] and agreed upon by all browser vendors. We are removing the `unsanitized` option, and instead, adding custom format support for MIME types that have "web " prefix in them. Added few wpt tests to test these changes. Below is a summary of the changes in this CL: 1. Removed `unsanitized` option from read/write methods. 2. If the custom format doesn't have a "web " prefix, then clipboard read/write fails. 3. Transient user activation is applicable to all supported formats - text/html, text/plain, image/png and web custom formats. 4. There are two "buckets" of clipboard formats. One for the well-known formats and the other for the web custom format. If the author doesn't specify the web format explicitly, then they don't get access to it. This means, we won't write web custom formats for well-known types implicitly if authors have not indicated that during the write call via a "web " prefix (e.g. "web text/html"). Same applies for reading web custom formats for well-known types- if there aren't any formats in the web custom format map, then we won't return any web custom formats i.e. text/html won't be automatically converted into "web text/html". Spec: w3c/clipboard-apis#175 Explainer: https://github.com/w3c/editing/blob/gh-pages/docs/clipboard-pickling/explainer.md i2p: https://groups.google.com/a/chromium.org/g/blink-dev/c/Lo7WBM_v_LY/m/LncCKkXeAwAJ i2s: https://groups.google.com/a/chromium.org/g/blink-dev/c/k2rgX-4Cigc/m/P0RijrpzBAAJ?utm_medium=email&utm_source=footer&pli=1 1. Github issue: w3c/clipboard-apis#165 Bug: 106449 Change-Id: I86aae6a662089efeede2a01ac87cb698e9646df5
This patch addresses the changes proposed by the EditingWG[1] and agreed upon by all browser vendors. We are removing the `unsanitized` option, and instead, adding custom format support for MIME types that have "web " prefix in them. Added few wpt tests to test these changes. Below is a summary of the changes in this CL: 1. Removed `unsanitized` option from read/write methods. 2. If the custom format doesn't have a "web " prefix, then clipboard read/write fails. 3. Transient user activation is applicable to all supported formats - text/html, text/plain, image/png and web custom formats. 4. There are two "buckets" of clipboard formats. One for the well-known formats and the other for the web custom format. If the author doesn't specify the web format explicitly, then they don't get access to it. This means, we won't write web custom formats for well-known types implicitly if authors have not indicated that during the write call via a "web " prefix (e.g. "web text/html"). Same applies for reading web custom formats for well-known types- if there aren't any formats in the web custom format map, then we won't return any web custom formats i.e. text/html won't be automatically converted into "web text/html". Spec: w3c/clipboard-apis#175 Explainer: https://github.com/w3c/editing/blob/gh-pages/docs/clipboard-pickling/explainer.md i2p: https://groups.google.com/a/chromium.org/g/blink-dev/c/Lo7WBM_v_LY/m/LncCKkXeAwAJ i2s: https://groups.google.com/a/chromium.org/g/blink-dev/c/k2rgX-4Cigc/m/P0RijrpzBAAJ?utm_medium=email&utm_source=footer&pli=1 1. Github issue: w3c/clipboard-apis#165 Bug: 106449 Change-Id: I86aae6a662089efeede2a01ac87cb698e9646df5
This patch addresses the changes proposed by the EditingWG[1] and agreed upon by all browser vendors. We are removing the `unsanitized` option, and instead, adding custom format support for MIME types that have "web " prefix in them. Added few wpt tests to test these changes. Below is a summary of the changes in this CL: 1. Removed `unsanitized` option from read/write methods. 2. If the custom format doesn't have a "web " prefix, then clipboard read/write fails. 3. Transient user activation is applicable to all supported formats - text/html, text/plain, image/png and web custom formats. 4. There are two "buckets" of clipboard formats. One for the well-known formats and the other for the web custom format. If the author doesn't specify the web format explicitly, then they don't get access to it. This means, we won't write web custom formats for well-known types implicitly if authors have not indicated that during the write call via a "web " prefix (e.g. "web text/html"). Same applies for reading web custom formats for well-known types- if there aren't any formats in the web custom format map, then we won't return any web custom formats i.e. text/html won't be automatically converted into "web text/html". Spec: w3c/clipboard-apis#175 Explainer: https://github.com/w3c/editing/blob/gh-pages/docs/clipboard-pickling/explainer.md i2p: https://groups.google.com/a/chromium.org/g/blink-dev/c/Lo7WBM_v_LY/m/LncCKkXeAwAJ i2s: https://groups.google.com/a/chromium.org/g/blink-dev/c/k2rgX-4Cigc/m/P0RijrpzBAAJ?utm_medium=email&utm_source=footer&pli=1 1. Github issue: w3c/clipboard-apis#165 Bug: 106449 Change-Id: I86aae6a662089efeede2a01ac87cb698e9646df5
This patch addresses the changes proposed by the EditingWG[1] and agreed upon by all browser vendors. We are removing the `unsanitized` option, and instead, adding custom format support for MIME types that have "web " prefix in them. Added few wpt tests to test these changes. Below is a summary of the changes in this CL: 1. Removed `unsanitized` option from read/write methods. 2. If the custom format doesn't have a "web " prefix, then clipboard read/write fails. 3. Transient user activation is applicable to all supported formats - text/html, text/plain, image/png and web custom formats. 4. There are two "buckets" of clipboard formats. One for the well-known formats and the other for the web custom format. If the author doesn't specify the web format explicitly, then they don't get access to it. This means, we won't write web custom formats for well-known types implicitly if authors have not indicated that during the write call via a "web " prefix (e.g. "web text/html"). Same applies for reading web custom formats for well-known types- if there aren't any formats in the web custom format map, then we won't return any web custom formats i.e. text/html won't be automatically converted into "web text/html". Spec: w3c/clipboard-apis#175 Explainer: https://github.com/w3c/editing/blob/gh-pages/docs/clipboard-pickling/explainer.md i2p: https://groups.google.com/a/chromium.org/g/blink-dev/c/Lo7WBM_v_LY/m/LncCKkXeAwAJ i2s: https://groups.google.com/a/chromium.org/g/blink-dev/c/k2rgX-4Cigc/m/P0RijrpzBAAJ?utm_medium=email&utm_source=footer&pli=1 1. Github issue: w3c/clipboard-apis#165 Bug: 106449 Change-Id: I86aae6a662089efeede2a01ac87cb698e9646df5
This patch addresses the changes proposed by the EditingWG[1] and agreed upon by all browser vendors. We are removing the `unsanitized` option, and instead, adding custom format support for MIME types that have "web " prefix in them. Added few wpt tests to test these changes. Below is a summary of the changes in this CL: 1. Removed `unsanitized` option from read/write methods. 2. If the custom format doesn't have a "web " prefix, then clipboard read/write fails. 3. Transient user activation is applicable to all supported formats - text/html, text/plain, image/png and web custom formats. 4. There are two "buckets" of clipboard formats. One for the well-known formats and the other for the web custom format. If the author doesn't specify the web format explicitly, then they don't get access to it. This means, we won't write web custom formats for well-known types implicitly if authors have not indicated that during the write call via a "web " prefix (e.g. "web text/html"). Same applies for reading web custom formats for well-known types- if there aren't any formats in the web custom format map, then we won't return any web custom formats i.e. text/html won't be automatically converted into "web text/html". Spec: w3c/clipboard-apis#175 Explainer: https://github.com/w3c/editing/blob/gh-pages/docs/clipboard-pickling/explainer.md i2p: https://groups.google.com/a/chromium.org/g/blink-dev/c/Lo7WBM_v_LY/m/LncCKkXeAwAJ i2s: https://groups.google.com/a/chromium.org/g/blink-dev/c/k2rgX-4Cigc/m/P0RijrpzBAAJ?utm_medium=email&utm_source=footer&pli=1 1. Github issue: w3c/clipboard-apis#165 Bug: 106449 Change-Id: I86aae6a662089efeede2a01ac87cb698e9646df5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3650952 Commit-Queue: Anupam Snigdha <[email protected]> Reviewed-by: Alexander Timin <[email protected]> Reviewed-by: Daniel Cheng <[email protected]> Reviewed-by: Austin Sullivan <[email protected]> Cr-Commit-Position: refs/heads/main@{#1011078}
This patch addresses the changes proposed by the EditingWG[1] and agreed upon by all browser vendors. We are removing the `unsanitized` option, and instead, adding custom format support for MIME types that have "web " prefix in them. Added few wpt tests to test these changes. Below is a summary of the changes in this CL: 1. Removed `unsanitized` option from read/write methods. 2. If the custom format doesn't have a "web " prefix, then clipboard read/write fails. 3. Transient user activation is applicable to all supported formats - text/html, text/plain, image/png and web custom formats. 4. There are two "buckets" of clipboard formats. One for the well-known formats and the other for the web custom format. If the author doesn't specify the web format explicitly, then they don't get access to it. This means, we won't write web custom formats for well-known types implicitly if authors have not indicated that during the write call via a "web " prefix (e.g. "web text/html"). Same applies for reading web custom formats for well-known types- if there aren't any formats in the web custom format map, then we won't return any web custom formats i.e. text/html won't be automatically converted into "web text/html". Spec: w3c/clipboard-apis#175 Explainer: https://github.com/w3c/editing/blob/gh-pages/docs/clipboard-pickling/explainer.md i2p: https://groups.google.com/a/chromium.org/g/blink-dev/c/Lo7WBM_v_LY/m/LncCKkXeAwAJ i2s: https://groups.google.com/a/chromium.org/g/blink-dev/c/k2rgX-4Cigc/m/P0RijrpzBAAJ?utm_medium=email&utm_source=footer&pli=1 1. Github issue: w3c/clipboard-apis#165 Bug: 106449 Change-Id: I86aae6a662089efeede2a01ac87cb698e9646df5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3650952 Commit-Queue: Anupam Snigdha <[email protected]> Reviewed-by: Alexander Timin <[email protected]> Reviewed-by: Daniel Cheng <[email protected]> Reviewed-by: Austin Sullivan <[email protected]> Cr-Commit-Position: refs/heads/main@{#1011078}
This patch addresses the changes proposed by the EditingWG[1] and agreed upon by all browser vendors. We are removing the `unsanitized` option, and instead, adding custom format support for MIME types that have "web " prefix in them. Added few wpt tests to test these changes. Below is a summary of the changes in this CL: 1. Removed `unsanitized` option from read/write methods. 2. If the custom format doesn't have a "web " prefix, then clipboard read/write fails. 3. Transient user activation is applicable to all supported formats - text/html, text/plain, image/png and web custom formats. 4. There are two "buckets" of clipboard formats. One for the well-known formats and the other for the web custom format. If the author doesn't specify the web format explicitly, then they don't get access to it. This means, we won't write web custom formats for well-known types implicitly if authors have not indicated that during the write call via a "web " prefix (e.g. "web text/html"). Same applies for reading web custom formats for well-known types- if there aren't any formats in the web custom format map, then we won't return any web custom formats i.e. text/html won't be automatically converted into "web text/html". Spec: w3c/clipboard-apis#175 Explainer: https://github.com/w3c/editing/blob/gh-pages/docs/clipboard-pickling/explainer.md i2p: https://groups.google.com/a/chromium.org/g/blink-dev/c/Lo7WBM_v_LY/m/LncCKkXeAwAJ i2s: https://groups.google.com/a/chromium.org/g/blink-dev/c/k2rgX-4Cigc/m/P0RijrpzBAAJ?utm_medium=email&utm_source=footer&pli=1 1. Github issue: w3c/clipboard-apis#165 Bug: 106449 Change-Id: I86aae6a662089efeede2a01ac87cb698e9646df5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3650952 Commit-Queue: Anupam Snigdha <[email protected]> Reviewed-by: Alexander Timin <[email protected]> Reviewed-by: Daniel Cheng <[email protected]> Reviewed-by: Austin Sullivan <[email protected]> Cr-Commit-Position: refs/heads/main@{#1011078}
@snianu We could also write arbitrary type with "web" prefix via legacy API, e.g. document.addEventListener("copy", function(e) {
e.preventDefault();
let clipboardData = e.clipboardData;
clipboardData.setData("web text/foo", "foo");
clipboardData.setData("text/bar", "bar");
}); I would expect the type with "web" prefix to follow the well-defined format/structure, too. So it could be interop with async clipobard API/browsers/native apps. for example, if we write the data into clipboard via above example and read clipboard data via async clipboard API const items = await navigator.clipboard.read();
items[0].getType("web text/foo"); // get "foo"
items[0].getType("text/bar"); // promise reject (and vice versa) Yes, this introduce a behavior changes in legacy API, but I think this also make web custom type less surprise to user? And the impact in legacy API should be small? |
@EdgarChen While it's true that you could write custom types with "web " prefix using DataTransfer APIs, those custom types do not follow the same model - there isn't a restriction on the number of custom format types that can be written by the web authors, no web custom JSON map for mapping the web custom types to a fixed number of native web clipboard formats etc. |
…mats implementation., a=testonly Automatic update from web-platform-tests [Clipboard API] Clipboard Web Custom Formats implementation. This patch addresses the changes proposed by the EditingWG[1] and agreed upon by all browser vendors. We are removing the `unsanitized` option, and instead, adding custom format support for MIME types that have "web " prefix in them. Added few wpt tests to test these changes. Below is a summary of the changes in this CL: 1. Removed `unsanitized` option from read/write methods. 2. If the custom format doesn't have a "web " prefix, then clipboard read/write fails. 3. Transient user activation is applicable to all supported formats - text/html, text/plain, image/png and web custom formats. 4. There are two "buckets" of clipboard formats. One for the well-known formats and the other for the web custom format. If the author doesn't specify the web format explicitly, then they don't get access to it. This means, we won't write web custom formats for well-known types implicitly if authors have not indicated that during the write call via a "web " prefix (e.g. "web text/html"). Same applies for reading web custom formats for well-known types- if there aren't any formats in the web custom format map, then we won't return any web custom formats i.e. text/html won't be automatically converted into "web text/html". Spec: w3c/clipboard-apis#175 Explainer: https://github.com/w3c/editing/blob/gh-pages/docs/clipboard-pickling/explainer.md i2p: https://groups.google.com/a/chromium.org/g/blink-dev/c/Lo7WBM_v_LY/m/LncCKkXeAwAJ i2s: https://groups.google.com/a/chromium.org/g/blink-dev/c/k2rgX-4Cigc/m/P0RijrpzBAAJ?utm_medium=email&utm_source=footer&pli=1 1. Github issue: w3c/clipboard-apis#165 Bug: 106449 Change-Id: I86aae6a662089efeede2a01ac87cb698e9646df5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3650952 Commit-Queue: Anupam Snigdha <[email protected]> Reviewed-by: Alexander Timin <[email protected]> Reviewed-by: Daniel Cheng <[email protected]> Reviewed-by: Austin Sullivan <[email protected]> Cr-Commit-Position: refs/heads/main@{#1011078} -- wpt-commits: b8ebea7f172334f5a5d9ac87860aec5f55becd26 wpt-pr: 34117
|
||
1. Let |firstItem| be |items|[0] | ||
|
||
1. Run the [=read web custom format=] algorithm given |firstItem|. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per https://w3c.github.io/clipboard-apis/#dom-clipboarditem-types, type
getter of ClipboardItem returns types array
, but it is not clear how does types array
be constructed. It would be nice that we could have some steps for that.
Not sure if this makes sense: maybe we could construct types array
from list of representations
, but which means we would need to read custom types first as we would like the custom types listed at the top.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. We should definitely add this to the spec.
This patch addresses the changes proposed by the EditingWG[1] and agreed upon by all browser vendors. We are removing the `unsanitized` option, and instead, adding custom format support for MIME types that have "web " prefix in them. Added few wpt tests to test these changes. Below is a summary of the changes in this CL: 1. Removed `unsanitized` option from read/write methods. 2. If the custom format doesn't have a "web " prefix, then clipboard read/write fails. 3. Transient user activation is applicable to all supported formats - text/html, text/plain, image/png and web custom formats. 4. There are two "buckets" of clipboard formats. One for the well-known formats and the other for the web custom format. If the author doesn't specify the web format explicitly, then they don't get access to it. This means, we won't write web custom formats for well-known types implicitly if authors have not indicated that during the write call via a "web " prefix (e.g. "web text/html"). Same applies for reading web custom formats for well-known types- if there aren't any formats in the web custom format map, then we won't return any web custom formats i.e. text/html won't be automatically converted into "web text/html". Spec: w3c/clipboard-apis#175 Explainer: https://github.com/w3c/editing/blob/gh-pages/docs/clipboard-pickling/explainer.md i2p: https://groups.google.com/a/chromium.org/g/blink-dev/c/Lo7WBM_v_LY/m/LncCKkXeAwAJ i2s: https://groups.google.com/a/chromium.org/g/blink-dev/c/k2rgX-4Cigc/m/P0RijrpzBAAJ?utm_medium=email&utm_source=footer&pli=1 1. Github issue: w3c/clipboard-apis#165 Bug: 106449 Change-Id: I86aae6a662089efeede2a01ac87cb698e9646df5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3650952 Commit-Queue: Anupam Snigdha <[email protected]> Reviewed-by: Alexander Timin <[email protected]> Reviewed-by: Daniel Cheng <[email protected]> Reviewed-by: Austin Sullivan <[email protected]> Cr-Commit-Position: refs/heads/main@{#1011078} NOKEYCHECK=True GitOrigin-RevId: a3b96a459cf17ddc683b510718bfcbe40ed08195
Hello @snianu , I've tried to review the current state after I have seen your presentation at the TPAC. Here are my rather nitty gritty comments:
Tell me if I should make my comments more precise (e.g. with line numbers). I am quite excited by the implementation found in Chromium (and blogged about it). I suspect that we are getting close to acceptance, at least provided that Mozilla will consider implementing as it seems it said at the start. thanks and sorry to be slow to have reviewed. Paul |
4f99bc5
to
c6394d3
Compare
Thanks @polx for the review and apologies for the delay!
Note that in the spec it's referred to as
This is referring to the custom format with a
This is by-design that we write raw bytes sequence to the clipboard for the custom formats so the reader has to know how to parse its content (which is also by-design).
This is because we need to perform an additional step to produce a native clipbaord format and insert the key-value pair into the |
@sanketj could you please take a look at this PR so we can merge it into the clipboard repo? Thanks! |
@garykac Thank you so much! |
SHA: eb4e99a Reason: push, by snianu Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
For web, our clipboard for resources currently is in-memory only. This prevents copying data between windows and can also cause us to get into odd states where the in-memory clipboard no longer matches what's the real clipboard This change tried to migrate resources to use the real clipboard thanks the custom web clipboard types: w3c/clipboard-apis#175 This feature only works in Chromium at the moment, but I believe other browsers have expressed intent to implement it too
For web, our clipboard for resources currently is in-memory only. This prevents copying data between windows and can also cause us to get into odd states where the in-memory clipboard no longer matches what's the real clipboard This change tried to migrate resources to use the real clipboard thanks the custom web clipboard types: w3c/clipboard-apis#175 This feature only works in Chromium at the moment, but I believe other browsers have expressed intent to implement it too
For web, our clipboard for resources currently is in-memory only. This prevents copying data between windows and can also cause us to get into odd states where the in-memory clipboard no longer matches what's the real clipboard This change tried to migrate resources to use the real clipboard thanks the custom web clipboard types: w3c/clipboard-apis#175 This feature only works in Chromium at the moment, but I believe other browsers have expressed intent to implement it too
Closes #165
For normative changes, the following tasks have been completed:
Implementation commitment:
Preview | Diff