Bug 1391978 - Part 8. Replace nsISelection::GetAnchorOffset with Selection::AnchorOffset. r?masayuki
MozReview-Commit-ID: GgxyRsVXHwl
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -1579,22 +1579,19 @@ HTMLEditor::InsertElementAtSelection(nsI
if (HTMLEditUtils::IsNamedAnchor(node)) {
selection->CollapseToStart();
} else {
selection->CollapseToEnd();
}
}
nsCOMPtr<nsIDOMNode> parentSelectedNode;
- int32_t offsetForInsert;
rv = selection->GetAnchorNode(getter_AddRefs(parentSelectedNode));
- // XXX: ERROR_HANDLING bad XPCOM usage
- if (NS_SUCCEEDED(rv) &&
- NS_SUCCEEDED(selection->GetAnchorOffset(&offsetForInsert)) &&
- parentSelectedNode) {
+ if (parentSelectedNode) {
+ int32_t offsetForInsert = selection->AnchorOffset();
// Adjust position based on the node we are going to insert.
NormalizeEOLInsertPosition(element, address_of(parentSelectedNode),
&offsetForInsert);
rv = InsertNodeAtPoint(node, address_of(parentSelectedNode),
&offsetForInsert, false);
NS_ENSURE_SUCCESS(rv, rv);
// Set caret after element, but check for special case
--- a/editor/libeditor/HTMLTableEditor.cpp
+++ b/editor/libeditor/HTMLTableEditor.cpp
@@ -3210,19 +3210,17 @@ HTMLEditor::GetSelectedOrParentTableElem
nsCOMPtr<nsIDOMNode> selectedNode;
// Get child of anchor node, if exists
bool hasChildren;
anchorNode->HasChildNodes(&hasChildren);
if (hasChildren) {
- int32_t anchorOffset;
- rv = selection->GetAnchorOffset(&anchorOffset);
- NS_ENSURE_SUCCESS(rv, rv);
+ int32_t anchorOffset = selection->AnchorOffset();
selectedNode = GetChildAt(anchorNode, anchorOffset);
if (!selectedNode) {
selectedNode = anchorNode;
// If anchor doesn't have a child, we can't be selecting a table element,
// so don't do the following:
} else {
nsCOMPtr<nsIAtom> atom = EditorBase::GetTag(selectedNode);
--- a/editor/libeditor/TextEditRules.cpp
+++ b/editor/libeditor/TextEditRules.cpp
@@ -196,17 +196,17 @@ TextEditRules::BeforeEdit(EditAction act
// setText replaces all text, so mCachedSelectionNode might be invalid on
// AfterEdit.
// Since this will be used as start position of spellchecker, we should
// use root instead.
mCachedSelectionNode = textEditor->GetRoot();
mCachedSelectionOffset = 0;
} else {
mCachedSelectionNode = selection->GetAnchorNode();
- selection->GetAnchorOffset(&mCachedSelectionOffset);
+ mCachedSelectionOffset = selection->AnchorOffset();
}
return NS_OK;
}
NS_IMETHODIMP
TextEditRules::AfterEdit(EditAction action,
nsIEditor::EDirection aDirection)