Title: [198859] trunk
Revision
198859
Author
[email protected]
Date
2016-03-30 15:19:08 -0700 (Wed, 30 Mar 2016)

Log 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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (198858 => 198859)


--- trunk/LayoutTests/ChangeLog	2016-03-30 22:06:38 UTC (rev 198858)
+++ trunk/LayoutTests/ChangeLog	2016-03-30 22:19:08 UTC (rev 198859)
@@ -1,3 +1,15 @@
+2016-03-30  Myles C. Maxfield  <[email protected]>
+
+        [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.
+
+        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.
+
 2016-03-30  Sam Weinig  <[email protected]>
 
         -webkit-text-underline-position: under; does not work in ToT

Added: trunk/LayoutTests/fast/scrolling/rtl-scrollbars-animation-property.html (0 => 198859)


--- trunk/LayoutTests/fast/scrolling/rtl-scrollbars-animation-property.html	                        (rev 0)
+++ trunk/LayoutTests/fast/scrolling/rtl-scrollbars-animation-property.html	2016-03-30 22:19:08 UTC (rev 198859)
@@ -0,0 +1,15 @@
+<!DOCTYPE html><!-- webkit-test-runner [ rtlScrollbars=true ] -->
+<html>
+<head>
+<script>
+if (window.internals)
+    window.internals.setMockScrollbarsEnabled(false);
+</script>
+</head>
+<body>
+<div style="width: 200px; height: 200px; position: relative; overflow: scroll;">
+<div style="width: 1px; height: 2000px; position: absolute; left: 0px; top: 0px;"></div>
+</div>
+<div style="width: 1px; height: 2000px; position: absolute; left: 0px; top: 0px;"></div>
+</body>
+<html>

Added: trunk/LayoutTests/platform/mac/fast/scrolling/rtl-scrollbars-animation-property-expected.txt (0 => 198859)


--- trunk/LayoutTests/platform/mac/fast/scrolling/rtl-scrollbars-animation-property-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/fast/scrolling/rtl-scrollbars-animation-property-expected.txt	2016-03-30 22:19:08 UTC (rev 198859)
@@ -0,0 +1,11 @@
+layer at (0,0) size 785x2000
+  RenderView at (0,0) size 785x600
+layer at (0,0) size 785x216
+  RenderBlock {HTML} at (0,0) size 785x216
+    RenderBody {BODY} at (8,8) size 769x200
+layer at (8,8) size 200x200 clip at (8,8) size 185x185 scrollHeight 2000
+  RenderBlock (relative positioned) {DIV} at (0,0) size 200x200
+layer at (8,8) size 1x2000 backgroundClip at (8,8) size 185x185 clip at (8,8) size 185x185
+  RenderBlock (positioned) {DIV} at (0,0) size 1x2000
+layer at (0,0) size 1x2000
+  RenderBlock (positioned) {DIV} at (0,0) size 1x2000

Modified: trunk/Source/WebCore/ChangeLog (198858 => 198859)


--- trunk/Source/WebCore/ChangeLog	2016-03-30 22:06:38 UTC (rev 198858)
+++ trunk/Source/WebCore/ChangeLog	2016-03-30 22:19:08 UTC (rev 198859)
@@ -1,3 +1,47 @@
+2016-03-30  Myles C. Maxfield  <[email protected]>
+
+        [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.
+
+        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:
+
 2016-03-30  Sam Weinig  <[email protected]>
 
         -webkit-text-underline-position: under; does not work in ToT

Modified: trunk/Source/WebCore/platform/ScrollableArea.h (198858 => 198859)


--- trunk/Source/WebCore/platform/ScrollableArea.h	2016-03-30 22:06:38 UTC (rev 198858)
+++ trunk/Source/WebCore/platform/ScrollableArea.h	2016-03-30 22:19:08 UTC (rev 198859)
@@ -180,8 +180,8 @@
     int verticalScrollbarIntrusion() const;
     WEBCORE_EXPORT IntSize scrollbarIntrusion() const;
 
-    virtual Scrollbar* horizontalScrollbar() const { return 0; }
-    virtual Scrollbar* verticalScrollbar() const { return 0; }
+    virtual Scrollbar* horizontalScrollbar() const { return nullptr; }
+    virtual Scrollbar* verticalScrollbar() const { return nullptr; }
 
     const IntPoint& scrollOrigin() const { return m_scrollOrigin; }
     bool scrollOriginChanged() const { return m_scrollOriginChanged; }
@@ -293,15 +293,15 @@
     bool isPinnedVerticallyInDirection(int verticalScrollDelta) const;
 #endif
 
-    virtual TiledBacking* tiledBacking() const { return 0; }
+    virtual TiledBacking* tiledBacking() const { return nullptr; }
 
     // True if scrolling happens by moving compositing layers.
     virtual bool usesCompositedScrolling() const { return false; }
     // True if the contents can be scrolled asynchronously (i.e. by a ScrollingCoordinator).
     virtual bool usesAsyncScrolling() const { return false; }
 
-    virtual GraphicsLayer* layerForHorizontalScrollbar() const { return 0; }
-    virtual GraphicsLayer* layerForVerticalScrollbar() const { return 0; }
+    virtual GraphicsLayer* layerForHorizontalScrollbar() const { return nullptr; }
+    virtual GraphicsLayer* layerForVerticalScrollbar() const { return nullptr; }
 
     bool hasLayerForHorizontalScrollbar() const;
     bool hasLayerForVerticalScrollbar() const;
@@ -327,10 +327,10 @@
     virtual void invalidateScrollCornerRect(const IntRect&) = 0;
 
     friend class ScrollingCoordinator;
-    virtual GraphicsLayer* layerForScrolling() const { return 0; }
-    virtual GraphicsLayer* layerForScrollCorner() const { return 0; }
+    virtual GraphicsLayer* layerForScrolling() const { return nullptr; }
+    virtual GraphicsLayer* layerForScrollCorner() const { return nullptr; }
 #if ENABLE(RUBBER_BANDING)
-    virtual GraphicsLayer* layerForOverhangAreas() const { return 0; }
+    virtual GraphicsLayer* layerForOverhangAreas() const { return nullptr; }
 #endif
 
     bool hasLayerForScrollCorner() const;

Modified: trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm (198858 => 198859)


--- trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm	2016-03-30 22:06:38 UTC (rev 198858)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm	2016-03-30 22:19:08 UTC (rev 198859)
@@ -1303,6 +1303,7 @@
 
         [m_scrollerImpPair setVerticalScrollerImp:newVerticalPainter];
         macTheme->setNewPainterForScrollbar(*verticalScrollbar, newVerticalPainter);
+        macTheme->didCreateScrollerImp(*verticalScrollbar);
 
         // The different scrollbar styles have different thicknesses, so we must re-set the 
         // frameRect to the new thickness, and the re-layout below will ensure the position
@@ -1319,6 +1320,7 @@
 
         [m_scrollerImpPair setHorizontalScrollerImp:newHorizontalPainter];
         macTheme->setNewPainterForScrollbar(*horizontalScrollbar, newHorizontalPainter);
+        macTheme->didCreateScrollerImp(*horizontalScrollbar);
 
         // The different scrollbar styles have different thicknesses, so we must re-set the 
         // frameRect to the new thickness, and the re-layout below will ensure the position

Modified: trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.h (198858 => 198859)


--- trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.h	2016-03-30 22:06:38 UTC (rev 198858)
+++ trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.h	2016-03-30 22:19:08 UTC (rev 198859)
@@ -64,6 +64,9 @@
     static bool isCurrentlyDrawingIntoLayer();
     static void setIsCurrentlyDrawingIntoLayer(bool);
 
+    void didCreateScrollerImp(Scrollbar&);
+    bool isLayoutDirectionRTL(Scrollbar&);
+
 #if ENABLE(RUBBER_BANDING)
     WEBCORE_EXPORT static void setUpOverhangAreaBackground(CALayer *, const Color& customBackgroundColor = Color());
     WEBCORE_EXPORT static void removeOverhangAreaBackground(CALayer *);

Modified: trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.mm (198858 => 198859)


--- trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.mm	2016-03-30 22:06:38 UTC (rev 198858)
+++ trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.mm	2016-03-30 22:19:08 UTC (rev 198859)
@@ -153,6 +153,17 @@
 #pragma clang diagnostic pop
 }
 
+void ScrollbarThemeMac::didCreateScrollerImp(Scrollbar& scrollbar)
+{
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+    NSScrollerImp *scrollerImp = painterForScrollbar(scrollbar);
+    ASSERT(scrollerImp);
+    scrollerImp.userInterfaceLayoutDirection = scrollbar.scrollableArea().verticalScrollbarIsOnLeft() ? NSUserInterfaceLayoutDirectionRightToLeft : NSUserInterfaceLayoutDirectionLeftToRight;
+#else
+    UNUSED_PARAM(scrollbar);
+#endif
+}
+
 void ScrollbarThemeMac::registerScrollbar(Scrollbar& scrollbar)
 {
     if (scrollbar.isCustomScrollbar())
@@ -161,6 +172,7 @@
     bool isHorizontal = scrollbar.orientation() == HorizontalScrollbar;
     NSScrollerImp *scrollerImp = [NSScrollerImp scrollerImpWithStyle:recommendedScrollerStyle() controlSize:scrollbarControlSizeToNSControlSize(scrollbar.controlSize()) horizontal:isHorizontal replacingScrollerImp:nil];
     scrollbarMap()->add(&scrollbar, scrollerImp);
+    didCreateScrollerImp(scrollbar);
     updateEnabledState(scrollbar);
     updateScrollbarOverlayStyle(scrollbar);
 }
@@ -182,6 +194,18 @@
     return scrollbarMap()->get(&scrollbar).get();
 }
 
