⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 287803 in webkit


Ignore:
Timestamp:
Jan 7, 2022, 6:20:37 PM (5 years ago)
Author:
commit-queue@webkit.org
Message:

Make FullscreenManager::requestFullscreenForElement more robust
https://bugs.webkit.org/show_bug.cgi?id=234995

Patch by Alex Christensen <achristensen@webkit.org> on 2022-01-07
Reviewed by Darin Adler.

Source/WebCore:

I think this may fix the Windows crashes after bug 233963 lands, and it makes things more robust anyways.

  • dom/Element.cpp:

(WebCore::Element::webkitRequestFullscreen):

  • dom/FullscreenManager.cpp:

(WebCore::FullscreenManager::requestFullscreenForElement):

  • dom/FullscreenManager.h:
  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::enterFullscreen):

Source/WebKit:

  • WebProcess/FullScreen/WebFullScreenManager.cpp:

(WebKit::WebFullScreenManager::requestEnterFullScreen):

Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r287802 r287803  
     12022-01-07  Alex Christensen  <achristensen@webkit.org>
     2
     3        Make FullscreenManager::requestFullscreenForElement more robust
     4        https://bugs.webkit.org/show_bug.cgi?id=234995
     5
     6        Reviewed by Darin Adler.
     7
     8        I think this may fix the Windows crashes after bug 233963 lands, and it makes things more robust anyways.
     9
     10        * dom/Element.cpp:
     11        (WebCore::Element::webkitRequestFullscreen):
     12        * dom/FullscreenManager.cpp:
     13        (WebCore::FullscreenManager::requestFullscreenForElement):
     14        * dom/FullscreenManager.h:
     15        * html/HTMLMediaElement.cpp:
     16        (WebCore::HTMLMediaElement::enterFullscreen):
     17
    1182022-01-07  Alexey Shvayka  <ashvayka@apple.com>
    219
  • trunk/Source/WebCore/dom/Element.cpp

    r287802 r287803  
    38703870void Element::webkitRequestFullscreen()
    38713871{
    3872     document().fullscreenManager().requestFullscreenForElement(this, FullscreenManager::EnforceIFrameAllowFullscreenRequirement);
     3872    document().fullscreenManager().requestFullscreenForElement(*this, FullscreenManager::EnforceIFrameAllowFullscreenRequirement);
    38733873}
    38743874
  • trunk/Source/WebCore/dom/FullscreenManager.cpp

    r284093 r287803  
    5959FullscreenManager::~FullscreenManager() = default;
    6060
    61 void FullscreenManager::requestFullscreenForElement(Element* element, FullscreenCheckType checkType)
    62 {
    63     if (!element)
    64         element = documentElement();
    65 
    66     auto failedPreflights = [this, weakThis = WeakPtr { *this }](auto element) mutable {
     61void FullscreenManager::requestFullscreenForElement(Ref<Element>&& element, FullscreenCheckType checkType)
     62{
     63    auto failedPreflights = [this, weakThis = WeakPtr { *this }](Ref<Element>&& element) mutable {
     64        if (!weakThis)
     65            return;
    6766        m_fullscreenErrorEventTargetQueue.append(WTFMove(element));
    6867        m_document.eventLoop().queueTask(TaskSource::MediaElement, [weakThis = WTFMove(weakThis)]() mutable {
     
    103102
    104103    bool hasKeyboardAccess = true;
    105     if (!page()->chrome().client().supportsFullScreenForElement(*element, hasKeyboardAccess)) {
     104    if (!page()->chrome().client().supportsFullScreenForElement(element, hasKeyboardAccess)) {
    106105        // The new full screen API does not accept a "flags" parameter, so fall back to disallowing
    107106        // keyboard input if the chrome client refuses to allow keyboard input.
    108107        hasKeyboardAccess = false;
    109108
    110         if (!page()->chrome().client().supportsFullScreenForElement(*element, hasKeyboardAccess)) {
     109        if (!page()->chrome().client().supportsFullScreenForElement(element, hasKeyboardAccess)) {
    111110            ERROR_LOG(LOGIDENTIFIER, "page does not support fullscreen for element; failing.");
    112111            failedPreflights(WTFMove(element));
     
    115114    }
    116115
    117     m_pendingFullscreenElement = element;
    118 
    119     m_document.eventLoop().queueTask(TaskSource::MediaElement, [this, weakThis = WeakPtr { *this }, element = RefPtr { element }, checkType, hasKeyboardAccess, failedPreflights, identifier = LOGIDENTIFIER] () mutable {
     116    m_pendingFullscreenElement = RefPtr { element.ptr() };
     117
     118    m_document.eventLoop().queueTask(TaskSource::MediaElement, [this, weakThis = WeakPtr { *this }, element = WTFMove(element), checkType, hasKeyboardAccess, failedPreflights, identifier = LOGIDENTIFIER] () mutable {
    120119        if (!weakThis)
    121120            return;
     
    123122        // Don't allow fullscreen if it has been cancelled or a different fullscreen element
    124123        // has requested fullscreen.
    125         if (m_pendingFullscreenElement != element) {
     124        if (m_pendingFullscreenElement != element.ptr()) {
    126125            ERROR_LOG(identifier, "task - pending element mismatch; failing.");
    127126            failedPreflights(WTFMove(element));
     
    206205            // set to true on the document.
    207206            if (!followingDoc) {
    208                 currentDoc->fullscreenManager().pushFullscreenElementStack(*element);
     207                currentDoc->fullscreenManager().pushFullscreenElementStack(element);
    209208                addDocumentToFullscreenChangeEventQueue(*currentDoc);
    210209                continue;
     
    234233
    235234            auto page = this->page();
    236             if (!page || document().hidden() || m_pendingFullscreenElement != element || !element->isConnected()) {
     235            if (!page || document().hidden() || m_pendingFullscreenElement != element.ptr() || !element->isConnected()) {
    237236                ERROR_LOG(identifier, "task - page, document, or element mismatch; failing.");
    238                 failedPreflights(element);
     237                failedPreflights(WTFMove(element));
    239238                return;
    240239            }
    241240            INFO_LOG(identifier, "task - success");
    242             page->chrome().client().enterFullScreenForElement(*element.get());
     241            page->chrome().client().enterFullScreenForElement(element);
    243242        });
    244243
  • trunk/Source/WebCore/dom/FullscreenManager.h

    r284857 r287803  
    7070        ExemptIFrameAllowFullscreenRequirement,
    7171    };
    72     WEBCORE_EXPORT void requestFullscreenForElement(Element*, FullscreenCheckType);
     72    WEBCORE_EXPORT void requestFullscreenForElement(Ref<Element>&&, FullscreenCheckType);
    7373
    7474    WEBCORE_EXPORT bool willEnterFullscreen(Element&);
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r287604 r287803  
    63046304        m_temporarilyAllowingInlinePlaybackAfterFullscreen = false;
    63056305        m_waitingToEnterFullscreen = true;
    6306         document().fullscreenManager().requestFullscreenForElement(this, FullscreenManager::ExemptIFrameAllowFullscreenRequirement);
     6306        document().fullscreenManager().requestFullscreenForElement(*this, FullscreenManager::ExemptIFrameAllowFullscreenRequirement);
    63076307        return;
    63086308    }
  • trunk/Source/WebKit/ChangeLog

    r287794 r287803  
     12022-01-07  Alex Christensen  <achristensen@webkit.org>
     2
     3        Make FullscreenManager::requestFullscreenForElement more robust
     4        https://bugs.webkit.org/show_bug.cgi?id=234995
     5
     6        Reviewed by Darin Adler.
     7
     8        * WebProcess/FullScreen/WebFullScreenManager.cpp:
     9        (WebKit::WebFullScreenManager::requestEnterFullScreen):
     10
    1112022-01-07  Chris Lord  <clord@igalia.com>
    212
  • trunk/Source/WebKit/WebProcess/FullScreen/WebFullScreenManager.cpp

    r280500 r287803  
    243243
    244244    WebCore::UserGestureIndicator gestureIndicator(WebCore::ProcessingUserGesture);
    245     m_element->document().fullscreenManager().requestFullscreenForElement(m_element.get(), WebCore::FullscreenManager::ExemptIFrameAllowFullscreenRequirement);
     245    m_element->document().fullscreenManager().requestFullscreenForElement(*m_element, WebCore::FullscreenManager::ExemptIFrameAllowFullscreenRequirement);
    246246}
    247247
Note: See TracChangeset for help on using the changeset viewer.