summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp7
-rw-r--r--WebCore/platform/graphics/android/LayerAndroid.cpp57
-rw-r--r--WebCore/platform/graphics/android/LayerAndroid.h9
-rw-r--r--WebKit/android/nav/WebView.cpp13
4 files changed, 70 insertions, 16 deletions
diff --git a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
index 7b479bf..fa4a180 100644
--- a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
@@ -250,6 +250,8 @@ void GraphicsLayerAndroid::updateFixedPosition()
m_contentLayer->setFixedPosition(left, top, right, bottom,
marginLeft, marginTop,
marginRight, marginBottom,
+ offsetFromRenderer().width(),
+ offsetFromRenderer().height(),
w, h);
}
}
@@ -431,11 +433,14 @@ void GraphicsLayerAndroid::sendImmediateRepaint()
if (rootGraphicsLayer->m_frame
&& rootGraphicsLayer->m_frame->view()) {
+ LayerAndroid* rootLayer = new LayerAndroid(true);
LayerAndroid* copyLayer = new LayerAndroid(*m_contentLayer);
+ rootLayer->addChild(copyLayer);
+ copyLayer->unref();
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());
- PlatformBridge::setUIRootLayer(m_frame->view(), copyLayer);
+ PlatformBridge::setUIRootLayer(m_frame->view(), rootLayer);
PlatformBridge::immediateRepaint(m_frame->view());
}
}
diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp
index bfb086c..d6ba0a1 100644
--- a/WebCore/platform/graphics/android/LayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/LayerAndroid.cpp
@@ -83,6 +83,7 @@ LayerAndroid::LayerAndroid(const LayerAndroid& layer) : SkLayer(layer),
m_fixedMarginTop = layer.m_fixedMarginTop;
m_fixedMarginRight = layer.m_fixedMarginRight;
m_fixedMarginBottom = layer.m_fixedMarginBottom;
+ m_fixedOffset = layer.m_fixedOffset;
m_fixedWidth = layer.m_fixedWidth;
m_fixedHeight = layer.m_fixedHeight;
@@ -249,6 +250,20 @@ const LayerAndroid* LayerAndroid::find(int x, int y) const
///////////////////////////////////////////////////////////////////////////////
+// The Layer bounds and the renderview bounds are not always indentical.
+// We need to compute the intersection to correctly compute the
+// positiong...
+static SkRect computeLayerRect(LayerAndroid* layer) {
+ SkRect layerRect, viewRect;
+ SkScalar fX, fY;
+ fX = layer->getOffset().fX;
+ fY = layer->getOffset().fY;
+ layerRect.set(0, 0, layer->getSize().width(), layer->getSize().height());
+ viewRect.set(-fX, -fY, -fX + layer->getFixedWidth(), -fY + layer->getFixedHeight());
+ layerRect.intersect(viewRect);
+ return layerRect;
+}
+
void LayerAndroid::updateFixedLayersPositions(const SkRect& viewport)
{
if (m_isFixed) {
@@ -259,15 +274,17 @@ void LayerAndroid::updateFixedLayersPositions(const SkRect& viewport)
float x = dx;
float y = dy;
+ SkRect layerRect = computeLayerRect(this);
+
if (m_fixedLeft.defined())
- x += m_fixedMarginLeft.calcFloatValue(w) + m_fixedLeft.calcFloatValue(w);
+ x += m_fixedMarginLeft.calcFloatValue(w) + m_fixedLeft.calcFloatValue(w) - layerRect.fLeft;
else if (m_fixedRight.defined())
- x += w - m_fixedMarginRight.calcFloatValue(w) - m_fixedRight.calcFloatValue(w) - m_fixedWidth;
+ x += w - m_fixedMarginRight.calcFloatValue(w) - m_fixedRight.calcFloatValue(w) - layerRect.width();
if (m_fixedTop.defined())
- y += m_fixedMarginTop.calcFloatValue(h) + m_fixedTop.calcFloatValue(h);
+ y += m_fixedMarginTop.calcFloatValue(h) + m_fixedTop.calcFloatValue(h) - layerRect.fTop;
else if (m_fixedBottom.defined())
- y += h - m_fixedMarginBottom.calcFloatValue(h) - m_fixedBottom.calcFloatValue(h) - m_fixedHeight;
+ y += h - m_fixedMarginBottom.calcFloatValue(h) - m_fixedBottom.calcFloatValue(h) - layerRect.fTop - layerRect.height();
this->setPosition(x, y);
}
@@ -334,6 +351,13 @@ void LayerAndroid::onDraw(SkCanvas* canvas, SkScalar opacity) {
canvas->drawLine(0, h, w, h, paint);
canvas->drawLine(w, h, w, 0, paint);
canvas->drawLine(w, 0, 0, 0, paint);
+
+ if (m_isFixed) {
+ SkRect layerRect = computeLayerRect(this);
+ SkPaint paint;
+ paint.setARGB(128, 0, 0, 255);
+ canvas->drawRect(layerRect, paint);
+ }
#endif
}
@@ -481,6 +505,8 @@ void LayerAndroid::dumpLayers(FILE* file, int indentLevel) const
writeHexVal(file, indentLevel + 1, "layer", (int)this);
writeIntVal(file, indentLevel + 1, "layerId", m_uniqueId);
writeIntVal(file, indentLevel + 1, "haveClip", m_haveClip);
+ writeIntVal(file, indentLevel + 1, "isRootLayer", m_isRootLayer);
+ writeIntVal(file, indentLevel + 1, "isFixed", m_isFixed);
writeFloatVal(file, indentLevel + 1, "opacity", getOpacity());
writeSize(file, indentLevel + 1, "size", getSize());
@@ -492,16 +518,19 @@ void LayerAndroid::dumpLayers(FILE* file, int indentLevel) const
if (m_doRotation)
writeFloatVal(file, indentLevel + 1, "angle", m_angleTransform);
- writeLength(file, indentLevel + 1, "fixedLeft", m_fixedLeft);
- writeLength(file, indentLevel + 1, "fixedTop", m_fixedTop);
- writeLength(file, indentLevel + 1, "fixedRight", m_fixedRight);
- writeLength(file, indentLevel + 1, "fixedBottom", m_fixedBottom);
- writeLength(file, indentLevel + 1, "fixedMarginLeft", m_fixedMarginLeft);
- writeLength(file, indentLevel + 1, "fixedMarginTop", m_fixedMarginTop);
- writeLength(file, indentLevel + 1, "fixedMarginRight", m_fixedMarginRight);
- writeLength(file, indentLevel + 1, "fixedMarginBottom", m_fixedMarginBottom);
- writeIntVal(file, indentLevel + 1, "fixedWidth", m_fixedWidth);
- writeIntVal(file, indentLevel + 1, "fixedHeight", m_fixedHeight);
+ if (m_isFixed) {
+ writeLength(file, indentLevel + 1, "fixedLeft", m_fixedLeft);
+ writeLength(file, indentLevel + 1, "fixedTop", m_fixedTop);
+ writeLength(file, indentLevel + 1, "fixedRight", m_fixedRight);
+ writeLength(file, indentLevel + 1, "fixedBottom", m_fixedBottom);
+ writeLength(file, indentLevel + 1, "fixedMarginLeft", m_fixedMarginLeft);
+ writeLength(file, indentLevel + 1, "fixedMarginTop", m_fixedMarginTop);
+ writeLength(file, indentLevel + 1, "fixedMarginRight", m_fixedMarginRight);
+ writeLength(file, indentLevel + 1, "fixedMarginBottom", m_fixedMarginBottom);
+ writePoint(file, indentLevel + 1, "fixedOffset", m_fixedOffset);
+ writeIntVal(file, indentLevel + 1, "fixedWidth", m_fixedWidth);
+ writeIntVal(file, indentLevel + 1, "fixedHeight", m_fixedHeight);
+ }
if (m_recordingPicture) {
writeIntVal(file, indentLevel + 1, "picture width", m_recordingPicture->width());
diff --git a/WebCore/platform/graphics/android/LayerAndroid.h b/WebCore/platform/graphics/android/LayerAndroid.h
index b92f4ac..e9416c1 100644
--- a/WebCore/platform/graphics/android/LayerAndroid.h
+++ b/WebCore/platform/graphics/android/LayerAndroid.h
@@ -96,6 +96,8 @@ public:
SkLength marginTop, // CSS margin-top property
SkLength marginRight, // CSS margin-right property
SkLength marginBottom, // CSS margin-bottom property
+ int offsetX, // X Offset from the renderer
+ int offsetY, // Y Offset from the renderer
int width, // visible overflow width
int height) { // visible overflow height
m_fixedLeft = left;
@@ -106,9 +108,11 @@ public:
m_fixedMarginTop = marginTop;
m_fixedMarginRight = marginRight;
m_fixedMarginBottom = marginBottom;
+ m_fixedOffset.set(offsetX, offsetY);
m_fixedWidth = width;
m_fixedHeight = height;
m_isFixed = true;
+ setInheritFromRootTransform(true);
}
void setBackgroundColor(SkColor color);
@@ -158,6 +162,10 @@ public:
}
void setExtra(DrawExtra* extra); // does not assign ownership
int uniqueId() const { return m_uniqueId; }
+ bool isFixed() { return m_isFixed; }
+ const SkPoint& getOffset() const { return m_fixedOffset; }
+ int getFixedWidth() { return m_fixedWidth; }
+ int getFixedHeight() { return m_fixedHeight; }
protected:
virtual void onDraw(SkCanvas*, SkScalar opacity);
@@ -185,6 +193,7 @@ private:
SkLength m_fixedMarginTop;
SkLength m_fixedMarginRight;
SkLength m_fixedMarginBottom;
+ SkPoint m_fixedOffset;
int m_fixedWidth;
int m_fixedHeight;
diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp
index 1155ea2..c83ceea 100644
--- a/WebKit/android/nav/WebView.cpp
+++ b/WebKit/android/nav/WebView.cpp
@@ -424,6 +424,11 @@ void drawExtras(SkCanvas* canvas, int extras)
// before we actually draw
m_rootLayer->updateFixedLayersPositions(visible);
m_rootLayer->updatePositions();
+ // We have to set the canvas' matrix on the root layer
+ // (to have fixed layers work as intended)
+ SkAutoCanvasRestore restore(canvas, true);
+ m_rootLayer->setMatrix(canvas->getTotalMatrix());
+ canvas->resetMatrix();
m_rootLayer->draw(canvas);
#endif
}
@@ -1836,8 +1841,14 @@ static void nativeDumpDisplayTree(JNIEnv* env, jobject jwebview, jstring jurl)
#if USE(ACCELERATED_COMPOSITING)
if (true) {
LayerAndroid* rootLayer = view->rootLayer();
- if (rootLayer)
+ if (rootLayer) {
+ // We have to set the canvas' matrix on the root layer
+ // (to have fixed layers work as intended)
+ SkAutoCanvasRestore restore(&canvas, true);
+ rootLayer->setMatrix(canvas.getTotalMatrix());
+ canvas.resetMatrix();
rootLayer->draw(&canvas);
+ }
}
#endif
// we're done with the file now