Bug 62464

Summary: [Qt] QWebElement::encloseWith doesn't work at all
Product: WebKit Reporter: Bernhard Rosenkraenzer <bero>
Component: WebKit QtAssignee: Zeno Albisser <zeno>
Status: RESOLVED FIXED    
Severity: Normal CC: steven.f.chu, webkit.review.bot
Priority: P2 Keywords: Qt
Version: 528+ (Nightly build)   
Hardware: All   
OS: Linux   
Attachments:
Description Flags
Test case
none
patch for review.
kling: review-, kling: commit-queue-
patch for review - fixed coding style issues none

Description Bernhard Rosenkraenzer 2011-06-10 10:31:03 PDT
Created attachment 96756 [details]
Test case

QWebElement::encloseWith fails to do anything - see attached test case.

Expected output after the encloseWith call:
<html><head><title>test</title></head><body><p id="p1"><img src="test.png"/></p></body></html>
Comment 1 Bernhard Rosenkraenzer 2011-06-14 02:02:34 PDT
The same is true for QWebElement::prependOutside and QWebElement::appendOutside.

To test, simply insert

e.prependOutside("<p id=\"p2\">Test</p>");
e.appendOutside("<p id=\"p3\">Another test</p>");

after

e.encloseWith("<p id=\"p1\"></p>");

in TestApp.cpp
The result remains the same -- none of the calls has any effect.
Comment 2 Steven Chu 2011-06-26 19:51:14 PDT
(In reply to comment #1)
> The same is true for QWebElement::prependOutside and QWebElement::appendOutside.
> 
> To test, simply insert
> 
> e.prependOutside("<p id=\"p2\">Test</p>");
> e.appendOutside("<p id=\"p3\">Another test</p>");
> 
> after
> 
> e.encloseWith("<p id=\"p1\"></p>");
> 
> in TestApp.cpp
> The result remains the same -- none of the calls has any effect.

<img> is one of the tags not allowed.  For the list of other tags ignored, HTMLElement.cpp - Line 76: HTMLElement::ieForbidsInsertHTML()
Comment 3 Zeno Albisser 2011-09-09 04:06:54 PDT
Created attachment 106858 [details]
patch for review.
Comment 4 Andreas Kling 2011-09-09 04:21:50 PDT
Comment on attachment 106858 [details]
patch for review.

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

Looks generally great, apart from some minor coding style problems.
Please refer to http://www.webkit.org/coding/coding-style.html for the inside scoop :)
You can use the Tools/Scripts/check-webkit-style script to verify correct style before uploading patches.

> Source/WebKit/qt/Api/qwebelement.cpp:1122
> +    RefPtr<DocumentFragment> fragment =  Range::createDocumentFragmentForElement(markup, toHTMLElement(parent));

Coding style, two spaces after =.

> Source/WebKit/qt/Api/qwebelement.cpp:1172
> +    RefPtr<DocumentFragment> fragment =  Range::createDocumentFragmentForElement(markup, toHTMLElement(parent));

Ditto.

> Source/WebKit/qt/Api/qwebelement.cpp:1393
> +    RefPtr<DocumentFragment> fragment =  Range::createDocumentFragmentForElement(markup, toHTMLElement(parent));

Ditto.

> Source/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp:650
> +    // check behavior for a tag that IE forbids inserting HTML

Coding style, comments should be written like normal sentences (capitalized and ending with a period.)

> Source/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp:655
> +    QWebElement img = body.findFirst("img");
> +    img.appendInside("<p id=\"fail1\"></p>");

QVERIFY(!img.isNull()); wouldn't hurt here.

> Source/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp:904
> +    // check behavior for a tag that IE forbids inserting HTML

Coding style, comments should be written like normal sentences (capitalized and ending with a period.)

> Source/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp:909
> +    QWebElement img = body.findFirst("img");
> +    img.encloseWith("<p id=\"success\"></p>");

QVERIFY(!img.isNull()); wouldn't hurt here.
Comment 5 Zeno Albisser 2011-09-09 05:13:04 PDT
Created attachment 106863 [details]
patch for review - fixed coding style issues
Comment 6 Andreas Kling 2011-09-09 05:15:19 PDT
Comment on attachment 106863 [details]
patch for review - fixed coding style issues

Delightful, r=me
Comment 7 WebKit Review Bot 2011-09-09 07:31:20 PDT
Comment on attachment 106863 [details]
patch for review - fixed coding style issues

Clearing flags on attachment: 106863

Committed r94852: <http://trac.webkit.org/changeset/94852>
Comment 8 WebKit Review Bot 2011-09-09 07:31:25 PDT
All reviewed patches have been landed.  Closing bug.