+bool ScrollbarThemeMac::isLayoutDirectionRTL(Scrollbar& scrollbar)
+{
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+    NSScrollerImp *scrollerImp = painterForScrollbar(scrollbar);
+    ASSERT(scrollerImp);
+    return scrollerImp.userInterfaceLayoutDirection == NSUserInterfaceLayoutDirectionRightToLeft;
+#else
+    UNUSED_PARAM(scrollbar);
+    return false;
+#endif
+}
+
 static bool g_isCurrentlyDrawingIntoLayer;
     
 bool ScrollbarThemeMac::isCurrentlyDrawingIntoLayer()

Modified: trunk/Source/WebCore/platform/spi/mac/NSScrollerImpSPI.h (198858 => 198859)


--- trunk/Source/WebCore/platform/spi/mac/NSScrollerImpSPI.h	2016-03-30 22:06:38 UTC (rev 198858)
+++ trunk/Source/WebCore/platform/spi/mac/NSScrollerImpSPI.h	2016-03-30 22:19:08 UTC (rev 198859)
@@ -79,6 +79,7 @@
 @property(readonly) CGFloat knobMinLength;
 @property(readonly) CGFloat knobOverlapEndInset;
 @property(readonly) CGFloat trackOverlapEndInset;
+@property NSUserInterfaceLayoutDirection userInterfaceLayoutDirection;
 - (NSRect)rectForPart:(NSScrollerPart)partCode;
 - (void)drawKnobSlotInRect:(NSRect)slotRect highlight:(BOOL)flag alpha:(CGFloat)alpha;
 - (void)drawKnobSlotInRect:(NSRect)slotRect highlight:(BOOL)flag;

