コード例 #1
0
PassRefPtr<DocumentFragment> DragController::createFragmentFromDragData(DragData& dragData, Frame& frame, Range&, bool /*allowPlainText*/, bool& /*chosePlainText*/)
{
    if (!dragData.platformData()->hasMarkup() || !frame.document())
        return nullptr;

    return createFragmentFromMarkup(*frame.document(), dragData.platformData()->markup(), "");
}
コード例 #2
0
void webkitWebViewBaseStartDrag(WebKitWebViewBase* webViewBase, const DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
{
    WebKitWebViewBasePrivate* priv = webViewBase->priv;

    RefPtr<DataObjectGtk> dataObject = adoptRef(dragData.platformData());
    GRefPtr<GtkTargetList> targetList = adoptGRef(PasteboardHelper::defaultPasteboardHelper()->targetListForDataObject(dataObject.get()));
    GUniquePtr<GdkEvent> currentEvent(gtk_get_current_event());
    GdkDragContext* context = gtk_drag_begin(GTK_WIDGET(webViewBase),
                                             targetList.get(),
                                             dragOperationToGdkDragActions(dragData.draggingSourceOperationMask()),
                                             1, /* button */
                                             currentEvent.get());
    priv->dragAndDropHelper.startedDrag(context, dataObject.get());


    // A drag starting should prevent a double-click from happening. This might
    // happen if a drag is followed very quickly by another click (like in the DRT).
    priv->clickCounter.reset();

    if (dragImage) {
        RefPtr<cairo_surface_t> image(dragImage->createCairoSurface());
        priv->dragIcon.setImage(image.get());
        priv->dragIcon.useForDrag(context);
    } else
        gtk_drag_set_icon_default(context);
}
コード例 #3
0
void ArgumentCoder<DragData>::encode(ArgumentEncoder* encoder, const DragData& dragData)
{
    encoder->encode(dragData.clientPosition());
    encoder->encode(dragData.globalPosition());
    encoder->encode(static_cast<uint64_t>(dragData.draggingSourceOperationMask()));
    encoder->encode(static_cast<uint64_t>(dragData.flags()));

    DataObjectGtk* platformData = dragData.platformData();
    encoder->encode(static_cast<bool>(platformData));
    if (platformData)
        encodeDataObject(encoder, platformData);
}
コード例 #4
0
ファイル: DragControllerEfl.cpp プロジェクト: eocanha/webkit
DragOperation DragController::dragOperation(const DragData& dragData)
{
    if (dragData.containsURL())
        return DragOperationCopy;

    return DragOperationNone;
}
コード例 #5
0
ファイル: FileInputType.cpp プロジェクト: Nord001/webkit.js
bool FileInputType::receiveDroppedFiles(const DragData& dragData)
{
    Vector<String> paths;
    dragData.asFilenames(paths);
    if (paths.isEmpty())
        return false;

    HTMLInputElement* input = &element();
#if ENABLE(DIRECTORY_UPLOAD)
    if (input->fastHasAttribute(webkitdirectoryAttr)) {
        receiveDropForDirectoryUpload(paths);
        return true;
    }
#endif

    Vector<FileChooserFileInfo> files;
    for (unsigned i = 0; i < paths.size(); ++i)
        files.append(FileChooserFileInfo(paths[i]));

    if (input->fastHasAttribute(multipleAttr))
        filesChosen(files);
    else {
        Vector<FileChooserFileInfo> firstFileOnly;
        firstFileOnly.append(files[0]);
        filesChosen(firstFileOnly);
    }
    return true;
}
コード例 #6
0
ファイル: DragControllerGtk.cpp プロジェクト: eocanha/webkit
DragOperation DragController::dragOperation(const DragData& dragData)
{
    // FIXME: This logic is incomplete
    if (dragData.containsURL())
        return DragOperationCopy;

    return DragOperationNone;
}
コード例 #7
0
ファイル: DragControllerWin.cpp プロジェクト: eocanha/webkit
DragOperation DragController::dragOperation(const DragData& dragData)
{
    //FIXME: to match the macos behaviour we should return DragOperationNone
    //if we are a modal window, we are the drag source, or the window is an attached sheet
    //If this can be determined from within WebCore operationForDrag can be pulled into 
    //WebCore itself
    return dragData.containsURL() && !m_didInitiateDrag ? DragOperationCopy : DragOperationNone;
}
コード例 #8
0
ファイル: WebDragClient.cpp プロジェクト: clbr/webkitfltk
DragDestinationAction WebDragClient::actionMaskForDrag(DragData& dragData)
{
    COMPtr<IWebUIDelegate> delegateRef = 0;
    //Default behaviour (eg. no delegate, or callback not implemented) is to allow
    //any action
    WebDragDestinationAction mask = WebDragDestinationActionAny;
    if (SUCCEEDED(m_webView->uiDelegate(&delegateRef)))
        delegateRef->dragDestinationActionMaskForDraggingInfo(m_webView, dragData.platformData(), &mask);

    return (DragDestinationAction)mask;
}
コード例 #9
0
ファイル: FileInputTypeTest.cpp プロジェクト: kjthegod/WebKit
TEST(FileInputTypeTest, ignoreDroppedNonNativeFiles)
{
    const RefPtrWillBeRawPtr<Document> document = Document::create();
    const RefPtrWillBeRawPtr<HTMLInputElement> input =
        HTMLInputElement::create(*document, nullptr, false);
    const RefPtrWillBeRawPtr<InputType> fileInput = FileInputType::create(*input);

    const RefPtrWillBeRawPtr<DataObject> nativeFileRawDragData = DataObject::create();
    const DragData nativeFileDragData(nativeFileRawDragData.get(), IntPoint(), IntPoint(), DragOperationCopy);
    nativeFileDragData.platformData()->add(File::create("/native/path"));
    nativeFileDragData.platformData()->setFilesystemId("fileSystemId");
    fileInput->receiveDroppedFiles(&nativeFileDragData);
    EXPECT_EQ("fileSystemId", fileInput->droppedFileSystemId());
    ASSERT_EQ(1u, fileInput->files()->length());
    EXPECT_EQ(String("/native/path"), fileInput->files()->item(0)->path());

    const RefPtrWillBeRawPtr<DataObject> nonNativeFileRawDragData = DataObject::create();
    const DragData nonNativeFileDragData(nonNativeFileRawDragData.get(), IntPoint(), IntPoint(), DragOperationCopy);
    FileMetadata metadata;
    metadata.length = 1234;
    const KURL url(ParsedURLStringTag(), "filesystem:http://example.com/isolated/hash/non-native-file");
    nonNativeFileDragData.platformData()->add(File::createForFileSystemFile(url, metadata, File::IsUserVisible));
    nonNativeFileDragData.platformData()->setFilesystemId("fileSystemId");
    fileInput->receiveDroppedFiles(&nonNativeFileDragData);
    // Dropping non-native files should not change the existing files.
    EXPECT_EQ("fileSystemId", fileInput->droppedFileSystemId());
    ASSERT_EQ(1u, fileInput->files()->length());
    EXPECT_EQ(String("/native/path"), fileInput->files()->item(0)->path());
}
コード例 #10
0
ファイル: DragAndDropHandler.cpp プロジェクト: sinoory/webv8
void DragAndDropHandler::startDrag(const DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
{
    RefPtr<DataObjectGtk> dataObject = adoptRef(dragData.platformData());
    GRefPtr<GtkTargetList> targetList = adoptGRef(PasteboardHelper::defaultPasteboardHelper()->targetListForDataObject(dataObject.get()));
    GUniquePtr<GdkEvent> currentEvent(gtk_get_current_event());

    GdkDragContext* context = gtk_drag_begin(m_page.viewWidget(), targetList.get(), dragOperationToGdkDragActions(dragData.draggingSourceOperationMask()),
        GDK_BUTTON_PRIMARY, currentEvent.get());
    m_draggingDataObjects.set(context, dataObject.get());

    if (dragImage) {
        RefPtr<cairo_surface_t> image(dragImage->createCairoSurface());
        m_dragIcon.setImage(image.get());
        m_dragIcon.useForDrag(context);
    } else
        gtk_drag_set_icon_default(context);
}
コード例 #11
0
bool FileInputType::receiveDroppedFiles(const DragData& dragData)
{
    Vector<String> paths;
    dragData.asFilenames(paths);
    if (paths.isEmpty())
        return false;

    HTMLInputElement* input = &element();

    Vector<FileChooserFileInfo> files;
    for (auto& path : paths)
        files.append(FileChooserFileInfo(path));

    if (input->hasAttributeWithoutSynchronization(multipleAttr))
        filesChosen(files);
    else {
        Vector<FileChooserFileInfo> firstFileOnly;
        firstFileOnly.append(files[0]);
        filesChosen(firstFileOnly);
    }
    return true;
}
コード例 #12
0
Ref<DataTransfer> DataTransfer::createForDragAndDrop(DataTransferAccessPolicy policy, const DragData& dragData)
{
    return adoptRef(*new DataTransfer(policy, Pasteboard::createForDragAndDrop(dragData), DragAndDrop, dragData.containsFiles()));
}
コード例 #13
0
ファイル: WebDragClient.cpp プロジェクト: clbr/webkitfltk
void WebDragClient::willPerformDragDestinationAction(DragDestinationAction action, DragData& dragData)
{
    //Default delegate for willPerformDragDestinationAction has no side effects
    //so we just call the delegate, and don't worry about whether it's implemented
    COMPtr<IWebUIDelegate> delegateRef = 0;
    if (SUCCEEDED(m_webView->uiDelegate(&delegateRef)))
        delegateRef->willPerformDragDestinationAction(m_webView, (WebDragDestinationAction)action, dragData.platformData());
}
コード例 #14
0
PassOwnPtr<Pasteboard> Pasteboard::createForDragAndDrop(const DragData& dragData)
{
    return create(dragData.platformData());
}
コード例 #15
0
ファイル: PasteboardGtk.cpp プロジェクト: cheekiatng/webkit
std::unique_ptr<Pasteboard> Pasteboard::createForDragAndDrop(const DragData& dragData)
{
    return std::make_unique<Pasteboard>(dragData.platformData());
}