Bug 1337718 part.7 Make IMEStateManager::OnMouseButtonEventInEditor() take WidgetMouseEvent* instead of nsIDOMMouseEvent r?m_kato
MozReview-Commit-ID: FDselwSymZq
--- a/dom/events/IMEStateManager.cpp
+++ b/dom/events/IMEStateManager.cpp
@@ -557,23 +557,29 @@ IMEStateManager::OnInstalledMenuKeyboard
InputContextAction::MENU_LOST_PSEUDO_FOCUS);
OnChangeFocusInternal(sPresContext, sContent, action);
}
// static
bool
IMEStateManager::OnMouseButtonEventInEditor(nsPresContext* aPresContext,
nsIContent* aContent,
- nsIDOMMouseEvent* aMouseEvent)
+ WidgetMouseEvent* aMouseEvent)
{
MOZ_LOG(sISMLog, LogLevel::Info,
("OnMouseButtonEventInEditor(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)) {
+ MOZ_LOG(sISMLog, LogLevel::Debug,
+ (" OnMouseButtonEventInEditor(), aMouseEvent is nullptr"));
+ return false;
+ }
+
if (sPresContext != aPresContext || sContent != aContent) {
MOZ_LOG(sISMLog, LogLevel::Debug,
(" OnMouseButtonEventInEditor(), "
"the mouse event isn't fired on the editor managed by ISM"));
return false;
}
if (!sActiveIMEContentObserver) {
@@ -585,35 +591,25 @@ IMEStateManager::OnMouseButtonEventInEdi
if (!sActiveIMEContentObserver->IsManaging(aPresContext, aContent)) {
MOZ_LOG(sISMLog, LogLevel::Debug,
(" OnMouseButtonEventInEditor(), "
"the active IMEContentObserver isn't managing the editor"));
return false;
}
- WidgetMouseEvent* internalEvent =
- aMouseEvent->AsEvent()->WidgetEventPtr()->AsMouseEvent();
- if (NS_WARN_IF(!internalEvent)) {
- MOZ_LOG(sISMLog, LogLevel::Debug,
- (" OnMouseButtonEventInEditor(), "
- "the internal event of aMouseEvent isn't WidgetMouseEvent"));
- return false;
- }
-
bool consumed =
- sActiveIMEContentObserver->OnMouseButtonEvent(aPresContext, internalEvent);
+ sActiveIMEContentObserver->OnMouseButtonEvent(aPresContext, aMouseEvent);
if (MOZ_LOG_TEST(sISMLog, LogLevel::Info)) {
nsAutoString eventType;
- aMouseEvent->AsEvent()->GetType(eventType);
MOZ_LOG(sISMLog, LogLevel::Info,
(" OnMouseButtonEventInEditor(), "
- "mouse event (type=%s, button=%d) is %s",
- NS_ConvertUTF16toUTF8(eventType).get(), internalEvent->button,
+ "mouse event (mMessage=%s, button=%d) is %s",
+ ToChar(aMouseEvent->mMessage), aMouseEvent->button,
consumed ? "consumed" : "not consumed"));
}
return consumed;
}
// static
void
--- a/dom/events/IMEStateManager.h
+++ b/dom/events/IMEStateManager.h
@@ -137,17 +137,17 @@ public:
nsIContent* aContent,
nsIEditor* aEditor);
// This method is called when user operates mouse button in focused editor
// and before the editor handles it.
// Returns true if IME consumes the event. Otherwise, false.
static bool OnMouseButtonEventInEditor(nsPresContext* aPresContext,
nsIContent* aContent,
- nsIDOMMouseEvent* aMouseEvent);
+ WidgetMouseEvent* aMouseEvent);
// 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,
--- a/editor/libeditor/EditorEventListener.cpp
+++ b/editor/libeditor/EditorEventListener.cpp
@@ -746,19 +746,21 @@ EditorEventListener::NotifyIMEOfMouseBut
MOZ_ASSERT(aMouseEvent);
if (!EditorHasFocus()) {
return false;
}
nsPresContext* presContext = GetPresContext();
NS_ENSURE_TRUE(presContext, false);
+ WidgetMouseEvent* mouseEvent =
+ aMouseEvent->AsEvent()->WidgetEventPtr()->AsMouseEvent();
return IMEStateManager::OnMouseButtonEventInEditor(presContext,
GetFocusedRootContent(),
- aMouseEvent);
+ mouseEvent);
}
nsresult
EditorEventListener::MouseDown(nsIDOMMouseEvent* aMouseEvent)
{
// FYI: We don't need to check if it's already consumed here because
// we need to commit composition at mouse button operation.
// FYI: This may be called by HTMLEditorEventListener::MouseDown() even