diff options
Diffstat (limited to 'WebCore')
-rw-r--r-- | WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp | 3 | ||||
-rw-r--r-- | WebCore/platform/graphics/android/LayerAndroid.cpp | 36 | ||||
-rw-r--r-- | WebCore/platform/graphics/android/LayerAndroid.h | 6 |
3 files changed, 40 insertions, 5 deletions
diff --git a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp index f2163cc..8ea274e 100644 --- a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp +++ b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp @@ -227,6 +227,9 @@ void GraphicsLayerAndroid::updateFixedPosition() RenderLayer* renderLayer = renderLayerFromClient(m_client); RenderView* view = static_cast<RenderView*>(renderLayer->renderer()); + // We will need the Iframe flag in the LayerAndroid tree for fixed position + if (view && view->isRenderIFrame()) + m_contentLayer->setIsIframe(true); // If we are a fixed position layer, just set it if (view->isPositioned() && view->style()->position() == FixedPosition) { // We need to get the passed CSS properties for the element diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp index f969999..3706d20 100644 --- a/WebCore/platform/graphics/android/LayerAndroid.cpp +++ b/WebCore/platform/graphics/android/LayerAndroid.cpp @@ -65,6 +65,7 @@ LayerAndroid::LayerAndroid(RenderLayer* owner, bool isRootLayer) : SkLayer(), m_isRootLayer(isRootLayer), m_haveClip(false), m_isFixed(false), + m_isIframe(false), m_preserves3D(false), m_anchorPointZ(0), m_recordingPicture(0), @@ -83,7 +84,7 @@ LayerAndroid::LayerAndroid(RenderLayer* owner, bool isRootLayer) : SkLayer(), m_preserves3D = false; m_dirty = false; - + m_iframeOffset.set(0,0); #ifdef DEBUG_COUNT ClassTracker::instance()->increment("LayerAndroid"); #endif @@ -92,6 +93,7 @@ LayerAndroid::LayerAndroid(RenderLayer* owner, bool isRootLayer) : SkLayer(), LayerAndroid::LayerAndroid(const LayerAndroid& layer) : SkLayer(layer), m_isRootLayer(layer.m_isRootLayer), m_haveClip(layer.m_haveClip), + m_isIframe(layer.m_isIframe), m_extra(0), // deliberately not copied m_uniqueId(layer.m_uniqueId), m_drawingTexture(0), @@ -115,7 +117,7 @@ LayerAndroid::LayerAndroid(const LayerAndroid& layer) : SkLayer(layer), m_fixedMarginRight = layer.m_fixedMarginRight; m_fixedMarginBottom = layer.m_fixedMarginBottom; m_fixedRect = layer.m_fixedRect; - + m_iframeOffset = layer.m_iframeOffset; m_recordingPicture = layer.m_recordingPicture; SkSafeRef(m_recordingPicture); @@ -144,6 +146,7 @@ LayerAndroid::LayerAndroid(SkPicture* picture) : SkLayer(), m_isRootLayer(true), m_haveClip(false), m_isFixed(false), + m_isIframe(false), m_recordingPicture(picture), m_contentsImage(0), m_extra(0), @@ -158,6 +161,7 @@ LayerAndroid::LayerAndroid(SkPicture* picture) : SkLayer(), m_backgroundColor = 0; m_dirty = false; SkSafeRef(m_recordingPicture); + m_iframeOffset.set(0,0); #ifdef DEBUG_COUNT ClassTracker::instance()->increment("LayerAndroid"); #endif @@ -466,9 +470,31 @@ const LayerAndroid* LayerAndroid::find(int* xPtr, int* yPtr, SkPicture* root) co /////////////////////////////////////////////////////////////////////////////// -void LayerAndroid::updateFixedLayersPositions(const SkRect& viewport) +void LayerAndroid::updateFixedLayersPositions(SkRect viewport, LayerAndroid* parentIframeLayer) { + // If this is an iframe, accumulate the offset from the parent with + // current position, and change the parent pointer. + if (m_isIframe) { + // If this is the top level, take the current position + SkPoint parentOffset; + parentOffset.set(0,0); + if (parentIframeLayer) + parentOffset = parentIframeLayer->getPosition(); + + m_iframeOffset = parentOffset + getPosition(); + + parentIframeLayer = this; + } + if (m_isFixed) { + // So if this is a fixed layer inside a iframe, use the iframe offset + // and the iframe's size as the viewport and pass to the children + if (parentIframeLayer) { + viewport = SkRect::MakeXYWH(parentIframeLayer->m_iframeOffset.fX, + parentIframeLayer->m_iframeOffset.fY, + parentIframeLayer->getSize().width(), + parentIframeLayer->getSize().height()); + } float w = viewport.width(); float h = viewport.height(); float dx = viewport.fLeft; @@ -500,7 +526,7 @@ void LayerAndroid::updateFixedLayersPositions(const SkRect& viewport) int count = this->countChildren(); for (int i = 0; i < count; i++) - this->getChild(i)->updateFixedLayersPositions(viewport); + this->getChild(i)->updateFixedLayersPositions(viewport, parentIframeLayer); } void LayerAndroid::updatePositions() @@ -1207,6 +1233,8 @@ void LayerAndroid::dumpLayers(FILE* file, int indentLevel) const writeIntVal(file, indentLevel + 1, "haveClip", m_haveClip); writeIntVal(file, indentLevel + 1, "isRootLayer", m_isRootLayer); writeIntVal(file, indentLevel + 1, "isFixed", m_isFixed); + writeIntVal(file, indentLevel + 1, "m_isIframe", m_isIframe); + writePoint(file, indentLevel + 1, "m_iframeOffset", m_iframeOffset); writeFloatVal(file, indentLevel + 1, "opacity", getOpacity()); writeSize(file, indentLevel + 1, "size", getSize()); diff --git a/WebCore/platform/graphics/android/LayerAndroid.h b/WebCore/platform/graphics/android/LayerAndroid.h index 7d4eac9..c315488 100644 --- a/WebCore/platform/graphics/android/LayerAndroid.h +++ b/WebCore/platform/graphics/android/LayerAndroid.h @@ -202,7 +202,7 @@ public: This call is recursive, so it should be called on the root of the hierarchy. */ - void updateFixedLayersPositions(const SkRect& viewPort); + void updateFixedLayersPositions(SkRect viewPort, LayerAndroid* parentIframeLayer = 0); /** Call this to update the position attribute, so that later calls like bounds() will report the corrected position. @@ -248,6 +248,8 @@ public: RenderLayer* owningLayer() const { return m_owningLayer; } + void setIsIframe(bool isIframe) { m_isIframe = isIframe; } + protected: virtual void onDraw(SkCanvas*, SkScalar opacity); @@ -266,6 +268,7 @@ private: bool m_haveClip; bool m_isFixed; bool m_backgroundColorSet; + bool m_isIframe; SkLength m_fixedLeft; SkLength m_fixedTop; @@ -277,6 +280,7 @@ private: SkLength m_fixedMarginBottom; SkRect m_fixedRect; + SkPoint m_iframeOffset; // When fixed element is undefined or auto, the render layer's position // is needed for offset computation IntPoint m_renderLayerPos; |