diff options
author | Ben Murdoch <benm@google.com> | 2011-06-02 12:07:03 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-06-10 10:47:21 +0100 |
commit | 2daae5fd11344eaa88a0d92b0f6d65f8d2255c00 (patch) | |
tree | e4964fbd1cb70599f7718ff03e50ea1dab33890b /Source/WebCore/platform/chromium | |
parent | 87bdf0060a247bfbe668342b87e0874182e0ffa9 (diff) | |
download | external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.zip external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.gz external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.bz2 |
Merge WebKit at r84325: Initial merge by git.
Change-Id: Ic1a909300ecc0a13ddc6b4e784371d2ac6e3d59b
Diffstat (limited to 'Source/WebCore/platform/chromium')
6 files changed, 38 insertions, 3 deletions
diff --git a/Source/WebCore/platform/chromium/ClipboardMimeTypes.cpp b/Source/WebCore/platform/chromium/ClipboardMimeTypes.cpp index 27e68ff..94ce27d 100644 --- a/Source/WebCore/platform/chromium/ClipboardMimeTypes.cpp +++ b/Source/WebCore/platform/chromium/ClipboardMimeTypes.cpp @@ -41,5 +41,6 @@ const char mimeTypeURL[] = "url"; const char mimeTypeTextURIList[] = "text/uri-list"; const char mimeTypeDownloadURL[] = "downloadurl"; const char mimeTypeFiles[] = "Files"; +const char mimeTypeImagePng[] = "image/png"; } // namespace WebCore diff --git a/Source/WebCore/platform/chromium/ClipboardMimeTypes.h b/Source/WebCore/platform/chromium/ClipboardMimeTypes.h index 31e2d3e..3e4ab50 100644 --- a/Source/WebCore/platform/chromium/ClipboardMimeTypes.h +++ b/Source/WebCore/platform/chromium/ClipboardMimeTypes.h @@ -41,6 +41,7 @@ extern const char mimeTypeURL[]; extern const char mimeTypeTextURIList[]; extern const char mimeTypeDownloadURL[]; extern const char mimeTypeFiles[]; +extern const char mimeTypeImagePng[]; } // namespace WebCore diff --git a/Source/WebCore/platform/chromium/DataTransferItemChromium.cpp b/Source/WebCore/platform/chromium/DataTransferItemChromium.cpp index 7857336..24b498e 100644 --- a/Source/WebCore/platform/chromium/DataTransferItemChromium.cpp +++ b/Source/WebCore/platform/chromium/DataTransferItemChromium.cpp @@ -33,9 +33,11 @@ #if ENABLE(DATA_TRANSFER_ITEMS) +#include "Blob.h" #include "Clipboard.h" #include "ClipboardMimeTypes.h" #include "PlatformBridge.h" +#include "SharedBuffer.h" #include "StringCallback.h" namespace WebCore { @@ -88,6 +90,8 @@ void DataTransferItemChromium::getAsString(PassRefPtr<StringCallback> callback) callback->scheduleCallback(m_context, m_data); return; } + + ASSERT(m_source == PasteboardSource); // This is ugly but there's no real alternative. if (m_type == mimeTypeTextPlain) { callback->scheduleCallback(m_context, PlatformBridge::clipboardReadPlainText(PasteboardPrivate::StandardBuffer)); @@ -103,6 +107,33 @@ void DataTransferItemChromium::getAsString(PassRefPtr<StringCallback> callback) ASSERT_NOT_REACHED(); } +PassRefPtr<Blob> DataTransferItemChromium::getAsFile() +{ + if (m_source == InternalSource) + return 0; + + ASSERT(m_source == PasteboardSource); + if (m_type == mimeTypeImagePng) { + // FIXME: This is pretty inefficient. We copy the data from the browser + // to the renderer. We then place it in a blob in WebKit, which + // registers it and copies it *back* to the browser. When a consumer + // wants to read the data, we then copy the data back into the renderer. + // https://bugs.webkit.org/show_bug.cgi?id=58107 has been filed to track + // improvements to this code (in particular, add a registerClipboardBlob + // method to the blob registry; that way the data is only copied over + // into the renderer when it's actually read, not when the blob is + // initially constructed). + RefPtr<SharedBuffer> data = PlatformBridge::clipboardReadImage(PasteboardPrivate::StandardBuffer); + RefPtr<RawData> rawData = RawData::create(); + rawData->mutableData()->append(data->data(), data->size()); + OwnPtr<BlobData> blobData = BlobData::create(); + blobData->appendData(rawData, 0, -1); + blobData->setContentType(mimeTypeImagePng); + return Blob::create(blobData.release(), data->size()); + } + return 0; +} + } // namespace WebCore #endif // ENABLE(DATA_TRANSFER_ITEMS) diff --git a/Source/WebCore/platform/chromium/DataTransferItemChromium.h b/Source/WebCore/platform/chromium/DataTransferItemChromium.h index 77f74f2..66be96e 100644 --- a/Source/WebCore/platform/chromium/DataTransferItemChromium.h +++ b/Source/WebCore/platform/chromium/DataTransferItemChromium.h @@ -51,6 +51,7 @@ public: virtual String type() const; virtual void getAsString(PassRefPtr<StringCallback>); + virtual PassRefPtr<Blob> getAsFile(); private: enum DataSource { diff --git a/Source/WebCore/platform/chromium/PlatformBridge.h b/Source/WebCore/platform/chromium/PlatformBridge.h index 1c3ccbd..3a04617 100644 --- a/Source/WebCore/platform/chromium/PlatformBridge.h +++ b/Source/WebCore/platform/chromium/PlatformBridge.h @@ -98,6 +98,7 @@ public: static String clipboardReadPlainText(PasteboardPrivate::ClipboardBuffer); static void clipboardReadHTML(PasteboardPrivate::ClipboardBuffer, String*, KURL*); + static PassRefPtr<SharedBuffer> clipboardReadImage(PasteboardPrivate::ClipboardBuffer); // Only the clipboardRead functions take a buffer argument because // Chromium currently uses a different technique to write to alternate diff --git a/Source/WebCore/platform/chromium/PopupMenuChromium.cpp b/Source/WebCore/platform/chromium/PopupMenuChromium.cpp index e83ebe4..af97ecf 100644 --- a/Source/WebCore/platform/chromium/PopupMenuChromium.cpp +++ b/Source/WebCore/platform/chromium/PopupMenuChromium.cpp @@ -571,10 +571,10 @@ void PopupContainer::refresh(const IntRect& targetControlRect) location.move(0, targetControlRect.height()); listBox()->updateFromElement(); - // Store the original height to check if we need to request the location. - int originalHeight = height(); + // Store the original size to check if we need to request the location. + IntSize originalSize = size(); IntRect widgetRect = layoutAndCalculateWidgetRect(targetControlRect.height(), location); - if (originalHeight != widgetRect.height()) + if (originalSize != widgetRect.size()) setFrameRect(widgetRect); invalidate(); |