Add an appearance keyword for wireless playback / airplay icon
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Jun 2015 20:50:34 +0000 (20:50 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Jun 2015 20:50:34 +0000 (20:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=145892
<rdar://problem/21344872>

Reviewed by Simon Fraser.

Source/WebCore:

Add a new "-webkit-appearance" value named "-apple-airplay"
which will be used to render an icon. This change simply
adds support for the value, and puts in hooks for drawing.

At the moment this is only going to be used by Airplay, so
the public-facing name is "-apple-airplay". However, the
implementation in Theme has a more generic name, in case
we hook it up for other ports later.

Test: fast/css/appearance-airplay.html

* css/CSSParser.cpp:
(WebCore::cssValueKeywordID): This new keyword should not get
translated into having a -webkit prefix.
* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue): New mapping from
the Theme to the CSS value.
* css/CSSValueKeywords.in: Add "-apple-airplay".
* platform/ThemeTypes.h: New ControlPart.
* rendering/RenderTheme.cpp: Stub implementation of the rendering and
style update for the new appearance.
(WebCore::RenderTheme::adjustStyle):
(WebCore::RenderTheme::paint):
(WebCore::RenderTheme::adjustWirelessPlaybackIconStyle):
(WebCore::RenderTheme::paintWirelessPlaybackIcon):
* rendering/RenderTheme.h:
* rendering/RenderThemeMac.h:
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::adjustWirelessPlaybackIconStyle):
(WebCore::RenderThemeMac::paintWirelessPlaybackIcon):

LayoutTests:

Simple test that makes sure we parse and evaluate
the new appearance value.

* fast/css/appearance-airplay-expected.txt: Added.
* fast/css/appearance-airplay.html: Added.

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

12 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css/appearance-airplay-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/appearance-airplay.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSPrimitiveValueMappings.h
Source/WebCore/css/CSSValueKeywords.in
Source/WebCore/platform/ThemeTypes.h
Source/WebCore/rendering/RenderTheme.cpp
Source/WebCore/rendering/RenderTheme.h
Source/WebCore/rendering/RenderThemeMac.h
Source/WebCore/rendering/RenderThemeMac.mm

index d194965..6c3b057 100644 (file)
@@ -1,3 +1,17 @@
+2015-06-11  Dean Jackson  <dino@apple.com>
+
+        Add an appearance keyword for wireless playback / airplay icon
+        https://bugs.webkit.org/show_bug.cgi?id=145892
+        <rdar://problem/21344872>
+
+        Reviewed by Simon Fraser.
+
+        Simple test that makes sure we parse and evaluate
+        the new appearance value.
+
+        * fast/css/appearance-airplay-expected.txt: Added.
+        * fast/css/appearance-airplay.html: Added.
+
 2015-06-11  Alexey Proskuryakov  <ap@apple.com>
 
         Update plugins/embed-attributes-style.html to not use the QuickTime plug-in
