Bug 1337718 part.9 Make IMEStateManager::OnClickInEditor() take const WidgetMouseEvent* instead of nsIDOMMouseEvent* r=m_kato

MozReview-Commit-ID: KdoMcxW8lkT

--HG--
extra : rebase_source : a03316e3a6ca7daf937032f32e00f2a4b2fd23fc
This commit is contained in:
Masayuki Nakano 2017-02-08 22:29:14 +09:00
parent a6bd2cc214
commit fa85dc8ad8
3 changed files with 11 additions and 19 deletions

View File

@ -615,13 +615,17 @@ IMEStateManager::OnMouseButtonEventInEditor(nsPresContext* aPresContext,
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(), "
@ -632,40 +636,29 @@ IMEStateManager::OnClickInEditor(nsPresContext* aPresContext,
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);

View File

@ -13,7 +13,6 @@
#include "nsIWidget.h"
class nsIContent;
class nsIDOMMouseEvent;
class nsIEditor;
class nsINode;
class nsPresContext;
@ -151,7 +150,7 @@ public:
// 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:

View File

@ -652,7 +652,7 @@ EditorEventListener::MouseClick(nsIDOMMouseEvent* aMouseEvent)
nsPresContext* presContext = GetPresContext();
if (presContext) {
IMEStateManager::OnClickInEditor(presContext, GetFocusedRootContent(),
aMouseEvent);
clickEvent);
if (DetachedFromEditor()) {
return NS_OK;
}