Open Bug 502156 Opened 15 years ago Updated 3 years ago

nsHTMLEditor::CreateDOMFragmentFromPaste should use CreateContextualFragment

Categories

(Core :: DOM: Editor, defect, P5)

defect

Tracking

()

People

(Reporter: roc, Unassigned)

Details

Attachments

(1 file)

Attached patch fixSplinter Review
Currently it instantiates an nsIParser directly. It can just use nsContentUtils::CreateContextualFragment. This saves code and means that if the HTML5 parser is enabled, we'll use it. This lets us do cool stuff like copy/paste and drag/drop SVG-in-HTML.
Attachment #386682 - Flags: superreview?(peterv)
Attachment #386682 - Flags: review?(peterv)
Ignore the media test junk at the start of the patch.
Ignore the stray nsHTML5Module include as well.
Attachment #386682 - Flags: superreview?(peterv)
Attachment #386682 - Flags: superreview+
Attachment #386682 - Flags: review?(peterv)
Attachment #386682 - Flags: review+
Comment on attachment 386682 [details] [diff] [review]
fix

>diff --git a/editor/libeditor/html/nsHTMLDataTransfer.cpp b/editor/libeditor/html/nsHTMLDataTransfer.cpp

>@@ -2540,54 +2541,55 @@ nsresult nsHTMLEditor::CreateDOMFragment

>   nsCOMPtr<nsIDOMDocument> domDoc;
>   GetDocument(getter_AddRefs(domDoc));
> 
>   nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
>   NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);

I think you can now also remove these.

>   nsCOMPtr<nsIDOMDocumentFragment> contextfrag;

contextfrag looks unused too.
It seems test_bug478725.html fails because the current parser, when called via CreateContextualFragment, parses "<dl><dd>Hello Kitty</dd></dl>" into a document fragment that starts with a text node containing a single space. Similar for test_bug480972.html. The tests pass using the HTML5 parser.

I also noticed that although it's not picked up in the tests, copying and pasting plain text not including a node does not work with this patch and the old parser. It does work with the HTML5 parser.

I'm not sure how to proceed.
Assignee: roc → nobody

Bulk-downgrade of unassigned, >=5 years untouched DOM/Storage bugs' priority.

If you have reason to believe this is wrong (especially for the severity), please write a comment and ni :jstutte.

Severity: normal → S4
Priority: -- → P5
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: