RESOLVED FIXED49166
[Qt] QWebElement::appendInside() doesn't work on head elements
https://bugs.webkit.org/show_bug.cgi?id=49166
Summary [Qt] QWebElement::appendInside() doesn't work on head elements
Bernhard Rosenkraenzer
Reported 2010-11-08 03:17:46 PST
Using QWebElement::appendInside() on the QWebElement representing the HTML's <head> tag does nothing. e.g. this works: QWebElement e=frame->findFirstElement("body"); e.appendInside("<p>test test test</p>"); But this doesn't: QWebElement e=frame->findFirstElement("head"); e.appendInside("<script type=\"text/javascript\" src=\"test.js\"/>");
Attachments
Test case (1.00 KB, application/octet-stream)
2010-11-08 03:19 PST, Bernhard Rosenkraenzer
no flags
Patch (1.85 KB, patch)
2010-11-21 15:40 PST, Jan Erik Hanssen
no flags
Patch (2.84 KB, patch)
2010-11-21 21:02 PST, Jan Erik Hanssen
no flags
Patch (2.55 KB, patch)
2010-11-22 01:39 PST, Jan Erik Hanssen
no flags
Bernhard Rosenkraenzer
Comment 1 2010-11-08 03:19:22 PST
Created attachment 73230 [details] Test case Adding simple test case. FWIW this is with the QtWebKit in the current qt 4.7 branch
Jan Erik Hanssen
Comment 2 2010-11-08 19:04:13 PST
Initial assessment: HTMLElement::deprecatedCreateContextualFragment() explicitly check if the element is a HEAD element (among others) and does not create a DocumentFragment if that's the case. Explicitly calling Element::deprecatedCreateContextualFragment() instead makes this work. Not sure yet if this is a Qt documentation issue or an actual bug.
Benjamin Poulain
Comment 3 2010-11-11 08:37:04 PST
(In reply to comment #2) > Not sure yet if this is a Qt documentation issue or an actual bug. I think we can consider this as a bug. To create WebKit animation on the fly it can be usefull to add stuff in the <head> element. If this can be supported, that sounds like a nice feature to have. I give this a low priority.
Jan Erik Hanssen
Comment 4 2010-11-21 15:40:30 PST
Andreas Kling
Comment 5 2010-11-21 18:54:05 PST
Comment on attachment 74518 [details] Patch Needs an autotest in WebKit/qt/tests/qwebelement
Jan Erik Hanssen
Comment 6 2010-11-21 21:02:04 PST
Kenneth Rohde Christiansen
Comment 7 2010-11-22 00:31:19 PST
Comment on attachment 74528 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=74528&action=review > WebKit/qt/Api/qwebelement.cpp:1030 > + RefPtr<DocumentFragment> fragment; > HTMLElement* htmlElement = static_cast<HTMLElement*>(m_element); > - RefPtr<DocumentFragment> fragment = htmlElement->deprecatedCreateContextualFragment(markup); > + if (htmlElement->hasLocalName(HTMLNames::headTag)) > + fragment = htmlElement->Element::deprecatedCreateContextualFragment(markup); > + else > + fragment = htmlElement->deprecatedCreateContextualFragment(markup); > > ExceptionCode exception = 0; Why not just cast it to Element always?
Jan Erik Hanssen
Comment 8 2010-11-22 01:36:59 PST
(In reply to comment #7) > Why not just cast it to Element always? Good point. For some reason I thought the default action should be to go through HTMLElement but there's no need for that it seems. I'll upload a new patch.
Jan Erik Hanssen
Comment 9 2010-11-22 01:39:53 PST
WebKit Commit Bot
Comment 10 2010-11-22 02:00:01 PST
Comment on attachment 74533 [details] Patch Clearing flags on attachment: 74533 Committed r72510: <http://trac.webkit.org/changeset/72510>
WebKit Commit Bot
Comment 11 2010-11-22 02:00:07 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.