Changeset 166015 in webkit


Ignore:
Timestamp:
Mar 20, 2014, 4:14:31 PM (11 years ago)
Author:
Simon Fraser
Message:

FrameView::paintContents() is not called for composited content
https://bugs.webkit.org/show_bug.cgi?id=130541

Reviewed by Beth Dakin.

FrameView::paintContents() is not called for frames that have
composited contents, yet it contains code that is expected
to run for all Frames.

Fix by factoring into will/didPaintContents(), and calling
the will/did functions from RenderLayerBacking::paintIntoLayer().

Also add a SetLayoutNeededForbiddenScope check for composited-layer
painting.

  • page/FrameView.cpp:

(WebCore::FrameView::updateControlTints):
(WebCore::FrameView::willPaintContents):
(WebCore::FrameView::didPaintContents):
(WebCore::FrameView::paintContents):

  • page/FrameView.h:
  • rendering/RenderLayerBacking.cpp:

(WebCore::RenderLayerBacking::paintIntoLayer):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r166007 r166015  
     12014-03-20  Simon Fraser  <simon.fraser@apple.com>
     2
     3        FrameView::paintContents() is not called for composited content
     4        https://bugs.webkit.org/show_bug.cgi?id=130541
     5
     6        Reviewed by Beth Dakin.
     7
     8        FrameView::paintContents() is not called for frames that have
     9        composited contents, yet it contains code that is expected
     10        to run for all Frames.
     11       
     12        Fix by factoring into will/didPaintContents(), and calling
     13        the will/did functions from RenderLayerBacking::paintIntoLayer().
     14       
     15        Also add a SetLayoutNeededForbiddenScope check for composited-layer
     16        painting.
     17
     18        * page/FrameView.cpp:
     19        (WebCore::FrameView::updateControlTints):
     20        (WebCore::FrameView::willPaintContents):
     21        (WebCore::FrameView::didPaintContents):
     22        (WebCore::FrameView::paintContents):
     23        * page/FrameView.h:
     24        * rendering/RenderLayerBacking.cpp:
     25        (WebCore::RenderLayerBacking::paintIntoLayer):
     26
    1272014-03-20  Tim Horton  <timothy_horton@apple.com>
    228
  • trunk/Source/WebCore/page/FrameView.cpp

    r165652 r166015  
    34623462}
    34633463
    3464 void FrameView::paintContents(GraphicsContext* p, const IntRect& rect)
     3464void FrameView::willPaintContents(GraphicsContext* context, const IntRect& dirtyRect, PaintingState& paintingState)
     3465{
     3466    Document* document = frame().document();
     3467
     3468    if (!context->paintingDisabled())
     3469        InspectorInstrumentation::willPaint(renderView());
     3470
     3471    paintingState.isTopLevelPainter = !sCurrentPaintTimeStamp;
     3472
     3473#if PLATFORM(IOS)
     3474    // FIXME: Remove PLATFORM(IOS)-guard once we upstream the iOS changes to MemoryPressureHandler.h.
     3475    if (isTopLevelPainter && memoryPressureHandler().hasReceivedMemoryPressure()) {
     3476        LOG(MemoryPressure, "Under memory pressure: %s", __PRETTY_FUNCTION__);
     3477
     3478        // To avoid unnecessary image decoding, we don't prune recently-decoded live resources here since
     3479        // we might need some live bitmaps on painting.
     3480        memoryCache()->prune();
     3481    }
     3482#endif
     3483    if (paintingState.isTopLevelPainter)
     3484        sCurrentPaintTimeStamp = monotonicallyIncreasingTime();
     3485
     3486    if (!context->paintingDisabled() && !document->printing())
     3487        flushCompositingStateForThisFrame(&frame());
     3488
     3489    paintingState.paintBehavior = m_paintBehavior;
     3490   
     3491    if (FrameView* parentView = parentFrameView()) {
     3492        if (parentView->paintBehavior() & PaintBehaviorFlattenCompositingLayers)
     3493            m_paintBehavior |= PaintBehaviorFlattenCompositingLayers;
     3494    }
     3495   
     3496    if (m_paintBehavior == PaintBehaviorNormal)
     3497        document->markers().invalidateRenderedRectsForMarkersInRect(dirtyRect);
     3498
     3499    if (document->printing())
     3500        m_paintBehavior |= PaintBehaviorFlattenCompositingLayers;
     3501
     3502    paintingState.isFlatteningPaintOfRootFrame = (m_paintBehavior & PaintBehaviorFlattenCompositingLayers) && !frame().ownerElement();
     3503    if (paintingState.isFlatteningPaintOfRootFrame)
     3504        notifyWidgetsInAllFrames(WillPaintFlattened);
     3505
     3506    ASSERT(!m_isPainting);
     3507    m_isPainting = true;
     3508}
     3509
     3510void FrameView::didPaintContents(GraphicsContext* context, const IntRect& dirtyRect, PaintingState& paintingState)
     3511{
     3512    m_isPainting = false;
     3513
     3514    if (paintingState.isFlatteningPaintOfRootFrame)
     3515        notifyWidgetsInAllFrames(DidPaintFlattened);
     3516
     3517    m_paintBehavior = paintingState.paintBehavior;
     3518    m_lastPaintTime = monotonicallyIncreasingTime();
     3519
     3520#if PLATFORM(IOS)
     3521    // Painting can lead to decoding of large amounts of bitmaps
     3522    // If we are low on memory, wipe them out after the paint.
     3523    // FIXME: Remove PLATFORM(IOS)-guard once we upstream the iOS changes to MemoryPressureHandler.h.
     3524    if (isTopLevelPainter && memoryPressureHandler().hasReceivedMemoryPressure())
     3525        memoryCache()->pruneLiveResources(true);
     3526#endif
     3527
     3528    Document* document = frame().document();
     3529    // Regions may have changed as a result of the visibility/z-index of element changing.
     3530#if ENABLE(DASHBOARD_SUPPORT)
     3531    if (document->annotatedRegionsDirty())
     3532        updateAnnotatedRegions();
     3533#endif
     3534
     3535    if (paintingState.isTopLevelPainter)
     3536        sCurrentPaintTimeStamp = 0;
     3537
     3538    if (!context->paintingDisabled()) {
     3539        InspectorInstrumentation::didPaint(renderView(), context, dirtyRect);
     3540        // FIXME: should probably not fire milestones for snapshot painting. https://bugs.webkit.org/show_bug.cgi?id=117623
     3541        firePaintRelatedMilestonesIfNeeded();
     3542    }
     3543}
     3544
     3545void FrameView::paintContents(GraphicsContext* context, const IntRect& dirtyRect)
    34653546{
    34663547    Document* document = frame().document();
     
    34823563   
    34833564    if (fillWithRed)
    3484         p->fillRect(rect, Color(0xFF, 0, 0), ColorSpaceDeviceRGB);
     3565        context->fillRect(dirtyRect, Color(0xFF, 0, 0), ColorSpaceDeviceRGB);
    34853566#endif
    34863567
     
    34953576        return;
    34963577
    3497     if (!p->paintingDisabled())
    3498         InspectorInstrumentation::willPaint(renderView);
    3499 
    3500     bool isTopLevelPainter = !sCurrentPaintTimeStamp;
    3501 #if PLATFORM(IOS)
    3502     // FIXME: Remove PLATFORM(IOS)-guard once we upstream the iOS changes to MemoryPressureHandler.h.
    3503     if (isTopLevelPainter && memoryPressureHandler().hasReceivedMemoryPressure()) {
    3504         LOG(MemoryPressure, "Under memory pressure: %s", __PRETTY_FUNCTION__);
    3505 
    3506         // To avoid unnecessary image decoding, we don't prune recently-decoded live resources here since
    3507         // we might need some live bitmaps on painting.
    3508         memoryCache()->prune();
    3509     }
    3510 #endif
    3511     if (isTopLevelPainter)
    3512         sCurrentPaintTimeStamp = monotonicallyIncreasingTime();
     3578    PaintingState paintingState;
     3579    willPaintContents(context, dirtyRect, paintingState);
    35133580
    35143581    FontCachePurgePreventer fontCachePurgePreventer;
    3515 
    3516     if (!p->paintingDisabled() && !document->printing())
    3517         flushCompositingStateForThisFrame(&frame());
    3518 
    3519     PaintBehavior oldPaintBehavior = m_paintBehavior;
    3520    
    3521     if (FrameView* parentView = parentFrameView()) {
    3522         if (parentView->paintBehavior() & PaintBehaviorFlattenCompositingLayers)
    3523             m_paintBehavior |= PaintBehaviorFlattenCompositingLayers;
    3524     }
    3525    
    3526     if (m_paintBehavior == PaintBehaviorNormal)
    3527         document->markers().invalidateRenderedRectsForMarkersInRect(rect);
    3528 
    3529     if (document->printing())
    3530         m_paintBehavior |= PaintBehaviorFlattenCompositingLayers;
    3531 
    3532     bool flatteningPaint = m_paintBehavior & PaintBehaviorFlattenCompositingLayers;
    3533     bool isRootFrame = !frame().ownerElement();
    3534     if (flatteningPaint && isRootFrame)
    3535         notifyWidgetsInAllFrames(WillPaintFlattened);
    3536 
    3537     ASSERT(!m_isPainting);
    3538     m_isPainting = true;
    35393582
    35403583    // m_nodeToDraw is used to draw only one element (and its descendants)
     
    35463589#endif
    35473590
    3548     rootLayer->paint(p, rect, m_paintBehavior, eltRenderer);
    3549 
     3591    rootLayer->paint(context, dirtyRect, m_paintBehavior, eltRenderer);
    35503592    if (rootLayer->containsDirtyOverlayScrollbars())
    3551         rootLayer->paintOverlayScrollbars(p, rect, m_paintBehavior, eltRenderer);
    3552 
    3553     m_isPainting = false;
    3554 
    3555     if (flatteningPaint && isRootFrame)
    3556         notifyWidgetsInAllFrames(DidPaintFlattened);
    3557 
    3558     m_paintBehavior = oldPaintBehavior;
    3559     m_lastPaintTime = monotonicallyIncreasingTime();
    3560 
    3561 #if PLATFORM(IOS)
    3562     // Painting can lead to decoding of large amounts of bitmaps
    3563     // If we are low on memory, wipe them out after the paint.
    3564     // FIXME: Remove PLATFORM(IOS)-guard once we upstream the iOS changes to MemoryPressureHandler.h.
    3565     if (isTopLevelPainter && memoryPressureHandler().hasReceivedMemoryPressure())
    3566         memoryCache()->pruneLiveResources(true);
    3567 #endif
    3568 
    3569     // Regions may have changed as a result of the visibility/z-index of element changing.
    3570 #if ENABLE(DASHBOARD_SUPPORT)
    3571     if (document->annotatedRegionsDirty())
    3572         updateAnnotatedRegions();
    3573 #endif
    3574 
    3575     if (isTopLevelPainter)
    3576         sCurrentPaintTimeStamp = 0;
    3577 
    3578     if (!p->paintingDisabled()) {
    3579         InspectorInstrumentation::didPaint(renderView, p, rect);
    3580         // FIXME: should probably not fire milestones for snapshot painting. https://bugs.webkit.org/show_bug.cgi?id=117623
    3581         firePaintRelatedMilestonesIfNeeded();
    3582     }
     3593        rootLayer->paintOverlayScrollbars(context, dirtyRect, m_paintBehavior, eltRenderer);
     3594
     3595    didPaintContents(context, dirtyRect, paintingState);
    35833596}
    35843597
  • trunk/Source/WebCore/page/FrameView.h

    r165652 r166015  
    298298    void removeEmbeddedObjectToUpdate(RenderEmbeddedObject&);
    299299
    300     virtual void paintContents(GraphicsContext*, const IntRect& damageRect) override;
     300    virtual void paintContents(GraphicsContext*, const IntRect& dirtyRect) override;
     301
     302    struct PaintingState {
     303        PaintBehavior paintBehavior;
     304        bool isTopLevelPainter;
     305        bool isFlatteningPaintOfRootFrame;
     306        PaintingState()
     307            : paintBehavior()
     308            , isTopLevelPainter(false)
     309            , isFlatteningPaintOfRootFrame(false)
     310        {
     311        }
     312    };
     313
     314    void willPaintContents(GraphicsContext*, const IntRect& dirtyRect, PaintingState&);
     315    void didPaintContents(GraphicsContext*, const IntRect& dirtyRect, PaintingState&);
     316
    301317    void setPaintBehavior(PaintBehavior);
    302318    PaintBehavior paintBehavior() const;
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r165977 r166015  
    21582158    else if (compositor().fixedRootBackgroundLayer())
    21592159        paintFlags |= RenderLayer::PaintLayerPaintingSkipRootBackground;
    2160    
     2160
     2161#ifndef NDEBUG
     2162    RenderElement::SetLayoutNeededForbiddenScope forbidSetNeedsLayout(&m_owningLayer.renderer());
     2163#endif
     2164
     2165    FrameView::PaintingState paintingState;
     2166    if (m_owningLayer.isRootLayer())
     2167        m_owningLayer.renderer().view().frameView().willPaintContents(context, paintDirtyRect, paintingState);
     2168
    21612169    // FIXME: GraphicsLayers need a way to split for RenderRegions.
    21622170    RenderLayer::LayerPaintingInfo paintingInfo(&m_owningLayer, paintDirtyRect, paintBehavior, m_devicePixelFractionFromRenderer);
     
    21652173    if (m_owningLayer.containsDirtyOverlayScrollbars())
    21662174        m_owningLayer.paintLayerContents(context, paintingInfo, paintFlags | RenderLayer::PaintLayerPaintingOverlayScrollbars);
     2175
     2176    if (m_owningLayer.isRootLayer())
     2177        m_owningLayer.renderer().view().frameView().didPaintContents(context, paintDirtyRect, paintingState);
    21672178
    21682179    compositor().didPaintBacking(this);
Note: See TracChangeset for help on using the changeset viewer.