diff options
author | dglazkov@google.com <dglazkov@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-15 15:00:32 +0000 |
---|---|---|
committer | dglazkov@google.com <dglazkov@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-15 15:00:32 +0000 |
commit | 721df41e312c9748988da745ced27b84f3f7412b (patch) | |
tree | f00c66b3820ad4bb116c4f8d342a23d86f73ada1 /webkit/port | |
parent | 38c1fb716799cbe6117e2d1035173234b955b062 (diff) | |
download | chromium_src-721df41e312c9748988da745ced27b84f3f7412b.zip chromium_src-721df41e312c9748988da745ced27b84f3f7412b.tar.gz chromium_src-721df41e312c9748988da745ced27b84f3f7412b.tar.bz2 |
This change fixes http://b/1325836, which is obscure but has a benefit of letting us pass another layout test: LayoutTests/editing/pasteboard/copy-standalone-image.html
It would probably be good to send this upstream eventually, because WebKit/Win doesn't pass this test, either.
WebKit/Mac for some reason inserts an extra P element around the image (along with margin-zero-setting style attribute to boot), but neither FF nor IE do that, so I decided to stick with the majority.
The test was rebaselined to a) remove the extra P element in the node tree and b) take minor pixel shifts due to Chrome rendering changes into the account.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@939 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/port')
-rw-r--r-- | webkit/port/platform/ClipboardUtilitiesWin.cpp | 14 | ||||
-rw-r--r-- | webkit/port/platform/ClipboardUtilitiesWin.h | 1 | ||||
-rw-r--r-- | webkit/port/platform/PasteboardWin.cpp | 17 |
3 files changed, 31 insertions, 1 deletions
diff --git a/webkit/port/platform/ClipboardUtilitiesWin.cpp b/webkit/port/platform/ClipboardUtilitiesWin.cpp index 9c2ca6b..f5223df 100644 --- a/webkit/port/platform/ClipboardUtilitiesWin.cpp +++ b/webkit/port/platform/ClipboardUtilitiesWin.cpp @@ -139,6 +139,20 @@ String urlToMarkup(const KURL& url, const String& title) return markup; } +String urlToImageMarkup(const KURL& url, const String& altStr) { + String markup("<img src=\""); + markup.append(url.string()); + markup.append("\""); + if (!altStr.isEmpty()) { + markup.append(" alt=\""); + // TODO(dglazkov): escape string + markup.append(altStr); + markup.append("\""); + } + markup.append("/>"); + return markup; +} + void replaceNewlinesWithWindowsStyleNewlines(String& str) { static const UChar Newline = '\n'; diff --git a/webkit/port/platform/ClipboardUtilitiesWin.h b/webkit/port/platform/ClipboardUtilitiesWin.h index 9b14e90..7cfe569 100644 --- a/webkit/port/platform/ClipboardUtilitiesWin.h +++ b/webkit/port/platform/ClipboardUtilitiesWin.h @@ -44,6 +44,7 @@ HGLOBAL createGlobalData(const KURL& url, const String& title); DeprecatedCString markupToCF_HTML(const String& markup, const String& srcURL); String urlToMarkup(const KURL& url, const String& title); +String urlToImageMarkup(const KURL& url, const String& altStr); void replaceNewlinesWithWindowsStyleNewlines(String& str); void replaceNBSPWithSpace(String& str); diff --git a/webkit/port/platform/PasteboardWin.cpp b/webkit/port/platform/PasteboardWin.cpp index 2fa1cc8..dae2ab5 100644 --- a/webkit/port/platform/PasteboardWin.cpp +++ b/webkit/port/platform/PasteboardWin.cpp @@ -121,7 +121,7 @@ void Pasteboard::writeURL(const KURL& url, const String& titleStr, Frame* frame) webkit_glue::ClipboardWriteText(spec); } -void Pasteboard::writeImage(Node* node, const KURL&, const String&) +void Pasteboard::writeImage(Node* node, const KURL& url, const String& title) { ASSERT(node && node->renderer() && node->renderer()->isImage()); RenderImage* renderer = static_cast<RenderImage*>(node->renderer()); @@ -134,6 +134,21 @@ void Pasteboard::writeImage(Node* node, const KURL&, const String&) NativeImageSkia* bitmap = image->getBitmap(); if (bitmap) webkit_glue::ClipboardWriteBitmap(*bitmap); + if (!url.isEmpty()) { + webkit_glue::ClipboardWriteBookmark(webkit_glue::StringToStdWString(title), + webkit_glue::KURLToGURL(url)); + // write to clipboard in format com.apple.safari.bookmarkdata to be able to paste into the bookmarks view with appropriate title + webkit_glue::ClipboardWriteBookmark(webkit_glue::StringToStdWString(title), + webkit_glue::KURLToGURL(url)); + + // write to clipboard in format CF_HTML to be able to paste into contenteditable areas as a an image + std::wstring markup(webkit_glue::StringToStdWString(urlToImageMarkup(url, title))); + webkit_glue::ClipboardWriteHTML(markup, GURL()); + + // bare-bones CF_UNICODETEXT support + std::wstring spec(webkit_glue::DeprecatedStringToStdWString(url.deprecatedString())); + webkit_glue::ClipboardWriteText(spec); + } } bool Pasteboard::canSmartReplace() |