Bug 57642 - Move WheelEvent-dispatching logic into WheelEventDispatchMediator.
Summary: Move WheelEvent-dispatching logic into WheelEventDispatchMediator.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Other OS X 10.5
: P2 Normal
Assignee: Dimitri Glazkov (Google)
URL:
Keywords:
Depends on: 57639
Blocks: 55515 57655
  Show dependency treegraph
 
Reported: 2011-04-01 10:00 PDT by Dimitri Glazkov (Google)
Modified: 2011-04-08 08:48 PDT (History)
1 user (show)

See Also:


Attachments
Patch (8.26 KB, patch)
2011-04-01 12:53 PDT, Dimitri Glazkov (Google)
no flags Details | Formatted Diff | Diff
Ready to bake on EWSs. (9.89 KB, patch)
2011-04-05 10:38 PDT, Dimitri Glazkov (Google)
no flags Details | Formatted Diff | Diff
Patch (9.83 KB, patch)
2011-04-06 21:10 PDT, Dimitri Glazkov (Google)
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>