Title: [203267] trunk
Revision
203267
Author
[email protected]
Date
2016-07-14 20:56:51 -0700 (Thu, 14 Jul 2016)

Log Message

[RTL Scrollbars] Frame scrollbars don't move to the right when text direction changes to RTL
https://bugs.webkit.org/show_bug.cgi?id=158252

Patch by Antonio Gomes <[email protected]> on 2016-07-14
Reviewed by Myles C. Maxfield.

Source/WebCore:

When the 'dir' attribute changes either on body or on the document
element level, the associated FrameView does not trigger an update on
the frame level vertical scrollbar.

Patch adds a 'hook' so that RenderBox::styleDidChange can call in
order to get the document level scrollbar placed properly in the next
layout.

Test: fast/scrolling/rtl-scrollbars-alternate-body-dir-attr-does-not-update-scrollbar-placement.html
      fast/scrolling/rtl-scrollbars-alternate-body-dir-attr-does-not-update-scrollbar-placement-2.html
      fast/scrolling/rtl-scrollbars-alternate-iframe-body-dir-attr-does-not-update-scrollbar-placement.html

* page/FrameView.cpp:
(WebCore::FrameView::topContentDirectionDidChange):
* page/FrameView.h:
* rendering/RenderBox.cpp:
(WebCore::RenderBox::styleDidChange):

LayoutTests:

* fast/scrolling/rtl-scrollbars-alternate-body-dir-attr-does-not-update-scrollbar-placement.html: Added.
* fast/scrolling/rtl-scrollbars-alternate-body-dir-attr-does-not-update-scrollbar-placement-expected.txt: Added.
* fast/scrolling/rtl-scrollbars-alternate-body-dir-attr-does-not-update-scrollbar-placement-2.html: Added.
* fast/scrolling/rtl-scrollbars-alternate-body-dir-attr-does-not-update-scrollbar-placement-2-expected.html: Added.
* fast/scrolling/rtl-scrollbars-alternate-iframe-body-dir-attr-does-not-update-scrollbar-placement.html: Added.
* fast/scrolling/rtl-scrollbars-alternate-iframe-body-dir-attr-does-not-update-scrollbar-placement-expected.txt: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (203266 => 203267)


--- trunk/LayoutTests/ChangeLog	2016-07-15 03:11:15 UTC (rev 203266)
+++ trunk/LayoutTests/ChangeLog	2016-07-15 03:56:51 UTC (rev 203267)
@@ -1,3 +1,17 @@
+2016-07-14  Antonio Gomes  <[email protected]>
+
+        [RTL Scrollbars] Frame scrollbars don't move to the right when text direction changes to RTL
+        https://bugs.webkit.org/show_bug.cgi?id=158252
+
+        Reviewed by Myles C. Maxfield.
+
+        * fast/scrolling/rtl-scrollbars-alternate-body-dir-attr-does-not-update-scrollbar-placement.html: Added.
+        * fast/scrolling/rtl-scrollbars-alternate-body-dir-attr-does-not-update-scrollbar-placement-expected.txt: Added.
+        * fast/scrolling/rtl-scrollbars-alternate-body-dir-attr-does-not-update-scrollbar-placement-2.html: Added.
+        * fast/scrolling/rtl-scrollbars-alternate-body-dir-attr-does-not-update-scrollbar-placement-2-expected.html: Added.
+        * fast/scrolling/rtl-scrollbars-alternate-iframe-body-dir-attr-does-not-update-scrollbar-placement.html: Added.
+        * fast/scrolling/rtl-scrollbars-alternate-iframe-body-dir-attr-does-not-update-scrollbar-placement-expected.txt: Added.
+
 2016-07-14  Myles C. Maxfield  <[email protected]>
 
         Support new emoji group candidates

Modified: trunk/LayoutTests/TestExpectations (203266 => 203267)


