Bug 1343037 part 12. Implement nsTextEditorState::SetSelectionStart. r=ehsan
This introduces three behavior changes:
1) Before this change, in cached mode, we did not enforce the "start <= end"
invariant.
2) Before this change, in cached mode, we did not fire "select" events on
selectionStart changes.
3) Changes the IDL type of HTMLInputElement's selectionStart attribute to
"unsigned long" to match the spec and HTMLTextareaElement.
MozReview-Commit-ID: JM9XXMMPUHM
This commit is contained in:
@@ -710,34 +710,7 @@ void
|
||||
HTMLTextAreaElement::SetSelectionStart(const Nullable<uint32_t>& aSelectionStart,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
int32_t selStart = 0;
|
||||
if (!aSelectionStart.IsNull()) {
|
||||
selStart = aSelectionStart.Value();
|
||||
}
|
||||
|
||||
if (mState.IsSelectionCached()) {
|
||||
mState.GetSelectionProperties().SetStart(selStart);
|
||||
return;
|
||||
}
|
||||
|
||||
nsAutoString direction;
|
||||
GetSelectionDirection(direction, aError);
|
||||
if (aError.Failed()) {
|
||||
return;
|
||||
}
|
||||
int32_t start, end;
|
||||
GetSelectionRange(&start, &end, aError);
|
||||
if (aError.Failed()) {
|
||||
return;
|
||||
}
|
||||
start = selStart;
|
||||
if (end < start) {
|
||||
end = start;
|
||||
}
|
||||
nsresult rv = SetSelectionRange(start, end, direction);
|
||||
if (NS_FAILED(rv)) {
|
||||
aError.Throw(rv);
|
||||
}
|
||||
mState.SetSelectionStart(aSelectionStart, aError);
|
||||
}
|
||||
|
||||
Nullable<uint32_t>
|
||||
|
||||
Reference in New Issue
Block a user