зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1343037 part 2. Get rid of nsIDOMHTMLInputElement's selectionEnd accessors. r=ehsan
MozReview-Commit-ID: L2Ozu7Vvort
This commit is contained in:
Родитель
bd425019e3
Коммит
f57f010e10
|
@ -6496,34 +6496,19 @@ HTMLInputElement::GetSelectionEnd(ErrorResult& aRv)
|
|||
return Nullable<int32_t>();
|
||||
}
|
||||
|
||||
int32_t selEnd;
|
||||
nsresult rv = GetSelectionEnd(&selEnd);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
}
|
||||
|
||||
return Nullable<int32_t>(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<int32_t>(state->GetSelectionProperties().GetEnd());
|
||||
}
|
||||
return rv;
|
||||
aRv.Throw(rv);
|
||||
return Nullable<int32_t>();
|
||||
}
|
||||
|
||||
*aSelectionEnd = selEnd;
|
||||
return NS_OK;
|
||||
return Nullable<int32_t>(selEnd);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -6566,15 +6551,6 @@ HTMLInputElement::SetSelectionEnd(const Nullable<int32_t>& aSelectionEnd,
|
|||
aRv = SetSelectionRange(start, end, direction);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLInputElement::SetSelectionEnd(int32_t aSelectionEnd)
|
||||
{
|
||||
ErrorResult rv;
|
||||
Nullable<int32_t> selEnd(aSelectionEnd);
|
||||
SetSelectionEnd(selEnd, rv);
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLInputElement::GetFiles(nsIDOMFileList** aFileList)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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<int32_t> 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<nsIContent> content = do_QueryInterface(mFocusedInput);
|
||||
if (!content) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
ErrorResult rv;
|
||||
Nullable<int32_t> 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;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче