RESOLVED FIXED 135244
Let WheelEvent wrap a PlatformWheelEvent
https://bugs.webkit.org/show_bug.cgi?id=135244
Summary Let WheelEvent wrap a PlatformWheelEvent
Wenson Hsieh
Reported 2014-07-24 11:39:12 PDT
If WheelEvent is initialized by a PlatformWheelEvent, store a reference to the PlatformWheelEvent. Subproblem of https://bugs.webkit.org/show_bug.cgi?id=135195 since ScrollAnimator::handleWheelEvent takes in a PlatformWheelEvent but the PlatformWheelEvent is discarded and rebuilt as a WheelEvent in Element::dispatchWheelEvent, we need a way of accessing the original PlatformWheelEvent in EventHandler. This will ultimately allow ScrollAnimator to know about momentum phases from the PlatformWheelEvent, which is necessary to implement scroll snapping (see https://bugs.webkit.org/show_bug.cgi?id=134283), among other things.
Attachments
Patch (2.60 KB, patch)
2014-07-24 12:07 PDT, Wenson Hsieh
no flags
Patch (2.54 KB, patch)
2014-07-24 14:22 PDT, Wenson Hsieh
no flags
Patch (8.85 KB, patch)
2014-07-25 20:12 PDT, Wenson Hsieh
no flags
Archive of layout-test-results from webkit-ews-07 for mac-mountainlion (553.76 KB, application/zip)
2014-07-25 20:44 PDT, Build Bot
no flags
Patch (5.28 KB, patch)
2014-07-25 21:49 PDT, Wenson Hsieh
no flags
Patch (5.44 KB, patch)
2014-07-25 23:21 PDT, Wenson Hsieh
no flags
Patch (5.14 KB, patch)
2014-07-28 09:04 PDT, Wenson Hsieh
no flags
Wenson Hsieh
Comment 1 2014-07-24 12:07:29 PDT
WebKit Commit Bot
Comment 2 2014-07-24 12:10:46 PDT
Attachment 235442 [details] did not pass style-queue: ERROR: Source/WebCore/dom/WheelEvent.cpp:73: Code inside a namespace should not be indented. [whitespace/indent] [4] Total errors found: 1 in 3 files If any of these errors are false positives, please file a bug against check-webkit-style.
Wenson Hsieh
Comment 3 2014-07-24 14:22:44 PDT
WebKit Commit Bot
Comment 4 2014-07-24 14:44:14 PDT
Comment on attachment 235461 [details] Patch Rejecting attachment 235461 [details] from commit-queue. wenson_hsieh@apple.com does not have committer permissions according to http://trac.webkit.org/browser/trunk/Tools/Scripts/webkitpy/common/config/contributors.json. - If you do not have committer rights please read http://webkit.org/coding/contributing.html for instructions on how to use bugzilla flags. - If you have committer rights please correct the error in Tools/Scripts/webkitpy/common/config/contributors.json by adding yourself to the file (no review needed). The commit-queue restarts itself every 2 hours. After restart the commit-queue will correctly respect your committer rights.
Beth Dakin
Comment 5 2014-07-24 14:45:48 PDT
Comment on attachment 235461 [details] Patch Sorry, my bad! I told Wenson to set cq+ and see what happens.
WebKit Commit Bot
Comment 6 2014-07-24 15:18:19 PDT
Comment on attachment 235461 [details] Patch Clearing flags on attachment: 235461 Committed r171531: <http://trac.webkit.org/changeset/171531>
WebKit Commit Bot
Comment 7 2014-07-24 15:18:23 PDT
All reviewed patches have been landed. Closing bug.
Sam Weinig
Comment 8 2014-07-25 16:34:22 PDT
Comment on attachment 235461 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=235461&action=review > Source/WebCore/dom/WheelEvent.h:114 > + std::unique_ptr<PlatformWheelEvent> m_wheelEvent; This seems like it is duplicating state now. I would prefer if we just had the PlatformWheelEvent itself (not in a std::unique_ptr) and we remove the duplicate state.
Sam Weinig
Comment 9 2014-07-25 16:36:08 PDT
Re-opening, since I don't think this fix is quite right. We shouldn't need to use a unique_ptr or duplicate the state.
Wenson Hsieh
Comment 10 2014-07-25 20:12:09 PDT
Build Bot
Comment 11 2014-07-25 20:44:05 PDT
Comment on attachment 235561 [details] Patch Attachment 235561 [details] did not pass mac-ews (mac): Output: http://webkit-queues.appspot.com/results/4633332109279232 New failing tests: fast/events/wheelevent-constructor.html
Build Bot
Comment 12 2014-07-25 20:44:09 PDT
Created attachment 235563 [details] Archive of layout-test-results from webkit-ews-07 for mac-mountainlion The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: webkit-ews-07 Port: mac-mountainlion Platform: Mac OS X 10.8.5
Wenson Hsieh
Comment 13 2014-07-25 21:49:20 PDT
Wenson Hsieh
Comment 14 2014-07-25 23:21:24 PDT
Darin Adler
Comment 15 2014-07-27 23:14:48 PDT
Comment on attachment 235567 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=235567&action=review > Source/WebCore/dom/WheelEvent.cpp:53 > + , m_wheelEvent(PlatformWheelEvent()) No need to include this. This is what happens if you don’t explicitly initialize m_wheelEvent, so you should just omit this line. > Source/WebCore/dom/WheelEvent.cpp:65 > + , m_wheelEvent(PlatformWheelEvent()) No need to include this. This is what happens if you don’t explicitly initialize m_wheelEvent, so you should just omit this line. > Source/WebCore/dom/WheelEvent.h:81 > + // Returns a null pointer if WheelEvent was not created using a PlatformWheelEvent. > + const PlatformWheelEvent* wheelEvent() const { return m_initializedWithPlatformWheelEvent ? &m_wheelEvent : nullptr; } This comment is not needed if we put the implementation inline like this, since the code says the same thing the comment does. But also, I am not convinced this boolean and null pointer technique is the right way to achieve what you want to achieve. Since this patch doesn’t include the changes to code that uses the wheelEvent() function, I can’t judge whether an alternative solution would be better, since I don’t know what problem the nullptr is trying to solve.
Wenson Hsieh
Comment 16 2014-07-28 00:00:47 PDT
Comment on attachment 235567 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=235567&action=review Thank you for the review! I'll put up a new version very soon. >> Source/WebCore/dom/WheelEvent.cpp:53 >> + , m_wheelEvent(PlatformWheelEvent()) > > No need to include this. This is what happens if you don’t explicitly initialize m_wheelEvent, so you should just omit this line. Good catch -- thanks! >> Source/WebCore/dom/WheelEvent.cpp:65 >> + , m_wheelEvent(PlatformWheelEvent()) > > No need to include this. This is what happens if you don’t explicitly initialize m_wheelEvent, so you should just omit this line. Fixed. >> Source/WebCore/dom/WheelEvent.h:81 >> + const PlatformWheelEvent* wheelEvent() const { return m_initializedWithPlatformWheelEvent ? &m_wheelEvent : nullptr; } > > This comment is not needed if we put the implementation inline like this, since the code says the same thing the comment does. > > But also, I am not convinced this boolean and null pointer technique is the right way to achieve what you want to achieve. Since this patch doesn’t include the changes to code that uses the wheelEvent() function, I can’t judge whether an alternative solution would be better, since I don’t know what problem the nullptr is trying to solve. Got it -- I'll take out the comment. The problem I'm planning to address with this is that I need to distinguish events initialized through JavaScript (e.g. document.createEvent("WheelEvent")) that don't have corresponding PlatformWheelEvents from regular wheel events created using PlatformWheelEvent. Depending on which type the wheel event is, I take a different code path -- one code path calls ScrollableArea::scroll directly with a scroll delta, granularity, and direction, while the other code path calls ScrollableArea::handleWheelEvent with the PlatformWheelEvent. Ultimately, I need the PlatformWheelEvent's momentum phase information to implement scroll snapping on a Mac, although this information is also necessary for implementing behaviors like rubber-banding when overflow scrolling.
Wenson Hsieh
Comment 17 2014-07-28 09:04:56 PDT
Beth Dakin
Comment 18 2014-07-28 12:32:28 PDT
Comment on attachment 235597 [details] Patch Re-instating Darin's r+ and adding a cq+!
WebKit Commit Bot
Comment 19 2014-07-28 12:36:05 PDT
Comment on attachment 235597 [details] Patch Clearing flags on attachment: 235597 Committed r171685: <http://trac.webkit.org/changeset/171685>
WebKit Commit Bot
Comment 20 2014-07-28 12:36:10 PDT
All reviewed patches have been landed. Closing bug.
Wenson Hsieh
Comment 21 2014-07-28 12:46:31 PDT
Comment on attachment 235597 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=235597&action=review > Source/WebCore/dom/WheelEvent.h:81 > double deltaX() const { return m_deltaX; } // Positive when scrolling right. I've tried wrapping these up along with the PlatformWheelEvent, but they ended up breaking LayoutTests/fast/events/wheelevent-constructor.html, since double precision is required (the diff ended up looking like 20.3 vs. 20.29999...). > Source/WebCore/dom/WheelEvent.h:87 > unsigned deltaMode() const { return m_deltaMode; } m_deltaMode could also be removed from WheelEvent, but doing so would mean that we need to compute the deltaMode on the fly using PlatformWheelEvent.granularity() every time deltaMode() is called. I chose not to take this option and store the result in m_deltaMode instead.
Note You need to log in before you can comment on or make changes to this bug.