From 7e6e4dd41950ef98c67ee99be2d67daf563009ca Mon Sep 17 00:00:00 2001 From: "Shimeng (Simon) Wang" Date: Thu, 14 Jul 2011 15:13:53 -0700 Subject: [PATCH] Add android specific virtual function to GraphicsLayerClient. This lets the GraphicsLayerClient instance decides whether it has owning RenderLayer, instead of using static_cast. This makes overflow'ed iframe scrollable again. This change also reverts Tenghui's CL: https://android-git.corp.google.com/g/#change,115508 Tested on scrollable iframe and inline video. issue: 4902019 Change-Id: I252f5432b0750c5cac0a4404663e1730ef006cfc --- Source/WebCore/platform/graphics/GraphicsLayerClient.h | 7 +++++++ .../platform/graphics/android/GraphicsLayerAndroid.cpp | 15 +++++++-------- Source/WebCore/rendering/RenderLayerBacking.h | 3 +++ Source/WebCore/rendering/RenderLayerCompositor.cpp | 9 --------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Source/WebCore/platform/graphics/GraphicsLayerClient.h b/Source/WebCore/platform/graphics/GraphicsLayerClient.h index afb297df9..aab176b85 100644 --- a/Source/WebCore/platform/graphics/GraphicsLayerClient.h +++ b/Source/WebCore/platform/graphics/GraphicsLayerClient.h @@ -32,6 +32,9 @@ namespace WebCore { class GraphicsContext; class GraphicsLayer; +#if PLATFORM(ANDROID) +class RenderLayer; +#endif class IntPoint; class IntRect; class FloatPoint; @@ -54,6 +57,10 @@ class GraphicsLayerClient { public: virtual ~GraphicsLayerClient() {} +#if PLATFORM(ANDROID) + virtual RenderLayer* owningLayer() const { return 0; } +#endif + // Callback for when hardware-accelerated animation started. virtual void notifyAnimationStarted(const GraphicsLayer*, double time) = 0; diff --git a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp index fc9d85f9b..fb41ccb62 100644 --- a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp @@ -107,9 +107,7 @@ SkLength convertLength(Length len) static RenderLayer* renderLayerFromClient(GraphicsLayerClient* client) { - if (client) - return static_cast(client)->owningLayer(); - return 0; + return client ? client->owningLayer() : 0; } GraphicsLayerAndroid::GraphicsLayerAndroid(GraphicsLayerClient* client) : @@ -220,10 +218,9 @@ void GraphicsLayerAndroid::removeFromParent() void GraphicsLayerAndroid::updateFixedPosition() { - if (!m_client) - return; - RenderLayer* renderLayer = renderLayerFromClient(m_client); + if (!renderLayer) + return; RenderView* view = static_cast(renderLayer->renderer()); if (!view) @@ -316,8 +313,8 @@ void GraphicsLayerAndroid::setSize(const FloatSize& size) // If it is a media layer the size may have changed as a result of the media // element (e.g. plugin) gaining focus. Therefore, we must sync the size of // the focus' outline so that our UI thread can draw accordingly. - if (m_contentLayer->isMedia() && m_client) { - RenderLayer* layer = renderLayerFromClient(m_client); + RenderLayer* layer = renderLayerFromClient(m_client); + if (layer && m_contentLayer->isMedia()) { RenderBox* box = layer->renderBox(); int outline = box->view()->maximalOutlineSize(); static_cast(m_contentLayer)->setOutlineSize(outline); @@ -554,6 +551,8 @@ bool GraphicsLayerAndroid::repaint() IntRect layerBounds(0, 0, m_size.width(), m_size.height()); RenderLayer* layer = renderLayerFromClient(m_client); + if (!layer) + return false; if (m_foregroundLayer) { PaintingPhase phase(this); // Paint the background into a separate context. diff --git a/Source/WebCore/rendering/RenderLayerBacking.h b/Source/WebCore/rendering/RenderLayerBacking.h index f1b8972ae..9e682098e 100644 --- a/Source/WebCore/rendering/RenderLayerBacking.h +++ b/Source/WebCore/rendering/RenderLayerBacking.h @@ -59,6 +59,9 @@ public: RenderLayerBacking(RenderLayer*); ~RenderLayerBacking(); +#if PLATFORM(ANDROID) + virtual +#endif RenderLayer* owningLayer() const { return m_owningLayer; } enum UpdateDepth { CompositingChildren, AllDescendants }; diff --git a/Source/WebCore/rendering/RenderLayerCompositor.cpp b/Source/WebCore/rendering/RenderLayerCompositor.cpp index 66dcf403d..786f8067c 100644 --- a/Source/WebCore/rendering/RenderLayerCompositor.cpp +++ b/Source/WebCore/rendering/RenderLayerCompositor.cpp @@ -1520,15 +1520,6 @@ bool RenderLayerCompositor::needsContentsCompositingLayer(const RenderLayer* lay bool RenderLayerCompositor::requiresScrollLayer(RootLayerAttachment attachment) const { -#if PLATFORM(ANDROID) - // Recently, RenderLayerCompositor is changed to be a subclass of - // GraphicsLayerClient, and it is used for iframe. - // http://trac.webkit.org/changeset/75262 - // We have our own support for iframe, before we embrace this new approach, - // we will disable it. - // TODO: Investigate how to utilize this way to support iframe. - return false; -#endif // We need to handle our own scrolling if we're: return !m_renderView->frameView()->platformWidget() // viewless (i.e. non-Mac, or Mac in WebKit2) || attachment == RootLayerAttachedViaEnclosingFrame; // a composited frame on Mac -- 2.11.0