diff --git a/editor/libeditor/html/nsHTMLEditorMouseListener.cpp b/editor/libeditor/html/nsHTMLEditorMouseListener.cpp
index d7fa729822ad..89905ff885d5 100644
--- a/editor/libeditor/html/nsHTMLEditorMouseListener.cpp
+++ b/editor/libeditor/html/nsHTMLEditorMouseListener.cpp
@@ -83,7 +83,6 @@ NS_IMPL_ISUPPORTS_INHERITED1(nsHTMLEditorMouseListener, nsTextEditorMouseListene
nsresult
nsHTMLEditorMouseListener::MouseUp(nsIDOMEvent* aMouseEvent)
{
- NS_ENSURE_ARG_POINTER(aMouseEvent);
nsCOMPtr mouseEvent ( do_QueryInterface(aMouseEvent) );
if (!mouseEvent) {
//non-ui event passed in. bad things.
@@ -113,7 +112,6 @@ nsHTMLEditorMouseListener::MouseUp(nsIDOMEvent* aMouseEvent)
nsresult
nsHTMLEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent)
{
- NS_ENSURE_TRUE(aMouseEvent, NS_ERROR_NULL_POINTER);
nsCOMPtr mouseEvent ( do_QueryInterface(aMouseEvent) );
if (!mouseEvent) {
//non-ui event passed in. bad things.
@@ -159,13 +157,13 @@ nsHTMLEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent)
mEditor->GetSelection(getter_AddRefs(selection));
if (!selection) return NS_OK;
- nsCOMPtr parent;
- PRInt32 offset = 0;
-
// Get location of mouse within target node
nsCOMPtr uiEvent = do_QueryInterface(aMouseEvent);
if (!uiEvent) return NS_ERROR_FAILURE;
+ nsCOMPtr parent;
+ PRInt32 offset = 0;
+
res = uiEvent->GetRangeParent(getter_AddRefs(parent));
if (NS_FAILED(res)) return res;
if (!parent) return NS_ERROR_FAILURE;
@@ -213,13 +211,6 @@ nsHTMLEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent)
if (isContextClick)
{
// Set the selection to the point under the mouse cursor:
- nsCOMPtr parent;
- if (NS_FAILED(uiEvent->GetRangeParent(getter_AddRefs(parent))))
- return NS_ERROR_NULL_POINTER;
- PRInt32 offset = 0;
- if (NS_FAILED(uiEvent->GetRangeOffset(&offset)))
- return NS_ERROR_NULL_POINTER;
-
selection->Collapse(parent, offset);
}
else
@@ -236,20 +227,15 @@ nsHTMLEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent)
// and not the entire body, or table-related elements
if (element)
{
- nsCOMPtr eleNode = do_QueryInterface(element);
+ nsCOMPtr selectAllNode = mHTMLEditor->FindUserSelectAllNode(element);
- if (eleNode)
+ if (selectAllNode)
{
- nsCOMPtr selectAllNode = mHTMLEditor->FindUserSelectAllNode(eleNode);
-
- if (selectAllNode)
+ nsCOMPtr newElement = do_QueryInterface(selectAllNode);
+ if (newElement)
{
- nsCOMPtr newElement = do_QueryInterface(selectAllNode);
- if (newElement)
- {
- node = selectAllNode;
- element = newElement;
- }
+ node = selectAllNode;
+ element = newElement;
}
}
@@ -298,16 +284,15 @@ nsHTMLEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent)
nsresult
nsHTMLEditorMouseListener::MouseClick(nsIDOMEvent* aMouseEvent)
{
- NS_ENSURE_ARG_POINTER(aMouseEvent);
nsCOMPtr mouseEvent ( do_QueryInterface(aMouseEvent) );
if (!mouseEvent) {
//non-ui event passed in. bad things.
return NS_OK;
}
- // Don't do anything special if not an HTML editor
- nsCOMPtr htmlEditor = do_QueryInterface(mEditor);
- if (htmlEditor)
+ // Don't do anything special if not an HTML inline table editor
+ nsCOMPtr inlineTableEditing = do_QueryInterface(mEditor);
+ if (inlineTableEditing)
{
nsCOMPtr target;
nsresult res = aMouseEvent->GetTarget(getter_AddRefs(target));
@@ -315,7 +300,6 @@ nsHTMLEditorMouseListener::MouseClick(nsIDOMEvent* aMouseEvent)
if (!target) return NS_ERROR_NULL_POINTER;
nsCOMPtr element = do_QueryInterface(target);
- nsCOMPtr inlineTableEditing = do_QueryInterface(htmlEditor);
inlineTableEditing->DoInlineTableEditingAction(element);
}