Bug 1343037 part 1. Get rid of nsIDOMHTMLInputElement's selectionStart accessors. r=ehsan

MozReview-Commit-ID: IyFv8NRuZIO
This commit is contained in:
Boris Zbarsky 2017-03-09 14:44:03 -05:00
Родитель 259065f253
Коммит bd425019e3
3 изменённых файлов: 18 добавлений и 31 удалений

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

@ -6434,34 +6434,19 @@ HTMLInputElement::GetSelectionStart(ErrorResult& aRv)
return Nullable<int32_t>(); return Nullable<int32_t>();
} }
int32_t selStart;
nsresult rv = GetSelectionStart(&selStart);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
}
return Nullable<int32_t>(selStart);
}
NS_IMETHODIMP
HTMLInputElement::GetSelectionStart(int32_t* aSelectionStart)
{
NS_ENSURE_ARG_POINTER(aSelectionStart);
int32_t selEnd, selStart; int32_t selEnd, selStart;
nsresult rv = GetSelectionRange(&selStart, &selEnd); nsresult rv = GetSelectionRange(&selStart, &selEnd);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
nsTextEditorState* state = GetEditorState(); nsTextEditorState* state = GetEditorState();
if (state && state->IsSelectionCached()) { if (state && state->IsSelectionCached()) {
*aSelectionStart = state->GetSelectionProperties().GetStart(); return Nullable<int32_t>(state->GetSelectionProperties().GetStart());
return NS_OK;
} }
return rv; aRv.Throw(rv);
return Nullable<int32_t>();
} }
*aSelectionStart = selStart; return Nullable<int32_t>(selStart);
return NS_OK;
} }
void void
@ -6504,15 +6489,6 @@ HTMLInputElement::SetSelectionStart(const Nullable<int32_t>& aSelectionStart,
aRv = SetSelectionRange(start, end, direction); aRv = SetSelectionRange(start, end, direction);
} }
NS_IMETHODIMP
HTMLInputElement::SetSelectionStart(int32_t aSelectionStart)
{
ErrorResult rv;
Nullable<int32_t> selStart(aSelectionStart);
SetSelectionStart(selStart, rv);
return rv.StealNSResult();
}
Nullable<int32_t> Nullable<int32_t>
HTMLInputElement::GetSelectionEnd(ErrorResult& aRv) HTMLInputElement::GetSelectionEnd(ErrorResult& aRv)
{ {

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

@ -84,7 +84,6 @@ interface nsIDOMHTMLInputElement : nsISupports
void setCustomValidity(in DOMString error); void setCustomValidity(in DOMString error);
void select(); void select();
attribute long selectionStart;
attribute long selectionEnd; attribute long selectionEnd;
void setSelectionRange(in long selectionStart, in long selectionEnd, [optional] in DOMString direction); void setSelectionRange(in long selectionStart, in long selectionEnd, [optional] in DOMString direction);
attribute DOMString selectionDirection; attribute DOMString selectionDirection;

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

@ -602,8 +602,20 @@ nsFormFillController::SetTextValueWithReason(const nsAString & aTextValue,
NS_IMETHODIMP NS_IMETHODIMP
nsFormFillController::GetSelectionStart(int32_t *aSelectionStart) nsFormFillController::GetSelectionStart(int32_t *aSelectionStart)
{ {
if (mFocusedInput) nsCOMPtr<nsIContent> content = do_QueryInterface(mFocusedInput);
mFocusedInput->GetSelectionStart(aSelectionStart); if (!content) {
return NS_ERROR_UNEXPECTED;
}
ErrorResult rv;
Nullable<int32_t> start =
HTMLInputElement::FromContent(content)->GetSelectionStart(rv);
if (NS_FAILED(rv)) {
return rv.StealNSResult();
}
if (start.IsNull()) {
return NS_ERROR_UNEXPECTED;
}
*aSelectionStart = start.Value();
return NS_OK; return NS_OK;
} }