Commit 37d8a583 authored by jianli@chromium.org's avatar jianli@chromium.org

Add ScriptExecutionContext argument to File/Blob constructors.

https://bugs.webkit.org/show_bug.cgi?id=40587

Reviewed by David Levin.

Remove DragData::createClipboard and add Clipboard::create for it to be
called directly in DragController. This is because we need to pass
Frame pointer to Clipboard class and use it to get ScriptExecutionContext
in order to construct File objects in Clipboard::files().

* bindings/js/SerializedScriptValue.cpp:
(WebCore::DeserializingTreeWalker::convertIfTerminal):
* bindings/v8/SerializedScriptValue.cpp:
(WebCore::ZigZag::Reader::readBlob):
(WebCore::ZigZag::Reader::readFile):
(WebCore::ZigZag::Reader::readFileList):
* dom/Clipboard.h:
* editing/Editor.cpp:
(WebCore::Editor::dispatchCPPEvent):
* editing/Editor.h:
* editing/android/EditorAndroid.cpp:
(WebCore::Editor::newGeneralClipboard):
* editing/brew/EditorBrew.cpp:
(WebCore::Editor::newGeneralClipboard):
* editing/chromium/EditorChromium.cpp:
(WebCore::Editor::newGeneralClipboard):
* editing/haiku/EditorHaiku.cpp:
(WebCore::Editor::newGeneralClipboard):
* editing/mac/EditorMac.mm:
(WebCore::Editor::newGeneralClipboard):
* editing/qt/EditorQt.cpp:
(WebCore::Editor::newGeneralClipboard):
* editing/wx/EditorWx.cpp:
(WebCore::Editor::newGeneralClipboard):
* html/Blob.cpp:
(WebCore::Blob::Blob):
(WebCore::Blob::slice):
* html/Blob.h:
(WebCore::Blob::create):
* html/Blob.idl:
* html/BlobBuilder.cpp:
(WebCore::BlobBuilder::getBlob):
* html/BlobBuilder.h:
* html/BlobBuilder.idl:
* html/File.cpp:
(WebCore::File::File):
* html/File.h:
(WebCore::File::create):
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::appendFormData):
(WebCore::HTMLInputElement::setFileListFromRenderer):
* page/DragController.cpp:
(WebCore::DragController::dragExited):
(WebCore::DragController::performDrag):
(WebCore::DragController::tryDHTMLDrag):
* page/chromium/EventHandlerChromium.cpp:
(WebCore::EventHandler::createDraggingClipboard):
* page/gtk/EventHandlerGtk.cpp:
(WebCore::EventHandler::createDraggingClipboard):
* page/win/EventHandlerWin.cpp:
(WebCore::EventHandler::createDraggingClipboard):
* platform/DragData.h:
* platform/android/ClipboardAndroid.cpp:
(WebCore::Clipboard::create):
* platform/android/DragDataAndroid.cpp:
* platform/brew/ClipboardBrew.cpp:
(WebCore::Clipboard::create):
* platform/brew/DragDataBrew.cpp:
* platform/chromium/ClipboardChromium.cpp:
(WebCore::Clipboard::create):
(WebCore::ClipboardChromium::ClipboardChromium):
(WebCore::ClipboardChromium::create):
(WebCore::ClipboardChromium::files):
* platform/chromium/ClipboardChromium.h:
* platform/chromium/DragDataChromium.cpp:
* platform/efl/ClipboardEfl.cpp:
(WebCore::Editor::newGeneralClipboard):
(WebCore::Clipboard::create):
* platform/efl/DragDataEfl.cpp:
* platform/gtk/ClipboardGtk.cpp:
(WebCore::Editor::newGeneralClipboard):
(WebCore::Clipboard::create):
(WebCore::ClipboardGtk::ClipboardGtk):
(WebCore::ClipboardGtk::files):
* platform/gtk/ClipboardGtk.h:
(WebCore::ClipboardGtk::create):
* platform/gtk/DragDataGtk.cpp:
* platform/haiku/ClipboardHaiku.cpp:
(WebCore::Clipboard::create):
* platform/haiku/DragDataHaiku.cpp:
* platform/mac/ClipboardMac.mm:
(WebCore::Clipboard::create):
(WebCore::ClipboardMac::files):
* platform/mac/DragDataMac.mm:
* platform/qt/ClipboardQt.cpp:
(WebCore::Clipboard::create):
* platform/qt/DragDataQt.cpp:
* platform/win/ClipboardWin.cpp:
(WebCore::Clipboard::create):
(WebCore::ClipboardWin::ClipboardWin):
(WebCore::ClipboardWin::files):
* platform/win/ClipboardWin.h:
(WebCore::ClipboardWin::create):
* platform/win/DragDataWin.cpp:
* platform/win/EditorWin.cpp:
(WebCore::Editor::newGeneralClipboard):
* platform/wince/DragDataWince.cpp:
* platform/wince/EditorWince.cpp:
(WebCore::Editor::newGeneralClipboard):
* platform/wx/ClipboardWx.cpp:
(WebCore::Clipboard::create):
* platform/wx/DragDataWx.cpp:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64152 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e8fdeee1
2010-07-27 Jian Li <jianli@chromium.org>
Reviewed by David Levin.
Add ScriptExecutionContext argument to File/Blob constructors.
https://bugs.webkit.org/show_bug.cgi?id=40587
Remove DragData::createClipboard and add Clipboard::create for it to be
called directly in DragController. This is because we need to pass
Frame pointer to Clipboard class and use it to get ScriptExecutionContext
in order to construct File objects in Clipboard::files().
* bindings/js/SerializedScriptValue.cpp:
(WebCore::DeserializingTreeWalker::convertIfTerminal):
* bindings/v8/SerializedScriptValue.cpp:
(WebCore::ZigZag::Reader::readBlob):
(WebCore::ZigZag::Reader::readFile):
(WebCore::ZigZag::Reader::readFileList):
* dom/Clipboard.h:
* editing/Editor.cpp:
(WebCore::Editor::dispatchCPPEvent):
* editing/Editor.h:
* editing/android/EditorAndroid.cpp:
(WebCore::Editor::newGeneralClipboard):
* editing/brew/EditorBrew.cpp:
(WebCore::Editor::newGeneralClipboard):
* editing/chromium/EditorChromium.cpp:
(WebCore::Editor::newGeneralClipboard):
* editing/haiku/EditorHaiku.cpp:
(WebCore::Editor::newGeneralClipboard):
* editing/mac/EditorMac.mm:
(WebCore::Editor::newGeneralClipboard):
* editing/qt/EditorQt.cpp:
(WebCore::Editor::newGeneralClipboard):
* editing/wx/EditorWx.cpp:
(WebCore::Editor::newGeneralClipboard):
* html/Blob.cpp:
(WebCore::Blob::Blob):
(WebCore::Blob::slice):
* html/Blob.h:
(WebCore::Blob::create):
* html/Blob.idl:
* html/BlobBuilder.cpp:
(WebCore::BlobBuilder::getBlob):
* html/BlobBuilder.h:
* html/BlobBuilder.idl:
* html/File.cpp:
(WebCore::File::File):
* html/File.h:
(WebCore::File::create):
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::appendFormData):
(WebCore::HTMLInputElement::setFileListFromRenderer):
* page/DragController.cpp:
(WebCore::DragController::dragExited):
(WebCore::DragController::performDrag):
(WebCore::DragController::tryDHTMLDrag):
* page/chromium/EventHandlerChromium.cpp:
(WebCore::EventHandler::createDraggingClipboard):
* page/gtk/EventHandlerGtk.cpp:
(WebCore::EventHandler::createDraggingClipboard):
* page/win/EventHandlerWin.cpp:
(WebCore::EventHandler::createDraggingClipboard):
* platform/DragData.h:
* platform/android/ClipboardAndroid.cpp:
(WebCore::Clipboard::create):
* platform/android/DragDataAndroid.cpp:
* platform/brew/ClipboardBrew.cpp:
(WebCore::Clipboard::create):
* platform/brew/DragDataBrew.cpp:
* platform/chromium/ClipboardChromium.cpp:
(WebCore::Clipboard::create):
(WebCore::ClipboardChromium::ClipboardChromium):
(WebCore::ClipboardChromium::create):
(WebCore::ClipboardChromium::files):
* platform/chromium/ClipboardChromium.h:
* platform/chromium/DragDataChromium.cpp:
* platform/efl/ClipboardEfl.cpp:
(WebCore::Editor::newGeneralClipboard):
(WebCore::Clipboard::create):
* platform/efl/DragDataEfl.cpp:
* platform/gtk/ClipboardGtk.cpp:
(WebCore::Editor::newGeneralClipboard):
(WebCore::Clipboard::create):
(WebCore::ClipboardGtk::ClipboardGtk):
(WebCore::ClipboardGtk::files):
* platform/gtk/ClipboardGtk.h:
(WebCore::ClipboardGtk::create):
* platform/gtk/DragDataGtk.cpp:
* platform/haiku/ClipboardHaiku.cpp:
(WebCore::Clipboard::create):
* platform/haiku/DragDataHaiku.cpp:
* platform/mac/ClipboardMac.mm:
(WebCore::Clipboard::create):
(WebCore::ClipboardMac::files):
* platform/mac/DragDataMac.mm:
* platform/qt/ClipboardQt.cpp:
(WebCore::Clipboard::create):
* platform/qt/DragDataQt.cpp:
* platform/win/ClipboardWin.cpp:
(WebCore::Clipboard::create):
(WebCore::ClipboardWin::ClipboardWin):
(WebCore::ClipboardWin::files):
* platform/win/ClipboardWin.h:
(WebCore::ClipboardWin::create):
* platform/win/DragDataWin.cpp:
* platform/win/EditorWin.cpp:
(WebCore::Editor::newGeneralClipboard):
* platform/wince/DragDataWince.cpp:
* platform/wince/EditorWince.cpp:
(WebCore::Editor::newGeneralClipboard):
* platform/wx/ClipboardWx.cpp:
(WebCore::Clipboard::create):
* platform/wx/DragDataWx.cpp:
2010-07-27 Dumitru Daniliuc <dumi@chromium.org>
Reviewed by David Levin.
......@@ -736,18 +736,23 @@ struct DeserializingTreeWalker : public BaseWalker {
return jsNumber(m_exec, value.asDouble());
case SerializedScriptValueData::DateType:
return new (m_exec) DateInstance(m_exec, m_globalObject->dateStructure(), value.asDouble());
case SerializedScriptValueData::FileType:
case SerializedScriptValueData::FileType: {
if (!m_isDOMGlobalObject)
return jsNull();
return toJS(m_exec, static_cast<JSDOMGlobalObject*>(m_globalObject), File::create(value.asString().crossThreadString()));
ScriptExecutionContext* scriptExecutionContext = static_cast<JSDOMGlobalObject*>(m_exec->lexicalGlobalObject())->scriptExecutionContext();
ASSERT(scriptExecutionContext);
return toJS(m_exec, static_cast<JSDOMGlobalObject*>(m_globalObject), File::create(scriptExecutionContext, value.asString().crossThreadString()));
}
case SerializedScriptValueData::FileListType: {
if (!m_isDOMGlobalObject)
return jsNull();
RefPtr<FileList> result = FileList::create();
SerializedFileList* serializedFileList = value.asFileList();
unsigned length = serializedFileList->length();
ScriptExecutionContext* scriptExecutionContext = static_cast<JSDOMGlobalObject*>(m_exec->lexicalGlobalObject())->scriptExecutionContext();
ASSERT(scriptExecutionContext);
for (unsigned i = 0; i < length; i++)
result->append(File::create(serializedFileList->item(i)));
result->append(File::create(scriptExecutionContext, serializedFileList->item(i)));
return toJS(m_exec, static_cast<JSDOMGlobalObject*>(m_globalObject), result.get());
}
case SerializedScriptValueData::ImageDataType: {
......
......@@ -45,6 +45,7 @@
#include "V8FileList.h"
#include "V8ImageData.h"
#include "V8Proxy.h"
#include "V8Utilities.h"
#include <wtf/Assertions.h>
#include <wtf/RefCounted.h>
......@@ -854,7 +855,7 @@ private:
String path;
if (!readWebCoreString(&path))
return false;
PassRefPtr<Blob> blob = Blob::create(path);
PassRefPtr<Blob> blob = Blob::create(getScriptExecutionContext(), path);
*value = toV8(blob);
return true;
}
......@@ -864,7 +865,7 @@ private:
String path;
if (!readWebCoreString(&path))
return false;
PassRefPtr<File> file = File::create(path);
PassRefPtr<File> file = File::create(getScriptExecutionContext(), path);
*value = toV8(file);
return true;
}
......@@ -879,7 +880,7 @@ private:
String path;
if (!readWebCoreString(&path))
return false;
fileList->append(File::create(path));
fileList->append(File::create(getScriptExecutionContext(), path));
}
*value = toV8(fileList);
return true;
......
......@@ -33,11 +33,15 @@
namespace WebCore {
class DragData;
class FileList;
class Frame;
// State available during IE's events for drag and drop and copy/paste
class Clipboard : public RefCounted<Clipboard> {
public:
static PassRefPtr<Clipboard> create(ClipboardAccessPolicy, DragData*, Frame*);
virtual ~Clipboard() { }
// Is this operation a drag-drop or a copy-paste?
......
......@@ -713,7 +713,7 @@ bool Editor::dispatchCPPEvent(const AtomicString &eventType, ClipboardAccessPoli
return true;
target = target->shadowAncestorNode();
RefPtr<Clipboard> clipboard = newGeneralClipboard(policy);
RefPtr<Clipboard> clipboard = newGeneralClipboard(policy, m_frame);
ExceptionCode ec = 0;
RefPtr<Event> evt = ClipboardEvent::create(eventType, true, true, clipboard);
......
......@@ -42,6 +42,7 @@ class DeleteButtonController;
class EditCommand;
class EditorClient;
class EditorInternalCommand;
class Frame;
class HTMLElement;
class HitTestResult;
class KillRing;
......@@ -309,7 +310,7 @@ private:
bool canDeleteRange(Range*) const;
bool canSmartReplaceWithPasteboard(Pasteboard*);
PassRefPtr<Clipboard> newGeneralClipboard(ClipboardAccessPolicy);
PassRefPtr<Clipboard> newGeneralClipboard(ClipboardAccessPolicy, Frame*);
void pasteAsPlainTextWithPasteboard(Pasteboard*);
void pasteWithPasteboard(Pasteboard*, bool allowPlainText);
void replaceSelectionWithFragment(PassRefPtr<DocumentFragment>, bool selectReplacement, bool smartReplace, bool matchStyle);
......
......@@ -31,7 +31,7 @@
namespace WebCore {
PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy)
PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy, Frame*)
{
return new ClipboardAndroid(policy, false);
}
......
......@@ -31,7 +31,7 @@
namespace WebCore {
PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy)
PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy, Frame*)
{
return new ClipboardBrew(policy, false);
}
......
......@@ -33,12 +33,13 @@
#include "ChromiumDataObject.h"
#include "ClipboardChromium.h"
#include "Frame.h"
namespace WebCore {
PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy)
PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy, Frame* frame)
{
return ClipboardChromium::create(false, ChromiumDataObject::create(), policy);
return ClipboardChromium::create(false, ChromiumDataObject::create(), policy, frame);
}
} // namespace WebCore
......@@ -35,7 +35,7 @@
namespace WebCore {
PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy)
PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy, Frame*)
{
return ClipboardHaiku::create(policy, false);
}
......
......@@ -33,9 +33,9 @@
namespace WebCore {
PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy)
PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy, Frame* frame)
{
return ClipboardMac::create(false, [NSPasteboard generalPasteboard], policy, 0);
return ClipboardMac::create(false, [NSPasteboard generalPasteboard], policy, frame);
}
void Editor::showFontPanel()
......
......@@ -39,7 +39,7 @@
namespace WebCore {
PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy)
PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy, Frame*)
{
return ClipboardQt::create(policy);
}
......
......@@ -31,7 +31,7 @@
namespace WebCore {
PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy)
PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy, Frame*)
{
return ClipboardWx::create(policy, true);
}
......
......@@ -36,19 +36,19 @@
namespace WebCore {
Blob::Blob(const String& type, const BlobItemList& items)
Blob::Blob(ScriptExecutionContext*, const String& type, const BlobItemList& items)
: m_type(type)
{
for (size_t i = 0; i < items.size(); ++i)
m_items.append(items[i]);
}
Blob::Blob(const PassRefPtr<BlobItem>& item)
Blob::Blob(ScriptExecutionContext*, const PassRefPtr<BlobItem>& item)
{
m_items.append(item);
}
Blob::Blob(const String& path)
Blob::Blob(ScriptExecutionContext*, const String& path)
{
// Note: this doesn't initialize the type unlike File(path).
m_items.append(FileBlobItem::create(path));
......@@ -71,7 +71,7 @@ const String& Blob::path() const
}
#if ENABLE(BLOB_SLICE)
PassRefPtr<Blob> Blob::slice(long long start, long long length, const String& contentType) const
PassRefPtr<Blob> Blob::slice(ScriptExecutionContext* scriptExecutionContext, long long start, long long length, const String& contentType) const
{
if (start < 0)
start = 0;
......@@ -95,7 +95,7 @@ PassRefPtr<Blob> Blob::slice(long long start, long long length, const String& co
length -= items.last()->size();
start = 0;
}
return Blob::create(contentType, items);
return Blob::create(scriptExecutionContext, contentType, items);
}
#endif // ENABLE(BLOB_SLICE)
......
......@@ -39,19 +39,21 @@
namespace WebCore {
class ScriptExecutionContext;
class Blob : public RefCounted<Blob> {
public:
static PassRefPtr<Blob> create(const String& type, const BlobItemList& items)
static PassRefPtr<Blob> create(ScriptExecutionContext* scriptExecutionContext, const String& type, const BlobItemList& items)
{
return adoptRef(new Blob(type, items));
return adoptRef(new Blob(scriptExecutionContext, type, items));
}
// FIXME: Deprecated method. This is called only from
// bindings/v8/SerializedScriptValue.cpp and the usage in it will become invalid once
// BlobBuilder is introduced.
static PassRefPtr<Blob> create(const String& path)
static PassRefPtr<Blob> create(ScriptExecutionContext* scriptExecutionContext, const String& path)
{
return adoptRef(new Blob(path));
return adoptRef(new Blob(scriptExecutionContext, path));
}
virtual ~Blob() { }
......@@ -66,15 +68,15 @@ public:
const BlobItemList& items() const { return m_items; }
#if ENABLE(BLOB_SLICE)
PassRefPtr<Blob> slice(long long start, long long length, const String& contentType = String()) const;
PassRefPtr<Blob> slice(ScriptExecutionContext*, long long start, long long length, const String& contentType = String()) const;
#endif
protected:
Blob(const String& type, const BlobItemList&);
Blob(const PassRefPtr<BlobItem>&);
Blob(ScriptExecutionContext*, const String& type, const BlobItemList&);
Blob(ScriptExecutionContext*, const PassRefPtr<BlobItem>&);
// FIXME: Deprecated constructor. See also the comment for Blob::create(path).
Blob(const String& path);
Blob(ScriptExecutionContext*, const String& path);
BlobItemList m_items;
String m_type;
......
......@@ -34,8 +34,10 @@ module html {
readonly attribute unsigned long long size;
readonly attribute DOMString type;
#if !defined(LANGUAGE_OBJECTIVE_C)
#if defined(ENABLE_BLOB_SLICE) && ENABLE_BLOB_SLICE
Blob slice(in long long start, in long long length, in [Optional, ConvertUndefinedOrNullToNullString] DOMString contentType);
[CallWith=ScriptExecutionContext] Blob slice(in long long start, in long long length, in [Optional, ConvertUndefinedOrNullToNullString] DOMString contentType);
#endif
#endif
};
......
......@@ -81,9 +81,9 @@ bool BlobBuilder::append(PassRefPtr<Blob> blob)
return false;
}
PassRefPtr<Blob> BlobBuilder::getBlob(const String& contentType) const
PassRefPtr<Blob> BlobBuilder::getBlob(ScriptExecutionContext* scriptExecutionContext, const String& contentType) const
{
return Blob::create(contentType, m_items);
return Blob::create(scriptExecutionContext, contentType, m_items);
}
} // namespace WebCore
......@@ -38,6 +38,7 @@
namespace WebCore {
class Blob;
class ScriptExecutionContext;
typedef int ExceptionCode;
......@@ -49,7 +50,7 @@ public:
bool append(const String& text, ExceptionCode&);
bool append(const String& text, const String& ending, ExceptionCode&);
PassRefPtr<Blob> getBlob(const String& contentType = String()) const;
PassRefPtr<Blob> getBlob(ScriptExecutionContext*, const String& contentType = String()) const;
private:
BlobItemList m_items;
......
......@@ -34,7 +34,9 @@ module html {
GenerateNativeConverter,
NoStaticTables
] BlobBuilder {
Blob getBlob(in [Optional, ConvertUndefinedOrNullToNullString] DOMString contentType);
#if !defined(LANGUAGE_OBJECTIVE_C)
[CallWith=ScriptExecutionContext] Blob getBlob(in [Optional, ConvertUndefinedOrNullToNullString] DOMString contentType);
#endif
void append(in Blob blob);
void append(in DOMString value, in [Optional, ConvertUndefinedOrNullToNullString] DOMString endings) raises (DOMException);
};
......
......@@ -31,15 +31,15 @@
namespace WebCore {
File::File(const String& path)
: Blob(path)
File::File(ScriptExecutionContext* scriptExecutionContext, const String& path)
: Blob(scriptExecutionContext, path)
{
Init();
}
#if ENABLE(DIRECTORY_UPLOAD)
File::File(const String& relativePath, const String& filePath)
: Blob(FileBlobItem::create(filePath, relativePath))
File::File(ScriptExecutionContext* scriptExecutionContext, const String& relativePath, const String& filePath)
: Blob(scriptExecutionContext, FileBlobItem::create(filePath, relativePath))
{
Init();
}
......
......@@ -34,15 +34,15 @@ namespace WebCore {
class File : public Blob {
public:
static PassRefPtr<File> create(const String& path)
static PassRefPtr<File> create(ScriptExecutionContext* scriptExecutionContext, const String& path)
{
return adoptRef(new File(path));
return adoptRef(new File(scriptExecutionContext, path));
}
#if ENABLE(DIRECTORY_UPLOAD)
static PassRefPtr<File> create(const String& relativePath, const String& path)
static PassRefPtr<File> create(ScriptExecutionContext* scriptExecutionContext, const String& relativePath, const String& path)
{
return adoptRef(new File(relativePath, path));
return adoptRef(new File(scriptExecutionContext, relativePath, path));
}
#endif
......@@ -59,11 +59,11 @@ public:
unsigned long long fileSize() const { return size(); }
private:
File(const String& path);
File(ScriptExecutionContext*, const String& path);
void Init();
#if ENABLE(DIRECTORY_UPLOAD)
File(const String& relativePath, const String& path);
File(ScriptExecutionContext*, const String& relativePath, const String& path);
#endif
};
......
......@@ -1342,7 +1342,7 @@ bool HTMLInputElement::appendFormData(FormDataList& encoding, bool multipart)
// If no filename at all is entered, return successful but empty.
// Null would be more logical, but Netscape posts an empty file. Argh.
if (!numFiles) {
encoding.appendBlob(name(), File::create(""));
encoding.appendBlob(name(), File::create(document()->scriptExecutionContext(), ""));
return true;
}
......@@ -1980,15 +1980,15 @@ void HTMLInputElement::setFileListFromRenderer(const Vector<String>& paths)
for (int i = 0; i < size; i++) {
// Normalize backslashes to slashes before exposing the relative path to script.
String relativePath = paths[i].substring(1 + rootPath.length()).replace('\\','/');
m_fileList->append(File::create(relativePath, paths[i]));
m_fileList->append(File::create(document()->scriptExecutionContext(), relativePath, paths[i]));
}
} else {
for (int i = 0; i < size; i++)
m_fileList->append(File::create(paths[i]));
m_fileList->append(File::create(document()->scriptExecutionContext(), paths[i]));
}
#else
for (int i = 0; i < size; i++)
m_fileList->append(File::create(paths[i]));
m_fileList->append(File::create(document()->scriptExecutionContext(), paths[i]));
#endif
setFormControlValueMatchesRenderer(true);
......
......@@ -170,7 +170,7 @@ void DragController::dragExited(DragData* dragData)
if (RefPtr<FrameView> v = mainFrame->view()) {
ClipboardAccessPolicy policy = (!m_documentUnderMouse || m_documentUnderMouse->securityOrigin()->isLocal()) ? ClipboardReadable : ClipboardTypesReadable;
RefPtr<Clipboard> clipboard = dragData->createClipboard(policy);
RefPtr<Clipboard> clipboard = Clipboard::create(policy, dragData, mainFrame);
clipboard->setSourceOperation(dragData->draggingSourceOperationMask());
mainFrame->eventHandler()->cancelDragAndDrop(createMouseEvent(dragData), clipboard.get());
clipboard->setAccessPolicy(ClipboardNumb); // invalidate clipboard here for security
......@@ -193,7 +193,7 @@ bool DragController::performDrag(DragData* dragData)
RefPtr<Frame> mainFrame = m_page->mainFrame();
if (mainFrame->view()) {
// Sending an event can result in the destruction of the view and part.
RefPtr<Clipboard> clipboard = dragData->createClipboard(ClipboardReadable);
RefPtr<Clipboard> clipboard = Clipboard::create(ClipboardReadable, dragData, mainFrame.get());
clipboard->setSourceOperation(dragData->draggingSourceOperationMask());
mainFrame->eventHandler()->performDragAndDrop(createMouseEvent(dragData), clipboard.get());
clipboard->setAccessPolicy(ClipboardNumb); // invalidate clipboard here for security
......@@ -524,7 +524,7 @@ bool DragController::tryDHTMLDrag(DragData* dragData, DragOperation& operation)
return false;
ClipboardAccessPolicy policy = m_documentUnderMouse->securityOrigin()->isLocal() ? ClipboardReadable : ClipboardTypesReadable;
RefPtr<Clipboard> clipboard = dragData->createClipboard(policy);
RefPtr<Clipboard> clipboard = Clipboard::create(policy, dragData, mainFrame.get());
DragOperation srcOpMask = dragData->draggingSourceOperationMask();
clipboard->setSourceOperation(srcOpMask);
......
......@@ -129,7 +129,7 @@ bool EventHandler::eventActivatedView(const PlatformMouseEvent& event) const
PassRefPtr<Clipboard> EventHandler::createDraggingClipboard() const
{
RefPtr<ChromiumDataObject> dataObject = ChromiumDataObject::create();
return ClipboardChromium::create(true, dataObject.get(), ClipboardWritable);
return ClipboardChromium::create(true, dataObject.get(), ClipboardWritable, m_frame);
}
void EventHandler::focusDocumentView()
......
......@@ -96,7 +96,7 @@ bool EventHandler::passWheelEventToWidget(PlatformWheelEvent& event, Widget* wid
PassRefPtr<Clipboard> EventHandler::createDraggingClipboard() const
{
return ClipboardGtk::create(ClipboardWritable, DataObjectGtk::create(), true);
return ClipboardGtk::create(ClipboardWritable, DataObjectGtk::create(), true, m_frame);
}
bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe)
......
......@@ -98,7 +98,7 @@ PassRefPtr<Clipboard> EventHandler::createDraggingClipboard() const
#else
COMPtr<WCDataObject> dataObject;
WCDataObject::createInstance(&dataObject);
return ClipboardWin::create(true, dataObject.get(), ClipboardWritable);
return ClipboardWin::create(true, dataObject.get(), ClipboardWritable, m_frame);
#endif
}
......
......@@ -26,7 +26,6 @@
#ifndef DragData_h
#define DragData_h
#include "ClipboardAccessPolicy.h"
#include "Color.h"
#include "DragActions.h"
#include "IntPoint.h"
......@@ -68,7 +67,6 @@ typedef void* DragDataRef;
namespace WebCore {
class Clipboard;
class Document;
class DocumentFragment;
class KURL;
......@@ -95,7 +93,6 @@ namespace WebCore {
const IntPoint& globalPosition() const { return m_globalPosition; }
DragDataRef platformData() const { return m_platformDragData; }
DragOperation draggingSourceOperationMask() const { return m_draggingSourceOperationMask; }
PassRefPtr<Clipboard> createClipboard(ClipboardAccessPolicy) const;
bool containsURL(FilenameConversionPolicy filenamePolicy = ConvertFilenames) const;
bool containsPlainText() const;
bool containsCompatibleContent() const;
......
......@@ -35,6 +35,11 @@
namespace WebCore {
PassRefPtr<Clipboard> Clipboard::create(ClipboardAccessPolicy, DragData*, Frame*)
{
return 0;
}
ClipboardAndroid::ClipboardAndroid(ClipboardAccessPolicy policy, bool isForDragging)
: Clipboard(policy, isForDragging)
{
......
......@@ -27,7 +27,6 @@
#include "config.h"
#include "DragData.h"
#include "Clipboard.h"
#include "Document.h"
#include "DocumentFragment.h"
......@@ -58,11 +57,6 @@ Color DragData::asColor() const
return Color();
}
PassRefPtr<Clipboard> DragData::createClipboard(ClipboardAccessPolicy) const
{
return 0;
}
bool DragData::containsCompatibleContent() const
{
return false;
......
......@@ -36,6 +36,11 @@
namespace WebCore {
PassRefPtr<Clipboard> Clipboard::create(ClipboardAccessPolicy, DragData*, Frame*)
{
return 0;
}
ClipboardBrew::ClipboardBrew(ClipboardAccessPolicy policy, bool isForDragging)
: Clipboard(policy, isForDragging)
{
......
......@@ -27,7 +27,6 @@
#include "config.h"
#include "DragData.h"