Diff
Modified: trunk/LayoutTests/ChangeLog (239180 => 239181)
--- trunk/LayoutTests/ChangeLog 2018-12-13 22:32:29 UTC (rev 239180)
+++ trunk/LayoutTests/ChangeLog 2018-12-13 23:06:49 UTC (rev 239181)
@@ -1,3 +1,16 @@
+2018-12-13 Per Arne Vollan <[email protected]>
+
+ [macOS] Inline WebVTT styles should override styles from Captions settings in System Preferences
+ https://bugs.webkit.org/show_bug.cgi?id=192638
+
+ Reviewed by Eric Carlson.
+
+ * media/track/captions-webvtt/css-styling.vtt:
+ * media/track/captions-webvtt/no-css-styling.vtt:
+ * media/track/track-css-user-override-expected.txt:
+ * media/track/track-css-user-override.html:
+ * media/track/track-cue-css-expected.html:
+
2018-12-13 Matt Baker <[email protected]>
Web Inspector: Table selection becomes corrupted when deleting selected cookies
Modified: trunk/LayoutTests/media/track/captions-webvtt/css-styling.vtt (239180 => 239181)
--- trunk/LayoutTests/media/track/captions-webvtt/css-styling.vtt 2018-12-13 22:32:29 UTC (rev 239180)
+++ trunk/LayoutTests/media/track/captions-webvtt/css-styling.vtt 2018-12-13 23:06:49 UTC (rev 239181)
@@ -11,6 +11,12 @@
font-size: 15px;
}
+STYLE
+video::cue {
+color: green;
+font-size: 15px;
+}
+
hello
00:00:00.000 --> 00:00:10.000
-<b>Hello</b>.
+<b>Hello</b> first cue.
Modified: trunk/LayoutTests/media/track/captions-webvtt/no-css-styling.vtt (239180 => 239181)
--- trunk/LayoutTests/media/track/captions-webvtt/no-css-styling.vtt 2018-12-13 22:32:29 UTC (rev 239180)
+++ trunk/LayoutTests/media/track/captions-webvtt/no-css-styling.vtt 2018-12-13 23:06:49 UTC (rev 239181)
@@ -2,4 +2,4 @@
hello
00:00:00.000 --> 00:00:10.000
-<b>Hello</b>.
+<b>Hello</b> first cue.
Modified: trunk/LayoutTests/media/track/track-css-user-override-expected.txt (239180 => 239181)
--- trunk/LayoutTests/media/track/track-css-user-override-expected.txt 2018-12-13 22:32:29 UTC (rev 239180)
+++ trunk/LayoutTests/media/track/track-css-user-override-expected.txt 2018-12-13 23:06:49 UTC (rev 239181)
@@ -1,6 +1,6 @@
-internals.captionsStyleSheetOverride = function captionsStyleSheetOverride() { [native code] }
+internals.captionsStyleSheetOverride =
Test that style to all cues is applied correctly.
EVENT(canplaythrough)
EVENT(seeked)
@@ -16,7 +16,7 @@
** Add an override, without '!important' **
RUN(internals.setCaptionsStyleSheetOverride('video::cue { color: blue; background-color: yellow; }'))
-internals.captionsStyleSheetOverride = function captionsStyleSheetOverride() { [native code] }
+internals.captionsStyleSheetOverride = video::cue { color: blue; background-color: yellow; }
EXPECTED (getComputedStyle(textTrackDisplayElement(video, 'cue')).color == 'rgb(128, 0, 128)') OK
EXPECTED (getComputedStyle(textTrackDisplayElement(video, 'cue')).backgroundColor == 'rgb(0, 255, 0)') OK
Modified: trunk/LayoutTests/media/track/track-css-user-override.html (239180 => 239181)
--- trunk/LayoutTests/media/track/track-css-user-override.html 2018-12-13 22:32:29 UTC (rev 239180)
+++ trunk/LayoutTests/media/track/track-css-user-override.html 2018-12-13 23:06:49 UTC (rev 239181)
@@ -30,7 +30,7 @@
consoleWrite("<br>** Add an override, without '!important' **");
document.body.offsetTop;
run("internals.setCaptionsStyleSheetOverride('video::cue { color: blue; background-color: yellow; }')");
- consoleWrite("internals.captionsStyleSheetOverride = " + internals.captionsStyleSheetOverride);
+ consoleWrite("internals.captionsStyleSheetOverride = " + internals.captionsStyleSheetOverride());
document.body.offsetTop;
testExpected("getComputedStyle(textTrackDisplayElement(video, 'cue')).color", "rgb(128, 0, 128)");
testExpected("getComputedStyle(textTrackDisplayElement(video, 'cue')).backgroundColor", "rgb(0, 255, 0)");
@@ -37,23 +37,25 @@
consoleWrite("<br>** Mark background-color '!important' **");
run("internals.setCaptionsStyleSheetOverride('video::cue { color: blue ; background-color: yellow !important; }')");
- document.body.offsetTop;
- testExpected("getComputedStyle(textTrackDisplayElement(video, 'cue')).color", "rgb(128, 0, 128)");
- testExpected("getComputedStyle(textTrackDisplayElement(video, 'cue')).backgroundColor", "rgb(255, 255, 0)");
+ // The style is not immediately updated, schedule the rest of the test with a zero timeout timer.
+ setTimeout(function() {
+ testExpected("getComputedStyle(textTrackDisplayElement(video, 'cue')).color", "rgb(128, 0, 128)");
+ testExpected("getComputedStyle(textTrackDisplayElement(video, 'cue')).backgroundColor", "rgb(255, 255, 0)");
- consoleWrite("<br>** Mark color '!important' **");
- run("stylesheet.insertRule('video::cue { color: blue !important; background-color: yellow !important; }', 0)");
- document.body.offsetTop;
- testExpected("getComputedStyle(textTrackDisplayElement(video, 'cue')).color", "rgb(0, 0, 255)");
- testExpected("getComputedStyle(textTrackDisplayElement(video, 'cue')).backgroundColor", "rgb(255, 255, 0)");
+ consoleWrite("<br>** Mark color '!important' **");
+ run("stylesheet.insertRule('video::cue { color: blue !important; background-color: yellow !important; }', 0)");
+ document.body.offsetTop;
+ testExpected("getComputedStyle(textTrackDisplayElement(video, 'cue')).color", "rgb(0, 0, 255)");
+ testExpected("getComputedStyle(textTrackDisplayElement(video, 'cue')).backgroundColor", "rgb(255, 255, 0)");
- consoleWrite("");
- endTest();
+ consoleWrite("");
+ endTest();
+ }, 100);
}
function loaded()
{
-consoleWrite("<br>internals.captionsStyleSheetOverride = " + internals.captionsStyleSheetOverride);
+ consoleWrite("<br>internals.captionsStyleSheetOverride = " + internals.captionsStyleSheetOverride());
consoleWrite("Test that style to all cues is applied correctly.");
findMediaElement();
Modified: trunk/LayoutTests/media/track/track-cue-css-expected.html (239180 => 239181)
--- trunk/LayoutTests/media/track/track-cue-css-expected.html 2018-12-13 22:32:29 UTC (rev 239180)
+++ trunk/LayoutTests/media/track/track-cue-css-expected.html 2018-12-13 23:06:49 UTC (rev 239181)
@@ -14,6 +14,10 @@
color: red;
font-size: 15px;
}
+ video::cue {
+ color: green;
+ font-size: 15px;
+ }
</style>
<script>
function seeked()
Modified: trunk/Source/WebCore/ChangeLog (239180 => 239181)
--- trunk/Source/WebCore/ChangeLog 2018-12-13 22:32:29 UTC (rev 239180)
+++ trunk/Source/WebCore/ChangeLog 2018-12-13 23:06:49 UTC (rev 239181)
@@ -1,3 +1,29 @@
+2018-12-13 Per Arne Vollan <[email protected]>
+
+ [macOS] Inline WebVTT styles should override styles from Captions settings in System Preferences
+ https://bugs.webkit.org/show_bug.cgi?id=192638
+
+ Reviewed by Eric Carlson.
+
+ It is currently not possible to override caption styles generated from System Preferences with inline
+ WebVTT styles without adding !important. The reason for this is that the generated styles from
+ System preferences are author styles which have higher priority than the inline WebVTT styles, which
+ are user agent styles in the video user agent shadow tree. This can be fixed by moving the generated
+ styles to the video user agent shadow tree. Inline WebVTT styles will then have higher priority since
+ they are added after the generated styles. This patch also fixes a problem where inline styles could be
+ added twice to the video user agent shadow root.
+
+ Test: media/track/track-cue-css.html
+
+ * dom/ExtensionStyleSheets.cpp:
+ (WebCore::ExtensionStyleSheets::updateInjectedStyleSheetCache const):
+ * html/track/VTTCue.cpp:
+ (WebCore::VTTCue::getDisplayTree):
+ * page/CaptionUserPreferences.cpp:
+ (WebCore::CaptionUserPreferences::setCaptionsStyleSheetOverride):
+ * page/Page.cpp:
+ (WebCore::Page::setCaptionUserPreferencesStyleSheet):
+
2018-12-13 Jer Noble <[email protected]>
Fix leak of AVPlayer boundaryTimeObserver object.
Modified: trunk/Source/WebCore/dom/ExtensionStyleSheets.cpp (239180 => 239181)
--- trunk/Source/WebCore/dom/ExtensionStyleSheets.cpp 2018-12-13 22:32:29 UTC (rev 239180)
+++ trunk/Source/WebCore/dom/ExtensionStyleSheets.cpp 2018-12-13 23:06:49 UTC (rev 239181)
@@ -137,15 +137,6 @@
else
m_injectedAuthorStyleSheets.append(WTFMove(sheet));
});
-
- if (!owningPage->captionUserPreferencesStyleSheet().isEmpty()) {
- // Identify our override style sheet with a unique URL - a new scheme and a UUID.
- static NeverDestroyed<URL> captionsStyleSheetURL(URL(), "user-captions-override:01F6AF12-C3B0-4F70-AF5E-A3E00234DC23");
-
- auto sheet = createExtensionsStyleSheet(const_cast<Document&>(m_document), captionsStyleSheetURL, owningPage->captionUserPreferencesStyleSheet(), UserStyleAuthorLevel);
-
- m_injectedAuthorStyleSheets.append(WTFMove(sheet));
- }
}
void ExtensionStyleSheets::invalidateInjectedStyleSheetCache()
Modified: trunk/Source/WebCore/html/track/VTTCue.cpp (239180 => 239181)
--- trunk/Source/WebCore/html/track/VTTCue.cpp 2018-12-13 22:32:29 UTC (rev 239180)
+++ trunk/Source/WebCore/html/track/VTTCue.cpp 2018-12-13 23:06:49 UTC (rev 239181)
@@ -896,12 +896,19 @@
displayTree->setFontSizeFromCaptionUserPrefs(fontSize);
displayTree->applyCSSProperties(videoSize);
+ if (displayTree->document().page()) {
+ auto cssString = displayTree->document().page()->captionUserPreferencesStyleSheet();
+ auto style = HTMLStyleElement::create(HTMLNames::styleTag, displayTree->document(), false);
+ style->setTextContent(cssString);
+ displayTree->appendChild(style);
+ }
+
const auto& styleSheets = track()->styleSheets();
if (styleSheets) {
for (const auto& cssString : *styleSheets) {
- auto style = HTMLStyleElement::create(HTMLNames::styleTag, m_cueBackdropBox->document(), false);
+ auto style = HTMLStyleElement::create(HTMLNames::styleTag, displayTree->document(), false);
style->setTextContent(cssString);
- m_cueBackdropBox->appendChild(style);
+ displayTree->appendChild(style);
}
}
Modified: trunk/Source/WebCore/page/CaptionUserPreferences.cpp (239180 => 239181)
--- trunk/Source/WebCore/page/CaptionUserPreferences.cpp 2018-12-13 22:32:29 UTC (rev 239180)
+++ trunk/Source/WebCore/page/CaptionUserPreferences.cpp 2018-12-13 23:06:49 UTC (rev 239181)
@@ -314,8 +314,13 @@
void CaptionUserPreferences::setCaptionsStyleSheetOverride(const String& override)
{
+ if (override == m_captionsStyleSheetOverride)
+ return;
+
m_captionsStyleSheetOverride = override;
updateCaptionStyleSheetOverride();
+ if (!m_timer.isActive())
+ m_timer.startOneShot(0_s);
}
void CaptionUserPreferences::updateCaptionStyleSheetOverride()
Modified: trunk/Source/WebCore/page/Page.cpp (239180 => 239181)
--- trunk/Source/WebCore/page/Page.cpp 2018-12-13 22:32:29 UTC (rev 239180)
+++ trunk/Source/WebCore/page/Page.cpp 2018-12-13 23:06:49 UTC (rev 239181)
@@ -2564,8 +2564,6 @@
return;
m_captionUserPreferencesStyleSheet = styleSheet;
-
- invalidateInjectedStyleSheetCacheInAllFrames();
}
void Page::accessibilitySettingsDidChange()