Bug 81261 - [chromium] Support file drag out using DataTransferItemList::add(File)
Summary: [chromium] Support file drag out using DataTransferItemList::add(File)
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Daniel Cheng
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-15 13:36 PDT by Daniel Cheng
Modified: 2012-03-23 15:25 PDT (History)
3 users (show)

See Also:


Attachments
Patch (4.59 KB, patch)
2012-03-22 19:38 PDT, Varun Jain
no flags Details | Formatted Diff | Diff
Patch (9.52 KB, patch)
2012-03-23 15:07 PDT, Daniel Cheng
tony: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Cheng 2012-03-15 13:36:34 PDT
Right now, file drag out isn't very well supported. We have downloadurl and the default drag handler for images, but we don't actually support image dragout using the specced method.
Comment 1 Varun Jain 2012-03-22 19:38:23 PDT
Created attachment 133417 [details]
Patch
Comment 2 Tony Chang 2012-03-23 09:43:55 PDT
Comment on attachment 133417 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=133417&action=review

r- for no test.  Please add one to ManualTests or create a layout test.

> Source/WebCore/ChangeLog:8
> +        No new tests. Manually tested that file drag and drop doesnot crash chrome.

Please create a layout test or at least make a manual test and put it in ManualTests.  There are a few other drag&drop tests in that directory already.

> Source/WebCore/platform/chromium/DataTransferItemListChromium.cpp:123
> +    // Note that passing file to createFromFile below transfers ownership of
> +    // it, so file is 0 after this call.
> +    m_itemList.append(DataTransferItemChromium::createFromFile(file));

Are you sure about this comment?  |file| is a ref counted pointer so createFromFile shouldn't delete anything.  Is the order that we add items important here?  Daniel would know.
Comment 3 Rick Byers 2012-03-23 09:58:27 PDT
(In reply to comment #2)
> (From update of attachment 133417 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=133417&action=review
> 
> r- for no test.  Please add one to ManualTests or create a layout test.

Daniel, are you taking this over now that you're back in the office?

> > Source/WebCore/platform/chromium/DataTransferItemListChromium.cpp:123
> > +    // Note that passing file to createFromFile below transfers ownership of
> > +    // it, so file is 0 after this call.
> > +    m_itemList.append(DataTransferItemChromium::createFromFile(file));
> 
> Are you sure about this comment?  |file| is a ref counted pointer so createFromFile shouldn't delete anything.  Is the order that we add items important here?  Daniel would know.

Moving this definitely fixed the crash I saw: crbug.com/119591
I'm new to these WebKit types, but http://www.webkit.org/coding/RefPtr.html says that assigning a PassRefPtr to a RefPtr clears the original pointer, and inside createFromFile we have:
  item->m_file = file;
Transferring ownership of the File to the DataTransferItemChromium.

I assumed the order of the items was irrelevant, but Daniel is the expert.
Comment 4 Tony Chang 2012-03-23 10:14:44 PDT
(In reply to comment #3)
> (In reply to comment #2)
> > (From update of attachment 133417 [details] [details])
> > View in context: https://bugs.webkit.org/attachment.cgi?id=133417&action=review
> > > Source/WebCore/platform/chromium/DataTransferItemListChromium.cpp:123
> > > +    // Note that passing file to createFromFile below transfers ownership of
> > > +    // it, so file is 0 after this call.
> > > +    m_itemList.append(DataTransferItemChromium::createFromFile(file));
> > 
> > Are you sure about this comment?  |file| is a ref counted pointer so createFromFile shouldn't delete anything.  Is the order that we add items important here?  Daniel would know.
> 
> Moving this definitely fixed the crash I saw: crbug.com/119591
> I'm new to these WebKit types, but http://www.webkit.org/coding/RefPtr.html says that assigning a PassRefPtr to a RefPtr clears the original pointer, and inside createFromFile we have:
>   item->m_file = file;
> Transferring ownership of the File to the DataTransferItemChromium.

createFromFile gets a copy of PassRefPtr. The original copy in DataTransferItemListChromium is unmodified.
Comment 5 Daniel Cheng 2012-03-23 15:07:33 PDT
Created attachment 133568 [details]
Patch
Comment 6 Tony Chang 2012-03-23 15:13:18 PDT
Comment on attachment 133568 [details]
Patch

Will this test pass on other ports or should it be in the Skipped files?
Comment 7 Daniel Cheng 2012-03-23 15:25:26 PDT
Committed r111919: <http://trac.webkit.org/changeset/111919>