Bug 57642

Summary: Move WheelEvent-dispatching logic into WheelEventDispatchMediator.
Product: WebKit Reporter: Dimitri Glazkov (Google) <dglazkov>
Component: New BugsAssignee: Dimitri Glazkov (Google) <dglazkov>
Status: RESOLVED FIXED    
Severity: Normal CC: darin
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Other   
OS: OS X 10.5   
Bug Depends on: 57639    
Bug Blocks: 55515, 57655    
Attachments:
Description Flags
Patch
none
Ready to bake on EWSs.
none
Patch darin: review+

Description Dimitri Glazkov (Google) 2011-04-01 10:00:52 PDT
Move WheelEvent-dispatching logic into WheelEventDispatchMediator.
Comment 1 Dimitri Glazkov (Google) 2011-04-01 12:53:13 PDT
Created attachment 87901 [details]
Patch
Comment 2 Dimitri Glazkov (Google) 2011-04-05 10:38:21 PDT
Created attachment 88274 [details]
Ready to bake on EWSs.
Comment 3 Eric Seidel (no email) 2011-04-06 09:40:44 PDT
Comment on attachment 88274 [details]
Ready to bake on EWSs.

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

> Source/WebCore/ChangeLog:8
> +        No new tests. (OOPS!)

I guess you've not written the ChangelOg yet?

> Source/WebCore/dom/Event.h:204
> +    EventDispatchMediator();

What does this class mediate between?
Comment 4 Dimitri Glazkov (Google) 2011-04-06 11:34:28 PDT
(In reply to comment #3)
> (From update of attachment 88274 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=88274&action=review
> 
> > Source/WebCore/ChangeLog:8
> > +        No new tests. (OOPS!)
> 
> I guess you've not written the ChangelOg yet?

No, I just forgot to replace this line :)

> 
> > Source/WebCore/dom/Event.h:204
> > +    EventDispatchMediator();
> 
> What does this class mediate between?

It mediates event dispatch. This class knows specifics of firing events, helping EventDispatcher do the right thing without having to know how.
Comment 5 Dimitri Glazkov (Google) 2011-04-06 11:41:30 PDT
(In reply to comment #4)
> (In reply to comment #3)
> > (From update of attachment 88274 [details] [details])
> > View in context: https://bugs.webkit.org/attachment.cgi?id=88274&action=review
> > 
> > > Source/WebCore/ChangeLog:8
> > > +        No new tests. (OOPS!)
> > 
> > I guess you've not written the ChangelOg yet?
> 
> No, I just forgot to replace this line :)
> 
> > 
> > > Source/WebCore/dom/Event.h:204
> > > +    EventDispatchMediator();
> > 
> > What does this class mediate between?
> 
> It mediates event dispatch. This class knows specifics of firing events, helping EventDispatcher do the right thing without having to know how.

Believe it or not, the whole EventDispatchMediator was born out of your comment: you said the EventDispatcher knows too much :)
Comment 6 Darin Adler 2011-04-06 17:15:30 PDT
Comment on attachment 88274 [details]
Ready to bake on EWSs.

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

> Source/WebCore/dom/Node.cpp:2665
> -void Node::dispatchWheelEvent(PlatformWheelEvent& e)
> +bool Node::dispatchWheelEvent(PlatformWheelEvent& e)
>  {
> -    EventDispatcher::dispatchWheelEvent(this, e);
> +    return EventDispatcher::dispatchEvent(this, WheelEventDispatchMediator(e, document()->defaultView()));
>  }

As long as you are touching this, I would prefer the name “event” to “e”.

> Source/WebCore/dom/Node.h:536
> -    void dispatchWheelEvent(PlatformWheelEvent&);
> +    bool dispatchWheelEvent(PlatformWheelEvent&);

Is this really a good change?

The DOM establishes a pattern where events themselves know if they have been handled. I think this is clearer than a boolean return value. It’s hard to name a function so you can understand what its boolean return value means.

Worse, we have functions that tell whether an event is handled both with a return value and with state in the event too! Although this is not one of them.

If you really ant to change this then I think it should take a const&. The reason this took a non-const before was so it could record that the event was handled.

> Source/WebCore/dom/WheelEvent.cpp:104
> +    : EventDispatchMediator()

Do you need to say this explicitly? I am surprised if so.
Comment 7 Dimitri Glazkov (Google) 2011-04-06 20:22:31 PDT
Comment on attachment 88274 [details]
Ready to bake on EWSs.

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

Darin, thank you for review. Will upload new patch shortly.

>> Source/WebCore/dom/Node.cpp:2665
>>  }
> 
> As long as you are touching this, I would prefer the name “event” to “e”.

Will change.

>> Source/WebCore/dom/Node.h:536
>> +    bool dispatchWheelEvent(PlatformWheelEvent&);
> 
> Is this really a good change?
> 
> The DOM establishes a pattern where events themselves know if they have been handled. I think this is clearer than a boolean return value. It’s hard to name a function so you can understand what its boolean return value means.
> 
> Worse, we have functions that tell whether an event is handled both with a return value and with state in the event too! Although this is not one of them.
> 
> If you really ant to change this then I think it should take a const&. The reason this took a non-const before was so it could record that the event was handled.

This just brings it in line with other similar events. Both dispatchEvent and dispatchKeyEvent return false when they weren't handled. I definitely overlooked the non-const ref. Will change that.

>> Source/WebCore/dom/WheelEvent.cpp:104
>> +    : EventDispatchMediator()
> 
> Do you need to say this explicitly? I am surprised if so.

No. I just got too mechanical in writing the code. I'll remove.
Comment 8 Dimitri Glazkov (Google) 2011-04-06 21:10:51 PDT
Created attachment 88566 [details]
Patch
Comment 9 Dimitri Glazkov (Google) 2011-04-07 15:06:06 PDT
<3
Comment 10 Dimitri Glazkov (Google) 2011-04-08 08:48:32 PDT
Committed r83298: <http://trac.webkit.org/changeset/83298>