[Webkit-unassigned] [Bug 29666] ClipboardWin::files() isn't implemented in Windows

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Sep 29 08:09:38 PDT 2009


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


Adam Roben (aroben) <aroben at apple.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #40274|review?                     |review-
               Flag|                            |




--- Comment #9 from Adam Roben (aroben) <aroben at apple.com>  2009-09-29 08:09:38 PDT ---
(From update of attachment 40274)
>  PassRefPtr<FileList> ClipboardWin::files() const
>  {
> -    notImplemented();
> -    return 0;
> +    if (policy() != ClipboardReadable && policy() != ClipboardTypesReadable)
> +      return FileList::create();
> +
> +    if (!m_dataObject)
> +        return FileList::create();
> +
> +    RefPtr<FileList> files = FileList::create();
> +    STGMEDIUM medium;
> +    if (FAILED(m_dataObject->GetData(cfHDropFormat(), &medium)))
> +        return files.release();
> +
> +    HDROP hdrop = reinterpret_cast<HDROP>(GlobalLock(medium.hGlobal));
> +    if (!hdrop)
> +        return files.release();

I think it would be more consistent to move the declaration of files to the top
of the function and return files.release() in all the bail-out cases.

> +    WCHAR filename[MAX_PATH];
> +    UINT fileCount = DragQueryFileW(hdrop, (UINT)0xFFFFFFFF, 0, 0);

I don't think you need the (UINT) cast here. If you do, please use static_cast
instead of a C-style cast.

> +    for (UINT i = 0; i < fileCount; i++) {
> +        if (!DragQueryFileW(hdrop, i, filename, ARRAYSIZE(filename)))
> +            continue;
> +        files->append(File::create(reinterpret_cast<UChar*>(filename)));
> +    }
> +
> +    DragFinish(hdrop);
> +    GlobalUnlock(medium.hGlobal);
> +    return files.release();
>  }

http://msdn.microsoft.com/en-us/library/bb776904(VS.85).aspx#extracting_filenames
says that you should be calling ReleaseStgMedium instead of DragFinish. Other
documentation on MSDN leads me to believe that DragFinish should only be called
when handling the WM_DROPFILES message. Sorry for not realizing this sooner!

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list