mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1003808 part 7 - Convert WSFragment members to nsINode; r=ehsan
This commit is contained in:
parent
6cfdefe422
commit
a7ec952796
@ -183,7 +183,7 @@ nsWSRunObject::InsertBreak(nsCOMPtr<nsIDOMNode> *aInOutParent,
|
|||||||
// delete the leading ws that is after insertion point. We don't
|
// delete the leading ws that is after insertion point. We don't
|
||||||
// have to (it would still not be significant after br), but it's
|
// have to (it would still not be significant after br), but it's
|
||||||
// just more aesthetically pleasing to.
|
// just more aesthetically pleasing to.
|
||||||
res = DeleteChars(*aInOutParent, *aInOutOffset, afterRun->mEndNode, afterRun->mEndOffset,
|
res = DeleteChars(*aInOutParent, *aInOutOffset, GetAsDOMNode(afterRun->mEndNode), afterRun->mEndOffset,
|
||||||
eOutsideUserSelectAll);
|
eOutsideUserSelectAll);
|
||||||
NS_ENSURE_SUCCESS(res, res);
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
} else if (afterRun->mType == WSType::normalWS) {
|
} else if (afterRun->mType == WSType::normalWS) {
|
||||||
@ -208,7 +208,7 @@ nsWSRunObject::InsertBreak(nsCOMPtr<nsIDOMNode> *aInOutParent,
|
|||||||
} else if (beforeRun->mType & WSType::trailingWS) {
|
} else if (beforeRun->mType & WSType::trailingWS) {
|
||||||
// need to delete the trailing ws that is before insertion point, because it
|
// need to delete the trailing ws that is before insertion point, because it
|
||||||
// would become significant after break inserted.
|
// would become significant after break inserted.
|
||||||
res = DeleteChars(beforeRun->mStartNode, beforeRun->mStartOffset, *aInOutParent, *aInOutOffset,
|
res = DeleteChars(GetAsDOMNode(beforeRun->mStartNode), beforeRun->mStartOffset, *aInOutParent, *aInOutOffset,
|
||||||
eOutsideUserSelectAll);
|
eOutsideUserSelectAll);
|
||||||
NS_ENSURE_SUCCESS(res, res);
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
} else if (beforeRun->mType == WSType::normalWS) {
|
} else if (beforeRun->mType == WSType::normalWS) {
|
||||||
@ -260,7 +260,7 @@ nsWSRunObject::InsertText(const nsAString& aStringToInsert,
|
|||||||
} else if (afterRun->mType & WSType::leadingWS) {
|
} else if (afterRun->mType & WSType::leadingWS) {
|
||||||
// delete the leading ws that is after insertion point, because it
|
// delete the leading ws that is after insertion point, because it
|
||||||
// would become significant after text inserted.
|
// would become significant after text inserted.
|
||||||
res = DeleteChars(*aInOutParent, *aInOutOffset, afterRun->mEndNode, afterRun->mEndOffset,
|
res = DeleteChars(*aInOutParent, *aInOutOffset, GetAsDOMNode(afterRun->mEndNode), afterRun->mEndOffset,
|
||||||
eOutsideUserSelectAll);
|
eOutsideUserSelectAll);
|
||||||
NS_ENSURE_SUCCESS(res, res);
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
} else if (afterRun->mType == WSType::normalWS) {
|
} else if (afterRun->mType == WSType::normalWS) {
|
||||||
@ -277,7 +277,7 @@ nsWSRunObject::InsertText(const nsAString& aStringToInsert,
|
|||||||
} else if (beforeRun->mType & WSType::trailingWS) {
|
} else if (beforeRun->mType & WSType::trailingWS) {
|
||||||
// need to delete the trailing ws that is before insertion point, because it
|
// need to delete the trailing ws that is before insertion point, because it
|
||||||
// would become significant after text inserted.
|
// would become significant after text inserted.
|
||||||
res = DeleteChars(beforeRun->mStartNode, beforeRun->mStartOffset, *aInOutParent, *aInOutOffset,
|
res = DeleteChars(GetAsDOMNode(beforeRun->mStartNode), beforeRun->mStartOffset, *aInOutParent, *aInOutOffset,
|
||||||
eOutsideUserSelectAll);
|
eOutsideUserSelectAll);
|
||||||
NS_ENSURE_SUCCESS(res, res);
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
} else if (beforeRun->mType == WSType::normalWS) {
|
} else if (beforeRun->mType == WSType::normalWS) {
|
||||||
@ -941,13 +941,13 @@ nsWSRunObject::GetRuns()
|
|||||||
|
|
||||||
// otherwise a little trickier. shucks.
|
// otherwise a little trickier. shucks.
|
||||||
mStartRun = new WSFragment();
|
mStartRun = new WSFragment();
|
||||||
mStartRun->mStartNode = GetAsDOMNode(mStartNode);
|
mStartRun->mStartNode = mStartNode;
|
||||||
mStartRun->mStartOffset = mStartOffset;
|
mStartRun->mStartOffset = mStartOffset;
|
||||||
|
|
||||||
if (mStartReason & WSType::block || mStartReason == WSType::br) {
|
if (mStartReason & WSType::block || mStartReason == WSType::br) {
|
||||||
// set up mStartRun
|
// set up mStartRun
|
||||||
mStartRun->mType = WSType::leadingWS;
|
mStartRun->mType = WSType::leadingWS;
|
||||||
mStartRun->mEndNode = GetAsDOMNode(mFirstNBSPNode);
|
mStartRun->mEndNode = mFirstNBSPNode;
|
||||||
mStartRun->mEndOffset = mFirstNBSPOffset;
|
mStartRun->mEndOffset = mFirstNBSPOffset;
|
||||||
mStartRun->mLeftType = mStartReason;
|
mStartRun->mLeftType = mStartReason;
|
||||||
mStartRun->mRightType = WSType::normalWS;
|
mStartRun->mRightType = WSType::normalWS;
|
||||||
@ -956,14 +956,14 @@ nsWSRunObject::GetRuns()
|
|||||||
WSFragment *normalRun = new WSFragment();
|
WSFragment *normalRun = new WSFragment();
|
||||||
mStartRun->mRight = normalRun;
|
mStartRun->mRight = normalRun;
|
||||||
normalRun->mType = WSType::normalWS;
|
normalRun->mType = WSType::normalWS;
|
||||||
normalRun->mStartNode = GetAsDOMNode(mFirstNBSPNode);
|
normalRun->mStartNode = mFirstNBSPNode;
|
||||||
normalRun->mStartOffset = mFirstNBSPOffset;
|
normalRun->mStartOffset = mFirstNBSPOffset;
|
||||||
normalRun->mLeftType = WSType::leadingWS;
|
normalRun->mLeftType = WSType::leadingWS;
|
||||||
normalRun->mLeft = mStartRun;
|
normalRun->mLeft = mStartRun;
|
||||||
if (mEndReason != WSType::block) {
|
if (mEndReason != WSType::block) {
|
||||||
// then no trailing ws. this normal run ends the overall ws run.
|
// then no trailing ws. this normal run ends the overall ws run.
|
||||||
normalRun->mRightType = mEndReason;
|
normalRun->mRightType = mEndReason;
|
||||||
normalRun->mEndNode = GetAsDOMNode(mEndNode);
|
normalRun->mEndNode = mEndNode;
|
||||||
normalRun->mEndOffset = mEndOffset;
|
normalRun->mEndOffset = mEndOffset;
|
||||||
mEndRun = normalRun;
|
mEndRun = normalRun;
|
||||||
}
|
}
|
||||||
@ -977,22 +977,22 @@ nsWSRunObject::GetRuns()
|
|||||||
{
|
{
|
||||||
// normal ws runs right up to adjacent block (nbsp next to block)
|
// normal ws runs right up to adjacent block (nbsp next to block)
|
||||||
normalRun->mRightType = mEndReason;
|
normalRun->mRightType = mEndReason;
|
||||||
normalRun->mEndNode = GetAsDOMNode(mEndNode);
|
normalRun->mEndNode = mEndNode;
|
||||||
normalRun->mEndOffset = mEndOffset;
|
normalRun->mEndOffset = mEndOffset;
|
||||||
mEndRun = normalRun;
|
mEndRun = normalRun;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
normalRun->mEndNode = GetAsDOMNode(mLastNBSPNode);
|
normalRun->mEndNode = mLastNBSPNode;
|
||||||
normalRun->mEndOffset = mLastNBSPOffset+1;
|
normalRun->mEndOffset = mLastNBSPOffset+1;
|
||||||
normalRun->mRightType = WSType::trailingWS;
|
normalRun->mRightType = WSType::trailingWS;
|
||||||
|
|
||||||
// set up next run
|
// set up next run
|
||||||
WSFragment *lastRun = new WSFragment();
|
WSFragment *lastRun = new WSFragment();
|
||||||
lastRun->mType = WSType::trailingWS;
|
lastRun->mType = WSType::trailingWS;
|
||||||
lastRun->mStartNode = GetAsDOMNode(mLastNBSPNode);
|
lastRun->mStartNode = mLastNBSPNode;
|
||||||
lastRun->mStartOffset = mLastNBSPOffset+1;
|
lastRun->mStartOffset = mLastNBSPOffset+1;
|
||||||
lastRun->mEndNode = GetAsDOMNode(mEndNode);
|
lastRun->mEndNode = mEndNode;
|
||||||
lastRun->mEndOffset = mEndOffset;
|
lastRun->mEndOffset = mEndOffset;
|
||||||
lastRun->mLeftType = WSType::normalWS;
|
lastRun->mLeftType = WSType::normalWS;
|
||||||
lastRun->mLeft = normalRun;
|
lastRun->mLeft = normalRun;
|
||||||
@ -1004,7 +1004,7 @@ nsWSRunObject::GetRuns()
|
|||||||
} else {
|
} else {
|
||||||
// mStartReason is not WSType::block or WSType::br; set up mStartRun
|
// mStartReason is not WSType::block or WSType::br; set up mStartRun
|
||||||
mStartRun->mType = WSType::normalWS;
|
mStartRun->mType = WSType::normalWS;
|
||||||
mStartRun->mEndNode = GetAsDOMNode(mLastNBSPNode);
|
mStartRun->mEndNode = mLastNBSPNode;
|
||||||
mStartRun->mEndOffset = mLastNBSPOffset+1;
|
mStartRun->mEndOffset = mLastNBSPOffset+1;
|
||||||
mStartRun->mLeftType = mStartReason;
|
mStartRun->mLeftType = mStartReason;
|
||||||
|
|
||||||
@ -1015,7 +1015,7 @@ nsWSRunObject::GetRuns()
|
|||||||
if ((mLastNBSPNode == mEndNode) && (mLastNBSPOffset == (mEndOffset-1)))
|
if ((mLastNBSPNode == mEndNode) && (mLastNBSPOffset == (mEndOffset-1)))
|
||||||
{
|
{
|
||||||
mStartRun->mRightType = mEndReason;
|
mStartRun->mRightType = mEndReason;
|
||||||
mStartRun->mEndNode = GetAsDOMNode(mEndNode);
|
mStartRun->mEndNode = mEndNode;
|
||||||
mStartRun->mEndOffset = mEndOffset;
|
mStartRun->mEndOffset = mEndOffset;
|
||||||
mEndRun = mStartRun;
|
mEndRun = mStartRun;
|
||||||
}
|
}
|
||||||
@ -1024,7 +1024,7 @@ nsWSRunObject::GetRuns()
|
|||||||
// set up next run
|
// set up next run
|
||||||
WSFragment *lastRun = new WSFragment();
|
WSFragment *lastRun = new WSFragment();
|
||||||
lastRun->mType = WSType::trailingWS;
|
lastRun->mType = WSType::trailingWS;
|
||||||
lastRun->mStartNode = GetAsDOMNode(mLastNBSPNode);
|
lastRun->mStartNode = mLastNBSPNode;
|
||||||
lastRun->mStartOffset = mLastNBSPOffset+1;
|
lastRun->mStartOffset = mLastNBSPOffset+1;
|
||||||
lastRun->mLeftType = WSType::normalWS;
|
lastRun->mLeftType = WSType::normalWS;
|
||||||
lastRun->mLeft = mStartRun;
|
lastRun->mLeft = mStartRun;
|
||||||
@ -1056,10 +1056,10 @@ nsWSRunObject::MakeSingleWSRun(WSType aType)
|
|||||||
{
|
{
|
||||||
mStartRun = new WSFragment();
|
mStartRun = new WSFragment();
|
||||||
|
|
||||||
mStartRun->mStartNode = GetAsDOMNode(mStartNode);
|
mStartRun->mStartNode = mStartNode;
|
||||||
mStartRun->mStartOffset = mStartOffset;
|
mStartRun->mStartOffset = mStartOffset;
|
||||||
mStartRun->mType = aType;
|
mStartRun->mType = aType;
|
||||||
mStartRun->mEndNode = GetAsDOMNode(mEndNode);
|
mStartRun->mEndNode = mEndNode;
|
||||||
mStartRun->mEndOffset = mEndOffset;
|
mStartRun->mEndOffset = mEndOffset;
|
||||||
mStartRun->mLeftType = mStartReason;
|
mStartRun->mLeftType = mStartReason;
|
||||||
mStartRun->mRightType = mEndReason;
|
mStartRun->mRightType = mEndReason;
|
||||||
@ -1315,7 +1315,7 @@ nsWSRunObject::PrepareToDeleteRangePriv(nsWSRunObject* aEndObject)
|
|||||||
|
|
||||||
// trim after run of any leading ws
|
// trim after run of any leading ws
|
||||||
if (afterRun && (afterRun->mType & WSType::leadingWS)) {
|
if (afterRun && (afterRun->mType & WSType::leadingWS)) {
|
||||||
res = aEndObject->DeleteChars(GetAsDOMNode(aEndObject->mNode), aEndObject->mOffset, afterRun->mEndNode, afterRun->mEndOffset,
|
res = aEndObject->DeleteChars(GetAsDOMNode(aEndObject->mNode), aEndObject->mOffset, GetAsDOMNode(afterRun->mEndNode), afterRun->mEndOffset,
|
||||||
eOutsideUserSelectAll);
|
eOutsideUserSelectAll);
|
||||||
NS_ENSURE_SUCCESS(res, res);
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
@ -1336,7 +1336,7 @@ nsWSRunObject::PrepareToDeleteRangePriv(nsWSRunObject* aEndObject)
|
|||||||
}
|
}
|
||||||
// trim before run of any trailing ws
|
// trim before run of any trailing ws
|
||||||
if (beforeRun && (beforeRun->mType & WSType::trailingWS)) {
|
if (beforeRun && (beforeRun->mType & WSType::trailingWS)) {
|
||||||
res = DeleteChars(beforeRun->mStartNode, beforeRun->mStartOffset, GetAsDOMNode(mNode), mOffset,
|
res = DeleteChars(GetAsDOMNode(beforeRun->mStartNode), beforeRun->mStartOffset, GetAsDOMNode(mNode), mOffset,
|
||||||
eOutsideUserSelectAll);
|
eOutsideUserSelectAll);
|
||||||
NS_ENSURE_SUCCESS(res, res);
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
} else if (beforeRun && beforeRun->mType == WSType::normalWS && !mPRE) {
|
} else if (beforeRun && beforeRun->mType == WSType::normalWS && !mPRE) {
|
||||||
@ -1758,7 +1758,7 @@ nsWSRunObject::FindRun(nsIDOMNode *aNode, int32_t aOffset, WSFragment **outRun,
|
|||||||
WSFragment *run = mStartRun;
|
WSFragment *run = mStartRun;
|
||||||
while (run)
|
while (run)
|
||||||
{
|
{
|
||||||
int16_t comp = nsContentUtils::ComparePoints(aNode, aOffset, run->mStartNode,
|
int16_t comp = nsContentUtils::ComparePoints(aNode, aOffset, GetAsDOMNode(run->mStartNode),
|
||||||
run->mStartOffset);
|
run->mStartOffset);
|
||||||
if (comp <= 0)
|
if (comp <= 0)
|
||||||
{
|
{
|
||||||
@ -1773,7 +1773,7 @@ nsWSRunObject::FindRun(nsIDOMNode *aNode, int32_t aOffset, WSFragment **outRun,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
comp = nsContentUtils::ComparePoints(aNode, aOffset,
|
comp = nsContentUtils::ComparePoints(aNode, aOffset,
|
||||||
run->mEndNode, run->mEndOffset);
|
GetAsDOMNode(run->mEndNode), run->mEndOffset);
|
||||||
if (comp < 0)
|
if (comp < 0)
|
||||||
{
|
{
|
||||||
*outRun = run;
|
*outRun = run;
|
||||||
@ -1945,7 +1945,7 @@ nsWSRunObject::CheckTrailingNBSPOfRun(WSFragment *aRun)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// first check for trailing nbsp
|
// first check for trailing nbsp
|
||||||
WSPoint thePoint = GetCharBefore(aRun->mEndNode, aRun->mEndOffset);
|
WSPoint thePoint = GetCharBefore(GetAsDOMNode(aRun->mEndNode), aRun->mEndOffset);
|
||||||
if (thePoint.mTextNode && thePoint.mChar == nbsp) {
|
if (thePoint.mTextNode && thePoint.mChar == nbsp) {
|
||||||
// now check that what is to the left of it is compatible with replacing nbsp with space
|
// now check that what is to the left of it is compatible with replacing nbsp with space
|
||||||
WSPoint prevPoint = GetCharBefore(thePoint);
|
WSPoint prevPoint = GetCharBefore(thePoint);
|
||||||
@ -1990,11 +1990,11 @@ nsWSRunObject::CheckTrailingNBSPOfRun(WSFragment *aRun)
|
|||||||
// soft wrapped lines, and lets the user see 2 spaces when they type 2 spaces.
|
// soft wrapped lines, and lets the user see 2 spaces when they type 2 spaces.
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMNode> brNode;
|
nsCOMPtr<nsIDOMNode> brNode;
|
||||||
res = mHTMLEditor->CreateBR(aRun->mEndNode, aRun->mEndOffset, address_of(brNode));
|
res = mHTMLEditor->CreateBR(GetAsDOMNode(aRun->mEndNode), aRun->mEndOffset, address_of(brNode));
|
||||||
NS_ENSURE_SUCCESS(res, res);
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
|
|
||||||
// refresh thePoint, prevPoint
|
// refresh thePoint, prevPoint
|
||||||
thePoint = GetCharBefore(aRun->mEndNode, aRun->mEndOffset);
|
thePoint = GetCharBefore(GetAsDOMNode(aRun->mEndNode), aRun->mEndOffset);
|
||||||
prevPoint = GetCharBefore(thePoint);
|
prevPoint = GetCharBefore(thePoint);
|
||||||
rightCheck = true;
|
rightCheck = true;
|
||||||
}
|
}
|
||||||
@ -2153,7 +2153,7 @@ nsWSRunObject::Scrub()
|
|||||||
while (run)
|
while (run)
|
||||||
{
|
{
|
||||||
if (run->mType & (WSType::leadingWS | WSType::trailingWS)) {
|
if (run->mType & (WSType::leadingWS | WSType::trailingWS)) {
|
||||||
nsresult res = DeleteChars(run->mStartNode, run->mStartOffset, run->mEndNode, run->mEndOffset);
|
nsresult res = DeleteChars(GetAsDOMNode(run->mStartNode), run->mStartOffset, GetAsDOMNode(run->mEndNode), run->mEndOffset);
|
||||||
NS_ENSURE_SUCCESS(res, res);
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
}
|
}
|
||||||
run = run->mRight;
|
run = run->mRight;
|
||||||
|
@ -266,10 +266,10 @@ class MOZ_STACK_CLASS nsWSRunObject
|
|||||||
// still span multiple nodes.
|
// still span multiple nodes.
|
||||||
struct WSFragment
|
struct WSFragment
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIDOMNode> mStartNode; // node where ws run starts
|
nsCOMPtr<nsINode> mStartNode; // node where ws run starts
|
||||||
nsCOMPtr<nsIDOMNode> mEndNode; // node where ws run ends
|
nsCOMPtr<nsINode> mEndNode; // node where ws run ends
|
||||||
int32_t mStartOffset; // offset where ws run starts
|
int32_t mStartOffset; // offset where ws run starts
|
||||||
int32_t mEndOffset; // offset where ws run ends
|
int32_t mEndOffset; // offset where ws run ends
|
||||||
// type of ws, and what is to left and right of it
|
// type of ws, and what is to left and right of it
|
||||||
WSType mType, mLeftType, mRightType;
|
WSType mType, mLeftType, mRightType;
|
||||||
// other ws runs to left or right. may be null.
|
// other ws runs to left or right. may be null.
|
||||||
|
Loading…
Reference in New Issue
Block a user