Bug 1347820 - Label ScrollSelectionIntoViewEvent for nsSelection.
Since GetParentObject has a chance returning nullptr, we keep the original
code path as a fallback.
MozReview-Commit-ID: LCJefr1ZH6t
--- a/layout/generic/nsSelection.cpp
+++ b/layout/generic/nsSelection.cpp
@@ -6178,19 +6178,28 @@ Selection::PostScrollSelectionIntoViewEv
{
// If we've already posted an event, revoke it and place a new one at the
// end of the queue to make sure that any new pending reflow events are
// processed before we scroll. This will insure that we scroll to the
// correct place on screen.
mScrollEvent.Revoke();
RefPtr<ScrollSelectionIntoViewEvent> ev =
- new ScrollSelectionIntoViewEvent(this, aRegion, aVertical, aHorizontal,
- aFlags);
- nsresult rv = NS_DispatchToCurrentThread(ev);
+ new ScrollSelectionIntoViewEvent(this, aRegion, aVertical, aHorizontal,
+ aFlags);
+ nsresult rv;
+ nsIDocument* doc = GetParentObject();
+ if (doc) {
+ rv = doc->Dispatch("ScrollSelectionIntoViewEvent",
+ TaskCategory::Other,
+ ev.forget());
+ } else {
+ rv = NS_DispatchToCurrentThread(ev);
+ }
+
NS_ENSURE_SUCCESS(rv, rv);
mScrollEvent = ev;
return NS_OK;
}
NS_IMETHODIMP
Selection::ScrollIntoView(SelectionRegion aRegion, bool aIsSynchronous,