Modified: trunk/Source/WebCore/rendering/RenderTreeAsText.cpp (198858 => 198859)


--- trunk/Source/WebCore/rendering/RenderTreeAsText.cpp	2016-03-30 22:06:38 UTC (rev 198858)
+++ trunk/Source/WebCore/rendering/RenderTreeAsText.cpp	2016-03-30 22:19:08 UTC (rev 198859)
@@ -72,6 +72,10 @@
 #include <wtf/Vector.h>
 #include <wtf/unicode/CharacterNames.h>
 
+#if PLATFORM(MAC)
+#include "ScrollbarThemeMac.h"
+#endif
+
 namespace WebCore {
 
 using namespace HTMLNames;
@@ -621,6 +625,14 @@
             ts << " scrollWidth " << layer.scrollWidth();
         if (layer.renderBox() && roundToInt(layer.renderBox()->clientHeight()) != layer.scrollHeight())
             ts << " scrollHeight " << layer.scrollHeight();
+#if PLATFORM(MAC)
+        ScrollbarTheme& scrollbarTheme = ScrollbarTheme::theme();
+        if (!scrollbarTheme.isMockTheme() && layer.hasVerticalScrollbar()) {
+            ScrollbarThemeMac& macTheme = *static_cast<ScrollbarThemeMac*>(&scrollbarTheme);
+            if (macTheme.isLayoutDirectionRTL(*layer.verticalScrollbar()))
+                ts << " scrollbarHasRTLLayoutDirection";
+        }
+#endif
     }
 
     if (paintPhase == LayerPaintPhaseBackground)

Modified: trunk/Source/WebCore/testing/Internals.cpp (198858 => 198859)


--- trunk/Source/WebCore/testing/Internals.cpp	2016-03-30 22:06:38 UTC (rev 198858)
+++ trunk/Source/WebCore/testing/Internals.cpp	2016-03-30 22:19:08 UTC (rev 198859)
@@ -2737,6 +2737,11 @@
     WebCore::Settings::setUsesMockScrollAnimator(enabled);
 }
 
+void Internals::setMockScrollbarsEnabled(bool enabled)
+{
+    WebCore::Settings::setMockScrollbarsEnabled(enabled);
+}
+
 void Internals::forceReload(bool endToEnd)
 {
     frame()->loader().reload(endToEnd);

Modified: trunk/Source/WebCore/testing/Internals.h (198858 => 198859)


--- trunk/Source/WebCore/testing/Internals.h	2016-03-30 22:06:38 UTC (rev 198858)
+++ trunk/Source/WebCore/testing/Internals.h	2016-03-30 22:19:08 UTC (rev 198859)
@@ -348,8 +348,9 @@
 
     bool isFromCurrentWorld(Deprecated::ScriptValue) const;
 
-    void setUsesOverlayScrollbars(bool enabled);
-    void setUsesMockScrollAnimator(bool enabled);
+    void setUsesOverlayScrollbars(bool);
+    void setUsesMockScrollAnimator(bool);
+    void setMockScrollbarsEnabled(bool);
 
     String getCurrentCursorInfo(ExceptionCode&);
 

Modified: trunk/Source/WebCore/testing/Internals.idl (198858 => 198859)


--- trunk/Source/WebCore/testing/Internals.idl	2016-03-30 22:06:38 UTC (rev 198858)
+++ trunk/Source/WebCore/testing/Internals.idl	2016-03-30 22:19:08 UTC (rev 198859)
@@ -351,6 +351,7 @@
 
     void setUsesOverlayScrollbars(boolean enabled);
     void setUsesMockScrollAnimator(boolean enabled);
+    void setMockScrollbarsEnabled(boolean enabled);
 
     void forceReload(boolean endToEnd);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to