Changeset 198859 in webkit


Ignore:
Timestamp:
Mar 30, 2016 3:19:08 PM (8 years ago)
Author:
mmaxfield@apple.com
Message:

[OS X] [RTL Scrollbars] Overlay RTL scrollbars animate in from the wrong side
https://bugs.webkit.org/show_bug.cgi?id=155962

Reviewed by Darin Adler.

Source/WebCore:

We can control the animation direction with the NSScrollerImp property
userInterfaceLayoutDirection.

This patch also adds an Internals function to set whether or not we
should mock the scrollbars. Not mocking the scrollbars is required
to use NSScrollerImps.

Test: fast/scrolling/rtl-scrollbars-animation-property.html

  • platform/ScrollableArea.h: Use nullptr instead of 0.

(WebCore::ScrollableArea::horizontalScrollbar):
(WebCore::ScrollableArea::verticalScrollbar):
(WebCore::ScrollableArea::tiledBacking):
(WebCore::ScrollableArea::layerForHorizontalScrollbar):
(WebCore::ScrollableArea::layerForVerticalScrollbar):
(WebCore::ScrollableArea::layerForScrolling):
(WebCore::ScrollableArea::layerForScrollCorner):
(WebCore::ScrollableArea::layerForOverhangAreas):

  • platform/mac/ScrollAnimatorMac.mm:

(WebCore::ScrollAnimatorMac::updateScrollerStyle): Set the direction
of the new NSScrollerImps.

  • platform/mac/ScrollbarThemeMac.h:
  • platform/mac/ScrollbarThemeMac.mm:

(WebCore::ScrollbarThemeMac::didCreateScrollerImp): Set the direction
of an NSScrollerImp.
(WebCore::ScrollbarThemeMac::registerScrollbar): Call
didCreateScrollerImp().
(WebCore::ScrollbarThemeMac::isLayoutDirectionRTL): Used for testing,
to tell if the scroller's direction is RTL.

  • platform/spi/mac/NSScrollerImpSPI.h:
  • rendering/RenderTreeAsText.cpp:

(WebCore::write):

  • testing/Internals.cpp:

(WebCore::Internals::setMockScrollbarsEnabled): Used for testing.

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

LayoutTests:

This test only prints the "RTL" token when running on certain OSes.

  • fast/scrolling/rtl-scrollbars-animation-property.html: Added.
  • platform/mac/fast/scrolling/rtl-scrollbars-animation-property-expected.txt: Added.
