[Modern Media Controls] Add a MediaControlsHost API to retrieve the shadow root CSS
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Oct 2016 19:11:20 +0000 (19:11 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Oct 2016 19:11:20 +0000 (19:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=163501
<rdar://problem/28792014>

Patch by Antoine Quint <graouts@apple.com> on 2016-10-17
Reviewed by Darin Adler.

Add a new `shadowRootCSSText` property to MediaControlsHost so that we may obtain the
concatenated CSS sources for the media controls shadow root via JS. Actually using this
API will be done in a later patch. We also no longer inject those styles as a user-agent
stylesheet when the runtime flag is on since it will no longer be necessary.

* Modules/mediacontrols/MediaControlsHost.cpp:
(WebCore::MediaControlsHost::shadowRootCSSText):
* Modules/mediacontrols/MediaControlsHost.h:
* Modules/mediacontrols/MediaControlsHost.idl:
* css/CSSDefaultStyleSheets.cpp:
(WebCore::CSSDefaultStyleSheets::ensureDefaultStyleSheetsForElement):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207421 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/Modules/mediacontrols/MediaControlsHost.cpp
Source/WebCore/Modules/mediacontrols/MediaControlsHost.h
Source/WebCore/Modules/mediacontrols/MediaControlsHost.idl
Source/WebCore/css/CSSDefaultStyleSheets.cpp

index 1839dd4..f6c31c8 100644 (file)
@@ -1,3 +1,23 @@
+2016-10-17  Antoine Quint  <graouts@apple.com>
+
+        [Modern Media Controls] Add a MediaControlsHost API to retrieve the shadow root CSS
+        https://bugs.webkit.org/show_bug.cgi?id=163501
+        <rdar://problem/28792014>
+
+        Reviewed by Darin Adler.
+
+        Add a new `shadowRootCSSText` property to MediaControlsHost so that we may obtain the
+        concatenated CSS sources for the media controls shadow root via JS. Actually using this
+        API will be done in a later patch. We also no longer inject those styles as a user-agent
+        stylesheet when the runtime flag is on since it will no longer be necessary.
+
+        * Modules/mediacontrols/MediaControlsHost.cpp:
+        (WebCore::MediaControlsHost::shadowRootCSSText):
+        * Modules/mediacontrols/MediaControlsHost.h:
+        * Modules/mediacontrols/MediaControlsHost.idl:
+        * css/CSSDefaultStyleSheets.cpp:
+        (WebCore::CSSDefaultStyleSheets::ensureDefaultStyleSheetsForElement):
+
 2016-10-17  Simon Fraser  <simon.fraser@apple.com>
 
         Implement DOMPoint/DOMPointReadOnly
index d7af35a..ed0cb58 100644 (file)
@@ -36,6 +36,7 @@
 #include "MediaControlElements.h"
 #include "Page.h"
 #include "PageGroup.h"
+#include "RenderTheme.h"
 #include "TextTrack.h"
 #include "TextTrackList.h"
 #include "UUID.h"
@@ -283,6 +284,14 @@ String MediaControlsHost::generateUUID() const
     return createCanonicalUUIDString();
 }
 
+String MediaControlsHost::shadowRootCSSText() const
+{
+    Page* page = m_mediaElement->document().page();
+    if (!page)
+        return emptyString();
+    return RenderTheme::themeForPage(page)->mediaControlsStyleSheet();
+}
+
 }
 
 #endif
index e992bfa..e8646f8 100644 (file)
@@ -82,6 +82,8 @@ public:
 
     String generateUUID() const;
 
+    String shadowRootCSSText() const;
+
 private:
     MediaControlsHost(HTMLMediaElement*);
 
index e181f9c..48289aa 100644 (file)
@@ -59,4 +59,6 @@ enum DeviceType {
     void exitedFullscreen();
 
     DOMString generateUUID();
+
+    [EnabledAtRuntime=ModernMediaControls] readonly attribute DOMString shadowRootCSSText;
 };
index 18ff3eb..097411c 100644 (file)
@@ -46,6 +46,7 @@
 #include "Page.h"
 #include "RenderTheme.h"
 #include "RuleSet.h"
+#include "RuntimeEnabledFeatures.h"
 #include "SVGElement.h"
 #include "StyleSheetContents.h"
 #include "UserAgentStyleSheets.h"
@@ -181,9 +182,14 @@ void CSSDefaultStyleSheets::ensureDefaultStyleSheetsForElement(const Element& el
 #if ENABLE(VIDEO)
         else if (is<HTMLMediaElement>(element)) {
             if (!mediaControlsStyleSheet) {
-                String mediaRules = RenderTheme::themeForPage(element.document().page())->mediaControlsStyleSheet();
-                if (mediaRules.isEmpty())
-                    mediaRules = String(mediaControlsUserAgentStyleSheet, sizeof(mediaControlsUserAgentStyleSheet)) + RenderTheme::themeForPage(element.document().page())->extraMediaControlsStyleSheet();
+                String mediaRules;
+                if (RuntimeEnabledFeatures::sharedFeatures().modernMediaControlsEnabled())
+                    mediaRules = emptyString();
+                else {
+                    mediaRules = RenderTheme::themeForPage(element.document().page())->mediaControlsStyleSheet();
+                    if (mediaRules.isEmpty())
+                        mediaRules = String(mediaControlsUserAgentStyleSheet, sizeof(mediaControlsUserAgentStyleSheet)) + RenderTheme::themeForPage(element.document().page())->extraMediaControlsStyleSheet();
+                }
                 mediaControlsStyleSheet = parseUASheet(mediaRules);
                 defaultStyle->addRulesFromSheet(*mediaControlsStyleSheet, screenEval());
                 defaultPrintStyle->addRulesFromSheet(*mediaControlsStyleSheet, printEval());