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

Changeset 173533 in webkit


Ignore:
Timestamp:
Sep 11, 2014, 12:57:33 PM (12 years ago)
Author:
jer.noble@apple.com
Message:

Add site-specific quirk for entering fullscreen on YouTube.com.
​https://bugs.webkit.org/show_bug.cgi?id=136742

Reviewed by Eric Carlson.

YouTube only resizes its <video> content when entering fullscreen after receiving the "webkitfullscreenchange"
event, which is fired once the animation to enter fullscreen completes. This leaves the apparent <video> content
too small during the animation, especially at the beginning of the animation. Add a site-specific hack for
YouTube sites which fires the "webkitfullscreenchange" event synchronously with the beginning of the enter
fullscreen animation. This will cause YouTube to resize their <video> content during the period of time where we
disable screen updates, and makes the enter fullscreen animation seamless.

Add a static utility method, hostIsYouTube(), for the various pieces of this site-specific hack, and expand it
to match youtube.co.uk, youtube.fr, etc.

  • dom/Document.cpp:

(WebCore::hostIsYouTube): Added.
(WebCore::Document::webkitWillEnterFullScreenForElement): Fire fullscreenchange event if hacks are enabled.
(WebCore::Document::webkitDidEnterFullScreenForElement): Don't fire the event if same.
(WebCore::Document::webkitDidExitFullScreenForElement): Use hostIsYouTube().

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r173531 r173533  
     12014-09-11  Jer Noble  <jer.noble@apple.com>
     2
     3        Add site-specific quirk for entering fullscreen on YouTube.com.
     4        https://bugs.webkit.org/show_bug.cgi?id=136742
     5
     6        Reviewed by Eric Carlson.
     7
     8        YouTube only resizes its <video> content when entering fullscreen after receiving the "webkitfullscreenchange"
     9        event, which is fired once the animation to enter fullscreen completes. This leaves the apparent <video> content
     10        too small during the animation, especially at the beginning of the animation. Add a site-specific hack for
     11        YouTube sites which fires the "webkitfullscreenchange" event synchronously with the beginning of the enter
     12        fullscreen animation. This will cause YouTube to resize their <video> content during the period of time where we
     13        disable screen updates, and makes the enter fullscreen animation seamless.
     14
     15        Add a static utility method, hostIsYouTube(), for the various pieces of this site-specific hack, and expand it
     16        to match youtube.co.uk, youtube.fr, etc.
     17
     18        * dom/Document.cpp:
     19        (WebCore::hostIsYouTube): Added.
     20        (WebCore::Document::webkitWillEnterFullScreenForElement): Fire fullscreenchange event if hacks are enabled.
     21        (WebCore::Document::webkitDidEnterFullScreenForElement): Don't fire the event if same.
     22        (WebCore::Document::webkitDidExitFullScreenForElement): Use hostIsYouTube().
     23       
    1242014-09-11  Bear Travis  <betravis@adobe.com>
    225
  • trunk/Source/WebCore/dom/Document.cpp

    r173528 r173533  
    159159#include <wtf/TemporaryChange.h>
    160160#include <wtf/text/StringBuffer.h>
     161#include <yarr/RegularExpression.h>
    161162
    162163#if ENABLE(SHARED_WORKERS)
    … …  
    53325333}
    53335334
     5335static bool hostIsYouTube(const String& host)
     5336{
     5337    // Match .youtube.com, youtube.com, youtube.co.uk, and all two-letter country codes.
     5338    static NeverDestroyed<JSC::Yarr::RegularExpression> youtubePattern("(^|\\.)youtube.(com|co.uk|[a-z]{2})$", TextCaseInsensitive);
     5339    ASSERT(youtubePattern.get().isValid());
     5340
     5341    return youtubePattern.get().match(host);
     5342}
     5343
    53345344void Document::webkitWillEnterFullScreenForElement(Element* element)
    53355345{
    … …  
    53695379
    53705380    m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(true);
    5371    
     5381
     5382    if (settings() && settings()->needsSiteSpecificQuirks() && hostIsYouTube(url().host()))
     5383        fullScreenChangeDelayTimerFired(m_fullScreenChangeDelayTimer);
     5384
    53725385    recalcStyle(Style::Force);
    53735386}
    … …  
    53835396    m_fullScreenElement->didBecomeFullscreenElement();
    53845397
    5385     m_fullScreenChangeDelayTimer.startOneShot(0);
     5398    if (!settings() || !settings()->needsSiteSpecificQuirks() || !hostIsYouTube(url().host()))
     5399        m_fullScreenChangeDelayTimer.startOneShot(0);
    53865400}
    53875401
    … …  
    54225436    // FIXME(136605): Remove this quirk once YouTube moves to relative widths and heights for
    54235437    // fullscreen mode.
    5424     String host = url().host();
    5425     if (settings() && settings()->needsSiteSpecificQuirks() && (host.endsWith(".youtube.com", false) || equalIgnoringCase("youtube.com", host)))
     5438    if (settings() && settings()->needsSiteSpecificQuirks() && hostIsYouTube(url().host()))
    54265439        exitingDocument.fullScreenChangeDelayTimerFired(exitingDocument.m_fullScreenChangeDelayTimer);
    54275440    else
Note: See TracChangeset for help on using the changeset viewer.