Postpone caption style sheet creation
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 2 May 2015 01:11:28 +0000 (01:11 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 2 May 2015 01:11:28 +0000 (01:11 +0000)
commitc3daa38f69538258dbb80e3a0e3020f065f91959
treedae3aee21d70d6d4d47d1cec2cb533ad05901628
parentf4e451f84a743786b0430a7473e7f9262120c2ea
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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@183705 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/media/track/track-user-stylesheet-expected.txt [new file with mode: 0644]
LayoutTests/media/track/track-user-stylesheet.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp