Changeset 236356 in webkit


Ignore:
Timestamp:
Sep 21, 2018, 1:29:18 PM (7 years ago)
Author:
Simon Fraser
Message:

Simplify the logic around has*ScrollbarWithAutoBehavior
https://bugs.webkit.org/show_bug.cgi?id=189813

Reviewed by Zalan Bujtas.

The boolean logic in scrollsOverflowX() and hasHorizontalScrollbarWithAutoBehavior() (and the vertical

equivalents) reduces simply to hasOverflowClip() && (style().overflowX() == Overflow::Scroll
style().overflowX() == Overflow::Auto);

Similarly, RenderBox::intrinsicScrollbarLogicalWidth() just needs the part of the logic
that asks whether the theme uses overlay scrollbars which are not customized (and thus
turned into non-overlay scrollbars).

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::intrinsicScrollbarLogicalWidth const):
(WebCore::RenderBox::canUseOverlayScrollbars const):
(WebCore::RenderBox::hasVerticalScrollbarWithAutoBehavior const):
(WebCore::RenderBox::hasHorizontalScrollbarWithAutoBehavior const):

  • rendering/RenderBox.h:

(WebCore::RenderBox::scrollsOverflowX const):
(WebCore::RenderBox::scrollsOverflowY const):

  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::updateScrollbarsAfterLayout):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r236352 r236356  
     12018-09-20  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Simplify the logic around has*ScrollbarWithAutoBehavior
     4        https://bugs.webkit.org/show_bug.cgi?id=189813
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        The boolean logic in scrollsOverflowX() and hasHorizontalScrollbarWithAutoBehavior() (and the vertical
     9        equivalents) reduces simply to hasOverflowClip() && (style().overflowX() == Overflow::Scroll || style().overflowX() == Overflow::Auto);
     10       
     11        Similarly, RenderBox::intrinsicScrollbarLogicalWidth() just needs the part of the logic
     12        that asks whether the theme uses overlay scrollbars which are not customized (and thus
     13        turned into non-overlay scrollbars).
     14
     15        * rendering/RenderBox.cpp:
     16        (WebCore::RenderBox::intrinsicScrollbarLogicalWidth const):
     17        (WebCore::RenderBox::canUseOverlayScrollbars const):
     18        (WebCore::RenderBox::hasVerticalScrollbarWithAutoBehavior const):
     19        (WebCore::RenderBox::hasHorizontalScrollbarWithAutoBehavior const):
     20        * rendering/RenderBox.h:
     21        (WebCore::RenderBox::scrollsOverflowX const):
     22        (WebCore::RenderBox::scrollsOverflowY const):
     23        * rendering/RenderLayer.cpp:
     24        (WebCore::RenderLayer::updateScrollbarsAfterLayout):
     25
    1262018-09-21  Michael Catanzaro  <mcatanzaro@igalia.com>
    227
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r236341 r236356  
    773773        return 0;
    774774
    775     if (isHorizontalWritingMode() && (style().overflowY() == Overflow::Scroll && !hasVerticalScrollbarWithAutoBehavior())) {
     775    if (isHorizontalWritingMode() && (style().overflowY() == Overflow::Scroll && !canUseOverlayScrollbars())) {
    776776        ASSERT(layer() && layer()->hasVerticalScrollbar());
    777777        return verticalScrollbarWidth();
    778778    }
    779779
    780     if (!isHorizontalWritingMode() && (style().overflowX() == Overflow::Scroll && !hasHorizontalScrollbarWithAutoBehavior())) {
     780    if (!isHorizontalWritingMode() && (style().overflowX() == Overflow::Scroll && !canUseOverlayScrollbars())) {
    781781        ASSERT(layer() && layer()->hasHorizontalScrollbar());
    782782        return horizontalScrollbarHeight();
     
    935935}
    936936
     937bool RenderBox::canUseOverlayScrollbars() const
     938{
     939    return !style().hasPseudoStyle(PseudoId::Scrollbar) && ScrollbarTheme::theme().usesOverlayScrollbars();
     940}
     941
    937942bool RenderBox::hasVerticalScrollbarWithAutoBehavior() const
    938943{
    939     bool overflowScrollActsLikeAuto = style().overflowY() == Overflow::Scroll && !style().hasPseudoStyle(PseudoId::Scrollbar) && ScrollbarTheme::theme().usesOverlayScrollbars();
    940     return hasOverflowClip() && (style().overflowY() == Overflow::Auto || overflowScrollActsLikeAuto);
     944    return hasOverflowClip() && (style().overflowY() == Overflow::Auto || (style().overflowY() == Overflow::Scroll && canUseOverlayScrollbars()));
    941945}
    942946
    943947bool RenderBox::hasHorizontalScrollbarWithAutoBehavior() const
    944948{
    945     bool overflowScrollActsLikeAuto = style().overflowX() == Overflow::Scroll && !style().hasPseudoStyle(PseudoId::Scrollbar) && ScrollbarTheme::theme().usesOverlayScrollbars();
    946     return hasOverflowClip() && (style().overflowX() == Overflow::Auto || overflowScrollActsLikeAuto);
     949    return hasOverflowClip() && (style().overflowX() == Overflow::Auto || (style().overflowX() == Overflow::Scroll && canUseOverlayScrollbars()));
    947950}
    948951
  • trunk/Source/WebCore/rendering/RenderBox.h

    r234619 r236356  
    460460    bool hasVerticalScrollbarWithAutoBehavior() const;
    461461    bool hasHorizontalScrollbarWithAutoBehavior() const;
     462   
     463    bool canUseOverlayScrollbars() const;
    462464
    463465    bool scrollsOverflow() const { return scrollsOverflowX() || scrollsOverflowY(); }
    464     bool scrollsOverflowX() const { return hasOverflowClip() && (style().overflowX() == Overflow::Scroll || hasHorizontalScrollbarWithAutoBehavior()); }
    465     bool scrollsOverflowY() const { return hasOverflowClip() && (style().overflowY() == Overflow::Scroll || hasVerticalScrollbarWithAutoBehavior()); }
     466    bool scrollsOverflowX() const { return hasOverflowClip() && (style().overflowX() == Overflow::Scroll || style().overflowX() == Overflow::Auto); }
     467    bool scrollsOverflowY() const { return hasOverflowClip() && (style().overflowY() == Overflow::Scroll || style().overflowY() == Overflow::Auto); }
    466468
    467469    bool hasHorizontalOverflow() const { return scrollWidth() != roundToInt(clientWidth()); }
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r236341 r236356  
    35163516        if (renderer().style().overflowX() == Overflow::Auto || renderer().style().overflowY() == Overflow::Auto) {
    35173517            if (!m_inOverflowRelayout) {
    3518                 // Our proprietary overflow: overlay value doesn't trigger a layout.
    35193518                m_inOverflowRelayout = true;
    35203519                renderer().setNeedsLayout(MarkOnlyThis);
Note: See TracChangeset for help on using the changeset viewer.