Controls panel should have system blurry background
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Mar 2015 00:39:36 +0000 (00:39 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Mar 2015 00:39:36 +0000 (00:39 +0000)
https://bugs.webkit.org/show_bug.cgi?id=142154
<rdar://problem/20000964>

Reviewed by Simon Fraser.

Source/WebCore:

In order to replicate the system style of media controls
on OS X and iOS, we need to expose a special -webkit-appearance.
This patch adds the new property value, and implements
the iOS part of the appearance, which is a blurry shaded
background.

Test: compositing/media-controls-bar-appearance.html

* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue): Map the new
keywords from ControlParts.

* css/CSSValueKeywords.in: Add media-controls-light-bar-background
and media-controls-dark-bar-background. Darin suggested they
be sorted, so I did this at the same time.
* platform/ThemeTypes.h: New ControlParts for the values, and
sort the values since they need to be in sync with
CSSValueKeywords.in.

* platform/graphics/GraphicsLayer.h: Expose two new custom appearance
values.
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::GraphicsLayerCA):
(WebCore::layerTypeForCustomBackdropAppearance): Helper function.
(WebCore::isCustomBackdropLayerType): Ditto.
(WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers): Merge setting
a system backdrop layer in with the code that swaps to/from tiled layers.
(WebCore::GraphicsLayerCA::changeLayerTypeTo): New method that does what
swapFromOrToTiledLayer implemented, but also allows us to change to a
system backdrop layer.
(WebCore::GraphicsLayerCA::swapFromOrToTiledLayer): Deleted.
* platform/graphics/ca/GraphicsLayerCA.h:

* platform/graphics/ca/PlatformCALayer.h: New layer types.
* platform/graphics/ca/mac/PlatformCALayerMac.mm: For now expose these
as regular backdrop layers.
(PlatformCALayerMac::PlatformCALayerMac):
(PlatformCALayerMac::updateCustomAppearance):

* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::createPrimaryGraphicsLayer): Make sure to update
custom appearance,
(WebCore::RenderLayerBacking::updateCustomAppearance): New method.
* rendering/RenderLayerBacking.h:

Source/WebKit2:

In order to replicate the system style of media controls
on OS X and iOS, we need to expose a special -webkit-appearance.
This patch adds the new property value, and implements
the iOS part of the appearance, which is a blurry shaded
background.

* Shared/mac/RemoteLayerBackingStore.mm:
(WebKit::RemoteLayerBackingStore::drawInContext): Add entries for
the new layer types, even though they are not correct yet.

* Shared/mac/RemoteLayerTreePropertyApplier.mm:
(WebKit::updateCustomAppearance):
(WebKit::RemoteLayerTreePropertyApplier::applyProperties): UIBackdropViews
have a defined hierarchy that we don't create. We need to make sure we add our
children to the right subview.
* Shared/mac/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTransaction::description): Logging.

* UIProcess/ios/RemoteLayerTreeHostIOS.mm: Rename existing WKBackdropView
to WKSimpleBackdropView, and add a new WKBackdropView that inherits
from UIBackdropView.
(-[WKBackdropView hitTest:withEvent:]):
(-[WKBackdropView description]):
(WebKit::RemoteLayerTreeHost::createLayer): Handle the new LayerTypes.
* UIProcess/mac/RemoteLayerTreeHost.mm:
(WebKit::RemoteLayerTreeHost::createLayer):

LayoutTests:

Make sure content with a -webkit-appearance of
media-controls-light-bar-background or
media-controls-dark-bar-background doesn't get composited
unless explicitly requested. This avoids a
performance hit for a rarely used feature.

* compositing/media-controls-bar-appearance-expected.txt: Added.
* compositing/media-controls-bar-appearance.html: Added.

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

21 files changed:
LayoutTests/ChangeLog
LayoutTests/compositing/media-controls-bar-appearance-expected.txt [new file with mode: 0644]
LayoutTests/compositing/media-controls-bar-appearance.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSPrimitiveValueMappings.h
Source/WebCore/css/CSSValueKeywords.in
Source/WebCore/platform/ThemeTypes.h
Source/WebCore/platform/graphics/GraphicsLayer.h
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h
Source/WebCore/platform/graphics/ca/PlatformCALayer.h
Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebCore/rendering/RenderLayerBacking.h
Source/WebKit2/ChangeLog
Source/WebKit2/Platform/spi/ios/UIKitSPI.h
Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm
Source/WebKit2/Shared/mac/RemoteLayerTreePropertyApplier.mm
Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm
Source/WebKit2/UIProcess/ios/RemoteLayerTreeHostIOS.mm
Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm

