diff --git a/editor/base/nsHTMLEditor.cpp b/editor/base/nsHTMLEditor.cpp
index 97d0b61c608..dd2782877bc 100644
--- a/editor/base/nsHTMLEditor.cpp
+++ b/editor/base/nsHTMLEditor.cpp
@@ -1758,7 +1758,7 @@ nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aRetu
if (image)
{
nsCOMPtr parent;
- nsCOMPtr current = selectedElement;
+ nsCOMPtr current = do_QueryInterface(selectedElement);
PRBool notDone = PR_TRUE;
do {
result = current->GetParentNode(getter_AddRefs(parent));
diff --git a/editor/libeditor/html/nsHTMLEditor.cpp b/editor/libeditor/html/nsHTMLEditor.cpp
index 97d0b61c608..dd2782877bc 100644
--- a/editor/libeditor/html/nsHTMLEditor.cpp
+++ b/editor/libeditor/html/nsHTMLEditor.cpp
@@ -1758,7 +1758,7 @@ nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aRetu
if (image)
{
nsCOMPtr parent;
- nsCOMPtr current = selectedElement;
+ nsCOMPtr current = do_QueryInterface(selectedElement);
PRBool notDone = PR_TRUE;
do {
result = current->GetParentNode(getter_AddRefs(parent));