void EventSender::reset()
{
    // The test should have finished a drag and the mouse button state.
    ASSERT(currentDragData.isNull());
    currentDragData.reset();
    currentDragEffect = WebKit::WebDragOperationNone;
    currentDragEffectsAllowed = WebKit::WebDragOperationNone;
    pressedButton = WebMouseEvent::ButtonNone;
    dragMode.set(true);
#if OS(WINDOWS)
    wmKeyDown.set(WM_KEYDOWN);
    wmKeyUp.set(WM_KEYUP);
    wmChar.set(WM_CHAR);
    wmDeadChar.set(WM_DEADCHAR);
    wmSysKeyDown.set(WM_SYSKEYDOWN);
    wmSysKeyUp.set(WM_SYSKEYUP);
    wmSysChar.set(WM_SYSCHAR);
    wmSysDeadChar.set(WM_SYSDEADCHAR);
#endif
    lastMousePos = WebPoint(0, 0);
    lastClickTimeSec = 0;
    lastClickPos = WebPoint(0, 0);
    clickCount = 0;
    lastButtonType = WebMouseEvent::ButtonNone;
    timeOffsetMs = 0;
    touchModifiers = 0;
    touchPoints.clear();
    m_taskList.revokeAll();
}
Exemple #2
0
void EventSender::beginDragWithFiles(const CppArgumentList& arguments, CppVariant* result)
{
    currentDragData.initialize();
    Vector<string> files = arguments[0].toStringVector();
    Vector<WebString> absoluteFilenames;
    for (size_t i = 0; i < files.size(); ++i) {
        WebDragData::Item item;
        item.storageType = WebDragData::Item::StorageTypeFilename;
        item.filenameData = webkit_support::GetAbsoluteWebStringFromUTF8Path(files[i]);
        currentDragData.addItem(item);
        absoluteFilenames.append(item.filenameData);
    }
    currentDragData.setFilesystemId(webkit_support::RegisterIsolatedFileSystem(absoluteFilenames));
    currentDragEffectsAllowed = WebKit::WebDragOperationCopy;

    // Provide a drag source.
    webview()->dragTargetDragEnter(currentDragData, lastMousePos, lastMousePos, currentDragEffectsAllowed);

    // dragMode saves events and then replays them later. We don't need/want that.
    dragMode.set(false);

    // Make the rest of eventSender think a drag is in progress.
    pressedButton = WebMouseEvent::ButtonLeft;

    result->setNull();
}
Exemple #3
0
WebDragData DataObject::toWebDragData() {
  WebDragData data;
  data.initialize();
  data.setModifierKeyState(m_modifiers);
  WebVector<WebDragData::Item> itemList(length());

  for (size_t i = 0; i < length(); ++i) {
    DataObjectItem* originalItem = item(i);
    WebDragData::Item item;
    if (originalItem->kind() == DataObjectItem::StringKind) {
      item.storageType = WebDragData::Item::StorageTypeString;
      item.stringType = originalItem->type();
      item.stringData = originalItem->getAsString();
    } else if (originalItem->kind() == DataObjectItem::FileKind) {
      if (originalItem->sharedBuffer()) {
        item.storageType = WebDragData::Item::StorageTypeBinaryData;
        item.binaryData = originalItem->sharedBuffer();
      } else if (originalItem->isFilename()) {
        Blob* blob = originalItem->getAsFile();
        if (blob->isFile()) {
          File* file = toFile(blob);
          if (file->hasBackingFile()) {
            item.storageType = WebDragData::Item::StorageTypeFilename;
            item.filenameData = file->path();
            item.displayNameData = file->name();
          } else if (!file->fileSystemURL().isEmpty()) {
            item.storageType = WebDragData::Item::StorageTypeFileSystemFile;
            item.fileSystemURL = file->fileSystemURL();
            item.fileSystemFileSize = file->size();
          } else {
            // FIXME: support dragging constructed Files across renderers, see
            // http://crbug.com/394955
            item.storageType = WebDragData::Item::StorageTypeString;
            item.stringType = "text/plain";
            item.stringData = file->name();
          }
        } else {
          ASSERT_NOT_REACHED();
        }
      } else {
        ASSERT_NOT_REACHED();
      }
    } else {
      ASSERT_NOT_REACHED();
    }
    item.title = originalItem->title();
    item.baseURL = originalItem->baseURL();
    itemList[i] = item;
  }
  data.swapItems(itemList);
  return data;
}
void EventSender::doMouseMove(const WebMouseEvent& e)
{
    lastMousePos = WebPoint(e.x, e.y);

    webview()->handleInputEvent(e);

    if (pressedButton == WebMouseEvent::ButtonNone || currentDragData.isNull())
        return;
    WebPoint clientPoint(e.x, e.y);
    WebPoint screenPoint(e.globalX, e.globalY);
    currentDragEffect = webview()->dragTargetDragOver(clientPoint, screenPoint, currentDragEffectsAllowed);
}
Exemple #5
0
void EventSender::dumpFilenameBeingDragged(const CppArgumentList&, CppVariant*)
{
    WebString filename;
    WebVector<WebDragData::Item> items = currentDragData.items();
    for (size_t i = 0; i < items.size(); ++i) {
        if (items[i].storageType == WebDragData::Item::StorageTypeBinaryData) {
            filename = items[i].title;
            break;
        }
    }
    printf("Filename being dragged: %s\n", filename.utf8().data());
}
void EventSender::doMouseUp(const WebMouseEvent& e)
{
    webview()->handleInputEvent(e);

    pressedButton = WebMouseEvent::ButtonNone;
    lastClickTimeSec = e.timeStampSeconds;
    lastClickPos = lastMousePos;

    // If we're in a drag operation, complete it.
    if (currentDragData.isNull())
        return;
    WebPoint clientPoint(e.x, e.y);
    WebPoint screenPoint(e.globalX, e.globalY);

    currentDragEffect = webview()->dragTargetDragOver(clientPoint, screenPoint, currentDragEffectsAllowed);
    if (currentDragEffect)
        webview()->dragTargetDrop(clientPoint, screenPoint);
    else
        webview()->dragTargetDragLeave();
    webview()->dragSourceEndedAt(clientPoint, screenPoint, currentDragEffect);
    webview()->dragSourceSystemDragEnded();

    currentDragData.reset();
}
Exemple #7
0
void EventSender::dumpFilenameBeingDragged(const CppArgumentList&, CppVariant*)
{
    printf("Filename being dragged: %s\n", currentDragData.fileContentFilename().utf8().data());
}