summaryrefslogtreecommitdiffstats
path: root/WebCore/platform
diff options
context:
space:
mode:
authorNicolas Roard <nicolas@android.com>2010-03-16 15:35:12 +0000
committerNicolas Roard <nicolas@android.com>2010-03-17 14:41:57 +0000
commit09cdf3e990745cfbcada2d0a49ef371029fc6a97 (patch)
treeac1e5f02cec6e463cb92d42742bcc4373ecf7770 /WebCore/platform
parentb0c2f7b33106420933e04a3b0a69ca4d1d1b3fd8 (diff)
downloadexternal_webkit-09cdf3e990745cfbcada2d0a49ef371029fc6a97.zip
external_webkit-09cdf3e990745cfbcada2d0a49ef371029fc6a97.tar.gz
external_webkit-09cdf3e990745cfbcada2d0a49ef371029fc6a97.tar.bz2
Refactor how we set up the layers hierarchy when using fixed
composited layers, and fix the z-index position. Bug:2497910 Bug:2450006 We add a new COMPOSITED_FIXED_ELEMENTS define to isolate the changes in the webkit common code. We previously had a problem where the hierarchy of GraphicsLayer (i.e. the backed surfaces associated to the composited RenderLayer) was not reflecting that layers were children of a fixed layer. The workaround we currently have is not fully satisfactory, due to the way we draw layers on screen (in some cases layers were wrongly translated, see Bug:2497910). Instead, modifying the webkit common code simplify things a lot, and makes the patch more likely to be upstreamed to webkit, as it's now a reasonably well-delimited feature (use composited layers for fixed elements). What we do now is to consider fixed elements as a stacking context, which makes all layers children of such elements children too in the GraphicsLayer hierarchy, and modifying the offset of those children accordingly (in RenderLayer.cpp). In addition, we fixes the z-index bugs we had by signaling that there is a fixed element to its siblings, and turning the siblings as composited layers as well (so that the ordering works fully UI-side). Change-Id: I735c6c14d955ef54653f0053187d3495bef1f332
Diffstat (limited to 'WebCore/platform')
-rw-r--r--WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp35
-rw-r--r--WebCore/platform/graphics/android/GraphicsLayerAndroid.h1
-rw-r--r--WebCore/platform/graphics/android/LayerAndroid.cpp46
-rw-r--r--WebCore/platform/graphics/android/LayerAndroid.h23
4 files changed, 3 insertions, 102 deletions
diff --git a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
index b48ef49..93469b0 100644
--- a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
@@ -218,39 +218,6 @@ void GraphicsLayerAndroid::needsSyncChildren()
askForSync();
}
-void GraphicsLayerAndroid::syncFixedDescendants()
-{
- for (unsigned int i = 0; i < m_children.size(); i++)
- (static_cast<GraphicsLayerAndroid*>(m_children[i]))->syncFixedDescendants();
-
- if (!m_client)
- return;
-
- RenderLayerBacking* backing = static_cast<RenderLayerBacking*>(m_client);
- RenderLayer* renderLayer = backing->owningLayer();
- RenderView* view = static_cast<RenderView*>(renderLayer->renderer());
-
- // If we have an ancestor that is a fixed position layer, we need to
- // mark ourselve as a child of it, as the RenderLayer hierarchy only
- // keeps track of the z-order.
- // By calling setRelativeTo() we ensure that we will keep track of
- // the fixed layer we are relative to, and will be able to update
- // our position accordingly.
- RenderLayer* positionedParent = renderLayer->parent();
- while (positionedParent &&
- !(positionedParent->renderer()->isPositioned() &&
- positionedParent->renderer()->style()->position() == FixedPosition))
- positionedParent = positionedParent->parent();
-
- if (positionedParent && positionedParent->isComposited()) {
- RenderLayerBacking* positionedParentBacking = positionedParent->backing();
- GraphicsLayerAndroid* positionedParentLayer =
- static_cast<GraphicsLayerAndroid*>(positionedParentBacking->graphicsLayer());
- LayerAndroid* parentLayer = positionedParentLayer->contentLayer();
- m_contentLayer->setRelativeTo(parentLayer);
- }
-}
-
void GraphicsLayerAndroid::updateFixedPosition()
{
if (!m_client)
@@ -456,7 +423,6 @@ void GraphicsLayerAndroid::sendImmediateRepaint()
if (rootGraphicsLayer->m_frame
&& rootGraphicsLayer->m_frame->view()) {
LayerAndroid* copyLayer = new LayerAndroid(*m_contentLayer);
- copyLayer->ensureFixedLayersForDescendants(copyLayer);
TLOG("(%x) sendImmediateRepaint, copy the layer, (%.2f,%.2f => %.2f,%.2f)",
this, m_contentLayer->getSize().width(), m_contentLayer->getSize().height(),
copyLayer->getSize().width(), copyLayer->getSize().height());
@@ -920,7 +886,6 @@ void GraphicsLayerAndroid::syncCompositingState()
syncChildren();
syncMask();
syncPositionState();
- syncFixedDescendants();
if (!gPaused || WTF::currentTime() >= gPausedDelay)
repaintAll();
diff --git a/WebCore/platform/graphics/android/GraphicsLayerAndroid.h b/WebCore/platform/graphics/android/GraphicsLayerAndroid.h
index 09f4181..25f70b4 100644
--- a/WebCore/platform/graphics/android/GraphicsLayerAndroid.h
+++ b/WebCore/platform/graphics/android/GraphicsLayerAndroid.h
@@ -110,7 +110,6 @@ public:
virtual void setZPosition(float);
void askForSync();
- void syncFixedDescendants();
void syncPositionState();
void needsSyncChildren();
void syncChildren();
diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp
index 26372f0..c17a034 100644
--- a/WebCore/platform/graphics/android/LayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/LayerAndroid.cpp
@@ -49,14 +49,10 @@ LayerAndroid::LayerAndroid(bool isRootLayer) : SkLayer(),
m_haveClip(false),
m_doRotation(false),
m_isFixed(false),
- m_isRelativeTo(false),
- m_relativeFixedLayerID(0),
m_recordingPicture(0),
m_extra(0),
- m_uniqueId(++gUniqueId),
- m_relativeFixedLayer(0)
+ m_uniqueId(++gUniqueId)
{
- m_deltaPosition.set(0, 0);
m_angleTransform = 0;
m_translation.set(0, 0);
m_scale.set(1, 1);
@@ -69,14 +65,10 @@ LayerAndroid::LayerAndroid(const LayerAndroid& layer) : SkLayer(layer),
m_isRootLayer(layer.m_isRootLayer),
m_haveClip(layer.m_haveClip),
m_extra(0), // deliberately not copied
- m_uniqueId(layer.m_uniqueId),
- m_relativeFixedLayer(0)
+ m_uniqueId(layer.m_uniqueId)
{
m_doRotation = layer.m_doRotation;
m_isFixed = layer.m_isFixed;
- m_isRelativeTo = layer.m_isRelativeTo;
- m_relativeFixedLayerID = layer.m_relativeFixedLayerID;
- m_deltaPosition = layer.m_deltaPosition;
m_angleTransform = layer.m_angleTransform;
m_translation = layer.m_translation;
@@ -108,14 +100,10 @@ LayerAndroid::LayerAndroid(SkPicture* picture) : SkLayer(),
m_haveClip(false),
m_doRotation(false),
m_isFixed(false),
- m_isRelativeTo(false),
- m_relativeFixedLayerID(0),
m_recordingPicture(picture),
m_extra(0),
- m_uniqueId(-1),
- m_relativeFixedLayer(0)
+ m_uniqueId(-1)
{
- m_deltaPosition.set(0, 0);
m_angleTransform = 0;
m_translation.set(0, 0);
m_scale.set(1, 1);
@@ -257,27 +245,6 @@ const LayerAndroid* LayerAndroid::find(int x, int y) const
///////////////////////////////////////////////////////////////////////////////
-void LayerAndroid::setRelativeTo(LayerAndroid* container) {
- ASSERT(container->m_isFixed);
- m_relativeFixedLayerID = container->m_uniqueId;
- m_isRelativeTo = true;
- m_deltaPosition = getPosition() - container->getPosition();
-}
-
-void LayerAndroid::ensureFixedLayersForDescendants(const LayerAndroid* rootLayer) {
- if (m_isRelativeTo && !m_relativeFixedLayer) {
- LayerAndroid* containerLayer = const_cast<LayerAndroid*>(
- rootLayer->findById(m_relativeFixedLayerID));
- if (containerLayer)
- m_relativeFixedLayer = containerLayer;
- }
-
- int count = countChildren();
- for (int i = 0; i < count; i++) {
- getChild(i)->ensureFixedLayersForDescendants(rootLayer);
- }
-}
-
void LayerAndroid::updateFixedLayersPositions(const SkRect& viewport) {
if (m_isFixed) {
@@ -311,13 +278,6 @@ void LayerAndroid::updatePositions() {
// apply the viewport to us
SkMatrix matrix;
if (!m_isFixed) {
- // If we are defined as being relative to a fixed
- // layer, we need to update our position...
- if (m_isRelativeTo && m_relativeFixedLayer) {
- this->setPosition(m_relativeFixedLayer->getPosition().fX + m_deltaPosition.fX,
- m_relativeFixedLayer->getPosition().fY + m_deltaPosition.fY);
- }
-
// turn our fields into a matrix.
//
// TODO: this should happen in the caller, and we should remove these
diff --git a/WebCore/platform/graphics/android/LayerAndroid.h b/WebCore/platform/graphics/android/LayerAndroid.h
index 005ef3d..247e902 100644
--- a/WebCore/platform/graphics/android/LayerAndroid.h
+++ b/WebCore/platform/graphics/android/LayerAndroid.h
@@ -103,14 +103,6 @@ public:
m_isFixed = true;
}
- /** Call that method to position the layer relative to another one.
- We can only be set relative to a fixed layer.
- The parameter is not refcounted -- we only save its ID as we
- need to reconnect with the correct layer once we copy the tree
- to the UI.
- */
- void setRelativeTo(LayerAndroid* container);
-
void setBackgroundColor(SkColor color);
void setMaskLayer(LayerAndroid*);
void setMasksToBounds(bool);
@@ -134,16 +126,6 @@ public:
void dumpLayers(FILE*, int indentLevel) const;
void dumpToLog() const;
- /** Call this to be sure all fixed descendants correctly have
- a pointer to their container layer before we try
- to update the positions. The fixed layer we point to is
- not refcounted (no need, it's already in the layers' tree).
-
- This call is recursive, so it should be called on the root of the
- hierarchy.
- */
- void ensureFixedLayersForDescendants(const LayerAndroid* rootLayer);
-
/** Call this with the current viewport (scrolling, zoom) to update
the position of the fixed layers.
@@ -185,7 +167,6 @@ private:
bool m_haveClip;
bool m_doRotation;
bool m_isFixed;
- bool m_isRelativeTo;
bool m_backgroundColorSet;
SkLength m_fixedLeft;
@@ -194,8 +175,6 @@ private:
SkLength m_fixedBottom;
int m_fixedWidth;
int m_fixedHeight;
- int m_relativeFixedLayerID;
- SkPoint m_deltaPosition;
SkPoint m_translation;
SkPoint m_scale;
@@ -209,8 +188,6 @@ private:
DrawExtra* m_extra;
int m_uniqueId;
- LayerAndroid* m_relativeFixedLayer;
-
typedef SkLayer INHERITED;
};