diff options
Diffstat (limited to 'Source/WebCore/platform')
12 files changed, 290 insertions, 97 deletions
diff --git a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp index fee94d3..3cf863e 100644 --- a/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/BaseLayerAndroid.cpp @@ -292,7 +292,7 @@ void BaseLayerAndroid::updateLayerPositions(const SkRect& visibleRect) if (!compositedRoot) return; TransformationMatrix ident; - compositedRoot->updateFixedLayersPositions(visibleRect); + compositedRoot->updateLayerPositions(visibleRect); FloatRect clip(0, 0, content()->width(), content()->height()); compositedRoot->updateGLPositionsAndScale( ident, clip, 1, m_state->zoomManager()->layersScale()); diff --git a/Source/WebCore/platform/graphics/android/FixedLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/FixedLayerAndroid.cpp index 67e2342..ebadeaf 100644 --- a/Source/WebCore/platform/graphics/android/FixedLayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/FixedLayerAndroid.cpp @@ -15,7 +15,7 @@ namespace WebCore { FixedLayerAndroid::FixedLayerAndroid(const FixedLayerAndroid& layer) - : LayerAndroid(layer, LayerAndroid::FixedLayer) + : LayerAndroid(layer) , m_fixedLeft(layer.m_fixedLeft) , m_fixedTop(layer.m_fixedTop) , m_fixedRight(layer.m_fixedRight) @@ -29,10 +29,10 @@ FixedLayerAndroid::FixedLayerAndroid(const FixedLayerAndroid& layer) { } -LayerAndroid* FixedLayerAndroid::updateFixedLayerPosition(SkRect viewport, - LayerAndroid* parentIframeLayer) +IFrameLayerAndroid* FixedLayerAndroid::updatePosition(SkRect viewport, + IFrameLayerAndroid* parentIframeLayer) { - LayerAndroid* iframeLayer = LayerAndroid::updateFixedLayerPosition(viewport, parentIframeLayer); + IFrameLayerAndroid* iframeLayer = LayerAndroid::updatePosition(viewport, parentIframeLayer); // 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 diff --git a/Source/WebCore/platform/graphics/android/FixedLayerAndroid.h b/Source/WebCore/platform/graphics/android/FixedLayerAndroid.h index 2578075..6870c1d 100644 --- a/Source/WebCore/platform/graphics/android/FixedLayerAndroid.h +++ b/Source/WebCore/platform/graphics/android/FixedLayerAndroid.h @@ -20,6 +20,7 @@ #if USE(ACCELERATED_COMPOSITING) #include "LayerAndroid.h" +#include "IFrameLayerAndroid.h" namespace WebCore { @@ -56,13 +57,14 @@ class FixedLayerAndroid : public LayerAndroid { public: FixedLayerAndroid(RenderLayer* owner) - : LayerAndroid(owner, LayerAndroid::FixedLayer) {} + : LayerAndroid(owner) {} FixedLayerAndroid(const LayerAndroid& layer) - : LayerAndroid(layer, LayerAndroid::FixedLayer) {} + : LayerAndroid(layer) {} FixedLayerAndroid(const FixedLayerAndroid& layer); virtual ~FixedLayerAndroid() {}; virtual LayerAndroid* copy() const { return new FixedLayerAndroid(*this); } + virtual SubclassType subclassType() { return LayerAndroid::FixedLayer; } friend void android::serializeLayer(LayerAndroid* layer, SkWStream* stream); friend LayerAndroid* android::deserializeLayer(int version, SkStream* stream); @@ -92,8 +94,8 @@ public: setShouldInheritFromRootTransform(true); } - virtual LayerAndroid* updateFixedLayerPosition(SkRect viewPort, - LayerAndroid* parentIframeLayer); + virtual IFrameLayerAndroid* updatePosition(SkRect viewPort, + IFrameLayerAndroid* parentIframeLayer); virtual void contentDraw(SkCanvas* canvas, PaintStyle style); diff --git a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp index 0ee6443..447ab28 100644 --- a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp @@ -24,6 +24,8 @@ #include "FloatRect.h" #include "FixedLayerAndroid.h" #include "GraphicsContext.h" +#include "IFrameContentLayerAndroid.h" +#include "IFrameLayerAndroid.h" #include "Image.h" #include "ImagesManager.h" #include "Layer.h" @@ -233,8 +235,12 @@ void GraphicsLayerAndroid::updateFixedPosition() return; // We will need the Iframe flag in the LayerAndroid tree for fixed position - if (view->isRenderIFrame()) - m_contentLayer->setIsIframe(true); + if (view->isRenderIFrame() && !m_contentLayer->isIFrame()) { + LayerAndroid* layer = new IFrameLayerAndroid(*m_contentLayer); + m_contentLayer->unref(); + m_contentLayer = layer; + } + // 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 @@ -533,8 +539,7 @@ void GraphicsLayerAndroid::updateScrollingLayers() // No need to copy the children as they will be removed and synced. m_contentLayer->removeChildren(); // Replace the content layer with a scrollable layer. - LayerAndroid* layer = new ScrollableLayerAndroid(*m_contentLayer); - layer->setIsIframe(true); + LayerAndroid* layer = new IFrameContentLayerAndroid(*m_contentLayer); m_contentLayer->unref(); m_contentLayer = layer; if (m_parent) { @@ -578,10 +583,10 @@ void GraphicsLayerAndroid::updateScrollOffset() { if (m_foregroundLayer) { IntSize scroll = layer->scrolledContentOffset(); m_foregroundLayer->setScrollOffset(IntPoint(scroll.width(), scroll.height())); - } else if (m_contentLayer->contentIsScrollable()) { + } else if (m_contentLayer->isIFrameContent()) { IntPoint p(layer->renderer()->frame()->view()->scrollX(), layer->renderer()->frame()->view()->scrollY()); - static_cast<ScrollableLayerAndroid*>(m_contentLayer)->setIFrameScrollOffset(p); + static_cast<IFrameContentLayerAndroid*>(m_contentLayer)->setIFrameScrollOffset(p); } askForSync(); } @@ -668,9 +673,9 @@ bool GraphicsLayerAndroid::repaint() m_contentLayer->checkForPictureOptimizations(); // Check for a scrollable iframe and report the scrolling // limits based on the view size. - if (m_contentLayer->contentIsScrollable()) { + if (m_contentLayer->isIFrameContent()) { FrameView* view = layer->renderer()->frame()->view(); - static_cast<ScrollableLayerAndroid*>(m_contentLayer)->setScrollLimits( + static_cast<IFrameContentLayerAndroid*>(m_contentLayer)->setScrollLimits( m_position.x(), m_position.y(), view->layoutWidth(), view->layoutHeight()); LOG("setScrollLimits(%.2f, %.2f, w: %d h: %d) layer %d, frame scroll position is %d, %d", m_position.x(), m_position.y(), view->layoutWidth(), view->layoutHeight(), diff --git a/Source/WebCore/platform/graphics/android/IFrameContentLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/IFrameContentLayerAndroid.cpp new file mode 100644 index 0000000..70b5c67 --- /dev/null +++ b/Source/WebCore/platform/graphics/android/IFrameContentLayerAndroid.cpp @@ -0,0 +1,42 @@ +#include "config.h" +#include "IFrameContentLayerAndroid.h" + +#if USE(ACCELERATED_COMPOSITING) + +#include <cutils/log.h> +#include <wtf/CurrentTime.h> +#include <wtf/text/CString.h> +#define XLOGC(...) android_printLog(ANDROID_LOG_DEBUG, "IFrameContentLayerAndroid", __VA_ARGS__) + +namespace WebCore { + +bool IFrameContentLayerAndroid::scrollTo(int x, int y) +{ + IntRect scrollBounds; + getScrollBounds(&scrollBounds); + if (!scrollBounds.width() && !scrollBounds.height()) + return false; + SkScalar newX = SkScalarPin(x, scrollBounds.x(), scrollBounds.width()); + SkScalar newY = SkScalarPin(y, scrollBounds.y(), scrollBounds.height()); + // Check for no change. + if (newX == m_iframeScrollOffset.x() && newY == m_iframeScrollOffset.y()) + return false; + newX = newX - m_iframeScrollOffset.x(); + newY = newY - m_iframeScrollOffset.y(); + setScrollOffset(IntPoint(newX, newY)); + return true; +} + +void IFrameContentLayerAndroid::getScrollRect(SkIRect* out) const +{ + const SkPoint& pos = getPosition(); + out->fLeft = m_scrollLimits.fLeft - pos.fX + m_iframeScrollOffset.x(); + out->fTop = m_scrollLimits.fTop - pos.fY + m_iframeScrollOffset.y(); + + out->fRight = getSize().width() - m_scrollLimits.width(); + out->fBottom = getSize().height() - m_scrollLimits.height(); +} + +} // namespace WebCore + +#endif // USE(ACCELERATED_COMPOSITING) diff --git a/Source/WebCore/platform/graphics/android/IFrameContentLayerAndroid.h b/Source/WebCore/platform/graphics/android/IFrameContentLayerAndroid.h new file mode 100644 index 0000000..64b2d06 --- /dev/null +++ b/Source/WebCore/platform/graphics/android/IFrameContentLayerAndroid.h @@ -0,0 +1,78 @@ +/* + * Copyright 2012, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef IFrameContentLayerAndroid_h +#define IFrameContentLayerAndroid_h + +#if USE(ACCELERATED_COMPOSITING) + +#include "ScrollableLayerAndroid.h" + +namespace WebCore { + +class IFrameContentLayerAndroid : public ScrollableLayerAndroid { + +public: + IFrameContentLayerAndroid(RenderLayer* owner) + : ScrollableLayerAndroid(owner) {} + IFrameContentLayerAndroid(const ScrollableLayerAndroid& layer) + : ScrollableLayerAndroid(layer) {} + IFrameContentLayerAndroid(const LayerAndroid& layer) + : ScrollableLayerAndroid(layer) {} + IFrameContentLayerAndroid(const IFrameContentLayerAndroid& layer) + : ScrollableLayerAndroid(layer) + , m_iframeScrollOffset(layer.m_iframeScrollOffset) {} + + virtual ~IFrameContentLayerAndroid() {}; + + // isIFrame() return true for compatibility reason (see ViewStateSerializer) + virtual bool isIFrame() const { return true; } + virtual bool isIFrameContent() const { return true; } + + virtual LayerAndroid* copy() const { return new IFrameContentLayerAndroid(*this); } + virtual SubclassType subclassType() { return LayerAndroid::IFrameContentLayer; } + + // Scrolls to the given position in the layer. + // Returns whether or not any scrolling was required. + virtual bool scrollTo(int x, int y); + + // Fills the rect with the current scroll offset and the maximum scroll offset. + // fLeft = scrollX + // fTop = scrollY + // fRight = maxScrollX + // fBottom = maxScrollY + virtual void getScrollRect(SkIRect*) const; + + void setIFrameScrollOffset(IntPoint offset) { m_iframeScrollOffset = offset; } + +private: + IntPoint m_iframeScrollOffset; +}; + +} + +#endif // USE(ACCELERATED_COMPOSITING) + +#endif // IFrameContentLayerAndroid_h diff --git a/Source/WebCore/platform/graphics/android/IFrameLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/IFrameLayerAndroid.cpp new file mode 100644 index 0000000..dfff91b --- /dev/null +++ b/Source/WebCore/platform/graphics/android/IFrameLayerAndroid.cpp @@ -0,0 +1,42 @@ +#include "config.h" +#include "IFrameLayerAndroid.h" + +#if USE(ACCELERATED_COMPOSITING) + +#include <cutils/log.h> +#include <wtf/CurrentTime.h> +#include <wtf/text/CString.h> + +#include "DumpLayer.h" + +#define XLOGC(...) android_printLog(ANDROID_LOG_DEBUG, "IFrameLayerAndroid", __VA_ARGS__) + +namespace WebCore { + +IFrameLayerAndroid* IFrameLayerAndroid::updatePosition(SkRect viewport, + IFrameLayerAndroid* parentIframeLayer) +{ + // As we are an iframe, accumulate the offset from the parent with + // the current position, and change the parent pointer. + + // If this is the top level, take the current position + SkPoint parentOffset; + parentOffset.set(0,0); + if (parentIframeLayer) + parentOffset = parentIframeLayer->getPosition(); + + SkPoint offset = parentOffset + getPosition(); + m_iframeOffset = IntPoint(offset.fX, offset.fY); + + return this; +} + +void IFrameLayerAndroid::dumpLayer(FILE* file, int indentLevel) const +{ + writeIntVal(file, indentLevel + 1, "m_isIframe", true); + writeIntPoint(file, indentLevel + 1, "m_iframeOffset", m_iframeOffset); +} + +} // namespace WebCore + +#endif // USE(ACCELERATED_COMPOSITING) diff --git a/Source/WebCore/platform/graphics/android/IFrameLayerAndroid.h b/Source/WebCore/platform/graphics/android/IFrameLayerAndroid.h new file mode 100644 index 0000000..e12188a --- /dev/null +++ b/Source/WebCore/platform/graphics/android/IFrameLayerAndroid.h @@ -0,0 +1,68 @@ +/* + * Copyright 2012, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef IFrameLayerAndroid_h +#define IFrameLayerAndroid_h + +#if USE(ACCELERATED_COMPOSITING) + +#include "LayerAndroid.h" + +namespace WebCore { + +class IFrameLayerAndroid : public LayerAndroid { + +public: + IFrameLayerAndroid(RenderLayer* owner) + : LayerAndroid(owner) {} + IFrameLayerAndroid(const LayerAndroid& layer) + : LayerAndroid(layer) {} + IFrameLayerAndroid(const IFrameLayerAndroid& layer) + : LayerAndroid(layer) + , m_iframeOffset(layer.m_iframeOffset) {} + + virtual ~IFrameLayerAndroid() {}; + + virtual bool isIFrame() const { return true; } + + virtual LayerAndroid* copy() const { return new IFrameLayerAndroid(*this); } + virtual SubclassType subclassType() { return LayerAndroid::IFrameLayer; } + + virtual IFrameLayerAndroid* updatePosition(SkRect viewport, + IFrameLayerAndroid* parentIframeLayer); + + virtual void dumpLayer(FILE*, int indentLevel) const; + + const IntPoint& iframeOffset() const { return m_iframeOffset; } + +private: + IntPoint m_iframeOffset; +}; + +} + +#endif // USE(ACCELERATED_COMPOSITING) + +#endif // IFrameLayerAndroid_h diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp index aaa57d6..c78540c 100644 --- a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp @@ -64,9 +64,8 @@ private: /////////////////////////////////////////////////////////////////////////////// -LayerAndroid::LayerAndroid(RenderLayer* owner, SubclassType subclassType) : Layer(), +LayerAndroid::LayerAndroid(RenderLayer* owner) : Layer(), m_haveClip(false), - m_isIframe(false), m_backfaceVisibility(true), m_visible(true), m_preserves3D(false), @@ -80,7 +79,6 @@ LayerAndroid::LayerAndroid(RenderLayer* owner, SubclassType subclassType) : Laye m_lastComputeTextureSize(0), m_owningLayer(owner), m_type(LayerAndroid::WebCoreLayer), - m_subclassType(subclassType), m_hasText(true), m_intrinsicallyComposited(true), m_layerGroup(0) @@ -95,9 +93,8 @@ LayerAndroid::LayerAndroid(RenderLayer* owner, SubclassType subclassType) : Laye #endif } -LayerAndroid::LayerAndroid(const LayerAndroid& layer, SubclassType subclassType) : Layer(layer), +LayerAndroid::LayerAndroid(const LayerAndroid& layer) : Layer(layer), m_haveClip(layer.m_haveClip), - m_isIframe(layer.m_isIframe), m_zValue(layer.m_zValue), m_uniqueId(layer.m_uniqueId), m_owningLayer(layer.m_owningLayer), @@ -115,14 +112,7 @@ LayerAndroid::LayerAndroid(const LayerAndroid& layer, SubclassType subclassType) m_visible = layer.m_visible; m_backgroundColor = layer.m_backgroundColor; - if (subclassType == LayerAndroid::CopyLayer) - m_subclassType = layer.m_subclassType; - else - m_subclassType = subclassType; - - m_iframeOffset = layer.m_iframeOffset; m_offset = layer.m_offset; - m_iframeScrollOffset = layer.m_iframeScrollOffset; m_recordingPicture = layer.m_recordingPicture; SkSafeRef(m_recordingPicture); @@ -174,7 +164,6 @@ void LayerAndroid::checkForPictureOptimizations() LayerAndroid::LayerAndroid(SkPicture* picture) : Layer(), m_haveClip(false), - m_isIframe(false), m_recordingPicture(picture), m_zValue(0), m_uniqueId(++gUniqueId), @@ -183,7 +172,6 @@ LayerAndroid::LayerAndroid(SkPicture* picture) : Layer(), m_lastComputeTextureSize(0), m_owningLayer(0), m_type(LayerAndroid::NavCacheLayer), - m_subclassType(LayerAndroid::StandardLayer), m_hasText(true), m_intrinsicallyComposited(true), m_layerGroup(0) @@ -389,40 +377,24 @@ void LayerAndroid::clipInner(SkTDArray<SkRect>* region, getChild(i)->clipInner(region, m_haveClip ? localBounds : local); } -LayerAndroid* LayerAndroid::updateFixedLayerPosition(SkRect viewport, - LayerAndroid* parentIframeLayer) +IFrameLayerAndroid* LayerAndroid::updatePosition(SkRect viewport, + IFrameLayerAndroid* parentIframeLayer) { - LayerAndroid* iframe = 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 (iframe) - parentOffset = iframe->getPosition(); - - SkPoint offset = parentOffset + getPosition(); - m_iframeOffset = IntPoint(offset.fX, offset.fY); - - iframe = this; - } - - return iframe; + // subclasses can implement this virtual function to modify their position + return parentIframeLayer; } -void LayerAndroid::updateFixedLayersPositions(SkRect viewport, LayerAndroid* parentIframeLayer) +void LayerAndroid::updateLayerPositions(SkRect viewport, IFrameLayerAndroid* parentIframeLayer) { XLOG("updating fixed positions, using viewport %fx%f - %fx%f", viewport.fLeft, viewport.fTop, viewport.width(), viewport.height()); - LayerAndroid* iframeLayer = updateFixedLayerPosition(viewport, parentIframeLayer); + IFrameLayerAndroid* iframeLayer = updatePosition(viewport, parentIframeLayer); int count = this->countChildren(); for (int i = 0; i < count; i++) - this->getChild(i)->updateFixedLayersPositions(viewport, iframeLayer); + this->getChild(i)->updateLayerPositions(viewport, iframeLayer); } void LayerAndroid::updatePositions() @@ -609,7 +581,7 @@ void LayerAndroid::showLayer(int indent) m_clippingRect.width(), m_clippingRect.height()); XLOGC("%s %s (%d) [%d:0x%x] - %s %s - area (%d, %d, %d, %d) - visible (%d, %d, %d, %d) " "clip (%d, %d, %d, %d) %s %s prepareContext(%x), pic w: %d h: %d", - spaces, subclassName().latin1().data(), m_subclassType, uniqueId(), m_owningLayer, + spaces, subclassName().latin1().data(), subclassType(), uniqueId(), m_owningLayer, needsTexture() ? "needs a texture" : "no texture", m_imageCRC ? "has an image" : "no image", tr.x(), tr.y(), tr.width(), tr.height(), @@ -1035,8 +1007,6 @@ void LayerAndroid::dumpLayer(FILE* file, int indentLevel) const writeIntVal(file, indentLevel + 1, "layerId", m_uniqueId); writeIntVal(file, indentLevel + 1, "haveClip", m_haveClip); writeIntVal(file, indentLevel + 1, "isFixed", isFixed()); - writeIntVal(file, indentLevel + 1, "m_isIframe", m_isIframe); - writeIntPoint(file, indentLevel + 1, "m_iframeOffset", m_iframeOffset); writeFloatVal(file, indentLevel + 1, "opacity", getOpacity()); writeSize(file, indentLevel + 1, "size", getSize()); diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.h b/Source/WebCore/platform/graphics/android/LayerAndroid.h index 4110aac..86c2851 100644 --- a/Source/WebCore/platform/graphics/android/LayerAndroid.h +++ b/Source/WebCore/platform/graphics/android/LayerAndroid.h @@ -67,6 +67,7 @@ class AndroidAnimation; class BaseTileTexture; class GLWebViewState; class LayerMergeState; +class IFrameLayerAndroid; class RenderLayer; class TiledPage; class PaintedSurface; @@ -89,23 +90,28 @@ public: class TEST_EXPORT LayerAndroid : public Layer { public: typedef enum { UndefinedLayer, WebCoreLayer, UILayer, NavCacheLayer } LayerType; - typedef enum { StandardLayer, CopyLayer, FixedLayer } SubclassType; + typedef enum { StandardLayer, FixedLayer, ScrollableLayer, + IFrameLayer, IFrameContentLayer } SubclassType; String subclassName() { - switch (m_subclassType) { + switch (subclassType()) { case LayerAndroid::StandardLayer: return "StandardLayer"; - case LayerAndroid::CopyLayer: - return "CopyLayer"; case LayerAndroid::FixedLayer: return "FixedLayer"; + case LayerAndroid::ScrollableLayer: + return "ScrollableLayer"; + case LayerAndroid::IFrameLayer: + return "IFrameLayer"; + case LayerAndroid::IFrameContentLayer: + return "IFrameContentLayer"; } return "Undefined"; } - LayerAndroid(RenderLayer* owner, SubclassType type = LayerAndroid::StandardLayer); - LayerAndroid(const LayerAndroid& layer, SubclassType type = LayerAndroid::CopyLayer); + LayerAndroid(RenderLayer* owner); + LayerAndroid(const LayerAndroid& layer); LayerAndroid(SkPicture*); virtual ~LayerAndroid(); @@ -156,10 +162,7 @@ public: const FloatRect& drawClip() { return m_clippingRect; } const IntPoint& scrollOffset() const { return m_offset; } - const IntPoint& iframeOffset() const { return m_iframeOffset; } - const IntPoint& iframeScrollOffset() const { return m_iframeScrollOffset; } void setScrollOffset(IntPoint offset) { m_offset = offset; } - void setIFrameScrollOffset(IntPoint offset) { m_iframeScrollOffset = offset; } void setBackgroundColor(SkColor color); void setMaskLayer(LayerAndroid*); void setMasksToBounds(bool masksToBounds) @@ -196,9 +199,9 @@ public: This call is recursive, so it should be called on the root of the hierarchy. */ - void updateFixedLayersPositions(SkRect viewPort, LayerAndroid* parentIframeLayer = 0); - virtual LayerAndroid* updateFixedLayerPosition(SkRect viewport, - LayerAndroid* parentIframeLayer); + void updateLayerPositions(SkRect viewPort, IFrameLayerAndroid* parentIframeLayer = 0); + virtual IFrameLayerAndroid* updatePosition(SkRect viewport, + IFrameLayerAndroid* parentIframeLayer); /** Call this to update the position attribute, so that later calls like bounds() will report the corrected position. @@ -243,11 +246,11 @@ public: virtual bool isMedia() const { return false; } virtual bool isVideo() const { return false; } virtual bool isFixed() const { return false; } + virtual bool isIFrame() const { return false; } + virtual bool isIFrameContent() const { return false; } RenderLayer* owningLayer() const { return m_owningLayer; } - void setIsIframe(bool isIframe) { m_isIframe = isIframe; } - bool isIFrame() const { return m_isIframe; } float zValue() const { return m_zValue; } // ViewStateSerializer friends @@ -262,7 +265,7 @@ public: virtual bool updateWithLayer(LayerAndroid*); LayerType type() { return m_type; } - SubclassType subclassType() { return m_subclassType; } + virtual SubclassType subclassType() { return LayerAndroid::StandardLayer; } bool hasText() { return m_hasText; } void checkForPictureOptimizations(); @@ -282,8 +285,6 @@ public: protected: virtual void onDraw(SkCanvas*, SkScalar opacity, android::DrawExtra* extra, PaintStyle style); IntPoint m_offset; - IntPoint m_iframeOffset; - IntPoint m_iframeScrollOffset; TransformationMatrix m_drawTransform; private: @@ -301,7 +302,6 @@ private: bool m_haveClip; bool m_backgroundColorSet; - bool m_isIframe; bool m_backfaceVisibility; bool m_visible; diff --git a/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp index 205727c..dffab58 100644 --- a/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.cpp @@ -21,15 +21,8 @@ bool ScrollableLayerAndroid::scrollTo(int x, int y) SkScalar newX = SkScalarPin(x, scrollBounds.x(), scrollBounds.width()); SkScalar newY = SkScalarPin(y, scrollBounds.y(), scrollBounds.height()); // Check for no change. - if (isIFrame()) { - if (newX == m_iframeScrollOffset.x() && newY == m_iframeScrollOffset.y()) - return false; - newX = newX - m_iframeScrollOffset.x(); - newY = newY - m_iframeScrollOffset.y(); - } else { - if (newX == m_offset.x() && newY == m_offset.y()) - return false; - } + if (newX == m_offset.x() && newY == m_offset.y()) + return false; setScrollOffset(IntPoint(newX, newY)); return true; } @@ -46,16 +39,8 @@ void ScrollableLayerAndroid::getScrollBounds(IntRect* out) const void ScrollableLayerAndroid::getScrollRect(SkIRect* out) const { const SkPoint& pos = getPosition(); - out->fLeft = m_scrollLimits.fLeft - pos.fX; - out->fTop = m_scrollLimits.fTop - pos.fY; - - if (isIFrame()) { - out->fLeft += m_iframeScrollOffset.x(); - out->fTop += m_iframeScrollOffset.y(); - } else { - out->fLeft += m_offset.x(); - out->fTop += m_offset.y(); - } + out->fLeft = m_scrollLimits.fLeft - pos.fX + m_offset.x(); + out->fTop = m_scrollLimits.fTop - pos.fY + m_offset.y(); out->fRight = getSize().width() - m_scrollLimits.width(); out->fBottom = getSize().height() - m_scrollLimits.height(); diff --git a/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.h b/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.h index 824804f..1f289e6 100644 --- a/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.h +++ b/Source/WebCore/platform/graphics/android/ScrollableLayerAndroid.h @@ -41,19 +41,20 @@ public: virtual bool contentIsScrollable() const { return true; } virtual LayerAndroid* copy() const { return new ScrollableLayerAndroid(*this); } + virtual SubclassType subclassType() { return LayerAndroid::ScrollableLayer; } virtual bool updateWithLayer(LayerAndroid*) { return true; } // Scrolls to the given position in the layer. // Returns whether or not any scrolling was required. - bool scrollTo(int x, int y); + virtual bool scrollTo(int x, int y); // Fills the rect with the current scroll offset and the maximum scroll offset. // fLeft = scrollX // fTop = scrollY // fRight = maxScrollX // fBottom = maxScrollY - void getScrollRect(SkIRect*) const; + virtual void getScrollRect(SkIRect*) const; void setScrollLimits(float x, float y, float width, float height) { @@ -70,7 +71,7 @@ public: friend void android::serializeLayer(LayerAndroid* layer, SkWStream* stream); friend LayerAndroid* android::deserializeLayer(int version, SkStream* stream); -private: +protected: void getScrollBounds(IntRect*) const; |