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

This commit is contained in:
Aryeh Gregor 2016-05-01 16:18:39 +03:00
Родитель 45c59d499f
Коммит 4f5b418627
3 изменённых файлов: 14 добавлений и 15 удалений

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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,

Просмотреть файл

@ -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;