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"
|
|
|
|
#include "mozilla/EventForwards.h" // for KeyNameIndex, temporarily
|
2013-10-22 17:27:36 +04:00
|
|
|
#include "mozilla/TextRange.h"
|
2013-09-24 14:04:15 +04:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIDOMKeyEvent.h"
|
|
|
|
#include "nsITransferable.h"
|
|
|
|
#include "nsRect.h"
|
|
|
|
#include "nsStringGlue.h"
|
|
|
|
#include "nsTArray.h"
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* virtual keycode values
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
#define NS_DEFINE_VK(aDOMKeyName, aDOMKeyCode) NS_##aDOMKeyName = aDOMKeyCode
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
2014-04-01 15:42:16 +04:00
|
|
|
#include "mozilla/VirtualKeyCodeList.h"
|
2013-09-24 14:04:15 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#undef NS_DEFINE_VK
|
|
|
|
|
2014-01-15 18:41:39 +04:00
|
|
|
#define kLatestSeqno UINT32_MAX
|
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
namespace dom {
|
|
|
|
class PBrowserParent;
|
|
|
|
class PBrowserChild;
|
|
|
|
} // namespace dom
|
|
|
|
namespace plugins {
|
|
|
|
class PPluginInstanceChild;
|
|
|
|
} // namespace plugins
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* 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
|
|
|
|
{
|
|
|
|
AlternativeCharCode(uint32_t aUnshiftedCharCode, uint32_t aShiftedCharCode) :
|
|
|
|
mUnshiftedCharCode(aUnshiftedCharCode), mShiftedCharCode(aShiftedCharCode)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
uint32_t mUnshiftedCharCode;
|
|
|
|
uint32_t mShiftedCharCode;
|
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::WidgetKeyboardEvent
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class WidgetKeyboardEvent : public WidgetInputEvent
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
friend class dom::PBrowserParent;
|
|
|
|
friend class dom::PBrowserChild;
|
|
|
|
|
|
|
|
WidgetKeyboardEvent()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-10-18 10:10:20 +04:00
|
|
|
public:
|
|
|
|
virtual WidgetKeyboardEvent* AsKeyboardEvent() MOZ_OVERRIDE { return this; }
|
|
|
|
|
2014-04-10 11:11:36 +04:00
|
|
|
WidgetKeyboardEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget)
|
|
|
|
: WidgetInputEvent(aIsTrusted, aMessage, aWidget, NS_KEY_EVENT)
|
|
|
|
, keyCode(0)
|
|
|
|
, charCode(0)
|
|
|
|
, location(nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD)
|
|
|
|
, isChar(false)
|
|
|
|
, mIsRepeat(false)
|
|
|
|
, mIsComposing(false)
|
|
|
|
, mKeyNameIndex(mozilla::KEY_NAME_INDEX_Unidentified)
|
|
|
|
, mNativeKeyEvent(nullptr)
|
|
|
|
, mUniqueId(0)
|
2013-09-24 14:04:15 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-01-27 10:10:44 +04:00
|
|
|
virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(eventStructType == NS_KEY_EVENT,
|
|
|
|
"Duplicate() must be overridden by sub class");
|
|
|
|
// Not copying widget, it is a weak reference.
|
|
|
|
WidgetKeyboardEvent* result =
|
|
|
|
new WidgetKeyboardEvent(false, message, nullptr);
|
|
|
|
result->AssignKeyEventData(*this, true);
|
|
|
|
result->mFlags = mFlags;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
// A DOM keyCode value or 0. If a keypress event whose charCode is 0, this
|
|
|
|
// should be 0.
|
|
|
|
uint32_t keyCode;
|
|
|
|
// 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.
|
|
|
|
uint32_t charCode;
|
|
|
|
// One of nsIDOMKeyEvent::DOM_KEY_LOCATION_*
|
|
|
|
uint32_t location;
|
|
|
|
// OS translated Unicode chars which are used for accesskey and accelkey
|
|
|
|
// handling. The handlers will try from first character to last character.
|
|
|
|
nsTArray<AlternativeCharCode> alternativeCharCodes;
|
|
|
|
// Indicates whether the event signifies a printable character
|
|
|
|
bool isChar;
|
2013-11-07 15:17:32 +04:00
|
|
|
// Indicates whether the event is generated by auto repeat or not.
|
|
|
|
// if this is keyup event, always false.
|
|
|
|
bool mIsRepeat;
|
2014-04-10 11:11:36 +04:00
|
|
|
// 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;
|
2013-09-24 14:04:15 +04:00
|
|
|
// DOM KeyboardEvent.key
|
|
|
|
KeyNameIndex mKeyNameIndex;
|
2013-12-10 20:14:53 +04:00
|
|
|
// DOM KeyboardEvent.key only when mKeyNameIndex is KEY_NAME_INDEX_USE_STRING.
|
|
|
|
nsString mKeyValue;
|
2013-09-24 14:04:15 +04:00
|
|
|
// OS-specific native event can optionally be preserved
|
|
|
|
void* mNativeKeyEvent;
|
|
|
|
// Unique id associated with a keydown / keypress event. Used in identifing
|
|
|
|
// keypress events for removal from async event dispatch queue in metrofx
|
|
|
|
// after preventDefault is called on keydown events. It's ok if this wraps
|
|
|
|
// over long periods.
|
|
|
|
uint32_t mUniqueId;
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void GetDOMKeyName(mozilla::KeyNameIndex aKeyNameIndex,
|
2014-01-08 20:45:30 +04:00
|
|
|
nsAString& aKeyName);
|
2013-09-24 14:04:15 +04:00
|
|
|
|
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);
|
|
|
|
|
|
|
|
keyCode = aEvent.keyCode;
|
|
|
|
charCode = aEvent.charCode;
|
|
|
|
location = aEvent.location;
|
|
|
|
alternativeCharCodes = aEvent.alternativeCharCodes;
|
|
|
|
isChar = aEvent.isChar;
|
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;
|
2013-12-10 20:14:53 +04:00
|
|
|
mKeyValue = aEvent.mKeyValue;
|
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;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::WidgetTextEvent
|
|
|
|
*
|
|
|
|
* XXX WidgetTextEvent is fired with compositionupdate event almost every time.
|
|
|
|
* This wastes performance and the cost of mantaining each platform's
|
|
|
|
* implementation. Therefore, we should merge WidgetTextEvent and
|
|
|
|
* WidgetCompositionEvent. Then, DOM compositionupdate should be fired
|
|
|
|
* from TextComposition automatically.
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class WidgetTextEvent : public WidgetGUIEvent
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
friend class dom::PBrowserParent;
|
|
|
|
friend class dom::PBrowserChild;
|
|
|
|
friend class plugins::PPluginInstanceChild;
|
|
|
|
|
|
|
|
WidgetTextEvent()
|
2014-01-15 18:41:39 +04:00
|
|
|
: mSeqno(kLatestSeqno)
|
|
|
|
, isChar(false)
|
2013-09-24 14:04:15 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2014-01-15 18:41:39 +04:00
|
|
|
uint32_t mSeqno;
|
2013-09-24 14:04:15 +04:00
|
|
|
|
|
|
|
public:
|
2013-10-18 10:10:20 +04:00
|
|
|
virtual WidgetTextEvent* AsTextEvent() MOZ_OVERRIDE { return this; }
|
|
|
|
|
2014-01-15 18:41:39 +04:00
|
|
|
WidgetTextEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget)
|
|
|
|
: WidgetGUIEvent(aIsTrusted, aMessage, aWidget, NS_TEXT_EVENT)
|
|
|
|
, mSeqno(kLatestSeqno)
|
|
|
|
, isChar(false)
|
2013-09-24 14:04:15 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-01-27 10:10:44 +04:00
|
|
|
virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(eventStructType == NS_TEXT_EVENT,
|
|
|
|
"Duplicate() must be overridden by sub class");
|
|
|
|
// Not copying widget, it is a weak reference.
|
|
|
|
WidgetTextEvent* result = new WidgetTextEvent(false, message, nullptr);
|
|
|
|
result->AssignTextEventData(*this, true);
|
|
|
|
result->mFlags = mFlags;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
// The composition string or the commit string.
|
|
|
|
nsString theText;
|
|
|
|
// Indicates whether the event signifies printable text.
|
|
|
|
// XXX This is not a standard, and most platforms don't set this properly.
|
|
|
|
// So, perhaps, we can get rid of this.
|
|
|
|
bool isChar;
|
|
|
|
|
2014-03-04 17:48:26 +04:00
|
|
|
nsRefPtr<TextRangeArray> mRanges;
|
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
void AssignTextEventData(const WidgetTextEvent& aEvent, bool aCopyTargets)
|
|
|
|
{
|
|
|
|
AssignGUIEventData(aEvent, aCopyTargets);
|
|
|
|
|
|
|
|
isChar = aEvent.isChar;
|
|
|
|
|
|
|
|
// Currently, we don't need to copy the other members because they are
|
|
|
|
// for internal use only (not available from JS).
|
|
|
|
}
|
2014-02-12 17:02:56 +04:00
|
|
|
|
2014-03-04 17:48:26 +04:00
|
|
|
bool IsComposing() const
|
|
|
|
{
|
|
|
|
return mRanges && mRanges->IsComposing();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t TargetClauseOffset() const
|
|
|
|
{
|
|
|
|
return mRanges ? mRanges->TargetClauseOffset() : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t RangeCount() const
|
|
|
|
{
|
|
|
|
return mRanges ? mRanges->Length() : 0;
|
2014-02-12 17:02:56 +04:00
|
|
|
}
|
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()
|
2014-01-15 18:41:39 +04:00
|
|
|
: mSeqno(kLatestSeqno)
|
2013-09-24 14:04:15 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2014-01-15 18:41:39 +04:00
|
|
|
uint32_t mSeqno;
|
2013-09-24 14:04:15 +04:00
|
|
|
|
|
|
|
public:
|
2013-10-18 10:10:20 +04:00
|
|
|
virtual WidgetCompositionEvent* AsCompositionEvent() MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
WidgetCompositionEvent(bool aIsTrusted, uint32_t aMessage,
|
2014-01-15 18:41:39 +04:00
|
|
|
nsIWidget* aWidget)
|
|
|
|
: WidgetGUIEvent(aIsTrusted, aMessage, aWidget, NS_COMPOSITION_EVENT)
|
|
|
|
, mSeqno(kLatestSeqno)
|
2013-09-24 14:04:15 +04:00
|
|
|
{
|
|
|
|
// XXX compositionstart is cancelable in draft of DOM3 Events.
|
|
|
|
// However, it doesn't make sense for us, we cannot cancel composition
|
|
|
|
// when we send compositionstart event.
|
|
|
|
mFlags.mCancelable = false;
|
|
|
|
}
|
|
|
|
|
2014-01-27 10:10:44 +04:00
|
|
|
virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(eventStructType == NS_COMPOSITION_EVENT,
|
|
|
|
"Duplicate() must be overridden by sub class");
|
|
|
|
// Not copying widget, it is a weak reference.
|
|
|
|
WidgetCompositionEvent* result =
|
|
|
|
new WidgetCompositionEvent(false, message, nullptr);
|
|
|
|
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.
|
|
|
|
nsString data;
|
|
|
|
|
|
|
|
void AssignCompositionEventData(const WidgetCompositionEvent& aEvent,
|
|
|
|
bool aCopyTargets)
|
|
|
|
{
|
|
|
|
AssignGUIEventData(aEvent, aCopyTargets);
|
|
|
|
|
|
|
|
data = aEvent.data;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::WidgetQueryContentEvent
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class WidgetQueryContentEvent : public WidgetGUIEvent
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
friend class dom::PBrowserParent;
|
|
|
|
friend class dom::PBrowserChild;
|
|
|
|
|
|
|
|
WidgetQueryContentEvent()
|
|
|
|
{
|
|
|
|
MOZ_CRASH("WidgetQueryContentEvent is created without proper arguments");
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2013-10-18 10:10:20 +04:00
|
|
|
virtual WidgetQueryContentEvent* AsQueryContentEvent() MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
WidgetQueryContentEvent(bool aIsTrusted, uint32_t aMessage,
|
2014-04-26 03:52:12 +04:00
|
|
|
nsIWidget* aWidget)
|
|
|
|
: WidgetGUIEvent(aIsTrusted, aMessage, aWidget, NS_QUERY_CONTENT_EVENT)
|
|
|
|
, mSucceeded(false)
|
|
|
|
, mWasAsync(false)
|
|
|
|
, mUseNativeLineBreak(true)
|
2013-09-24 14:04:15 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-01-27 10:10:44 +04:00
|
|
|
virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
// 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()");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-04-26 03:52:12 +04:00
|
|
|
void InitForQueryTextContent(uint32_t aOffset, uint32_t aLength,
|
|
|
|
bool aUseNativeLineBreak = true)
|
2013-09-24 14:04:15 +04:00
|
|
|
{
|
|
|
|
NS_ASSERTION(message == NS_QUERY_TEXT_CONTENT,
|
|
|
|
"wrong initializer is called");
|
|
|
|
mInput.mOffset = aOffset;
|
|
|
|
mInput.mLength = aLength;
|
2014-04-26 03:52:12 +04:00
|
|
|
mUseNativeLineBreak = aUseNativeLineBreak;
|
2013-09-24 14:04:15 +04:00
|
|
|
}
|
|
|
|
|
2014-04-26 03:52:12 +04:00
|
|
|
void InitForQueryCaretRect(uint32_t aOffset,
|
|
|
|
bool aUseNativeLineBreak = true)
|
2013-09-24 14:04:15 +04:00
|
|
|
{
|
|
|
|
NS_ASSERTION(message == NS_QUERY_CARET_RECT,
|
|
|
|
"wrong initializer is called");
|
|
|
|
mInput.mOffset = aOffset;
|
2014-04-26 03:52:12 +04:00
|
|
|
mUseNativeLineBreak = aUseNativeLineBreak;
|
2013-09-24 14:04:15 +04:00
|
|
|
}
|
|
|
|
|
2014-04-26 03:52:12 +04:00
|
|
|
void InitForQueryTextRect(uint32_t aOffset, uint32_t aLength,
|
|
|
|
bool aUseNativeLineBreak = true)
|
2013-09-24 14:04:15 +04:00
|
|
|
{
|
|
|
|
NS_ASSERTION(message == NS_QUERY_TEXT_RECT,
|
|
|
|
"wrong initializer is called");
|
|
|
|
mInput.mOffset = aOffset;
|
|
|
|
mInput.mLength = aLength;
|
2014-04-26 03:52:12 +04:00
|
|
|
mUseNativeLineBreak = aUseNativeLineBreak;
|
2013-09-24 14:04:15 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void InitForQueryDOMWidgetHittest(const mozilla::LayoutDeviceIntPoint& aPoint)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(message == NS_QUERY_DOM_WIDGET_HITTEST,
|
|
|
|
"wrong initializer is called");
|
|
|
|
refPoint = aPoint;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t GetSelectionStart(void) const
|
|
|
|
{
|
|
|
|
NS_ASSERTION(message == NS_QUERY_SELECTED_TEXT,
|
|
|
|
"not querying selection");
|
|
|
|
return mReply.mOffset + (mReply.mReversed ? mReply.mString.Length() : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t GetSelectionEnd(void) const
|
|
|
|
{
|
|
|
|
NS_ASSERTION(message == NS_QUERY_SELECTED_TEXT,
|
|
|
|
"not querying selection");
|
|
|
|
return mReply.mOffset + (mReply.mReversed ? 0 : mReply.mString.Length());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool mSucceeded;
|
|
|
|
bool mWasAsync;
|
2014-04-26 03:52:12 +04:00
|
|
|
bool mUseNativeLineBreak;
|
2013-09-24 14:04:15 +04:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
uint32_t mOffset;
|
|
|
|
uint32_t mLength;
|
|
|
|
} mInput;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
void* mContentsRoot;
|
|
|
|
uint32_t mOffset;
|
|
|
|
nsString mString;
|
|
|
|
// Finally, the coordinates is system coordinates.
|
|
|
|
nsIntRect mRect;
|
|
|
|
// The return widget has the caret. This is set at all query events.
|
|
|
|
nsIWidget* mFocusedWidget;
|
|
|
|
// 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;
|
|
|
|
// used by NS_QUERY_SELECTION_AS_TRANSFERABLE
|
|
|
|
nsCOMPtr<nsITransferable> mTransferable;
|
|
|
|
} 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()
|
2014-01-15 18:41:39 +04:00
|
|
|
: mSeqno(kLatestSeqno)
|
|
|
|
, mOffset(0)
|
|
|
|
, mLength(0)
|
|
|
|
, mReversed(false)
|
|
|
|
, mExpandToClusterBoundary(true)
|
|
|
|
, mSucceeded(false)
|
2013-09-24 14:04:15 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2014-01-15 18:41:39 +04:00
|
|
|
uint32_t mSeqno;
|
2013-09-24 14:04:15 +04:00
|
|
|
|
|
|
|
public:
|
2013-10-18 10:10:20 +04:00
|
|
|
virtual WidgetSelectionEvent* AsSelectionEvent() MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2014-01-15 18:41:39 +04:00
|
|
|
WidgetSelectionEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget)
|
|
|
|
: WidgetGUIEvent(aIsTrusted, aMessage, aWidget, NS_SELECTION_EVENT)
|
|
|
|
, mSeqno(kLatestSeqno)
|
|
|
|
, mOffset(0)
|
|
|
|
, mLength(0)
|
|
|
|
, mReversed(false)
|
|
|
|
, mExpandToClusterBoundary(true)
|
|
|
|
, mSucceeded(false)
|
2014-04-26 03:52:12 +04:00
|
|
|
, mUseNativeLineBreak(true)
|
2013-09-24 14:04:15 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-01-27 10:10:44 +04:00
|
|
|
virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
// 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;
|
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:
|
|
|
|
virtual InternalEditorInputEvent* AsEditorInputEvent() MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
InternalEditorInputEvent(bool aIsTrusted, uint32_t aMessage,
|
|
|
|
nsIWidget* aWidget)
|
|
|
|
: InternalUIEvent(aIsTrusted, aMessage, aWidget, NS_EDITOR_INPUT_EVENT)
|
|
|
|
, mIsComposing(false)
|
|
|
|
{
|
|
|
|
if (!aIsTrusted) {
|
|
|
|
mFlags.mBubbles = false;
|
|
|
|
mFlags.mCancelable = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mFlags.mBubbles = true;
|
|
|
|
mFlags.mCancelable = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(eventStructType == NS_EDITOR_INPUT_EVENT,
|
|
|
|
"Duplicate() must be overridden by sub class");
|
|
|
|
// Not copying widget, it is a weak reference.
|
|
|
|
InternalEditorInputEvent* result =
|
|
|
|
new InternalEditorInputEvent(false, message, nullptr);
|
|
|
|
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__
|