[Webkit-unassigned] [Bug 21358] DragData should not depend on Clipboard, DocumentFragment, and Document
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Mon Sep 15 01:55:36 PDT 2014
https://bugs.webkit.org/show_bug.cgi?id=21358
--- Comment #9 from Carlos Garcia Campos <cgarcia at igalia.com> 2014-09-15 01:55:34 PST ---
(In reply to comment #8)
> (From update of attachment 237217 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=237217&action=review
Thanks for the review.
> We should make sure we are adding the minimum includes here.
I tried it for GTK+ port at least since it's the only port I can compile.
> > Source/WebCore/page/DragController.h:119
> > + static PassRefPtr<DocumentFragment> documentFragmentFromDragData(DragData&, Frame&, Range&, bool allowPlainText, bool& chosePlainText);
> > + static PassRefPtr<DocumentFragment> createFragmentFromDragData(DragData&, Frame&, Range&, bool allowPlainText, bool& chosePlainText);
>
> The names of these two functions don’t make it at all clear why there are two of them and how they differ.
>
> I think the second one exists only to have a platform-dependent hook to do things differently on every platform. Long term, I want to refactor this code so that it’s shared and not platform-specific. I think it can be done. In the meantime, I suggest a name that is clearer.
We can create a Pasteboard for drag and drop with the given DragData, and use something like Editor::webContentFromPasteboard() implementing that for other platforms (it's mac specific now). But that will be easier once I land patch in bug #136802, so I'll leave just a FIXME here and will submit a new patch once this and #136802 are both fixed.
> I’m also not sure that the first function needs to be a class member. Maybe it can just be a function with internal linkages inside the .cpp file and not in the header at all.
Yes, I made it a member only because I needed to call the second one, that is implemented in port specific files. I could also make it public and pass the drag controller to the static function, but I thought it was better to keep them private. In any case, I'll remove the first one and make the second one static function again in a follow up patch, when moving the implementation to the editor.
> > Source/WebCore/page/win/DragControllerWin.cpp:93
> > + * Order is richest format first. On OSX this is:
>
> You just moved this code, but this is a Windows-specific file. Not sure why a list of OS X formats is relevant. Also, it’s “OS X”, not “OSX”.
>
> I suggest we just drop the comment entirely.
Ok.
> > Source/WebCore/page/win/DragControllerWin.cpp:122
> > + if (DragDataRef platformDragData = dragData.platformData()) {
> > + if (containsFilenames(platformDragData)) {
> > + if (PassRefPtr<DocumentFragment> fragment = fragmentFromFilenames(frame.document(), platformDragData))
> > + return fragment;
> > + }
> > +
> > + if (containsHTML(platformDragData)) {
> > + if (PassRefPtr<DocumentFragment> fragment = fragmentFromHTML(frame.document(), platformDragData))
> > + return fragment;
> > + }
> > + } else {
> > + if (containsFilenames(&dragData.dragDataMap())) {
> > + if (PassRefPtr<DocumentFragment> fragment = fragmentFromFilenames(frame.document(), &dragData.dragDataMap()))
> > + return fragment;
> > + }
> > +
> > + if (containsHTML(&dragData.dragDataMap())) {
> > + if (PassRefPtr<DocumentFragment> fragment = fragmentFromHTML(frame.document(), &dragData.dragDataMap()))
> > + return fragment;
> > + }
> > + }
>
> You just moved this code, but sure would be nice to factor this so we don’t have to repeat everything twice.
Agree.
> > Source/WebCore/platform/DragData.h:95
> > + bool containsURL(FilenameConversionPolicy filenamePolicy = ConvertFilenames) const;
>
> The argument name filenamePolicy doesn’t add anything and should be removed.
>
> > Source/WebCore/platform/DragData.h:98
> > + String asURL(FilenameConversionPolicy filenamePolicy = ConvertFilenames, String* title = 0) const;
>
> The argument name filenamePolicy doesn’t add anything and should be removed. Should use nullptr rather than 0.
>
> > Source/WebCore/platform/mac/DragDataMac.mm:111
> > + // FIXME: It's not clear this is 100% correct since we know -[NSURL URLWithString:] does not handle
> > + // all the same cases we handle well in the URL code for creating an NSURL.
>
> Where was this code moved from? It’s easy for us to rewrite this use WebCore::URL to make the NSURL.
>From Editor::plainTextFromPasteboard() in EditorMac.mm
--
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