зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1343037 part 1. Get rid of nsIDOMHTMLInputElement's selectionStart accessors. r=ehsan
MozReview-Commit-ID: IyFv8NRuZIO
This commit is contained in:
Родитель
259065f253
Коммит
bd425019e3
|
@ -6434,34 +6434,19 @@ HTMLInputElement::GetSelectionStart(ErrorResult& aRv)
|
|||
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;
|
||||
nsresult rv = GetSelectionRange(&selStart, &selEnd);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
nsTextEditorState* state = GetEditorState();
|
||||
if (state && state->IsSelectionCached()) {
|
||||
*aSelectionStart = state->GetSelectionProperties().GetStart();
|
||||
return NS_OK;
|
||||
return Nullable<int32_t>(state->GetSelectionProperties().GetStart());
|
||||
}
|
||||
return rv;
|
||||
aRv.Throw(rv);
|
||||
return Nullable<int32_t>();
|
||||
}
|
||||
|
||||
*aSelectionStart = selStart;
|
||||
return NS_OK;
|
||||
return Nullable<int32_t>(selStart);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -6504,15 +6489,6 @@ HTMLInputElement::SetSelectionStart(const Nullable<int32_t>& aSelectionStart,
|
|||
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>
|
||||
HTMLInputElement::GetSelectionEnd(ErrorResult& aRv)
|
||||
{
|
||||
|
|
|
@ -84,7 +84,6 @@ interface nsIDOMHTMLInputElement : nsISupports
|
|||
void setCustomValidity(in DOMString error);
|
||||
|
||||
void select();
|
||||
attribute long selectionStart;
|
||||
attribute long selectionEnd;
|
||||
void setSelectionRange(in long selectionStart, in long selectionEnd, [optional] in DOMString direction);
|
||||
attribute DOMString selectionDirection;
|
||||
|
|
|
@ -602,8 +602,20 @@ nsFormFillController::SetTextValueWithReason(const nsAString & aTextValue,
|
|||
NS_IMETHODIMP
|
||||
nsFormFillController::GetSelectionStart(int32_t *aSelectionStart)
|
||||
{
|
||||
if (mFocusedInput)
|
||||
mFocusedInput->GetSelectionStart(aSelectionStart);
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(mFocusedInput);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче