Bug 1343037 part 9. Simplify the setup around the editor state's GetSelectionDirection function. r=ehsan

Really, there are only two cases we need to worry about.  Either
IsSelectionCached(), and then our SelectionProperties has the data we want, or
not and then we have a non-null mSelCon which has the data we want.

MozReview-Commit-ID: AEW9D1zG6sM
This commit is contained in:
Boris Zbarsky
2017-03-09 14:44:05 -05:00
parent b90d6841a9
commit b5f0f960fd
4 changed files with 40 additions and 60 deletions

View File

@@ -807,23 +807,12 @@ DirectionToName(nsITextControlFrame::SelectionDirection dir, nsAString& aDirecti
void
HTMLTextAreaElement::GetSelectionDirection(nsAString& aDirection, ErrorResult& aError)
{
nsresult rv = NS_ERROR_FAILURE;
nsIFormControlFrame* formControlFrame = GetFormControlFrame(true);
if (formControlFrame) {
nsITextControlFrame::SelectionDirection dir;
rv = mState.GetSelectionDirection(&dir);
if (NS_SUCCEEDED(rv)) {
DirectionToName(dir, aDirection);
return;
}
}
if (mState.IsSelectionCached()) {
DirectionToName(mState.GetSelectionProperties().GetDirection(), aDirection);
nsITextControlFrame::SelectionDirection dir =
mState.GetSelectionDirection(aError);
if (aError.Failed()) {
return;
}
aError.Throw(rv);
DirectionToName(dir, aDirection);
}
void