Closed Bug 912956 Opened 11 years ago Closed 11 years ago

Separate nsGUIEvent.h to a few header files

Categories

(Core :: Widget, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla27

People

(Reporter: masayuki, Assigned: masayuki)

References

(Blocks 1 open bug)

Details

Attachments

(18 files, 14 obsolete files)

(deleted), patch
roc
: review+
Details | Diff | Splinter Review
(deleted), patch
Details | Diff | Splinter Review
(deleted), patch
Details | Diff | Splinter Review
(deleted), patch
roc
: review+
Details | Diff | Splinter Review
(deleted), patch
Details | Diff | Splinter Review
(deleted), patch
Details | Diff | Splinter Review
(deleted), patch
Details | Diff | Splinter Review
(deleted), patch
roc
: review+
Details | Diff | Splinter Review
(deleted), patch
Details | Diff | Splinter Review
(deleted), patch
Details | Diff | Splinter Review
(deleted), patch
Details | Diff | Splinter Review
(deleted), patch
roc
: review+
Details | Diff | Splinter Review
(deleted), patch
roc
: review+
Details | Diff | Splinter Review
(deleted), patch
roc
: review+
Details | Diff | Splinter Review
(deleted), patch
roc
: review+
Details | Diff | Splinter Review
(deleted), patch
roc
: review+
Details | Diff | Splinter Review
(deleted), patch
roc
: review+
Details | Diff | Splinter Review
(deleted), patch
roc
: review+
Details | Diff | Splinter Review
nsGUIEvent.h is now included by a lot of files. This causes very long rebuild when you modify nsGUIEvent.h.

For solving this issue, we should sort out the nsGUIEvent.h.

1. Move all constants to nsEvent.h
2. Make BasicEvent.h for nsEvent, nsGUIEvent, nsInputEvent, nsUIEvent
3. Make TextEvent.h for nsKeyEvent, nsTextEvent, nsCompositionEvent
4. Make MouseEvent.h for nsMouseEvent_base, nsMouseEvent, nsDragEvent, nsMouseScrollEvent, widget::WheelEvent
5. Make TouchEvent.h for nsGestureNotifyEvent, nsTouchEvent, nsSimpleGestureEvent
6. Make ContentEvent.h for nsScriptErrorEvent, nsScrollPortEvent, nsScrollAreaEvent, nsFormEvent, nsCommandEvent, nsClipboardEvent, nsFocusEvent, nsTransitionEvent, nsAnimationEvent
7. Make InternalEvent. for nsQueryContentEvent, nsSelectionEvent, nsContentCommandEvent, nsPluginEvent

And then, all events should be renamed to mozilla::widget::*Event and for compatibility, defining ns*Event with typedef.

If you have some suggestion, let me know.
Sounds reasonable. However I'd put everything in the mozilla namespace. We don't really need a 'widget' namespace here.

I also think you should update all uses of ns*Event rather than leaving typedefs in.
(In reply to Robert O'Callahan (:roc) (Mozilla Corporation) from comment #1)
> Sounds reasonable. However I'd put everything in the mozilla namespace. We
> don't really need a 'widget' namespace here.

Thank you for the feedback. Currently, only WheelEvent and some constants are in mozilla::widget. If all event stuff should be in mozilla namespace, I'll change them too.

> I also think you should update all uses of ns*Event rather than leaving
> typedefs in.

I also want to do it. However, it makes the patch too large. So, I'd like to do it in next bug. Do you agree with this idea?
A separate bug would be OK, or a separate patch in this bug would be fine too.
Whiteboard: [leave open]
First of all, all mozilla::widget::* in nsGUIEvent.h and nsEvent.h are renamed to mozilla::*.

However, only widget::NotificationToIME is moved to nsIWidget.h because it's not an event stuff and it's used by nsIWidget::NotifyIME(). Other IME related structs and types are in mozilla::widget.
Status: NEW → ASSIGNED
Although, I like widget name space for internal event classes since it can distinguish the constants, types and class belonging in dom or widget easier.

However, it's not big matter for me. Let's land this first.

See comment 4 for the detail of this patch.
Attachment #804364 - Attachment is obsolete: true
Attachment #804480 - Flags: review?(roc)
I'll improve the EventForwards.h's enum with "enum class" later.
Attached patch part.3 Create mozilla/BasicEvents.h (obsolete) (deleted) — Splinter Review
workers/Events.cpp users Event class in anonymous namespace. Therefore, some code conflict with mozilla::Event.

Against for it, I changed *Event in workers/Events.cpp to Workers*Event. It might be better we rename nsEvent to mozilla::BasicEvent or something rather than mozilla::Event, tough.
Roc:

Do you agree with exporting the new event header files as "mozilla/*Events.h"? Or they should be just "*Events.h"?
Flags: needinfo?(roc)
(In reply to Masayuki Nakano (:masayuki) (Mozilla Japan) from comment #9)
> Do you agree with exporting the new event header files as
> "mozilla/*Events.h"? Or they should be just "*Events.h"?

I'm not sure, but I guess "mozilla/*Events.h".

(In reply to Masayuki Nakano (:masayuki) (Mozilla Japan) from comment #8)
> workers/Events.cpp users Event class in anonymous namespace. Therefore, some
> code conflict with mozilla::Event.
> 
> Against for it, I changed *Event in workers/Events.cpp to Workers*Event. It
> might be better we rename nsEvent to mozilla::BasicEvent or something rather
> than mozilla::Event, tough.

I think the worker events stuff is going to change a lot, to use the same infrastructure as main-thread DOM events. So let's not worry about that.

Maybe we should name it something like mozilla::WidgetEvent or mozilla::NativeEvent though, in case we want to rename nsDOMEvent to mozilla::dom::Event? I think we might want to do the latter, and since a lot of code has to deal with nsDOMEvent and nsEvent, we don't really want to rely on namespaces to disambiguate.

Olli, what do you think?
Flags: needinfo?(roc) → needinfo?(bugs)
(In reply to Robert O'Callahan (:roc) (Mozilla Corporation) from comment #11)
> I think the worker events stuff is going to change a lot, to use the same
> infrastructure as main-thread DOM events. So let's not worry about that.

What I mean is, I think you've done the right thing to do whatever you have to do to get things working with workers.

I think mozilla::WidgetEvent is probably the best name for nsEvent.
Worker events are indeed going away, so better to make other things look good, and worker events
can be a bit uglier.

mozilla::NativeEvent sounds ok.
Flags: needinfo?(bugs)
Thank you for the advice.

mozilla::NativeEvent sounds not good for widget developers because widget converts from "native event" to "Gecko event". In other words, ns*Event are abstract event information of each platform's native event. So, sounds mozilla::WidgetEvent is better to me.

Then, other events should also have Widget prefix? E.g., InputEvent and KeyEvent would conflict with B2G's native events in android:: namespace (http://mxr.mozilla.org/mozilla-central/source/widget/gonk/libui/Input.h) if we just drop "ns" prefix. mozilla::Widget*Event sounds very clear name to me in XP level code.
Flags: needinfo?(roc)
(In reply to Masayuki Nakano (:masayuki) (Mozilla Japan) from comment #14)
> Then, other events should also have Widget prefix? E.g., InputEvent and
> KeyEvent would conflict with B2G's native events in android:: namespace
> (http://mxr.mozilla.org/mozilla-central/source/widget/gonk/libui/Input.h) if
> we just drop "ns" prefix. mozilla::Widget*Event sounds very clear name to me
> in XP level code.

I agree.
Flags: needinfo?(roc)
WidgetEvent is ok to me.
Attachment #804951 - Attachment is obsolete: true
Attachment #807088 - Flags: review?(roc)
Attached patch part.3 Create mozilla/BasicEvents.h (obsolete) (deleted) — Splinter Review
Changes in BasicEvents.h will cause almost full build like nsGUIEvent.h change. This should be fixed in another bug.
Attachment #804952 - Attachment is obsolete: true
Attachment #807089 - Flags: review?(roc)
Attached patch part.4 Create mozilla/KeyTextEvents.h (obsolete) (deleted) — Splinter Review
Attachment #807092 - Flags: review?(roc)
Attached patch part.5 Create mozilla/MouseEvents.h (obsolete) (deleted) — Splinter Review
Attachment #807093 - Flags: review?(roc)
Attached patch part.6 Create mozilla/TouchEvents.h (obsolete) (deleted) — Splinter Review
Attachment #807094 - Flags: review?(roc)
Attached patch part.7 Create mozilla/ContentEvents.h (obsolete) (deleted) — Splinter Review
Attachment #807095 - Flags: review?(roc)
Attached patch part.8 Create mozilla/InternalEvents.h (obsolete) (deleted) — Splinter Review
This patch removes all unnecessary forward declarations and including headers. This causes bustage on some platform, I'm still testing this on tryserver.
Comment on attachment 807098 [details] [diff] [review]
part.9 Rename nsMutationEvent.h to mozilla/MutationEvent.h

Renaming mutation event like other widget events.

This patch moves the NS_MUTATION_* event message to BasicEvents.h because I'd like to change them as an enum in the future.
Attachment #807098 - Flags: review?(bugs)
I believe that this is just a mistake at creating this file.
Attachment #807099 - Flags: review?(bugs)
Attached patch part.11 Get rid of NS_EVENT_TYPE_* (obsolete) (deleted) — Splinter Review
NS_EVENT_TYPE_* values are used as event message value. So, they should be merged in other message values.
Attachment #807100 - Flags: review?(bugs)
This patch is still being tested on tryserver.
I'll post some patches which removes nsGUIEvent.h completely but I'd like to land them separately after landing part.2 - part.12.
Comment on attachment 807097 [details] [diff] [review]
part.8 Create mozilla/InternalEvents.h

Okay, bustage has gone.
Attachment #807097 - Flags: review?(roc)
Attachment #804480 - Attachment description: part.1 Rename all event stuff in mozilla::widget to mozilla::* → part.1 Rename all event stuff in mozilla::widget to mozilla::* (landed on Gecko 26)
Attachment #807102 - Flags: review?(roc)
Comment on attachment 807098 [details] [diff] [review]
part.9 Rename nsMutationEvent.h to mozilla/MutationEvent.h




>+// XXX Following values are used in nsINode.h.  So, change of this header or
>+//     BasicEvents.h causes rebuilding a lot of files.  We need to do something
>+//     for this issue.
This header shouldn't be changed too often, so perhaps no worth to have this comment




I'm not very happy with WidgetMutationEvent, but I don't know what would be a better name.
Attachment #807098 - Flags: review?(bugs) → review+
Comment on attachment 807099 [details] [diff] [review]
part.10 Replace NS_EVENT_NULL in nsEventNameList.h with NS_EVENT since the argument specifies an event struct type

Should be ok since nsContentUtils::GetEventCategory defaults to NS_EVENT.

This does change the behavior of GetEventIdAndAtom, but looks ok to me.
Attachment #807099 - Flags: review?(bugs) → review+
Attachment #807100 - Flags: review?(bugs) → review+
Comment on attachment 807092 [details] [diff] [review]
part.4 Create mozilla/KeyTextEvents.h

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

Why not call the new header KeyEvents.h?
Comment on attachment 807095 [details] [diff] [review]
part.7 Create mozilla/ContentEvents.h

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

Actually, in this patch, I wonder if we should keep using the "Widget" prefix. Because these events are really unrelated to widgets.

How about, for the events that aren't relevant to widgets, we call them Internal*Event instead?
(In reply to Robert O'Callahan (:roc) (Mozilla Corporation) from comment #34)
> Comment on attachment 807092 [details] [diff] [review]
> part.4 Create mozilla/KeyTextEvents.h
> 
> Review of attachment 807092 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> Why not call the new header KeyEvents.h?

Composition (and Text) events may be caused by non keyboard device such as hand writing system or voice input system.

I'd like to name it InputEvents.h. However, there is WidgetInputEvent in BasicEvents.h. So, do you have better idea for the new header file?
Flags: needinfo?(roc)
(In reply to Robert O'Callahan (:roc) (Mozilla Corporation) from comment #35)
> Comment on attachment 807095 [details] [diff] [review]
> part.7 Create mozilla/ContentEvents.h
> 
> Review of attachment 807095 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> Actually, in this patch, I wonder if we should keep using the "Widget"
> prefix. Because these events are really unrelated to widgets.
> 
> How about, for the events that aren't relevant to widgets, we call them
> Internal*Event instead?

Hmm, then, InternalEvents.h becomes strange name...
(In reply to Masayuki Nakano (:masayuki) (Mozilla Japan) from comment #37)
> (In reply to Robert O'Callahan (:roc) (Mozilla Corporation) from comment #35)
> > Comment on attachment 807095 [details] [diff] [review]
> > part.7 Create mozilla/ContentEvents.h
> > 
> > Review of attachment 807095 [details] [diff] [review]:
> > -----------------------------------------------------------------
> > 
> > Actually, in this patch, I wonder if we should keep using the "Widget"
> > prefix. Because these events are really unrelated to widgets.
> > 
> > How about, for the events that aren't relevant to widgets, we call them
> > Internal*Event instead?
> 
> Hmm, then, InternalEvents.h becomes strange name...

How about Content*Event?
(In reply to Masayuki Nakano (:masayuki) (Mozilla Japan) from comment #36)
> Composition (and Text) events may be caused by non keyboard device such as
> hand writing system or voice input system.
> 
> I'd like to name it InputEvents.h. However, there is WidgetInputEvent in
> BasicEvents.h. So, do you have better idea for the new header file?

How about TextEvents.h?
Flags: needinfo?(roc)
In InternalEvents.h, shouldn't WidgetQueryContentEvent belong to KeyTextEvents.h (or TextEvents.h)?

Then we could rename InternalEvents.h to MiscEvents.h.
(In reply to Robert O'Callahan (:roc) (Mozilla Corporation) from comment #39)
> (In reply to Masayuki Nakano (:masayuki) (Mozilla Japan) from comment #36)
> > Composition (and Text) events may be caused by non keyboard device such as
> > hand writing system or voice input system.
> > 
> > I'd like to name it InputEvents.h. However, there is WidgetInputEvent in
> > BasicEvents.h. So, do you have better idea for the new header file?
> 
> How about TextEvents.h?

Keyboard event may not cause text input, though. However, I was thinking it as a candidate name of it. If you do not mind this issue, let's use it.
(In reply to Robert O'Callahan (:roc) (Mozilla Corporation) from comment #40)
> In InternalEvents.h, shouldn't WidgetQueryContentEvent belong to
> KeyTextEvents.h (or TextEvents.h)?
> 
> Then we could rename InternalEvents.h to MiscEvents.h.

Hmm, then, I'd like to move WidgetSelectionEvent too because it's also used by IME handling.
KeyTextEvents.h -> TextEvents.h
WidgetQueryContentEvent and WidgetSelectionEvent belong to TextEvents.h
Name the events in ContentEvents.h (Or InternalEvents.h?)
InternalEvents.h -> MiscEvents.h

Then, WidgetMutationEvent should be renamed as InternalMutationEvent too?
Flags: needinfo?(roc)
> Name the events in ContentEvents.h (Or InternalEvents.h?)

I meant they should be named Internal*Event and ContentEvents.h should be InternalEvents.h?
(In reply to Masayuki Nakano (:masayuki) (Mozilla Japan) from comment #41)
> Keyboard event may not cause text input, though. However, I was thinking it
> as a candidate name of it. If you do not mind this issue, let's use it.

Yeah I think that's fine. Keyboard events are still related to text even if they don't cause immediate input.

(In reply to Masayuki Nakano (:masayuki) (Mozilla Japan) from comment #43)
> KeyTextEvents.h -> TextEvents.h
> WidgetQueryContentEvent and WidgetSelectionEvent belong to TextEvents.h
> Name the events in ContentEvents.h (Or InternalEvents.h?)
> InternalEvents.h -> MiscEvents.h
> 
> Then, WidgetMutationEvent should be renamed as InternalMutationEvent too?

Yes.

(In reply to Masayuki Nakano (:masayuki) (Mozilla Japan) from comment #44)
> > Name the events in ContentEvents.h (Or InternalEvents.h?)
> 
> I meant they should be named Internal*Event and ContentEvents.h should be
> InternalEvents.h?

No. If we have a header file called InternalEvents.h then you'd expect all Internal*Events to be in it, which we don't want since there are a lot of Internal*Events. So let's have ContentEvents.h, MiscEvents.h and any other files we need, all containing various Internal*Events.
Flags: needinfo?(roc)
Thanks, I agree all of your idea now!
Ah, then, WidgetUIEvent should be InternalUIEvent? It's internal event for nsDOMUIEvent. It's not used by widget directly.
See the previous comment. Sorry for the spam.
Flags: needinfo?(roc)
(In reply to Masayuki Nakano (:masayuki) (Mozilla Japan) from comment #47)
> Ah, then, WidgetUIEvent should be InternalUIEvent? It's internal event for
> nsDOMUIEvent. It's not used by widget directly.

Yes.
Flags: needinfo?(roc)
(I think that the fact we need to define nsEvent subclasses for events that have nothing to do with widgets --- i.e., that we need Internal*Events at all --- is a really annoying problem with our event system.)
Thank you, perhaps, I'll post new patches Tuesday or later (Monday is a holiday of Japan).
(In reply to Robert O'Callahan (:roc) (Mozilla Corporation) from comment #50)
> (I think that the fact we need to define nsEvent subclasses for events that
> have nothing to do with widgets
You don't *have* to define any subclass if you just need a DOM Event. Just define a new DOM Event 
interface using .webidl (and implement it hopefully using .webidl event codegen if the interface is rather simple).
But for certain cases when we don't necessarily need any heap event object, ns*Event structs are handy.
Are you saying we don't need stuff like WidgetScriptErrorEvent?
Technically we don't need it if someone implements the same functionality to some DOM event. But script error event is *very* special case, even in the spec. EventHandlers for script errors get different kinds of arguments than EventListeners.
http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#onerroreventhandler
Renamed to TextEvents.h
Attachment #807092 - Attachment is obsolete: true
Attachment #807092 - Flags: review?(roc)
Attachment #809028 - Flags: review?(roc)
Widget*Event are Renamed to Internal*Event.
Attachment #807095 - Attachment is obsolete: true
The file is renamed to MiscEvents.h. And WidgetQueryContentEvent and WidgetSelectionEvent are moved to TextEvents.h.
Attachment #807097 - Attachment is obsolete: true
Attachment #807097 - Flags: review?(roc)
Attachment #809033 - Flags: review?(roc)
nsMutationEvent is now renamed to InternalMutationEvent.
Attachment #807098 - Attachment is obsolete: true
Attachment #807099 - Attachment is obsolete: true
Attachment #807100 - Attachment is obsolete: true
Comment on attachment 809033 [details] [diff] [review]
part.8 Create mozilla/MiscEvents.h

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

::: widget/MiscEvents.h
@@ +3,5 @@
> + * License, v. 2.0. If a copy of the MPL was not distributed with this
> + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
> +
> +#ifndef mozilla_InternalEvents_h__
> +#define mozilla_InternalEvents_h__

Change to MiscEvents
Attachment #809033 - Flags: review?(roc) → review+
Comment on attachment 809040 [details] [diff] [review]
part.12 All event utils (macros and inline methods) should be methods of mozilla::WidgetEvent

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

Nice!

::: widget/shared/WidgetEventImpl.cpp
@@ +36,5 @@
> +bool
> +WidgetEvent::IsMouseDerivedEvent() const
> +{
> +  return (eventStructType == NS_MOUSE_EVENT ||
> +          eventStructType == NS_DRAG_EVENT);

You don't need parentheses around these return values. (Here and many below.)
Attachment #809040 - Flags: review?(roc) → review+
Blocks: includehell
(In reply to Robert O'Callahan (:roc) (Mozilla Corporation) from comment #66)
> > +#ifndef mozilla_InternalEvents_h__
> > +#define mozilla_InternalEvents_h__
> 
> Change to MiscEvents

And don't use double underscores in identifiers. C++ reserves all identifiers containing a double underscore.
(In reply to Masatoshi Kimura [:emk] from comment #70)
> (In reply to Robert O'Callahan (:roc) (Mozilla Corporation) from comment #66)
> > > +#ifndef mozilla_InternalEvents_h__
> > > +#define mozilla_InternalEvents_h__
> > 
> > Change to MiscEvents
> 
> And don't use double underscores in identifiers. C++ reserves all
> identifiers containing a double underscore.

IIRC, there are a lot of header files using "__". Could you file a bug for it?
Whiteboard: [leave open]
Filed 920412 about include guards.
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla27
(In reply to Masatoshi Kimura [:emk] from comment #72)
> Filed 920412 about include guards.

Hey, don't close this bug without confirmation. There are some remaining work.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Status: REOPENED → ASSIGNED
Attached patch part.18 Remove nsGUIEvent.h (deleted) — Splinter Review
Attachment #809732 - Flags: review?(roc)
(In reply to Masayuki Nakano (:masayuki) (Mozilla Japan) from comment #75)
> Hey, don't close this bug without confirmation. There are some remaining
> work.

Sorry, I thought the work was done because you removed [leave open].
(In reply to Masatoshi Kimura [:emk] from comment #80)
> (In reply to Masayuki Nakano (:masayuki) (Mozilla Japan) from comment #75)
> > Hey, don't close this bug without confirmation. There are some remaining
> > work.
> 
> Sorry, I thought the work was done because you removed [leave open].

because next landing is the final work in this bug.
Comment on attachment 809727 [details] [diff] [review]
part.15 mozilla/TextEvents.h should be included directly

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

::: layout/xul/base/src/nsXULPopupManager.cpp
@@ +48,5 @@
> +              nsIDOMKeyEvent::DOM_VK_LEFT  == nsIDOMKeyEvent::DOM_VK_END + 2 &&
> +              nsIDOMKeyEvent::DOM_VK_UP    == nsIDOMKeyEvent::DOM_VK_END + 3 &&
> +              nsIDOMKeyEvent::DOM_VK_RIGHT == nsIDOMKeyEvent::DOM_VK_END + 4 &&
> +              nsIDOMKeyEvent::DOM_VK_DOWN  == nsIDOMKeyEvent::DOM_VK_END + 5,
> +              "nsXULPopupManager assumes some keyCode values are consinueous");

"consecutive"
Attachment #809727 - Flags: review?(roc) → review+
These changes caught me by surprise. You might want to post to dev.platform to give people an idea as to what moved where and what changed names.
(In reply to Jim Mathies [:jimm] from comment #85)
> These changes caught me by surprise. You might want to post to dev.platform
> to give people an idea as to what moved where and what changed names.

Indeed. I posted it. Sorry for the delay to notify of this series of changes.
https://groups.google.com/forum/#!topic/mozilla.dev.platform/cHg_ExqEC_U
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: