diff --git a/mozilla/editor/base/nsHTMLEditor.cpp b/mozilla/editor/base/nsHTMLEditor.cpp
index 598f3f5e741..3d5cc6d98f8 100644
--- a/mozilla/editor/base/nsHTMLEditor.cpp
+++ b/mozilla/editor/base/nsHTMLEditor.cpp
@@ -2246,7 +2246,7 @@ nsHTMLEditor::InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection)
(parentSelectedNode != bodyElement))
{
nsCOMPtr bodyNode = do_QueryInterface(bodyElement);
- PRBool isInline = PR_TRUE;
+ isInline = PR_TRUE;
while (isInline)
{
// Get parent of the top node to split
@@ -2589,6 +2589,67 @@ nsHTMLEditor::SetCaretAfterElement(nsIDOMElement* aElement)
return res;
}
+NS_IMETHODIMP
+nsHTMLEditor::GetEmbeddedObjects(nsISupportsArray* aNodeList)
+{
+ if (!aNodeList)
+ return NS_ERROR_NULL_POINTER;
+
+#if 0
+ return NS_ERROR_NOT_IMPLEMENTED;
+#else
+ nsresult res;
+
+ res = NS_NewISupportsArray(&aNodeList);
+ if (NS_FAILED(res))
+ return res;
+
+ nsCOMPtr iter;
+ res = nsComponentManager::CreateInstance(kCContentIteratorCID, nsnull,
+ nsIContentIterator::GetIID(),
+ getter_AddRefs(iter));
+ if ((NS_SUCCEEDED(res)) && iter)
+ {
+ // get the root content
+ nsCOMPtr rootContent;
+
+ nsCOMPtr domdoc;
+ nsEditor::GetDocument(getter_AddRefs(domdoc));
+ if (!domdoc)
+ return NS_ERROR_UNEXPECTED;
+
+ nsCOMPtr doc (do_QueryInterface(domdoc));
+ if (!doc)
+ return NS_ERROR_UNEXPECTED;
+
+ rootContent = doc->GetRootContent();
+
+ iter->Init(rootContent);
+
+ // loop through the content iterator for each content node
+ nsCOMPtr content;
+ res = iter->CurrentNode(getter_AddRefs(content));
+
+ while (NS_COMFALSE == iter->IsDone())
+ {
+ nsCOMPtr node (do_QueryInterface(content));
+ if (node)
+ {
+ nsAutoString tagName;
+ node->GetNodeName(tagName);
+ tagName.ToLowerCase();
+
+ // See if it's an image or an embed
+ if (tagName == "img" || tagName == "embed")
+ aNodeList->AppendElement(node);
+ }
+ iter->Next();
+ }
+ }
+
+ return res;
+#endif
+}
PRBool
nsHTMLEditor::CanContainTag(nsIDOMNode* aParent, const nsString &aTag)
diff --git a/mozilla/editor/base/nsHTMLEditor.h b/mozilla/editor/base/nsHTMLEditor.h
index 1e1d575161f..b393e0cf2ef 100644
--- a/mozilla/editor/base/nsHTMLEditor.h
+++ b/mozilla/editor/base/nsHTMLEditor.h
@@ -164,6 +164,9 @@ public:
NS_IMETHOD SetCaretInTableCell(nsIDOMElement* aElement, PRBool* caretIsSet);
NS_IMETHOD SetCaretAfterElement(nsIDOMElement* aElement);
+// MHTML helper methods
+ NS_IMETHOD GetEmbeddedObjects(nsISupportsArray* aNodeList);
+
// Table Editing (implemented in EditTable.cpp)
NS_IMETHOD CreateTxnForInsertTable(const nsIDOMElement *aTableNode, InsertTableTxn ** aTxn);
NS_IMETHOD GetColIndexForCell(nsIDOMNode *aCellNode, PRInt32 &aCellIndex);
diff --git a/mozilla/editor/base/nsJSEditorLog.cpp b/mozilla/editor/base/nsJSEditorLog.cpp
index a532c54bbaf..6e9d3e4e6b9 100644
--- a/mozilla/editor/base/nsJSEditorLog.cpp
+++ b/mozilla/editor/base/nsJSEditorLog.cpp
@@ -760,6 +760,12 @@ nsJSEditorLog::SetCaretAfterElement(nsIDOMElement* aElement)
return NS_ERROR_NOT_IMPLEMENTED;
}
+NS_IMETHODIMP
+nsJSEditorLog::GetEmbeddedObjects(nsISupportsArray* aNodeList)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
NS_IMETHODIMP
nsJSEditorLog::InsertTable()
{
diff --git a/mozilla/editor/base/nsJSEditorLog.h b/mozilla/editor/base/nsJSEditorLog.h
index 3c42428585c..e3e2de4838f 100644
--- a/mozilla/editor/base/nsJSEditorLog.h
+++ b/mozilla/editor/base/nsJSEditorLog.h
@@ -132,6 +132,7 @@ public:
NS_IMETHOD InsertLinkAroundSelection(nsIDOMElement* aAnchorElement);
NS_IMETHOD SelectElement(nsIDOMElement* aElement);
NS_IMETHOD SetCaretAfterElement(nsIDOMElement* aElement);
+ NS_IMETHOD GetEmbeddedObjects(nsISupportsArray* aNodeList);
NS_IMETHOD InsertTable();
NS_IMETHOD InsertTableCell(PRInt32 aNumber, PRBool aAfter);
NS_IMETHOD InsertTableColumn(PRInt32 aNumber, PRBool aAfter);
diff --git a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp
index 598f3f5e741..3d5cc6d98f8 100644
--- a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp
+++ b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp
@@ -2246,7 +2246,7 @@ nsHTMLEditor::InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection)
(parentSelectedNode != bodyElement))
{
nsCOMPtr bodyNode = do_QueryInterface(bodyElement);
- PRBool isInline = PR_TRUE;
+ isInline = PR_TRUE;
while (isInline)
{
// Get parent of the top node to split
@@ -2589,6 +2589,67 @@ nsHTMLEditor::SetCaretAfterElement(nsIDOMElement* aElement)
return res;
}
+NS_IMETHODIMP
+nsHTMLEditor::GetEmbeddedObjects(nsISupportsArray* aNodeList)
+{
+ if (!aNodeList)
+ return NS_ERROR_NULL_POINTER;
+
+#if 0
+ return NS_ERROR_NOT_IMPLEMENTED;
+#else
+ nsresult res;
+
+ res = NS_NewISupportsArray(&aNodeList);
+ if (NS_FAILED(res))
+ return res;
+
+ nsCOMPtr iter;
+ res = nsComponentManager::CreateInstance(kCContentIteratorCID, nsnull,
+ nsIContentIterator::GetIID(),
+ getter_AddRefs(iter));
+ if ((NS_SUCCEEDED(res)) && iter)
+ {
+ // get the root content
+ nsCOMPtr rootContent;
+
+ nsCOMPtr domdoc;
+ nsEditor::GetDocument(getter_AddRefs(domdoc));
+ if (!domdoc)
+ return NS_ERROR_UNEXPECTED;
+
+ nsCOMPtr doc (do_QueryInterface(domdoc));
+ if (!doc)
+ return NS_ERROR_UNEXPECTED;
+
+ rootContent = doc->GetRootContent();
+
+ iter->Init(rootContent);
+
+ // loop through the content iterator for each content node
+ nsCOMPtr content;
+ res = iter->CurrentNode(getter_AddRefs(content));
+
+ while (NS_COMFALSE == iter->IsDone())
+ {
+ nsCOMPtr node (do_QueryInterface(content));
+ if (node)
+ {
+ nsAutoString tagName;
+ node->GetNodeName(tagName);
+ tagName.ToLowerCase();
+
+ // See if it's an image or an embed
+ if (tagName == "img" || tagName == "embed")
+ aNodeList->AppendElement(node);
+ }
+ iter->Next();
+ }
+ }
+
+ return res;
+#endif
+}
PRBool
nsHTMLEditor::CanContainTag(nsIDOMNode* aParent, const nsString &aTag)
diff --git a/mozilla/editor/libeditor/html/nsHTMLEditor.h b/mozilla/editor/libeditor/html/nsHTMLEditor.h
index 1e1d575161f..b393e0cf2ef 100644
--- a/mozilla/editor/libeditor/html/nsHTMLEditor.h
+++ b/mozilla/editor/libeditor/html/nsHTMLEditor.h
@@ -164,6 +164,9 @@ public:
NS_IMETHOD SetCaretInTableCell(nsIDOMElement* aElement, PRBool* caretIsSet);
NS_IMETHOD SetCaretAfterElement(nsIDOMElement* aElement);
+// MHTML helper methods
+ NS_IMETHOD GetEmbeddedObjects(nsISupportsArray* aNodeList);
+
// Table Editing (implemented in EditTable.cpp)
NS_IMETHOD CreateTxnForInsertTable(const nsIDOMElement *aTableNode, InsertTableTxn ** aTxn);
NS_IMETHOD GetColIndexForCell(nsIDOMNode *aCellNode, PRInt32 &aCellIndex);
diff --git a/mozilla/editor/public/nsIHTMLEditor.h b/mozilla/editor/public/nsIHTMLEditor.h
index 308966390f4..58d0ba2ae42 100644
--- a/mozilla/editor/public/nsIHTMLEditor.h
+++ b/mozilla/editor/public/nsIHTMLEditor.h
@@ -99,7 +99,6 @@ public:
NS_IMETHOD InsertAsQuotation(const nsString& aQuotedText)=0;
NS_IMETHOD InsertAsCitedQuotation(const nsString& aQuotedText, const nsString& aCitation)=0;
-
NS_IMETHOD InsertHTML(const nsString &aInputString)=0;
/**
@@ -187,6 +186,9 @@ public:
NS_IMETHOD SelectElement(nsIDOMElement* aElement)=0;
NS_IMETHOD SetCaretAfterElement(nsIDOMElement* aElement)=0;
+// MHTML helper methods
+ NS_IMETHOD GetEmbeddedObjects(nsISupportsArray* aNodeList)=0;
+
// Table editing Methods
NS_IMETHOD InsertTable()=0;
NS_IMETHOD InsertTableCell(PRInt32 aNumber, PRBool aAfter)=0;