index 738c65a..104811e 100644 (file)
@@ -1,3 +1,20 @@
+2015-03-03  Dean Jackson  <dino@apple.com>
+
+        Controls panel should have system blurry background
+        https://bugs.webkit.org/show_bug.cgi?id=142154
+        <rdar://problem/20000964>
+
+        Reviewed by Simon Fraser.
+
+        Make sure content with a -webkit-appearance of
+        media-controls-light-bar-background or
+        media-controls-dark-bar-background doesn't get composited
+        unless explicitly requested. This avoids a
+        performance hit for a rarely used feature.
+
+        * compositing/media-controls-bar-appearance-expected.txt: Added.
+        * compositing/media-controls-bar-appearance.html: Added.
+
 2015-03-03  Daniel Bates  <dabates@apple.com>
 
         Convert ManualTests/svg-tooltip.svg to a DRT test
diff --git a/LayoutTests/compositing/media-controls-bar-appearance-expected.txt b/LayoutTests/compositing/media-controls-bar-appearance-expected.txt
new file mode 100644 (file)
index 0000000..595813f
--- /dev/null
@@ -0,0 +1,27 @@
+These elements should not get their own layers.
+
+These elements explicitly request layers.
+
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (children 2
+        (GraphicsLayer
+          (position 8.00 300.00)
+          (bounds 100.00 100.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 8.00 400.00)
+          (bounds 100.00 100.00)
+          (drawsContent 1)
+        )
+      )
+    )
+  )
+)
+
diff --git a/LayoutTests/compositing/media-controls-bar-appearance.html b/LayoutTests/compositing/media-controls-bar-appearance.html
new file mode 100644 (file)
index 0000000..20fe5f2
--- /dev/null
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <style>
+        div {
+            position: relative;
+            height: 100px;
+            width: 100px;
+        }
+        .media-controls-dark {
+            -webkit-appearance: media-controls-dark-bar-background;
+        }
+        .media-controls-light {
+            -webkit-appearance: media-controls-light-bar-background;
+        }
+        .with-layer {
+            -webkit-transform: translate3d(0, 0, 0);
+        }
+    </style>
+    <script>
+        if (window.testRunner)
+            testRunner.dumpAsText();
+
+        function dumpLayers()
+        {
+            var layersResult = document.getElementById('layers');
+            if (window.testRunner)
+                layersResult.innerText = window.internals.layerTreeAsText(document);
+
+        }
+        window.addEventListener('load', dumpLayers, false)
+    </script>
+</head>
+<body>
+    <p>These elements should not get their own layers.</p>
+    <div class="media-controls-dark">
+    </div>
+    <div class="media-controls-light">
+    </div>
+    <p>These elements explicitly request layers.</p>
+    <div class="media-controls-dark with-layer">
+    </div>
+    <div class="media-controls-light with-layer">
+    </div>
+<pre id="layers"></pre>
+</body>
+</html>
index 2836300..9367042 100644 (file)
@@ -1,3 +1,56 @@
+2015-03-03  Dean Jackson  <dino@apple.com>
+
+        Controls panel should have system blurry background
+        https://bugs.webkit.org/show_bug.cgi?id=142154
+        <rdar://problem/20000964>
+
+        Reviewed by Simon Fraser.
+
+        In order to replicate the system style of media controls
+        on OS X and iOS, we need to expose a special -webkit-appearance.
+        This patch adds the new property value, and implements
+        the iOS part of the appearance, which is a blurry shaded
+        background.
+
+        Test: compositing/media-controls-bar-appearance.html
+
+        * css/CSSPrimitiveValueMappings.h:
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): Map the new
+        keywords from ControlParts.
+
+        * css/CSSValueKeywords.in: Add media-controls-light-bar-background
+        and media-controls-dark-bar-background. Darin suggested they
+        be sorted, so I did this at the same time.
+        * platform/ThemeTypes.h: New ControlParts for the values, and
+        sort the values since they need to be in sync with
+        CSSValueKeywords.in.
+
+        * platform/graphics/GraphicsLayer.h: Expose two new custom appearance
+        values.
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::GraphicsLayerCA):
+        (WebCore::layerTypeForCustomBackdropAppearance): Helper function.
+        (WebCore::isCustomBackdropLayerType): Ditto.
+        (WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers): Merge setting
+        a system backdrop layer in with the code that swaps to/from tiled layers.
+        (WebCore::GraphicsLayerCA::changeLayerTypeTo): New method that does what
+        swapFromOrToTiledLayer implemented, but also allows us to change to a
+        system backdrop layer.
+        (WebCore::GraphicsLayerCA::swapFromOrToTiledLayer): Deleted.
+        * platform/graphics/ca/GraphicsLayerCA.h:
+
+        * platform/graphics/ca/PlatformCALayer.h: New layer types.
+        * platform/graphics/ca/mac/PlatformCALayerMac.mm: For now expose these
+        as regular backdrop layers.
+        (PlatformCALayerMac::PlatformCALayerMac):
+        (PlatformCALayerMac::updateCustomAppearance):
+
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::createPrimaryGraphicsLayer): Make sure to update
+        custom appearance,
+        (WebCore::RenderLayerBacking::updateCustomAppearance): New method.
+        * rendering/RenderLayerBacking.h:
+
 2015-03-03  Chris Dumez  <cdumez@apple.com>
 
         Access ApplicationCacheStorage global instance via singleton() static member function
