Changeset 183775 in webkit


Ignore:
Timestamp:
May 4, 2015, 3:53:10 PM (11 years ago)
Author:
Simon Fraser
Message:

Fix updating of tiled backing opaquenss when the page background color changes
https://bugs.webkit.org/show_bug.cgi?id=144600
rdar://problem/20723035

Reviewed by Tim Horton.

Source/WebCore:

RenderLayerCompositor makes the page tiles opaque or not based on the result of
viewHasTransparentBackground(), which consults the view transparency, and
FrameView::documentBackgroundColor(). documentBackgroundColor() in turn is based
on the root and/or body background colors.

We thus need to re-evaluate whether page tiles are opaque when any of these inputs
change, but were failing to do so for the FrameView's baseBackgroundColor, and
the page root background color.

Fix by having FrameView::setBaseBackgroundColor(), and RenderBox::styleDidChange()
(for the root) trigger a compositing update when necessary.

Added setViewBaseBackgroundColor() on Internals for testing.

Test: platform/mac-wk2/tiled-drawing/background-transparency-toggle.html

  • page/FrameView.cpp:

(WebCore::FrameView::setTransparent): Use the isViewForDocumentInFrame() helper.
(WebCore::FrameView::setBaseBackgroundColor): Bail if we're not the view for the
frame's document, and trigger a compositing update check if the alpha changed.
(WebCore::FrameView::isViewForDocumentInFrame): Helper that checks to see if
this FrameView is associated with the Document being displayed in the FrameView's
Frame. This returns false when we're setting up a new FrameView (its Frame still
points to the old document, so renderView() returns the RenderView for the Frame's
existing Document).

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

(WebCore::RenderBox::styleDidChange): Have the compositor check to see if it needs
to do an update.

  • rendering/RenderLayerCompositor.cpp:

(WebCore::RenderLayerCompositor::rootBackgroundTransparencyChanged): If the result
of documentBackgroundColor() changed in alpha since the last time, trigger a compositing
update.

  • rendering/RenderLayerCompositor.h:
  • testing/Internals.cpp:

(WebCore::Internals::setViewBaseBackgroundColor):

  • testing/Internals.h:
  • testing/Internals.idl:

LayoutTests:

Test that dumps layers with various baseBackgroundColor and body background color
combinations.

  • platform/mac-wk2/tiled-drawing/background-transparency-toggle-expected.txt: Added.
  • platform/mac-wk2/tiled-drawing/background-transparency-toggle.html: Added.