--- trunk/LayoutTests/TestExpectations	2016-07-15 03:11:15 UTC (rev 203266)
+++ trunk/LayoutTests/TestExpectations	2016-07-15 03:56:51 UTC (rev 203267)
@@ -973,6 +973,9 @@
 fast/scrolling/rtl-scrollbars-listbox-simple.html [ ImageOnlyFailure ]
 fast/scrolling/rtl-scrollbars-listbox.html [ ImageOnlyFailure ]
 fast/scrolling/rtl-scrollbars-positioned-intersect-scrollbars.html [ ImageOnlyFailure ]
+fast/scrolling/rtl-scrollbars-alternate-body-dir-attr-does-not-update-scrollbar-placement.html [ ImageOnlyFailure ]
+fast/scrolling/rtl-scrollbars-alternate-body-dir-attr-does-not-update-scrollbar-placement-2.html [ ImageOnlyFailure ]
+fast/scrolling/rtl-scrollbars-alternate-iframe-body-dir-attr-does-not-update-scrollbar-placement.html [ ImageOnlyFailure ]
 
 # <a download> does not support Blobs
 webkit.org/b/156099 http/tests/security/anchor-download-allow-blob.html [ Failure ]

Added: trunk/LayoutTests/fast/scrolling/rtl-scrollbars-alternate-body-dir-attr-does-not-update-scrollbar-placement-2-expected.html (0 => 203267)


--- trunk/LayoutTests/fast/scrolling/rtl-scrollbars-alternate-body-dir-attr-does-not-update-scrollbar-placement-2-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/scrolling/rtl-scrollbars-alternate-body-dir-attr-does-not-update-scrollbar-placement-2-expected.html	2016-07-15 03:56:51 UTC (rev 203267)
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<head>
+    <style type='text/css'>
+        body {
+            height: 5000px;
+        }
+    </style>
+    <script>
+        if (window.internals) {
+            internals.settings.setUserInterfaceDirectionPolicy("View");
+            internals.settings.setSystemLayoutDirection("RTL");
+        }
+    </script>
+</head>
+<body style='min-height: 5000px'></body>

Added: trunk/LayoutTests/fast/scrolling/rtl-scrollbars-alternate-body-dir-attr-does-not-update-scrollbar-placement-2.html (0 => 203267)


--- trunk/LayoutTests/fast/scrolling/rtl-scrollbars-alternate-body-dir-attr-does-not-update-scrollbar-placement-2.html	                        (rev 0)
+++ trunk/LayoutTests/fast/scrolling/rtl-scrollbars-alternate-body-dir-attr-does-not-update-scrollbar-placement-2.html	2016-07-15 03:56:51 UTC (rev 203267)
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<head>
+    <style type='text/css'>
+        body {
+            height: 5000px;
+            direction: ltr;
+        }
+    </style>
+    <script>
+        if (window.internals)
+            internals.settings.setUserInterfaceDirectionPolicy('Content');
+
+        function startTest()
+        {
+            document.scrollingElement.scrollTop = 0;
+            document.body.style.direction = 'rtl';
+        }
+    </script>
+</head>
+<body style='min-height: 5000px' _onload_='startTest();'></body>

Added: trunk/LayoutTests/fast/scrolling/rtl-scrollbars-alternate-body-dir-attr-does-not-update-scrollbar-placement-expected.txt (0 => 203267)


--- trunk/LayoutTests/fast/scrolling/rtl-scrollbars-alternate-body-dir-attr-does-not-update-scrollbar-placement-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/scrolling/rtl-scrollbars-alternate-body-dir-attr-does-not-update-scrollbar-placement-expected.txt	2016-07-15 03:56:51 UTC (rev 203267)
@@ -0,0 +1,6 @@
+ACTION : Drag the outermost frame LTR scrollbar.
+PASS scroller.scrollTop is not 0
+ACTION : Flip 'dir' from 'rtl' to 'ltr'.
+ACTION : Drag the outermost frame RTL scrollbar.
+PASS scroller.scrollTop is not 0
+

Added: trunk/LayoutTests/fast/scrolling/rtl-scrollbars-alternate-body-dir-attr-does-not-update-scrollbar-placement.html (0 => 203267)


