Bug 1193762 part 3 - Remove nsEditor::IsDescendantOfEditorRoot(nsIDOMNode*); r=ehsan

This commit is contained in:
Aryeh Gregor 2016-05-01 17:59:29 +03:00
parent 419ed0f1bb
commit 0a025f6cca
3 changed files with 14 additions and 15 deletions

View File

@ -3347,13 +3347,6 @@ nsEditor::IsDescendantOfRoot(nsINode* inNode)
return nsContentUtils::ContentIsDescendantOf(inNode, root);
}
bool
nsEditor::IsDescendantOfEditorRoot(nsIDOMNode* aNode)
{
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
return IsDescendantOfEditorRoot(node);
}
bool
nsEditor::IsDescendantOfEditorRoot(nsINode* aNode)
{
@ -3648,13 +3641,15 @@ nsEditor::GetChildAt(nsIDOMNode *aParent, int32_t aOffset)
// assuming that aParentOrNode is the node itself if it's a text node, or
// the node's parent otherwise.
//
nsCOMPtr<nsIDOMNode>
nsIContent*
nsEditor::GetNodeAtRangeOffsetPoint(nsIDOMNode* aParentOrNode, int32_t aOffset)
{
if (IsTextNode(aParentOrNode)) {
return aParentOrNode;
nsCOMPtr<nsINode> parentOrNode = do_QueryInterface(aParentOrNode);
NS_ENSURE_TRUE(parentOrNode || !aParentOrNode, nullptr);
if (parentOrNode->GetAsText()) {
return parentOrNode->AsContent();
}
return GetChildAt(aParentOrNode, aOffset);
return parentOrNode->GetChildAt(aOffset);
}

View File

@ -555,7 +555,6 @@ public:
/** returns true if aNode is a descendant of our root node */
bool IsDescendantOfRoot(nsIDOMNode* inNode);
bool IsDescendantOfRoot(nsINode* inNode);
bool IsDescendantOfEditorRoot(nsIDOMNode* aNode);
bool IsDescendantOfEditorRoot(nsINode* aNode);
/** returns true if aNode is a container */
@ -599,7 +598,8 @@ public:
static bool IsTextNode(nsINode *aNode);
static nsCOMPtr<nsIDOMNode> GetChildAt(nsIDOMNode *aParent, int32_t aOffset);
static nsCOMPtr<nsIDOMNode> GetNodeAtRangeOffsetPoint(nsIDOMNode* aParentOrNode, int32_t aOffset);
static nsIContent* GetNodeAtRangeOffsetPoint(nsIDOMNode* aParentOrNode,
int32_t aOffset);
static nsresult GetStartNodeAndOffset(Selection* aSelection,
nsIDOMNode** outStartNode,

View File

@ -1651,10 +1651,12 @@ nsHTMLEditor::InsertNodeAtPoint(nsIDOMNode *aNode,
NS_IMETHODIMP
nsHTMLEditor::SelectElement(nsIDOMElement* aElement)
{
nsCOMPtr<Element> element = do_QueryInterface(aElement);
NS_ENSURE_STATE(element || !aElement);
nsresult res = NS_ERROR_NULL_POINTER;
// Must be sure that element is contained in the document body
if (IsDescendantOfEditorRoot(aElement)) {
if (IsDescendantOfEditorRoot(element)) {
RefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIDOMNode>parent;
@ -1677,10 +1679,12 @@ nsHTMLEditor::SelectElement(nsIDOMElement* aElement)
NS_IMETHODIMP
nsHTMLEditor::SetCaretAfterElement(nsIDOMElement* aElement)
{
nsCOMPtr<Element> element = do_QueryInterface(aElement);
NS_ENSURE_STATE(element || !aElement);
nsresult res = NS_ERROR_NULL_POINTER;
// Be sure the element is contained in the document body
if (aElement && IsDescendantOfEditorRoot(aElement)) {
if (aElement && IsDescendantOfEditorRoot(element)) {
RefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIDOMNode>parent;