Bug 1129078 - part 1, Remove the chunk that bug 739396 added to Selection::Extend. r=smaug

This commit is contained in:
Mats Palmgren 2015-02-21 04:27:59 +00:00
parent f4a34c2cf5
commit 00aef14813

View File

@ -5001,48 +5001,6 @@ Selection::Extend(nsINode& aParentNode, uint32_t aOffset, ErrorResult& aRv)
}
nsDirection dir = GetDirection();
// If aParentNode is inside a range in a multi-range selection we need
// to remove the ranges that follows in the selection direction and
// make that range the mAnchorFocusRange.
if (mRanges.Length() > 1) {
for (size_t i = 0; i < mRanges.Length(); ++i) {
nsRange* range = mRanges[i].mRange;
bool disconnected1 = false;
bool disconnected2 = false;
const bool isBeforeStart =
nsContentUtils::ComparePoints(range->GetStartParent(),
range->StartOffset(),
&aParentNode, aOffset,
&disconnected1) > 0;
const bool isAfterEnd =
nsContentUtils::ComparePoints(range->GetEndParent(),
range->EndOffset(),
&aParentNode, aOffset,
&disconnected2) < 0;
if (!isBeforeStart && !isAfterEnd && !disconnected1 && !disconnected2) {
// aParentNode/aOffset is inside 'range'.
mAnchorFocusRange = range;
if (dir == eDirNext) {
for (size_t j = i + 1; j < mRanges.Length(); ++j) {
nsRange* r = mRanges[j].mRange;
r->SetInSelection(false);
selectFrames(presContext, r, false);
}
mRanges.TruncateLength(i + 1);
} else {
for (size_t j = 0; j < i; ++j) {
nsRange* r = mRanges[j].mRange;
r->SetInSelection(false);
selectFrames(presContext, r, false);
}
mRanges.RemoveElementsAt(0, i);
}
break;
}
}
}
nsINode* anchorNode = GetAnchorNode();
nsINode* focusNode = GetFocusNode();
uint32_t anchorOffset = AnchorOffset();