Bug 1451672 - part 22: Rename HTMLEditor::InsertNodeIntoProperAncestor() to HTMLEditor::InsertNodeIntoProperAncestorWithTransaction() r?m_kato
MozReview-Commit-ID: 6O47YeSpud8
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -84,22 +84,22 @@ IsLinkTag(const nsString& s)
static bool
IsNamedAnchorTag(const nsString& s)
{
return s.EqualsIgnoreCase("anchor") || s.EqualsIgnoreCase("namedanchor");
}
template EditorDOMPoint
-HTMLEditor::InsertNodeIntoProperAncestor(
+HTMLEditor::InsertNodeIntoProperAncestorWithTransaction(
nsIContent& aNode,
const EditorDOMPoint& aPointToInsert,
SplitAtEdges aSplitAtEdges);
template EditorDOMPoint
-HTMLEditor::InsertNodeIntoProperAncestor(
+HTMLEditor::InsertNodeIntoProperAncestorWithTransaction(
nsIContent& aNode,
const EditorRawDOMPoint& aPointToInsert,
SplitAtEdges aSplitAtEdges);
HTMLEditor::HTMLEditor()
: mCRInParagraphCreatesParagraph(false)
, mCSSAware(false)
, mSelectedCellIndex(0)
@@ -1579,17 +1579,17 @@ HTMLEditor::InsertElementAtSelection(nsI
// Adjust position based on the node we are going to insert.
EditorRawDOMPoint pointToInsert =
GetBetterInsertionPointFor(*element, atAnchor);
if (NS_WARN_IF(!pointToInsert.IsSet())) {
return NS_ERROR_FAILURE;
}
EditorDOMPoint insertedPoint =
- InsertNodeIntoProperAncestor(
+ InsertNodeIntoProperAncestorWithTransaction(
*element, pointToInsert, SplitAtEdges::eAllowToCreateEmptyContainer);
if (NS_WARN_IF(!insertedPoint.IsSet())) {
return NS_ERROR_FAILURE;
}
// Set caret after element, but check for special case
// of inserting table-related elements: set in first cell instead
if (!SetCaretInTableCell(aElement)) {
rv = SetCaretAfterElement(aElement);
@@ -1612,17 +1612,17 @@ HTMLEditor::InsertElementAtSelection(nsI
}
}
rv = rules->DidDoAction(selection, &ruleInfo, rv);
return rv;
}
template<typename PT, typename CT>
EditorDOMPoint
-HTMLEditor::InsertNodeIntoProperAncestor(
+HTMLEditor::InsertNodeIntoProperAncestorWithTransaction(
nsIContent& aNode,
const EditorDOMPointBase<PT, CT>& aPointToInsert,
SplitAtEdges aSplitAtEdges)
{
if (NS_WARN_IF(!aPointToInsert.IsSet())) {
return EditorDOMPoint();
}
MOZ_ASSERT(aPointToInsert.IsSetAndValid());
--- a/editor/libeditor/HTMLEditor.h
+++ b/editor/libeditor/HTMLEditor.h
@@ -438,37 +438,38 @@ public:
/**
* OnInputLineBreak() is called when user inputs a line break with
* Shift + Enter or something.
*/
nsresult OnInputLineBreak();
/**
- * InsertNodeIntoProperAncestor() attempts to insert aNode into the document,
- * at aPointToInsert. Checks with strict dtd to see if containment is
- * allowed. If not allowed, will attempt to find a parent in the parent
- * hierarchy of aPointToInsert.GetContainer() that will accept aNode as a
- * child. If such a parent is found, will split the document tree from
- * aPointToInsert up to parent, and then insert aNode. aPointToInsert is then
- * adjusted to point to the actual location that aNode was inserted at.
- * aSplitAtEdges specifies if the splitting process is allowed to result in
- * empty nodes.
+ * InsertNodeIntoProperAncestorWithTransaction() attempts to insert aNode
+ * into the document, at aPointToInsert. Checks with strict dtd to see if
+ * containment is allowed. If not allowed, will attempt to find a parent
+ * in the parent hierarchy of aPointToInsert.GetContainer() that will accept
+ * aNode as a child. If such a parent is found, will split the document
+ * tree from aPointToInsert up to parent, and then insert aNode.
+ * aPointToInsert is then adjusted to point to the actual location that
+ * aNode was inserted at. aSplitAtEdges specifies if the splitting process
+ * is allowed to result in empty nodes.
*
* @param aNode Node to insert.
* @param aPointToInsert Insertion point.
* @param aSplitAtEdges Splitting can result in empty nodes?
* @return Returns inserted point if succeeded.
* Otherwise, the result is not set.
*/
template<typename PT, typename CT>
EditorDOMPoint
- InsertNodeIntoProperAncestor(nsIContent& aNode,
- const EditorDOMPointBase<PT, CT>& aPointToInsert,
- SplitAtEdges aSplitAtEdges);
+ InsertNodeIntoProperAncestorWithTransaction(
+ nsIContent& aNode,
+ const EditorDOMPointBase<PT, CT>& aPointToInsert,
+ SplitAtEdges aSplitAtEdges);
/**
* Use this to assure that selection is set after attribute nodes when
* trying to collapse selection at begining of a block node
* e.g., when setting at beginning of a table cell
* This will stop at a table, however, since we don't want to
* "drill down" into nested tables.
* @param aSelection Optional. If null, we get current selection.
--- a/editor/libeditor/HTMLEditorDataTransfer.cpp
+++ b/editor/libeditor/HTMLEditorDataTransfer.cpp
@@ -459,17 +459,17 @@ HTMLEditor::DoInsertHTMLWithContext(cons
if (HTMLEditUtils::IsTableRow(curNode) &&
HTMLEditUtils::IsTableRow(pointToInsert.GetContainer()) &&
(HTMLEditUtils::IsTable(curNode) ||
HTMLEditUtils::IsTable(pointToInsert.GetContainer()))) {
for (nsCOMPtr<nsIContent> firstChild = curNode->GetFirstChild();
firstChild;
firstChild = curNode->GetFirstChild()) {
EditorDOMPoint insertedPoint =
- InsertNodeIntoProperAncestor(
+ InsertNodeIntoProperAncestorWithTransaction(
*firstChild, pointToInsert,
SplitAtEdges::eDoNotCreateEmptyContainer);
if (NS_WARN_IF(!insertedPoint.IsSet())) {
break;
}
bDidInsert = true;
lastInsertNode = firstChild;
pointToInsert = insertedPoint;
@@ -501,17 +501,17 @@ HTMLEditor::DoInsertHTMLWithContext(cons
// Is it an orphan node?
} else {
DeleteNodeWithTransaction(*pointToInsert.GetContainer());
pointToInsert.Set(pointToInsert.GetContainer());
}
}
}
EditorDOMPoint insertedPoint =
- InsertNodeIntoProperAncestor(
+ InsertNodeIntoProperAncestorWithTransaction(
*firstChild, pointToInsert,
SplitAtEdges::eDoNotCreateEmptyContainer);
if (NS_WARN_IF(!insertedPoint.IsSet())) {
break;
}
bDidInsert = true;
lastInsertNode = firstChild;
@@ -530,17 +530,17 @@ HTMLEditor::DoInsertHTMLWithContext(cons
}
} else if (parentBlock && HTMLEditUtils::IsPre(parentBlock) &&
HTMLEditUtils::IsPre(curNode)) {
// Check for pre's going into pre's.
for (nsCOMPtr<nsIContent> firstChild = curNode->GetFirstChild();
firstChild;
firstChild = curNode->GetFirstChild()) {
EditorDOMPoint insertedPoint =
- InsertNodeIntoProperAncestor(
+ InsertNodeIntoProperAncestorWithTransaction(
*firstChild, pointToInsert,
SplitAtEdges::eDoNotCreateEmptyContainer);
if (NS_WARN_IF(!insertedPoint.IsSet())) {
break;
}
bDidInsert = true;
lastInsertNode = firstChild;
@@ -549,17 +549,17 @@ HTMLEditor::DoInsertHTMLWithContext(cons
NS_WARNING_ASSERTION(advanced,
"Failed to advance offset from inserted point");
}
}
if (!bDidInsert || NS_FAILED(rv)) {
// Try to insert.
EditorDOMPoint insertedPoint =
- InsertNodeIntoProperAncestor(
+ InsertNodeIntoProperAncestorWithTransaction(
*curNode->AsContent(), pointToInsert,
SplitAtEdges::eDoNotCreateEmptyContainer);
if (insertedPoint.IsSet()) {
lastInsertNode = curNode->AsContent();
pointToInsert = insertedPoint;
}
// Assume failure means no legal parent in the document hierarchy,
@@ -569,17 +569,17 @@ HTMLEditor::DoInsertHTMLWithContext(cons
content && !insertedPoint.IsSet();
content = content->GetParent()) {
if (NS_WARN_IF(!content->GetParent()) ||
NS_WARN_IF(TextEditUtils::IsBody(content->GetParent()))) {
continue;
}
nsCOMPtr<nsINode> oldParent = content->GetParentNode();
insertedPoint =
- InsertNodeIntoProperAncestor(
+ InsertNodeIntoProperAncestorWithTransaction(
*content->GetParent(), pointToInsert,
SplitAtEdges::eDoNotCreateEmptyContainer);
if (insertedPoint.IsSet()) {
insertedContextParent = oldParent;
pointToInsert = insertedPoint;
}
}
}