2013-09-24 14:04:15 +04:00
|
|
|
/* -*- 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/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_TextEvents_h__
|
|
|
|
#define mozilla_TextEvents_h__
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "mozilla/Assertions.h"
|
|
|
|
#include "mozilla/BasicEvents.h"
|
2015-06-05 12:28:21 +03:00
|
|
|
#include "mozilla/CheckedInt.h"
|
2013-09-24 14:04:15 +04:00
|
|
|
#include "mozilla/EventForwards.h" // for KeyNameIndex, temporarily
|
2013-10-22 17:27:36 +04:00
|
|
|
#include "mozilla/TextRange.h"
|
2015-01-31 10:17:12 +03:00
|
|
|
#include "mozilla/FontRange.h"
|
2013-09-24 14:04:15 +04:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIDOMKeyEvent.h"
|
2016-06-21 07:13:11 +03:00
|
|
|
#include "nsISelectionController.h"
|
2015-12-01 23:25:06 +03:00
|
|
|
#include "nsISelectionListener.h"
|
2013-09-24 14:04:15 +04:00
|
|
|
#include "nsITransferable.h"
|
|
|
|
#include "nsRect.h"
|
|
|
|
#include "nsStringGlue.h"
|
|
|
|
#include "nsTArray.h"
|
2014-11-22 17:39:03 +03:00
|
|
|
#include "WritingModes.h"
|
2013-09-24 14:04:15 +04:00
|
|
|
|
2015-02-19 09:50:19 +03:00
|
|
|
class nsStringHashKey;
|
|
|
|
template<class, class> class nsDataHashtable;
|
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
/******************************************************************************
|
|
|
|
* virtual keycode values
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
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
|
|
|
#define NS_DEFINE_VK(aDOMKeyName, aDOMKeyCode) NS_##aDOMKeyName = aDOMKeyCode,
|
2014-04-01 15:42:16 +04:00
|
|
|
#include "mozilla/VirtualKeyCodeList.h"
|
2013-09-24 14:04:15 +04:00
|
|
|
#undef NS_DEFINE_VK
|
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
|
|
|
NS_VK_UNKNOWN = 0xFF
|
|
|
|
};
|
2013-09-24 14:04:15 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2017-02-08 15:04:22 +03:00
|
|
|
enum : uint32_t
|
|
|
|
{
|
|
|
|
eKeyLocationStandard = nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD,
|
|
|
|
eKeyLocationLeft = nsIDOMKeyEvent::DOM_KEY_LOCATION_LEFT,
|
|
|
|
eKeyLocationRight = nsIDOMKeyEvent::DOM_KEY_LOCATION_RIGHT,
|
|
|
|
eKeyLocationNumpad = nsIDOMKeyEvent::DOM_KEY_LOCATION_NUMPAD
|
|
|
|
};
|
|
|
|
|
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 GetDOMKeyCodeName(uint32_t aKeyCode);
|
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
namespace dom {
|
|
|
|
class PBrowserParent;
|
|
|
|
class PBrowserChild;
|
|
|
|
} // namespace dom
|
|
|
|
namespace plugins {
|
|
|
|
class PPluginInstanceChild;
|
|
|
|
} // namespace plugins
|
|
|
|
|
2017-07-06 11:36:19 +03:00
|
|
|
enum class AccessKeyType
|
|
|
|
{
|
|
|
|
// Handle access key for chrome.
|
|
|
|
eChrome,
|
|
|
|
// Handle access key for content.
|
|
|
|
eContent,
|
|
|
|
// Don't handle access key.
|
|
|
|
eNone
|
|
|
|
};
|
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::AlternativeCharCode
|
|
|
|
*
|
|
|
|
* This stores alternative charCode values of a key event with some modifiers.
|
|
|
|
* The stored values proper for testing shortcut key or access key.
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
struct AlternativeCharCode
|
|
|
|
{
|
2014-07-23 15:05:45 +04:00
|
|
|
AlternativeCharCode() :
|
|
|
|
mUnshiftedCharCode(0), mShiftedCharCode(0)
|
|
|
|
{
|
|
|
|
}
|
2013-09-24 14:04:15 +04:00
|
|
|
AlternativeCharCode(uint32_t aUnshiftedCharCode, uint32_t aShiftedCharCode) :
|
|
|
|
mUnshiftedCharCode(aUnshiftedCharCode), mShiftedCharCode(aShiftedCharCode)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
uint32_t mUnshiftedCharCode;
|
|
|
|
uint32_t mShiftedCharCode;
|
|
|
|
};
|
|
|
|
|
2016-03-18 05:22:37 +03:00
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::ShortcutKeyCandidate
|
|
|
|
*
|
|
|
|
* This stores a candidate of shortcut key combination.
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
struct ShortcutKeyCandidate
|
|
|
|
{
|
2017-06-06 02:09:40 +03:00
|
|
|
ShortcutKeyCandidate()
|
|
|
|
: mCharCode(0)
|
|
|
|
, mIgnoreShift(0)
|
|
|
|
{
|
|
|
|
}
|
2016-03-18 05:22:37 +03:00
|
|
|
ShortcutKeyCandidate(uint32_t aCharCode, bool aIgnoreShift)
|
|
|
|
: mCharCode(aCharCode)
|
|
|
|
, mIgnoreShift(aIgnoreShift)
|
|
|
|
{
|
|
|
|
}
|
2016-05-13 10:06:18 +03:00
|
|
|
// The mCharCode value which must match keyboard shortcut definition.
|
2016-03-18 05:22:37 +03:00
|
|
|
uint32_t mCharCode;
|
|
|
|
// true if Shift state can be ignored. Otherwise, Shift key state must
|
|
|
|
// match keyboard shortcut definition.
|
|
|
|
bool mIgnoreShift;
|
|
|
|
};
|
|
|
|
|
2017-06-06 02:24:35 +03:00
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::IgnoreModifierState
|
|
|
|
*
|
|
|
|
* This stores flags for modifiers that should be ignored when matching
|
|
|
|
* XBL handlers.
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
struct IgnoreModifierState
|
|
|
|
{
|
|
|
|
// When mShift is true, Shift key state will be ignored.
|
|
|
|
bool mShift;
|
|
|
|
// When mOS is true, OS key state will be ignored.
|
|
|
|
bool mOS;
|
|
|
|
|
|
|
|
IgnoreModifierState()
|
|
|
|
: mShift(false)
|
|
|
|
, mOS(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::WidgetKeyboardEvent
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class WidgetKeyboardEvent : public WidgetInputEvent
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
friend class dom::PBrowserParent;
|
|
|
|
friend class dom::PBrowserChild;
|
2017-05-19 11:24:20 +03:00
|
|
|
friend struct IPC::ParamTraits<WidgetKeyboardEvent>;
|
2013-09-24 14:04:15 +04:00
|
|
|
|
2014-11-03 10:05:12 +03:00
|
|
|
protected:
|
2013-09-24 14:04:15 +04:00
|
|
|
WidgetKeyboardEvent()
|
2016-05-12 13:18:36 +03:00
|
|
|
: mNativeKeyEvent(nullptr)
|
|
|
|
, mKeyCode(0)
|
2016-05-13 10:06:18 +03:00
|
|
|
, mCharCode(0)
|
2016-03-19 14:57:11 +03:00
|
|
|
, mPseudoCharCode(0)
|
2017-02-08 15:04:22 +03:00
|
|
|
, mLocation(eKeyLocationStandard)
|
2016-01-12 21:16:59 +03:00
|
|
|
, mUniqueId(0)
|
|
|
|
#ifdef XP_MACOSX
|
|
|
|
, mNativeModifierFlags(0)
|
2016-05-12 13:18:36 +03:00
|
|
|
, mNativeKeyCode(0)
|
|
|
|
#endif // #ifdef XP_MACOSX
|
2017-02-08 15:04:22 +03:00
|
|
|
, mKeyNameIndex(KEY_NAME_INDEX_Unidentified)
|
2016-05-12 13:18:36 +03:00
|
|
|
, mCodeNameIndex(CODE_NAME_INDEX_UNKNOWN)
|
|
|
|
, mIsRepeat(false)
|
|
|
|
, mIsComposing(false)
|
2016-03-15 08:50:16 +03:00
|
|
|
, mIsSynthesizedByTIP(false)
|
2017-05-19 10:50:30 +03:00
|
|
|
, mEditCommandsForSingleLineEditorInitialized(false)
|
|
|
|
, mEditCommandsForMultiLineEditorInitialized(false)
|
|
|
|
, mEditCommandsForRichTextEditorInitialized(false)
|
2013-09-24 14:04:15 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-10-18 10:10:20 +04:00
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual WidgetKeyboardEvent* AsKeyboardEvent() override { return this; }
|
2013-10-18 10:10:20 +04:00
|
|
|
|
2015-08-26 15:56:59 +03:00
|
|
|
WidgetKeyboardEvent(bool aIsTrusted, EventMessage aMessage,
|
|
|
|
nsIWidget* aWidget,
|
2014-11-03 10:05:12 +03:00
|
|
|
EventClassID aEventClassID = eKeyboardEventClass)
|
|
|
|
: WidgetInputEvent(aIsTrusted, aMessage, aWidget, aEventClassID)
|
2016-05-12 13:18:36 +03:00
|
|
|
, mNativeKeyEvent(nullptr)
|
2016-05-12 11:13:49 +03:00
|
|
|
, mKeyCode(0)
|
2016-05-13 10:06:18 +03:00
|
|
|
, mCharCode(0)
|
2016-03-19 14:57:11 +03:00
|
|
|
, mPseudoCharCode(0)
|
2017-02-08 15:04:22 +03:00
|
|
|
, mLocation(eKeyLocationStandard)
|
2014-04-10 11:11:36 +04:00
|
|
|
, mUniqueId(0)
|
2014-12-11 17:44:07 +03:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
, mNativeModifierFlags(0)
|
2016-05-12 13:18:36 +03:00
|
|
|
, mNativeKeyCode(0)
|
|
|
|
#endif // #ifdef XP_MACOSX
|
2017-02-08 15:04:22 +03:00
|
|
|
, mKeyNameIndex(KEY_NAME_INDEX_Unidentified)
|
2016-05-12 13:18:36 +03:00
|
|
|
, mCodeNameIndex(CODE_NAME_INDEX_UNKNOWN)
|
|
|
|
, mIsRepeat(false)
|
|
|
|
, mIsComposing(false)
|
2016-03-15 08:50:16 +03:00
|
|
|
, mIsSynthesizedByTIP(false)
|
2017-05-19 10:50:30 +03:00
|
|
|
, mEditCommandsForSingleLineEditorInitialized(false)
|
|
|
|
, mEditCommandsForMultiLineEditorInitialized(false)
|
|
|
|
, mEditCommandsForRichTextEditorInitialized(false)
|
2013-09-24 14:04:15 +04:00
|
|
|
{
|
2016-04-22 19:22:49 +03:00
|
|
|
// If this is a keyboard event on a plugin, it shouldn't fired on content.
|
2017-07-05 07:58:41 +03:00
|
|
|
if (IsKeyEventOnPlugin()) {
|
|
|
|
mFlags.mOnlySystemGroupDispatchInContent = true;
|
|
|
|
StopCrossProcessForwarding();
|
|
|
|
}
|
2016-04-22 19:22:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool IsKeyDownOrKeyDownOnPlugin(EventMessage aMessage)
|
|
|
|
{
|
|
|
|
return aMessage == eKeyDown || aMessage == eKeyDownOnPlugin;
|
|
|
|
}
|
|
|
|
bool IsKeyDownOrKeyDownOnPlugin() const
|
|
|
|
{
|
|
|
|
return IsKeyDownOrKeyDownOnPlugin(mMessage);
|
|
|
|
}
|
|
|
|
static bool IsKeyUpOrKeyUpOnPlugin(EventMessage aMessage)
|
|
|
|
{
|
|
|
|
return aMessage == eKeyUp || aMessage == eKeyUpOnPlugin;
|
|
|
|
}
|
|
|
|
bool IsKeyUpOrKeyUpOnPlugin() const
|
|
|
|
{
|
|
|
|
return IsKeyUpOrKeyUpOnPlugin(mMessage);
|
|
|
|
}
|
|
|
|
static bool IsKeyEventOnPlugin(EventMessage aMessage)
|
|
|
|
{
|
|
|
|
return aMessage == eKeyDownOnPlugin || aMessage == eKeyUpOnPlugin;
|
|
|
|
}
|
|
|
|
bool IsKeyEventOnPlugin() const
|
|
|
|
{
|
|
|
|
return IsKeyEventOnPlugin(mMessage);
|
2013-09-24 14:04:15 +04:00
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual WidgetEvent* Duplicate() const override
|
2014-01-27 10:10:44 +04:00
|
|
|
{
|
2014-08-04 09:28:48 +04:00
|
|
|
MOZ_ASSERT(mClass == eKeyboardEventClass,
|
2014-01-27 10:10:44 +04:00
|
|
|
"Duplicate() must be overridden by sub class");
|
|
|
|
// Not copying widget, it is a weak reference.
|
|
|
|
WidgetKeyboardEvent* result =
|
2015-08-22 04:34:51 +03:00
|
|
|
new WidgetKeyboardEvent(false, mMessage, nullptr);
|
2014-01-27 10:10:44 +04:00
|
|
|
result->AssignKeyEventData(*this, true);
|
2017-05-19 10:50:30 +03:00
|
|
|
result->mEditCommandsForSingleLineEditor = mEditCommandsForSingleLineEditor;
|
|
|
|
result->mEditCommandsForMultiLineEditor = mEditCommandsForMultiLineEditor;
|
|
|
|
result->mEditCommandsForRichTextEditor = mEditCommandsForRichTextEditor;
|
2014-01-27 10:10:44 +04:00
|
|
|
result->mFlags = mFlags;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-05-12 13:18:36 +03:00
|
|
|
// OS translated Unicode chars which are used for accesskey and accelkey
|
|
|
|
// handling. The handlers will try from first character to last character.
|
|
|
|
nsTArray<AlternativeCharCode> mAlternativeCharCodes;
|
|
|
|
// DOM KeyboardEvent.key only when mKeyNameIndex is KEY_NAME_INDEX_USE_STRING.
|
|
|
|
nsString mKeyValue;
|
|
|
|
// DOM KeyboardEvent.code only when mCodeNameIndex is
|
|
|
|
// CODE_NAME_INDEX_USE_STRING.
|
|
|
|
nsString mCodeValue;
|
|
|
|
|
|
|
|
#ifdef XP_MACOSX
|
|
|
|
// Values given by a native NSEvent, for use with Cocoa NPAPI plugins.
|
|
|
|
nsString mNativeCharacters;
|
|
|
|
nsString mNativeCharactersIgnoringModifiers;
|
|
|
|
// If this is non-empty, create a text event for plugins instead of a
|
|
|
|
// keyboard event.
|
|
|
|
nsString mPluginTextEventString;
|
|
|
|
#endif // #ifdef XP_MACOSX
|
|
|
|
|
|
|
|
// OS-specific native event can optionally be preserved
|
|
|
|
void* mNativeKeyEvent;
|
2016-05-13 10:06:18 +03:00
|
|
|
// A DOM keyCode value or 0. If a keypress event whose mCharCode is 0, this
|
2013-09-24 14:04:15 +04:00
|
|
|
// should be 0.
|
2016-05-12 11:13:49 +03:00
|
|
|
uint32_t mKeyCode;
|
2013-09-24 14:04:15 +04:00
|
|
|
// If the instance is a keypress event of a printable key, this is a UTF-16
|
|
|
|
// value of the key. Otherwise, 0. This value must not be a control
|
|
|
|
// character when some modifiers are active. Then, this value should be an
|
|
|
|
// unmodified value except Shift and AltGr.
|
2016-05-13 10:06:18 +03:00
|
|
|
uint32_t mCharCode;
|
2016-03-19 14:57:11 +03:00
|
|
|
// mPseudoCharCode is valid only when mMessage is an eKeyDown event.
|
2016-05-13 10:06:18 +03:00
|
|
|
// This stores mCharCode value of keypress event which is fired with same
|
2016-03-19 14:57:11 +03:00
|
|
|
// key value and same modifier state.
|
|
|
|
uint32_t mPseudoCharCode;
|
2017-02-08 15:04:22 +03:00
|
|
|
// One of eKeyLocation*
|
2016-05-12 12:17:22 +03:00
|
|
|
uint32_t mLocation;
|
2017-05-16 05:59:35 +03:00
|
|
|
// Unique id associated with a keydown / keypress event. It's ok if this wraps
|
2013-09-24 14:04:15 +04:00
|
|
|
// over long periods.
|
|
|
|
uint32_t mUniqueId;
|
|
|
|
|
2014-12-11 17:44:07 +03:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
// Values given by a native NSEvent, for use with Cocoa NPAPI plugins.
|
|
|
|
uint32_t mNativeModifierFlags;
|
2016-05-12 13:18:36 +03:00
|
|
|
uint16_t mNativeKeyCode;
|
|
|
|
#endif // #ifdef XP_MACOSX
|
2014-12-11 17:44:07 +03:00
|
|
|
|
2016-05-12 13:18:36 +03:00
|
|
|
// DOM KeyboardEvent.key
|
|
|
|
KeyNameIndex mKeyNameIndex;
|
|
|
|
// DOM KeyboardEvent.code
|
|
|
|
CodeNameIndex mCodeNameIndex;
|
2016-03-15 08:50:16 +03:00
|
|
|
|
2016-05-12 13:18:36 +03:00
|
|
|
// Indicates whether the event is generated by auto repeat or not.
|
|
|
|
// if this is keyup event, always false.
|
|
|
|
bool mIsRepeat;
|
|
|
|
// Indicates whether the event is generated during IME (or deadkey)
|
|
|
|
// composition. This is initialized by EventStateManager. So, key event
|
|
|
|
// dispatchers don't need to initialize this.
|
|
|
|
bool mIsComposing;
|
2016-03-15 08:50:16 +03:00
|
|
|
// Indicates whether the event is synthesized from Text Input Processor
|
|
|
|
// or an actual event from nsAppShell.
|
|
|
|
bool mIsSynthesizedByTIP;
|
|
|
|
|
2017-05-19 11:24:20 +03:00
|
|
|
/**
|
|
|
|
* Retrieves all edit commands from mWidget. This shouldn't be called when
|
|
|
|
* the instance is an untrusted event, doesn't have widget or in non-chrome
|
|
|
|
* process.
|
|
|
|
*/
|
|
|
|
void InitAllEditCommands();
|
|
|
|
|
2017-05-19 12:46:02 +03:00
|
|
|
/**
|
|
|
|
* Retrieves edit commands from mWidget only for aType. This shouldn't be
|
|
|
|
* called when the instance is an untrusted event or doesn't have widget.
|
|
|
|
*/
|
|
|
|
void InitEditCommandsFor(nsIWidget::NativeKeyBindingsType aType);
|
|
|
|
|
2017-05-19 11:24:20 +03:00
|
|
|
/**
|
|
|
|
* PreventNativeKeyBindings() makes the instance to not cause any edit
|
|
|
|
* actions even if it matches with a native key binding.
|
|
|
|
*/
|
|
|
|
void PreventNativeKeyBindings()
|
|
|
|
{
|
|
|
|
mEditCommandsForSingleLineEditor.Clear();
|
|
|
|
mEditCommandsForMultiLineEditor.Clear();
|
|
|
|
mEditCommandsForRichTextEditor.Clear();
|
|
|
|
mEditCommandsForSingleLineEditorInitialized = true;
|
|
|
|
mEditCommandsForMultiLineEditorInitialized = true;
|
|
|
|
mEditCommandsForRichTextEditorInitialized = true;
|
|
|
|
}
|
|
|
|
|
2017-05-19 11:49:41 +03:00
|
|
|
/**
|
|
|
|
* EditCommandsConstRef() returns reference to edit commands for aType.
|
|
|
|
*/
|
|
|
|
const nsTArray<CommandInt>&
|
|
|
|
EditCommandsConstRef(nsIWidget::NativeKeyBindingsType aType) const
|
|
|
|
{
|
|
|
|
return const_cast<WidgetKeyboardEvent*>(this)->EditCommandsRef(aType);
|
|
|
|
}
|
|
|
|
|
2017-05-19 10:50:30 +03:00
|
|
|
/**
|
|
|
|
* IsEditCommandsInitialized() returns true if edit commands for aType
|
|
|
|
* was already initialized. Otherwise, false.
|
|
|
|
*/
|
|
|
|
bool IsEditCommandsInitialized(
|
|
|
|
nsIWidget::NativeKeyBindingsType aType) const
|
|
|
|
{
|
|
|
|
return const_cast<WidgetKeyboardEvent*>(this)->
|
|
|
|
IsEditCommandsInitializedRef(aType);
|
|
|
|
}
|
2017-05-19 11:24:20 +03:00
|
|
|
|
2017-05-19 11:49:41 +03:00
|
|
|
#ifdef DEBUG
|
2017-05-19 11:24:20 +03:00
|
|
|
/**
|
|
|
|
* AreAllEditCommandsInitialized() returns true if edit commands for all
|
|
|
|
* types were already initialized. Otherwise, false.
|
|
|
|
*/
|
|
|
|
bool AreAllEditCommandsInitialized() const
|
|
|
|
{
|
|
|
|
return mEditCommandsForSingleLineEditorInitialized &&
|
|
|
|
mEditCommandsForMultiLineEditorInitialized &&
|
|
|
|
mEditCommandsForRichTextEditorInitialized;
|
|
|
|
}
|
2017-05-19 10:50:30 +03:00
|
|
|
#endif // #ifdef DEBUG
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute edit commands for aType.
|
|
|
|
*
|
|
|
|
* @return true if the caller should do nothing anymore.
|
|
|
|
* false, otherwise.
|
|
|
|
*/
|
2017-05-19 11:49:41 +03:00
|
|
|
typedef void (*DoCommandCallback)(Command, void*);
|
2017-05-19 10:50:30 +03:00
|
|
|
bool ExecuteEditCommands(nsIWidget::NativeKeyBindingsType aType,
|
2017-05-19 11:49:41 +03:00
|
|
|
DoCommandCallback aCallback,
|
2017-05-19 10:50:30 +03:00
|
|
|
void* aCallbackData);
|
|
|
|
|
2015-02-19 09:50:18 +03:00
|
|
|
// If the key should cause keypress events, this returns true.
|
|
|
|
// Otherwise, false.
|
|
|
|
bool ShouldCauseKeypressEvents() const;
|
|
|
|
|
2016-05-13 10:06:18 +03:00
|
|
|
// mCharCode value of non-eKeyPress events is always 0. However, if
|
2016-03-19 14:57:11 +03:00
|
|
|
// non-eKeyPress event has one or more alternative char code values,
|
2016-05-13 10:06:18 +03:00
|
|
|
// its first item should be the mCharCode value of following eKeyPress event.
|
|
|
|
// PseudoCharCode() returns mCharCode value for eKeyPress event,
|
2016-03-19 14:57:11 +03:00
|
|
|
// the first alternative char code value of non-eKeyPress event or 0.
|
|
|
|
uint32_t PseudoCharCode() const
|
|
|
|
{
|
2016-05-13 10:06:18 +03:00
|
|
|
return mMessage == eKeyPress ? mCharCode : mPseudoCharCode;
|
2016-03-19 14:57:11 +03:00
|
|
|
}
|
|
|
|
void SetCharCode(uint32_t aCharCode)
|
|
|
|
{
|
|
|
|
if (mMessage == eKeyPress) {
|
2016-05-13 10:06:18 +03:00
|
|
|
mCharCode = aCharCode;
|
2016-03-19 14:57:11 +03:00
|
|
|
} else {
|
|
|
|
mPseudoCharCode = aCharCode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
void GetDOMKeyName(nsAString& aKeyName)
|
|
|
|
{
|
2013-12-10 20:14:53 +04:00
|
|
|
if (mKeyNameIndex == KEY_NAME_INDEX_USE_STRING) {
|
|
|
|
aKeyName = mKeyValue;
|
|
|
|
return;
|
|
|
|
}
|
2013-09-24 14:04:15 +04:00
|
|
|
GetDOMKeyName(mKeyNameIndex, aKeyName);
|
|
|
|
}
|
2014-05-25 06:08:58 +04:00
|
|
|
void GetDOMCodeName(nsAString& aCodeName)
|
|
|
|
{
|
|
|
|
if (mCodeNameIndex == CODE_NAME_INDEX_USE_STRING) {
|
|
|
|
aCodeName = mCodeValue;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
GetDOMCodeName(mCodeNameIndex, aCodeName);
|
|
|
|
}
|
2013-09-24 14:04:15 +04:00
|
|
|
|
2015-02-19 09:50:20 +03:00
|
|
|
bool IsModifierKeyEvent() const
|
|
|
|
{
|
|
|
|
return GetModifierForKeyName(mKeyNameIndex) != MODIFIER_NONE;
|
|
|
|
}
|
|
|
|
|
2016-03-18 05:22:37 +03:00
|
|
|
/**
|
|
|
|
* Get the candidates for shortcut key.
|
|
|
|
*
|
|
|
|
* @param aCandidates [out] the candidate shortcut key combination list.
|
|
|
|
* the first item is most preferred.
|
|
|
|
*/
|
2017-06-06 02:09:40 +03:00
|
|
|
void GetShortcutKeyCandidates(ShortcutKeyCandidateArray& aCandidates) const;
|
2016-03-18 05:22:37 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the candidates for access key.
|
|
|
|
*
|
|
|
|
* @param aCandidates [out] the candidate access key list.
|
|
|
|
* the first item is most preferred.
|
|
|
|
*/
|
2017-06-06 02:09:40 +03:00
|
|
|
void GetAccessKeyCandidates(nsTArray<uint32_t>& aCandidates) const;
|
2016-03-18 05:22:37 +03:00
|
|
|
|
2017-07-06 11:36:19 +03:00
|
|
|
/**
|
|
|
|
* Check whether the modifiers match with chrome access key or
|
|
|
|
* content access key.
|
|
|
|
*/
|
|
|
|
bool ModifiersMatchWithAccessKey(AccessKeyType aType) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return active modifiers which may match with access key.
|
|
|
|
* For example, even if Alt is access key modifier, then, when Control,
|
|
|
|
* CapseLock and NumLock are active, this returns only MODIFIER_CONTROL.
|
|
|
|
*/
|
|
|
|
Modifiers ModifiersForAccessKeyMatching() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return access key modifiers.
|
|
|
|
*/
|
|
|
|
static Modifiers AccessKeyModifiers(AccessKeyType aType);
|
|
|
|
|
2015-02-19 09:50:19 +03:00
|
|
|
static void Shutdown();
|
|
|
|
|
2015-02-19 09:50:19 +03:00
|
|
|
/**
|
2016-05-12 12:17:22 +03:00
|
|
|
* ComputeLocationFromCodeValue() returns one of .mLocation value
|
2017-02-08 15:04:22 +03:00
|
|
|
* (eKeyLocation*) which is the most preferred value for the specified code
|
|
|
|
* value.
|
2015-02-19 09:50:19 +03:00
|
|
|
*/
|
2015-01-28 16:36:53 +03:00
|
|
|
static uint32_t ComputeLocationFromCodeValue(CodeNameIndex aCodeNameIndex);
|
|
|
|
|
2015-02-19 09:50:19 +03:00
|
|
|
/**
|
2016-05-12 11:13:49 +03:00
|
|
|
* ComputeKeyCodeFromKeyNameIndex() return a .mKeyCode value which can be
|
2015-02-19 09:50:19 +03:00
|
|
|
* mapped from the specified key value. Note that this returns 0 if the
|
|
|
|
* key name index is KEY_NAME_INDEX_Unidentified or KEY_NAME_INDEX_USE_STRING.
|
|
|
|
* This means that this method is useful only for non-printable keys.
|
|
|
|
*/
|
|
|
|
static uint32_t ComputeKeyCodeFromKeyNameIndex(KeyNameIndex aKeyNameIndex);
|
|
|
|
|
2015-02-19 09:50:19 +03:00
|
|
|
/**
|
|
|
|
* GetModifierForKeyName() returns a value of Modifier which is activated
|
|
|
|
* by the aKeyNameIndex.
|
|
|
|
*/
|
|
|
|
static Modifier GetModifierForKeyName(KeyNameIndex aKeyNameIndex);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* IsLockableModifier() returns true if aKeyNameIndex is a lockable modifier
|
|
|
|
* key such as CapsLock and NumLock.
|
|
|
|
*/
|
|
|
|
static bool IsLockableModifier(KeyNameIndex aKeyNameIndex);
|
|
|
|
|
2014-05-25 06:08:58 +04:00
|
|
|
static void GetDOMKeyName(KeyNameIndex aKeyNameIndex,
|
2014-01-08 20:45:30 +04:00
|
|
|
nsAString& aKeyName);
|
2014-05-25 06:08:58 +04:00
|
|
|
static void GetDOMCodeName(CodeNameIndex aCodeNameIndex,
|
|
|
|
nsAString& aCodeName);
|
2013-09-24 14:04:15 +04:00
|
|
|
|
2015-02-19 09:50:19 +03:00
|
|
|
static KeyNameIndex GetKeyNameIndex(const nsAString& aKeyValue);
|
|
|
|
static CodeNameIndex GetCodeNameIndex(const nsAString& aCodeValue);
|
|
|
|
|
2014-03-14 17:13:30 +04:00
|
|
|
static const char* GetCommandStr(Command aCommand);
|
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
void AssignKeyEventData(const WidgetKeyboardEvent& aEvent, bool aCopyTargets)
|
|
|
|
{
|
|
|
|
AssignInputEventData(aEvent, aCopyTargets);
|
|
|
|
|
2016-05-12 11:13:49 +03:00
|
|
|
mKeyCode = aEvent.mKeyCode;
|
2016-05-13 10:06:18 +03:00
|
|
|
mCharCode = aEvent.mCharCode;
|
2016-03-19 14:57:11 +03:00
|
|
|
mPseudoCharCode = aEvent.mPseudoCharCode;
|
2016-05-12 12:17:22 +03:00
|
|
|
mLocation = aEvent.mLocation;
|
2016-05-12 11:57:21 +03:00
|
|
|
mAlternativeCharCodes = aEvent.mAlternativeCharCodes;
|
2013-11-07 15:17:32 +04:00
|
|
|
mIsRepeat = aEvent.mIsRepeat;
|
2014-04-10 11:11:36 +04:00
|
|
|
mIsComposing = aEvent.mIsComposing;
|
2013-09-24 14:04:15 +04:00
|
|
|
mKeyNameIndex = aEvent.mKeyNameIndex;
|
2014-05-25 06:08:58 +04:00
|
|
|
mCodeNameIndex = aEvent.mCodeNameIndex;
|
2013-12-10 20:14:53 +04:00
|
|
|
mKeyValue = aEvent.mKeyValue;
|
2014-05-25 06:08:58 +04:00
|
|
|
mCodeValue = aEvent.mCodeValue;
|
2013-09-24 14:04:15 +04:00
|
|
|
// Don't copy mNativeKeyEvent because it may be referred after its instance
|
|
|
|
// is destroyed.
|
|
|
|
mNativeKeyEvent = nullptr;
|
|
|
|
mUniqueId = aEvent.mUniqueId;
|
2015-02-20 19:37:02 +03:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
mNativeKeyCode = aEvent.mNativeKeyCode;
|
|
|
|
mNativeModifierFlags = aEvent.mNativeModifierFlags;
|
|
|
|
mNativeCharacters.Assign(aEvent.mNativeCharacters);
|
|
|
|
mNativeCharactersIgnoringModifiers.
|
|
|
|
Assign(aEvent.mNativeCharactersIgnoringModifiers);
|
|
|
|
mPluginTextEventString.Assign(aEvent.mPluginTextEventString);
|
|
|
|
#endif
|
2016-03-15 08:50:16 +03:00
|
|
|
mIsSynthesizedByTIP = aEvent.mIsSynthesizedByTIP;
|
2017-05-19 10:50:30 +03:00
|
|
|
|
|
|
|
// Don't copy mEditCommandsFor*Editor because it may require a lot of
|
|
|
|
// memory space. For example, if the event is dispatched but grabbed by
|
|
|
|
// a JS variable, they are not necessary anymore.
|
|
|
|
|
|
|
|
mEditCommandsForSingleLineEditorInitialized =
|
|
|
|
aEvent.mEditCommandsForSingleLineEditorInitialized;
|
|
|
|
mEditCommandsForMultiLineEditorInitialized =
|
|
|
|
aEvent.mEditCommandsForMultiLineEditorInitialized;
|
|
|
|
mEditCommandsForRichTextEditorInitialized =
|
|
|
|
aEvent.mEditCommandsForRichTextEditorInitialized;
|
2013-09-24 14:04:15 +04:00
|
|
|
}
|
2015-02-19 09:50:19 +03:00
|
|
|
|
|
|
|
private:
|
2016-03-11 05:18:39 +03:00
|
|
|
static const char16_t* const kKeyNames[];
|
|
|
|
static const char16_t* const kCodeNames[];
|
2015-02-19 09:50:19 +03:00
|
|
|
typedef nsDataHashtable<nsStringHashKey,
|
|
|
|
KeyNameIndex> KeyNameIndexHashtable;
|
|
|
|
typedef nsDataHashtable<nsStringHashKey,
|
|
|
|
CodeNameIndex> CodeNameIndexHashtable;
|
|
|
|
static KeyNameIndexHashtable* sKeyNameIndexHashtable;
|
|
|
|
static CodeNameIndexHashtable* sCodeNameIndexHashtable;
|
2017-05-19 10:50:30 +03:00
|
|
|
|
|
|
|
// mEditCommandsFor*Editor store edit commands. This should be initialized
|
|
|
|
// with InitEditCommandsFor().
|
|
|
|
// XXX Ideally, this should be array of Command rather than CommandInt.
|
|
|
|
// However, ParamTraits isn't aware of enum array.
|
|
|
|
nsTArray<CommandInt> mEditCommandsForSingleLineEditor;
|
|
|
|
nsTArray<CommandInt> mEditCommandsForMultiLineEditor;
|
|
|
|
nsTArray<CommandInt> mEditCommandsForRichTextEditor;
|
|
|
|
|
|
|
|
nsTArray<CommandInt>& EditCommandsRef(nsIWidget::NativeKeyBindingsType aType)
|
|
|
|
{
|
|
|
|
switch (aType) {
|
|
|
|
case nsIWidget::NativeKeyBindingsForSingleLineEditor:
|
|
|
|
return mEditCommandsForSingleLineEditor;
|
|
|
|
case nsIWidget::NativeKeyBindingsForMultiLineEditor:
|
|
|
|
return mEditCommandsForMultiLineEditor;
|
|
|
|
case nsIWidget::NativeKeyBindingsForRichTextEditor:
|
|
|
|
return mEditCommandsForRichTextEditor;
|
|
|
|
default:
|
|
|
|
MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE(
|
|
|
|
"Invalid native key binding type");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// mEditCommandsFor*EditorInitialized are set to true when
|
|
|
|
// InitEditCommandsFor() initializes edit commands for the type.
|
|
|
|
bool mEditCommandsForSingleLineEditorInitialized;
|
|
|
|
bool mEditCommandsForMultiLineEditorInitialized;
|
|
|
|
bool mEditCommandsForRichTextEditorInitialized;
|
|
|
|
|
|
|
|
bool& IsEditCommandsInitializedRef(nsIWidget::NativeKeyBindingsType aType)
|
|
|
|
{
|
|
|
|
switch (aType) {
|
|
|
|
case nsIWidget::NativeKeyBindingsForSingleLineEditor:
|
|
|
|
return mEditCommandsForSingleLineEditorInitialized;
|
|
|
|
case nsIWidget::NativeKeyBindingsForMultiLineEditor:
|
|
|
|
return mEditCommandsForMultiLineEditorInitialized;
|
|
|
|
case nsIWidget::NativeKeyBindingsForRichTextEditor:
|
|
|
|
return mEditCommandsForRichTextEditorInitialized;
|
|
|
|
default:
|
|
|
|
MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE(
|
|
|
|
"Invalid native key binding type");
|
|
|
|
}
|
|
|
|
}
|
2017-07-06 11:36:19 +03:00
|
|
|
|
|
|
|
static int32_t GenericAccessModifierKeyPref();
|
|
|
|
static int32_t ChromeAccessModifierMaskPref();
|
|
|
|
static int32_t ContentAccessModifierMaskPref();
|
2013-09-24 14:04:15 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::WidgetCompositionEvent
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class WidgetCompositionEvent : public WidgetGUIEvent
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
friend class mozilla::dom::PBrowserParent;
|
|
|
|
friend class mozilla::dom::PBrowserChild;
|
|
|
|
|
|
|
|
WidgetCompositionEvent()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual WidgetCompositionEvent* AsCompositionEvent() override
|
2013-10-18 10:10:20 +04:00
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2015-08-26 15:56:59 +03:00
|
|
|
WidgetCompositionEvent(bool aIsTrusted, EventMessage aMessage,
|
2014-01-15 18:41:39 +04:00
|
|
|
nsIWidget* aWidget)
|
2014-08-04 09:28:48 +04:00
|
|
|
: WidgetGUIEvent(aIsTrusted, aMessage, aWidget, eCompositionEventClass)
|
2015-12-11 09:15:57 +03:00
|
|
|
, mNativeIMEContext(aWidget)
|
2015-09-08 06:54:14 +03:00
|
|
|
, mOriginalMessage(eVoidEvent)
|
2013-09-24 14:04:15 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual WidgetEvent* Duplicate() const override
|
2014-01-27 10:10:44 +04:00
|
|
|
{
|
2014-08-04 09:28:48 +04:00
|
|
|
MOZ_ASSERT(mClass == eCompositionEventClass,
|
2014-01-27 10:10:44 +04:00
|
|
|
"Duplicate() must be overridden by sub class");
|
|
|
|
// Not copying widget, it is a weak reference.
|
|
|
|
WidgetCompositionEvent* result =
|
2015-08-22 04:34:51 +03:00
|
|
|
new WidgetCompositionEvent(false, mMessage, nullptr);
|
2014-01-27 10:10:44 +04:00
|
|
|
result->AssignCompositionEventData(*this, true);
|
|
|
|
result->mFlags = mFlags;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
// The composition string or the commit string. If the instance is a
|
|
|
|
// compositionstart event, this is initialized with selected text by
|
|
|
|
// TextComposition automatically.
|
2014-10-07 14:01:46 +04:00
|
|
|
nsString mData;
|
2013-09-24 14:04:15 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<TextRangeArray> mRanges;
|
2014-10-07 14:01:47 +04:00
|
|
|
|
2015-12-11 09:15:57 +03:00
|
|
|
// mNativeIMEContext stores the native IME context which causes the
|
|
|
|
// composition event.
|
|
|
|
widget::NativeIMEContext mNativeIMEContext;
|
|
|
|
|
2015-09-08 06:54:14 +03:00
|
|
|
// If the instance is a clone of another event, mOriginalMessage stores
|
|
|
|
// the another event's mMessage.
|
|
|
|
EventMessage mOriginalMessage;
|
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
void AssignCompositionEventData(const WidgetCompositionEvent& aEvent,
|
|
|
|
bool aCopyTargets)
|
|
|
|
{
|
|
|
|
AssignGUIEventData(aEvent, aCopyTargets);
|
|
|
|
|
2014-10-07 14:01:46 +04:00
|
|
|
mData = aEvent.mData;
|
2015-09-08 06:54:14 +03:00
|
|
|
mOriginalMessage = aEvent.mOriginalMessage;
|
2016-07-26 13:09:07 +03:00
|
|
|
mRanges = aEvent.mRanges;
|
2014-10-07 14:01:47 +04:00
|
|
|
|
|
|
|
// Currently, we don't need to copy the other members because they are
|
|
|
|
// for internal use only (not available from JS).
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsComposing() const
|
|
|
|
{
|
|
|
|
return mRanges && mRanges->IsComposing();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t TargetClauseOffset() const
|
|
|
|
{
|
|
|
|
return mRanges ? mRanges->TargetClauseOffset() : 0;
|
|
|
|
}
|
|
|
|
|
2015-06-11 13:50:15 +03:00
|
|
|
uint32_t TargetClauseLength() const
|
|
|
|
{
|
|
|
|
uint32_t length = UINT32_MAX;
|
|
|
|
if (mRanges) {
|
|
|
|
length = mRanges->TargetClauseLength();
|
|
|
|
}
|
|
|
|
return length == UINT32_MAX ? mData.Length() : length;
|
|
|
|
}
|
|
|
|
|
2014-10-07 14:01:47 +04:00
|
|
|
uint32_t RangeCount() const
|
|
|
|
{
|
|
|
|
return mRanges ? mRanges->Length() : 0;
|
2013-09-24 14:04:15 +04:00
|
|
|
}
|
2014-11-25 08:02:30 +03:00
|
|
|
|
|
|
|
bool CausesDOMTextEvent() const
|
|
|
|
{
|
2015-09-11 15:21:27 +03:00
|
|
|
return mMessage == eCompositionChange ||
|
2015-09-11 15:21:27 +03:00
|
|
|
mMessage == eCompositionCommit ||
|
2015-09-11 15:21:26 +03:00
|
|
|
mMessage == eCompositionCommitAsIs;
|
2014-11-25 08:02:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CausesDOMCompositionEndEvent() const
|
|
|
|
{
|
2015-09-11 15:21:27 +03:00
|
|
|
return mMessage == eCompositionEnd ||
|
2015-09-11 15:21:27 +03:00
|
|
|
mMessage == eCompositionCommit ||
|
2015-09-11 15:21:26 +03:00
|
|
|
mMessage == eCompositionCommitAsIs;
|
2014-11-25 08:02:30 +03:00
|
|
|
}
|
2015-09-08 06:54:14 +03:00
|
|
|
|
|
|
|
bool IsFollowedByCompositionEnd() const
|
|
|
|
{
|
2016-10-12 11:09:02 +03:00
|
|
|
return IsFollowedByCompositionEnd(mOriginalMessage);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool IsFollowedByCompositionEnd(EventMessage aEventMessage)
|
|
|
|
{
|
|
|
|
return aEventMessage == eCompositionCommit ||
|
|
|
|
aEventMessage == eCompositionCommitAsIs;
|
2015-09-08 06:54:14 +03:00
|
|
|
}
|
2013-09-24 14:04:15 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::WidgetQueryContentEvent
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class WidgetQueryContentEvent : public WidgetGUIEvent
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
friend class dom::PBrowserParent;
|
|
|
|
friend class dom::PBrowserChild;
|
|
|
|
|
|
|
|
WidgetQueryContentEvent()
|
2016-01-12 21:16:59 +03:00
|
|
|
: mSucceeded(false)
|
|
|
|
, mUseNativeLineBreak(true)
|
|
|
|
, mWithFontRanges(false)
|
2013-09-24 14:04:15 +04:00
|
|
|
{
|
|
|
|
MOZ_CRASH("WidgetQueryContentEvent is created without proper arguments");
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual WidgetQueryContentEvent* AsQueryContentEvent() override
|
2013-10-18 10:10:20 +04:00
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2015-08-26 15:56:59 +03:00
|
|
|
WidgetQueryContentEvent(bool aIsTrusted, EventMessage aMessage,
|
2014-04-26 03:52:12 +04:00
|
|
|
nsIWidget* aWidget)
|
2014-08-04 09:28:49 +04:00
|
|
|
: WidgetGUIEvent(aIsTrusted, aMessage, aWidget, eQueryContentEventClass)
|
2014-04-26 03:52:12 +04:00
|
|
|
, mSucceeded(false)
|
|
|
|
, mUseNativeLineBreak(true)
|
2015-01-31 10:17:12 +03:00
|
|
|
, mWithFontRanges(false)
|
2013-09-24 14:04:15 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-07-28 18:37:09 +03:00
|
|
|
WidgetQueryContentEvent(EventMessage aMessage,
|
|
|
|
const WidgetQueryContentEvent& aOtherEvent)
|
|
|
|
: WidgetGUIEvent(aOtherEvent.IsTrusted(), aMessage,
|
|
|
|
const_cast<nsIWidget*>(aOtherEvent.mWidget.get()),
|
|
|
|
eQueryContentEventClass)
|
|
|
|
, mSucceeded(false)
|
|
|
|
, mUseNativeLineBreak(aOtherEvent.mUseNativeLineBreak)
|
|
|
|
, mWithFontRanges(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual WidgetEvent* Duplicate() const override
|
2014-01-27 10:10:44 +04:00
|
|
|
{
|
|
|
|
// This event isn't an internal event of any DOM event.
|
2014-03-27 17:53:19 +04:00
|
|
|
NS_ASSERTION(!IsAllowedToDispatchDOMEvent(),
|
|
|
|
"WidgetQueryContentEvent needs to support Duplicate()");
|
2014-01-27 10:10:44 +04:00
|
|
|
MOZ_CRASH("WidgetQueryContentEvent doesn't support Duplicate()");
|
|
|
|
}
|
|
|
|
|
2016-06-16 08:10:49 +03:00
|
|
|
struct Options final
|
|
|
|
{
|
|
|
|
bool mUseNativeLineBreak;
|
|
|
|
bool mRelativeToInsertionPoint;
|
|
|
|
|
|
|
|
explicit Options()
|
|
|
|
: mUseNativeLineBreak(true)
|
|
|
|
, mRelativeToInsertionPoint(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
explicit Options(const WidgetQueryContentEvent& aEvent)
|
|
|
|
: mUseNativeLineBreak(aEvent.mUseNativeLineBreak)
|
|
|
|
, mRelativeToInsertionPoint(aEvent.mInput.mRelativeToInsertionPoint)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void Init(const Options& aOptions)
|
|
|
|
{
|
|
|
|
mUseNativeLineBreak = aOptions.mUseNativeLineBreak;
|
|
|
|
mInput.mRelativeToInsertionPoint = aOptions.mRelativeToInsertionPoint;
|
|
|
|
MOZ_ASSERT(mInput.IsValidEventMessage(mMessage));
|
|
|
|
}
|
|
|
|
|
|
|
|
void InitForQueryTextContent(int64_t aOffset, uint32_t aLength,
|
|
|
|
const Options& aOptions = Options())
|
2013-09-24 14:04:15 +04:00
|
|
|
{
|
2015-09-10 04:40:05 +03:00
|
|
|
NS_ASSERTION(mMessage == eQueryTextContent,
|
2013-09-24 14:04:15 +04:00
|
|
|
"wrong initializer is called");
|
|
|
|
mInput.mOffset = aOffset;
|
|
|
|
mInput.mLength = aLength;
|
2016-06-16 08:10:49 +03:00
|
|
|
Init(aOptions);
|
|
|
|
MOZ_ASSERT(mInput.IsValidOffset());
|
2013-09-24 14:04:15 +04:00
|
|
|
}
|
|
|
|
|
2016-06-16 08:10:49 +03:00
|
|
|
void InitForQueryCaretRect(int64_t aOffset,
|
|
|
|
const Options& aOptions = Options())
|
2013-09-24 14:04:15 +04:00
|
|
|
{
|
2015-09-10 04:40:06 +03:00
|
|
|
NS_ASSERTION(mMessage == eQueryCaretRect,
|
2013-09-24 14:04:15 +04:00
|
|
|
"wrong initializer is called");
|
|
|
|
mInput.mOffset = aOffset;
|
2016-06-16 08:10:49 +03:00
|
|
|
Init(aOptions);
|
|
|
|
MOZ_ASSERT(mInput.IsValidOffset());
|
2013-09-24 14:04:15 +04:00
|
|
|
}
|
|
|
|
|
2016-06-16 08:10:49 +03:00
|
|
|
void InitForQueryTextRect(int64_t aOffset, uint32_t aLength,
|
|
|
|
const Options& aOptions = Options())
|
2013-09-24 14:04:15 +04:00
|
|
|
{
|
2015-09-11 15:21:26 +03:00
|
|
|
NS_ASSERTION(mMessage == eQueryTextRect,
|
2013-09-24 14:04:15 +04:00
|
|
|
"wrong initializer is called");
|
|
|
|
mInput.mOffset = aOffset;
|
|
|
|
mInput.mLength = aLength;
|
2016-06-16 08:10:49 +03:00
|
|
|
Init(aOptions);
|
|
|
|
MOZ_ASSERT(mInput.IsValidOffset());
|
2013-09-24 14:04:15 +04:00
|
|
|
}
|
|
|
|
|
2016-06-21 07:13:11 +03:00
|
|
|
void InitForQuerySelectedText(SelectionType aSelectionType,
|
2016-06-16 08:10:49 +03:00
|
|
|
const Options& aOptions = Options())
|
2016-06-21 07:13:11 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(mMessage == eQuerySelectedText);
|
|
|
|
MOZ_ASSERT(aSelectionType != SelectionType::eNone);
|
|
|
|
mInput.mSelectionType = aSelectionType;
|
2016-06-16 08:10:49 +03:00
|
|
|
Init(aOptions);
|
2016-06-21 07:13:11 +03:00
|
|
|
}
|
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
void InitForQueryDOMWidgetHittest(const mozilla::LayoutDeviceIntPoint& aPoint)
|
|
|
|
{
|
2015-09-10 04:40:06 +03:00
|
|
|
NS_ASSERTION(mMessage == eQueryDOMWidgetHittest,
|
2013-09-24 14:04:15 +04:00
|
|
|
"wrong initializer is called");
|
2016-04-18 17:09:02 +03:00
|
|
|
mRefPoint = aPoint;
|
2013-09-24 14:04:15 +04:00
|
|
|
}
|
|
|
|
|
2016-06-23 12:40:04 +03:00
|
|
|
void InitForQueryTextRectArray(uint32_t aOffset, uint32_t aLength,
|
|
|
|
const Options& aOptions = Options())
|
|
|
|
{
|
|
|
|
NS_ASSERTION(mMessage == eQueryTextRectArray,
|
|
|
|
"wrong initializer is called");
|
|
|
|
mInput.mOffset = aOffset;
|
|
|
|
mInput.mLength = aLength;
|
|
|
|
Init(aOptions);
|
|
|
|
}
|
|
|
|
|
2015-01-31 10:17:12 +03:00
|
|
|
void RequestFontRanges()
|
|
|
|
{
|
2015-09-10 04:40:05 +03:00
|
|
|
NS_ASSERTION(mMessage == eQueryTextContent,
|
2015-01-31 10:17:12 +03:00
|
|
|
"not querying text content");
|
|
|
|
mWithFontRanges = true;
|
|
|
|
}
|
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
uint32_t GetSelectionStart(void) const
|
|
|
|
{
|
2015-09-10 04:40:05 +03:00
|
|
|
NS_ASSERTION(mMessage == eQuerySelectedText,
|
2013-09-24 14:04:15 +04:00
|
|
|
"not querying selection");
|
|
|
|
return mReply.mOffset + (mReply.mReversed ? mReply.mString.Length() : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t GetSelectionEnd(void) const
|
|
|
|
{
|
2015-09-10 04:40:05 +03:00
|
|
|
NS_ASSERTION(mMessage == eQuerySelectedText,
|
2013-09-24 14:04:15 +04:00
|
|
|
"not querying selection");
|
|
|
|
return mReply.mOffset + (mReply.mReversed ? 0 : mReply.mString.Length());
|
|
|
|
}
|
|
|
|
|
2014-12-05 05:15:43 +03:00
|
|
|
mozilla::WritingMode GetWritingMode(void) const
|
|
|
|
{
|
2015-09-10 04:40:05 +03:00
|
|
|
NS_ASSERTION(mMessage == eQuerySelectedText ||
|
2015-09-10 04:40:06 +03:00
|
|
|
mMessage == eQueryCaretRect ||
|
2015-09-11 15:21:26 +03:00
|
|
|
mMessage == eQueryTextRect,
|
2015-02-10 18:28:05 +03:00
|
|
|
"not querying selection or text rect");
|
2014-12-05 05:15:43 +03:00
|
|
|
return mReply.mWritingMode;
|
|
|
|
}
|
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
bool mSucceeded;
|
2014-04-26 03:52:12 +04:00
|
|
|
bool mUseNativeLineBreak;
|
2015-01-31 10:17:12 +03:00
|
|
|
bool mWithFontRanges;
|
2016-06-21 07:13:11 +03:00
|
|
|
struct Input final
|
2013-09-24 14:04:15 +04:00
|
|
|
{
|
2015-05-26 11:14:35 +03:00
|
|
|
uint32_t EndOffset() const
|
|
|
|
{
|
2015-06-05 12:28:21 +03:00
|
|
|
CheckedInt<uint32_t> endOffset =
|
|
|
|
CheckedInt<uint32_t>(mOffset) + mLength;
|
|
|
|
return NS_WARN_IF(!endOffset.isValid()) ? UINT32_MAX : endOffset.value();
|
2015-05-26 11:14:35 +03:00
|
|
|
}
|
|
|
|
|
2016-06-16 08:10:49 +03:00
|
|
|
int64_t mOffset;
|
2013-09-24 14:04:15 +04:00
|
|
|
uint32_t mLength;
|
2016-06-21 07:13:11 +03:00
|
|
|
SelectionType mSelectionType;
|
2016-06-16 08:10:49 +03:00
|
|
|
// If mOffset is true, mOffset is relative to the start offset of
|
|
|
|
// composition if there is, otherwise, the start of the first selection
|
|
|
|
// range.
|
|
|
|
bool mRelativeToInsertionPoint;
|
2016-06-21 07:13:11 +03:00
|
|
|
|
|
|
|
Input()
|
|
|
|
: mOffset(0)
|
|
|
|
, mLength(0)
|
|
|
|
, mSelectionType(SelectionType::eNormal)
|
2016-06-16 08:10:49 +03:00
|
|
|
, mRelativeToInsertionPoint(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsValidOffset() const
|
|
|
|
{
|
|
|
|
return mRelativeToInsertionPoint || mOffset >= 0;
|
|
|
|
}
|
|
|
|
bool IsValidEventMessage(EventMessage aEventMessage) const
|
|
|
|
{
|
|
|
|
if (!mRelativeToInsertionPoint) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
switch (aEventMessage) {
|
|
|
|
case eQueryTextContent:
|
|
|
|
case eQueryCaretRect:
|
|
|
|
case eQueryTextRect:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool MakeOffsetAbsolute(uint32_t aInsertionPointOffset)
|
2016-06-21 07:13:11 +03:00
|
|
|
{
|
2016-06-16 08:10:49 +03:00
|
|
|
if (NS_WARN_IF(!mRelativeToInsertionPoint)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
mRelativeToInsertionPoint = false;
|
|
|
|
// If mOffset + aInsertionPointOffset becomes negative value,
|
|
|
|
// we should assume the absolute offset is 0.
|
|
|
|
if (mOffset < 0 && -mOffset > aInsertionPointOffset) {
|
|
|
|
mOffset = 0;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
// Otherwise, we don't allow too large offset.
|
|
|
|
CheckedInt<uint32_t> absOffset = mOffset + aInsertionPointOffset;
|
|
|
|
if (NS_WARN_IF(!absOffset.isValid())) {
|
|
|
|
mOffset = UINT32_MAX;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
mOffset = absOffset.value();
|
|
|
|
return true;
|
2016-06-21 07:13:11 +03:00
|
|
|
}
|
2013-09-24 14:04:15 +04:00
|
|
|
} mInput;
|
2015-04-14 13:46:51 +03:00
|
|
|
|
2016-06-21 07:13:11 +03:00
|
|
|
struct Reply final
|
2013-09-24 14:04:15 +04:00
|
|
|
{
|
|
|
|
void* mContentsRoot;
|
|
|
|
uint32_t mOffset;
|
2015-09-10 04:40:06 +03:00
|
|
|
// mTentativeCaretOffset is used by only eQueryCharacterAtPoint.
|
2016-04-18 17:09:02 +03:00
|
|
|
// This is the offset where caret would be if user clicked at the mRefPoint.
|
2015-04-14 08:27:37 +03:00
|
|
|
uint32_t mTentativeCaretOffset;
|
2013-09-24 14:04:15 +04:00
|
|
|
nsString mString;
|
2015-10-05 08:46:39 +03:00
|
|
|
// mRect is used by eQueryTextRect, eQueryCaretRect, eQueryCharacterAtPoint
|
|
|
|
// and eQueryEditorRect. The coordinates is system coordinates relative to
|
|
|
|
// the top level widget of mFocusedWidget. E.g., if a <xul:panel> which
|
|
|
|
// is owned by a window has focused editor, the offset of mRect is relative
|
|
|
|
// to the owner window, not the <xul:panel>.
|
2015-02-04 23:21:03 +03:00
|
|
|
mozilla::LayoutDeviceIntRect mRect;
|
2013-09-24 14:04:15 +04:00
|
|
|
// The return widget has the caret. This is set at all query events.
|
|
|
|
nsIWidget* mFocusedWidget;
|
2014-11-22 17:39:03 +03:00
|
|
|
// mozilla::WritingMode value at the end (focus) of the selection
|
|
|
|
mozilla::WritingMode mWritingMode;
|
2015-09-10 04:40:05 +03:00
|
|
|
// Used by eQuerySelectionAsTransferable
|
2013-09-24 14:04:15 +04:00
|
|
|
nsCOMPtr<nsITransferable> mTransferable;
|
2015-09-10 04:40:05 +03:00
|
|
|
// Used by eQueryTextContent with font ranges requested
|
2016-02-02 18:36:30 +03:00
|
|
|
AutoTArray<mozilla::FontRange, 1> mFontRanges;
|
2016-06-23 12:40:04 +03:00
|
|
|
// Used by eQueryTextRectArray
|
|
|
|
nsTArray<mozilla::LayoutDeviceIntRect> mRectArray;
|
2015-04-14 13:46:51 +03:00
|
|
|
// true if selection is reversed (end < start)
|
|
|
|
bool mReversed;
|
|
|
|
// true if the selection exists
|
|
|
|
bool mHasSelection;
|
|
|
|
// true if DOM element under mouse belongs to widget
|
|
|
|
bool mWidgetIsHit;
|
|
|
|
|
|
|
|
Reply()
|
|
|
|
: mContentsRoot(nullptr)
|
|
|
|
, mOffset(NOT_FOUND)
|
|
|
|
, mTentativeCaretOffset(NOT_FOUND)
|
|
|
|
, mFocusedWidget(nullptr)
|
|
|
|
, mReversed(false)
|
|
|
|
, mHasSelection(false)
|
|
|
|
, mWidgetIsHit(false)
|
|
|
|
{
|
|
|
|
}
|
2013-09-24 14:04:15 +04:00
|
|
|
} mReply;
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
NOT_FOUND = UINT32_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
// values of mComputedScrollAction
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
SCROLL_ACTION_NONE,
|
|
|
|
SCROLL_ACTION_LINE,
|
|
|
|
SCROLL_ACTION_PAGE
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::WidgetSelectionEvent
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class WidgetSelectionEvent : public WidgetGUIEvent
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
friend class mozilla::dom::PBrowserParent;
|
|
|
|
friend class mozilla::dom::PBrowserChild;
|
|
|
|
|
|
|
|
WidgetSelectionEvent()
|
2015-05-28 07:51:40 +03:00
|
|
|
: mOffset(0)
|
2014-01-15 18:41:39 +04:00
|
|
|
, mLength(0)
|
|
|
|
, mReversed(false)
|
|
|
|
, mExpandToClusterBoundary(true)
|
|
|
|
, mSucceeded(false)
|
2016-01-12 21:16:59 +03:00
|
|
|
, mUseNativeLineBreak(true)
|
2013-09-24 14:04:15 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual WidgetSelectionEvent* AsSelectionEvent() override
|
2013-10-18 10:10:20 +04:00
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2015-08-26 15:56:59 +03:00
|
|
|
WidgetSelectionEvent(bool aIsTrusted, EventMessage aMessage,
|
|
|
|
nsIWidget* aWidget)
|
2014-08-04 09:28:49 +04:00
|
|
|
: WidgetGUIEvent(aIsTrusted, aMessage, aWidget, eSelectionEventClass)
|
2014-01-15 18:41:39 +04:00
|
|
|
, mOffset(0)
|
|
|
|
, mLength(0)
|
|
|
|
, mReversed(false)
|
|
|
|
, mExpandToClusterBoundary(true)
|
|
|
|
, mSucceeded(false)
|
2014-04-26 03:52:12 +04:00
|
|
|
, mUseNativeLineBreak(true)
|
2015-12-01 23:25:06 +03:00
|
|
|
, mReason(nsISelectionListener::NO_REASON)
|
2013-09-24 14:04:15 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual WidgetEvent* Duplicate() const override
|
2014-01-27 10:10:44 +04:00
|
|
|
{
|
|
|
|
// This event isn't an internal event of any DOM event.
|
2014-03-27 17:53:19 +04:00
|
|
|
NS_ASSERTION(!IsAllowedToDispatchDOMEvent(),
|
|
|
|
"WidgetSelectionEvent needs to support Duplicate()");
|
2014-01-27 10:10:44 +04:00
|
|
|
MOZ_CRASH("WidgetSelectionEvent doesn't support Duplicate()");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
// Start offset of selection
|
|
|
|
uint32_t mOffset;
|
|
|
|
// Length of selection
|
|
|
|
uint32_t mLength;
|
|
|
|
// Selection "anchor" should be in front
|
|
|
|
bool mReversed;
|
|
|
|
// Cluster-based or character-based
|
|
|
|
bool mExpandToClusterBoundary;
|
|
|
|
// true if setting selection succeeded.
|
|
|
|
bool mSucceeded;
|
2014-04-26 03:52:12 +04:00
|
|
|
// true if native line breaks are used for mOffset and mLength
|
|
|
|
bool mUseNativeLineBreak;
|
2015-12-01 23:25:06 +03:00
|
|
|
// Fennec provides eSetSelection reason codes for downstream
|
|
|
|
// use in AccessibleCaret visibility logic.
|
|
|
|
int16_t mReason;
|
2013-09-24 14:04:15 +04:00
|
|
|
};
|
|
|
|
|
2014-04-10 11:11:37 +04:00
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::InternalEditorInputEvent
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class InternalEditorInputEvent : public InternalUIEvent
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
InternalEditorInputEvent()
|
|
|
|
: mIsComposing(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual InternalEditorInputEvent* AsEditorInputEvent() override
|
2014-04-10 11:11:37 +04:00
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2015-08-26 15:56:59 +03:00
|
|
|
InternalEditorInputEvent(bool aIsTrusted, EventMessage aMessage,
|
2017-06-17 06:42:05 +03:00
|
|
|
nsIWidget* aWidget = nullptr)
|
2014-08-04 09:28:49 +04:00
|
|
|
: InternalUIEvent(aIsTrusted, aMessage, aWidget, eEditorInputEventClass)
|
2014-04-10 11:11:37 +04:00
|
|
|
, mIsComposing(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual WidgetEvent* Duplicate() const override
|
2014-04-10 11:11:37 +04:00
|
|
|
{
|
2014-08-04 09:28:49 +04:00
|
|
|
MOZ_ASSERT(mClass == eEditorInputEventClass,
|
2014-04-10 11:11:37 +04:00
|
|
|
"Duplicate() must be overridden by sub class");
|
|
|
|
// Not copying widget, it is a weak reference.
|
|
|
|
InternalEditorInputEvent* result =
|
2015-08-22 04:34:51 +03:00
|
|
|
new InternalEditorInputEvent(false, mMessage, nullptr);
|
2014-04-10 11:11:37 +04:00
|
|
|
result->AssignEditorInputEventData(*this, true);
|
|
|
|
result->mFlags = mFlags;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool mIsComposing;
|
|
|
|
|
|
|
|
void AssignEditorInputEventData(const InternalEditorInputEvent& aEvent,
|
|
|
|
bool aCopyTargets)
|
|
|
|
{
|
|
|
|
AssignUIEventData(aEvent, aCopyTargets);
|
|
|
|
|
|
|
|
mIsComposing = aEvent.mIsComposing;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_TextEvents_h__
|