diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp index b6f424c6b87c..42a5a973462d 100644 --- a/dom/html/HTMLInputElement.cpp +++ b/dom/html/HTMLInputElement.cpp @@ -6496,34 +6496,19 @@ HTMLInputElement::GetSelectionEnd(ErrorResult& aRv) return Nullable(); } - int32_t selEnd; - nsresult rv = GetSelectionEnd(&selEnd); - if (NS_FAILED(rv)) { - aRv.Throw(rv); - } - - return Nullable(selEnd); -} - -NS_IMETHODIMP -HTMLInputElement::GetSelectionEnd(int32_t* aSelectionEnd) -{ - NS_ENSURE_ARG_POINTER(aSelectionEnd); - int32_t selEnd, selStart; nsresult rv = GetSelectionRange(&selStart, &selEnd); if (NS_FAILED(rv)) { nsTextEditorState* state = GetEditorState(); if (state && state->IsSelectionCached()) { - *aSelectionEnd = state->GetSelectionProperties().GetEnd(); - return NS_OK; + return Nullable(state->GetSelectionProperties().GetEnd()); } - return rv; + aRv.Throw(rv); + return Nullable(); } - *aSelectionEnd = selEnd; - return NS_OK; + return Nullable(selEnd); } void @@ -6566,15 +6551,6 @@ HTMLInputElement::SetSelectionEnd(const Nullable& aSelectionEnd, aRv = SetSelectionRange(start, end, direction); } -NS_IMETHODIMP -HTMLInputElement::SetSelectionEnd(int32_t aSelectionEnd) -{ - ErrorResult rv; - Nullable selEnd(aSelectionEnd); - SetSelectionEnd(selEnd, rv); - return rv.StealNSResult(); -} - NS_IMETHODIMP HTMLInputElement::GetFiles(nsIDOMFileList** aFileList) { diff --git a/dom/interfaces/html/nsIDOMHTMLInputElement.idl b/dom/interfaces/html/nsIDOMHTMLInputElement.idl index 41345a27f626..9186f54b7d5d 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 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 ced04cd6ef54..13eeb86e9d81 100644 --- a/toolkit/components/satchel/nsFormFillController.cpp +++ b/toolkit/components/satchel/nsFormFillController.cpp @@ -6,6 +6,7 @@ #include "nsFormFillController.h" +#include "mozilla/ErrorResult.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/Event.h" // for nsIDOMEvent::InternalDOMEvent() #include "mozilla/dom/HTMLInputElement.h" @@ -44,6 +45,7 @@ using namespace mozilla; using namespace mozilla::dom; +using mozilla::ErrorResult; NS_IMPL_CYCLE_COLLECTION(nsFormFillController, mController, mLoginManager, mFocusedPopup, mDocShells, @@ -609,7 +611,7 @@ nsFormFillController::GetSelectionStart(int32_t *aSelectionStart) ErrorResult rv; Nullable start = HTMLInputElement::FromContent(content)->GetSelectionStart(rv); - if (NS_FAILED(rv)) { + if (rv.Failed()) { return rv.StealNSResult(); } if (start.IsNull()) { @@ -622,8 +624,20 @@ nsFormFillController::GetSelectionStart(int32_t *aSelectionStart) NS_IMETHODIMP nsFormFillController::GetSelectionEnd(int32_t *aSelectionEnd) { - if (mFocusedInput) - mFocusedInput->GetSelectionEnd(aSelectionEnd); + nsCOMPtr content = do_QueryInterface(mFocusedInput); + if (!content) { + return NS_ERROR_UNEXPECTED; + } + ErrorResult rv; + Nullable end = + HTMLInputElement::FromContent(content)->GetSelectionEnd(rv); + if (rv.Failed()) { + return rv.StealNSResult(); + } + if (end.IsNull()) { + return NS_ERROR_UNEXPECTED; + } + *aSelectionEnd = end.Value(); return NS_OK; }