remove redundant code and unused variables, cleanup (r=glazman, sr=tor, a=asa, bug=216054)

This commit is contained in:
brade%comcast.net 2003-09-03 13:56:21 +00:00
parent 8b0ca47657
commit f1dedc3d24

View File

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