Location:
trunk
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r198858 r198859  
     12016-03-30  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        [OS X] [RTL Scrollbars] Overlay RTL scrollbars animate in from the wrong side
     4        https://bugs.webkit.org/show_bug.cgi?id=155962
     5
     6        Reviewed by Darin Adler.
     7
     8        This test only prints the "RTL" token when running on certain OSes.
     9
     10        * fast/scrolling/rtl-scrollbars-animation-property.html: Added.
     11        * platform/mac/fast/scrolling/rtl-scrollbars-animation-property-expected.txt: Added.
     12
    1132016-03-30  Sam Weinig  <sam@webkit.org>
    214
  • trunk/Source/WebCore/ChangeLog

    r198858 r198859  
     12016-03-30  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        [OS X] [RTL Scrollbars] Overlay RTL scrollbars animate in from the wrong side
     4        https://bugs.webkit.org/show_bug.cgi?id=155962
     5
     6        Reviewed by Darin Adler.
     7
     8        We can control the animation direction with the NSScrollerImp property
     9        userInterfaceLayoutDirection.
     10
     11        This patch also adds an Internals function to set whether or not we
     12        should mock the scrollbars. Not mocking the scrollbars is required
     13        to use NSScrollerImps.
     14
     15        Test: fast/scrolling/rtl-scrollbars-animation-property.html
     16
     17        * platform/ScrollableArea.h: Use nullptr instead of 0.
     18        (WebCore::ScrollableArea::horizontalScrollbar):
     19        (WebCore::ScrollableArea::verticalScrollbar):
     20        (WebCore::ScrollableArea::tiledBacking):
     21        (WebCore::ScrollableArea::layerForHorizontalScrollbar):
     22        (WebCore::ScrollableArea::layerForVerticalScrollbar):
     23        (WebCore::ScrollableArea::layerForScrolling):
     24        (WebCore::ScrollableArea::layerForScrollCorner):
     25        (WebCore::ScrollableArea::layerForOverhangAreas):
     26        * platform/mac/ScrollAnimatorMac.mm:
     27        (WebCore::ScrollAnimatorMac::updateScrollerStyle): Set the direction
     28        of the new NSScrollerImps.
     29        * platform/mac/ScrollbarThemeMac.h:
     30        * platform/mac/ScrollbarThemeMac.mm:
     31        (WebCore::ScrollbarThemeMac::didCreateScrollerImp): Set the direction
     32        of an NSScrollerImp.
     33        (WebCore::ScrollbarThemeMac::registerScrollbar): Call
     34        didCreateScrollerImp().
     35        (WebCore::ScrollbarThemeMac::isLayoutDirectionRTL): Used for testing,
     36        to tell if the scroller's direction is RTL.
     37        * platform/spi/mac/NSScrollerImpSPI.h:
     38        * rendering/RenderTreeAsText.cpp:
     39        (WebCore::write):
     40        * testing/Internals.cpp:
     41        (WebCore::Internals::setMockScrollbarsEnabled): Used for testing.
     42        * testing/Internals.h:
     43        * testing/Internals.idl:
     44
    1452016-03-30  Sam Weinig  <sam@webkit.org>
    246
  • trunk/Source/WebCore/platform/ScrollableArea.h

    r198841 r198859  
    181181    WEBCORE_EXPORT IntSize scrollbarIntrusion() const;
    182182
    183     virtual Scrollbar* horizontalScrollbar() const { return 0; }
    184     virtual Scrollbar* verticalScrollbar() const { return 0; }
     183    virtual Scrollbar* horizontalScrollbar() const { return nullptr; }
     184    virtual Scrollbar* verticalScrollbar() const { return nullptr; }
    185185
    186186    const IntPoint& scrollOrigin() const { return m_scrollOrigin; }
     
    294294#endif
    295295
    296     virtual TiledBacking* tiledBacking() const { return 0; }
     296    virtual TiledBacking* tiledBacking() const { return nullptr; }
    297297
    298298    // True if scrolling happens by moving compositing layers.
     
    301301    virtual bool usesAsyncScrolling() const { return false; }
    302302
    303     virtual GraphicsLayer* layerForHorizontalScrollbar() const { return 0; }
    304     virtual GraphicsLayer* layerForVerticalScrollbar() const { return 0; }
     303    virtual GraphicsLayer* layerForHorizontalScrollbar() const { return nullptr; }
     304    virtual GraphicsLayer* layerForVerticalScrollbar() const { return nullptr; }
    305305
    306306    bool hasLayerForHorizontalScrollbar() const;
     
    328328
    329329    friend class ScrollingCoordinator;
    330     virtual GraphicsLayer* layerForScrolling() const { return 0; }
    331     virtual GraphicsLayer* layerForScrollCorner() const { return 0; }
     330    virtual GraphicsLayer* layerForScrolling() const { return nullptr; }
     331    virtual GraphicsLayer* layerForScrollCorner() const { return nullptr; }
    332332#if ENABLE(RUBBER_BANDING)
    333     virtual GraphicsLayer* layerForOverhangAreas() const { return 0; }
     333    virtual GraphicsLayer* layerForOverhangAreas() const { return nullptr; }
    334334#endif
    335335
  • trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm

    r198817 r198859  
    13041304        [m_scrollerImpPair setVerticalScrollerImp:newVerticalPainter];
    13051305        macTheme->setNewPainterForScrollbar(*verticalScrollbar, newVerticalPainter);
     1306        macTheme->didCreateScrollerImp(*verticalScrollbar);
    13061307
    13071308        // The different scrollbar styles have different thicknesses, so we must re-set the
     
    13201321        [m_scrollerImpPair setHorizontalScrollerImp:newHorizontalPainter];
    13211322        macTheme->setNewPainterForScrollbar(*horizontalScrollbar, newHorizontalPainter);
     1323        macTheme->didCreateScrollerImp(*horizontalScrollbar);
    13221324
    13231325        // The different scrollbar styles have different thicknesses, so we must re-set the
  • trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.h

    r198078 r198859  
    6565    static void setIsCurrentlyDrawingIntoLayer(bool);
    6666
     67    void didCreateScrollerImp(Scrollbar&);
     68    bool isLayoutDirectionRTL(Scrollbar&);
     69
    6770#if ENABLE(RUBBER_BANDING)
    6871    WEBCORE_EXPORT static void setUpOverhangAreaBackground(CALayer *, const Color& customBackgroundColor = Color());
  • trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.mm

    r198817 r198859  
    154154}
    155155
     156void ScrollbarThemeMac::didCreateScrollerImp(Scrollbar& scrollbar)
     157{
     158#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
     159    NSScrollerImp *scrollerImp = painterForScrollbar(scrollbar);
     160    ASSERT(scrollerImp);
     161    scrollerImp.userInterfaceLayoutDirection = scrollbar.scrollableArea().verticalScrollbarIsOnLeft() ? NSUserInterfaceLayoutDirectionRightToLeft : NSUserInterfaceLayoutDirectionLeftToRight;
     162#else
     163    UNUSED_PARAM(scrollbar);
     164#endif
     165}
     166
    156167void ScrollbarThemeMac::registerScrollbar(Scrollbar& scrollbar)
    157168{
     
    162173    NSScrollerImp *scrollerImp = [NSScrollerImp scrollerImpWithStyle:recommendedScrollerStyle() controlSize:scrollbarControlSizeToNSControlSize(scrollbar.controlSize()) horizontal:isHorizontal replacingScrollerImp:nil];
    163174    scrollbarMap()->add(&scrollbar, scrollerImp);
     175    didCreateScrollerImp(scrollbar);
    164176    updateEnabledState(scrollbar);
    165177    updateScrollbarOverlayStyle(scrollbar);
     
    181193{
    182194    return scrollbarMap()->get(&scrollbar).get();
     195}
     196
     197bool ScrollbarThemeMac::isLayoutDirectionRTL(Scrollbar& scrollbar)
     198{
     199#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
     200    NSScrollerImp *scrollerImp = painterForScrollbar(scrollbar);
     201    ASSERT(scrollerImp);
     202    return scrollerImp.userInterfaceLayoutDirection == NSUserInterfaceLayoutDirectionRightToLeft;
     203#else
     204    UNUSED_PARAM(scrollbar);
     205    return false;
     206#endif
    183207}
    184208
  • trunk/Source/WebCore/platform/spi/mac/NSScrollerImpSPI.h

    r198817 r198859  
    8080@property(readonly) CGFloat knobOverlapEndInset;
    8181@property(readonly) CGFloat trackOverlapEndInset;
     82@property NSUserInterfaceLayoutDirection userInterfaceLayoutDirection;
    8283- (NSRect)rectForPart:(NSScrollerPart)partCode;
    8384- (void)drawKnobSlotInRect:(NSRect)slotRect highlight:(BOOL)flag alpha:(CGFloat)alpha;
  • trunk/Source/WebCore/rendering/RenderTreeAsText.cpp

    r196244 r198859  
    7373#include <wtf/unicode/CharacterNames.h>
    7474
     75#if PLATFORM(MAC)
     76#include "ScrollbarThemeMac.h"
     77#endif
     78
    7579namespace WebCore {
    7680
     
    622626        if (layer.renderBox() && roundToInt(layer.renderBox()->clientHeight()) != layer.scrollHeight())
    623627            ts << " scrollHeight " << layer.scrollHeight();
     628#if PLATFORM(MAC)
     629        ScrollbarTheme& scrollbarTheme = ScrollbarTheme::theme();
     630        if (!scrollbarTheme.isMockTheme() && layer.hasVerticalScrollbar()) {
     631            ScrollbarThemeMac& macTheme = *static_cast<ScrollbarThemeMac*>(&scrollbarTheme);
     632            if (macTheme.isLayoutDirectionRTL(*layer.verticalScrollbar()))
     633                ts << " scrollbarHasRTLLayoutDirection";
     634        }
     635#endif
    624636    }
    625637
  • trunk/Source/WebCore/testing/Internals.cpp

    r198492 r198859  
    27382738}
    27392739
     2740void Internals::setMockScrollbarsEnabled(bool enabled)
     2741{
     2742    WebCore::Settings::setMockScrollbarsEnabled(enabled);
     2743}
     2744
    27402745void Internals::forceReload(bool endToEnd)
    27412746{
  • trunk/Source/WebCore/testing/Internals.h

    r198492 r198859  
    349349    bool isFromCurrentWorld(Deprecated::ScriptValue) const;
    350350
    351     void setUsesOverlayScrollbars(bool enabled);
    352     void setUsesMockScrollAnimator(bool enabled);
     351    void setUsesOverlayScrollbars(bool);
     352    void setUsesMockScrollAnimator(bool);
     353    void setMockScrollbarsEnabled(bool);
    353354
    354355    String getCurrentCursorInfo(ExceptionCode&);
  • trunk/Source/WebCore/testing/Internals.idl

    r198833 r198859  
    352352    void setUsesOverlayScrollbars(boolean enabled);
    353353    void setUsesMockScrollAnimator(boolean enabled);
     354    void setMockScrollbarsEnabled(boolean enabled);
    354355
    355356    void forceReload(boolean endToEnd);
Note: See TracChangeset for help on using the changeset viewer.