Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
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;
}