mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 718170 - Part c: Use nsINode in IsEmptyCell; r=ehsan
This commit is contained in:
parent
4bcb2cb24d
commit
b8529ac65e
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user