index 01b6126..81bcd86 100644 (file)
@@ -527,6 +527,12 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ControlPart e)
     case MediaTimeRemainingPart:
         m_value.valueID = CSSValueMediaTimeRemainingDisplay;
         break;
+    case MediaControlsLightBarBackgroundPart:
+        m_value.valueID = CSSValueMediaControlsLightBarBackground;
+        break;
+    case MediaControlsDarkBarBackgroundPart:
+        m_value.valueID = CSSValueMediaControlsDarkBarBackground;
+        break;
     case MenulistPart:
         m_value.valueID = CSSValueMenulist;
         break;
index 29d2b8f..ca8730b 100644 (file)
@@ -696,28 +696,30 @@ default-button
 inner-spin-button
 listbox
 listitem
+media-controls-background
+media-controls-dark-bar-background
+media-controls-fullscreen-background
+media-controls-light-bar-background
+media-current-time-display
 media-enter-fullscreen-button
 media-exit-fullscreen-button
 media-fullscreen-volume-slider
 media-fullscreen-volume-slider-thumb
 media-mute-button
-media-play-button
 media-overlay-play-button
+media-play-button
+media-return-to-realtime-button
+media-rewind-button
 media-seek-back-button
 media-seek-forward-button
-media-rewind-button
-media-return-to-realtime-button
-media-toggle-closed-captions-button
 media-slider
 media-sliderthumb
-media-volume-slider-container
+media-time-remaining-display
+media-toggle-closed-captions-button
 media-volume-slider
-media-volume-sliderthumb
+media-volume-slider-container
 media-volume-slider-mute-button
-media-controls-background
-media-controls-fullscreen-background
-media-current-time-display
-media-time-remaining-display
+media-volume-sliderthumb
 menulist
 menulist-button
 menulist-text
