Bug 1343037 part 14. Implement nsTextEditorState::SetSelectionDirection. r=ehsan

This introduces two behavior changes:

1)  In cached mode, we used to treat unknown selection directions as "none".
    Now we treat it like "forward", consistently with the "have an editor" mode.
2)  Before this change, in cached mode, we did not fire "select" events on
    selectionDirection changes.

MozReview-Commit-ID: 4nBCAm3mAiz
This commit is contained in:
Boris Zbarsky
2017-03-09 14:44:06 -05:00
parent 5751a40e69
commit 8c2206f672
4 changed files with 41 additions and 37 deletions

View File

@@ -6561,22 +6561,8 @@ HTMLInputElement::SetSelectionDirection(const nsAString& aDirection, ErrorResult
}
nsTextEditorState* state = GetEditorState();
if (state && state->IsSelectionCached()) {
nsITextControlFrame::SelectionDirection dir = nsITextControlFrame::eNone;
if (aDirection.EqualsLiteral("forward")) {
dir = nsITextControlFrame::eForward;
} else if (aDirection.EqualsLiteral("backward")) {
dir = nsITextControlFrame::eBackward;
}
state->GetSelectionProperties().SetDirection(dir);
return;
}
int32_t start, end;
GetSelectionRange(&start, &end, aRv);
if (!aRv.Failed()) {
aRv = SetSelectionRange(start, end, aDirection);
}
MOZ_ASSERT(state, "SupportsTextSelection came back true!");
state->SetSelectionDirection(aDirection, aRv);
}
NS_IMETHODIMP