Location:
trunk
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r183773 r183775  
     12015-05-04  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Fix updating of tiled backing opaquenss when the page background color changes
     4        https://bugs.webkit.org/show_bug.cgi?id=144600
     5        rdar://problem/20723035
     6
     7        Reviewed by Tim Horton.
     8
     9        Test that dumps layers with various baseBackgroundColor and body background color
     10        combinations.
     11
     12        * platform/mac-wk2/tiled-drawing/background-transparency-toggle-expected.txt: Added.
     13        * platform/mac-wk2/tiled-drawing/background-transparency-toggle.html: Added.
     14
    1152015-05-04  Ryosuke Niwa  <rniwa@webkit.org>
    216
  • trunk/Source/WebCore/ChangeLog

    r183774 r183775  
     12015-05-04  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Fix updating of tiled backing opaquenss when the page background color changes
     4        https://bugs.webkit.org/show_bug.cgi?id=144600
     5        rdar://problem/20723035
     6
     7        Reviewed by Tim Horton.
     8
     9        RenderLayerCompositor makes the page tiles opaque or not based on the result of
     10        viewHasTransparentBackground(), which consults the view transparency, and
     11        FrameView::documentBackgroundColor(). documentBackgroundColor() in turn is based
     12        on the root and/or body background colors.
     13
     14        We thus need to re-evaluate whether page tiles are opaque when any of these inputs
     15        change, but were failing to do so for the FrameView's baseBackgroundColor, and
     16        the page root background color.
     17       
     18        Fix by having FrameView::setBaseBackgroundColor(), and RenderBox::styleDidChange()
     19        (for the root) trigger a compositing update when necessary.
     20
     21        Added setViewBaseBackgroundColor() on Internals for testing.
     22
     23        Test: platform/mac-wk2/tiled-drawing/background-transparency-toggle.html
     24
     25        * page/FrameView.cpp:
     26        (WebCore::FrameView::setTransparent): Use the isViewForDocumentInFrame() helper.
     27        (WebCore::FrameView::setBaseBackgroundColor): Bail if we're not the view for the
     28        frame's document, and trigger a compositing update check if the alpha changed.
     29        (WebCore::FrameView::isViewForDocumentInFrame): Helper that checks to see if
     30        this FrameView is associated with the Document being displayed in the FrameView's
     31        Frame. This returns false when we're setting up a new FrameView (its Frame still
     32        points to the old document, so renderView() returns the RenderView for the Frame's
     33        existing Document).
     34        * page/FrameView.h:
     35        * rendering/RenderBox.cpp:
     36        (WebCore::RenderBox::styleDidChange): Have the compositor check to see if it needs
     37        to do an update.
     38        * rendering/RenderLayerCompositor.cpp:
     39        (WebCore::RenderLayerCompositor::rootBackgroundTransparencyChanged): If the result
     40        of documentBackgroundColor() changed in alpha since the last time, trigger a compositing
     41        update.
     42        * rendering/RenderLayerCompositor.h:
     43        * testing/Internals.cpp:
     44        (WebCore::Internals::setViewBaseBackgroundColor):
     45        * testing/Internals.h:
     46        * testing/Internals.idl:
     47
    1482015-05-04  Jer Noble  <jer.noble@apple.com>
    249
  • trunk/Source/WebCore/page/FrameView.cpp

    r183710 r183775  
    26792679    m_isTransparent = isTransparent;
    26802680
    2681     RenderView* renderView = this->renderView();
    2682     if (!renderView)
    2683         return;
    2684 
    26852681    // setTransparent can be called in the window between FrameView initialization
    26862682    // and switching in the new Document; this means that the RenderView that we
    26872683    // retrieve is actually attached to the previous Document, which is going away,
    26882684    // and must not update compositing layers.
    2689     if (&renderView->frameView() != this)
    2690         return;
    2691 
    2692     RenderLayerCompositor& compositor = renderView->compositor();
    2693     compositor.setCompositingLayersNeedRebuild();
    2694     compositor.scheduleCompositingLayerUpdate();
     2685    if (!isViewForDocumentInFrame())
     2686        return;
     2687
     2688    renderView()->compositor().rootBackgroundTransparencyChanged();
    26952689}
    26962690
     
    27072701void FrameView::setBaseBackgroundColor(const Color& backgroundColor)
    27082702{
     2703    bool hadAlpha = m_baseBackgroundColor.hasAlpha();
     2704   
    27092705    if (!backgroundColor.isValid())
    27102706        m_baseBackgroundColor = Color::white;
     
    27122708        m_baseBackgroundColor = backgroundColor;
    27132709
     2710    if (!isViewForDocumentInFrame())
     2711        return;
     2712
    27142713    recalculateScrollbarOverlayStyle();
     2714
     2715    if (m_baseBackgroundColor.hasAlpha() != hadAlpha)
     2716        renderView()->compositor().rootBackgroundTransparencyChanged();
    27152717}
    27162718
     
    41114113}
    41124114
     4115bool FrameView::isViewForDocumentInFrame() const
     4116{
     4117    RenderView* renderView = this->renderView();
     4118    if (!renderView)
     4119        return false;
     4120
     4121    return &renderView->frameView() == this;
     4122}
     4123
    41134124void FrameView::enableAutoSizeMode(bool enable, const IntSize& minSize, const IntSize& maxSize)
    41144125{
  • trunk/Source/WebCore/page/FrameView.h

    r183710 r183775  
    649649
    650650    bool qualifiesAsVisuallyNonEmpty() const;
     651    bool isViewForDocumentInFrame() const;
    651652
    652653    AXObjectCache* axObjectCache() const;
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r183636 r183775  
    426426        if (rootStyleChanged && is<RenderBlockFlow>(rootRenderer) && downcast<RenderBlockFlow>(*rootRenderer).multiColumnFlowThread())
    427427            downcast<RenderBlockFlow>(*rootRenderer).updateStylesForColumnChildren();
     428
     429        if (diff != StyleDifferenceEqual)
     430            view().compositor().rootBackgroundTransparencyChanged();
    428431    }
    429432
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp

    r183710 r183775  
    32153215}
    32163216
     3217void RenderLayerCompositor::rootBackgroundTransparencyChanged()
     3218{
     3219    Color documentBackgroundColor = m_renderView.frameView().documentBackgroundColor();
     3220    if (m_lastDocumentBackgroundColor.isValid() && documentBackgroundColor.hasAlpha() == m_lastDocumentBackgroundColor.hasAlpha())
     3221        return;
     3222
     3223    // FIXME: We should do something less expensive than a full layer rebuild.
     3224    setCompositingLayersNeedRebuild();
     3225    scheduleCompositingLayerUpdate();
     3226}
     3227
    32173228void RenderLayerCompositor::setRootExtendedBackgroundColor(const Color& color)
    32183229{
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.h

    r183710 r183775  
    166166    GraphicsLayer* fixedRootBackgroundLayer() const;
    167167   
     168    // Called after the view transparency, or the document or base background color change.
     169    void rootBackgroundTransparencyChanged();
     170   
    168171    // Repaint the appropriate layers when the given RenderLayer starts or stops being composited.
    169172    void repaintOnCompositingChange(RenderLayer&);
     
    555558
    556559    Color m_rootExtendedBackgroundColor;
     560    Color m_lastDocumentBackgroundColor;
    557561
    558562    HashMap<ScrollingNodeID, RenderLayer*> m_scrollingNodeToLayerMap;
  • trunk/Source/WebCore/testing/Internals.cpp

    r183710 r183775  
    988988}
    989989
     990void Internals::setViewBaseBackgroundColor(const String& colorValue, ExceptionCode& ec)
     991{
     992    Document* document = contextDocument();
     993    if (!document || !document->view()) {
     994        ec = INVALID_ACCESS_ERR;
     995        return;
     996    }
     997
     998    document->view()->setBaseBackgroundColor(Color(colorValue));
     999}
     1000
    9901001void Internals::setPagination(const String& mode, int gap, int pageLength, ExceptionCode& ec)
    9911002{
  • trunk/Source/WebCore/testing/Internals.h

    r183710 r183775  
    158158
    159159    void setScrollViewPosition(long x, long y, ExceptionCode&);
     160    void setViewBaseBackgroundColor(const String& colorValue, ExceptionCode&);
     161
    160162    void setPagination(const String& mode, int gap, ExceptionCode& ec) { setPagination(mode, gap, 0, ec); }
    161163    void setPagination(const String& mode, int gap, int pageLength, ExceptionCode&);
  • trunk/Source/WebCore/testing/Internals.idl

    r183710 r183775  
    123123    [RaisesException] void setScrollViewPosition(long x, long y);
    124124
     125    [RaisesException] void setViewBaseBackgroundColor(DOMString colorValue);
     126
    125127    [RaisesException] void setPagination(DOMString mode, long gap, optional long pageLength);
    126128
Note: See TracChangeset for help on using the changeset viewer.