Changeset 85064 in webkit
- Timestamp:
- Apr 27, 2011 11:15:56 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r85063 r85064 1 2011-02-03 Martin Robinson <mrobinson@igalia.com> 2 3 Reviewed by Xan Lopez. 4 5 [GTK] editing/pasteboard/copy-standalone-image.html fails 6 https://bugs.webkit.org/show_bug.cgi?id=53645 7 8 Unskip the test and add new expected results for it. 9 10 * platform/gtk/Skipped: Unskip this test as it is now passing. 11 * platform/gtk/editing/pasteboard/copy-standalone-image-expected.checksum: 12 * platform/gtk/editing/pasteboard/copy-standalone-image-expected.png: 13 * platform/gtk/editing/pasteboard/copy-standalone-image-expected.txt: 14 1 15 2011-04-27 Kenneth Russell <kbr@google.com> 2 16 -
trunk/LayoutTests/platform/gtk/Skipped
r85061 r85064 391 391 fast/forms/select-script-onchange.html 392 392 fast/html/tab-order.html 393 394 # Images do not seem to copy and paste properly395 # https://bugs.webkit.org/show_bug.cgi?id=53645396 editing/pasteboard/copy-standalone-image.html397 393 398 394 # The box isn't empty after a test run with this test. -
trunk/LayoutTests/platform/gtk/editing/pasteboard/copy-standalone-image-expected.txt
r77444 r85064 2 2 EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification 3 3 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification 4 EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted 5 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 6 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification 7 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification 4 8 layer at (0,0) size 800x600 5 9 RenderView at (0,0) size 800x600 … … 23 27 RenderImage {IMG} at (0,0) size 76x103 24 28 RenderText {#text} at (0,0) size 0x0 25 RenderBlock {DIV} at (0,243) size 784x56 [border: (2px solid #FF0000)] 26 caret: position 0 of child 7 {DIV} of body 29 RenderBlock {DIV} at (0,243) size 784x131 [border: (2px solid #FF0000)] 30 RenderImage {IMG} at (14,14) size 76x103 31 RenderText {#text} at (0,0) size 0x0 32 caret: position 1 of child 0 {IMG} of child 7 {DIV} of body -
trunk/Source/WebCore/ChangeLog
r85058 r85064 1 2011-02-03 Martin Robinson <mrobinson@igalia.com> 2 3 Reviewed by Xan Lopez. 4 5 [GTK] editing/pasteboard/copy-standalone-image.html fails 6 https://bugs.webkit.org/show_bug.cgi?id=53645 7 8 When writing an image to the clipboard, also write the URL and title 9 into the markup and URL portion. This change also abstracts a helper 10 imageToMarkup into markup.{cpp/h} from several different locations 11 throughout the platform layer. 12 13 * editing/markup.h: Added new function definition. 14 * editing/markup.cpp: 15 (WebCore::imageToMarkup): Add this function which turns an image URL 16 and element into some markup representing that image, while preserving 17 non-src attributes. 18 * platform/chromium/ClipboardChromium.cpp: Move the imageToMarkup helper 19 to markup.cpp. 20 * platform/gtk/PasteboardGtk.cpp: 21 (WebCore::getURLForImageNode): Add this helper which gets the appropriate 22 image URL for a variety of image tag types. 23 (WebCore::Pasteboard::writeImage): Write the image URL and title to the 24 markup and URL portions of the clipboard. This will ensure that images 25 paste properly back into WebKit. 26 * platform/win/ClipboardWin.cpp: Remove the imageToMarkup helper and the 27 one from markup.h 28 1 29 2011-04-27 Steve Block <steveblock@google.com> 2 30 -
trunk/Source/WebCore/editing/markup.cpp
r84311 r85064 1 1 /* 2 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 3 * Copyright (C) 2008, 2009 Google Inc. 4 * Copyright (C) 2011 Igalia S.L. 3 5 * 4 6 * Redistribution and use in source and binary forms, with or without … … 915 917 } 916 918 917 } 919 String imageToMarkup(const KURL& url, Element* element) 920 { 921 Vector<UChar> markup; 922 append(markup, "<img src=\""); 923 append(markup, url.string()); 924 append(markup, "\""); 925 926 NamedNodeMap* attrs = element->attributes(); 927 unsigned length = attrs->length(); 928 for (unsigned i = 0; i < length; ++i) { 929 Attribute* attr = attrs->attributeItem(i); 930 if (attr->localName() == "src") 931 continue; 932 append(markup, " "); 933 append(markup, attr->localName()); 934 append(markup, "=\""); 935 appendCharactersReplacingEntities(markup, attr->value().characters(), attr->value().length(), EntityMaskInAttributeValue); 936 append(markup, "\""); 937 } 938 939 append(markup, "/>"); 940 return String::adopt(markup); 941 } 942 943 } -
trunk/Source/WebCore/editing/markup.h
r69994 r85064 36 36 class Document; 37 37 class DocumentFragment; 38 class Element; 38 39 class KURL; 39 40 class Node; … … 57 58 58 59 String urlToMarkup(const KURL&, const String& title); 60 String imageToMarkup(const KURL&, Element*); 59 61 } 60 62 -
trunk/Source/WebCore/platform/chromium/ClipboardChromium.cpp
r81620 r85064 196 196 } 197 197 198 static String imageToMarkup(const String& url, Element* element)199 {200 StringBuilder markup;201 markup.append("<img src=\"");202 markup.append(url);203 markup.append('"');204 // Copy over attributes. If we are dragging an image, we expect things like205 // the id to be copied as well.206 NamedNodeMap* attrs = element->attributes();207 unsigned length = attrs->length();208 for (unsigned i = 0; i < length; ++i) {209 Attribute* attr = attrs->attributeItem(i);210 if (attr->localName() == "src")211 continue;212 markup.append(' ');213 markup.append(attr->localName());214 markup.append("=\"");215 String escapedAttr = attr->value();216 escapedAttr.replace("\"", """);217 markup.append(escapedAttr);218 markup.append('"');219 }220 221 markup.append("/>");222 return markup.toString();223 }224 225 198 static CachedImage* getCachedImage(Element* element) 226 199 { … … 282 255 return; 283 256 284 StringfullURL = frame->document()->completeURL(stripLeadingAndTrailingHTMLSpaces(imageURL));257 KURL fullURL = frame->document()->completeURL(stripLeadingAndTrailingHTMLSpaces(imageURL)); 285 258 if (fullURL.isEmpty()) 286 259 return; -
trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp
r75009 r85064 24 24 #include "DocumentFragment.h" 25 25 #include "Frame.h" 26 #include "GOwnPtrGtk.h" 27 #include "HTMLNames.h" 28 #include "HTMLParserIdioms.h" 29 #include "KURL.h" 26 30 #include "NotImplemented.h" 27 31 #include "PlatformString.h" … … 29 33 #include "Image.h" 30 34 #include "RenderImage.h" 31 #include "KURL.h"32 35 #include "markup.h" 36 #include <gtk/gtk.h> 33 37 #include <wtf/gobject/GRefPtr.h> 34 38 #include <wtf/text/CString.h> 35 39 36 #include <gtk/gtk.h> 40 #if ENABLE(SVG) 41 #include "SVGNames.h" 42 #include "XLinkNames.h" 43 #endif 37 44 38 45 namespace WebCore { … … 92 99 } 93 100 94 void Pasteboard::writeImage(Node* node, const KURL&, const String&)101 static KURL getURLForImageNode(Node* node) 95 102 { 96 GtkClipboard* clipboard = gtk_clipboard_get_for_display(gdk_display_get_default(), GDK_SELECTION_CLIPBOARD); 103 // FIXME: Later this code should be shared with Chromium somehow. Chances are all platforms want it. 104 AtomicString urlString; 105 if (node->hasTagName(HTMLNames::imgTag) || node->hasTagName(HTMLNames::inputTag)) 106 urlString = static_cast<Element*>(node)->getAttribute(HTMLNames::srcAttr); 107 #if ENABLE(SVG) 108 else if (node->hasTagName(SVGNames::imageTag)) 109 urlString = static_cast<Element*>(node)->getAttribute(XLinkNames::hrefAttr); 110 #endif 111 else if (node->hasTagName(HTMLNames::embedTag) || node->hasTagName(HTMLNames::objectTag)) { 112 Element* element = static_cast<Element*>(node); 113 urlString = element->getAttribute(element->imageSourceAttributeName()); 114 } 115 return urlString.isEmpty() ? KURL() : node->document()->completeURL(stripLeadingAndTrailingHTMLSpaces(urlString)); 116 } 97 117 98 ASSERT(node && node->renderer() && node->renderer()->isImage()); 118 void Pasteboard::writeImage(Node* node, const KURL&, const String& title) 119 { 120 ASSERT(node); 121 ASSERT(node->renderer()); 99 122 RenderImage* renderer = toRenderImage(node->renderer()); 100 123 CachedImage* cachedImage = renderer->cachedImage(); … … 104 127 ASSERT(image); 105 128 129 GtkClipboard* clipboard = gtk_clipboard_get_for_display(gdk_display_get_default(), GDK_SELECTION_CLIPBOARD); 130 DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard); 131 132 KURL url = getURLForImageNode(node); 133 if (!url.isEmpty()) { 134 dataObject->setURL(url, title); 135 136 // This image may be an SVG, embed, or object tag, so do not write the image 137 // tag markup in those cases. Eventually we may want to support passing markup 138 // for these tag types. 139 if (node->hasTagName(HTMLNames::imgTag)) 140 dataObject->setMarkup(imageToMarkup(url, static_cast<Element*>(node))); 141 } 142 106 143 GRefPtr<GdkPixbuf> pixbuf = adoptGRef(image->getGdkPixbuf()); 107 DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard);108 144 dataObject->setImage(pixbuf.get()); 145 109 146 m_helper->writeClipboardContents(clipboard); 110 147 } -
trunk/Source/WebCore/platform/win/ClipboardWin.cpp
r83067 r85064 632 632 } 633 633 634 static String imageToMarkup(const String& url)635 {636 String markup("<img src=\"");637 markup.append(url);638 markup.append("\"/>");639 return markup;640 }641 642 634 static CachedImage* getCachedImage(Element* element) 643 635 { … … 699 691 return; 700 692 701 String fullURL = frame->document()->completeURL(stripLeadingAndTrailingHTMLSpaces(imageURL)).string();693 KURL fullURL = frame->document()->completeURL(stripLeadingAndTrailingHTMLSpaces(imageURL)); 702 694 if (fullURL.isEmpty()) 703 695 return; … … 707 699 // Put img tag on the clipboard referencing the image 708 700 Vector<char> data; 709 markupToCFHTML(imageToMarkup(fullURL ), "", data);701 markupToCFHTML(imageToMarkup(fullURL, element), "", data); 710 702 medium.hGlobal = createGlobalData(data); 711 703 if (medium.hGlobal && FAILED(m_writableDataObject->SetData(htmlFormat(), &medium, TRUE)))
Note: See TracChangeset
for help on using the changeset viewer.