Title: [285413] trunk/Source/WebCore
Revision
285413
Author
[email protected]
Date
2021-11-08 10:37:35 -0800 (Mon, 08 Nov 2021)

Log Message

Stop using a timer to dispatch the source element's error event asynchronously
https://bugs.webkit.org/show_bug.cgi?id=232817

Reviewed by Youenn Fablet.

Stop using a timer to dispatch the source element's error event asynchronously and use
the HTML5 event loop instead.

* html/HTMLSourceElement.cpp:
(WebCore::HTMLSourceElement::HTMLSourceElement):
(WebCore::HTMLSourceElement::scheduleErrorEvent):
(WebCore::HTMLSourceElement::cancelPendingErrorEvent):
(WebCore::HTMLSourceElement::errorEventTimerFired): Deleted.
(WebCore::HTMLSourceElement::suspend): Deleted.
(WebCore::HTMLSourceElement::resume): Deleted.
* html/HTMLSourceElement.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (285412 => 285413)


--- trunk/Source/WebCore/ChangeLog	2021-11-08 18:36:12 UTC (rev 285412)
+++ trunk/Source/WebCore/ChangeLog	2021-11-08 18:37:35 UTC (rev 285413)
@@ -1,3 +1,22 @@
+2021-11-08  Chris Dumez  <[email protected]>
+
+        Stop using a timer to dispatch the source element's error event asynchronously
+        https://bugs.webkit.org/show_bug.cgi?id=232817
+
+        Reviewed by Youenn Fablet.
+
+        Stop using a timer to dispatch the source element's error event asynchronously and use
+        the HTML5 event loop instead.
+
+        * html/HTMLSourceElement.cpp:
+        (WebCore::HTMLSourceElement::HTMLSourceElement):
+        (WebCore::HTMLSourceElement::scheduleErrorEvent):
+        (WebCore::HTMLSourceElement::cancelPendingErrorEvent):
+        (WebCore::HTMLSourceElement::errorEventTimerFired): Deleted.
+        (WebCore::HTMLSourceElement::suspend): Deleted.
+        (WebCore::HTMLSourceElement::resume): Deleted.
+        * html/HTMLSourceElement.h:
+
 2021-11-08  Wenson Hsieh  <[email protected]>
 
         Enabling "media source inline painting" by default should work when using GPU Process for media

Modified: trunk/Source/WebCore/html/HTMLSourceElement.cpp (285412 => 285413)


--- trunk/Source/WebCore/html/HTMLSourceElement.cpp	2021-11-08 18:36:12 UTC (rev 285412)
+++ trunk/Source/WebCore/html/HTMLSourceElement.cpp	2021-11-08 18:37:35 UTC (rev 285413)
@@ -54,7 +54,6 @@
 inline HTMLSourceElement::HTMLSourceElement(const QualifiedName& tagName, Document& document)
     : HTMLElement(tagName, document)
     , ActiveDOMObject(document)
-    , m_errorEventTimer(*this, &HTMLSourceElement::errorEventTimerFired)
 {
     LOG(Media, "HTMLSourceElement::HTMLSourceElement - %p", this);
     ASSERT(hasTagName(sourceTag));
@@ -125,24 +124,18 @@
 void HTMLSourceElement::scheduleErrorEvent()
 {
     LOG(Media, "HTMLSourceElement::scheduleErrorEvent - %p", this);
-    if (m_errorEventTimer.isActive())
+    if (m_errorEventCancellationGroup.hasPendingTask())
         return;
 
-    m_errorEventTimer.startOneShot(0_s);
+    queueCancellableTaskToDispatchEvent(*this, TaskSource::MediaElement, m_errorEventCancellationGroup, Event::create(eventNames().errorEvent, Event::CanBubble::No, Event::IsCancelable::Yes));
 }
 
 void HTMLSourceElement::cancelPendingErrorEvent()
 {
     LOG(Media, "HTMLSourceElement::cancelPendingErrorEvent - %p", this);
-    m_errorEventTimer.stop();
+    m_errorEventCancellationGroup.cancel();
 }
 
-void HTMLSourceElement::errorEventTimerFired()
-{
-    LOG(Media, "HTMLSourceElement::errorEventTimerFired - %p", this);
-    dispatchEvent(Event::create(eventNames().errorEvent, Event::CanBubble::No, Event::IsCancelable::Yes));
-}
-
 bool HTMLSourceElement::isURLAttribute(const Attribute& attribute) const
 {
     return attribute.name() == srcAttr || HTMLElement::isURLAttribute(attribute);
@@ -153,23 +146,6 @@
     return "HTMLSourceElement";
 }
 
-void HTMLSourceElement::suspend(ReasonForSuspension reason)
-{
-    // FIXME: Shouldn't this also stop the timer for PageWillBeSuspended?
-    if (reason == ReasonForSuspension::BackForwardCache) {
-        m_shouldRescheduleErrorEventOnResume = m_errorEventTimer.isActive();
-        m_errorEventTimer.stop();
-    }
-}
-
-void HTMLSourceElement::resume()
-{
-    if (m_shouldRescheduleErrorEventOnResume) {
-        m_errorEventTimer.startOneShot(0_s);
-        m_shouldRescheduleErrorEventOnResume = false;
-    }
-}
-
 void HTMLSourceElement::stop()
 {
     cancelPendingErrorEvent();

Modified: trunk/Source/WebCore/html/HTMLSourceElement.h (285412 => 285413)


--- trunk/Source/WebCore/html/HTMLSourceElement.h	2021-11-08 18:36:12 UTC (rev 285412)
+++ trunk/Source/WebCore/html/HTMLSourceElement.h	2021-11-08 18:37:35 UTC (rev 285413)
@@ -53,8 +53,6 @@
 
     // ActiveDOMObject.
     const char* activeDOMObjectName() const final;
-    void suspend(ReasonForSuspension) final;
-    void resume() final;
     void stop() final;
 
     void parseAttribute(const QualifiedName&, const AtomString&) final;
@@ -61,10 +59,7 @@
 
     void attributeChanged(const QualifiedName&, const AtomString& oldValue, const AtomString& newValue, AttributeModificationReason) final;
 
-    void errorEventTimerFired();
-
-    Timer m_errorEventTimer;
-    bool m_shouldRescheduleErrorEventOnResume { false };
+    TaskCancellationGroup m_errorEventCancellationGroup;
     bool m_shouldCallSourcesChanged { false };
     mutable std::optional<RefPtr<const MediaQuerySet>> m_cachedParsedMediaAttribute;
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to