Hello. I'd like to share the information about new event related stuff
in Gecko.
nsGUIEvent.h defined and implemented all events (except
nsMutationEvent). Additionally, it's included by a lot of files
including some headers. So, this caused changes in the header needing to
waste long time for rebuilding Gecko.
For fixing this issues, now, nsGUIEvent.h is separated to following
files and nsGUIEvent.h has been removed.
* widget/BasicEvents.h
* widget/ContentEvents.h
* widget/MiscEvents.h
* widget/MouseEvents.
* widget/TextEvents.h
* widget/TextRange.h
* widget/TouchEvents.h
And content/events/public/nsMutationEvent.h is renamed to:
* content/events/public/MutationEvent.h
These files are exported under mozilla. So, when you need to include
some of them, you should write #include like:
#include "mozilla/BasicEvents.h"
FYI: BasicEvent.h is included by the other header files. So, you don't
need to include if directly if you've already included one of the others.
If you need forward declaration of event class or related stuff, you
should *not* do it yourself. Instead of that you should add:
#include "mozilla/EventForwards.h"
Actual file of it is widget/EventForwards.h which has all event classes'
forward declaration and related structs' forward declaration.
Additionally, it defines nsEventStatus, mozilla::Modifiers and
mozilla::KeyNameIndex.
Please don't include mozilla/*Events.h files from header file directly
as far as possible!
Additionally, the event names have been completely sorted out. See
following list for the detail:
BasicEvents.h
* nsEvent -> mozilla::WidgetEvent
* nsGUIEvent -> mozilla::WidgetGUIEvent
* nsInputEvent -> mozilla::WidgetInputEvent
* nsUIEvent -> mozilla::InternalUIEvent
ContentEvents.h
* nsScriptErrorEvent -> mozilla::InternalScriptErrorEvent
* nsScrollPortEvent -> mozilla::InternalScrollPortEvent
* nsScrollAreaEvent -> mozilla::InternalScrollAreaEvent
* nsFormEvent -> mozilla::InternalFormEvent
* nsClipboardEvent -> mozilla::InternalClipboardEvent
* nsFocusEvent -> mozilla::InternalFocusEvent
* nsTransitionEvent -> mozilla::InternalTransitionEvent
* nsAnimationEvent -> mozilla::InternalAnimationEvent
MiscEvents.h
* nsContentCommandEvent -> mozilla::WidgetContentCommandEvent
* nsCommandEvent -> mozilla::WidgetCommandEvent
* nsPluginEvent -> mozilla::WidgetPluginEvent
MouseEvents.h
* nsMouseEvent_base -> mozilla::WidgetMouseEventBase
* nsMouseEvent -> mozilla::WidgetMouseEvent
* nsDragEvent -> mozilla::WidgetDragEvent
* nsMouseScrollEvent -> mozilla::WidgetMouseScrollEvent
* mozilla::widget::WheelEvent -> mozilla::WidgetWheelEvent
TextEvents.h
* nsAlternativeCharCode -> mozilla::AlternativeCharCode
* nsKeyEvent -> mozilla::WidgetKeyboardEvent
* nsCompositionEvent -> mozilla::WidgetCompositionEvent
* nsQueryContentEvent -> mozilla::WidgetQueryContentEvent
* nsSelectionEvent -> mozilla::WidgetSelectionEvent
TextRange.h
* nsTextRangeStyle -> mozilla::TextRangeStyle
* nsTextRange -> mozilla::TextRange
* nsTextRangeArray -> mozilla::TextRangeArray
TouchEvents.h
* nsGestureNotifyEvent -> mozilla::WidgetGestureNotifyEvent
* nsSimpleGestureEvent -> mozilla::WidgetSimpleGestureEvent
* nsTouchEvent -> mozilla::WidgetTouchEvent
MutationEvent.h
* nsMutationEvent -> mozilla::InternalMutationEvent
The naming rules of them are:
1. Defined in "mozilla" namespace.
2. Use prefix "Widget" or "Internal". If the event is dispatched from
widget/, use "Widget". Otherwise, i.e., generated by content/, layout/
or something others, use "Internal".
Next, event classes now have vtable. I.e., they have virtual destructor.
Therefore, even if you create an instance and stores it in a pointer of
its superclass, you don't mind to cast the pointer type to the actual
class. For example,
WidgetEvent* event = new WidgetKeyboardEvent(...);
delete event;
is now safe.
Finally, the root class, WidgetEvent, has As*Event class. The "*"
doesn't include the prefix. I.e., for WidgetMouseEvent, the method name
is WidgetEvent::AsMouseEvent(). This returns the pointer of the instance
only when the instance is the class or its derived class. Otherwise,
returns nullptr.
E.g., WidgetDragEvent is defines as:
WidgetEvent
+- WidgetGUIEvent
+- WidgetInputEvent
+- WidgetMouseEventBase
+- WidgetMouseEvent
+- WidgetDragEvent
If an instance is WidgetDragEvent, AsGUIEvent(), AsInputEvent(),
AsMouseEventBase(), AsMouseEvent() and AsDragEvent() returns its
pointer. The other As*Event() methods return nullptr.
You should not use static_cast for Widget*Event and Internal*Event
anymore because it may cause wrong casting bug with some mistakes
(actually, there was such bug!).
I hope this change makes you happy!
--
Masayuki Nakano <masay...@d-toybox.com>
Manager, Internationalization, Mozilla Japan.
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform