Bug 1411687 - part 0: Get rid of HTMLEditor::GetBlockNodeParent(nsIDOMNode*) r?m_kato
Currently, HTMLEditor::GetBlockNodeParent(nsIDOMNode*) is used only by
HTMLEditor::DoInsertHTMLWithContext() and there is a variable of nsINode*.
So, we don't need to keep it anymore.
MozReview-Commit-ID: LEWaiR5BEB9
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -759,29 +759,16 @@ HTMLEditor::GetBlockNodeParent(nsINode*
return p->AsElement();
}
p = p->GetParentNode();
}
return nullptr;
}
-nsIDOMNode*
-HTMLEditor::GetBlockNodeParent(nsIDOMNode* aNode)
-{
- nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
-
- if (!node) {
- NS_NOTREACHED("null node passed to GetBlockNodeParent()");
- return nullptr;
- }
-
- return GetAsDOMNode(GetBlockNodeParent(node));
-}
-
/**
* Returns the node if it's a block, otherwise GetBlockNodeParent
*/
Element*
HTMLEditor::GetBlock(nsINode& aNode)
{
if (NodeIsBlockStatic(&aNode)) {
return aNode.AsElement();
--- a/editor/libeditor/HTMLEditor.h
+++ b/editor/libeditor/HTMLEditor.h
@@ -182,17 +182,16 @@ public:
* This sets background on the appropriate container element (table, cell,)
* or calls into nsTextEditor to set the page background.
*/
nsresult SetCSSBackgroundColor(const nsAString& aColor);
nsresult SetHTMLBackgroundColor(const nsAString& aColor);
// Block methods moved from EditorBase
static Element* GetBlockNodeParent(nsINode* aNode);
- static nsIDOMNode* GetBlockNodeParent(nsIDOMNode* aNode);
static Element* GetBlock(nsINode& aNode);
void IsNextCharInNodeWhitespace(nsIContent* aContent,
int32_t aOffset,
bool* outIsSpace,
bool* outIsNBSP,
nsIContent** outNode = nullptr,
int32_t* outOffset = 0);
--- a/editor/libeditor/HTMLEditorDataTransfer.cpp
+++ b/editor/libeditor/HTMLEditorDataTransfer.cpp
@@ -421,18 +421,18 @@ HTMLEditor::DoInsertHTMLWithContext(cons
}
// Loop over the node list and paste the nodes:
nsCOMPtr<nsIDOMNode> parentBlock, lastInsertNode, insertedContextParent;
nsCOMPtr<nsINode> parentNodeNode = do_QueryInterface(parentNode);
NS_ENSURE_STATE(parentNodeNode || !parentNode);
if (IsBlockNode(parentNodeNode)) {
parentBlock = parentNode;
- } else {
- parentBlock = GetBlockNodeParent(parentNode);
+ } else if (parentNodeNode) {
+ parentBlock = GetAsDOMNode(GetBlockNodeParent(parentNodeNode));
}
int32_t listCount = nodeList.Length();
for (int32_t j = 0; j < listCount; j++) {
bool bDidInsert = false;
nsCOMPtr<nsIDOMNode> curNode = nodeList[j]->AsDOMNode();
NS_ENSURE_TRUE(curNode, NS_ERROR_FAILURE);