--- trunk/LayoutTests/fast/scrolling/rtl-scrollbars-alternate-body-dir-attr-does-not-update-scrollbar-placement.html	                        (rev 0)
+++ trunk/LayoutTests/fast/scrolling/rtl-scrollbars-alternate-body-dir-attr-does-not-update-scrollbar-placement.html	2016-07-15 03:56:51 UTC (rev 203267)
@@ -0,0 +1,60 @@
+<!-- webkit-test-runner [ useThreadedScrolling=false ] -->
+<!DOCTYPE html>
+<head>
+    <style type='text/css'>
+        body {
+            height: 5000px;
+            direction: ltr;
+        }
+    </style>
+    <script src=""
+    <script>
+        window.jsTestIsAsync = true;
+
+        var scroller;
+        var previousScrollPosition;
+
+        if (window.internals)
+            internals.settings.setUserInterfaceDirectionPolicy('Content');
+
+        function doTest()
+        {
+            previousScrollPosition = scroller.scrollTop;
+
+            debug('ACTION : Drag the outermost frame LTR scrollbar.');
+            eventSender.mouseMoveTo(window.innerWidth - 4, 20);
+            eventSender.mouseDown();
+            eventSender.mouseMoveTo(window.innerWidth - 4, 50);
+            eventSender.mouseUp();
+
+            shouldNotBe("scroller.scrollTop", "0");
+
+            debug('ACTION : Flip \'dir\' from \'rtl\' to \'ltr\'.');
+            document.scrollingElement.scrollTop = 0;
+            document.body.style.direction = 'rtl';
+
+            debug('ACTION : Drag the outermost frame RTL scrollbar.');
+            previousScrollPosition = scroller.scrollTop;
+            eventSender.mouseMoveTo(4, 20);
+            eventSender.mouseDown();
+            eventSender.mouseMoveTo(4, 50);
+            eventSender.mouseUp();
+
+            shouldNotBe("scroller.scrollTop", "0");
+            testRunner.notifyDone();
+        }
+
+        function startTest()
+        {
+            if (window.eventSender) {
+                testRunner.dumpAsText();
+                testRunner.waitUntilDone();
+
+                scroller = document.scrollingElement;
+                setTimeout(doTest, 0);
+            }
+        }
+    </script>
+    <script src=""
+</head>
+<body style='min-height: 5000px' _onload_='startTest();'></body>

Added: trunk/LayoutTests/fast/scrolling/rtl-scrollbars-alternate-iframe-body-dir-attr-does-not-update-scrollbar-placement-expected.html (0 => 203267)


--- trunk/LayoutTests/fast/scrolling/rtl-scrollbars-alternate-iframe-body-dir-attr-does-not-update-scrollbar-placement-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/scrolling/rtl-scrollbars-alternate-iframe-body-dir-attr-does-not-update-scrollbar-placement-expected.html	2016-07-15 03:56:51 UTC (rev 203267)
@@ -0,0 +1,19 @@
+<html>
+    <script>
+        if (window.internals) {
+            internals.settings.setUserInterfaceDirectionPolicy("View");
+            internals.settings.setSystemLayoutDirection("RTL");
+        }
+    </script>
+    <iframe width="200" height="100" scrolling="yes" src=""
+        <html>
+            <body id='body' dir='rtl'>
+              Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
+              Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
+              dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
+              proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
+            </body>
+        </html>">
+    </iframe>
+</html>
+

Added: trunk/LayoutTests/fast/scrolling/rtl-scrollbars-alternate-iframe-body-dir-attr-does-not-update-scrollbar-placement.html (0 => 203267)


--- trunk/LayoutTests/fast/scrolling/rtl-scrollbars-alternate-iframe-body-dir-attr-does-not-update-scrollbar-placement.html	                        (rev 0)
+++ trunk/LayoutTests/fast/scrolling/rtl-scrollbars-alternate-iframe-body-dir-attr-does-not-update-scrollbar-placement.html	2016-07-15 03:56:51 UTC (rev 203267)
@@ -0,0 +1,20 @@
+<html>
+    <iframe width="200" height="100" scrolling="yes" src=""
+        <html>
+            <script>
+                function load()
+                {
+                    var body = document.getElementById('body');
+                    body.style.direction='rtl';
+                }
+            </script>
+            <body id='body' _onload_='setTimeout(load, 0);'>
+              Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
+              Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
+              dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
+              proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
+            </body>
+        </html>">
+    </iframe>
+</html>
+

