mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Bug 1004522 part 1 - Clean up nsWSRunObject::PrepareToJoinBlocks; r=ehsan
This commit is contained in:
parent
752e23f084
commit
f3ede06db7
@ -491,13 +491,13 @@ nsHTMLEditRules::AfterEditInner(EditAction action,
|
||||
|
||||
// also do this for original selection endpoints.
|
||||
NS_ENSURE_STATE(mHTMLEditor);
|
||||
nsWSRunObject(mHTMLEditor, GetAsDOMNode(mRangeItem->startNode),
|
||||
nsWSRunObject(mHTMLEditor, mRangeItem->startNode,
|
||||
mRangeItem->startOffset).AdjustWhitespace();
|
||||
// we only need to handle old selection endpoint if it was different from start
|
||||
if (mRangeItem->startNode != mRangeItem->endNode ||
|
||||
mRangeItem->startOffset != mRangeItem->endOffset) {
|
||||
NS_ENSURE_STATE(mHTMLEditor);
|
||||
nsWSRunObject(mHTMLEditor, GetAsDOMNode(mRangeItem->endNode),
|
||||
nsWSRunObject(mHTMLEditor, mRangeItem->endNode,
|
||||
mRangeItem->endOffset).AdjustWhitespace();
|
||||
}
|
||||
}
|
||||
@ -2901,7 +2901,9 @@ nsHTMLEditRules::JoinBlocks(nsIDOMNode *aLeftNode,
|
||||
|
||||
// adjust whitespace at block boundaries
|
||||
NS_ENSURE_STATE(mHTMLEditor);
|
||||
res = nsWSRunObject::PrepareToJoinBlocks(mHTMLEditor, aLeftBlock, aRightBlock);
|
||||
nsCOMPtr<Element> leftBlock(do_QueryInterface(aLeftBlock));
|
||||
nsCOMPtr<Element> rightBlock(do_QueryInterface(aRightBlock));
|
||||
res = nsWSRunObject::PrepareToJoinBlocks(mHTMLEditor, leftBlock, rightBlock);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
// Do br adjustment.
|
||||
nsCOMPtr<nsIDOMNode> brNode;
|
||||
|
@ -970,7 +970,7 @@ nsHTMLEditor::IsVisBreak(nsINode* aNode)
|
||||
nsCOMPtr<nsINode> selNode = GetNodeLocation(aNode, &selOffset);
|
||||
// Let's look after the break
|
||||
selOffset++;
|
||||
nsWSRunObject wsObj(this, selNode->AsDOMNode(), selOffset);
|
||||
nsWSRunObject wsObj(this, selNode, selOffset);
|
||||
nsCOMPtr<nsIDOMNode> visNode;
|
||||
int32_t visOffset = 0;
|
||||
WSType visType;
|
||||
|
@ -122,17 +122,15 @@ nsWSRunObject::ScrubBlockBoundary(nsHTMLEditor* aHTMLEd,
|
||||
return theWSObj.Scrub();
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsWSRunObject::PrepareToJoinBlocks(nsHTMLEditor *aHTMLEd,
|
||||
nsIDOMNode *aLeftParent,
|
||||
nsIDOMNode *aRightParent)
|
||||
nsresult
|
||||
nsWSRunObject::PrepareToJoinBlocks(nsHTMLEditor* aHTMLEd,
|
||||
Element* aLeftBlock,
|
||||
Element* aRightBlock)
|
||||
{
|
||||
nsCOMPtr<nsINode> leftParent(do_QueryInterface(aLeftParent));
|
||||
nsCOMPtr<nsINode> rightParent(do_QueryInterface(aRightParent));
|
||||
NS_ENSURE_TRUE(leftParent && rightParent && aHTMLEd, NS_ERROR_NULL_POINTER);
|
||||
NS_ENSURE_TRUE(aLeftBlock && aRightBlock && aHTMLEd, NS_ERROR_NULL_POINTER);
|
||||
|
||||
nsWSRunObject leftWSObj(aHTMLEd, leftParent, leftParent->Length());
|
||||
nsWSRunObject rightWSObj(aHTMLEd, rightParent, 0);
|
||||
nsWSRunObject leftWSObj(aHTMLEd, aLeftBlock, aLeftBlock->Length());
|
||||
nsWSRunObject rightWSObj(aHTMLEd, aRightBlock, 0);
|
||||
|
||||
return leftWSObj.PrepareToDeleteRangePriv(&rightWSObj);
|
||||
}
|
||||
|
@ -165,13 +165,13 @@ class MOZ_STACK_CLASS nsWSRunObject
|
||||
BlockBoundary aBoundary,
|
||||
nsINode* aBlock,
|
||||
int32_t aOffset = -1);
|
||||
|
||||
// PrepareToJoinBlocks fixes up ws at the end of aLeftParent and the
|
||||
// beginning of aRightParent in preperation for them to be joined.
|
||||
// example of fixup: trailingws in aLeftParent needs to be removed.
|
||||
static nsresult PrepareToJoinBlocks(nsHTMLEditor *aEd,
|
||||
nsIDOMNode *aLeftParent,
|
||||
nsIDOMNode *aRightParent);
|
||||
|
||||
// PrepareToJoinBlocks fixes up ws at the end of aLeftBlock and the
|
||||
// beginning of aRightBlock in preperation for them to be joined. Example
|
||||
// of fixup: trailingws in aLeftBlock needs to be removed.
|
||||
static nsresult PrepareToJoinBlocks(nsHTMLEditor* aEd,
|
||||
mozilla::dom::Element* aLeftBlock,
|
||||
mozilla::dom::Element* aRightBlock);
|
||||
|
||||
// PrepareToDeleteRange fixes up ws before {aStartNode,aStartOffset}
|
||||
// and after {aEndNode,aEndOffset} in preperation for content
|
||||
|
Loading…
Reference in New Issue
Block a user