WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
142801
<attachment> should put URLs on the pasteboard so that Finder can accept drops
https://bugs.webkit.org/show_bug.cgi?id=142801
Summary
<attachment> should put URLs on the pasteboard so that Finder can accept drops
Enrica Casucci
Reported
2015-03-17 16:40:52 PDT
Tracks the work required to be able to drag an attachment element out of a WebKit view and into a different target.
rdar://problem/19982527
Attachments
Patch
(34.01 KB, patch)
2015-03-17 16:48 PDT
,
Enrica Casucci
no flags
Details
Formatted Diff
Diff
Patch that fixes builds and style
(34.73 KB, patch)
2015-03-17 17:55 PDT
,
Enrica Casucci
no flags
Details
Formatted Diff
Diff
Patch3
(50.21 KB, patch)
2015-03-18 16:23 PDT
,
Enrica Casucci
no flags
Details
Formatted Diff
Diff
Patch4
(50.57 KB, patch)
2015-03-18 16:36 PDT
,
Enrica Casucci
thorton
: review+
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Enrica Casucci
Comment 1
2015-03-17 16:48:24 PDT
Created
attachment 248886
[details]
Patch
WebKit Commit Bot
Comment 2
2015-03-17 16:49:58 PDT
Attachment 248886
[details]
did not pass style-queue: ERROR: Source/WebCore/page/DragController.cpp:51: Alphabetical sorting problem. [build/include_order] [4] Total errors found: 1 in 26 files If any of these errors are false positives, please file a bug against check-webkit-style.
Enrica Casucci
Comment 3
2015-03-17 16:50:23 PDT
I fixed the include order in DragController.cpp after posting the patch.
Tim Horton
Comment 4
2015-03-17 17:01:33 PDT
Comment on
attachment 248886
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=248886&action=review
> Source/WebCore/page/DragController.cpp:629 > + // Attachment elements can have DragSourceActionNone even if > + // selected, if the selection contains only the attachement element.
This is not a 'why?' comment, but I wish it were.
> Source/WebCore/page/DragController.cpp:759 > + m_draggingAttachmentURL = URL();
Vaguely interesting that you reset m_draggingAttachmentURL here, but this isn't where m_draggingImageURL is reset. But maybe there's a reason!
> Source/WebCore/rendering/HitTestResult.cpp:330 > + return m_innerNonSharedNode->document().completeURL(attachmentFile->path());
This doesn't look right... is it? Is the file relative to the document's URL? Why are we completeURLing?
> Source/WebKit2/UIProcess/mac/PageClientImpl.mm:410 > void PageClientImpl::setPromisedData(const String& pasteboardName, PassRefPtr<SharedBuffer> imageBuffer, const String& filename, const String& extension, const String& title, const String& url, const String& visibleUrl, PassRefPtr<SharedBuffer> archiveBuffer)
It's pretty weird that this function takes an ImageBuffer and we call it even in the non-image case. Maybe it needs a rename and duplication?
> Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm:413 > + RefPtr<SharedMemory> sharedMemoryImage = (!imageHandle.isNull()) ? SharedMemory::create(imageHandle, SharedMemory::ReadOnly) : nullptr;
Ditto here, I think this should be written differently. Maybe split into setPromisedData and setPromisedImage (and setPromisedImage calls setPromisedData after extracting the data?)
> Source/WebKit/mac/Misc/WebNSPasteboardExtras.mm:275 > + NSMutableArray *types = [[NSMutableArray alloc] initWithObjects:NSFilesPromisePboardType, nil];
Isn't this leaking?
> Source/WebKit/mac/Misc/WebNSPasteboardExtras.mm:292 > + [paths.get() addObject:title];
no .get()
Enrica Casucci
Comment 5
2015-03-17 17:55:03 PDT
Created
attachment 248893
[details]
Patch that fixes builds and style
Enrica Casucci
Comment 6
2015-03-17 18:07:32 PDT
(In reply to
comment #4
)
> Comment on
attachment 248886
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=248886&action=review
> > > Source/WebCore/page/DragController.cpp:629 > > + // Attachment elements can have DragSourceActionNone even if > > + // selected, if the selection contains only the attachement element. > > This is not a 'why?' comment, but I wish it were.
I don't understand your comment. This is exactly what we do. What am I missing?
> > > Source/WebCore/page/DragController.cpp:759 > > + m_draggingAttachmentURL = URL(); > > Vaguely interesting that you reset m_draggingAttachmentURL here, but this > isn't where m_draggingImageURL is reset. But maybe there's a reason!
Moved it up simply not to add another #if ENABLE(ATTACHMENT_ELEMENT)
> > > Source/WebCore/rendering/HitTestResult.cpp:330 > > + return m_innerNonSharedNode->document().completeURL(attachmentFile->path()); > > This doesn't look right... is it? Is the file relative to the document's > URL? Why are we completeURLing?
I believe you are right, copy paste mistake.
> > > Source/WebKit2/UIProcess/mac/PageClientImpl.mm:410 > > void PageClientImpl::setPromisedData(const String& pasteboardName, PassRefPtr<SharedBuffer> imageBuffer, const String& filename, const String& extension, const String& title, const String& url, const String& visibleUrl, PassRefPtr<SharedBuffer> archiveBuffer) > > It's pretty weird that this function takes an ImageBuffer and we call it > even in the non-image case. Maybe it needs a rename and duplication? > > > Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm:413 > > + RefPtr<SharedMemory> sharedMemoryImage = (!imageHandle.isNull()) ? SharedMemory::create(imageHandle, SharedMemory::ReadOnly) : nullptr; > > Ditto here, I think this should be written differently. Maybe split into > setPromisedData and setPromisedImage (and setPromisedImage calls > setPromisedData after extracting the data?)
> I was not entirely convinced to duplicate the code, but maybe I should...
> > Source/WebKit/mac/Misc/WebNSPasteboardExtras.mm:275 > > + NSMutableArray *types = [[NSMutableArray alloc] initWithObjects:NSFilesPromisePboardType, nil]; > > Isn't this leaking?
I only moved up an existing line. I've noticed that in many places where declareTypes is called we don't worry about the array we pass.
> > > Source/WebKit/mac/Misc/WebNSPasteboardExtras.mm:292 > > + [paths.get() addObject:title]; > > no .get()
ok.
Tim Horton
Comment 7
2015-03-17 18:14:44 PDT
(In reply to
comment #6
)
> (In reply to
comment #4
) > > Comment on
attachment 248886
[details]
> > Patch > > > > View in context: > >
https://bugs.webkit.org/attachment.cgi?id=248886&action=review
> > > > > Source/WebCore/page/DragController.cpp:629 > > > + // Attachment elements can have DragSourceActionNone even if > > > + // selected, if the selection contains only the attachement element. > > > > This is not a 'why?' comment, but I wish it were. > I don't understand your comment. This is exactly what we do. What am I > missing?
Exactly. The comment is describing what the code does, but not why it does that. If I wanted to know what it does, I would read the code. If I wanted to know why it does it... I would come ask you, because the comment doesn't help me.
> > > > > Source/WebCore/page/DragController.cpp:759 > > > + m_draggingAttachmentURL = URL(); > > > > Vaguely interesting that you reset m_draggingAttachmentURL here, but this > > isn't where m_draggingImageURL is reset. But maybe there's a reason! > Moved it up simply not to add another #if ENABLE(ATTACHMENT_ELEMENT)
Ah! OK.
> > > Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm:413 > > > + RefPtr<SharedMemory> sharedMemoryImage = (!imageHandle.isNull()) ? SharedMemory::create(imageHandle, SharedMemory::ReadOnly) : nullptr; > > > > Ditto here, I think this should be written differently. Maybe split into > > setPromisedData and setPromisedImage (and setPromisedImage calls > > setPromisedData after extracting the data?) > > > I was not entirely convinced to duplicate the code, but maybe I should...
It doesn't need to be much duplication (I think!) if you have setPromisedImage extract the image data and then just go ahead and call setPromisedData.
> > > Source/WebKit/mac/Misc/WebNSPasteboardExtras.mm:275 > > > + NSMutableArray *types = [[NSMutableArray alloc] initWithObjects:NSFilesPromisePboardType, nil]; > > > > Isn't this leaking? > I only moved up an existing line. I've noticed that in many places where > declareTypes is called we don't worry about the array we pass.
Oh! No, there's an explicit -release sent there (it's now far away from the alloc/init, so I missed it). This should probably use RetainPtr, but I don't care if you fix it in this patch.
Alexey Proskuryakov
Comment 8
2015-03-17 18:34:13 PDT
Does this patch introduce sandbox escape opportunities? Can malicious native code running inside WebContent process fool UI process into giving it full file system access? Files inside drag normally result in getting such access.
Enrica Casucci
Comment 9
2015-03-18 16:23:44 PDT
Created
attachment 248979
[details]
Patch3 This patch addresses the comments and the security concerns.
Enrica Casucci
Comment 10
2015-03-18 16:36:48 PDT
Created
attachment 248983
[details]
Patch4 Trying to make EWS happy.
WebKit Commit Bot
Comment 11
2015-03-18 16:39:59 PDT
Attachment 248983
[details]
did not pass style-queue: ERROR: Source/WebKit2/UIProcess/PageClient.h:198: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] Total errors found: 1 in 34 files If any of these errors are false positives, please file a bug against check-webkit-style.
Tim Horton
Comment 12
2015-03-19 14:01:43 PDT
Comment on
attachment 248983
[details]
Patch4 View in context:
https://bugs.webkit.org/attachment.cgi?id=248983&action=review
> Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:105 > + NSURL* nsURL = (NSURL *)url;
one of the stars is on the wrong side
> Source/WebKit/mac/Misc/WebNSPasteboardExtras.mm:292 > + [paths.get() addObject:title];
no .get()
> LayoutTests/ChangeLog:13 > +<<<<<<< .mine
Something bad happened here.
> LayoutTests/editing/pasteboard/drag-and-drop-attachment-contenteditable.html:1 > +
blank line?
> LayoutTests/editing/pasteboard/drag-and-drop-attachment-contenteditable.html:26 > + shouldBe('target.getElementsByTagName("attachment").length', '1');
indentation error
> LayoutTests/editing/pasteboard/drag-and-drop-attachment-contenteditable.html:32 > +{
this { is inconsistent with the others.
Enrica Casucci
Comment 13
2015-03-19 15:00:09 PDT
Committed revision 181760.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug