12011-10-27 Simon Fraser <simon.fraser@apple.com>
2
3 The HTML5 video element in Safari does not respect "visibility:hidden" CSS property
4 https://bugs.webkit.org/show_bug.cgi?id=38829
5
6 Reviewed by NOBODY (OOPS!).
7
8 Make compositiong and CSS visibility play nicely together.
9
10 The main issue was that an old optimization (see bug 4377) caused
11 visibility:hidden layers to not appear in the z-order lists, but those
12 layers could still become composited, but would remain detached. In addition,
13 composited layers which were visibility:hidden would become visible sometimes.
14
15 With this fix, the z-order lists always contain all layers when the page
16 is in compositing mode. GraphicsLayer is changed to ensure that visibility:hidden
17 layers show no content, and visible descendants of hidden layers work correctly.
18
19 Tests: compositing/visibility/visibility-composited-transforms.html
20 compositing/visibility/visibility-composited.html
21 compositing/visibility/visibility-image-layers-dynamic.html
22 compositing/visibility/visibility-image-layers.html
23
24 * platform/graphics/GraphicsLayer.cpp:
25 (WebCore::GraphicsLayer::GraphicsLayer): Init m_contentsVisible to true.
26 (WebCore::GraphicsLayer::dumpProperties): Dump m_contentsVisible if not true.
27 * platform/graphics/GraphicsLayer.h:
28 (WebCore::GraphicsLayer::contentsAreVisible): Getter for m_contentsVisible.
29 (WebCore::GraphicsLayer::setContentsVisible): Setter for m_contentsVisible.
30 * platform/graphics/ca/GraphicsLayerCA.cpp:
31 (WebCore::GraphicsLayerCA::setContentsVisible): Override setContentsVisible.
32 (WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers): Handle ContentsVisibilityChanged
33 flag
34 (WebCore::GraphicsLayerCA::updateSublayerList): Only parent the m_contentsLayer if the layer
35 has visible contents.
36 (WebCore::GraphicsLayerCA::updateContentsVisibility): For bits painted into the layer itself,
37 we hide it by clearing the backing store.
38 * platform/graphics/ca/GraphicsLayerCA.h: Removed obsolete comment on the DrawsContentChanged flag,
39 added ContentsVisibilityChanged flag.
40 * rendering/RenderLayer.cpp:
41 (WebCore::RenderLayer::updateZOrderLists): If we're in compositing mode, include all layers
42 in the z-order lists.
43 (WebCore::RenderLayer::collectLayers): New param to specify whether we need to collect all layers.
44 * rendering/RenderLayer.h:
45 (WebCore::RenderLayer::hasVisibleDescendant): Add comment about the need for an assertion in hasVisibleContent()
46 , and assertion in hasVisibleDescendant().
47 * rendering/RenderLayerBacking.cpp:
48 (WebCore::RenderLayerBacking::updateGraphicsLayerGeometry): Call setContentsVisible() on the GraphicsLayer.
49 (WebCore::RenderLayerBacking::isSimpleContainerCompositingLayer): We can use simple container layers in cases
50 where visibility:hidden causes layer content to not be drawn.
51 (WebCore::RenderLayerBacking::hasVisibleNonCompositingDescendants): Renamed from hasNonCompositingDescendants()
52 because it now also looks at visibility to decide when things are visible.
53 * rendering/RenderLayerBacking.h: hasNonCompositingDescendants() renamed to hasVisibleNonCompositingDescendants().
54