Bug 1368397 part 4 - Rename Selection::setAnchorFocusRange() to Selection::SetAnchorFocusRange() r?mats
MozReview-Commit-ID: BhiGhxSAUbl
--- a/layout/generic/Selection.h
+++ b/layout/generic/Selection.h
@@ -334,19 +334,23 @@ private:
private:
Selection *mSelection;
SelectionRegion mRegion;
nsIPresShell::ScrollAxis mVerticalScroll;
nsIPresShell::ScrollAxis mHorizontalScroll;
int32_t mFlags;
};
- void setAnchorFocusRange(int32_t aIndex); // pass in index into mRanges;
- // negative value clears
- // mAnchorFocusRange
+ /**
+ * Set mAnchorFocusRange to mRanges[aIndex] if aIndex is a valid index.
+ * Set mAnchorFocusRange to nullptr if aIndex is negative.
+ * Otherwise, i.e., if aIndex is positive but out of bounds of mRanges, do
+ * nothing.
+ */
+ void SetAnchorFocusRange(int32_t aIndex);
void SelectFramesForContent(nsIContent* aContent, bool aSelected);
nsresult SelectAllFramesForContent(nsIContentIterator* aInnerIter,
nsIContent *aContent,
bool aSelected);
nsresult SelectFrames(nsPresContext* aPresContext,
nsRange* aRange,
bool aSelect);
nsresult GetTableCellLocationFromRange(nsRange* aRange,
--- a/layout/generic/nsSelection.cpp
+++ b/layout/generic/nsSelection.cpp
@@ -3506,17 +3506,17 @@ Selection::Selection(nsFrameSelection* a
, mUserInitiated(false)
, mCalledByJS(false)
, mSelectionChangeBlockerCount(0)
{
}
Selection::~Selection()
{
- setAnchorFocusRange(-1);
+ SetAnchorFocusRange(-1);
uint32_t count = mRanges.Length();
for (uint32_t i = 0; i < count; ++i) {
mRanges[i].mRange->SetSelection(nullptr);
}
if (mAutoScrollTimer) {
mAutoScrollTimer->Stop();
@@ -3639,17 +3639,17 @@ Selection::GetFocusNode()
NS_IMETHODIMP
Selection::GetFocusOffset(int32_t* aFocusOffset)
{
*aFocusOffset = static_cast<int32_t>(FocusOffset());
return NS_OK;
}
void
-Selection::setAnchorFocusRange(int32_t indx)
+Selection::SetAnchorFocusRange(int32_t indx)
{
if (indx >= (int32_t)mRanges.Length())
return;
if (indx < 0) //release all
{
mAnchorFocusRange = nullptr;
}
else{
@@ -4098,17 +4098,17 @@ Selection::RemoveCollapsedRanges()
}
}
return NS_OK;
}
nsresult
Selection::Clear(nsPresContext* aPresContext)
{
- setAnchorFocusRange(-1);
+ SetAnchorFocusRange(-1);
for (uint32_t i = 0; i < mRanges.Length(); ++i) {
mRanges[i].mRange->SetSelection(nullptr);
SelectFrames(aPresContext, mRanges[i].mRange, false);
}
mRanges.Clear();
// Reset direction so for more dependable table selection range handling
@@ -5063,17 +5063,17 @@ Selection::AddRangeInternal(nsRange& aRa
return;
}
}
if (rangeIndex < 0) {
return;
}
- setAnchorFocusRange(rangeIndex);
+ SetAnchorFocusRange(rangeIndex);
// Make sure the caret appears on the next line, if at a newline
if (mSelectionType == SelectionType::eNormal) {
SetInterlinePosition(true);
}
RefPtr<nsPresContext> presContext = GetPresContext();
SelectFrames(presContext, &aRange, true);
@@ -5160,17 +5160,17 @@ Selection::RemoveRange(nsRange& aRange,
}
for (uint32_t i = 0; i < affectedRanges.Length(); i++) {
SelectFrames(presContext, affectedRanges[i], true);
}
int32_t cnt = mRanges.Length();
if (&aRange == mAnchorFocusRange) {
// Reset anchor to LAST range or clear it if there are no ranges.
- setAnchorFocusRange(cnt - 1);
+ SetAnchorFocusRange(cnt - 1);
// When the selection is user-created it makes sense to scroll the range
// into view. The spell-check selection, however, is created and destroyed
// in the background. We don't want to scroll in this case or the view
// might appear to be moving randomly (bug 337871).
if (mSelectionType != SelectionType::eSpellCheck && cnt > 0) {
ScrollIntoView(nsISelectionController::SELECTION_FOCUS_REGION);
}
@@ -5298,17 +5298,17 @@ Selection::Collapse(nsINode& aParentNode
#endif
int32_t rangeIndex = -1;
result = AddItem(range, &rangeIndex);
if (NS_FAILED(result)) {
aRv.Throw(result);
return;
}
- setAnchorFocusRange(0);
+ SetAnchorFocusRange(0);
SelectFrames(presContext, range, true);
// Be aware, this instance may be destroyed after this call.
// XXX Why doesn't this call Selection::NotifySelectionListener() directly?
result = frameSelection->NotifySelectionListeners(GetType());
if (NS_FAILED(result)) {
aRv.Throw(result);
}
@@ -5495,17 +5495,17 @@ Selection::SetAnchorFocusToRange(nsRange
nsresult res = RemoveItem(mAnchorFocusRange);
if (NS_FAILED(res))
return res;
int32_t aOutIndex = -1;
res = AddItem(aRange, &aOutIndex, !collapsed);
if (NS_FAILED(res))
return res;
- setAnchorFocusRange(aOutIndex);
+ SetAnchorFocusRange(aOutIndex);
return NS_OK;
}
void
Selection::ReplaceAnchorFocusRange(nsRange* aRange)
{
NS_ENSURE_TRUE_VOID(mAnchorFocusRange);
@@ -5530,21 +5530,21 @@ Selection::AdjustAnchorFocusForMultiRang
}
nsRange* firstRange = GetRangeAt(0);
nsRange* lastRange = GetRangeAt(RangeCount() - 1);
if (mDirection == eDirPrevious) {
firstRange->SetIsGenerated(false);
lastRange->SetIsGenerated(true);
- setAnchorFocusRange(0);
+ SetAnchorFocusRange(0);
} else { // aDir == eDirNext
firstRange->SetIsGenerated(true);
lastRange->SetIsGenerated(false);
- setAnchorFocusRange(RangeCount() - 1);
+ SetAnchorFocusRange(RangeCount() - 1);
}
}
/*
Notes which might come in handy for extend:
We can tell the direction of the selection by asking for the anchors selection
if the begin is less than the end then we know the selection is to the "right".