Bug 34893
Summary: | [Qt] Copying markup using QWebAction::Copy has problems with <img> tags | ||
---|---|---|---|
Product: | WebKit | Reporter: | Sebastian Gottfried <sebastian.gottfried> |
Component: | Platform | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED INVALID | ||
Severity: | Minor | CC: | andersca |
Priority: | P4 | Keywords: | Qt, QtTriaged |
Version: | 528+ (Nightly build) | ||
Hardware: | PC | ||
OS: | Windows XP |
Sebastian Gottfried
If I copy a selection containing text and images via QWebAction::Copy and paste it into MS Word all images are omitted. Layout and formatting are transferred as expected.
As it appears QtWebKit embeds the images as data urls into to html code for the clipboard. This isn't necessaraly a bug, but one of the most important paste targets, MS Word, can't handle this. As other popular browsers, like MSIE and Mozilla Firefox just pass the URLs of the images, QtWebKit should follow this behaviour for better compatibility.
I'm using WebKit from Qt 4.6.1.
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Tor Arne Vestbø
Please follow the QtWebKit bug reporting guidelines when reporting bugs.
See http://trac.webkit.org/wiki/QtWebKitBugs
Specifically:
- The 'QtWebKit' component should only be used for bugs/features in the
public QtWebKit API layer, not to signify that the bug is specific to
the Qt port of WebKit
http://trac.webkit.org/wiki/QtWebKitBugs#Component
- Add the keyword 'Qt' to signal that it's a Qt-related bug
http://trac.webkit.org/wiki/QtWebKitBugs#Keywords
Tor Arne Vestbø
If Microsoft Word does not support data: urls that's a bug/missing feature in their software.
That said, it does not look like we're using data-urls to embed images. The markup is copied verbatim and wrapped in document like reporter suggested.
But one thing I noticed was that both Chromium and Safari sets the SourceURL for the HTML clipboard part, which we don't. That will cause relative URLs to be broken unless there's some other way we pass that.
Sebastian Gottfried
I did some additional research on this bug. Indeed images are not passed data urls. This was an stupid mistake during my first debugging session.
As Tor Arne Vestbø already mentioned, relative URLS are passed as is and will, of course, not work if not treated specially.
I have fixed the bug by patching WebCore/editing/markup.cpp: In the function appendStartMarkup() I make URLs absolute before passed to appendQuotedURLAttributeValue() if annotate is set.
if (el->isURLAttribute(attr)) {
if (annotate)
appendQuotedURLAttributeValue(result, node->document()->completeURL(attr->value()));
else
appendQuotedURLAttributeValue(result, attr->value());
}
I'm not completely sure if this breaks some other functionality but my investigations told me that annotate is only set for clipboard functionality.