summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorFranklinDM <mrmineshafter17@gmail.com>2023-03-03 23:39:58 +0800
committerFranklinDM <mrmineshafter17@gmail.com>2023-03-04 21:32:11 +0800
commit59b4e5ceb2350c355d5e51ebc86949092fd18dc4 (patch)
tree9ea9172fbc80d3578f2c981556e3eb356f13d64d /editor
parent6ffdfa793ee9d16de0c1218dbe9188e8a7279f14 (diff)
downloaduxp-59b4e5ceb2350c355d5e51ebc86949092fd18dc4.tar.gz
Issue #2135 - Bug 1356496: Don't use nsIDOM* in ConfirmSelectionInBody
Diffstat (limited to 'editor')
-rw-r--r--editor/libeditor/HTMLEditRules.cpp29
1 files changed, 15 insertions, 14 deletions
diff --git a/editor/libeditor/HTMLEditRules.cpp b/editor/libeditor/HTMLEditRules.cpp
index ac1c4ce6ff..850bbe9b5a 100644
--- a/editor/libeditor/HTMLEditRules.cpp
+++ b/editor/libeditor/HTMLEditRules.cpp
@@ -7986,16 +7986,20 @@ HTMLEditRules::ConfirmSelectionInBody()
{
// get the body
NS_ENSURE_STATE(mHTMLEditor);
- nsCOMPtr<nsIDOMElement> rootElement = do_QueryInterface(mHTMLEditor->GetRoot());
- NS_ENSURE_TRUE(rootElement, NS_ERROR_UNEXPECTED);
+ RefPtr<Element> rootElement = mHTMLEditor->GetRoot();
+ if (NS_WARN_IF(!rootElement)) {
+ return NS_ERROR_UNEXPECTED;
+ }
// get the selection
NS_ENSURE_STATE(mHTMLEditor);
RefPtr<Selection> selection = mHTMLEditor->GetSelection();
- NS_ENSURE_STATE(selection);
+ if (NS_WARN_IF(!selection)) {
+ return NS_ERROR_UNEXPECTED;
+ }
// get the selection start location
- nsCOMPtr<nsIDOMNode> selNode, temp, parent;
+ nsCOMPtr<nsINode> selNode;
int32_t selOffset;
NS_ENSURE_STATE(mHTMLEditor);
nsresult rv =
@@ -8005,12 +8009,11 @@ HTMLEditRules::ConfirmSelectionInBody()
return rv;
}
- temp = selNode;
+ nsINode* temp = selNode;
// check that selNode is inside body
- while (temp && !TextEditUtils::IsBody(temp)) {
- temp->GetParentNode(getter_AddRefs(parent));
- temp = parent;
+ while (temp && !temp->IsHTMLElement(nsGkAtoms::body)) {
+ temp = temp->GetParentNode();
}
// if we aren't in the body, force the issue
@@ -8018,6 +8021,7 @@ HTMLEditRules::ConfirmSelectionInBody()
// uncomment this to see when we get bad selections
// NS_NOTREACHED("selection not in body");
selection->Collapse(rootElement, 0);
+ return NS_OK;
}
// get the selection end location
@@ -8028,9 +8032,8 @@ HTMLEditRules::ConfirmSelectionInBody()
temp = selNode;
// check that selNode is inside body
- while (temp && !TextEditUtils::IsBody(temp)) {
- rv = temp->GetParentNode(getter_AddRefs(parent));
- temp = parent;
+ while (temp && !temp->IsHTMLElement(nsGkAtoms::body)) {
+ temp = temp->GetParentNode();
}
// if we aren't in the body, force the issue
@@ -8040,9 +8043,7 @@ HTMLEditRules::ConfirmSelectionInBody()
selection->Collapse(rootElement, 0);
}
- // XXX This is the result of the last call of GetParentNode(), it doesn't
- // make sense...
- return rv;
+ return NS_OK;
}
nsresult