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 | |
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
6 files changed, 72 insertions, 5 deletions
diff --git a/webkit/data/layout_test_results/common/LayoutTests/editing/pasteboard/README b/webkit/data/layout_test_results/common/LayoutTests/editing/pasteboard/README index 4c2a8ad..39e9fb3 100644 --- a/webkit/data/layout_test_results/common/LayoutTests/editing/pasteboard/README +++ b/webkit/data/layout_test_results/common/LayoutTests/editing/pasteboard/README @@ -10,3 +10,9 @@ subframe-dragndrop-1-expected.txt --------------------------------- This test uses double click to select a word and drag it to a new location. We follow Windows convention and include the trailing space on double click. + +copy-standalone-image-expected.txt +---------------------------------- +Rebaselined to account for subtle pixel differences in the test where pixels +are not the main subject and to remove the extra P node that only applies to +Safari/Mac. diff --git a/webkit/data/layout_test_results/common/LayoutTests/editing/pasteboard/copy-standalone-image-expected.txt b/webkit/data/layout_test_results/common/LayoutTests/editing/pasteboard/copy-standalone-image-expected.txt new file mode 100644 index 0000000..357305e --- /dev/null +++ b/webkit/data/layout_test_results/common/LayoutTests/editing/pasteboard/copy-standalone-image-expected.txt @@ -0,0 +1,32 @@ +EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document +EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted +EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 1 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE +EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification +EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification +layer at (0,0) size 800x600 + RenderView at (0,0) size 800x600 +layer at (0,0) size 800x600 + RenderBlock {HTML} at (0,0) size 800x600 + RenderBody {BODY} at (8,8) size 784x584 + RenderBlock {P} at (0,0) size 784x20 + RenderText {#text} at (0,0) size 334x19 + text run at (0,0) width 334: "This is an automatic test of copying an image document." + RenderBlock {P} at (0,36) size 784x40 + RenderText {#text} at (0,0) size 780x39 + text run at (0,0) width 780: "To perform this test manually, click once in the image frame, choose Edit -> Copy then click in the red box and paste the image. If" + text run at (0,20) width 283: "the image pastes successfully the test is passed." + RenderBlock (anonymous) at (0,92) size 784x154 + RenderPartObject {IFRAME} at (0,0) size 304x154 [border: (2px solid #0000FF)] + layer at (0,0) size 300x150 + RenderView at (0,0) size 300x150 + layer at (0,0) size 300x150 + RenderBlock {HTML} at (0,0) size 300x150 + RenderBody {BODY} at (0,0) size 300x150 + RenderImage {IMG} at (0,0) size 76x103 + RenderText {#text} at (0,0) size 0x0 + RenderBlock {DIV} at (0,246) size 784x131 [border: (2px solid #FF0000)] + RenderImage {IMG} at (14,14) size 76x103 + RenderText {#text} at (0,0) size 0x0 +caret: position 1 of child 0 {IMG} of child 7 {DIV} of child 1 {BODY} of child 0 {HTML} of document 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() diff --git a/webkit/tools/layout_tests/test_lists/tests_fixable.txt b/webkit/tools/layout_tests/test_lists/tests_fixable.txt index 868e926..46fabbc 100644 --- a/webkit/tools/layout_tests/test_lists/tests_fixable.txt +++ b/webkit/tools/layout_tests/test_lists/tests_fixable.txt @@ -8,6 +8,7 @@ // Bug 1124548: Copying with no selection is sometimes supposed to work // This test also crashes in debug due to an ASSERT. (see bug 1058654) +// Also skipped by Apple on Windows (rdar://problem/5015941) V8 | KJS # DEFER : LayoutTests/editing/execCommand/copy-without-selection.html = FAIL | CRASH // Bug 1317563: Debug-only test failures following removal of font-metrics @@ -30,6 +31,8 @@ V8 # pending/svg/carto.net/window.svg = PASS | FAIL // onload race condition due to poorly designed test. // Works fine when run stand-alone. Not needed for Beta. +// Also skipped by Apple on Windows, due to intermittent failure +// (rdar://5313536) V8 | KJS # DEFER : LayoutTests/fast/dom/frame-loading-via-document-write.html = FAIL // ----------------------------------------------------------------- @@ -199,10 +202,6 @@ V8 | KJS # DEFER : LayoutTests/editing/selection/designmode-no-caret.html = FAIL // which are intended to be fixed for Beta. V8 | KJS # DEFER : LayoutTests/editing/selection/move-begin-end.html = FAIL -// Bug 845400 Miscellaneous layout issues under editing -// Also skipped by Apple on Windows (rdar://5015941). -V8 | KJS # DEFER : LayoutTests/editing/pasteboard/copy-standalone-image.html = FAIL - // Bug 845400 // The end result looks right, but the event messages differ. // Not critical for Beta, DEFER |