Bug 189504 - [Cocoa] Complete support for Paste as Quotation
Summary: [Cocoa] Complete support for Paste as Quotation
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: mitz
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-09-11 09:40 PDT by mitz
Modified: 2018-09-12 15:27 PDT (History)
4 users (show)

See Also:


Attachments
macOS-only patch to see what work needs to be done in other ports (11.94 KB, patch)
2018-09-11 09:41 PDT, mitz
no flags Details | Formatted Diff | Diff
Multi-platform patch for EWS (20.33 KB, patch)
2018-09-11 13:02 PDT, mitz
no flags Details | Formatted Diff | Diff
Multi-platform patch for EWS (20.28 KB, patch)
2018-09-11 13:16 PDT, mitz
no flags Details | Formatted Diff | Diff
Multi-platform patch for EWS (20.28 KB, patch)
2018-09-11 13:30 PDT, mitz
no flags Details | Formatted Diff | Diff
Multi-platform patch for EWS (22.57 KB, patch)
2018-09-11 14:24 PDT, mitz
no flags Details | Formatted Diff | Diff
Add PasteAsQuotation command and -[WKWebView _pasteAsQuotation:] (36.39 KB, patch)
2018-09-12 13:11 PDT, mitz
wenson_hsieh: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description mitz 2018-09-11 09:40:52 PDT
WebCore implements custom paste behavior for Paste as Quotation, which is triggered by the presence of a specific class attribute value on the blockquote element being pasted (see isMailPasteAsQuotationNode in ReplaceSeelctionCommand.cpp). This allows clients of the legacy API to create a document fragment that will get pasted as a quotation. To expose the same functionality to clients of the modern WebKit API, we can introduce an explicit Paste as Quotation command, which will take care of creating an enclosing blockquote with the appropriate class. In the future we can do away with using the class attribute to signal the desired behavior altogether.
Comment 1 mitz 2018-09-11 09:41:41 PDT
Created attachment 349400 [details]
macOS-only patch to see what work needs to be done in other ports
Comment 2 EWS Watchlist 2018-09-11 09:44:45 PDT
Attachment 349400 [details] did not pass style-queue:


ERROR: Source/WebCore/editing/mac/EditorMac.mm:114:  Extra space before )  [whitespace/parens] [2]
Total errors found: 1 in 8 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 mitz 2018-09-11 13:02:38 PDT
Created attachment 349426 [details]
Multi-platform patch for EWS
Comment 4 EWS Watchlist 2018-09-11 13:05:53 PDT
Attachment 349426 [details] did not pass style-queue:


ERROR: Source/WebCore/editing/mac/EditorMac.mm:97:  Extra space before )  [whitespace/parens] [2]
Total errors found: 1 in 12 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 5 mitz 2018-09-11 13:16:36 PDT
Created attachment 349432 [details]
Multi-platform patch for EWS
Comment 6 EWS Watchlist 2018-09-11 13:18:15 PDT
Attachment 349432 [details] did not pass style-queue:


ERROR: Source/WebCore/editing/mac/EditorMac.mm:97:  Extra space before )  [whitespace/parens] [2]
Total errors found: 1 in 12 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 7 mitz 2018-09-11 13:30:20 PDT
Created attachment 349436 [details]
Multi-platform patch for EWS
Comment 8 EWS Watchlist 2018-09-11 13:45:33 PDT
Attachment 349436 [details] did not pass style-queue:


ERROR: Source/WebCore/editing/mac/EditorMac.mm:97:  Extra space before )  [whitespace/parens] [2]
Total errors found: 1 in 12 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 9 mitz 2018-09-11 14:24:51 PDT
Created attachment 349454 [details]
Multi-platform patch for EWS
Comment 10 EWS Watchlist 2018-09-11 14:26:59 PDT
Attachment 349454 [details] did not pass style-queue:


ERROR: Source/WebCore/editing/mac/EditorMac.mm:97:  Extra space before )  [whitespace/parens] [2]
Total errors found: 1 in 14 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 11 mitz 2018-09-12 13:11:53 PDT
Created attachment 349574 [details]
Add PasteAsQuotation command and -[WKWebView _pasteAsQuotation:]
Comment 12 EWS Watchlist 2018-09-12 13:16:26 PDT
Attachment 349574 [details] did not pass style-queue:


ERROR: Source/WebCore/editing/mac/EditorMac.mm:96:  Extra space before )  [whitespace/parens] [2]
Total errors found: 1 in 25 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 13 Wenson Hsieh 2018-09-12 14:50:52 PDT
Comment on attachment 349574 [details]
Add PasteAsQuotation command and -[WKWebView _pasteAsQuotation:]

View in context: https://bugs.webkit.org/attachment.cgi?id=349574&action=review

r=mews

> Source/WebCore/editing/Editor.h:135
> +        AsQuotation = 2 << 0,

‽‽‽‽

> LayoutTests/editing/pasteboard/4930986-1-paste-as-quotation.html:17
> +document.addEventListener("beforecopy", (event) => { event.preventDefault(); });

Nit - no need for the { } around the function body.

> LayoutTests/editing/pasteboard/4930986-2-paste-as-quotation.html:13
> +    document.addEventListener("beforecopy", (event) => { event.preventDefault(); });

(Ditto)

> LayoutTests/editing/pasteboard/4930986-3-paste-as-quotation.html:17
> +document.addEventListener("beforecopy", (event) => { event.preventDefault(); });

(Ditto)
Comment 14 mitz 2018-09-12 15:21:38 PDT
Comment on attachment 349574 [details]
Add PasteAsQuotation command and -[WKWebView _pasteAsQuotation:]

View in context: https://bugs.webkit.org/attachment.cgi?id=349574&action=review

>> Source/WebCore/editing/Editor.h:135
>> +        AsQuotation = 2 << 0,
> 
> ‽‽‽‽

The whole thing is unbelievable.

>> LayoutTests/editing/pasteboard/4930986-1-paste-as-quotation.html:17
>> +document.addEventListener("beforecopy", (event) => { event.preventDefault(); });
> 
> Nit - no need for the { } around the function body.

Nice.
Comment 15 mitz 2018-09-12 15:26:26 PDT
Committed <https://trac.webkit.org/r235955>.
Comment 16 Radar WebKit Bug Importer 2018-09-12 15:27:21 PDT
<rdar://problem/44397322>