summaryrefslogtreecommitdiffstats
path: root/WebCore/platform
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform')
-rw-r--r--WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp17
-rw-r--r--WebCore/platform/graphics/android/LayerAndroid.cpp20
-rw-r--r--WebCore/platform/graphics/android/LayerAndroid.h6
3 files changed, 30 insertions, 13 deletions
diff --git a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
index 46be9bb..ab0e0ea 100644
--- a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
@@ -200,17 +200,23 @@ bool GraphicsLayerAndroid::replaceChild(GraphicsLayer* oldChild, GraphicsLayer*
{
LOG("(%x) replaceChild %x by %x", this, oldChild, newChild);
bool ret = GraphicsLayer::replaceChild(oldChild, newChild);
- m_needsSyncChildren = true;
- askForSync();
+ if (ret) {
+ m_needsSyncChildren = true;
+ askForSync();
+ }
return ret;
}
void GraphicsLayerAndroid::removeFromParent()
{
LOG("(%x) removeFromParent()", this);
+ GraphicsLayerAndroid* parent = static_cast<GraphicsLayerAndroid*>(m_parent);
GraphicsLayer::removeFromParent();
- m_needsSyncChildren = true;
- askForSync();
+ // Update the parent's children.
+ if (parent) {
+ parent->m_needsSyncChildren = true;
+ askForSync();
+ }
}
void GraphicsLayerAndroid::updateFixedPosition()
@@ -251,10 +257,11 @@ void GraphicsLayerAndroid::updateFixedPosition()
SkRect viewRect;
viewRect.set(paintingOffsetX, paintingOffsetY, paintingOffsetX + w, paintingOffsetY + h);
-
+ IntPoint renderLayerPos(renderLayer->x(), renderLayer->y());
m_contentLayer->setFixedPosition(left, top, right, bottom,
marginLeft, marginTop,
marginRight, marginBottom,
+ renderLayerPos,
viewRect);
}
}
diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp
index 004c36b..03bb11d 100644
--- a/WebCore/platform/graphics/android/LayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/LayerAndroid.cpp
@@ -101,7 +101,7 @@ LayerAndroid::LayerAndroid(const LayerAndroid& layer) : SkLayer(layer),
m_isFixed = layer.m_isFixed;
m_contentsImage = layer.m_contentsImage;
m_contentsImage->safeRef();
-
+ m_renderLayerPos = layer.m_renderLayerPos;
m_transform = layer.m_transform;
m_backgroundColor = layer.m_backgroundColor;
@@ -225,8 +225,9 @@ bool LayerAndroid::evaluateAnimations(double time) const
return hasRunningAnimations;
}
-void LayerAndroid::addAnimation(PassRefPtr<AndroidAnimation> anim)
+void LayerAndroid::addAnimation(PassRefPtr<AndroidAnimation> prpAnim)
{
+ RefPtr<AndroidAnimation> anim = prpAnim;
if (m_animations.get(anim->name()))
removeAnimation(anim->name());
m_animations.add(anim->name(), anim);
@@ -461,17 +462,20 @@ void LayerAndroid::updateFixedLayersPositions(const SkRect& viewport)
float x = dx;
float y = dy;
- // Not defined corresponds to 'auto';
- // If both left and right are auto, the w3c says we should set left
- // to zero (in left-to-right layout). So we use left if it's defined
- // or if right isn't defined.
+ // It turns out that when it is 'auto', the webkit computation will
+ // take one more factor into account, that is the original render
+ // layer's X,Y, such that it will align well with the parent's layer.
+ if (!(m_fixedLeft.defined() || m_fixedRight.defined()))
+ x += m_renderLayerPos.x();
+
+ if (!(m_fixedTop.defined() || m_fixedBottom.defined()))
+ y += m_renderLayerPos.y();
+
if (m_fixedLeft.defined() || !m_fixedRight.defined())
x += m_fixedMarginLeft.calcFloatValue(w) + m_fixedLeft.calcFloatValue(w) - m_fixedRect.fLeft;
else
x += w - m_fixedMarginRight.calcFloatValue(w) - m_fixedRight.calcFloatValue(w) - m_fixedRect.fRight;
- // Following the same reason as above, if bottom isn't defined, we apply
- // top regardless of it being defined or not.
if (m_fixedTop.defined() || !m_fixedBottom.defined())
y += m_fixedMarginTop.calcFloatValue(h) + m_fixedTop.calcFloatValue(h) - m_fixedRect.fTop;
else
diff --git a/WebCore/platform/graphics/android/LayerAndroid.h b/WebCore/platform/graphics/android/LayerAndroid.h
index 72eba0f..bb91755 100644
--- a/WebCore/platform/graphics/android/LayerAndroid.h
+++ b/WebCore/platform/graphics/android/LayerAndroid.h
@@ -138,6 +138,7 @@ public:
SkLength marginTop, // CSS margin-top property
SkLength marginRight, // CSS margin-right property
SkLength marginBottom, // CSS margin-bottom property
+ const IntPoint& renderLayerPos, // For undefined fixed position
SkRect viewRect) { // view rect, can be smaller than the layer's
m_fixedLeft = left;
m_fixedTop = top;
@@ -149,6 +150,7 @@ public:
m_fixedMarginBottom = marginBottom;
m_fixedRect = viewRect;
m_isFixed = true;
+ m_renderLayerPos = renderLayerPos;
setInheritFromRootTransform(true);
}
@@ -259,6 +261,10 @@ private:
SkLength m_fixedMarginBottom;
SkRect m_fixedRect;
+ // When fixed element is undefined or auto, the render layer's position
+ // is needed for offset computation
+ IntPoint m_renderLayerPos;
+
TransformationMatrix m_transform;
SkColor m_backgroundColor;