Changeset 152335 in webkit


Ignore:
Timestamp:
Jul 2, 2013 8:19:06 PM (11 years ago)
Author:
Simon Fraser
Message:

Don't set z-index: 0 on lots of elements with -webkit-overflow-scrolling: touch
https://bugs.webkit.org/show_bug.cgi?id=118337

Reviewed by Benjamin Poulain.

-webkit-overflow-scrolling: touch is an inherited property that, on iOS, controls
the behavior of overflow scrolling content, and causes overflow scrolling elements
to become CSS stacking contexts.

However, the code was too aggressive in setting style->setZIndex(0), doing so
for any element with overflow != hidden. Since the default for overflow is visible,
that meant almost every element.

Previously, this didn't really matter. However, since r125693, any renderer with non-auto
z-index gets a RenderLayer, and that RenderLayer will become a stacking context. The result
was too many RenderLayers and incorrect stacking context behavior.

Fix by ensuring that -webkit-overflow-scrolling: touch only affects elements which
are actually scrollable.

Also move the code that does this to below the code that adjust overflow style
for different elements.

  • css/StyleResolver.cpp:

(WebCore::isScrollableOverflow):
(WebCore::StyleResolver::adjustRenderStyle):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r152333 r152335  
     12013-07-02  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Don't set z-index: 0 on lots of elements with -webkit-overflow-scrolling: touch
     4        https://bugs.webkit.org/show_bug.cgi?id=118337
     5
     6        Reviewed by Benjamin Poulain.
     7
     8        -webkit-overflow-scrolling: touch is an inherited property that, on iOS, controls
     9        the behavior of overflow scrolling content, and causes overflow scrolling elements
     10        to become CSS stacking contexts.
     11         
     12        However, the code was too aggressive in setting style->setZIndex(0), doing so
     13        for any element with overflow != hidden. Since the default for overflow is visible,
     14        that meant almost every element.
     15       
     16        Previously, this didn't really matter. However, since r125693, any renderer with non-auto
     17        z-index gets a RenderLayer, and that RenderLayer will become a stacking context. The result
     18        was too many RenderLayers and incorrect stacking context behavior.
     19       
     20        Fix by ensuring that -webkit-overflow-scrolling: touch  only affects elements which
     21        are actually scrollable.
     22       
     23        Also move the code that does this to below the code that adjust overflow style
     24        for different elements.
     25
     26        * css/StyleResolver.cpp:
     27        (WebCore::isScrollableOverflow):
     28        (WebCore::StyleResolver::adjustRenderStyle):
     29
    1302013-07-02  Commit Queue  <commit-queue@webkit.org>
    231
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r152218 r152335  
    13531353}
    13541354
     1355#if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
     1356static bool isScrollableOverflow(EOverflow overflow)
     1357{
     1358    return overflow == OSCROLL || overflow == OAUTO || overflow == OOVERLAY;
     1359}
     1360#endif
     1361
    13551362void StyleResolver::adjustRenderStyle(RenderStyle* style, RenderStyle* parentStyle, Element *e)
    13561363{
     
    14711478        || style->position() == StickyPosition
    14721479        || (style->position() == FixedPosition && e && e->document()->page() && e->document()->page()->settings()->fixedPositionCreatesStackingContext())
    1473 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
    1474         // Touch overflow scrolling creates a stacking context.
    1475         || ((style->overflowX() != OHIDDEN || style->overflowY() != OHIDDEN) && style->useTouchOverflowScrolling())
    1476 #endif
    14771480#if ENABLE(DIALOG_ELEMENT)
    14781481        || (e && e->isInTopLayer())
     
    15261529        style->setOverflowY(OVISIBLE);
    15271530    }
     1531
     1532#if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
     1533    // Touch overflow scrolling creates a stacking context.
     1534    if (style->useTouchOverflowScrolling() && (isScrollableOverflow(style->overflowX()) || isScrollableOverflow(style->overflowY())))
     1535        style->setZIndex(0);
     1536#endif
    15281537
    15291538    // Cull out any useless layers and also repeat patterns into additional layers.
Note: See TracChangeset for help on using the changeset viewer.