зеркало из https://github.com/mozilla/gecko-dev.git
Backout changeset bb29532b1b73 (bug 1190172 part 11)
--HG-- extra : rebase_source : 08096495e936bfd6517d6651149ec65c96805980
This commit is contained in:
Родитель
2ef6ade2c4
Коммит
3aba3916c7
|
@ -1556,7 +1556,7 @@ nsHTMLEditRules::WillInsertBreak(Selection& aSelection, bool* aCancel,
|
|||
// "Text" is deleted leaving an empty block. We want to put in one br to
|
||||
// make block have a line. Then code further below will put in a second br.)
|
||||
bool isEmpty;
|
||||
IsEmptyBlock(*blockParent, &isEmpty);
|
||||
IsEmptyBlock(GetAsDOMNode(blockParent), &isEmpty);
|
||||
if (isEmpty) {
|
||||
nsCOMPtr<Element> br = mHTMLEditor->CreateBR(blockParent,
|
||||
blockParent->Length());
|
||||
|
@ -4526,24 +4526,29 @@ nsHTMLEditRules::CreateStyleForInsertText(Selection& aSelection,
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Figure out if aNode is (or is inside) an empty block. A block can have
|
||||
* children and still be considered empty, if the children are empty or
|
||||
* non-editable.
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IsEmptyBlock: figure out if aNode is (or is inside) an empty block.
|
||||
// A block can have children and still be considered empty,
|
||||
// if the children are empty or non-editable.
|
||||
//
|
||||
nsresult
|
||||
nsHTMLEditRules::IsEmptyBlock(Element& aNode,
|
||||
bool* aOutIsEmptyBlock,
|
||||
MozBRCounts aMozBRCounts)
|
||||
nsHTMLEditRules::IsEmptyBlock(nsIDOMNode *aNode,
|
||||
bool *outIsEmptyBlock,
|
||||
bool aMozBRDoesntCount,
|
||||
bool aListItemsNotEmpty)
|
||||
{
|
||||
MOZ_ASSERT(aOutIsEmptyBlock);
|
||||
*aOutIsEmptyBlock = true;
|
||||
NS_ENSURE_TRUE(aNode && outIsEmptyBlock, NS_ERROR_NULL_POINTER);
|
||||
*outIsEmptyBlock = true;
|
||||
|
||||
NS_ENSURE_TRUE(IsBlockNode(aNode.AsDOMNode()), NS_ERROR_NULL_POINTER);
|
||||
// nsresult res = NS_OK;
|
||||
nsCOMPtr<nsIDOMNode> nodeToTest;
|
||||
if (IsBlockNode(aNode)) nodeToTest = do_QueryInterface(aNode);
|
||||
// else nsCOMPtr<nsIDOMElement> block;
|
||||
// looks like I forgot to finish this. Wonder what I was going to do?
|
||||
|
||||
return mHTMLEditor->IsEmptyNode(aNode.AsDOMNode(), aOutIsEmptyBlock,
|
||||
aMozBRCounts == MozBRCounts::yes ? false
|
||||
: true);
|
||||
NS_ENSURE_TRUE(nodeToTest, NS_ERROR_NULL_POINTER);
|
||||
return mHTMLEditor->IsEmptyNode(nodeToTest, outIsEmptyBlock,
|
||||
aMozBRDoesntCount, aListItemsNotEmpty);
|
||||
}
|
||||
|
||||
|
||||
|
@ -6321,7 +6326,7 @@ nsHTMLEditRules::ReturnInHeader(Selection& aSelection,
|
|||
|
||||
// If the new (righthand) header node is empty, delete it
|
||||
bool isEmpty;
|
||||
res = IsEmptyBlock(aHeader, &isEmpty, MozBRCounts::no);
|
||||
res = IsEmptyBlock(aHeader.AsDOMNode(), &isEmpty, true);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
if (isEmpty) {
|
||||
res = mHTMLEditor->DeleteNode(&aHeader);
|
||||
|
@ -6574,7 +6579,7 @@ nsHTMLEditRules::ReturnInListItem(Selection& aSelection,
|
|||
// only if prefs say it's okay and if the parent isn't the active editing
|
||||
// host.
|
||||
bool isEmpty;
|
||||
nsresult res = IsEmptyBlock(aListItem, &isEmpty, MozBRCounts::no);
|
||||
nsresult res = IsEmptyBlock(aListItem.AsDOMNode(), &isEmpty, true, false);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
if (isEmpty && root != list && mReturnInEmptyLIKillsList) {
|
||||
// Get the list offset now -- before we might eventually split the list
|
||||
|
|
|
@ -249,10 +249,10 @@ protected:
|
|||
|
||||
nsresult CreateStyleForInsertText(mozilla::dom::Selection& aSelection,
|
||||
nsIDocument& aDoc);
|
||||
enum class MozBRCounts { yes, no };
|
||||
nsresult IsEmptyBlock(mozilla::dom::Element& aNode,
|
||||
bool* aOutIsEmptyBlock,
|
||||
MozBRCounts aMozBRCounts = MozBRCounts::yes);
|
||||
nsresult IsEmptyBlock(nsIDOMNode *aNode,
|
||||
bool *outIsEmptyBlock,
|
||||
bool aMozBRDoesntCount = false,
|
||||
bool aListItemsNotEmpty = false);
|
||||
nsresult CheckForEmptyBlock(nsINode* aStartNode,
|
||||
mozilla::dom::Element* aBodyNode,
|
||||
mozilla::dom::Selection* aSelection,
|
||||
|
|
Загрузка…
Ссылка в новой задаче