Closed Bug 930860 Opened 6 years ago Closed 6 years ago

Move some methods in WidgetEvent to WidgetMouseEvent

Categories

(Core :: Widget, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla27

People

(Reporter: masayuki, Assigned: masayuki)

Details

Attachments

(1 file)

No description provided.
From smaug's request, I wrote this.

However, at reading around the callers, this patch just makes the code complicated.

Indeed, the WidgetEvent becomes simple, but I don't feel this is good change.

Requesting to review to both roc and smaug.
Attachment #822264 - Flags: review?(roc)
Attachment #822264 - Flags: review?(bugs)
Well, if IsLeftClickEvent and IsContextMenuKeyEvent are in the WidgetEvent, so should
IsAlt & co. Or if those aren't there, then IsLeftClickEvent and IsContextMenuKeyEvent should be in
the right class, not in the base class.
So basically, whatever we do, let's do it consistently :)
Comment on attachment 822264 [details] [diff] [review]
Move IsLeftClickEvent() and IsContextMenuKeyEvent() from WidgetEvent to WidgetMouseEvent(Base)

Review of attachment 822264 [details] [diff] [review]:
-----------------------------------------------------------------

I think we should do this.
Attachment #822264 - Flags: review?(roc) → review+
Comment on attachment 822264 [details] [diff] [review]
Move IsLeftClickEvent() and IsContextMenuKeyEvent() from WidgetEvent to WidgetMouseEvent(Base)

Might be useful to have IsFooBarEvent() in the base event and if that returns
true event->AsFooBarEvent()->DoSomething would be ok.
Attachment #822264 - Flags: review?(bugs) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/b9d18faa1a97

(In reply to Olli Pettay [:smaug] from comment #4)
> Might be useful to have IsFooBarEvent() in the base event and if that returns
> true event->AsFooBarEvent()->DoSomething would be ok.

Do you think that IsFooBarEvent() returns true even if the eventStructType doesn't exactly match? I.e., the implementation becomes |return AsFooBarEvent() != nullptr;|? If so, it's same as |event->AsFooBarEvent() && event->AsFooBarEvent()->DoSomething()|.

If you think that IsForBarEvent() returns true only when eventStructType exactly match, I love them. See this post:
https://groups.google.com/d/msg/mozilla.dev.platform/cHg_ExqEC_U/adfrnWQUB7cJ
IsFooBarEvent() should return true it the event is FooBar or extends FooBar.
That is what DOM code does with IsElement() for example.
(In reply to Olli Pettay [:smaug] from comment #6)
> IsFooBarEvent() should return true it the event is FooBar or extends FooBar.
> That is what DOM code does with IsElement() for example.

Hmm, then, I don't think that we need to implement them because they just do AsFooBarEvent() != nullptr...
https://hg.mozilla.org/mozilla-central/rev/b9d18faa1a97
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla28
Target Milestone: mozilla28 → mozilla27
You need to log in before you can comment on or make changes to this bug.