Changeset 285413 in webkit


Ignore:
Timestamp:
Nov 8, 2021 10:37:35 AM (8 months ago)
Author:
Chris Dumez
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:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r285410 r285413  
     12021-11-08  Chris Dumez  <cdumez@apple.com>
     2
     3        Stop using a timer to dispatch the source element's error event asynchronously
     4        https://bugs.webkit.org/show_bug.cgi?id=232817
     5
     6        Reviewed by Youenn Fablet.
     7
     8        Stop using a timer to dispatch the source element's error event asynchronously and use
     9        the HTML5 event loop instead.
     10
     11        * html/HTMLSourceElement.cpp:
     12        (WebCore::HTMLSourceElement::HTMLSourceElement):
     13        (WebCore::HTMLSourceElement::scheduleErrorEvent):
     14        (WebCore::HTMLSourceElement::cancelPendingErrorEvent):
     15        (WebCore::HTMLSourceElement::errorEventTimerFired): Deleted.
     16        (WebCore::HTMLSourceElement::suspend): Deleted.
     17        (WebCore::HTMLSourceElement::resume): Deleted.
     18        * html/HTMLSourceElement.h:
     19
    1202021-11-08  Wenson Hsieh  <wenson_hsieh@apple.com>
    221
  • trunk/Source/WebCore/html/HTMLSourceElement.cpp

    r283851 r285413  
    5555    : HTMLElement(tagName, document)
    5656    , ActiveDOMObject(document)
    57     , m_errorEventTimer(*this, &HTMLSourceElement::errorEventTimerFired)
    5857{
    5958    LOG(Media, "HTMLSourceElement::HTMLSourceElement - %p", this);
     
    126125{
    127126    LOG(Media, "HTMLSourceElement::scheduleErrorEvent - %p", this);
    128     if (m_errorEventTimer.isActive())
     127    if (m_errorEventCancellationGroup.hasPendingTask())
    129128        return;
    130129
    131     m_errorEventTimer.startOneShot(0_s);
     130    queueCancellableTaskToDispatchEvent(*this, TaskSource::MediaElement, m_errorEventCancellationGroup, Event::create(eventNames().errorEvent, Event::CanBubble::No, Event::IsCancelable::Yes));
    132131}
    133132
     
    135134{
    136135    LOG(Media, "HTMLSourceElement::cancelPendingErrorEvent - %p", this);
    137     m_errorEventTimer.stop();
    138 }
    139 
    140 void HTMLSourceElement::errorEventTimerFired()
    141 {
    142     LOG(Media, "HTMLSourceElement::errorEventTimerFired - %p", this);
    143     dispatchEvent(Event::create(eventNames().errorEvent, Event::CanBubble::No, Event::IsCancelable::Yes));
     136    m_errorEventCancellationGroup.cancel();
    144137}
    145138
     
    152145{
    153146    return "HTMLSourceElement";
    154 }
    155 
    156 void HTMLSourceElement::suspend(ReasonForSuspension reason)
    157 {
    158     // FIXME: Shouldn't this also stop the timer for PageWillBeSuspended?
    159     if (reason == ReasonForSuspension::BackForwardCache) {
    160         m_shouldRescheduleErrorEventOnResume = m_errorEventTimer.isActive();
    161         m_errorEventTimer.stop();
    162     }
    163 }
    164 
    165 void HTMLSourceElement::resume()
    166 {
    167     if (m_shouldRescheduleErrorEventOnResume) {
    168         m_errorEventTimer.startOneShot(0_s);
    169         m_shouldRescheduleErrorEventOnResume = false;
    170     }
    171147}
    172148
  • trunk/Source/WebCore/html/HTMLSourceElement.h

    r284078 r285413  
    5454    // ActiveDOMObject.
    5555    const char* activeDOMObjectName() const final;
    56     void suspend(ReasonForSuspension) final;
    57     void resume() final;
    5856    void stop() final;
    5957
     
    6260    void attributeChanged(const QualifiedName&, const AtomString& oldValue, const AtomString& newValue, AttributeModificationReason) final;
    6361
    64     void errorEventTimerFired();
    65 
    66     Timer m_errorEventTimer;
    67     bool m_shouldRescheduleErrorEventOnResume { false };
     62    TaskCancellationGroup m_errorEventCancellationGroup;
    6863    bool m_shouldCallSourcesChanged { false };
    6964    mutable std::optional<RefPtr<const MediaQuerySet>> m_cachedParsedMediaAttribute;
Note: See TracChangeset for help on using the changeset viewer.