Bug 1156062 part 2 - Make GetBlockNodeParent and GetEnclosingTable return regular pointers; r=ehsan

This commit is contained in:
Aryeh Gregor 2015-10-11 18:58:47 +03:00
parent 7bf421040d
commit 158db25f7d
2 changed files with 12 additions and 15 deletions

View File

@ -817,7 +817,7 @@ nsHTMLEditor::SetDocumentTitle(const nsAString &aTitle)
///////////////////////////////////////////////////////////////////////////
// GetBlockNodeParent: returns enclosing block level ancestor, if any
//
already_AddRefed<Element>
Element*
nsHTMLEditor::GetBlockNodeParent(nsINode* aNode)
{
MOZ_ASSERT(aNode);
@ -826,7 +826,7 @@ nsHTMLEditor::GetBlockNodeParent(nsINode* aNode)
while (p) {
if (NodeIsBlockStatic(p)) {
return p.forget().downcast<Element>();
return p->AsElement();
}
p = p->GetParentNode();
}
@ -834,7 +834,7 @@ nsHTMLEditor::GetBlockNodeParent(nsINode* aNode)
return nullptr;
}
already_AddRefed<nsIDOMNode>
nsIDOMNode*
nsHTMLEditor::GetBlockNodeParent(nsIDOMNode *aNode)
{
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
@ -844,9 +844,7 @@ nsHTMLEditor::GetBlockNodeParent(nsIDOMNode *aNode)
return nullptr;
}
nsCOMPtr<nsIDOMNode> ret =
dont_AddRef(GetAsDOMNode(GetBlockNodeParent(node).take()));
return ret.forget();
return GetAsDOMNode(GetBlockNodeParent(node));
}
static const char16_t nbsp = 160;
@ -1065,7 +1063,7 @@ nsHTMLEditor::TabInTable(bool inIsShift, bool* outHandled)
node = iter->GetCurrentNode();
if (node && nsHTMLEditUtils::IsTableCell(node) &&
nsCOMPtr<Element>(GetEnclosingTable(node)) == table) {
GetEnclosingTable(node) == table) {
CollapseSelectionToDeepestNonTableFirstChild(nullptr, node);
*outHandled = true;
return NS_OK;
@ -3656,7 +3654,7 @@ nsHTMLEditor::SetCaretInTableCell(nsIDOMElement* aElement)
///////////////////////////////////////////////////////////////////////////
// GetEnclosingTable: find ancestor who is a table, if any
//
already_AddRefed<Element>
Element*
nsHTMLEditor::GetEnclosingTable(nsINode* aNode)
{
MOZ_ASSERT(aNode);
@ -3665,13 +3663,13 @@ nsHTMLEditor::GetEnclosingTable(nsINode* aNode)
block;
block = GetBlockNodeParent(block)) {
if (nsHTMLEditUtils::IsTable(block)) {
return block.forget();
return block;
}
}
return nullptr;
}
nsCOMPtr<nsIDOMNode>
nsIDOMNode*
nsHTMLEditor::GetEnclosingTable(nsIDOMNode *aNode)
{
NS_PRECONDITION(aNode, "null node passed to nsHTMLEditor::GetEnclosingTable");

View File

@ -231,8 +231,8 @@ public:
nsresult SetHTMLBackgroundColor(const nsAString& aColor);
/* ------------ Block methods moved from nsEditor -------------- */
static already_AddRefed<mozilla::dom::Element> GetBlockNodeParent(nsINode* aNode);
static already_AddRefed<nsIDOMNode> GetBlockNodeParent(nsIDOMNode *aNode);
static mozilla::dom::Element* GetBlockNodeParent(nsINode* aNode);
static nsIDOMNode* GetBlockNodeParent(nsIDOMNode* aNode);
void IsNextCharInNodeWhitespace(nsIContent* aContent,
int32_t aOffset,
@ -495,9 +495,8 @@ protected:
// End of Table Editing utilities
static already_AddRefed<mozilla::dom::Element>
GetEnclosingTable(nsINode* aNode);
static nsCOMPtr<nsIDOMNode> GetEnclosingTable(nsIDOMNode *aNode);
static mozilla::dom::Element* GetEnclosingTable(nsINode* aNode);
static nsIDOMNode* GetEnclosingTable(nsIDOMNode *aNode);
/** content-based query returns true if <aProperty aAttribute=aValue> effects aNode
* If <aProperty aAttribute=aValue> contains aNode,