Bug 1337718 part.10 Make EditorEventListener::MouseClick() and EditorEventListener::HandleMiddleClickPaste() use WidgetMouseEvent as far as possible r?m_kato
MozReview-Commit-ID: EMFevpq9ftM
--- a/editor/libeditor/EditorEventListener.cpp
+++ b/editor/libeditor/EditorEventListener.cpp
@@ -666,30 +666,30 @@ EditorEventListener::MouseClick(nsIDOMMo
// If we got a mouse down inside the editing area, we should force the
// IME to commit before we change the cursor position
editorBase->ForceCompositionEnd();
if (DetachedFromEditor()) {
return NS_OK;
}
- int16_t button = -1;
- aMouseEvent->GetButton(&button);
- if (button == 1) {
+ if (clickEvent->button == 1) {
return HandleMiddleClickPaste(aMouseEvent);
}
return NS_OK;
}
nsresult
EditorEventListener::HandleMiddleClickPaste(nsIDOMMouseEvent* aMouseEvent)
{
MOZ_ASSERT(aMouseEvent);
- MOZ_ASSERT(!DetachedFromEditorOrDefaultPrevented(
- aMouseEvent->AsEvent()->WidgetEventPtr()));
+
+ WidgetMouseEvent* clickEvent =
+ aMouseEvent->AsEvent()->WidgetEventPtr()->AsMouseEvent();
+ MOZ_ASSERT(!DetachedFromEditorOrDefaultPrevented(clickEvent));
if (!Preferences::GetBool("middlemouse.paste", false)) {
// Middle click paste isn't enabled.
return NS_OK;
}
// Set the selection to the point under the mouse cursor:
nsCOMPtr<nsIDOMNode> parent;
@@ -704,21 +704,18 @@ EditorEventListener::HandleMiddleClickPa
RefPtr<EditorBase> editorBase(mEditorBase);
RefPtr<Selection> selection = editorBase->GetSelection();
if (selection) {
selection->Collapse(parent, offset);
}
// If the ctrl key is pressed, we'll do paste as quotation.
// Would've used the alt key, but the kde wmgr treats alt-middle specially.
- bool ctrlKey = false;
- aMouseEvent->GetCtrlKey(&ctrlKey);
-
nsCOMPtr<nsIEditorMailSupport> mailEditor;
- if (ctrlKey) {
+ if (clickEvent->IsControl()) {
mailEditor = do_QueryObject(editorBase);
}
nsresult rv;
int32_t clipboard = nsIClipboard::kGlobalClipboard;
nsCOMPtr<nsIClipboard> clipboardService =
do_GetService("@mozilla.org/widget/clipboard;1", &rv);
if (NS_SUCCEEDED(rv)) {
@@ -732,18 +729,18 @@ EditorEventListener::HandleMiddleClickPa
if (mailEditor) {
mailEditor->PasteAsQuotation(clipboard);
} else {
editorBase->Paste(clipboard);
}
// Prevent the event from propagating up to be possibly handled
// again by the containing window:
- aMouseEvent->AsEvent()->StopPropagation();
- aMouseEvent->AsEvent()->PreventDefault();
+ clickEvent->StopPropagation();
+ clickEvent->PreventDefault();
// We processed the event, whether drop/paste succeeded or not
return NS_OK;
}
bool
EditorEventListener::NotifyIMEOfMouseButtonEvent(
WidgetMouseEvent* aMouseEvent)