Changeset 57919 in webkit


Ignore:
Timestamp:
Apr 20, 2010 2:24:10 PM (14 years ago)
Author:
Simon Fraser
Message:

2010-04-20 Simon Fraser <Simon Fraser>

Reviewed by Dan Bernstein.

Hook compositing layers together across iframes
https://bugs.webkit.org/show_bug.cgi?id=37878

First step: if an iframe's document goes into compositing mode, also throw the parent
document into compositing mode (all the way up to the root). This is required both
to preserve layering (since parent document content can obscure iframe content),
and so that we can eventually hook the layer trees together.

Test: compositing/iframes/composited-iframe.html

  • rendering/RenderIFrame.h:
  • rendering/RenderIFrame.cpp: (WebCore::RenderIFrame::requiresLayer): In order to make an iframe composited, it also has to have a RenderLayer, so must return |true| from requiresLayer(). (WebCore::RenderIFrame::requiresAcceleratedCompositing): Returns true if the content document is in compositing mode. (WebCore::RenderIFrame::isRenderIFrame): Required so that RenderLayerCompositor can check if a renderer is an iframe. (WebCore::toRenderIFrame): Required so that RenderLayerCompositor can cast to a RenderIFrame.
  • rendering/RenderLayerCompositor.h:
  • rendering/RenderLayerCompositor.cpp: (WebCore::RenderLayerCompositor::enableCompositingMode): Call out to the RenderView when the compositing mode changes, so that the parent document can update its compositing status. (WebCore::RenderLayerCompositor::requiresCompositingLayer): Call requiresCompositingForIFrame(). (WebCore::RenderLayerCompositor::requiresCompositingForIFrame): Check to see if the iframe wants to be composited.
  • rendering/RenderObject.h: (WebCore::RenderObject::isRenderIFrame): Base class returns false.
  • rendering/RenderView.h:
  • rendering/RenderView.cpp: (WebCore::RenderView::compositingStateChanged): New method that allows an iframe to notify its parent document that a recalcStyle is required, to update compositing state.
