Bug 1337718 part.9 Make IMEStateManager::OnClickInEditor() take const WidgetMouseEvent* instead of nsIDOMMouseEvent* r?m_kato
MozReview-Commit-ID: KdoMcxW8lkT
--- a/dom/events/IMEStateManager.cpp
+++ b/dom/events/IMEStateManager.cpp
@@ -610,67 +610,60 @@ IMEStateManager::OnMouseButtonEventInEdi
return consumed;
}
// static
void
IMEStateManager::OnClickInEditor(nsPresContext* aPresContext,
nsIContent* aContent,
- nsIDOMMouseEvent* aMouseEvent)
+ const WidgetMouseEvent* aMouseEvent)
{
MOZ_LOG(sISMLog, LogLevel::Info,
("OnClickInEditor(aPresContext=0x%p, aContent=0x%p, aMouseEvent=0x%p), "
"sPresContext=0x%p, sContent=0x%p",
aPresContext, aContent, aMouseEvent, sPresContext.get(), sContent.get()));
+ if (NS_WARN_IF(!aMouseEvent)) {
+ return;
+ }
+
if (sPresContext != aPresContext || sContent != aContent) {
MOZ_LOG(sISMLog, LogLevel::Debug,
(" OnClickInEditor(), "
"the mouse event isn't fired on the editor managed by ISM"));
return;
}
nsCOMPtr<nsIWidget> widget = aPresContext->GetRootWidget();
NS_ENSURE_TRUE_VOID(widget);
- bool isTrusted;
- nsresult rv = aMouseEvent->AsEvent()->GetIsTrusted(&isTrusted);
- NS_ENSURE_SUCCESS_VOID(rv);
- if (!isTrusted) {
+ if (!aMouseEvent->IsTrusted()) {
MOZ_LOG(sISMLog, LogLevel::Debug,
(" OnClickInEditor(), "
"the mouse event isn't a trusted event"));
return; // ignore untrusted event.
}
- int16_t button;
- rv = aMouseEvent->GetButton(&button);
- NS_ENSURE_SUCCESS_VOID(rv);
- if (button != 0) {
+ if (aMouseEvent->button) {
MOZ_LOG(sISMLog, LogLevel::Debug,
(" OnClickInEditor(), "
"the mouse event isn't a left mouse button event"));
return; // not a left click event.
}
- int32_t clickCount;
- rv = aMouseEvent->GetDetail(&clickCount);
- NS_ENSURE_SUCCESS_VOID(rv);
- if (clickCount != 1) {
+ if (aMouseEvent->mClickCount != 1) {
MOZ_LOG(sISMLog, LogLevel::Debug,
(" OnClickInEditor(), "
"the mouse event isn't a single click event"));
return; // should notify only first click event.
}
- uint16_t inputSource = nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
- aMouseEvent->GetMozInputSource(&inputSource);
InputContextAction::Cause cause =
- inputSource == nsIDOMMouseEvent::MOZ_SOURCE_TOUCH ?
+ aMouseEvent->inputSource == nsIDOMMouseEvent::MOZ_SOURCE_TOUCH ?
InputContextAction::CAUSE_TOUCH : InputContextAction::CAUSE_MOUSE;
InputContextAction action(cause, InputContextAction::FOCUS_NOT_CHANGED);
IMEState newState = GetNewIMEState(aPresContext, aContent);
SetIMEState(newState, aContent, widget, action);
}
// static
--- a/dom/events/IMEStateManager.h
+++ b/dom/events/IMEStateManager.h
@@ -8,17 +8,16 @@
#define mozilla_IMEStateManager_h_
#include "mozilla/EventForwards.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/dom/TabParent.h"
#include "nsIWidget.h"
class nsIContent;
-class nsIDOMMouseEvent;
class nsIEditor;
class nsINode;
class nsPresContext;
class nsISelection;
namespace mozilla {
class EventDispatchingCallback;
@@ -146,17 +145,17 @@ public:
// This method is called when user clicked in an editor.
// aContent must be:
// If the editor is for <input> or <textarea>, the element.
// If the editor is for contenteditable, the active editinghost.
// If the editor is for designMode, nullptr.
static void OnClickInEditor(nsPresContext* aPresContext,
nsIContent* aContent,
- nsIDOMMouseEvent* aMouseEvent);
+ const WidgetMouseEvent* aMouseEvent);
// This method is called when editor actually gets focus.
// aContent must be:
// If the editor is for <input> or <textarea>, the element.
// If the editor is for contenteditable, the active editinghost.
// If the editor is for designMode, nullptr.
static void OnFocusInEditor(nsPresContext* aPresContext,
nsIContent* aContent,
--- a/editor/libeditor/EditorEventListener.cpp
+++ b/editor/libeditor/EditorEventListener.cpp
@@ -647,17 +647,17 @@ EditorEventListener::MouseClick(nsIDOMMo
}
// Notifies clicking on editor to IMEStateManager even when the event was
// consumed.
if (EditorHasFocus()) {
nsPresContext* presContext = GetPresContext();
if (presContext) {
IMEStateManager::OnClickInEditor(presContext, GetFocusedRootContent(),
- aMouseEvent);
+ clickEvent);
if (DetachedFromEditor()) {
return NS_OK;
}
}
}
if (DetachedFromEditorOrDefaultPrevented(clickEvent)) {
// We're done if 'preventdefault' is true (see for example bug 70698).