diff --git a/LayoutTests/fast/css/appearance-airplay-expected.txt b/LayoutTests/fast/css/appearance-airplay-expected.txt
new file mode 100644 (file)
index 0000000..92c7225
--- /dev/null
@@ -0,0 +1,10 @@
+Test the -apple-airplay appearance keyword value.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS filterStyle is '-apple-airplay'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/css/appearance-airplay.html b/LayoutTests/fast/css/appearance-airplay.html
new file mode 100644 (file)
index 0000000..e3a2886
--- /dev/null
@@ -0,0 +1,28 @@
+<!DOCTYPE>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<style>
+#target {
+  -webkit-appearance: -apple-airplay;
+}
+</style>
+</head>
+<body>
+<div id="target"></div>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+
+description("Test the -apple-airplay appearance keyword value.");
+
+var target = document.getElementById("target");
+var filterStyle = window.getComputedStyle(target).getPropertyValue('-webkit-appearance');
+shouldBe('filterStyle', "'-apple-airplay'");
+
+successfullyParsed = true;
+
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
index fd86080..637d14b 100644 (file)
@@ -1,3 +1,42 @@
+2015-06-11  Dean Jackson  <dino@apple.com>
+
+        Add an appearance keyword for wireless playback / airplay icon
+        https://bugs.webkit.org/show_bug.cgi?id=145892
+        <rdar://problem/21344872>
+
+        Reviewed by Simon Fraser.
+
+        Add a new "-webkit-appearance" value named "-apple-airplay"
+        which will be used to render an icon. This change simply
+        adds support for the value, and puts in hooks for drawing.
+
+        At the moment this is only going to be used by Airplay, so
+        the public-facing name is "-apple-airplay". However, the
+        implementation in Theme has a more generic name, in case
+        we hook it up for other ports later.
+
+        Test: fast/css/appearance-airplay.html
+
+        * css/CSSParser.cpp:
+        (WebCore::cssValueKeywordID): This new keyword should not get
+        translated into having a -webkit prefix.
+        * css/CSSPrimitiveValueMappings.h:
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): New mapping from
+        the Theme to the CSS value.
+        * css/CSSValueKeywords.in: Add "-apple-airplay".
+        * platform/ThemeTypes.h: New ControlPart.
+        * rendering/RenderTheme.cpp: Stub implementation of the rendering and
+        style update for the new appearance.
+        (WebCore::RenderTheme::adjustStyle):
+        (WebCore::RenderTheme::paint):
+        (WebCore::RenderTheme::adjustWirelessPlaybackIconStyle):
+        (WebCore::RenderTheme::paintWirelessPlaybackIcon):
+        * rendering/RenderTheme.h:
+        * rendering/RenderThemeMac.h:
+        * rendering/RenderThemeMac.mm:
+        (WebCore::RenderThemeMac::adjustWirelessPlaybackIconStyle):
+        (WebCore::RenderThemeMac::paintWirelessPlaybackIcon):
+
 2015-06-11  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r185464.
index 584c0c5..6ded950 100644 (file)
@@ -12830,7 +12830,11 @@ static CSSValueID cssValueKeywordID(const CharacterType* valueKeyword, unsigned
         // This makes the string one character longer.
         // On iOS we don't want to change values starting with -apple-system to -webkit-system.
         // FIXME: Remove this mangling without breaking the web.
-        if ((hasPrefix(buffer, length, "-apple-") && !hasPrefix(buffer, length, "-apple-system")) || hasPrefix(buffer, length, "-khtml-")) {
+        // FIXME: The better way to do this would be to mark up CSSValueKeywords.in with
+        // commands that indicate if the keyword should support a translation.
+        // https://bugs.webkit.org/show_bug.cgi?id=145883
+
+        if ((hasPrefix(buffer, length, "-apple-") && !hasPrefix(buffer, length, "-apple-system") && memcmp(buffer, "-apple-airplay", length)) || hasPrefix(buffer, length, "-khtml-")) {
             memmove(buffer + 7, buffer + 6, length + 1 - 6);
             memcpy(buffer, "-webkit", 7);
             ++length;
index 3348aac..3b91a4e 100644 (file)
@@ -616,6 +616,9 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ControlPart e)
         m_value.valueID = CSSValueImageControlsButton;
         break;
 #endif
+    case WirelessPlaybackIconPart:
+        m_value.valueID = CSSValueAppleAirplay;
+        break;
     }
 }
 
index 1beb134..79e1ea8 100644 (file)
@@ -760,6 +760,7 @@ relevancy-level-indicator
 continuous-capacity-level-indicator
 discrete-capacity-level-indicator
 rating-level-indicator
+-apple-airplay
 #if defined(ENABLE_SERVICE_CONTROLS) && ENABLE_SERVICE_CONTROLS
 image-controls-button
 #endif
