Browse Source

import changes from `dev' branch of rmottola/Arctic-Fox:

- Bug 1124608 Support D3E EventModifierInit r=smaug (8238935214)
- Bug 1164981 - Add MouseEvent.movementX/Y. r=masayuki, r=ehsan (5e59178c38)
- Bug 1204439 part.1 Add NS_EVENT_MESSAGE_FIRST_LAST() into EventMessageList.h for defining e*EventFirst and e*EventLast r=smaug (c5750576b4)
- Bug 1204439 part.2 NS_EVENT_MESSAGE() shouldn't take specific value for the event message r=smaug (eaea28b6b7)
- update like 895274 (d17845605a)
- Bug 1203364 IMEContentObserver should notify IME of selection change with the latest change reason r=smaug (59d9c7d3b7)
- Bug 1203381 part.1 IMEContentObserver shouldn't clear mTextChangeData until immediately before sending a text change notification r=smaug (770aa44c43)
- Bug 1203381 part.2 Merge all IME notification sending events of IMEContentObserver to a runnable class r=smaug (d4faa0e5c8)
- Bug 1203381 part.3 IMEContentObserver::mIsFlushingPendingNotifications should be cleared when all pending notifications are sent to IME r=smaug (6f74f02106)
- Bug 1203381 part.4 IMENotificationSender should keep the order of notifications even when a notification causes another change r=smaug (d6a411c1e9)
- Bug 1203381 part.5 IMENotificationSender shouldn't send notification recursively r=smaug (602cffffb0)
- Bug 1203381 part.6 IMEContentObserver shouldn't post position change event if Reflow() is called during handling a query content event and sending NOTIFY_IME_OF_POSITION_CHANGE since the result of query content event includes the latest layout information r=smaug (e3f843d991)
- Bug 1203381 part.7 Rename IMEContentObserver::mIs*ChangeEventPending to IMEContentObserver::mNeedsToNotifyIMEOf*Change r=smaug (9fddde18a6)
- Bug 1204439 part.3 Create methods to get enum item name r=smaug (2be37da179)
-  Bug 1182551 - Updating nsSecureBrowserUIImpl so that insecure pages with mixed content iframes don't get marked as broken. r=keeler (a46e2cf3ac)
- Bug 1198669 - Add nsIMultiPartChannel.originalResponseHeader support. r=valentin (7c28524a6d)
- bug 496234 - use stdint types in md4 implementation r=mayhemer (721f86c2b1)
- bug 496234 - fix md4 implementation by appending the input length as a 64-bit number r=mayhemer (51637a359f)
- revert PM specific patch, checked against FF 60 & 68 (c133d93f93)
- some let->var, code style (d5c6b316da)
master
roytam1 2 months ago
parent
commit
d9d6a919f9
  1. 1
      dom/events/DragEvent.cpp
  2. 2
      dom/events/EventNameList.h
  3. 478
      dom/events/IMEContentObserver.cpp
  4. 113
      dom/events/IMEContentObserver.h
  5. 29
      dom/events/IMEStateManager.cpp
  6. 4
      dom/events/KeyboardEvent.cpp
  7. 27
      dom/events/MouseEvent.cpp
  8. 7
      dom/events/MouseEvent.h
  9. 4
      dom/events/PointerEvent.cpp
  10. 39
      dom/events/UIEvent.cpp
  11. 1
      dom/events/UIEvent.h
  12. 35
      dom/events/WheelEvent.cpp
  13. 4
      dom/events/test/test_dom_mouse_event.html
  14. 108
      dom/events/test/test_eventctors.html
  15. 6
      dom/webidl/KeyboardEvent.webidl
  16. 25
      dom/webidl/MouseEvent.webidl
  17. 20
      dom/webidl/UIEvent.webidl
  18. 7
      netwerk/base/nsIMultiPartChannel.idl
  19. 32
      netwerk/streamconv/converters/nsMultiMixedConv.cpp
  20. 7
      netwerk/streamconv/converters/nsMultiMixedConv.h
  21. 7
      netwerk/test/unit/test_multipart_streamconv_application_package.js
  22. 4
      security/manager/ssl/NSSErrorsService.cpp
  23. 412
      security/manager/ssl/RootHashes.inc
  24. 58
      security/manager/ssl/md4.c
  25. 18
      security/manager/ssl/nsSecureBrowserUIImpl.cpp
  26. 398
      security/manager/tools/KnownRootHashes.json
  27. 4
      services/sync/modules/FxaMigrator.jsm
  28. 2
      services/sync/modules/main.js
  29. 2
      services/sync/modules/util.js
  30. 8
      testing/web-platform/meta/pointerlock/constructor.html.ini
  31. 18
      testing/web-platform/meta/pointerlock/idlharness.html.ini
  32. 7
      toolkit/components/telemetry/Histograms.json
  33. 6
      uriloader/exthandler/ExternalHelperAppParent.cpp
  34. 29
      widget/ContentCache.cpp
  35. 9
      widget/EventForwards.h
  36. 523
      widget/EventMessageList.h
  37. 25
      widget/IMEData.h
  38. 43
      widget/WidgetEventImpl.cpp
  39. 16
      widget/windows/TSFTextStore.cpp

1
dom/events/DragEvent.cpp

@ -149,6 +149,7 @@ DragEvent::Constructor(const GlobalObject& aGlobal,
aParam.mCtrlKey, aParam.mAltKey, aParam.mShiftKey,
aParam.mMetaKey, aParam.mButton, aParam.mRelatedTarget,
aParam.mDataTransfer);
e->InitializeExtraMouseEventDictionaryMembers(aParam);
e->SetTrusted(trusted);
return e.forget();
}

2
dom/events/EventNameList.h

@ -414,7 +414,7 @@ EVENT(timeupdate,
EventNameType_HTML,
eBasicEventClass)
EVENT(toggle,
NS_TOGGLE,
eToggle,
EventNameType_HTML,
eBasicEventClass)
EVENT(volumechange,

478
dom/events/IMEContentObserver.cpp

@ -48,29 +48,31 @@ ToChar(bool aBool)
}
static const char*
ToChar(EventMessage aEventMessage)
ToChar(IMEMessage aIMEMessage)
{
switch (aEventMessage) {
case eQuerySelectedText:
return "eQuerySelectedText";
case eQueryTextContent:
return "eQueryTextContent";
case eQueryCaretRect:
return "eQueryCaretRect";
case eQueryTextRect:
return "eQueryTextRect";
case eQueryEditorRect:
return "eQueryEditorRect";
case eQueryContentState:
return "eQueryContentState";
case eQuerySelectionAsTransferable:
return "eQuerySelectionAsTransferable";
case eQueryCharacterAtPoint:
return "eQueryCharacterAtPoint";
case eQueryDOMWidgetHittest:
return "eQueryDOMWidgetHittest";
switch (aIMEMessage) {
case NOTIFY_IME_OF_NOTHING:
return "NOTIFY_IME_OF_NOTHING";
case NOTIFY_IME_OF_FOCUS:
return "NOTIFY_IME_OF_FOCUS";
case NOTIFY_IME_OF_BLUR:
return "NOTIFY_IME_OF_BLUR";
case NOTIFY_IME_OF_SELECTION_CHANGE:
return "NOTIFY_IME_OF_SELECTION_CHANGE";
case NOTIFY_IME_OF_TEXT_CHANGE:
return "NOTIFY_IME_OF_TEXT_CHANGE";
case NOTIFY_IME_OF_COMPOSITION_UPDATE:
return "NOTIFY_IME_OF_COMPOSITION_UPDATE";
case NOTIFY_IME_OF_POSITION_CHANGE:
return "NOTIFY_IME_OF_POSITION_CHANGE";
case NOTIFY_IME_OF_MOUSE_BUTTON_EVENT:
return "NOTIFY_IME_OF_MOUSE_BUTTON_EVENT";
case REQUEST_TO_COMMIT_COMPOSITION:
return "REQUEST_TO_COMMIT_COMPOSITION";
case REQUEST_TO_CANCEL_COMPOSITION:
return "REQUEST_TO_CANCEL_COMPOSITION";
default:
return "Unsupported message";
return "Unexpected value";
}
}
@ -192,14 +194,15 @@ IMEContentObserver::IMEContentObserver()
: mESM(nullptr)
, mSuppressNotifications(0)
, mPreCharacterDataChangeLength(-1)
, mSendingNotification(NOTIFY_IME_OF_NOTHING)
, mIsObserving(false)
, mIMEHasFocus(false)
, mIsFocusEventPending(false)
, mIsSelectionChangeEventPending(false)
, mSelectionChangeCausedOnlyByComposition(false)
, mSelectionChangeCausedOnlyBySelectionEvent(false)
, mIsPositionChangeEventPending(false)
, mNeedsToNotifyIMEOfFocusSet(false)
, mNeedsToNotifyIMEOfTextChange(false)
, mNeedsToNotifyIMEOfSelectionChange(false)
, mNeedsToNotifyIMEOfPositionChange(false)
, mIsFlushingPendingNotifications(false)
, mIsHandlingQueryContentEvent(false)
{
#ifdef DEBUG
mTextChangeData.Test();
@ -563,10 +566,6 @@ IMEContentObserver::ReflowInterruptible(DOMHighResTimeStamp aStart,
nsresult
IMEContentObserver::HandleQueryContentEvent(WidgetQueryContentEvent* aEvent)
{
MOZ_LOG(sIMECOLog, LogLevel::Debug,
("IMECO: 0x%p IMEContentObserver::HandleQueryContentEvent(aEvent={ "
"mMessage=%s })", this, ToChar(aEvent->mMessage)));
// If the instance has cache, it should use the cached selection which was
// sent to the widget.
if (aEvent->mMessage == eQuerySelectedText && aEvent->mUseNativeLineBreak &&
@ -584,6 +583,12 @@ IMEContentObserver::HandleQueryContentEvent(WidgetQueryContentEvent* aEvent)
return NS_OK;
}
MOZ_LOG(sIMECOLog, LogLevel::Debug,
("IMECO: 0x%p IMEContentObserver::HandleQueryContentEvent(aEvent={ "
"mMessage=%s })", this, ToChar(aEvent->mMessage)));
AutoRestore<bool> handling(mIsHandlingQueryContentEvent);
mIsHandlingQueryContentEvent = true;
ContentEventHandler handler(GetPresContext());
nsresult rv = handler.HandleQueryContentEvent(aEvent);
if (aEvent->mSucceeded) {
@ -1001,51 +1006,32 @@ IMEContentObserver::PostFocusSetNotification()
MOZ_LOG(sIMECOLog, LogLevel::Debug,
("IMECO: 0x%p IMEContentObserver::PostFocusSetNotification()", this));
mIsFocusEventPending = true;
mNeedsToNotifyIMEOfFocusSet = true;
}
void
IMEContentObserver::PostTextChangeNotification(
const TextChangeDataBase& aTextChangeData)
IMEContentObserver::PostTextChangeNotification()
{
MOZ_LOG(sIMECOLog, LogLevel::Debug,
("IMECO: 0x%p IMEContentObserver::PostTextChangeNotification("
"aTextChangeData=%s)",
this, TextChangeDataToString(aTextChangeData).get()));
"mTextChangeData=%s)",
this, TextChangeDataToString(mTextChangeData).get()));
mTextChangeData += aTextChangeData;
MOZ_ASSERT(mTextChangeData.IsValid(),
"mTextChangeData must have text change data");
MOZ_LOG(sIMECOLog, LogLevel::Debug,
("IMECO: 0x%p IMEContentObserver::PostTextChangeNotification(), "
"mTextChangeData=%s)",
this, TextChangeDataToString(mTextChangeData).get()));
mNeedsToNotifyIMEOfTextChange = true;
}
void
IMEContentObserver::PostSelectionChangeNotification(
bool aCausedByComposition,
bool aCausedBySelectionEvent)
IMEContentObserver::PostSelectionChangeNotification()
{
MOZ_LOG(sIMECOLog, LogLevel::Debug,
("IMECO: 0x%p IMEContentObserver::PostSelectionChangeNotification("
"aCausedByComposition=%s, aCausedBySelectionEvent=%s)",
this, ToChar(aCausedByComposition), ToChar(aCausedBySelectionEvent)));
("IMECO: 0x%p IMEContentObserver::PostSelectionChangeNotification(), "
"mSelectionData={ mCausedByComposition=%s, mCausedBySelectionEvent=%s }",
this, ToChar(mSelectionData.mCausedByComposition),
ToChar(mSelectionData.mCausedBySelectionEvent)));
if (!mIsSelectionChangeEventPending) {
mSelectionChangeCausedOnlyByComposition = aCausedByComposition;
} else {
mSelectionChangeCausedOnlyByComposition =
mSelectionChangeCausedOnlyByComposition && aCausedByComposition;
}
if (!mSelectionChangeCausedOnlyBySelectionEvent) {
mSelectionChangeCausedOnlyBySelectionEvent = aCausedBySelectionEvent;
} else {
mSelectionChangeCausedOnlyBySelectionEvent =
mSelectionChangeCausedOnlyBySelectionEvent && aCausedBySelectionEvent;
}
mIsSelectionChangeEventPending = true;
mNeedsToNotifyIMEOfSelectionChange = true;
}
void
@ -1067,7 +1053,8 @@ IMEContentObserver::MaybeNotifyIMEOfTextChange(
"aTextChangeData=%s)",
this, TextChangeDataToString(aTextChangeData).get()));
PostTextChangeNotification(aTextChangeData);
mTextChangeData += aTextChangeData;
PostTextChangeNotification();
FlushMergeableNotifications();
}
@ -1081,8 +1068,9 @@ IMEContentObserver::MaybeNotifyIMEOfSelectionChange(
"aCausedByComposition=%s, aCausedBySelectionEvent=%s)",
this, ToChar(aCausedByComposition), ToChar(aCausedBySelectionEvent)));
PostSelectionChangeNotification(aCausedByComposition,
aCausedBySelectionEvent);
mSelectionData.AssignReason(aCausedByComposition,
aCausedBySelectionEvent);
PostSelectionChangeNotification();
FlushMergeableNotifications();
}
@ -1091,6 +1079,18 @@ IMEContentObserver::MaybeNotifyIMEOfPositionChange()
{
MOZ_LOG(sIMECOLog, LogLevel::Debug,
("IMECO: 0x%p IMEContentObserver::MaybeNotifyIMEOfPositionChange()", this));
// If reflow is caused by ContentEventHandler during PositionChangeEvent
// sending NOTIFY_IME_OF_POSITION_CHANGE, we don't need to notify IME of it
// again since ContentEventHandler returns the result including this reflow's
// result.
if (mIsHandlingQueryContentEvent &&
mSendingNotification == NOTIFY_IME_OF_POSITION_CHANGE) {
MOZ_LOG(sIMECOLog, LogLevel::Debug,
("IMECO: 0x%p IMEContentObserver::MaybeNotifyIMEOfPositionChange(), "
"ignored since caused by ContentEventHandler during sending "
"NOTIY_IME_OF_POSITION_CHANGE", this));
return;
}
PostPositionChangeNotification();
FlushMergeableNotifications();
}
@ -1104,7 +1104,7 @@ IMEContentObserver::UpdateSelectionCache()
return false;
}
mSelectionData.Clear();
mSelectionData.ClearSelectionData();
// XXX Cannot we cache some information for reducing the cost to compute
// selection offset and writing mode?
@ -1120,8 +1120,8 @@ IMEContentObserver::UpdateSelectionCache()
*mSelectionData.mString = selection.mReply.mString;
mSelectionData.SetWritingMode(selection.GetWritingMode());
mSelectionData.mReversed = selection.mReply.mReversed;
mSelectionData.mCausedByComposition = false;
mSelectionData.mCausedBySelectionEvent = false;
// WARNING: Don't modify the reason of selection change here.
MOZ_LOG(sIMECOLog, LogLevel::Debug,
("IMECO: 0x%p IMEContentObserver::UpdateSelectionCache(), "
@ -1137,7 +1137,7 @@ IMEContentObserver::PostPositionChangeNotification()
MOZ_LOG(sIMECOLog, LogLevel::Debug,
("IMECO: 0x%p IMEContentObserver::PostPositionChangeNotification()", this));
mIsPositionChangeEventPending = true;
mNeedsToNotifyIMEOfPositionChange = true;
}
bool
@ -1215,63 +1215,22 @@ IMEContentObserver::FlushMergeableNotifications()
return;
}
AutoRestore<bool> flusing(mIsFlushingPendingNotifications);
mIsFlushingPendingNotifications = true;
// NOTE: Reset each pending flag because sending notification may cause
// another change.
if (mIsFocusEventPending) {
if (!NeedsToNotifyIMEOfSomething()) {
MOZ_LOG(sIMECOLog, LogLevel::Debug,
("IMECO: 0x%p IMEContentObserver::FlushMergeableNotifications(), "
"creating FocusSetEvent...", this));
mIsFocusEventPending = false;
nsContentUtils::AddScriptRunner(new FocusSetEvent(this));
// This is the first notification to IME. So, we don't need to notify any
// more since IME starts to query content after it gets focus.
ClearPendingNotifications();
("IMECO: 0x%p IMEContentObserver::FlushMergeableNotifications(), "
"FAILED, due to no pending notifications", this));
return;
}
if (mTextChangeData.IsValid()) {
MOZ_LOG(sIMECOLog, LogLevel::Debug,
("IMECO: 0x%p IMEContentObserver::FlushMergeableNotifications(), "
"creating TextChangeEvent...", this));
nsContentUtils::AddScriptRunner(new TextChangeEvent(this, mTextChangeData));
}
// Be aware, PuppetWidget depends on the order of this. A selection change
// notification should not be sent before a text change notification because
// PuppetWidget shouldn't query new text content every selection change.
if (mIsSelectionChangeEventPending) {
MOZ_LOG(sIMECOLog, LogLevel::Debug,
("IMECO: 0x%p IMEContentObserver::FlushMergeableNotifications(), "
"creating SelectionChangeEvent...", this));
mIsSelectionChangeEventPending = false;
nsContentUtils::AddScriptRunner(
new SelectionChangeEvent(this, mSelectionChangeCausedOnlyByComposition,
mSelectionChangeCausedOnlyBySelectionEvent));
}
// NOTE: Reset each pending flag because sending notification may cause
// another change.
if (mIsPositionChangeEventPending) {
MOZ_LOG(sIMECOLog, LogLevel::Debug,
("IMECO: 0x%p IMEContentObserver::FlushMergeableNotifications(), "
"creating PositionChangeEvent...", this));
mIsPositionChangeEventPending = false;
nsContentUtils::AddScriptRunner(new PositionChangeEvent(this));
}
MOZ_LOG(sIMECOLog, LogLevel::Debug,
("IMECO: 0x%p IMEContentObserver::FlushMergeableNotifications(), "
"creating IMENotificationSender...", this));
// If notifications may cause new change, we should notify them now.
if (mTextChangeData.IsValid() ||
mIsSelectionChangeEventPending ||
mIsPositionChangeEventPending) {
MOZ_LOG(sIMECOLog, LogLevel::Debug,
("IMECO: 0x%p IMEContentObserver::FlushMergeableNotifications(), "
"posting AsyncMergeableNotificationsFlusher to current thread", this));
nsRefPtr<AsyncMergeableNotificationsFlusher> asyncFlusher =
new AsyncMergeableNotificationsFlusher(this);
NS_DispatchToCurrentThread(asyncFlusher);
}
mIsFlushingPendingNotifications = true;
nsContentUtils::AddScriptRunner(new IMENotificationSender(this));
MOZ_LOG(sIMECOLog, LogLevel::Debug,
("IMECO: 0x%p IMEContentObserver::FlushMergeableNotifications(), "
@ -1283,7 +1242,8 @@ IMEContentObserver::FlushMergeableNotifications()
******************************************************************************/
bool
IMEContentObserver::AChangeEvent::CanNotifyIME() const
IMEContentObserver::AChangeEvent::CanNotifyIME(
ChangeEventType aChangeEventType) const
{
if (NS_WARN_IF(!mIMEContentObserver)) {
return false;
@ -1294,7 +1254,7 @@ IMEContentObserver::AChangeEvent::CanNotifyIME() const
return false;
}
// If setting focus, just check the state.
if (mChangeEventType == eChangeEventType_Focus) {
if (aChangeEventType == eChangeEventType_Focus) {
return !NS_WARN_IF(mIMEContentObserver->mIMEHasFocus);
}
// If we've not notified IME of focus yet, we shouldn't notify anything.
@ -1309,13 +1269,24 @@ IMEContentObserver::AChangeEvent::CanNotifyIME() const
}
bool
IMEContentObserver::AChangeEvent::IsSafeToNotifyIME() const
IMEContentObserver::AChangeEvent::IsSafeToNotifyIME(
ChangeEventType aChangeEventType) const
{
if (NS_WARN_IF(!nsContentUtils::IsSafeToRunScript())) {
return false;
}
// While we're sending a notification, we shouldn't send another notification
// recursively.
if (mIMEContentObserver->mSendingNotification != NOTIFY_IME_OF_NOTHING) {
MOZ_LOG(sIMECOLog, LogLevel::Debug,
("IMECO: 0x%p IMEContentObserver::AChangeEvent::IsSafeToNotifyIME(), "
"putting off sending notification due to detecting recursive call, "
"mIMEContentObserver={ mSendingNotification=%s }",
this, ToChar(mIMEContentObserver->mSendingNotification)));
return false;
}
State state = mIMEContentObserver->GetState();
if (mChangeEventType == eChangeEventType_Focus) {
if (aChangeEventType == eChangeEventType_Focus) {
if (NS_WARN_IF(state != eState_Initializing && state != eState_Observing)) {
return false;
}
@ -1326,28 +1297,90 @@ IMEContentObserver::AChangeEvent::IsSafeToNotifyIME() const
}
/******************************************************************************
* mozilla::IMEContentObserver::FocusSetEvent
* mozilla::IMEContentObserver::IMENotificationSender
******************************************************************************/
NS_IMETHODIMP
IMEContentObserver::FocusSetEvent::Run()
IMEContentObserver::IMENotificationSender::Run()
{
if (!CanNotifyIME()) {
MOZ_ASSERT(mIMEContentObserver->mIsFlushingPendingNotifications);
// NOTE: Reset each pending flag because sending notification may cause
// another change.
if (mIMEContentObserver->mNeedsToNotifyIMEOfFocusSet) {
mIMEContentObserver->mNeedsToNotifyIMEOfFocusSet = false;
SendFocusSet();
// This is the first notification to IME. So, we don't need to notify
// anymore since IME starts to query content after it gets focus.
mIMEContentObserver->ClearPendingNotifications();
mIMEContentObserver->mIsFlushingPendingNotifications = false;
return NS_OK;
}
if (mIMEContentObserver->mNeedsToNotifyIMEOfTextChange) {
mIMEContentObserver->mNeedsToNotifyIMEOfTextChange = false;
SendTextChange();
}
// If a text change notification causes another text change again, we should
// notify IME of that before sending a selection change notification.
if (!mIMEContentObserver->mNeedsToNotifyIMEOfTextChange) {
// Be aware, PuppetWidget depends on the order of this. A selection change
// notification should not be sent before a text change notification because
// PuppetWidget shouldn't query new text content every selection change.
if (mIMEContentObserver->mNeedsToNotifyIMEOfSelectionChange) {
mIMEContentObserver->mNeedsToNotifyIMEOfSelectionChange = false;
SendSelectionChange();
}
}
// If a text change notification causes another text change again or a
// selection change notification causes either a text change or another
// selection change, we should notify IME of those before sending a position
// change notification.
if (!mIMEContentObserver->mNeedsToNotifyIMEOfTextChange &&
!mIMEContentObserver->mNeedsToNotifyIMEOfSelectionChange) {
if (mIMEContentObserver->mNeedsToNotifyIMEOfPositionChange) {
mIMEContentObserver->mNeedsToNotifyIMEOfPositionChange = false;
SendPositionChange();
}
}
// If notifications caused some new change, we should notify them now.
mIMEContentObserver->mIsFlushingPendingNotifications =
mIMEContentObserver->NeedsToNotifyIMEOfSomething();
if (mIMEContentObserver->mIsFlushingPendingNotifications) {
MOZ_LOG(sIMECOLog, LogLevel::Debug,
("IMECO: 0x%p IMEContentObserver::IMENotificationSender::Run(), "
"posting AsyncMergeableNotificationsFlusher to current thread", this));
nsRefPtr<AsyncMergeableNotificationsFlusher> asyncFlusher =
new AsyncMergeableNotificationsFlusher(mIMEContentObserver);
NS_DispatchToCurrentThread(asyncFlusher);
}
return NS_OK;
}
void
IMEContentObserver::IMENotificationSender::SendFocusSet()
{
if (!CanNotifyIME(eChangeEventType_Focus)) {
// If IMEContentObserver has already gone, we don't need to notify IME of
// focus.
MOZ_LOG(sIMECOLog, LogLevel::Debug,
("IMECO: 0x%p IMEContentObserver::FocusSetEvent::Run(), FAILED, due to "
"impossible to notify IME of focus", this));
("IMECO: 0x%p IMEContentObserver::IMENotificationSender::"
"SendFocusSet(), FAILED, due to impossible to notify IME of focus",
this));
mIMEContentObserver->ClearPendingNotifications();
return NS_OK;
return;
}
if (!IsSafeToNotifyIME()) {
if (!IsSafeToNotifyIME(eChangeEventType_Focus)) {
MOZ_LOG(sIMECOLog, LogLevel::Debug,
("IMECO: 0x%p IMEContentObserver::FocusSetEvent::Run(), retrying to "
"send NOTIFY_IME_OF_FOCUS...", this));
("IMECO: 0x%p IMEContentObserver::IMENotificationSender::"
"SendFocusSet(), retrying to send NOTIFY_IME_OF_FOCUS...", this));
mIMEContentObserver->PostFocusSetNotification();
return NS_OK;
return;
}
mIMEContentObserver->mIMEHasFocus = true;
@ -1355,166 +1388,177 @@ IMEContentObserver::FocusSetEvent::Run()
mIMEContentObserver->UpdateSelectionCache();
MOZ_LOG(sIMECOLog, LogLevel::Info,
("IMECO: 0x%p IMEContentObserver::FocusSetEvent::Run(), "
"sending NOTIFY_IME_OF_FOCUS...", this));
("IMECO: 0x%p IMEContentObserver::IMENotificationSender::"
"SendFocusSet(), sending NOTIFY_IME_OF_FOCUS...", this));
MOZ_RELEASE_ASSERT(mIMEContentObserver->mSendingNotification ==
NOTIFY_IME_OF_NOTHING);
mIMEContentObserver->mSendingNotification = NOTIFY_IME_OF_FOCUS;
IMEStateManager::NotifyIME(IMENotification(NOTIFY_IME_OF_FOCUS),
mIMEContentObserver->mWidget);
mIMEContentObserver->mSendingNotification = NOTIFY_IME_OF_NOTHING;
MOZ_LOG(sIMECOLog, LogLevel::Debug,
("IMECO: 0x%p IMEContentObserver::FocusSetEvent::Run(), "
"sent NOTIFY_IME_OF_FOCUS", this));
return NS_OK;
("IMECO: 0x%p IMEContentObserver::IMENotificationSender::"
"SendFocusSet(), sent NOTIFY_IME_OF_FOCUS", this));
}
/******************************************************************************
* mozilla::IMEContentObserver::SelectionChangeEvent
******************************************************************************/
NS_IMETHODIMP
IMEContentObserver::SelectionChangeEvent::Run()
void
IMEContentObserver::IMENotificationSender::SendSelectionChange()
{
if (!CanNotifyIME()) {
if (!CanNotifyIME(eChangeEventType_Selection)) {
MOZ_LOG(sIMECOLog, LogLevel::Debug,
("IMECO: 0x%p IMEContentObserver::SelectionChangeEvent::Run(), FAILED, "
"due to impossible to notify IME of selection change", this));
return NS_OK;
("IMECO: 0x%p IMEContentObserver::IMENotificationSender::"
"SendSelectionChange(), FAILED, due to impossible to notify IME of "
"selection change", this));
return;
}
if (!IsSafeToNotifyIME()) {
if (!IsSafeToNotifyIME(eChangeEventType_Selection)) {
MOZ_LOG(sIMECOLog, LogLevel::Debug,
("IMECO: 0x%p IMEContentObserver::SelectionChangeEvent::Run(), "
"retrying to send NOTIFY_IME_OF_SELECTION_CHANGE...", this));
mIMEContentObserver->PostSelectionChangeNotification(
mCausedByComposition, mCausedBySelectionEvent);
return NS_OK;
("IMECO: 0x%p IMEContentObserver::IMENotificationSender::"
"SendSelectionChange(), retrying to send "
"NOTIFY_IME_OF_SELECTION_CHANGE...", this));
mIMEContentObserver->PostSelectionChangeNotification();
return;
}
SelectionChangeData lastSelChangeData = mIMEContentObserver->mSelectionData;
if (NS_WARN_IF(!mIMEContentObserver->UpdateSelectionCache())) {
MOZ_LOG(sIMECOLog, LogLevel::Error,
("IMECO: 0x%p IMEContentObserver::SelectionChangeEvent::Run(), FAILED, "
"due to UpdateSelectionCache() failure", this));
return NS_OK;
("IMECO: 0x%p IMEContentObserver::IMENotificationSender::"
"SendSelectionChange(), FAILED, due to UpdateSelectionCache() failure",
this));
return;
}
// If the IME doesn't want selection change notifications caused by
// composition, we should do nothing anymore.
if (mCausedByComposition &&
SelectionChangeData& newSelChangeData = mIMEContentObserver->mSelectionData;
if (newSelChangeData.mCausedByComposition &&
!mIMEContentObserver->
mUpdatePreference.WantChangesCausedByComposition()) {
return NS_OK;
return;
}
// The state may be changed since querying content causes flushing layout.
if (!CanNotifyIME()) {
if (!CanNotifyIME(eChangeEventType_Selection)) {
MOZ_LOG(sIMECOLog, LogLevel::Debug,
("IMECO: 0x%p IMEContentObserver::SelectionChangeEvent::Run(), FAILED, "
"due to flushing layout having changed something", this));
return NS_OK;
("IMECO: 0x%p IMEContentObserver::IMENotificationSender::"
"SendSelectionChange(), FAILED, due to flushing layout having changed "
"something", this));
return;
}
// If the selection isn't changed actually, we shouldn't notify IME of
// selection change.
SelectionChangeData& newSelChangeData = mIMEContentObserver->mSelectionData;
if (lastSelChangeData.IsValid() &&
lastSelChangeData.mOffset == newSelChangeData.mOffset &&
lastSelChangeData.String() == newSelChangeData.String() &&
lastSelChangeData.GetWritingMode() == newSelChangeData.GetWritingMode() &&
lastSelChangeData.mReversed == newSelChangeData.mReversed) {
MOZ_LOG(sIMECOLog, LogLevel::Debug,
("IMECO: 0x%p IMEContentObserver::SelectionChangeEvent::Run(), not "
"notifying IME of NOTIFY_IME_OF_SELECTION_CHANGE due to not changed "
"actually", this));
return NS_OK;
("IMECO: 0x%p IMEContentObserver::IMENotificationSender::"
"SendSelectionChange(), not notifying IME of "
"NOTIFY_IME_OF_SELECTION_CHANGE due to not changed actually", this));
return;
}
MOZ_LOG(sIMECOLog, LogLevel::Info,
("IMECO: 0x%p IMEContentObserver::SelectionChangeEvent::Run(), "
"sending NOTIFY_IME_OF_SELECTION_CHANGE... newSelChangeData=%s",
("IMECO: 0x%p IMEContentObserver::IMENotificationSender::"
"SendSelectionChange(), sending NOTIFY_IME_OF_SELECTION_CHANGE... "
"newSelChangeData=%s",
this, SelectionChangeDataToString(newSelChangeData).get()));
IMENotification notification(NOTIFY_IME_OF_SELECTION_CHANGE);
notification.SetData(mIMEContentObserver->mSelectionData,
mCausedByComposition, mCausedBySelectionEvent);
notification.SetData(mIMEContentObserver->mSelectionData);
MOZ_RELEASE_ASSERT(mIMEContentObserver->mSendingNotification ==
NOTIFY_IME_OF_NOTHING);
mIMEContentObserver->mSendingNotification = NOTIFY_IME_OF_SELECTION_CHANGE;
IMEStateManager::NotifyIME(notification, mIMEContentObserver->mWidget);
mIMEContentObserver->mSendingNotification = NOTIFY_IME_OF_NOTHING;
MOZ_LOG(sIMECOLog, LogLevel::Debug,
("IMECO: 0x%p IMEContentObserver::SelectionChangeEvent::Run(), "
"sent NOTIFY_IME_OF_SELECTION_CHANGE", this));
return NS_OK;
("IMECO: 0x%p IMEContentObserver::IMENotificationSender::"
"SendSelectionChange(), sent NOTIFY_IME_OF_SELECTION_CHANGE", this));
}
/******************************************************************************
* mozilla::IMEContentObserver::TextChangeEvent
******************************************************************************/
NS_IMETHODIMP
IMEContentObserver::TextChangeEvent::Run()
void
IMEContentObserver::IMENotificationSender::SendTextChange()
{
if (!CanNotifyIME()) {
if (!CanNotifyIME(eChangeEventType_Text)) {
MOZ_LOG(sIMECOLog, LogLevel::Debug,
("IMECO: 0x%p IMEContentObserver::TextChangeEvent::Run(), FAILED, "
"due to impossible to notify IME of text change", this));
return NS_OK;
("IMECO: 0x%p IMEContentObserver::IMENotificationSender::"
"SendTextChange(), FAILED, due to impossible to notify IME of text "
"change", this));
return;
}
if (!IsSafeToNotifyIME()) {
if (!IsSafeToNotifyIME(eChangeEventType_Text)) {
MOZ_LOG(sIMECOLog, LogLevel::Debug,
("IMECO: 0x%p IMEContentObserver::TextChangeEvent::Run(), retrying to "
"send NOTIFY_IME_OF_TEXT_CHANGE...", this));
mIMEContentObserver->PostTextChangeNotification(mTextChangeData);
return NS_OK;
("IMECO: 0x%p IMEContentObserver::IMENotificationSender::"
"SendTextChange(), retrying to send NOTIFY_IME_OF_TEXT_CHANGE...",
this));
mIMEContentObserver->PostTextChangeNotification();
return;
}
MOZ_LOG(sIMECOLog, LogLevel::Info,
("IMECO: 0x%p IMEContentObserver::TextChangeEvent::Run(), "
"sending NOTIFY_IME_OF_TEXT_CHANGE... mTextChangeData=%s",
this, TextChangeDataToString(mTextChangeData).get()));
("IMECO: 0x%p IMEContentObserver::IMENotificationSender::"
"SendTextChange(), sending NOTIFY_IME_OF_TEXT_CHANGE... "
"mIMEContentObserver={ mTextChangeData=%s }",
this, TextChangeDataToString(mIMEContentObserver->mTextChangeData).get()));
IMENotification notification(NOTIFY_IME_OF_TEXT_CHANGE);
notification.SetData(mTextChangeData);
notification.SetData(mIMEContentObserver->mTextChangeData);
mIMEContentObserver->mTextChangeData.Clear();
MOZ_RELEASE_ASSERT(mIMEContentObserver->mSendingNotification ==
NOTIFY_IME_OF_NOTHING);
mIMEContentObserver->mSendingNotification = NOTIFY_IME_OF_TEXT_CHANGE;
IMEStateManager::NotifyIME(notification, mIMEContentObserver->mWidget);
mIMEContentObserver->mSendingNotification = NOTIFY_IME_OF_NOTHING;
MOZ_LOG(sIMECOLog, LogLevel::Debug,
("IMECO: 0x%p IMEContentObserver::TextChangeEvent::Run(), "
"sent NOTIFY_IME_OF_TEXT_CHANGE", this));
return NS_OK;
("IMECO: 0x%p IMEContentObserver::IMENotificationSender::"
"SendTextChange(), sent NOTIFY_IME_OF_TEXT_CHANGE", this));
}
/******************************************************************************
* mozilla::IMEContentObserver::PositionChangeEvent
******************************************************************************/
NS_IMETHODIMP
IMEContentObserver::PositionChangeEvent::Run()
void
IMEContentObserver::IMENotificationSender::SendPositionChange()
{
if (!CanNotifyIME()) {
if (!CanNotifyIME(eChangeEventType_Position)) {
MOZ_LOG(sIMECOLog, LogLevel::Debug,
("IMECO: 0x%p IMEContentObserver::PositionChangeEvent::Run(), FAILED, "
"due to impossible to notify IME of position change", this));
return NS_OK;
("IMECO: 0x%p IMEContentObserver::IMENotificationSender::"
"SendPositionChange(), FAILED, due to impossible to notify IME of "
"position change", this));
return;
}
if (!IsSafeToNotifyIME()) {
if (!IsSafeToNotifyIME(eChangeEventType_Position)) {
MOZ_LOG(sIMECOLog, LogLevel::Debug,
("IMECO: 0x%p IMEContentObserver::PositionChangeEvent::Run(), "
"retrying to send NOTIFY_IME_OF_POSITION_CHANGE...", this));
("IMECO: 0x%p IMEContentObserver::IMENotificationSender::"
"SendPositionChange(), retrying to send "
"NOTIFY_IME_OF_POSITION_CHANGE...", this));
mIMEContentObserver->PostPositionChangeNotification();
return NS_OK;
return;
}
MOZ_LOG(sIMECOLog, LogLevel::Info,
("IMECO: 0x%p IMEContentObserver::PositionChangeEvent::Run(), "
"sending NOTIFY_IME_OF_POSITION_CHANGE...", this));
("IMECO: 0x%p IMEContentObserver::IMENotificationSender::"
"SendPositionChange(), sending NOTIFY_IME_OF_POSITION_CHANGE...", this));
MOZ_RELEASE_ASSERT(mIMEContentObserver->mSendingNotification ==
NOTIFY_IME_OF_NOTHING);
mIMEContentObserver->mSendingNotification = NOTIFY_IME_OF_POSITION_CHANGE;
IMEStateManager::NotifyIME(IMENotification(NOTIFY_IME_OF_POSITION_CHANGE),
mIMEContentObserver->mWidget);
mIMEContentObserver->mSendingNotification = NOTIFY_IME_OF_NOTHING;
MOZ_LOG(sIMECOLog, LogLevel::Debug,
("IMECO: 0x%p IMEContentObserver::PositionChangeEvent::Run(), "
"sent NOTIFY_IME_OF_POSITION_CHANGE", this));
return NS_OK;
("IMECO: 0x%p IMEContentObserver::IMENotificationSender::"
"SendPositionChange(), sent NOTIFY_IME_OF_POSITION_CHANGE", this));
}
/******************************************************************************
@ -1524,7 +1568,7 @@ IMEContentObserver::PositionChangeEvent::Run()
NS_IMETHODIMP
IMEContentObserver::AsyncMergeableNotificationsFlusher::Run()
{
if (!CanNotifyIME()) {
if (!CanNotifyIME(eChangeEventType_FlushPendingEvents)) {
MOZ_LOG(sIMECOLog, LogLevel::Debug,
("IMECO: 0x%p IMEContentObserver::AsyncMergeableNotificationsFlusher::"
"Run(), FAILED, due to impossible to flush pending notifications",

113
dom/events/IMEContentObserver.h

@ -43,6 +43,7 @@ public:
typedef widget::IMENotification::SelectionChangeData SelectionChangeData;
typedef widget::IMENotification::TextChangeData TextChangeData;
typedef widget::IMENotification::TextChangeDataBase TextChangeDataBase;
typedef widget::IMEMessage IMEMessage;
IMEContentObserver();
@ -119,10 +120,9 @@ private:
void PostFocusSetNotification();
void MaybeNotifyIMEOfFocusSet();
void PostTextChangeNotification(const TextChangeDataBase& aTextChangeData);
void PostTextChangeNotification();
void MaybeNotifyIMEOfTextChange(const TextChangeDataBase& aTextChangeData);
void PostSelectionChangeNotification(bool aCausedByComposition,
bool aCausedBySelectionEvent);
void PostSelectionChangeNotification();
void MaybeNotifyIMEOfSelectionChange(bool aCausedByComposition,
bool aCausedBySelectionEvent);
void PostPositionChangeNotification();
@ -141,11 +141,19 @@ private:
void FlushMergeableNotifications();
void ClearPendingNotifications()
{
mIsFocusEventPending = false;
mIsSelectionChangeEventPending = false;
mIsPositionChangeEventPending = false;
mNeedsToNotifyIMEOfFocusSet = false;
mNeedsToNotifyIMEOfTextChange = false;
mNeedsToNotifyIMEOfSelectionChange = false;
mNeedsToNotifyIMEOfPositionChange = false;
mTextChangeData.Clear();
}
bool NeedsToNotifyIMEOfSomething() const
{
return mNeedsToNotifyIMEOfFocusSet ||
mNeedsToNotifyIMEOfTextChange ||
mNeedsToNotifyIMEOfSelectionChange ||
mNeedsToNotifyIMEOfPositionChange;
}
/**
* UpdateSelectionCache() updates mSelectionData with the latest selection.
@ -223,9 +231,9 @@ private:
TextChangeData mTextChangeData;
// mSelectionData is the last selection data which was notified. This is
// modified by UpdateSelectionCache(). Note that mCausedBy* are always
// false. Do NOT refer them.
// mSelectionData is the last selection data which was notified. The
// selection information is modified by UpdateSelectionCache(). The reason
// of the selection change is modified by MaybeNotifyIMEOfSelectionChange().
SelectionChangeData mSelectionData;
EventStateManager* mESM;
@ -235,14 +243,24 @@ private:
uint32_t mSuppressNotifications;
int64_t mPreCharacterDataChangeLength;
// mSendingNotification is a notification which is now sending from
// IMENotificationSender. When the value is NOTIFY_IME_OF_NOTHING, it's
// not sending any notification.
IMEMessage mSendingNotification;
bool mIsObserving;
bool mIMEHasFocus;
bool mIsFocusEventPending;
bool mIsSelectionChangeEventPending;
bool mSelectionChangeCausedOnlyByComposition;
bool mSelectionChangeCausedOnlyBySelectionEvent;
bool mIsPositionChangeEventPending;
bool mNeedsToNotifyIMEOfFocusSet;
bool mNeedsToNotifyIMEOfTextChange;
bool mNeedsToNotifyIMEOfSelectionChange;
bool mNeedsToNotifyIMEOfPositionChange;
// mIsFlushingPendingNotifications is true between
// FlushMergeableNotifications() creates IMENotificationSender and
// IMENotificationSender sent all pending notifications.
bool mIsFlushingPendingNotifications;
// mIsHandlingQueryContentEvent is true when IMEContentObserver is handling
// WidgetQueryContentEvent with ContentEventHandler.
bool mIsHandlingQueryContentEvent;
/**
@ -261,84 +279,39 @@ private:
eChangeEventType_FlushPendingEvents
};
AChangeEvent(ChangeEventType aChangeEventType,
IMEContentObserver* aIMEContentObserver)
explicit AChangeEvent(IMEContentObserver* aIMEContentObserver)
: mIMEContentObserver(aIMEContentObserver)
, mChangeEventType(aChangeEventType)
{
MOZ_ASSERT(mIMEContentObserver);
}
nsRefPtr<IMEContentObserver> mIMEContentObserver;
ChangeEventType mChangeEventType;
/**
* CanNotifyIME() checks if mIMEContentObserver can and should notify IME.
*/
bool CanNotifyIME() const;
bool CanNotifyIME(ChangeEventType aChangeEventType) const;
/**
* IsSafeToNotifyIME() checks if it's safe to noitify IME.
*/
bool IsSafeToNotifyIME() const;
};
class FocusSetEvent: public AChangeEvent
{
public:
explicit FocusSetEvent(IMEContentObserver* aIMEContentObserver)
: AChangeEvent(eChangeEventType_Focus, aIMEContentObserver)
{
}
NS_IMETHOD Run() override;
bool IsSafeToNotifyIME(ChangeEventType aChangeEventType) const;
};
class SelectionChangeEvent : public AChangeEvent
class IMENotificationSender: public AChangeEvent
{
public:
SelectionChangeEvent(IMEContentObserver* aIMEContentObserver,
bool aCausedByComposition,
bool aCausedBySelectionEvent)
: AChangeEvent(eChangeEventType_Selection, aIMEContentObserver)
, mCausedByComposition(aCausedByComposition)
, mCausedBySelectionEvent(aCausedBySelectionEvent)
explicit IMENotificationSender(IMEContentObserver* aIMEContentObserver)
: AChangeEvent(aIMEContentObserver)
{
aIMEContentObserver->mSelectionChangeCausedOnlyByComposition = false;
aIMEContentObserver->mSelectionChangeCausedOnlyBySelectionEvent = false;
}
NS_IMETHOD Run() override;
private:
bool mCausedByComposition;
bool mCausedBySelectionEvent;
};
class TextChangeEvent : public AChangeEvent
{
public:
TextChangeEvent(IMEContentObserver* aIMEContentObserver,
TextChangeDataBase& aTextChangeData)
: AChangeEvent(eChangeEventType_Text, aIMEContentObserver)
, mTextChangeData(aTextChangeData)
{
MOZ_ASSERT(mTextChangeData.IsValid());
// Reset aTextChangeData because this now consumes the data.
aTextChangeData.Clear();
}
NS_IMETHOD Run() override;
private:
TextChangeDataBase mTextChangeData;
};
class PositionChangeEvent final : public AChangeEvent
{
public:
explicit PositionChangeEvent(IMEContentObserver* aIMEContentObserver)
: AChangeEvent(eChangeEventType_Position, aIMEContentObserver)
{
}
NS_IMETHOD Run() override;
void SendFocusSet();
void SendSelectionChange();
void SendTextChange();
void SendPositionChange();
};
class AsyncMergeableNotificationsFlusher : public AChangeEvent
@ -346,7 +319,7 @@ private:
public:
explicit AsyncMergeableNotificationsFlusher(
IMEContentObserver* aIMEContentObserver)
: AChangeEvent(eChangeEventType_FlushPendingEvents, aIMEContentObserver)
: AChangeEvent(aIMEContentObserver)
{
}
NS_IMETHOD Run() override;

29
dom/events/IMEStateManager.cpp

@ -133,29 +133,6 @@ GetIMEStateSetOpenName(IMEState::Open aOpen)
}
}
static const char*
GetEventMessageName(EventMessage aMessage)
{
switch (aMessage) {
case eCompositionStart:
return "eCompositionStart";
case eCompositionEnd:
return "eCompositionEnd";
case eCompositionUpdate:
return "eCompositionUpdate";
case eCompositionChange:
return "eCompositionChange";
case eCompositionCommitAsIs:
return "eCompositionCommitAsIs";
case eCompositionCommit:
return "eCompositionCommit";
case eSetSelection:
return "eSetSelection";
default:
return "unacceptable event message";
}
}
static const char*
GetNotifyIMEMessageName(IMEMessage aMessage)
{
@ -1137,7 +1114,7 @@ IMEStateManager::DispatchCompositionEvent(
"mFlags={ mIsTrusted=%s, mPropagationStopped=%s } }, "
"aIsSynthesized=%s), tabParent=%p",
aEventTargetNode, aPresContext,
GetEventMessageName(aCompositionEvent->mMessage),
ToChar(aCompositionEvent->mMessage),
GetBoolName(aCompositionEvent->mFlags.mIsTrusted),
GetBoolName(aCompositionEvent->mFlags.mPropagationStopped),
GetBoolName(aIsSynthesized), tabParent.get()));
@ -1235,7 +1212,7 @@ IMEStateManager::HandleSelectionEvent(nsPresContext* aPresContext,
"aEventTargetContent=0x%p, aSelectionEvent={ mMessage=%s, "
"mFlags={ mIsTrusted=%s } }), tabParent=%p",
aPresContext, aEventTargetContent,
GetEventMessageName(aSelectionEvent->mMessage),
ToChar(aSelectionEvent->mMessage),
GetBoolName(aSelectionEvent->mFlags.mIsTrusted),
tabParent.get()));
@ -1268,7 +1245,7 @@ IMEStateManager::OnCompositionEventDiscarded(
MOZ_LOG(sISMLog, LogLevel::Info,
("ISM: IMEStateManager::OnCompositionEventDiscarded(aCompositionEvent={ "
"mMessage=%s, mFlags={ mIsTrusted=%s } })",
GetEventMessageName(aCompositionEvent->mMessage),
ToChar(aCompositionEvent->mMessage),
GetBoolName(aCompositionEvent->mFlags.mIsTrusted)));
if (!aCompositionEvent->mFlags.mIsTrusted) {

4
dom/events/KeyboardEvent.cpp

@ -261,9 +261,9 @@ KeyboardEvent::InitWithKeyboardEventInit(EventTarget* aOwner,
{
bool trusted = Init(aOwner);
aRv = InitKeyEvent(aType, aParam.mBubbles, aParam.mCancelable,
aParam.mView, aParam.mCtrlKey, aParam.mAltKey,
aParam.mShiftKey, aParam.mMetaKey,
aParam.mView, false, false, false, false,
aParam.mKeyCode, aParam.mCharCode);
InitModifiers(aParam);
SetTrusted(trusted);
mDetail = aParam.mDetail;
mInitializedByCtor = true;

27
dom/events/MouseEvent.cpp

@ -139,6 +139,15 @@ MouseEvent::InitMouseEvent(const nsAString& aType,
}
}
void
MouseEvent::InitializeExtraMouseEventDictionaryMembers(const MouseEventInit& aParam)
{
InitModifiers(aParam);
mEvent->AsMouseEventBase()->buttons = aParam.mButtons;
mMovementPoint.x = aParam.mMovementX;
mMovementPoint.y = aParam.mMovementY;
}
already_AddRefed<MouseEvent>
MouseEvent::Constructor(const GlobalObject& aGlobal,
const nsAString& aType,
@ -154,21 +163,9 @@ MouseEvent::Constructor(const GlobalObject& aGlobal,
aParam.mCtrlKey, aParam.mAltKey, aParam.mShiftKey,
aParam.mMetaKey, aParam.mButton, aParam.mRelatedTarget,
aRv);
e->InitializeExtraMouseEventDictionaryMembers(aParam);
e->SetTrusted(trusted);
switch (e->mEvent->mClass) {
case eMouseEventClass:
case eMouseScrollEventClass:
case eWheelEventClass:
case eDragEventClass:
case ePointerEventClass:
case eSimpleGestureEventClass:
e->mEvent->AsMouseEventBase()->buttons = aParam.mButtons;
break;
default:
break;
}
return e.forget();
}
@ -315,7 +312,7 @@ NS_IMETHODIMP
MouseEvent::GetMozMovementX(int32_t* aMovementX)
{
NS_ENSURE_ARG_POINTER(aMovementX);
*aMovementX = MozMovementX();
*aMovementX = MovementX();
return NS_OK;
}
@ -324,7 +321,7 @@ NS_IMETHODIMP
MouseEvent::GetMozMovementY(int32_t* aMovementY)
{
NS_ENSURE_ARG_POINTER(aMovementY);
*aMovementY = MozMovementY();
*aMovementY = MovementY();
return NS_OK;
}

7
dom/events/MouseEvent.h

@ -69,6 +69,9 @@ public:
aShiftKey, aMetaKey, aButton,
aRelatedTarget);
}
void InitializeExtraMouseEventDictionaryMembers(const MouseEventInit& aParam);
bool GetModifierState(const nsAString& aKeyArg)
{
return GetModifierStateInternal(aKeyArg);
@ -77,11 +80,11 @@ public:
const nsAString& aType,
const MouseEventInit& aParam,
ErrorResult& aRv);
int32_t MozMovementX()
int32_t MovementX()
{
return GetMovementPoint().x;
}
int32_t MozMovementY()
int32_t MovementY()
{
return GetMovementPoint().y;
}

4
dom/events/PointerEvent.cpp

@ -81,9 +81,9 @@ PointerEvent::Constructor(EventTarget* aOwner,
e->InitMouseEvent(aType, aParam.mBubbles, aParam.mCancelable,
aParam.mView, aParam.mDetail, aParam.mScreenX,
aParam.mScreenY, aParam.mClientX, aParam.mClientY,
aParam.mCtrlKey, aParam.mAltKey, aParam.mShiftKey,
aParam.mMetaKey, aParam.mButton,
false, false, false, false, aParam.mButton,
aParam.mRelatedTarget);
e->InitializeExtraMouseEventDictionaryMembers(aParam);
WidgetPointerEvent* widgetEvent = e->mEvent->AsPointerEvent();
widgetEvent->pointerId = aParam.mPointerId;

39
dom/events/UIEvent.cpp

@ -114,7 +114,7 @@ DevPixelsToCSSPixels(const LayoutDeviceIntPoint& aPoint,
nsIntPoint
UIEvent::GetMovementPoint()
{
if (mPrivateDataDuplicated) {
if (mPrivateDataDuplicated || mEventIsInternal) {
return mMovementPoint;
}
@ -441,6 +441,43 @@ UIEvent::GetModifierStateInternal(const nsAString& aKey)
return ((inputEvent->modifiers & WidgetInputEvent::GetModifier(aKey)) != 0);
}
void
UIEvent::InitModifiers(const EventModifierInit& aParam)
{
if (NS_WARN_IF(!mEvent)) {
return;
}
WidgetInputEvent* inputEvent = mEvent->AsInputEvent();
MOZ_ASSERT(inputEvent,
"This method shouldn't be called if it doesn't have modifiers");
if (NS_WARN_IF(!inputEvent)) {
return;
}
inputEvent->modifiers = MODIFIER_NONE;
#define SET_MODIFIER(aName, aValue) \
if (aParam.m##aName) { \
inputEvent->modifiers |= aValue; \
} \
SET_MODIFIER(CtrlKey, MODIFIER_CONTROL)
SET_MODIFIER(ShiftKey, MODIFIER_SHIFT)
SET_MODIFIER(AltKey, MODIFIER_ALT)
SET_MODIFIER(MetaKey, MODIFIER_META)
SET_MODIFIER(ModifierAltGraph, MODIFIER_ALTGRAPH)
SET_MODIFIER(ModifierCapsLock, MODIFIER_CAPSLOCK)
SET_MODIFIER(ModifierFn, MODIFIER_FN)
SET_MODIFIER(ModifierFnLock, MODIFIER_FNLOCK)
SET_MODIFIER(ModifierNumLock, MODIFIER_NUMLOCK)
SET_MODIFIER(ModifierOS, MODIFIER_OS)
SET_MODIFIER(ModifierScrollLock, MODIFIER_SCROLLLOCK)
SET_MODIFIER(ModifierSymbol, MODIFIER_SYMBOL)
SET_MODIFIER(ModifierSymbolLock, MODIFIER_SYMBOLLOCK)
#undef SET_MODIFIER
}
} // namespace dom
} // namespace mozilla

1
dom/events/UIEvent.h

@ -164,6 +164,7 @@ protected:
static Modifiers ComputeModifierState(const nsAString& aModifiersList);
bool GetModifierStateInternal(const nsAString& aKey);
void InitModifiers(const EventModifierInit& aParam);
};
} // namespace dom

35
dom/events/WheelEvent.cpp

@ -148,33 +148,6 @@ WheelEvent::GetDeltaMode(uint32_t* aDeltaMode)
return NS_OK;
}
static void
GetModifierList(bool aCtrl, bool aShift, bool aAlt, bool aMeta,
nsAString& aModifierList)
{
if (aCtrl) {
aModifierList.AppendLiteral(NS_DOM_KEYNAME_CONTROL);
}
if (aShift) {
if (!aModifierList.IsEmpty()) {
aModifierList.Append(' ');
}
aModifierList.AppendLiteral(NS_DOM_KEYNAME_SHIFT);
}
if (aAlt) {
if (!aModifierList.IsEmpty()) {
aModifierList.Append(' ');
}
aModifierList.AppendLiteral(NS_DOM_KEYNAME_ALT);
}
if (aMeta) {
if (!aModifierList.IsEmpty()) {
aModifierList.Append(' ');
}
aModifierList.AppendLiteral(NS_DOM_KEYNAME_META);
}
}
already_AddRefed<WheelEvent>
WheelEvent::Constructor(const GlobalObject& aGlobal,
const nsAString& aType,
@ -184,18 +157,14 @@ WheelEvent::Constructor(const GlobalObject& aGlobal,
nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
nsRefPtr<WheelEvent> e = new WheelEvent(t, nullptr, nullptr);
bool trusted = e->Init(t);
nsAutoString modifierList;
GetModifierList(aParam.mCtrlKey, aParam.mShiftKey,
aParam.mAltKey, aParam.mMetaKey,
modifierList);
aRv = e->InitWheelEvent(aType, aParam.mBubbles, aParam.mCancelable,
aParam.mView, aParam.mDetail,
aParam.mScreenX, aParam.mScreenY,
aParam.mClientX, aParam.mClientY,
aParam.mButton, aParam.mRelatedTarget,
modifierList, aParam.mDeltaX,
EmptyString(), aParam.mDeltaX,
aParam.mDeltaY, aParam.mDeltaZ, aParam.mDeltaMode);
e->mEvent->AsWheelEvent()->buttons = aParam.mButtons;
e->InitializeExtraMouseEventDictionaryMembers(aParam);
e->SetTrusted(trusted);
return e.forget();
}

4
dom/events/test/test_dom_mouse_event.html

@ -107,6 +107,10 @@ function testInitializingUntrustedEvent()
}
is(e.isTrusted, false, description + "isTrusted returns wrong value");
is(e.buttons, 0, description + "buttons returns wrong value");
is(e.movementX, 0, description + "movementX returns wrong value");
is(e.movementY, 0, description + "movementY returns wrong value");
is(e.movementX, e.mozMovementX);
is(e.movementY, e.mozMovementY);
// getModifierState() tests
is(e.getModifierState("Shift"), kTest.shiftKey,

108
dom/events/test/test_eventctors.html

@ -22,6 +22,19 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=675884
var receivedEvent;
document.addEventListener("hello", function(e) { receivedEvent = e; }, true);
function isMethodResultInitializer(aPropName)
{
return aPropName.startsWith("modifier");
}
function getPropValue(aEvent, aPropName)
{
if (aPropName.startsWith("modifier")) {
return aEvent.getModifierState(aPropName.substr("modifier".length));
}
return aEvent[aPropName];
}
// Event
var e;
var ex = false;
@ -371,6 +384,15 @@ var keyboardEventProps =