void DOMWindowEventQueue::dispatchEvent(Event* event) { EventTarget* eventTarget = event->target(); InspectorInstrumentation::AsyncTask asyncTask( eventTarget->getExecutionContext(), event); if (LocalDOMWindow* window = eventTarget->toLocalDOMWindow()) window->dispatchEvent(event, nullptr); else eventTarget->dispatchEvent(event); }
ScriptPromise HTMLVideoElement::createImageBitmap(ScriptState* scriptState, EventTarget& eventTarget, int sx, int sy, int sw, int sh, const ImageBitmapOptions& options, ExceptionState& exceptionState) { ASSERT(eventTarget.toLocalDOMWindow()); if (getNetworkState() == HTMLMediaElement::NETWORK_EMPTY) { exceptionState.throwDOMException(InvalidStateError, "The provided element has not retrieved data."); return ScriptPromise(); } if (getReadyState() <= HTMLMediaElement::HAVE_METADATA) { exceptionState.throwDOMException(InvalidStateError, "The provided element's player has no current data."); return ScriptPromise(); } if (!sw || !sh) { exceptionState.throwDOMException(IndexSizeError, String::format("The source %s provided is 0.", sw ? "height" : "width")); return ScriptPromise(); } return ImageBitmapSource::fulfillImageBitmap(scriptState, ImageBitmap::create(this, IntRect(sx, sy, sw, sh), eventTarget.toLocalDOMWindow()->document(), options)); }