2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2001-07-16 02:57:29 +04:00
|
|
|
|
2013-09-24 14:04:14 +04:00
|
|
|
#ifndef mozilla_EventForwards_h__
|
|
|
|
#define mozilla_EventForwards_h__
|
2001-07-16 02:57:29 +04:00
|
|
|
|
2013-07-30 18:25:31 +04:00
|
|
|
#include <stdint.h>
|
2012-08-09 01:08:17 +04:00
|
|
|
|
2017-08-17 02:48:52 +03:00
|
|
|
#include "nsStringFwd.h"
|
2016-03-18 05:22:37 +03:00
|
|
|
#include "nsTArray.h"
|
|
|
|
|
2020-01-14 10:15:45 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
# include "mozilla/StaticPrefs_dom.h"
|
|
|
|
#endif // #ifdef DEBUG
|
|
|
|
|
2019-05-21 10:47:51 +03:00
|
|
|
class nsCommandParams;
|
|
|
|
|
2001-07-16 02:57:29 +04:00
|
|
|
/**
|
2013-09-24 14:04:14 +04:00
|
|
|
* XXX Following enums should be in BasicEvents.h. However, currently, it's
|
|
|
|
* impossible to use foward delearation for enum.
|
2001-07-16 02:57:29 +04:00
|
|
|
*/
|
|
|
|
|
2009-04-02 01:59:02 +04:00
|
|
|
/**
|
2013-09-24 14:04:14 +04:00
|
|
|
* Return status for event processors.
|
2009-04-02 01:59:02 +04:00
|
|
|
*/
|
2013-09-24 14:04:14 +04:00
|
|
|
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
|
2015-05-14 15:16:00 +03:00
|
|
|
nsEventStatus_eConsumeDoDefault,
|
|
|
|
// Value is not for use, only for serialization
|
|
|
|
nsEventStatus_eSentinel
|
2009-04-02 01:59:02 +04:00
|
|
|
};
|
|
|
|
|
2015-08-26 15:56:59 +03:00
|
|
|
namespace mozilla {
|
|
|
|
|
2018-06-25 19:23:50 +03:00
|
|
|
enum class CanBubble { eYes, eNo };
|
|
|
|
|
|
|
|
enum class Cancelable { eYes, eNo };
|
|
|
|
|
|
|
|
enum class ChromeOnlyDispatch { eYes, eNo };
|
|
|
|
|
|
|
|
enum class Trusted { eYes, eNo };
|
|
|
|
|
2018-06-22 22:47:29 +03:00
|
|
|
enum class Composed { eYes, eNo, eDefault };
|
|
|
|
|
2015-08-22 04:34:51 +03:00
|
|
|
/**
|
|
|
|
* Event messages
|
|
|
|
*/
|
|
|
|
|
2015-08-26 15:56:59 +03:00
|
|
|
typedef uint16_t EventMessageType;
|
|
|
|
|
|
|
|
enum EventMessage : EventMessageType {
|
2015-08-22 04:34:51 +03:00
|
|
|
|
2015-09-17 06:05:44 +03:00
|
|
|
#define NS_EVENT_MESSAGE(aMessage) aMessage,
|
|
|
|
#define NS_EVENT_MESSAGE_FIRST_LAST(aMessage, aFirst, aLast) \
|
|
|
|
aMessage##First = aFirst, aMessage##Last = aLast,
|
2015-08-22 04:34:51 +03:00
|
|
|
|
|
|
|
#include "mozilla/EventMessageList.h"
|
|
|
|
|
|
|
|
#undef NS_EVENT_MESSAGE
|
2015-09-17 06:05:44 +03:00
|
|
|
#undef NS_EVENT_MESSAGE_FIRST_LAST
|
2015-08-22 04:34:51 +03:00
|
|
|
|
|
|
|
// For preventing bustage due to "," after the last item.
|
|
|
|
eEventMessage_MaxValue
|
|
|
|
};
|
|
|
|
|
2015-09-17 06:05:44 +03:00
|
|
|
const char* ToChar(EventMessage aEventMessage);
|
|
|
|
|
2015-08-22 04:34:51 +03:00
|
|
|
/**
|
|
|
|
* Event class IDs
|
|
|
|
*/
|
|
|
|
|
2014-08-04 09:28:58 +04:00
|
|
|
typedef uint8_t EventClassIDType;
|
|
|
|
|
2015-01-21 16:35:19 +03:00
|
|
|
enum EventClassID : EventClassIDType {
|
2014-08-04 09:28:58 +04:00
|
|
|
// 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
|
|
|
|
|
|
|
|
#include "mozilla/EventClassList.h"
|
|
|
|
|
|
|
|
#undef NS_EVENT_CLASS
|
|
|
|
#undef NS_ROOT_EVENT_CLASS
|
|
|
|
};
|
|
|
|
|
2015-09-17 06:05:44 +03:00
|
|
|
const char* ToChar(EventClassID aEventClassID);
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
typedef uint16_t Modifiers;
|
2012-04-25 07:00:01 +04:00
|
|
|
|
2013-04-24 07:49:46 +04:00
|
|
|
#define NS_DEFINE_KEYNAME(aCPPName, aDOMKeyName) KEY_NAME_INDEX_##aCPPName,
|
|
|
|
|
2016-05-12 13:18:36 +03:00
|
|
|
typedef uint16_t KeyNameIndexType;
|
|
|
|
enum KeyNameIndex : KeyNameIndexType {
|
2014-04-01 15:42:11 +04:00
|
|
|
#include "mozilla/KeyNameList.h"
|
2013-10-29 08:14:42 +04:00
|
|
|
// 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
|
2013-04-24 07:49:46 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#undef NS_DEFINE_KEYNAME
|
|
|
|
|
Bug 1297013 part.2 Implement some helper methods to log constants related to event handling r=smaug
This patch implements some helper methods to log constants related to event handling.
ToString(KeyNameIndex) and ToString(CodeNameIndex) converts the enum itmes to human readable string. They use WidgetKeyboardEvent's helper class which returns Unicode text. Therefore, this need to convert from UTF16 to UTF8. That's the reason why these methods don't return |const char*|.
GetDOMKeyCodeName(uint32_t) returns DOM keycode name if it's defined. Otherwise, returns hexadecimal value. For generating switch-case statement, VirtualKeyCodeList.h shouldn't include ",". Therefore, this patch removes "," from VirtualKeyCodeList.h and append it at defining NS_DEFINE_VK. Additionally, the last item of enum and array should not end with ",". Therefore, this adds dummy last item at each of them. Finally, some of the keyCode values are shared between 2 keys. Therefore, it needs to support NS_DISALLOW_SAME_KEYCODE for switch-case generator. See the comment in the file for more detail.
GetModifiersName(Modifiers) returns all modifier names included in the given value.
MozReview-Commit-ID: 9i2ftFOTpDn
--HG--
extra : rebase_source : 458a4d28624dc10dd4454f2e7708d746d1fcb045
2016-09-14 18:48:47 +03:00
|
|
|
const nsCString ToString(KeyNameIndex aKeyNameIndex);
|
|
|
|
|
2014-05-25 06:08:58 +04:00
|
|
|
#define NS_DEFINE_PHYSICAL_KEY_CODE_NAME(aCPPName, aDOMCodeName) \
|
|
|
|
CODE_NAME_INDEX_##aCPPName,
|
|
|
|
|
2016-05-12 13:18:36 +03:00
|
|
|
typedef uint8_t CodeNameIndexType;
|
|
|
|
enum CodeNameIndex : CodeNameIndexType {
|
2014-05-25 06:08:58 +04:00
|
|
|
#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
|
|
|
|
};
|
|
|
|
|
|
|
|
#undef NS_DEFINE_PHYSICAL_KEY_CODE_NAME
|
|
|
|
|
Bug 1297013 part.2 Implement some helper methods to log constants related to event handling r=smaug
This patch implements some helper methods to log constants related to event handling.
ToString(KeyNameIndex) and ToString(CodeNameIndex) converts the enum itmes to human readable string. They use WidgetKeyboardEvent's helper class which returns Unicode text. Therefore, this need to convert from UTF16 to UTF8. That's the reason why these methods don't return |const char*|.
GetDOMKeyCodeName(uint32_t) returns DOM keycode name if it's defined. Otherwise, returns hexadecimal value. For generating switch-case statement, VirtualKeyCodeList.h shouldn't include ",". Therefore, this patch removes "," from VirtualKeyCodeList.h and append it at defining NS_DEFINE_VK. Additionally, the last item of enum and array should not end with ",". Therefore, this adds dummy last item at each of them. Finally, some of the keyCode values are shared between 2 keys. Therefore, it needs to support NS_DISALLOW_SAME_KEYCODE for switch-case generator. See the comment in the file for more detail.
GetModifiersName(Modifiers) returns all modifier names included in the given value.
MozReview-Commit-ID: 9i2ftFOTpDn
--HG--
extra : rebase_source : 458a4d28624dc10dd4454f2e7708d746d1fcb045
2016-09-14 18:48:47 +03:00
|
|
|
const nsCString ToString(CodeNameIndex aCodeNameIndex);
|
|
|
|
|
2019-01-07 13:10:57 +03:00
|
|
|
#define NS_DEFINE_INPUTTYPE(aCPPName, aDOMName) e##aCPPName,
|
|
|
|
|
|
|
|
typedef uint8_t EditorInputTypeType;
|
|
|
|
enum class 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
|
|
|
|
|
2019-03-29 19:08:11 +03:00
|
|
|
inline bool ExposesClipboardDataOrDataTransfer(EditorInputType aInputType) {
|
|
|
|
switch (aInputType) {
|
|
|
|
case EditorInputType::eInsertFromPaste:
|
|
|
|
case EditorInputType::eInsertFromPasteAsQuotation:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-19 09:28:19 +03:00
|
|
|
/**
|
|
|
|
* IsDataAvailableOnTextEditor() returns true if aInputType on TextEditor
|
|
|
|
* should have non-null InputEvent.data value.
|
|
|
|
*/
|
|
|
|
inline bool IsDataAvailableOnTextEditor(EditorInputType aInputType) {
|
|
|
|
switch (aInputType) {
|
|
|
|
case EditorInputType::eInsertText:
|
|
|
|
case EditorInputType::eInsertCompositionText:
|
|
|
|
case EditorInputType::eInsertFromComposition: // Only level 2
|
Bug 998941 - part 1-3: Make TextEditor (only when not HTMLEditor instance) set InputEvent.data to inserting string when InputEvent.inputType is "insertFromPaste", "insertFromDrop" or "insertReplacementText" r=smaug,m_kato
https://rawgit.com/w3c/input-events/v1/index.html#dfn-data
https://w3c.github.io/input-events/#dfn-data
Both Input Events Level 1 and Level 2 declare that InputEvent.data should be
set to inserting string only on TextEditor when InputEvent.inputType is
"insertFromPaste", "insertFromPasteAsQuotation", "insertFromDrop",
"insertTranspose", "insertReplacementText" or "insertFromYank".
Currently, we support only "insertFromPaste", "insertFromDrop",
"insertReplacementText". Therefore, this patch makes TextEditor set
EditorBase::mEditActionData::mData only for them (and the instance is not
HTMLEditor's).
Differential Revision: https://phabricator.services.mozilla.com/D19287
--HG--
extra : moz-landing-system : lando
2019-02-19 09:28:57 +03:00
|
|
|
case EditorInputType::eInsertFromPaste:
|
2019-03-05 17:35:43 +03:00
|
|
|
case EditorInputType::eInsertFromPasteAsQuotation:
|
Bug 998941 - part 1-3: Make TextEditor (only when not HTMLEditor instance) set InputEvent.data to inserting string when InputEvent.inputType is "insertFromPaste", "insertFromDrop" or "insertReplacementText" r=smaug,m_kato
https://rawgit.com/w3c/input-events/v1/index.html#dfn-data
https://w3c.github.io/input-events/#dfn-data
Both Input Events Level 1 and Level 2 declare that InputEvent.data should be
set to inserting string only on TextEditor when InputEvent.inputType is
"insertFromPaste", "insertFromPasteAsQuotation", "insertFromDrop",
"insertTranspose", "insertReplacementText" or "insertFromYank".
Currently, we support only "insertFromPaste", "insertFromDrop",
"insertReplacementText". Therefore, this patch makes TextEditor set
EditorBase::mEditActionData::mData only for them (and the instance is not
HTMLEditor's).
Differential Revision: https://phabricator.services.mozilla.com/D19287
--HG--
extra : moz-landing-system : lando
2019-02-19 09:28:57 +03:00
|
|
|
case EditorInputType::eInsertTranspose:
|
|
|
|
case EditorInputType::eInsertFromDrop:
|
|
|
|
case EditorInputType::eInsertReplacementText:
|
|
|
|
case EditorInputType::eInsertFromYank:
|
2019-02-19 09:29:38 +03:00
|
|
|
case EditorInputType::eFormatSetBlockTextDirection:
|
|
|
|
case EditorInputType::eFormatSetInlineTextDirection:
|
2019-02-19 09:28:19 +03:00
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* IsDataAvailableOnHTMLEditor() returns true if aInputType on HTMLEditor
|
|
|
|
* should have non-null InputEvent.data value.
|
|
|
|
*/
|
|
|
|
inline bool IsDataAvailableOnHTMLEditor(EditorInputType aInputType) {
|
|
|
|
switch (aInputType) {
|
|
|
|
case EditorInputType::eInsertText:
|
|
|
|
case EditorInputType::eInsertCompositionText:
|
|
|
|
case EditorInputType::eInsertFromComposition: // Only level 2
|
2019-02-19 09:29:38 +03:00
|
|
|
case EditorInputType::eFormatSetBlockTextDirection:
|
|
|
|
case EditorInputType::eFormatSetInlineTextDirection:
|
2019-02-19 09:30:12 +03:00
|
|
|
case EditorInputType::eInsertLink:
|
Bug 998941 - part 1-7: Make HTMLEditor set InputEvent.data to serialized color value when InputEvent.inputType is "formatBackColor" or "formatForeColor" r=smaug,m_kato,emilio
Although neither Chrome nor Safari does not set InputEvent.data when the event
is caused by `document.execCommand()` with `backColor`, `foreColor` nor
`hiliteColor`, Safari supports styling color with touchbar and in that case,
Safari sets it (*1).
Additionally, currently Safari uses `rgb()` to represents a color value and
using same rule to serializing color value for CSS OM matches Safari's behavior
and can represent any valid color values.
This patch makes given color value parsed and then serialized with same code
in style system. If the value is `currentcolor`, `inherit`, `initial` or `reset`, sets
the value as-is for now. Additionally, when given value is invalid, sets the value
as-is for forward compatibility.
Note that automated tests will be added into input-events-exec-command.html
by the last patch.
1. https://github.com/w3c/input-events/issues/94#issuecomment-461061517
Differential Revision: https://phabricator.services.mozilla.com/D19295
--HG--
extra : moz-landing-system : lando
2019-02-19 09:31:28 +03:00
|
|
|
case EditorInputType::eFormatBackColor:
|
|
|
|
case EditorInputType::eFormatFontColor:
|
2019-02-19 09:30:50 +03:00
|
|
|
case EditorInputType::eFormatFontName:
|
2019-02-19 09:28:19 +03:00
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-19 09:33:42 +03:00
|
|
|
/**
|
|
|
|
* IsDataTransferAvailableOnHTMLEditor() returns true if aInputType on
|
|
|
|
* HTMLEditor should have non-null InputEvent.dataTransfer value.
|
|
|
|
*/
|
|
|
|
inline bool IsDataTransferAvailableOnHTMLEditor(EditorInputType aInputType) {
|
|
|
|
switch (aInputType) {
|
|
|
|
case EditorInputType::eInsertFromPaste:
|
2019-03-05 17:35:43 +03:00
|
|
|
case EditorInputType::eInsertFromPasteAsQuotation:
|
2019-02-19 09:33:42 +03:00
|
|
|
case EditorInputType::eInsertFromDrop:
|
|
|
|
case EditorInputType::eInsertTranspose:
|
|
|
|
case EditorInputType::eInsertReplacementText:
|
|
|
|
case EditorInputType::eInsertFromYank:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-03 06:38:43 +03:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
inline bool 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:
|
|
|
|
return false;
|
|
|
|
default:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-14 10:15:45 +03:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
inline bool IsCancelableBeforeInputEvent(EditorInputType aInputType) {
|
|
|
|
switch (aInputType) {
|
|
|
|
case EditorInputType::eInsertText:
|
|
|
|
return true; // In Level 1, undefined.
|
|
|
|
case EditorInputType::eInsertReplacementText:
|
|
|
|
return true; // In Level 1, undefined.
|
|
|
|
case EditorInputType::eInsertLineBreak:
|
|
|
|
return true; // In Level 1, undefined.
|
|
|
|
case EditorInputType::eInsertParagraph:
|
|
|
|
return true; // In Level 1, undefined.
|
|
|
|
case EditorInputType::eInsertOrderedList:
|
|
|
|
return true;
|
|
|
|
case EditorInputType::eInsertUnorderedList:
|
|
|
|
return true;
|
|
|
|
case EditorInputType::eInsertHorizontalRule:
|
|
|
|
return true;
|
|
|
|
case EditorInputType::eInsertFromYank:
|
|
|
|
return true;
|
|
|
|
case EditorInputType::eInsertFromDrop:
|
|
|
|
return true;
|
|
|
|
case EditorInputType::eInsertFromPaste:
|
|
|
|
return true;
|
|
|
|
case EditorInputType::eInsertFromPasteAsQuotation:
|
|
|
|
return true;
|
|
|
|
case EditorInputType::eInsertTranspose:
|
|
|
|
return true;
|
|
|
|
case EditorInputType::eInsertCompositionText:
|
|
|
|
return false;
|
|
|
|
case EditorInputType::eInsertFromComposition:
|
|
|
|
MOZ_ASSERT(!StaticPrefs::dom_input_events_conform_to_level_1());
|
|
|
|
return true;
|
|
|
|
case EditorInputType::eInsertLink:
|
|
|
|
return true;
|
|
|
|
case EditorInputType::eDeleteByComposition:
|
|
|
|
MOZ_ASSERT(!StaticPrefs::dom_input_events_conform_to_level_1());
|
|
|
|
return true;
|
|
|
|
case EditorInputType::eDeleteCompositionText:
|
|
|
|
MOZ_ASSERT(!StaticPrefs::dom_input_events_conform_to_level_1());
|
|
|
|
return false;
|
|
|
|
case EditorInputType::eDeleteWordBackward:
|
|
|
|
return true; // In Level 1, undefined.
|
|
|
|
case EditorInputType::eDeleteWordForward:
|
|
|
|
return true; // In Level 1, undefined.
|
|
|
|
case EditorInputType::eDeleteSoftLineBackward:
|
|
|
|
return true; // In Level 1, undefined.
|
|
|
|
case EditorInputType::eDeleteSoftLineForward:
|
|
|
|
return true; // In Level 1, undefined.
|
|
|
|
case EditorInputType::eDeleteEntireSoftLine:
|
|
|
|
return true; // In Level 1, undefined.
|
|
|
|
case EditorInputType::eDeleteHardLineBackward:
|
|
|
|
return true; // In Level 1, undefined.
|
|
|
|
case EditorInputType::eDeleteHardLineForward:
|
|
|
|
return true; // In Level 1, undefined.
|
|
|
|
case EditorInputType::eDeleteByDrag:
|
|
|
|
return true;
|
|
|
|
case EditorInputType::eDeleteByCut:
|
|
|
|
return true;
|
|
|
|
case EditorInputType::eDeleteContent:
|
|
|
|
return true; // In Level 1, undefined.
|
|
|
|
case EditorInputType::eDeleteContentBackward:
|
|
|
|
return true; // In Level 1, undefined.
|
|
|
|
case EditorInputType::eDeleteContentForward:
|
|
|
|
return true; // In Level 1, undefined.
|
|
|
|
case EditorInputType::eHistoryUndo:
|
|
|
|
return true;
|
|
|
|
case EditorInputType::eHistoryRedo:
|
|
|
|
return true;
|
|
|
|
case EditorInputType::eFormatBold:
|
|
|
|
return true;
|
|
|
|
case EditorInputType::eFormatItalic:
|
|
|
|
return true;
|
|
|
|
case EditorInputType::eFormatUnderline:
|
|
|
|
return true;
|
|
|
|
case EditorInputType::eFormatStrikeThrough:
|
|
|
|
return true;
|
|
|
|
case EditorInputType::eFormatSuperscript:
|
|
|
|
return true;
|
|
|
|
case EditorInputType::eFormatSubscript:
|
|
|
|
return true;
|
|
|
|
case EditorInputType::eFormatJustifyFull:
|
|
|
|
return true;
|
|
|
|
case EditorInputType::eFormatJustifyCenter:
|
|
|
|
return true;
|
|
|
|
case EditorInputType::eFormatJustifyRight:
|
|
|
|
return true;
|
|
|
|
case EditorInputType::eFormatJustifyLeft:
|
|
|
|
return true;
|
|
|
|
case EditorInputType::eFormatIndent:
|
|
|
|
return true;
|
|
|
|
case EditorInputType::eFormatOutdent:
|
|
|
|
return true;
|
|
|
|
case EditorInputType::eFormatRemove:
|
|
|
|
return true;
|
|
|
|
case EditorInputType::eFormatSetBlockTextDirection:
|
|
|
|
return true;
|
|
|
|
case EditorInputType::eFormatSetInlineTextDirection:
|
|
|
|
return true;
|
|
|
|
case EditorInputType::eFormatBackColor:
|
|
|
|
return true;
|
|
|
|
case EditorInputType::eFormatFontColor:
|
|
|
|
return true;
|
|
|
|
case EditorInputType::eFormatFontName:
|
|
|
|
return true;
|
|
|
|
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.
|
|
|
|
return false;
|
|
|
|
default:
|
|
|
|
MOZ_ASSERT_UNREACHABLE("The new input type is not handled");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-30 07:23:24 +03:00
|
|
|
#define NS_DEFINE_COMMAND(aName, aCommandStr) , aName
|
Bug 1546839 - part 2: Define commands which are handled by editor r=smaug
`NS_DEFINE_COMMAND_WITH_PARAM` macro is special case for `cmd_align`.
`cmd_align` can be mapped to multiple `Command` values. It's distinguished
with additional parameter, '"left"', '"right"', '"center"' or '"justify"'.
Therefore, we cannot map from XUL command to `Command` value simply with
hashtable created by the next patch. So, this new macro is necessary for
the next patch to ignore this special case.
The used commands are listed up from:
* [converted from `execCommand`, `cmd_bold` - `cmd_superscript`](https://searchfox.org/mozilla-central/rev/b756e6d00728dda4121f8278a744381d8643317a/dom/html/nsHTMLDocument.cpp#2066-2071)
* [converted from `execCommand`, `cmd_undo` - `cmd_redo`](https://searchfox.org/mozilla-central/rev/b756e6d00728dda4121f8278a744381d8643317a/dom/html/nsHTMLDocument.cpp#2078-2079)
* [converted from `execCommand`, `cmd_paragraphState` - `cmd_outdent`](https://searchfox.org/mozilla-central/rev/b756e6d00728dda4121f8278a744381d8643317a/dom/html/nsHTMLDocument.cpp#2080-2081,2105-2106)
* [converted from `execCommand`, `cmd_align`s](https://searchfox.org/mozilla-central/rev/b756e6d00728dda4121f8278a744381d8643317a/dom/html/nsHTMLDocument.cpp#2095-2098)
* [converted from `execCommand`, `cmd_highlight` - `cmd_decreaseFont`](https://searchfox.org/mozilla-central/rev/b756e6d00728dda4121f8278a744381d8643317a/dom/html/nsHTMLDocument.cpp#2082-2088)
* [converted from `execCommand`, `cmd_insertHR` - `cmd_ul`](https://searchfox.org/mozilla-central/rev/b756e6d00728dda4121f8278a744381d8643317a/dom/html/nsHTMLDocument.cpp#2089-2093,2101-2102)
* [converted from `execCommand`, `cmd_getContents` - `cmd_enableAbsolutePositionEditing`](https://searchfox.org/mozilla-central/rev/b756e6d00728dda4121f8278a744381d8643317a/dom/html/nsHTMLDocument.cpp#2094,2099-2100,2107-2113)
* [internal commands, `obs_documentCreated` - `obs_documentWillBeDestroyed`](https://searchfox.org/mozilla-central/rev/b756e6d00728dda4121f8278a744381d8643317a/editor/libeditor/HTMLEditorController.cpp#26-28)
* [internal command, `cmd_abbr`](https://searchfox.org/mozilla-central/rev/b756e6d00728dda4121f8278a744381d8643317a/editor/libeditor/HTMLEditorController.cpp#68)
* [internal command, `cmd_absPos`](https://searchfox.org/mozilla-central/rev/b756e6d00728dda4121f8278a744381d8643317a/editor/libeditor/HTMLEditorController.cpp#102)
* [internal commands, `cmd_acronym` - `cmd_var`](https://searchfox.org/mozilla-central/rev/b756e6d00728dda4121f8278a744381d8643317a/editor/libeditor/HTMLEditorController.cpp#58,63,65-67,69-72)
* [internal commands, `cmd_dd` - `cmd_dt`](https://searchfox.org/mozilla-central/rev/b756e6d00728dda4121f8278a744381d8643317a/editor/libeditor/HTMLEditorController.cpp#78-79)
* [internal commands, `cmd_moveDown` - `cmd_selectUp2`](https://searchfox.org/mozilla-central/rev/b756e6d00728dda4121f8278a744381d8643317a/editor/libeditor/EditorController.cpp#97-112)
* [internal command, `cmd_setDocumentModified`](https://searchfox.org/mozilla-central/rev/b756e6d00728dda4121f8278a744381d8643317a/editor/libeditor/HTMLEditorController.cpp#31)
Differential Revision: https://phabricator.services.mozilla.com/D29171
--HG--
extra : moz-landing-system : lando
2019-04-30 09:04:01 +03:00
|
|
|
#define NS_DEFINE_COMMAND_WITH_PARAM(aName, aCommandStr, aParam) , aName
|
2019-04-30 07:23:24 +03:00
|
|
|
#define NS_DEFINE_COMMAND_NO_EXEC_COMMAND(aName) , aName
|
2014-03-14 17:13:30 +04:00
|
|
|
|
2019-05-21 10:44:11 +03:00
|
|
|
typedef uint8_t CommandInt;
|
2019-04-30 07:23:24 +03:00
|
|
|
enum class Command : CommandInt {
|
|
|
|
DoNothing
|
2014-03-14 17:13:30 +04:00
|
|
|
|
|
|
|
#include "mozilla/CommandList.h"
|
|
|
|
};
|
|
|
|
#undef NS_DEFINE_COMMAND
|
Bug 1546839 - part 2: Define commands which are handled by editor r=smaug
`NS_DEFINE_COMMAND_WITH_PARAM` macro is special case for `cmd_align`.
`cmd_align` can be mapped to multiple `Command` values. It's distinguished
with additional parameter, '"left"', '"right"', '"center"' or '"justify"'.
Therefore, we cannot map from XUL command to `Command` value simply with
hashtable created by the next patch. So, this new macro is necessary for
the next patch to ignore this special case.
The used commands are listed up from:
* [converted from `execCommand`, `cmd_bold` - `cmd_superscript`](https://searchfox.org/mozilla-central/rev/b756e6d00728dda4121f8278a744381d8643317a/dom/html/nsHTMLDocument.cpp#2066-2071)
* [converted from `execCommand`, `cmd_undo` - `cmd_redo`](https://searchfox.org/mozilla-central/rev/b756e6d00728dda4121f8278a744381d8643317a/dom/html/nsHTMLDocument.cpp#2078-2079)
* [converted from `execCommand`, `cmd_paragraphState` - `cmd_outdent`](https://searchfox.org/mozilla-central/rev/b756e6d00728dda4121f8278a744381d8643317a/dom/html/nsHTMLDocument.cpp#2080-2081,2105-2106)
* [converted from `execCommand`, `cmd_align`s](https://searchfox.org/mozilla-central/rev/b756e6d00728dda4121f8278a744381d8643317a/dom/html/nsHTMLDocument.cpp#2095-2098)
* [converted from `execCommand`, `cmd_highlight` - `cmd_decreaseFont`](https://searchfox.org/mozilla-central/rev/b756e6d00728dda4121f8278a744381d8643317a/dom/html/nsHTMLDocument.cpp#2082-2088)
* [converted from `execCommand`, `cmd_insertHR` - `cmd_ul`](https://searchfox.org/mozilla-central/rev/b756e6d00728dda4121f8278a744381d8643317a/dom/html/nsHTMLDocument.cpp#2089-2093,2101-2102)
* [converted from `execCommand`, `cmd_getContents` - `cmd_enableAbsolutePositionEditing`](https://searchfox.org/mozilla-central/rev/b756e6d00728dda4121f8278a744381d8643317a/dom/html/nsHTMLDocument.cpp#2094,2099-2100,2107-2113)
* [internal commands, `obs_documentCreated` - `obs_documentWillBeDestroyed`](https://searchfox.org/mozilla-central/rev/b756e6d00728dda4121f8278a744381d8643317a/editor/libeditor/HTMLEditorController.cpp#26-28)
* [internal command, `cmd_abbr`](https://searchfox.org/mozilla-central/rev/b756e6d00728dda4121f8278a744381d8643317a/editor/libeditor/HTMLEditorController.cpp#68)
* [internal command, `cmd_absPos`](https://searchfox.org/mozilla-central/rev/b756e6d00728dda4121f8278a744381d8643317a/editor/libeditor/HTMLEditorController.cpp#102)
* [internal commands, `cmd_acronym` - `cmd_var`](https://searchfox.org/mozilla-central/rev/b756e6d00728dda4121f8278a744381d8643317a/editor/libeditor/HTMLEditorController.cpp#58,63,65-67,69-72)
* [internal commands, `cmd_dd` - `cmd_dt`](https://searchfox.org/mozilla-central/rev/b756e6d00728dda4121f8278a744381d8643317a/editor/libeditor/HTMLEditorController.cpp#78-79)
* [internal commands, `cmd_moveDown` - `cmd_selectUp2`](https://searchfox.org/mozilla-central/rev/b756e6d00728dda4121f8278a744381d8643317a/editor/libeditor/EditorController.cpp#97-112)
* [internal command, `cmd_setDocumentModified`](https://searchfox.org/mozilla-central/rev/b756e6d00728dda4121f8278a744381d8643317a/editor/libeditor/HTMLEditorController.cpp#31)
Differential Revision: https://phabricator.services.mozilla.com/D29171
--HG--
extra : moz-landing-system : lando
2019-04-30 09:04:01 +03:00
|
|
|
#undef NS_DEFINE_COMMAND_WITH_PARAM
|
Bug 1403759 - part 2: Handle edit/selection commands like insertNewline: in TextInputHandler::HandleCommand() r=m_kato
Let's make TextInputHandler::HandleCommand() handle other
commands which are caused by Backspace, Delete, Tab, ArrowUp,
ArrowDown, ArrowRight, ArrowLeft, PageUp, PageDown, Home, End
and Escape keys with various modifiers.
This patch makes Korean users can do most key operation in
editor even with composing Hangul character.
Note that this patch has a hack for cancelOperation: command.
The command is typically fired for Escape key press. However,
it's also fired for Command + Period. Unfortunately, this
behavior is really odd if subclass of NSResponder implements
|void cancelOperation:(id)sender|. If it's implemented,
Cocoa doesn't call its |void keyDown:(NSEvent)theEvent|.
Instead, it calls only |void doCommandBySelector:(SEL)aSelector|
and |void cancelOperation:(id)sender| when Command + Period is
pressed. Therefore, we cannot dispatch keydown nor keypress
event for this key combination if we implement it. Therefore,
this patch doesn't implement the method but handle it in
doCommandBySelector even though the super class of ChildView
cannot handle the command with this path.
MozReview-Commit-ID: 4hS23SiwNJv
--HG--
extra : rebase_source : 38ac1ea494b5f786ecd5c9327efbacd460b59faf
2017-12-02 08:53:10 +03:00
|
|
|
#undef NS_DEFINE_COMMAND_NO_EXEC_COMMAND
|
2014-03-14 17:13:30 +04:00
|
|
|
|
2017-12-02 04:46:31 +03:00
|
|
|
const char* ToChar(Command aCommand);
|
|
|
|
|
2019-04-30 07:24:26 +03:00
|
|
|
/**
|
|
|
|
* Return a command value for aCommandName.
|
|
|
|
* XXX: Is there a better place to put `Command` related methods instead of
|
|
|
|
* global scope in `mozilla` namespace?
|
|
|
|
*
|
2019-05-21 10:47:51 +03:00
|
|
|
* @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.
|
2019-04-30 07:24:26 +03:00
|
|
|
*/
|
2019-05-21 10:47:51 +03:00
|
|
|
Command GetInternalCommand(const char* aCommandName,
|
|
|
|
const nsCommandParams* aCommandParams = nullptr);
|
2019-04-30 07:24:26 +03:00
|
|
|
|
2012-04-25 07:00:01 +04:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2013-09-24 14:04:14 +04:00
|
|
|
/**
|
|
|
|
* All header files should include this header instead of *Events.h.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2020-03-03 06:39:26 +03:00
|
|
|
template <class T>
|
|
|
|
class OwningNonNull;
|
|
|
|
|
|
|
|
namespace dom {
|
|
|
|
class StaticRange;
|
|
|
|
}
|
|
|
|
|
2013-10-18 10:10:20 +04:00
|
|
|
#define NS_EVENT_CLASS(aPrefix, aName) class aPrefix##aName;
|
|
|
|
#define NS_ROOT_EVENT_CLASS(aPrefix, aName) NS_EVENT_CLASS(aPrefix, aName)
|
|
|
|
|
|
|
|
#include "mozilla/EventClassList.h"
|
|
|
|
|
|
|
|
#undef NS_EVENT_CLASS
|
|
|
|
#undef NS_ROOT_EVENT_CLASS
|
|
|
|
|
|
|
|
// BasicEvents.h
|
2014-11-25 08:02:31 +03:00
|
|
|
struct BaseEventFlags;
|
2013-10-18 10:10:20 +04:00
|
|
|
struct EventFlags;
|
2013-09-24 14:04:14 +04:00
|
|
|
|
2016-03-16 07:47:48 +03:00
|
|
|
class WidgetEventTime;
|
|
|
|
|
2016-04-05 08:23:13 +03:00
|
|
|
class NativeEventData;
|
|
|
|
|
2013-09-24 14:04:14 +04:00
|
|
|
// TextEvents.h
|
2017-07-06 11:36:19 +03:00
|
|
|
enum class AccessKeyType;
|
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
struct AlternativeCharCode;
|
2016-03-18 05:22:37 +03:00
|
|
|
struct ShortcutKeyCandidate;
|
|
|
|
|
|
|
|
typedef nsTArray<ShortcutKeyCandidate> ShortcutKeyCandidateArray;
|
|
|
|
typedef AutoTArray<ShortcutKeyCandidate, 10> AutoShortcutKeyCandidateArray;
|
2013-10-22 17:27:36 +04:00
|
|
|
|
|
|
|
// TextRange.h
|
2016-06-04 03:49:21 +03:00
|
|
|
typedef uint8_t RawTextRangeType;
|
|
|
|
enum class TextRangeType : RawTextRangeType;
|
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
struct TextRangeStyle;
|
|
|
|
struct TextRange;
|
|
|
|
|
2017-05-19 10:50:30 +03:00
|
|
|
class EditCommands;
|
2014-03-04 17:48:26 +04:00
|
|
|
class TextRangeArray;
|
2013-09-24 14:04:14 +04:00
|
|
|
|
2020-05-07 11:49:18 +03:00
|
|
|
typedef nsTArray<OwningNonNull<dom::StaticRange>> OwningNonNullStaticRangeArray;
|
2020-03-03 06:39:26 +03:00
|
|
|
|
2015-01-31 10:17:12 +03:00
|
|
|
// FontRange.h
|
|
|
|
struct FontRange;
|
|
|
|
|
2020-06-19 21:02:41 +03:00
|
|
|
enum MouseButton {
|
|
|
|
eNotPressed = -1,
|
|
|
|
ePrimary = 0,
|
|
|
|
eMiddle = 1,
|
|
|
|
eSecondary = 2
|
|
|
|
};
|
2019-04-21 23:13:34 +03:00
|
|
|
|
|
|
|
enum MouseButtonsFlag {
|
|
|
|
eNoButtons = 0x00,
|
2020-06-23 01:54:07 +03:00
|
|
|
ePrimaryFlag = 0x01,
|
|
|
|
eSecondaryFlag = 0x02,
|
2019-04-21 23:13:34 +03:00
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2020-02-11 04:23:12 +03:00
|
|
|
enum class TextRangeType : RawTextRangeType;
|
|
|
|
|
2020-11-26 13:34:13 +03:00
|
|
|
// IMEData.h
|
|
|
|
|
2020-11-26 15:37:42 +03:00
|
|
|
template <typename IntType>
|
|
|
|
class StartAndEndOffsets;
|
2020-11-26 13:34:13 +03:00
|
|
|
template <typename IntType>
|
|
|
|
class OffsetAndData;
|
|
|
|
|
2013-09-24 14:04:16 +04:00
|
|
|
} // namespace mozilla
|
2013-09-24 14:04:14 +04:00
|
|
|
|
|
|
|
#endif // mozilla_EventForwards_h__
|