/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * 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/. */
#ifdef DEBUG # include "mozilla/StaticPrefs_dom.h" #endif// #ifdef DEBUG
class nsCommandParams;
/** * XXX Following enums should be in BasicEvents.h. However, currently, it's * impossible to use foward delearation for enum.
*/
/** * Return status for event processors.
*/ enum nsEventStatus { // The event is ignored, do default processing
nsEventStatus_eIgnore, // The event is consumed, don't do default processing
nsEventStatus_eConsumeNoDefault, // The event is consumed, but do default processing
nsEventStatus_eConsumeDoDefault, // Value is not for use, only for serialization
nsEventStatus_eSentinel
};
// For preventing bustage due to "," after the last item.
eEventMessage_MaxValue
};
constchar* ToChar(EventMessage aEventMessage);
/** * Return true if aMessage should be dispatched as a WidgetPointerEvent.
*/
[[nodiscard]] bool IsPointerEventMessage(EventMessage aMessage);
/** * Return true if aMessage should be dispatched as a WidgetPointerEvent and * the message was dispatched as a WidgetMouseEvent. So, this returns true * if the event message is ePointerClick, ePointerAuxClick or eContextMenu.
*/
[[nodiscard]] bool IsPointerEventMessageOriginallyMouseEventMessage(
EventMessage aMessage);
/** * Return true if aMessage is not allowed to dispatch to a content node except * Element node when we dispatch the event as a trusted event which . * * NOTE: This is currently designed for PresShell to consider whether a content * node is proper event target for aMessage. So, this may not work the expected * way in other cases. Therefore, when you use this method in a new place, you * should check whether this returns the expected result for you.
*/
[[nodiscard]] bool IsForbiddenDispatchingToNonElementContent(
EventMessage aMessage);
/** * Event class IDs
*/
typedef uint8_t EventClassIDType;
enum EventClassID : EventClassIDType { // The event class name will be: // eBasicEventClass for WidgetEvent // eFooEventClass for WidgetFooEvent or InternalFooEvent #define NS_ROOT_EVENT_CLASS(aPrefix, aName) eBasic##aName##Class #define NS_EVENT_CLASS(aPrefix, aName) , e##aName##Class
typedef uint16_t KeyNameIndexType; enum KeyNameIndex : KeyNameIndexType { #include"mozilla/KeyNameList.h" // If a DOM keyboard event is synthesized by script, this is used. Then, // specified key name should be stored and use it as .key value.
KEY_NAME_INDEX_USE_STRING
};
typedef uint8_t CodeNameIndexType; enum CodeNameIndex : CodeNameIndexType { #include"mozilla/PhysicalKeyCodeNameList.h" // If a DOM keyboard event is synthesized by script, this is used. Then, // specified code name should be stored and use it as .code value.
CODE_NAME_INDEX_USE_STRING
};
typedef uint8_t EditorInputTypeType; enumclass EditorInputType : EditorInputTypeType { #include"mozilla/InputTypeList.h" // If a DOM input event is synthesized by script, this is used. Then, // specified input type should be stored as string and use it as .inputType // value.
eUnknown,
};
#undef NS_DEFINE_INPUTTYPE
inlinebool ExposesClipboardDataOrDataTransfer(EditorInputType aInputType) { switch (aInputType) { case EditorInputType::eInsertFromPaste: case EditorInputType::eInsertFromPasteAsQuotation: returntrue; default: returnfalse;
}
}
/** * IsDataAvailableOnTextEditor() returns true if aInputType on TextEditor * should have non-null InputEvent.data value.
*/ inlinebool IsDataAvailableOnTextEditor(EditorInputType aInputType) { switch (aInputType) { case EditorInputType::eInsertText: case EditorInputType::eInsertCompositionText: case EditorInputType::eInsertFromComposition: // Only level 2 case EditorInputType::eInsertFromPaste: case EditorInputType::eInsertFromPasteAsQuotation: case EditorInputType::eInsertTranspose: case EditorInputType::eInsertFromDrop: case EditorInputType::eInsertReplacementText: case EditorInputType::eInsertFromYank: case EditorInputType::eFormatSetBlockTextDirection: case EditorInputType::eFormatSetInlineTextDirection: returntrue; default: returnfalse;
}
}
/** * IsDataAvailableOnHTMLEditor() returns true if aInputType on HTMLEditor * should have non-null InputEvent.data value.
*/ inlinebool IsDataAvailableOnHTMLEditor(EditorInputType aInputType) { switch (aInputType) { case EditorInputType::eInsertText: case EditorInputType::eInsertCompositionText: case EditorInputType::eInsertFromComposition: // Only level 2 case EditorInputType::eFormatSetBlockTextDirection: case EditorInputType::eFormatSetInlineTextDirection: case EditorInputType::eInsertLink: case EditorInputType::eFormatBackColor: case EditorInputType::eFormatFontColor: case EditorInputType::eFormatFontName: returntrue; default: returnfalse;
}
}
/** * IsDataTransferAvailableOnHTMLEditor() returns true if aInputType on * HTMLEditor should have non-null InputEvent.dataTransfer value.
*/ inlinebool IsDataTransferAvailableOnHTMLEditor(EditorInputType aInputType) { switch (aInputType) { case EditorInputType::eInsertFromPaste: case EditorInputType::eInsertFromPasteAsQuotation: case EditorInputType::eInsertFromDrop: case EditorInputType::eInsertTranspose: case EditorInputType::eInsertReplacementText: case EditorInputType::eInsertFromYank: returntrue; default: returnfalse;
}
}
/** * MayHaveTargetRangesOnHTMLEditor() returns true if "beforeinput" event whose * whose inputType is aInputType on HTMLEditor may return non-empty static * range array from getTargetRanges(). * Note that TextEditor always sets empty array. Therefore, there is no * method for TextEditor.
*/ inlinebool MayHaveTargetRangesOnHTMLEditor(EditorInputType aInputType) { switch (aInputType) { // Explicitly documented by the specs. case EditorInputType::eHistoryRedo: case EditorInputType::eHistoryUndo: // Not documented, but other browsers use empty array. case EditorInputType::eFormatSetBlockTextDirection: returnfalse; default: returntrue;
}
}
/** * IsCancelableBeforeInputEvent() returns true if `beforeinput` event for * aInputType should be cancelable. * * Input Events Level 1: * https://rawgit.com/w3c/input-events/v1/index.html#x5-1-2-attributes * Input Events Level 2: * https://w3c.github.io/input-events/#interface-InputEvent-Attributes
*/ inlinebool IsCancelableBeforeInputEvent(EditorInputType aInputType) { switch (aInputType) { case EditorInputType::eInsertText: returntrue; // In Level 1, undefined. case EditorInputType::eInsertReplacementText: returntrue; // In Level 1, undefined. case EditorInputType::eInsertLineBreak: returntrue; // In Level 1, undefined. case EditorInputType::eInsertParagraph: returntrue; // In Level 1, undefined. case EditorInputType::eInsertOrderedList: returntrue; case EditorInputType::eInsertUnorderedList: returntrue; case EditorInputType::eInsertHorizontalRule: returntrue; case EditorInputType::eInsertFromYank: returntrue; case EditorInputType::eInsertFromDrop: returntrue; case EditorInputType::eInsertFromPaste: returntrue; case EditorInputType::eInsertFromPasteAsQuotation: returntrue; case EditorInputType::eInsertTranspose: returntrue; case EditorInputType::eInsertCompositionText: returnfalse; case EditorInputType::eInsertFromComposition:
MOZ_ASSERT(!StaticPrefs::dom_input_events_conform_to_level_1()); returntrue; case EditorInputType::eInsertLink: returntrue; case EditorInputType::eDeleteCompositionText:
MOZ_ASSERT(!StaticPrefs::dom_input_events_conform_to_level_1()); returnfalse; case EditorInputType::eDeleteWordBackward: returntrue; // In Level 1, undefined. case EditorInputType::eDeleteWordForward: returntrue; // In Level 1, undefined. case EditorInputType::eDeleteSoftLineBackward: returntrue; // In Level 1, undefined. case EditorInputType::eDeleteSoftLineForward: returntrue; // In Level 1, undefined. case EditorInputType::eDeleteEntireSoftLine: returntrue; // In Level 1, undefined. case EditorInputType::eDeleteHardLineBackward: returntrue; // In Level 1, undefined. case EditorInputType::eDeleteHardLineForward: returntrue; // In Level 1, undefined. case EditorInputType::eDeleteByDrag: returntrue; case EditorInputType::eDeleteByCut: returntrue; case EditorInputType::eDeleteContent: returntrue; // In Level 1, undefined. case EditorInputType::eDeleteContentBackward: returntrue; // In Level 1, undefined. case EditorInputType::eDeleteContentForward: returntrue; // In Level 1, undefined. case EditorInputType::eHistoryUndo: returntrue; case EditorInputType::eHistoryRedo: returntrue; case EditorInputType::eFormatBold: returntrue; case EditorInputType::eFormatItalic: returntrue; case EditorInputType::eFormatUnderline: returntrue; case EditorInputType::eFormatStrikeThrough: returntrue; case EditorInputType::eFormatSuperscript: returntrue; case EditorInputType::eFormatSubscript: returntrue; case EditorInputType::eFormatJustifyFull: returntrue; case EditorInputType::eFormatJustifyCenter: returntrue; case EditorInputType::eFormatJustifyRight: returntrue; case EditorInputType::eFormatJustifyLeft: returntrue; case EditorInputType::eFormatIndent: returntrue; case EditorInputType::eFormatOutdent: returntrue; case EditorInputType::eFormatRemove: returntrue; case EditorInputType::eFormatSetBlockTextDirection: returntrue; case EditorInputType::eFormatSetInlineTextDirection: returntrue; case EditorInputType::eFormatBackColor: returntrue; case EditorInputType::eFormatFontColor: returntrue; case EditorInputType::eFormatFontName: returntrue; case EditorInputType::eUnknown: // This is not declared by Input Events, but it does not make sense to // allow web apps to cancel default action without inputType value check. // If some our specific edit actions should be cancelable, new inputType // value for them should be declared by the spec. returnfalse; default:
MOZ_ASSERT_UNREACHABLE("The new input type is not handled"); returnfalse;
}
}
/** * Return a command value for aCommandName. * XXX: Is there a better place to put `Command` related methods instead of * global scope in `mozilla` namespace? * * @param aCommandName Should be a XUL command name like "cmd_bold" * (case sensitive). * @param aCommandparams Additional parameter value of aCommandName. * Can be nullptr, but if aCommandName requires * additional parameter and sets this to nullptr, * will return Command::DoNothing with warning.
*/
Command GetInternalCommand(constchar* aCommandName, const nsCommandParams* aCommandParams = nullptr);
} // namespace mozilla
/** * All header files should include this header instead of *Events.h.
*/
namespace mozilla {
template <class T> class OwningNonNull;
namespace dom { class StaticRange;
}
#define NS_EVENT_CLASS(aPrefix, aName) class aPrefix##aName; #define NS_ROOT_EVENT_CLASS(aPrefix, aName) NS_EVENT_CLASS(aPrefix, aName)
enum MouseButtonsFlag {
eNoButtons = 0x00,
ePrimaryFlag = 0x01,
eSecondaryFlag = 0x02,
eMiddleFlag = 0x04, // typicall, "back" button being left side of 5-button // mice, see "buttons" attribute document of DOM3 Events.
e4thFlag = 0x08, // typicall, "forward" button being right side of 5-button // mice, see "buttons" attribute document of DOM3 Events.
e5thFlag = 0x10,
eEraserFlag = 0x20
};
/** * Returns a MouseButtonsFlag value which is changed by a button state change * event whose mButton is aMouseButton.
*/ inline MouseButtonsFlag MouseButtonsFlagToChange(MouseButton aMouseButton) { switch (aMouseButton) { case MouseButton::ePrimary: return MouseButtonsFlag::ePrimaryFlag; case MouseButton::eMiddle: return MouseButtonsFlag::eMiddleFlag; case MouseButton::eSecondary: return MouseButtonsFlag::eSecondaryFlag; case MouseButton::eX1: return MouseButtonsFlag::e4thFlag; case MouseButton::eX2: return MouseButtonsFlag::e5thFlag; case MouseButton::eEraser: return MouseButtonsFlag::eEraserFlag; default: return MouseButtonsFlag::eNoButtons;
}
}
enumclass TextRangeType : RawTextRangeType;
// IMEData.h
template <typename IntType> class StartAndEndOffsets; template <typename IntType> class OffsetAndData;
} // namespace mozilla
#endif// mozilla_EventForwards_h__
¤ Dauer der Verarbeitung: 0.31 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.