Bug 1447890 part 4. Remove nsISelection::GetRangeCount. r=mystor

MozReview-Commit-ID: FypNZE0oQiW
This commit is contained in:
Boris Zbarsky 2018-03-27 00:35:22 -04:00
Родитель eefd412514
Коммит 24781001eb
6 изменённых файлов: 15 добавлений и 38 удалений

Просмотреть файл

@ -2625,9 +2625,7 @@ Selection::CollapseToStartJS(ErrorResult& aRv)
void
Selection::CollapseToStart(ErrorResult& aRv)
{
int32_t cnt;
nsresult rv = GetRangeCount(&cnt);
if (NS_FAILED(rv) || cnt <= 0) {
if (RangeCount() == 0) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
@ -2674,9 +2672,8 @@ Selection::CollapseToEndJS(ErrorResult& aRv)
void
Selection::CollapseToEnd(ErrorResult& aRv)
{
int32_t cnt;
nsresult rv = GetRangeCount(&cnt);
if (NS_FAILED(rv) || cnt <= 0) {
uint32_t cnt = RangeCount();
if (cnt == 0) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
@ -2716,14 +2713,6 @@ Selection::GetIsCollapsed(bool* aIsCollapsed)
return NS_OK;
}
NS_IMETHODIMP
Selection::GetRangeCount(int32_t* aRangeCount)
{
*aRangeCount = (int32_t)RangeCount();
return NS_OK;
}
void
Selection::GetType(nsAString& aOutType) const
{

Просмотреть файл

@ -54,11 +54,6 @@ interface nsISelection : nsISupports
readonly attribute boolean isCollapsed;
[noscript,notxpcom,nostdcall] boolean collapsed();
/**
* Returns the number of ranges in the selection.
*/
readonly attribute long rangeCount;
/**
* Collapses the selection to a single point, at the specified offset
* in the given DOM node. When the selection is collapsed, and the content

Просмотреть файл

@ -16,6 +16,9 @@ interface Selection {
readonly attribute Node? focusNode;
readonly attribute unsigned long focusOffset;
readonly attribute boolean isCollapsed;
/**
* Returns the number of ranges in the selection.
*/
readonly attribute unsigned long rangeCount;
readonly attribute DOMString type;
/**

Просмотреть файл

@ -5197,11 +5197,10 @@ PresShell::RenderSelection(Selection* aSelection,
// iterate over each range and collect them into the rangeItems array.
// This is done so that the size of selection can be determined so as
// to allocate a surface area
int32_t numRanges;
aSelection->GetRangeCount(&numRanges);
uint32_t numRanges = aSelection->RangeCount();
NS_ASSERTION(numRanges > 0, "RenderSelection called with no selection");
for (int32_t r = 0; r < numRanges; r++)
for (uint32_t r = 0; r < numRanges; r++)
{
RefPtr<nsRange> range = aSelection->GetRangeAt(r);

Просмотреть файл

@ -2281,10 +2281,7 @@ printf("aTarget == %d\n", aTarget);
mDragSelectingCells, mStartSelectedCell.get());
#endif
// First check if we are extending a block selection
int32_t rangeCount;
result = mDomSelections[index]->GetRangeCount(&rangeCount);
if (NS_FAILED(result))
return result;
uint32_t rangeCount = mDomSelections[index]->RangeCount();
if (rangeCount > 0 && aMouseEvent->IsShift() &&
mAppendStartSelectedCell && mAppendStartSelectedCell != childContent)
@ -2328,7 +2325,7 @@ printf("aTarget == %d\n", aTarget);
#ifdef DEBUG_TABLE_SELECTION
printf("HandleTableSelection: Unselecting mUnselectCellOnMouseUp; rangeCount=%d\n", rangeCount);
#endif
for( int32_t i = 0; i < rangeCount; i++)
for (uint32_t i = 0; i < rangeCount; i++)
{
// Strong reference, because sometimes we want to remove
// this range, and then we might be the only owner.

Просмотреть файл

@ -800,23 +800,17 @@ nsWebBrowserFind::GetFrameSelection(nsPIDOMWindowOuter* aWindow)
focusedContent ? focusedContent->GetPrimaryFrame() : nullptr;
nsCOMPtr<nsISelectionController> selCon;
nsCOMPtr<nsISelection> sel;
RefPtr<Selection> sel;
if (frame) {
frame->GetSelectionController(presContext, getter_AddRefs(selCon));
selCon->GetSelection(nsISelectionController::SELECTION_NORMAL,
getter_AddRefs(sel));
if (sel) {
int32_t count = -1;
sel->GetRangeCount(&count);
if (count > 0) {
return sel.forget();
}
sel = selCon->GetDOMSelection(nsISelectionController::SELECTION_NORMAL);
if (sel && sel->RangeCount() > 0) {
return sel.forget();
}
}
selCon = do_QueryInterface(presShell);
selCon->GetSelection(nsISelectionController::SELECTION_NORMAL,
getter_AddRefs(sel));
sel = selCon->GetDOMSelection(nsISelectionController::SELECTION_NORMAL);
return sel.forget();
}