Bug 718170 - Part c: Use nsINode in IsEmptyCell; r=ehsan

This commit is contained in:
Ms2ger 2012-01-25 08:50:06 +01:00
Родитель 0ee0b0b894
Коммит b4f8648985
3 изменённых файлов: 40 добавлений и 26 удалений

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

@ -4868,10 +4868,21 @@ nsHTMLEditor::IsEmptyNode( nsIDOMNode *aNode,
bool aSafeToAskFrames)
{
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
NS_ENSURE_TRUE(node && outIsEmptyNode, NS_ERROR_NULL_POINTER);
return IsEmptyNode(node, outIsEmptyNode, aSingleBRDoesntCount,
aListOrCellNotEmpty, aSafeToAskFrames);
}
nsresult
nsHTMLEditor::IsEmptyNode(nsINode* aNode,
bool* outIsEmptyNode,
bool aSingleBRDoesntCount,
bool aListOrCellNotEmpty,
bool aSafeToAskFrames)
{
NS_ENSURE_TRUE(aNode && outIsEmptyNode, NS_ERROR_NULL_POINTER);
*outIsEmptyNode = true;
bool seenBR = false;
return IsEmptyNodeImpl(node, outIsEmptyNode, aSingleBRDoesntCount,
return IsEmptyNodeImpl(aNode, outIsEmptyNode, aSingleBRDoesntCount,
aListOrCellNotEmpty, aSafeToAskFrames, &seenBR);
}

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

@ -395,6 +395,10 @@ public:
bool aMozBRDoesntCount = false,
bool aListOrCellNotEmpty = false,
bool aSafeToAskFrames = false);
nsresult IsEmptyNode(nsINode* aNode, bool* outIsEmptyBlock,
bool aMozBRDoesntCount = false,
bool aListOrCellNotEmpty = false,
bool aSafeToAskFrames = false);
nsresult IsEmptyNodeImpl(nsINode* aNode,
bool *outIsEmptyBlock,
bool aMozBRDoesntCount,

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

@ -62,7 +62,9 @@
#include "nsHTMLEditUtils.h"
#include "nsLayoutErrors.h"
#include "mozilla/dom/Element.h"
using namespace mozilla;
/***************************************************************************
* stack based helper class for restoring selection after table edit
@ -3441,31 +3443,28 @@ nsHTMLEditor::AllCellsInColumnSelected(nsIDOMElement *aTable, PRInt32 aColIndex,
bool
nsHTMLEditor::IsEmptyCell(nsIDOMElement *aCell)
{
nsCOMPtr<nsIDOMNode> cellChild;
nsCOMPtr<dom::Element> cell = do_QueryInterface(aCell);
// Check if target only contains empty text node or <br>
nsresult res = aCell->GetFirstChild(getter_AddRefs(cellChild));
NS_ENSURE_SUCCESS(res, false);
if (cellChild)
{
nsCOMPtr<nsIDOMNode> nextChild;
res = cellChild->GetNextSibling(getter_AddRefs(nextChild));
NS_ENSURE_SUCCESS(res, false);
if (!nextChild)
{
// We insert a single break into a cell by default
// to have some place to locate a cursor -- it is dispensable
bool isEmpty = nsTextEditUtils::IsBreak(cellChild);
// Or check if no real content
if (!isEmpty)
{
res = IsEmptyNode(cellChild, &isEmpty, false, false);
NS_ENSURE_SUCCESS(res, false);
}
return isEmpty;
}
nsCOMPtr<nsINode> cellChild = cell->GetFirstChild();
if (!cellChild) {
return false;
}
return false;
nsCOMPtr<nsINode> nextChild = cellChild->GetNextSibling();
if (nextChild) {
return false;
}
// We insert a single break into a cell by default
// to have some place to locate a cursor -- it is dispensable
if (cellChild->IsElement() && cellChild->AsElement()->IsHTML(nsGkAtoms::br)) {
return true;
}
bool isEmpty;
// Or check if no real content
nsresult rv = IsEmptyNode(cellChild, &isEmpty, false, false);
NS_ENSURE_SUCCESS(rv, false);
return isEmpty;
}