index 4d1564c..5ff8542 100644 (file)
@@ -32,10 +32,14 @@ namespace WebCore {
 enum ControlPart {
     NoControlPart, CheckboxPart, RadioPart, PushButtonPart, SquareButtonPart, ButtonPart,
     ButtonBevelPart, DefaultButtonPart, InnerSpinButtonPart, ListboxPart, ListItemPart,
-    MediaEnterFullscreenButtonPart, MediaExitFullscreenButtonPart, MediaFullScreenVolumeSliderPart, MediaFullScreenVolumeSliderThumbPart, MediaMuteButtonPart, MediaPlayButtonPart,
-    MediaOverlayPlayButtonPart, MediaSeekBackButtonPart, MediaSeekForwardButtonPart, MediaRewindButtonPart, MediaReturnToRealtimeButtonPart, MediaToggleClosedCaptionsButtonPart,
-    MediaSliderPart, MediaSliderThumbPart, MediaVolumeSliderContainerPart, MediaVolumeSliderPart, MediaVolumeSliderThumbPart,
-    MediaVolumeSliderMuteButtonPart, MediaControlsBackgroundPart, MediaControlsFullscreenBackgroundPart, MediaCurrentTimePart, MediaTimeRemainingPart,
+    MediaControlsBackgroundPart, MediaControlsDarkBarBackgroundPart, MediaControlsFullscreenBackgroundPart,
+    MediaControlsLightBarBackgroundPart, MediaCurrentTimePart, MediaEnterFullscreenButtonPart,
+    MediaExitFullscreenButtonPart, MediaFullScreenVolumeSliderPart,
+    MediaFullScreenVolumeSliderThumbPart, MediaMuteButtonPart, MediaOverlayPlayButtonPart,
+    MediaPlayButtonPart, MediaReturnToRealtimeButtonPart, MediaRewindButtonPart, MediaSeekBackButtonPart,
+    MediaSeekForwardButtonPart, MediaSliderPart, MediaSliderThumbPart, MediaTimeRemainingPart,
+    MediaToggleClosedCaptionsButtonPart, MediaVolumeSliderContainerPart, MediaVolumeSliderMuteButtonPart,
+    MediaVolumeSliderPart, MediaVolumeSliderThumbPart,
     MenulistPart, MenulistButtonPart, MenulistTextPart, MenulistTextFieldPart, MeterPart, ProgressBarPart, ProgressBarValuePart,
     SliderHorizontalPart, SliderVerticalPart, SliderThumbHorizontalPart,
     SliderThumbVerticalPart, CaretPart, SearchFieldPart, SearchFieldDecorationPart,
index 000bc77..6fad63c 100644 (file)
@@ -443,7 +443,7 @@ public:
     virtual void setDebugBackgroundColor(const Color&) { }
     virtual void setDebugBorder(const Color&, float /*borderWidth*/) { }
 
-    enum CustomAppearance { NoCustomAppearance, ScrollingOverhang, ScrollingShadow };
+    enum CustomAppearance { NoCustomAppearance, ScrollingOverhang, ScrollingShadow, LightBackdropAppearance, DarkBackdropAppearance };
     virtual void setCustomAppearance(CustomAppearance customAppearance) { m_customAppearance = customAppearance; }
     CustomAppearance customAppearance() const { return m_customAppearance; }
 
index acffd73..6eb8d92 100644 (file)
@@ -354,6 +354,7 @@ GraphicsLayerCA::GraphicsLayerCA(Type layerType, GraphicsLayerClient& client)
     , m_contentsLayerPurpose(NoContentsLayer)
     , m_isPageTiledBackingLayer(false)
     , m_needsFullRepaint(false)
+    , m_usingBackdropLayerType(false)
     , m_uncommittedChanges(0)
     , m_isCommittingChanges(false)
 {
@@ -1338,6 +1339,16 @@ bool GraphicsLayerCA::platformCALayerShouldTemporarilyRetainTileCohorts(Platform
     return client().shouldTemporarilyRetainTileCohorts(this);
 }
 
+static PlatformCALayer::LayerType layerTypeForCustomBackdropAppearance(GraphicsLayer::CustomAppearance appearance)
+{
+    return appearance == GraphicsLayer::LightBackdropAppearance ? PlatformCALayer::LayerTypeLightSystemBackdropLayer : PlatformCALayer::LayerTypeDarkSystemBackdropLayer;
+}
+
+static bool isCustomBackdropLayerType(PlatformCALayer::LayerType layerType)
+{
+    return layerType == PlatformCALayer::LayerTypeLightSystemBackdropLayer || layerType == PlatformCALayer::LayerTypeDarkSystemBackdropLayer;
+}
+
 void GraphicsLayerCA::commitLayerChangesBeforeSublayers(CommitState& commitState, float pageScaleFactor, const FloatPoint& positionRelativeToBase, const FloatRect& oldVisibleRect)
 {
     TemporaryChange<bool> committingChangesChange(m_isCommittingChanges, true);
@@ -1353,8 +1364,18 @@ void GraphicsLayerCA::commitLayerChangesBeforeSublayers(CommitState& commitState
     }
 
     bool needTiledLayer = requiresTiledLayer(pageScaleFactor);
-    if (needTiledLayer != m_usingTiledBacking)
-        swapFromOrToTiledLayer(needTiledLayer);
+    bool needBackdropLayerType = (customAppearance() == LightBackdropAppearance || customAppearance() == DarkBackdropAppearance);
+    PlatformCALayer::LayerType neededLayerType = m_layer->layerType();
+
+    if (needTiledLayer)
+        neededLayerType = PlatformCALayer::LayerTypeTiledBackingLayer;
+    else if (needBackdropLayerType)
+        neededLayerType = layerTypeForCustomBackdropAppearance(customAppearance());
+    else if (isCustomBackdropLayerType(m_layer->layerType()) || m_usingTiledBacking)
+        neededLayerType = PlatformCALayer::LayerTypeWebLayer;
+
+    if (neededLayerType != m_layer->layerType())
+        changeLayerTypeTo(neededLayerType);
 
     // Need to handle Preserves3DChanged first, because it affects which layers subsequent properties are applied to
     if (m_uncommittedChanges & (Preserves3DChanged | ReplicatedLayerChanged | BackdropFiltersChanged))
@@ -3187,18 +3208,19 @@ bool GraphicsLayerCA::requiresTiledLayer(float pageScaleFactor) const
 #endif
 }
 
-void GraphicsLayerCA::swapFromOrToTiledLayer(bool useTiledLayer)
+void GraphicsLayerCA::changeLayerTypeTo(PlatformCALayer::LayerType newLayerType)
 {
-    ASSERT(m_layer->layerType() != PlatformCALayer::LayerTypePageTiledBackingLayer);
-    ASSERT(useTiledLayer != m_usingTiledBacking);
+    PlatformCALayer::LayerType oldLayerType = m_layer->layerType();
+    if (newLayerType == oldLayerType)
+        return;
+
     RefPtr<PlatformCALayer> oldLayer = m_layer;
 
-    PlatformCALayer::LayerType layerType = useTiledLayer ? PlatformCALayer::LayerTypeTiledBackingLayer : PlatformCALayer::LayerTypeWebLayer;
+    m_layer = createPlatformCALayer(newLayerType, this);
 
-    m_layer = createPlatformCALayer(layerType, this);
+    m_usingTiledBacking = newLayerType == PlatformCALayer::LayerTypeTiledBackingLayer;
+    m_usingBackdropLayerType = isCustomBackdropLayerType(newLayerType);
 
-    m_usingTiledBacking = useTiledLayer;
-    
     m_layer->adoptSublayers(*oldLayer);
 
 #ifdef VISIBLE_TILE_WASH
@@ -3238,7 +3260,7 @@ void GraphicsLayerCA::swapFromOrToTiledLayer(bool useTiledLayer)
         m_uncommittedChanges |= VisibleRectChanged;
 
 #ifndef NDEBUG
-    String name = String::format("%sCALayer(%p) GraphicsLayer(%p, %llu) ", (m_layer->layerType() == PlatformCALayer::LayerTypeWebTiledLayer) ? "Tiled " : "", m_layer->platformLayer(), this, primaryLayerID()) + m_name;
+    String name = String::format("%sCALayer(%p) GraphicsLayer(%p, %llu) ", (newLayerType == PlatformCALayer::LayerTypeWebTiledLayer) ? "Tiled " : "", m_layer->platformLayer(), this, primaryLayerID()) + m_name;
     m_layer->setName(name);
 #endif
 
@@ -3246,8 +3268,9 @@ void GraphicsLayerCA::swapFromOrToTiledLayer(bool useTiledLayer)
     
     // need to tell new layer to draw itself
     setNeedsDisplay();
-    
-    client().tiledBackingUsageChanged(this, m_usingTiledBacking);
+
+    if (oldLayerType == PlatformCALayer::LayerTypeTiledBackingLayer || newLayerType == PlatformCALayer::LayerTypeTiledBackingLayer)
+        client().tiledBackingUsageChanged(this, m_usingTiledBacking);
 }
 
 GraphicsLayer::CompositingCoordinatesOrientation GraphicsLayerCA::defaultContentsOrientation() const
index ab6c196..99666b3 100644 (file)
@@ -256,7 +256,7 @@ private:
     FloatPoint computePositionRelativeToBase(float& pageScale) const;
 
     bool requiresTiledLayer(float pageScaleFactor) const;
-    void swapFromOrToTiledLayer(bool useTiledLayer);
+    void changeLayerTypeTo(PlatformCALayer::LayerType);
 
     CompositingCoordinatesOrientation defaultContentsOrientation() const;
 
@@ -493,6 +493,7 @@ private:
     ContentsLayerPurpose m_contentsLayerPurpose;
     bool m_isPageTiledBackingLayer : 1;
     bool m_needsFullRepaint : 1;
+    bool m_usingBackdropLayerType : 1;
 
     Color m_contentsSolidColor;
 
index bcfc046..007704d 100644 (file)
@@ -80,6 +80,8 @@ public:
         LayerTypeWebGLLayer,
         LayerTypeBackdropLayer,
         LayerTypeShapeLayer,
+        LayerTypeLightSystemBackdropLayer,
+        LayerTypeDarkSystemBackdropLayer,
         LayerTypeScrollingLayer,
         LayerTypeCustom
     };
index 0407aa4..b36e060 100644 (file)
@@ -226,6 +226,8 @@ PlatformCALayerMac::PlatformCALayerMac(LayerType layerType, PlatformCALayerClien
         layerClass = [CATransformLayer class];
         break;
     case LayerTypeBackdropLayer:
+    case LayerTypeLightSystemBackdropLayer:
+    case LayerTypeDarkSystemBackdropLayer:
 #if ENABLE(FILTERS_LEVEL_2)
         layerClass = [CABackdropLayer class];
 #else
@@ -908,6 +910,8 @@ void PlatformCALayerMac::updateCustomAppearance(GraphicsLayer::CustomAppearance
 #if ENABLE(RUBBER_BANDING)
     switch (appearance) {
     case GraphicsLayer::NoCustomAppearance:
+    case GraphicsLayer::LightBackdropAppearance:
+    case GraphicsLayer::DarkBackdropAppearance:
         ScrollbarThemeMac::removeOverhangAreaBackground(platformLayer());
         ScrollbarThemeMac::removeOverhangAreaShadow(platformLayer());
         break;
index 4be264c..27617c1 100644 (file)
@@ -311,6 +311,7 @@ void RenderLayerBacking::createPrimaryGraphicsLayer()
 #if ENABLE(CSS_COMPOSITING)
     updateBlendMode(renderer().style());
 #endif
+    updateCustomAppearance(renderer().style());
 }
 
 #if PLATFORM(IOS)
@@ -403,6 +404,17 @@ void RenderLayerBacking::updateBlendMode(const RenderStyle& style)
 }
 #endif
 
+void RenderLayerBacking::updateCustomAppearance(const RenderStyle& style)
+{
+    ControlPart appearance = style.appearance();
+    if (appearance == MediaControlsLightBarBackgroundPart)
+        m_graphicsLayer->setCustomAppearance(GraphicsLayer::LightBackdropAppearance);
+    else if (appearance == MediaControlsDarkBarBackgroundPart)
+        m_graphicsLayer->setCustomAppearance(GraphicsLayer::DarkBackdropAppearance);
+    else
+        m_graphicsLayer->setCustomAppearance(GraphicsLayer::NoCustomAppearance);
+}
+
 // FIXME: the hasAcceleratedTouchScrolling()/needsCompositedScrolling() concepts need to be merged.
 static bool layerOrAncestorIsTransformedOrUsingCompositedScrolling(RenderLayer& layer)
 {
index e5da930..4a4a467 100644 (file)
@@ -295,6 +295,8 @@ private:
 #if ENABLE(CSS_COMPOSITING)
     void updateBlendMode(const RenderStyle&);
 #endif
+    void updateCustomAppearance(const RenderStyle&);
+
     // Return the opacity value that this layer should use for compositing.
     float compositingOpacity(float rendererOpacity) const;
     
index d33f855..2b5a420 100644 (file)
@@ -1,3 +1,38 @@
+2015-03-03  Dean Jackson  <dino@apple.com>
+
+        Controls panel should have system blurry background
+        https://bugs.webkit.org/show_bug.cgi?id=142154
+        <rdar://problem/20000964>
+
+        Reviewed by Simon Fraser.
+
+        In order to replicate the system style of media controls
+        on OS X and iOS, we need to expose a special -webkit-appearance.
+        This patch adds the new property value, and implements
+        the iOS part of the appearance, which is a blurry shaded
+        background.
+
+        * Shared/mac/RemoteLayerBackingStore.mm:
+        (WebKit::RemoteLayerBackingStore::drawInContext): Add entries for
+        the new layer types, even though they are not correct yet.
+
+        * Shared/mac/RemoteLayerTreePropertyApplier.mm:
+        (WebKit::updateCustomAppearance):
+        (WebKit::RemoteLayerTreePropertyApplier::applyProperties): UIBackdropViews
+        have a defined hierarchy that we don't create. We need to make sure we add our
+        children to the right subview.
+        * Shared/mac/RemoteLayerTreeTransaction.mm:
+        (WebKit::RemoteLayerTreeTransaction::description): Logging.
+
+        * UIProcess/ios/RemoteLayerTreeHostIOS.mm: Rename existing WKBackdropView
+        to WKSimpleBackdropView, and add a new WKBackdropView that inherits
+        from UIBackdropView.
+        (-[WKBackdropView hitTest:withEvent:]):
+        (-[WKBackdropView description]):
+        (WebKit::RemoteLayerTreeHost::createLayer): Handle the new LayerTypes.
+        * UIProcess/mac/RemoteLayerTreeHost.mm:
+        (WebKit::RemoteLayerTreeHost::createLayer):
+
 2015-03-03  Chris Dumez  <cdumez@apple.com>
 
         Access ApplicationCacheStorage global instance via singleton() static member function
index d65fb93..8f1f634 100644 (file)
@@ -564,6 +564,7 @@ struct _UIWebTouchEvent {
 
 typedef NS_ENUM(NSInteger, _UIBackdropViewStylePrivate) {
     _UIBackdropViewStyle_Light = 2020,
+    _UIBackdropViewStyle_Dark = 2030
 };
 
 @interface _UIBackdropView : UIView
@@ -571,6 +572,7 @@ typedef NS_ENUM(NSInteger, _UIBackdropViewStylePrivate) {
 
 @interface _UIBackdropView (_UIBackdropViewDetails)
 - (instancetype)initWithPrivateStyle:(_UIBackdropViewStylePrivate)style;
+- (instancetype)initWithFrame:(CGRect)frame privateStyle:(_UIBackdropViewStylePrivate)style;
 @property (nonatomic, strong, readonly) UIView *contentView;
 @end
 
index 8a02ece..1ef8e76 100644 (file)
@@ -330,6 +330,13 @@ void RemoteLayerBackingStore::drawInContext(GraphicsContext& context, CGImageRef
         m_layer->owner()->platformCALayerPaintContents(m_layer, context, dirtyBounds);
         break;
     case PlatformCALayer::LayerTypeWebLayer:
+    case PlatformCALayer::LayerTypeBackdropLayer:
+        PlatformCALayer::drawLayerContents(cgContext, m_layer, m_paintingRects);
+        break;
+    case PlatformCALayer::LayerTypeDarkSystemBackdropLayer:
+    case PlatformCALayer::LayerTypeLightSystemBackdropLayer:
+        // FIXME: These have a more complicated layer hierarchy. We need to paint into
+        // a child layer in order to see the rendered results.
         PlatformCALayer::drawLayerContents(cgContext, m_layer, m_paintingRects);
         break;
     case PlatformCALayer::LayerTypeLayer:
@@ -340,7 +347,6 @@ void RemoteLayerBackingStore::drawInContext(GraphicsContext& context, CGImageRef
     case PlatformCALayer::LayerTypeRootLayer:
     case PlatformCALayer::LayerTypeAVPlayerLayer:
     case PlatformCALayer::LayerTypeWebGLLayer:
-    case PlatformCALayer::LayerTypeBackdropLayer:
     case PlatformCALayer::LayerTypeShapeLayer:
     case PlatformCALayer::LayerTypeScrollingLayer:
     case PlatformCALayer::LayerTypeCustom:
index f54bc35..d18bcc0 100644 (file)
@@ -37,6 +37,7 @@
 
 #if PLATFORM(IOS)
 #import <UIKit/UIView.h>
+#import <UIKitSPI.h>
 #endif
 
 #if PLATFORM(IOS)
@@ -112,6 +113,8 @@ static void updateCustomAppearance(CALayer *layer, GraphicsLayer::CustomAppearan
 #if ENABLE(RUBBER_BANDING)
     switch (customAppearance) {
     case GraphicsLayer::NoCustomAppearance:
+    case GraphicsLayer::DarkBackdropAppearance:
+    case GraphicsLayer::LightBackdropAppearance:
         ScrollbarThemeMac::removeOverhangAreaBackground(layer);
         ScrollbarThemeMac::removeOverhangAreaShadow(layer);
         break;
@@ -301,7 +304,12 @@ void RemoteLayerTreePropertyApplier::applyProperties(UIView *view, RemoteLayerTr
             [children addObject:relatedLayers.get(child)];
         }
 
-        [view _web_setSubviews:children.get()];
+        if (properties.customAppearance == GraphicsLayer::LightBackdropAppearance || properties.customAppearance == GraphicsLayer::DarkBackdropAppearance) {
+            // This is a UIBackdropView, which should have children attached to
+            // its content view, not directly on its layers.
+            [[(_UIBackdropView*)view contentView] _web_setSubviews:children.get()];
+        } else
+            [view _web_setSubviews:children.get()];
     }
 
     if (properties.changedProperties & RemoteLayerTreeTransaction::MaskLayerChanged) {
index f26d1b0..c957480 100644 (file)
@@ -1270,6 +1270,12 @@ CString RemoteLayerTreeTransaction::description() const
             case PlatformCALayer::LayerTypeCustom:
                 ts << "custom-layer (context-id " << createdLayer.hostingContextID << ")";
                 break;
+            case PlatformCALayer::LayerTypeLightSystemBackdropLayer:
+                ts << "light-system-backdrop-layer";
+                break;
+            case PlatformCALayer::LayerTypeDarkSystemBackdropLayer:
+                ts << "dark-system-backdrop-layer";
+                break;
             }
             ts << " " << createdLayer.layerID << ")";
         }
index 27f37cb..13064a6 100644 (file)
@@ -30,6 +30,7 @@
 #import "RemoteLayerTreeHost.h"
 #import <QuartzCore/QuartzCore.h>
 #import <UIKit/UIScrollView.h>
+#import <UIKitSPI.h>
 #import <WebKitSystemInterface.h>
 
 using namespace WebCore;
@@ -110,10 +111,11 @@ using namespace WebCore;
 
 @end
 
-@interface WKBackdropView : WKCompositingView
+@interface WKSimpleBackdropView : WKCompositingView
 @end
 
-@implementation WKBackdropView
+@implementation WKSimpleBackdropView
+
 + (Class)layerClass
 {
     return [CABackdropLayer self];
@@ -157,6 +159,25 @@ using namespace WebCore;
 
 @end
 
+@interface WKBackdropView : _UIBackdropView
+@end
+
+@implementation WKBackdropView
+
+- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
+{
+    return [self _findDescendantViewAtPoint:point withEvent:event];
+}
+
+- (NSString *)description
+{
+    NSString *viewDescription = [super description];
+    NSString *webKitDetails = [NSString stringWithFormat:@" layerID = %llu \"%@\"", WebKit::RemoteLayerTreeHost::layerID(self.layer), self.layer.name ? self.layer.name : @""];
+    return [viewDescription stringByAppendingString:webKitDetails];
+}
+
+@end
+
 namespace WebKit {
 
 LayerOrView *RemoteLayerTreeHost::createLayer(const RemoteLayerTreeTransaction::LayerCreationProperties& properties, const RemoteLayerTreeTransaction::LayerProperties* layerProperties)
@@ -176,7 +197,13 @@ LayerOrView *RemoteLayerTreeHost::createLayer(const RemoteLayerTreeTransaction::
         view = adoptNS([[WKCompositingView alloc] init]);
         break;
     case PlatformCALayer::LayerTypeBackdropLayer:
-        view = adoptNS([[WKBackdropView alloc] init]);
+        view = adoptNS([[WKSimpleBackdropView alloc] init]);
+        break;
+    case PlatformCALayer::LayerTypeLightSystemBackdropLayer:
+        view = adoptNS([[WKBackdropView alloc] initWithFrame:CGRectZero privateStyle:_UIBackdropViewStyle_Light]);
+        break;
+    case PlatformCALayer::LayerTypeDarkSystemBackdropLayer:
+        view = adoptNS([[WKBackdropView alloc] initWithFrame:CGRectZero privateStyle:_UIBackdropViewStyle_Dark]);
         break;
     case PlatformCALayer::LayerTypeTransformLayer:
         view = adoptNS([[WKTransformView alloc] init]);
index 16cd27e..47d4963 100644 (file)
@@ -229,6 +229,8 @@ LayerOrView *RemoteLayerTreeHost::createLayer(const RemoteLayerTreeTransaction::
         layer = adoptNS([[CATransformLayer alloc] init]);
         break;
     case PlatformCALayer::LayerTypeBackdropLayer:
+    case PlatformCALayer::LayerTypeLightSystemBackdropLayer:
+    case PlatformCALayer::LayerTypeDarkSystemBackdropLayer:
 #if ENABLE(FILTERS_LEVEL_2)
         layer = adoptNS([[CABackdropLayer alloc] init]);
 #else