Bug 1342197 part 4. Move GetSelectionRange from nsTextControlFrame to the editor state. r=ehsan
At this point, all this method does is ensure editor initialization and then ask the editor state for various information. Let's cut out the middleman. MozReview-Commit-ID: p491umScJO
This commit is contained in:
@@ -840,17 +840,24 @@ HTMLTextAreaElement::SetSelectionEnd(const Nullable<uint32_t>& aSelectionEnd,
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_IMETHODIMP
|
||||
HTMLTextAreaElement::GetSelectionRange(int32_t* aSelectionStart,
|
||||
int32_t* aSelectionEnd)
|
||||
{
|
||||
nsIFormControlFrame* formControlFrame = GetFormControlFrame(true);
|
||||
nsITextControlFrame* textControlFrame = do_QueryFrame(formControlFrame);
|
||||
if (textControlFrame) {
|
||||
return textControlFrame->GetSelectionRange(aSelectionStart, aSelectionEnd);
|
||||
// Flush frames, because our editor state will want to work with the frame.
|
||||
if (IsInComposedDoc()) {
|
||||
GetComposedDoc()->FlushPendingNotifications(FlushType::Frames);
|
||||
}
|
||||
if (!GetPrimaryFrame()) {
|
||||
// Can we return a selection range anyway here, now that it lives on our
|
||||
// state? In fact, could we make this behave more like
|
||||
// GetSelectionDirection, in the sense of working even when we have no
|
||||
// frame, by just delegating entirely to mState? And then, do we really
|
||||
// need the flush?
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
return mState.GetSelectionRange(aSelectionStart, aSelectionEnd);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -880,22 +887,21 @@ HTMLTextAreaElement::GetSelectionDirection(nsAString& aDirection, ErrorResult& a
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsIFormControlFrame* formControlFrame = GetFormControlFrame(true);
|
||||
nsITextControlFrame* textControlFrame = do_QueryFrame(formControlFrame);
|
||||
if (textControlFrame) {
|
||||
if (formControlFrame) {
|
||||
nsITextControlFrame::SelectionDirection dir;
|
||||
rv = textControlFrame->GetSelectionRange(nullptr, nullptr, &dir);
|
||||
rv = mState.GetSelectionDirection(&dir);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
DirectionToName(dir, aDirection);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
if (mState.IsSelectionCached()) {
|
||||
DirectionToName(mState.GetSelectionProperties().GetDirection(), aDirection);
|
||||
return;
|
||||
}
|
||||
aError.Throw(rv);
|
||||
if (mState.IsSelectionCached()) {
|
||||
DirectionToName(mState.GetSelectionProperties().GetDirection(), aDirection);
|
||||
return;
|
||||
}
|
||||
|
||||
aError.Throw(rv);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
||||
Reference in New Issue
Block a user