Changeset 208981 in webkit


Ignore:
Timestamp:
Nov 26, 2016 6:06:59 PM (7 years ago)
Author:
Simon Fraser
Message:

Composited negative z-index elements are hidden behind the body sometimes
https://bugs.webkit.org/show_bug.cgi?id=165080
rdar://problem/22260229

Reviewed by Zalan Bujtas.

Source/WebCore:

If the <body> falls into the "directly composited background color" code path
(say, because it's composited because of composited negative z-index children,
and has content of its own), then we failed to take root background propagation
into account, and put the opaque root background color on the body's layer.

Fix by sharing some code from RenderBox related to whether the body's renderer
paints its background.

Tests cover the buggy case, and the case where the <html> has its own background color.

Tests: compositing/backgrounds/negative-z-index-behind-body-non-propagated.html

compositing/backgrounds/negative-z-index-behind-body.html

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::paintsOwnBackground):
(WebCore::RenderBox::paintBackground):
(WebCore::RenderBox::backgroundIsKnownToBeOpaqueInRect):
(WebCore::skipBodyBackground): Deleted.

  • rendering/RenderBox.h:
  • rendering/RenderLayerBacking.cpp:

(WebCore::RenderLayerBacking::updateDirectlyCompositedBackgroundColor):

LayoutTests:

  • compositing/backgrounds/negative-z-index-behind-body-expected.html: Added.
  • compositing/backgrounds/negative-z-index-behind-body-non-propagated-expected.html: Added.
  • compositing/backgrounds/negative-z-index-behind-body-non-propagated.html: Added.
  • compositing/backgrounds/negative-z-index-behind-body.html: Added.
Location:
trunk
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r208980 r208981  
     12016-11-26  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Composited negative z-index elements are hidden behind the body sometimes
     4        https://bugs.webkit.org/show_bug.cgi?id=165080
     5        rdar://problem/22260229
     6
     7        Reviewed by Zalan Bujtas.
     8
     9        * compositing/backgrounds/negative-z-index-behind-body-expected.html: Added.
     10        * compositing/backgrounds/negative-z-index-behind-body-non-propagated-expected.html: Added.
     11        * compositing/backgrounds/negative-z-index-behind-body-non-propagated.html: Added.
     12        * compositing/backgrounds/negative-z-index-behind-body.html: Added.
     13
    1142016-11-26  Simon Fraser  <simon.fraser@apple.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r208976 r208981  
     12016-11-26  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Composited negative z-index elements are hidden behind the body sometimes
     4        https://bugs.webkit.org/show_bug.cgi?id=165080
     5        rdar://problem/22260229
     6
     7        Reviewed by Zalan Bujtas.
     8
     9        If the <body> falls into the "directly composited background color" code path
     10        (say, because it's composited because of composited negative z-index children,
     11        and has content of its own), then we failed to take root background propagation
     12        into account, and put the opaque root background color on the body's layer.
     13
     14        Fix by sharing some code from RenderBox related to whether the body's renderer
     15        paints its background.
     16       
     17        Tests cover the buggy case, and the case where the <html> has its own background color.
     18
     19        Tests: compositing/backgrounds/negative-z-index-behind-body-non-propagated.html
     20               compositing/backgrounds/negative-z-index-behind-body.html
     21
     22        * rendering/RenderBox.cpp:
     23        (WebCore::RenderBox::paintsOwnBackground):
     24        (WebCore::RenderBox::paintBackground):
     25        (WebCore::RenderBox::backgroundIsKnownToBeOpaqueInRect):
     26        (WebCore::skipBodyBackground): Deleted.
     27        * rendering/RenderBox.h:
     28        * rendering/RenderLayerBacking.cpp:
     29        (WebCore::RenderLayerBacking::updateDirectlyCompositedBackgroundColor):
     30
    1312016-11-25  Myles C. Maxfield  <mmaxfield@apple.com>
    232
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r208597 r208981  
    131131bool RenderBox::s_hadOverflowClip = false;
    132132
    133 static bool skipBodyBackground(const RenderBox* bodyElementRenderer)
    134 {
    135     ASSERT(bodyElementRenderer->isBody());
    136     // The <body> only paints its background if the root element has defined a background independent of the body,
    137     // or if the <body>'s parent is not the document element's renderer (e.g. inside SVG foreignObject).
    138     auto documentElementRenderer = bodyElementRenderer->document().documentElement()->renderer();
    139     return documentElementRenderer
    140         && !documentElementRenderer->hasBackground()
    141         && (documentElementRenderer == bodyElementRenderer->parent());
    142 }
    143 
    144133RenderBox::RenderBox(Element& element, RenderStyle&& style, BaseTypeFlags baseTypeFlags)
    145134    : RenderBoxModelObject(element, WTFMove(style), baseTypeFlags)
     
    13841373}
    13851374
     1375bool RenderBox::paintsOwnBackground() const
     1376{
     1377    if (isBody()) {
     1378        // The <body> only paints its background if the root element has defined a background independent of the body,
     1379        // or if the <body>'s parent is not the document element's renderer (e.g. inside SVG foreignObject).
     1380        auto documentElementRenderer = document().documentElement()->renderer();
     1381        return !documentElementRenderer
     1382            || documentElementRenderer->hasBackground()
     1383            || (documentElementRenderer != parent());
     1384    }
     1385   
     1386    return true;
     1387}
     1388
    13861389void RenderBox::paintBackground(const PaintInfo& paintInfo, const LayoutRect& paintRect, BackgroundBleedAvoidance bleedAvoidance)
    13871390{
     
    13901393        return;
    13911394    }
    1392     if (isBody() && skipBodyBackground(this))
     1395
     1396    if (!paintsOwnBackground())
    13931397        return;
     1398
    13941399    if (backgroundIsKnownToBeObscured(paintRect.location()) && !boxShadowShouldBeAppliedToBackground(paintRect.location(), bleedAvoidance))
    13951400        return;
     1401
    13961402    paintFillLayers(paintInfo, style().visitedDependentColor(CSSPropertyBackgroundColor), style().backgroundLayers(), paintRect, bleedAvoidance);
    13971403}
     
    14201426bool RenderBox::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) const
    14211427{
    1422     if (isBody() && skipBodyBackground(this))
     1428    if (!paintsOwnBackground())
    14231429        return false;
    14241430
  • trunk/Source/WebCore/rendering/RenderBox.h

    r208668 r208981  
    5757
    5858    bool backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) const final;
     59   
     60    // Returns false for the body renderer if its background is propagated to the root.
     61    bool paintsOwnBackground() const;
    5962
    6063    // Use this with caution! No type checking is done!
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r208460 r208981  
    18101810void RenderLayerBacking::updateDirectlyCompositedBackgroundColor(bool isSimpleContainer, bool& didUpdateContentsRect)
    18111811{
    1812     if (!isSimpleContainer) {
     1812    if (!isSimpleContainer || (is<RenderBox>(renderer()) && !downcast<RenderBox>(renderer()).paintsOwnBackground())) {
    18131813        m_graphicsLayer->setContentsToSolidColor(Color());
    18141814        return;
Note: See TracChangeset for help on using the changeset viewer.