Commit 382e03ce authored by Emilio Cobos Álvarez's avatar Emilio Cobos Álvarez
Browse files

Bug 1769869 - Fix nsVideoFrame::ReflowFinished. r=jfkthame

ReflowFinished can happen with scripts allowed, so make sure not to
synchronously fire events, as they can fire content microtasks which
could destroy the frame.

Differential Revision: https://phabricator.services.mozilla.com/D146668
parent 931f35fa
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -197,10 +197,12 @@ bool nsVideoFrame::ReflowFinished() {
    return Some(f->GetSize());
  };

  AutoTArray<nsCOMPtr<nsIRunnable>, 2> events;

  if (auto size = GetSize(mCaptionDiv)) {
    if (*size != mCaptionTrackedSize) {
      mCaptionTrackedSize = *size;
      nsContentUtils::AddScriptRunner(
      events.AppendElement(
          new DispatchResizeEvent(mCaptionDiv, u"resizecaption"_ns));
    }
  }
@@ -208,10 +210,13 @@ bool nsVideoFrame::ReflowFinished() {
  if (auto size = GetSize(controls)) {
    if (*size != mControlsTrackedSize) {
      mControlsTrackedSize = *size;
      nsContentUtils::AddScriptRunner(
      events.AppendElement(
          new DispatchResizeEvent(controls, u"resizevideocontrols"_ns));
    }
  }
  for (auto& event : events) {
    nsContentUtils::AddScriptRunner(event.forget());
  }
  return false;
}