Bug 148384

Summary: Wheel events stop propagating when target element is removed from DOM
Product: WebKit Reporter: Brent Fulgham <bfulgham>
Component: Layout and RenderingAssignee: Brent Fulgham <bfulgham>
Status: RESOLVED FIXED    
Severity: Normal CC: bfulgham, cmarcelo, commit-queue, esprehn+autocc, kangil.han
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch hyatt: review+

Description Brent Fulgham 2015-08-24 11:57:06 PDT
When listening to the ‘wheel’ or ‘mousewheel’ event on the document, if the event’s original target element is removed from the DOM the wheel event is no longer dispatched. 

1. Add a listener for ‘wheel’ on the document that removes the target of the event from the DOM. Have this happen after the element moves a specific amount or a certain number of events is received.
2. Scroll on the page (over the relevant element)
3. Keep scrolling

You will observe that the DOM event is no longer dispatched.
Comment 1 Brent Fulgham 2015-08-24 11:57:48 PDT
<rdar://problem/19732211>
Comment 2 Brent Fulgham 2015-08-24 12:01:31 PDT
Created attachment 259762 [details]
Patch
Comment 3 Tim Horton 2015-08-24 12:08:02 PDT
Comment on attachment 259762 [details]
Patch

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

> Source/WebCore/page/mac/EventHandlerMac.mm:919
> +        return false;

Frames can be removed...

> Source/WebCore/page/mac/EventHandlerMac.mm:922
> +        return true;

Anonymous nodes can't be scrollable? (probably true)

> Source/WebCore/page/mac/EventHandlerMac.mm:925
> +        return true;

What if a node is moved around in the DOM? (removed and reinserted before we get here) Is that OK?
Comment 4 Brent Fulgham 2015-08-24 14:00:15 PDT
Comment on attachment 259762 [details]
Patch

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

>> Source/WebCore/page/mac/EventHandlerMac.mm:925
>> +        return true;
> 
> What if a node is moved around in the DOM? (removed and reinserted before we get here) Is that OK?

It does seem like it would be a problem if we removed a node from one scrolling container, and inserted it into a new location. In that case, even with this code, we would start our event handling with this "migrated" node.

Maybe it would be better to just break the caching state in Element::removedFrom.
Comment 5 Brent Fulgham 2015-08-24 15:46:01 PDT
Created attachment 259786 [details]
Patch
Comment 6 Brent Fulgham 2015-08-24 17:35:06 PDT
Created attachment 259797 [details]
Patch
Comment 7 Dave Hyatt 2015-08-25 10:54:02 PDT
Comment on attachment 259797 [details]
Patch

r=me
Comment 8 Brent Fulgham 2015-08-25 11:03:12 PDT
Committed r188920: <http://trac.webkit.org/changeset/188920>