Modified: trunk/LayoutTests/platform/gtk/TestExpectations (203266 => 203267)


--- trunk/LayoutTests/platform/gtk/TestExpectations	2016-07-15 03:11:15 UTC (rev 203266)
+++ trunk/LayoutTests/platform/gtk/TestExpectations	2016-07-15 03:56:51 UTC (rev 203267)
@@ -2649,6 +2649,9 @@
 fast/scrolling/rtl-scrollbars-listbox-simple.html [ Pass ]
 fast/scrolling/rtl-scrollbars-listbox.html [ Pass ]
 fast/scrolling/rtl-scrollbars-positioned-intersect-scrollbars.html [ Pass ]
+fast/scrolling/rtl-scrollbars-alternate-body-dir-attr-does-not-update-scrollbar-placement.html [ Pass ]
+fast/scrolling/rtl-scrollbars-alternate-body-dir-attr-does-not-update-scrollbar-placement-2.html [ Pass ]
+fast/scrolling/rtl-scrollbars-alternate-iframe-body-dir-attr-does-not-update-scrollbar-placement.html [ Pass ]
 
 # https://bugs.webkit.org/show_bug.cgi?id=156612
 http/tests/security/contentSecurityPolicy/embed-redirect-blocked3.html [ Pass ]

Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (203266 => 203267)


--- trunk/LayoutTests/platform/mac-wk2/TestExpectations	2016-07-15 03:11:15 UTC (rev 203266)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations	2016-07-15 03:56:51 UTC (rev 203267)
@@ -506,6 +506,9 @@
 [ Sierra+ ] fast/scrolling/rtl-scrollbars-listbox-simple.html [ Pass ]
 [ Sierra+ ] fast/scrolling/rtl-scrollbars-listbox.html [ Pass ]
 [ Sierra+ ] fast/scrolling/rtl-scrollbars-positioned-intersect-scrollbars.html [ Pass ]
+[ Sierra+ ] fast/scrolling/rtl-scrollbars-alternate-body-dir-attr-does-not-update-scrollbar-placement.html [ Pass ]
+[ Sierra+ ] fast/scrolling/rtl-scrollbars-alternate-body-dir-attr-does-not-update-scrollbar-placement-2.html [ Pass ]
+[ Sierra+ ] fast/scrolling/rtl-scrollbars-alternate-iframe-body-dir-attr-does-not-update-scrollbar-placement.html [ Pass ]
 
 # <rdar://problem/25063128>
 [ Sierra+ ] media/media-controls-drag-timeline-set-controls-property.html [ Pass Timeout ]

Modified: trunk/Source/WebCore/ChangeLog (203266 => 203267)


--- trunk/Source/WebCore/ChangeLog	2016-07-15 03:11:15 UTC (rev 203266)
+++ trunk/Source/WebCore/ChangeLog	2016-07-15 03:56:51 UTC (rev 203267)
@@ -1,3 +1,28 @@
+2016-07-14  Antonio Gomes  <[email protected]>
+
+        [RTL Scrollbars] Frame scrollbars don't move to the right when text direction changes to RTL
+        https://bugs.webkit.org/show_bug.cgi?id=158252
+
+        Reviewed by Myles C. Maxfield.
+
+        When the 'dir' attribute changes either on body or on the document
+        element level, the associated FrameView does not trigger an update on
+        the frame level vertical scrollbar.
+
+        Patch adds a 'hook' so that RenderBox::styleDidChange can call in
+        order to get the document level scrollbar placed properly in the next
+        layout.
+
+        Test: fast/scrolling/rtl-scrollbars-alternate-body-dir-attr-does-not-update-scrollbar-placement.html
+              fast/scrolling/rtl-scrollbars-alternate-body-dir-attr-does-not-update-scrollbar-placement-2.html
+              fast/scrolling/rtl-scrollbars-alternate-iframe-body-dir-attr-does-not-update-scrollbar-placement.html
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::topContentDirectionDidChange):
+        * page/FrameView.h:
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::styleDidChange):
+
 2016-07-14  Myles C. Maxfield  <[email protected]>
 
         Support new emoji group candidates

