WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
Bug 178056
dragenter and dragleave shouldn't use the same data transfer object
https://bugs.webkit.org/show_bug.cgi?id=178056
Summary
dragenter and dragleave shouldn't use the same data transfer object
Ryosuke Niwa
Reported
2017-10-07 18:27:13 PDT
We're supposed to be creating a distinct DataTransfer object for each dragenter & dragleave event we fire.
Attachments
Fixes the bug and refactors code
(28.73 KB, patch)
2017-10-07 18:39 PDT
,
Ryosuke Niwa
no flags
Details
Formatted Diff
Diff
Skipped the test on Windows
(29.49 KB, patch)
2017-10-07 20:25 PDT
,
Ryosuke Niwa
no flags
Details
Formatted Diff
Diff
Patch for landing
(30.33 KB, patch)
2017-10-08 02:29 PDT
,
Ryosuke Niwa
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Ryosuke Niwa
Comment 1
2017-10-07 18:39:12 PDT
Created
attachment 323111
[details]
Fixes the bug and refactors code
Ryosuke Niwa
Comment 2
2017-10-07 20:25:47 PDT
Created
attachment 323117
[details]
Skipped the test on Windows
Darin Adler
Comment 3
2017-10-07 23:41:04 PDT
Comment on
attachment 323117
[details]
Skipped the test on Windows View in context:
https://bugs.webkit.org/attachment.cgi?id=323117&action=review
> Source/WebCore/page/DragController.cpp:697 > + if (!destinationOperation) > + operation = defaultOperationForDrag(sourceOperation); > + else if (!(sourceOperation & *destinationOperation)) // The element picked an operation which is not supported by the source > operation = DragOperationNone; > - } > + else > + operation = *destinationOperation;
Stylistic question about * vs. using the value() function on optionals. I almost always use the named function, but I am not sure it’s better.
> Source/WebCore/page/EventHandler.cpp:2277 > +bool EventHandler::dispatchDragEnterOrDragOverEvent(const AtomicString& eventType, Element& target, const PlatformMouseEvent& event, > + std::unique_ptr<Pasteboard>&& pasteborad, DragOperation sourceOperation, bool draggingFiles, std::optional<DragOperation>& destinationOperation)
Out arguments are kind of ugly. Sure would be nice if it could all be in the return value instead of a return value plus an out argument.
> Source/WebCore/page/EventHandler.cpp:2289 > +bool EventHandler::updateDragAndDrop(const PlatformMouseEvent& event, std::function<std::unique_ptr<Pasteboard>()> makePasteboard, DragOperation sourceOperation, bool draggingFiles, std::optional<DragOperation>& destinationOperation)
Ditto. Also, a std::function can be expensive to copy, so it would be nice if it was a const&, assuming it’s always called synchronously and not saved for later.
Wenson Hsieh
Comment 4
2017-10-08 00:17:24 PDT
Comment on
attachment 323117
[details]
Skipped the test on Windows View in context:
https://bugs.webkit.org/attachment.cgi?id=323117&action=review
>> Source/WebCore/page/EventHandler.cpp:2277 >> + std::unique_ptr<Pasteboard>&& pasteborad, DragOperation sourceOperation, bool draggingFiles, std::optional<DragOperation>& destinationOperation) > > Out arguments are kind of ugly. Sure would be nice if it could all be in the return value instead of a return value plus an out argument.
Nit - "pasteborad" => "pasteboard"
Darin Adler
Comment 5
2017-10-08 00:22:29 PDT
$ git grep borad Found this typo in ChangeLog, but not in any pre-existing code.
Ryosuke Niwa
Comment 6
2017-10-08 00:52:27 PDT
(In reply to Darin Adler from
comment #3
)
> Comment on
attachment 323117
[details]
> Skipped the test on Windows > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=323117&action=review
> > > Source/WebCore/page/DragController.cpp:697 > > + if (!destinationOperation) > > + operation = defaultOperationForDrag(sourceOperation); > > + else if (!(sourceOperation & *destinationOperation)) // The element picked an operation which is not supported by the source > > operation = DragOperationNone; > > - } > > + else > > + operation = *destinationOperation; > > Stylistic question about * vs. using the value() function on optionals. I > almost always use the named function, but I am not sure it’s better.
Fixed to use .value().
> > Source/WebCore/page/EventHandler.cpp:2277 > > +bool EventHandler::dispatchDragEnterOrDragOverEvent(const AtomicString& eventType, Element& target, const PlatformMouseEvent& event, > > + std::unique_ptr<Pasteboard>&& pasteborad, DragOperation sourceOperation, bool draggingFiles, std::optional<DragOperation>& destinationOperation) > > Out arguments are kind of ugly. Sure would be nice if it could all be in the > return value instead of a return value plus an out argument.
Okay. I'm gonna add the following struct and make this function return that. struct DragTargetResponse { bool accept; std::optional<DragOperation> operation; };
> > Source/WebCore/page/EventHandler.cpp:2289 > > +bool EventHandler::updateDragAndDrop(const PlatformMouseEvent& event, std::function<std::unique_ptr<Pasteboard>()> makePasteboard, DragOperation sourceOperation, bool draggingFiles, std::optional<DragOperation>& destinationOperation) > > Ditto. > > Also, a std::function can be expensive to copy, so it would be nice if it > was a const&, assuming it’s always called synchronously and not saved for > later.
Oops, that's a good catch. Fixed.
Ryosuke Niwa
Comment 7
2017-10-08 00:53:17 PDT
(In reply to Wenson Hsieh from
comment #4
)
> Comment on
attachment 323117
[details]
> Skipped the test on Windows > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=323117&action=review
> > >> Source/WebCore/page/EventHandler.cpp:2277 > >> + std::unique_ptr<Pasteboard>&& pasteborad, DragOperation sourceOperation, bool draggingFiles, std::optional<DragOperation>& destinationOperation) > > > > Out arguments are kind of ugly. Sure would be nice if it could all be in the return value instead of a return value plus an out argument. > > Nit - "pasteborad" => "pasteboard"
Fixed.
Ryosuke Niwa
Comment 8
2017-10-08 02:29:26 PDT
Created
attachment 323132
[details]
Patch for landing
WebKit Commit Bot
Comment 9
2017-10-08 03:08:56 PDT
Comment on
attachment 323132
[details]
Patch for landing Clearing flags on attachment: 323132 Committed
r223031
: <
http://trac.webkit.org/changeset/223031
>
WebKit Commit Bot
Comment 10
2017-10-08 03:08:58 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 11
2017-10-08 03:11:08 PDT
<
rdar://problem/34875120
>
Matt Lewis
Comment 12
2017-10-09 09:40:21 PDT
This patch caused a build break on windows:
https://build.webkit.org/builders/Apple%20Win%20Release%20%28Build%29/builds/5053
https://build.webkit.org/builders/Apple%20Win%20Release%20%28Build%29/builds/5053/steps/compile-webkit/logs/stdio
Error: C:\cygwin\home\buildbot\slave\win-release\build\Source\WebCore\page\EventHandler.cpp(2285): error C2440: 'return': cannot convert from 'initializer list' to 'WebCore::EventHandler::DragTargetResponse' [C:\cygwin\home\buildbot\slave\win-release\build\WebKitBuild\Release\Source\WebCore\WebCore.vcxproj] C:\cygwin\home\buildbot\slave\win-release\build\Source\WebCore\page\EventHandler.cpp(2285): note: No constructor could take the source type, or constructor overload resolution was ambiguous If this can't be addressed quickly, we will need to revert the patch.
Ryosuke Niwa
Comment 13
2017-10-09 11:55:16 PDT
Wenson fixed it in
https://trac.webkit.org/changeset/223050
https://trac.webkit.org/changeset/223054
Thanks, Wenson!
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