index 5ff8542..6f5d96a 100644 (file)
@@ -46,6 +46,7 @@ enum ControlPart {
     SearchFieldResultsDecorationPart, SearchFieldResultsButtonPart,
     SearchFieldCancelButtonPart, SnapshottedPluginOverlayPart, TextFieldPart,
     RelevancyLevelIndicatorPart, ContinuousCapacityLevelIndicatorPart, DiscreteCapacityLevelIndicatorPart, RatingLevelIndicatorPart,
+    WirelessPlaybackIconPart,
 #if ENABLE(SERVICE_CONTROLS)
     ImageControlsButtonPart,
 #endif
index 8014082..0b6145c 100644 (file)
@@ -257,6 +257,8 @@ void RenderTheme::adjustStyle(StyleResolver& styleResolver, RenderStyle& style,
     case AttachmentPart:
         return adjustAttachmentStyle(styleResolver, style, element);
 #endif
+    case WirelessPlaybackIconPart:
+        return adjustWirelessPlaybackIconStyle(styleResolver, style, element);
     default:
         break;
     }
@@ -399,6 +401,8 @@ bool RenderTheme::paint(const RenderObject& o, ControlStates* controlStates, con
     case AttachmentPart:
         return paintAttachment(o, paintInfo, integralSnappedRect);
 #endif
+    case WirelessPlaybackIconPart:
+        return paintWirelessPlaybackIcon(o, paintInfo, integralSnappedRect);
     default:
         break;
     }
@@ -995,6 +999,15 @@ bool RenderTheme::paintAttachment(const RenderObject&, const PaintInfo&, const I
 }
 #endif
 
+void RenderTheme::adjustWirelessPlaybackIconStyle(StyleResolver&, RenderStyle&, Element*) const
+{
+}
+
+bool RenderTheme::paintWirelessPlaybackIcon(const RenderObject&, const PaintInfo&, const IntRect&)
+{
+    return false;
+}
+
 #if ENABLE(DATALIST_ELEMENT)
 LayoutUnit RenderTheme::sliderTickSnappingThreshold() const
 {
index 92246f5..824e172 100644 (file)
@@ -326,6 +326,9 @@ protected:
     virtual bool paintAttachment(const RenderObject&, const PaintInfo&, const IntRect&);
 #endif
 
+    virtual void adjustWirelessPlaybackIconStyle(StyleResolver&, RenderStyle&, Element*) const;
+    virtual bool paintWirelessPlaybackIcon(const RenderObject&, const PaintInfo&, const IntRect&);
+
     virtual void adjustProgressBarStyle(StyleResolver&, RenderStyle&, Element*) const;
     virtual bool paintProgressBar(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
 
index e05b87a..6f63b0d 100644 (file)
@@ -173,6 +173,9 @@ protected:
     virtual bool paintAttachment(const RenderObject&, const PaintInfo&, const IntRect&) override;
 #endif
 
+    virtual void adjustWirelessPlaybackIconStyle(StyleResolver&, RenderStyle&, Element*) const override;
+    virtual bool paintWirelessPlaybackIcon(const RenderObject&, const PaintInfo&, const IntRect&) override;
+
 private:
     virtual String fileListNameForWidth(const FileList*, const FontCascade&, int width, bool multipleFilesAllowed) const override;
 
index 4a7ccb2..f89c7e9 100644 (file)
@@ -2613,6 +2613,15 @@ bool RenderThemeMac::paintAttachment(const RenderObject& renderer, const PaintIn
 
 #endif // ENABLE(ATTACHMENT_ELEMENT)
 
+void RenderThemeMac::adjustWirelessPlaybackIconStyle(StyleResolver&, RenderStyle&, Element*) const
+{
+}
+
+bool RenderThemeMac::paintWirelessPlaybackIcon(const RenderObject&, const PaintInfo&, const IntRect&)
+{
+    return false;
+}
+
 } // namespace WebCore
 
 #endif // !PLATFORM(IOS)