Modified: trunk/Source/WebCore/page/FrameView.cpp (203266 => 203267)


--- trunk/Source/WebCore/page/FrameView.cpp	2016-07-15 03:11:15 UTC (rev 203266)
+++ trunk/Source/WebCore/page/FrameView.cpp	2016-07-15 03:56:51 UTC (rev 203267)
@@ -319,6 +319,7 @@
     m_isVisuallyNonEmpty = false;
     m_firstVisuallyNonEmptyLayoutCallbackPending = true;
     m_viewportIsStable = true;
+    m_needsDeferredScrollbarsUpdate = false;
     m_maintainScrollPositionAnchor = nullptr;
 }
 
@@ -1126,6 +1127,23 @@
     if (TiledBacking* tiledBacking = this->tiledBacking())
         tiledBacking->setTopContentInset(newTopContentInset);
 }
+
+void FrameView::topContentDirectionDidChange()
+{
+    m_needsDeferredScrollbarsUpdate = true;
+}
+
+void FrameView::handleDeferredScrollbarsUpdateAfterDirectionChange()
+{
+    if (!m_needsDeferredScrollbarsUpdate)
+        return;
+
+    m_needsDeferredScrollbarsUpdate = false;
+
+    ASSERT(m_layoutPhase == InPostLayerPositionsUpdatedAfterLayout);
+    updateScrollbars(scrollPosition());
+    positionScrollbarLayers();
+}
     
 bool FrameView::hasCompositedContent() const
 {
@@ -1479,6 +1497,8 @@
 
     handleDeferredScrollUpdateAfterContentSizeChange();
 
+    handleDeferredScrollbarsUpdateAfterDirectionChange();
+
     if (document.hasListenerType(Document::OVERFLOWCHANGED_LISTENER))
         updateOverflowStatus(layoutWidth() < contentsWidth(), layoutHeight() < contentsHeight());
 

Modified: trunk/Source/WebCore/page/FrameView.h (203266 => 203267)


--- trunk/Source/WebCore/page/FrameView.h	2016-07-15 03:11:15 UTC (rev 203266)
+++ trunk/Source/WebCore/page/FrameView.h	2016-07-15 03:56:51 UTC (rev 203267)
@@ -504,6 +504,8 @@
     WEBCORE_EXPORT float topContentInset(TopContentInsetType = TopContentInsetType::WebCoreContentInset) const override;
     void topContentInsetDidChange(float newTopContentInset);
 
+    void topContentDirectionDidChange();
+
     WEBCORE_EXPORT void willStartLiveResize() override;
     WEBCORE_EXPORT void willEndLiveResize() override;
 
@@ -657,6 +659,8 @@
     IntSize sizeForResizeEvent() const;
     void sendResizeEventIfNeeded();
 
+    void handleDeferredScrollbarsUpdateAfterDirectionChange();
+
     void updateScrollableAreaSet();
 
     void notifyPageThatContentAreaWillPaint() const override;
@@ -772,6 +776,8 @@
 
     bool m_viewportIsStable { true };
 
+    bool m_needsDeferredScrollbarsUpdate { false };
+
     RefPtr<ContainerNode> m_maintainScrollPositionAnchor;
 
     // Renderer to hold our custom scroll corner.

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (203266 => 203267)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2016-07-15 03:11:15 UTC (rev 203266)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2016-07-15 03:56:51 UTC (rev 203267)
@@ -401,6 +401,8 @@
                 rootStyleChanged = true;
             }
             setNeedsLayoutAndPrefWidthsRecalc();
+
+            view().frameView().topContentDirectionDidChange();
         }
 
         if (viewStyle.writingMode() != newStyle.writingMode() && (isDocElementRenderer || !documentElementRenderer->style().hasExplicitlySetWritingMode())) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to