Changeset 183705 in webkit


Ignore:
Timestamp:
May 1, 2015, 6:11:28 PM (10 years ago)
Author:
eric.carlson@apple.com
Message:

Postpone caption style sheet creation
https://bugs.webkit.org/show_bug.cgi?id=144499

Reviewed by Simon Fraser.
Source/WebCore:


Generating and inserting the caption user style sheet is expensive so don't do it until
we see a text track, and only do it for the first video element in a PageGroup.

Test: media/track/track-user-stylesheet.html

  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::registerWithDocument): Only register for caption preferences
changes if we have done so before.
(WebCore::HTMLMediaElement::unregisterWithDocument): Only unregister for caption preferences
changes if we registered for them.
(WebCore::HTMLMediaElement::addTextTrack): Register for caption preference changes.

  • html/HTMLMediaElement.h:
  • page/CaptionUserPreferencesMediaAF.cpp:

(WebCore::CaptionUserPreferencesMediaAF::setInterestedInCaptionPreferenceChanges): Only
generate the style sheet when called for the first time.

LayoutTests:

  • media/track/track-user-stylesheet-expected.txt: Added.
  • media/track/track-user-stylesheet.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r183696 r183705  
     12015-05-01  Eric Carlson  <eric.carlson@apple.com>
     2
     3        Postpone caption style sheet creation
     4        https://bugs.webkit.org/show_bug.cgi?id=144499
     5
     6        Reviewed by Simon Fraser.
     7
     8        * media/track/track-user-stylesheet-expected.txt: Added.
     9        * media/track/track-user-stylesheet.html: Added.
     10
    1112015-05-01  Myles C. Maxfield  <mmaxfield@apple.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r183704 r183705  
     12015-05-01  Eric Carlson  <eric.carlson@apple.com>
     2
     3        Postpone caption style sheet creation
     4        https://bugs.webkit.org/show_bug.cgi?id=144499
     5
     6        Reviewed by Simon Fraser.
     7       
     8        Generating and inserting the caption user style sheet is expensive so don't do it until
     9        we see a text track, and only do it for the first video element in a PageGroup.
     10
     11        Test: media/track/track-user-stylesheet.html
     12
     13        * html/HTMLMediaElement.cpp:
     14        (WebCore::HTMLMediaElement::registerWithDocument): Only register for caption preferences
     15        changes if we have done so before.
     16        (WebCore::HTMLMediaElement::unregisterWithDocument): Only unregister for caption preferences
     17        changes if we registered for them.
     18        (WebCore::HTMLMediaElement::addTextTrack): Register for caption preference changes.
     19        * html/HTMLMediaElement.h:
     20
     21        * page/CaptionUserPreferencesMediaAF.cpp:
     22        (WebCore::CaptionUserPreferencesMediaAF::setInterestedInCaptionPreferenceChanges): Only
     23        generate the style sheet when called for the first time.
     24
    1252015-05-01  Dean Jackson  <dino@apple.com>
    226
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r183676 r183705  
    449449
    450450#if ENABLE(VIDEO_TRACK)
    451     document.registerForCaptionPreferencesChangedCallbacks(this);
     451    if (m_requireCaptionPreferencesChangedCallbacks)
     452        document.registerForCaptionPreferencesChangedCallbacks(this);
    452453#endif
    453454
     
    476477
    477478#if ENABLE(VIDEO_TRACK)
    478     document.unregisterForCaptionPreferencesChangedCallbacks(this);
     479    if (m_requireCaptionPreferencesChangedCallbacks)
     480        document.unregisterForCaptionPreferencesChangedCallbacks(this);
    479481#endif
    480482
     
    33633365    if (!RuntimeEnabledFeatures::sharedFeatures().webkitVideoTrackEnabled())
    33643366        return;
     3367
     3368    if (!m_requireCaptionPreferencesChangedCallbacks) {
     3369        m_requireCaptionPreferencesChangedCallbacks = true;
     3370        document().registerForCaptionPreferencesChangedCallbacks(this);
     3371    }
    33653372
    33663373    textTracks()->append(track);
  • trunk/Source/WebCore/html/HTMLMediaElement.h

    r183618 r183705  
    885885    CueList m_currentlyActiveCues;
    886886    int m_ignoreTrackDisplayUpdate;
     887
     888    bool m_requireCaptionPreferencesChangedCallbacks { false };
    887889#endif
    888890
  • trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp

    r183676 r183705  
    186186void CaptionUserPreferencesMediaAF::setInterestedInCaptionPreferenceChanges()
    187187{
     188    if (m_listeningForPreferenceChanges)
     189        return;
     190
    188191    if (!MediaAccessibilityLibrary())
    189192        return;
     
    192195        return;
    193196
    194     if (!m_listeningForPreferenceChanges) {
    195         m_listeningForPreferenceChanges = true;
    196         m_registeringForNotification = true;
    197         CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), this, userCaptionPreferencesChangedNotificationCallback, kMAXCaptionAppearanceSettingsChangedNotification, 0, CFNotificationSuspensionBehaviorCoalesce);
    198         m_registeringForNotification = false;
    199     }
     197    m_listeningForPreferenceChanges = true;
     198    m_registeringForNotification = true;
     199    CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), this, userCaptionPreferencesChangedNotificationCallback, kMAXCaptionAppearanceSettingsChangedNotification, 0, CFNotificationSuspensionBehaviorCoalesce);
     200    m_registeringForNotification = false;
    200201
    201202    // Generating and registering the caption stylesheet can be expensive and this method is called indirectly when the parser creates an audio or
    202203    // video element, so do it after a brief pause.
    203     if (m_updateStyleSheetTimer.isActive())
    204         m_updateStyleSheetTimer.stop();
    205204    m_updateStyleSheetTimer.startOneShot(0);
    206205}
Note: See TracChangeset for help on using the changeset viewer.