diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp index 9ffced39beff..b6f424c6b87c 100644 --- a/dom/html/HTMLInputElement.cpp +++ b/dom/html/HTMLInputElement.cpp @@ -6434,34 +6434,19 @@ HTMLInputElement::GetSelectionStart(ErrorResult& aRv) return Nullable(); } - int32_t selStart; - nsresult rv = GetSelectionStart(&selStart); - if (NS_FAILED(rv)) { - aRv.Throw(rv); - } - - return Nullable(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(state->GetSelectionProperties().GetStart()); } - return rv; + aRv.Throw(rv); + return Nullable(); } - *aSelectionStart = selStart; - return NS_OK; + return Nullable(selStart); } void @@ -6504,15 +6489,6 @@ HTMLInputElement::SetSelectionStart(const Nullable& aSelectionStart, aRv = SetSelectionRange(start, end, direction); } -NS_IMETHODIMP -HTMLInputElement::SetSelectionStart(int32_t aSelectionStart) -{ - ErrorResult rv; - Nullable selStart(aSelectionStart); - SetSelectionStart(selStart, rv); - return rv.StealNSResult(); -} - Nullable HTMLInputElement::GetSelectionEnd(ErrorResult& aRv) { diff --git a/dom/interfaces/html/nsIDOMHTMLInputElement.idl b/dom/interfaces/html/nsIDOMHTMLInputElement.idl index 0b913571b14a..41345a27f626 100644 --- a/dom/interfaces/html/nsIDOMHTMLInputElement.idl +++ b/dom/interfaces/html/nsIDOMHTMLInputElement.idl @@ -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; diff --git a/toolkit/components/satchel/nsFormFillController.cpp b/toolkit/components/satchel/nsFormFillController.cpp index be3b2ca4934d..ced04cd6ef54 100644 --- a/toolkit/components/satchel/nsFormFillController.cpp +++ b/toolkit/components/satchel/nsFormFillController.cpp @@ -602,8 +602,20 @@ nsFormFillController::SetTextValueWithReason(const nsAString & aTextValue, NS_IMETHODIMP nsFormFillController::GetSelectionStart(int32_t *aSelectionStart) { - if (mFocusedInput) - mFocusedInput->GetSelectionStart(aSelectionStart); + nsCOMPtr content = do_QueryInterface(mFocusedInput); + if (!content) { + return NS_ERROR_UNEXPECTED; + } + ErrorResult rv; + Nullable 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; }