Location:
trunk
Files:
5 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r57916 r57919  
    1313
    1414        * platform/chromium/test_expectations.txt:
     15
     162010-04-20  Simon Fraser  <simon.fraser@apple.com>
     17
     18        Reviewed by Dan Bernstein.
     19
     20        Hook compositing layers together across iframes
     21        https://bugs.webkit.org/show_bug.cgi?id=37878
     22       
     23        Testcase that has a composited iframe, and dumps the layer tree of the parent document
     24        to ensure that it also became composited.
     25
     26        * compositing/iframes/composited-iframe-expected.txt: Added.
     27        * compositing/iframes/composited-iframe.html: Added.
     28        * compositing/iframes/resources/composited-subframe.html: Added.
    1529
    16302010-04-20  Simon Fraser  <simon.fraser@apple.com>
  • trunk/WebCore/ChangeLog

    r57913 r57919  
     12010-04-20  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        Hook compositing layers together across iframes
     6        https://bugs.webkit.org/show_bug.cgi?id=37878
     7       
     8        First step: if an iframe's document goes into compositing mode, also throw the parent
     9        document into compositing mode (all the way up to the root). This is required both
     10        to preserve layering (since parent document content can obscure iframe content),
     11        and so that we can eventually hook the layer trees together.
     12
     13        Test: compositing/iframes/composited-iframe.html
     14
     15        * rendering/RenderIFrame.h:
     16        * rendering/RenderIFrame.cpp:
     17        (WebCore::RenderIFrame::requiresLayer): In order to make an iframe composited, it also has to have
     18        a RenderLayer, so must return |true| from requiresLayer().
     19        (WebCore::RenderIFrame::requiresAcceleratedCompositing): Returns true if the content document
     20        is in compositing mode.
     21        (WebCore::RenderIFrame::isRenderIFrame): Required so that RenderLayerCompositor can check
     22        if a renderer is an iframe.
     23        (WebCore::toRenderIFrame): Required so that RenderLayerCompositor can cast to a RenderIFrame.
     24
     25        * rendering/RenderLayerCompositor.h:
     26        * rendering/RenderLayerCompositor.cpp:
     27        (WebCore::RenderLayerCompositor::enableCompositingMode): Call out to the RenderView when
     28        the compositing mode changes, so that the parent document can update its compositing status.
     29        (WebCore::RenderLayerCompositor::requiresCompositingLayer): Call requiresCompositingForIFrame().
     30        (WebCore::RenderLayerCompositor::requiresCompositingForIFrame): Check to see if the iframe
     31        wants to be composited.
     32
     33        * rendering/RenderObject.h:
     34        (WebCore::RenderObject::isRenderIFrame): Base class returns false.
     35
     36        * rendering/RenderView.h:
     37        * rendering/RenderView.cpp:
     38        (WebCore::RenderView::compositingStateChanged): New method that allows an iframe to notify
     39        its parent document that a recalcStyle is required, to update compositing state.
     40
    1412010-04-20  Gavin Barraclough  <barraclough@apple.com>
    242
  • trunk/WebCore/rendering/RenderIFrame.cpp

    r57866 r57919  
    119119}
    120120
     121#if USE(ACCELERATED_COMPOSITING)
     122bool RenderIFrame::requiresLayer() const
     123{
     124    if (RenderPart::requiresLayer())
     125        return true;
     126   
     127    return requiresAcceleratedCompositing();
    121128}
     129
     130bool RenderIFrame::requiresAcceleratedCompositing() const
     131{
     132    if (!node() || !node()->hasTagName(iframeTag))
     133        return false;
     134
     135    // If the contents of the iframe are composited, then we have to be as well.
     136    HTMLIFrameElement* element = static_cast<HTMLIFrameElement*>(node());
     137    if (Document* contentDocument = element->contentDocument()) {
     138        if (RenderView* view = contentDocument->renderView())
     139            return view->usesCompositing();
     140    }
     141
     142    return false;
     143}
     144#endif
     145
     146}
  • trunk/WebCore/rendering/RenderIFrame.h

    r57866 r57919  
    3535    RenderIFrame(Element*);
    3636
     37#if USE(ACCELERATED_COMPOSITING)
     38    bool requiresAcceleratedCompositing() const;
     39#endif
     40
    3741private:
    3842    virtual void calcHeight();
     
    4044
    4145    virtual void layout();
     46
     47#if USE(ACCELERATED_COMPOSITING)
     48    virtual bool requiresLayer() const;
     49#endif
     50    virtual bool isRenderIFrame() const { return true; }
    4251
    4352    virtual const char* renderName() const { return "RenderPartObject"; } // Lying for now to avoid breaking tests
     
    4756};
    4857
     58inline RenderIFrame* toRenderIFrame(RenderObject* object)
     59{
     60    ASSERT(!object || object->isRenderIFrame());
     61    return static_cast<RenderIFrame*>(object);
     62}
     63
     64inline const RenderIFrame* toRenderIFrame(const RenderObject* object)
     65{
     66    ASSERT(!object || object->isRenderIFrame());
     67    return static_cast<const RenderIFrame*>(object);
     68}
     69
     70// This will catch anyone doing an unnecessary cast.
     71void toRenderIFrame(const RenderIFrame*);
     72
     73
    4974} // namespace WebCore
    5075
  • trunk/WebCore/rendering/RenderLayerCompositor.cpp

    r56949 r57919  
    4444#include "Page.h"
    4545#include "RenderEmbeddedObject.h"
     46#include "RenderIFrame.h"
    4647#include "RenderLayerBacking.h"
    4748#include "RenderReplica.h"
     
    117118        else
    118119            destroyRootPlatformLayer();
     120
     121        m_renderView->compositingStateChanged(m_compositing);
    119122    }
    120123}
     
    977980             || requiresCompositingForCanvas(renderer)
    978981             || requiresCompositingForPlugin(renderer)
     982             || requiresCompositingForIFrame(renderer)
    979983             || renderer->style()->backfaceVisibility() == BackfaceVisibilityHidden
    980984             || clipsCompositingDescendants(layer)
     
    10841088}
    10851089
     1090bool RenderLayerCompositor::requiresCompositingForIFrame(RenderObject* renderer) const
     1091{
     1092    return renderer->isRenderIFrame() && toRenderIFrame(renderer)->requiresAcceleratedCompositing();
     1093}
     1094
    10861095bool RenderLayerCompositor::requiresCompositingForAnimation(RenderObject* renderer) const
    10871096{
  • trunk/WebCore/rendering/RenderLayerCompositor.h

    r56949 r57919  
    182182    bool requiresCompositingForCanvas(RenderObject*) const;
    183183    bool requiresCompositingForPlugin(RenderObject*) const;
     184    bool requiresCompositingForIFrame(RenderObject*) const;
    184185    bool requiresCompositingWhenDescendantsAreCompositing(RenderObject*) const;
    185186
  • trunk/WebCore/rendering/RenderObject.h

    r57895 r57919  
    283283    virtual bool isRenderBlock() const { return false; }
    284284    virtual bool isRenderButton() const { return false; }
     285    virtual bool isRenderIFrame() const { return false; }
    285286    virtual bool isRenderImage() const { return false; }
    286287    virtual bool isRenderInline() const { return false; }
  • trunk/WebCore/rendering/RenderView.cpp

    r56646 r57919  
    709709}
    710710
     711void RenderView::compositingStateChanged(bool)
     712{
     713    Element* elt = document()->ownerElement();
     714    if (!elt)
     715        return;
     716
     717    // Trigger a recalcStyle in the parent document, to update compositing in that document.
     718    elt->setNeedsStyleRecalc(SyntheticStyleChange);
     719}
     720
    711721RenderLayerCompositor* RenderView::compositor()
    712722{
  • trunk/WebCore/rendering/RenderView.h

    r52757 r57919  
    164164    RenderLayerCompositor* compositor();
    165165    bool usesCompositing() const;
     166    void compositingStateChanged(bool nowComposited);
    166167#endif
    167168
Note: See TracChangeset for help on using the changeset viewer.