Title: [109512] trunk
Revision
109512
Author
[email protected]
Date
2012-03-01 22:33:00 -0800 (Thu, 01 Mar 2012)

Log Message

Render overflow controls of an RTL element to its left-side.
https://bugs.webkit.org/show_bug.cgi?id=54623

This change adds a new flag WTF_USE_RTL_SCROLLBAR and render the
vertical scrollbars and resizers of RTL elements to their left side if
this new flag is enabled.

Patch by Hironori Bono <[email protected]> on 2012-03-01
Reviewed by Ryosuke Niwa.

Source/WebCore:

Test: platform/chromium/fast/events/rtl-scrollbar.html

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::addOverflowFromPositionedObjects): Move child elements right.
(WebCore::RenderBlock::determineLogicalLeftPositionForChild): ditto.
* rendering/RenderBox.cpp:
(WebCore::RenderBox::overflowClipRect): Move the content rectangle right.
* rendering/RenderLayer.cpp:
(WebCore::cornerStart): Added a function that calculates the X position of a resizer.
(WebCore):
(WebCore::cornerRect): Use cornerStart to move a resizer.
(WebCore::RenderLayer::verticalScrollbarStart): Added a function that calculates
the X position of a vertical scrollbar.
(WebCore::RenderLayer::horizontalScrollbarStart): Added a function that calculates
the X position of a horizontal scrollbar.
(WebCore::RenderLayer::scrollbarOffset): Render a vertical scrollbar to the left side
and move a horizontal scrollbar right by the width of the vertical scrollbar.
(WebCore::RenderLayer::invalidateScrollbarRect): ditto.
(WebCore::RenderLayer::positionOverflowControls): ditto.
(WebCore::RenderLayer::hitTestOverflowControls): ditto.
* rendering/RenderLayer.h:
(RenderLayer):
* rendering/style/RenderStyle.h: Added shouldPlaceBlockDirectionScrollbarOnLogicalLeft,
which returns if we need to move a left scrollbar to its right side.

Source/WebKit/chromium:

* features.gypi: Set WTF_USE_RTL_SCROLLBAR to 1 on Chromium.

LayoutTests:

* platform/chromium/fast/events/rtl-scrollbar-expected.txt: Added.
* platform/chromium/fast/events/rtl-scrollbar.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (109511 => 109512)


--- trunk/LayoutTests/ChangeLog	2012-03-02 06:28:45 UTC (rev 109511)
+++ trunk/LayoutTests/ChangeLog	2012-03-02 06:33:00 UTC (rev 109512)
@@ -1,3 +1,17 @@
+2012-03-01  Hironori Bono  <[email protected]>
+
+        Render overflow controls of an RTL element to its left-side.
+        https://bugs.webkit.org/show_bug.cgi?id=54623
+
+        This change adds a new flag WTF_USE_RTL_SCROLLBAR and render the
+        vertical scrollbars and resizers of RTL elements to their left side if
+        this new flag is enabled.
+
+        Reviewed by Ryosuke Niwa.
+
+        * platform/chromium/fast/events/rtl-scrollbar-expected.txt: Added.
+        * platform/chromium/fast/events/rtl-scrollbar.html: Added.
+
 2012-03-01  Dirk Pranke  <[email protected]>
 
         Tighten various expectations to be more accurate.

Added: trunk/LayoutTests/platform/chromium/fast/events/rtl-scrollbar-expected.txt (0 => 109512)


--- trunk/LayoutTests/platform/chromium/fast/events/rtl-scrollbar-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/fast/events/rtl-scrollbar-expected.txt	2012-03-02 06:33:00 UTC (rev 109512)
@@ -0,0 +1,10 @@
+Test that we can scroll down an RTL element with its left-side scrollbar.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+PASS document.getElementById('overflow').scrollTop > scrollTop is true
+
Property changes on: trunk/LayoutTests/platform/chromium/fast/events/rtl-scrollbar-expected.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/platform/chromium/fast/events/rtl-scrollbar.html (0 => 109512)


--- trunk/LayoutTests/platform/chromium/fast/events/rtl-scrollbar.html	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/fast/events/rtl-scrollbar.html	2012-03-02 06:33:00 UTC (rev 109512)
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body style="margin:0">
+<div id="overflow" dir="rtl" style="border:2px solid black;overflow:auto;height:400px;width:400px; position:absolute;">
+<div style="background-color:red;height:720px"></div>
+<div style="background-color:green;height:1600px"></div>
+</div>
+
+<script>
+description('Test that we can scroll down an RTL element with its left-side scrollbar.');
+
+var scrollTop = document.getElementById('overflow').scrollTop;
+
+if (window.layoutTestController)
+    layoutTestController.waitUntilDone();
+
+if (window.eventSender) {
+    var node = document.getElementById('overflow');
+    eventSender.mouseMoveTo(node.offsetLeft + 5, node.offsetTop + node.offsetHeight - 50);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+    setTimeout(finished, 0);
+}
+
+function finished()
+{
+    shouldBeTrue('document.getElementById(\'overflow\').scrollTop > scrollTop');
+    window.layoutTestController.notifyDone();
+}
+
+var successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>
Property changes on: trunk/LayoutTests/platform/chromium/fast/events/rtl-scrollbar.html
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (109511 => 109512)


--- trunk/Source/WebCore/ChangeLog	2012-03-02 06:28:45 UTC (rev 109511)
+++ trunk/Source/WebCore/ChangeLog	2012-03-02 06:33:00 UTC (rev 109512)
@@ -1,3 +1,39 @@
+2012-03-01  Hironori Bono  <[email protected]>
+
+        Render overflow controls of an RTL element to its left-side.
+        https://bugs.webkit.org/show_bug.cgi?id=54623
+
+        This change adds a new flag WTF_USE_RTL_SCROLLBAR and render the
+        vertical scrollbars and resizers of RTL elements to their left side if
+        this new flag is enabled.
+
+        Reviewed by Ryosuke Niwa.
+
+        Test: platform/chromium/fast/events/rtl-scrollbar.html
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::addOverflowFromPositionedObjects): Move child elements right.
+        (WebCore::RenderBlock::determineLogicalLeftPositionForChild): ditto.
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::overflowClipRect): Move the content rectangle right.
+        * rendering/RenderLayer.cpp:
+        (WebCore::cornerStart): Added a function that calculates the X position of a resizer.
+        (WebCore):
+        (WebCore::cornerRect): Use cornerStart to move a resizer.
+        (WebCore::RenderLayer::verticalScrollbarStart): Added a function that calculates
+        the X position of a vertical scrollbar.
+        (WebCore::RenderLayer::horizontalScrollbarStart): Added a function that calculates
+        the X position of a horizontal scrollbar.
+        (WebCore::RenderLayer::scrollbarOffset): Render a vertical scrollbar to the left side
+        and move a horizontal scrollbar right by the width of the vertical scrollbar.
+        (WebCore::RenderLayer::invalidateScrollbarRect): ditto.
+        (WebCore::RenderLayer::positionOverflowControls): ditto.
+        (WebCore::RenderLayer::hitTestOverflowControls): ditto.
+        * rendering/RenderLayer.h:
+        (RenderLayer):
+        * rendering/style/RenderStyle.h: Added shouldPlaceBlockDirectionScrollbarOnLogicalLeft,
+        which returns if we need to move a left scrollbar to its right side.
+
 2012-03-01  Kent Tamura  <[email protected]>
 
         REGRESSION(90089): Input type='search' text shakes up and down when the style is changed.

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (109511 => 109512)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2012-03-02 06:28:45 UTC (rev 109511)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2012-03-02 06:33:00 UTC (rev 109512)
@@ -1652,8 +1652,12 @@
         positionedObject = *it;
         
         // Fixed positioned elements don't contribute to layout overflow, since they don't scroll with the content.
-        if (positionedObject->style()->position() != FixedPosition)
-            addOverflowFromChild(positionedObject);
+        if (positionedObject->style()->position() != FixedPosition) {
+            int x = positionedObject->x();
+            if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft())
+                x -= verticalScrollbarWidth();
+            addOverflowFromChild(positionedObject, IntSize(x, positionedObject->y()));
+        }
     }
 }
 
@@ -2049,6 +2053,8 @@
 void RenderBlock::determineLogicalLeftPositionForChild(RenderBox* child)
 {
     LayoutUnit startPosition = borderStart() + paddingStart();
+    if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft())
+        startPosition -= verticalScrollbarWidth();
     LayoutUnit totalAvailableLogicalWidth = borderAndPaddingLogicalWidth() + availableLogicalWidth();
 
     // Add in our start margin.

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (109511 => 109512)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2012-03-02 06:28:45 UTC (rev 109511)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2012-03-02 06:33:00 UTC (rev 109512)
@@ -1232,8 +1232,11 @@
     clipRect.setSize(clipRect.size() - LayoutSize(borderLeft() + borderRight(), borderTop() + borderBottom()));
 
     // Subtract out scrollbars if we have them.
-    if (layer())
+     if (layer()) {
+        if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft())
+            clipRect.move(layer()->verticalScrollbarWidth(relevancy), 0);
         clipRect.contract(layer()->verticalScrollbarWidth(relevancy), layer()->horizontalScrollbarHeight(relevancy));
+     }
 
     return clipRect;
 }

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (109511 => 109512)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2012-03-02 06:28:45 UTC (rev 109511)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2012-03-02 06:33:00 UTC (rev 109512)
@@ -1834,6 +1834,13 @@
     return page && page->focusController()->isActive();
 }
 
+static LayoutUnit cornerStart(const RenderLayer* layer, int minX, int maxX, int thickness)
+{
+    if (layer->renderer()->style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft())
+        return minX + layer->renderer()->style()->borderLeftWidth();
+    return maxX - thickness - layer->renderer()->style()->borderRightWidth();
+}
+
 static IntRect cornerRect(const RenderLayer* layer, const IntRect& bounds)
 {
     int horizontalThickness;
@@ -1853,7 +1860,7 @@
         horizontalThickness = layer->verticalScrollbar()->width();
         verticalThickness = layer->horizontalScrollbar()->height();
     }
-    return IntRect(bounds.maxX() - horizontalThickness - layer->renderer()->style()->borderRightWidth(), 
+    return IntRect(cornerStart(layer, bounds.x(), bounds.maxX(), horizontalThickness),
                    bounds.maxY() - verticalThickness - layer->renderer()->style()->borderBottomWidth(),
                    horizontalThickness, verticalThickness);
 }
@@ -1976,15 +1983,32 @@
     return renderer()->frame() ? renderer()->frame()->eventHandler()->currentMousePosition() : IntPoint();
 }
 
+LayoutUnit RenderLayer::verticalScrollbarStart(int minX, int maxX) const
+{
+    const RenderBox* box = renderBox();
+    if (renderer()->style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft())
+        return minX + box->borderLeft();
+    return maxX - box->borderRight() - m_vBar->width();
+}
+
+LayoutUnit RenderLayer::horizontalScrollbarStart(int minX) const
+{
+    const RenderBox* box = renderBox();
+    int x = minX + box->borderLeft();
+    if (renderer()->style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft())
+        x += m_vBar ? m_vBar->width() : resizerCornerRect(this, box->borderBoxRect()).width();
+    return x;
+}
+
 IntSize RenderLayer::scrollbarOffset(const Scrollbar* scrollbar) const
 {
     RenderBox* box = renderBox();
 
     if (scrollbar == m_vBar.get())
-        return IntSize(box->width() - box->borderRight() - scrollbar->width(), box->borderTop());
+        return IntSize(verticalScrollbarStart(0, box->width()), box->borderTop());
 
     if (scrollbar == m_hBar.get())
-        return IntSize(box->borderLeft(), box->height() - box->borderBottom() - scrollbar->height());
+        return IntSize(horizontalScrollbarStart(0), box->height() - box->borderBottom() - scrollbar->height());
     
     ASSERT_NOT_REACHED();
     return IntSize();
@@ -2009,9 +2033,9 @@
     RenderBox* box = renderBox();
     ASSERT(box);
     if (scrollbar == m_vBar.get())
-        scrollRect.move(box->width() - box->borderRight() - scrollbar->width(), box->borderTop());
+        scrollRect.move(verticalScrollbarStart(0, box->width()), box->borderTop());
     else
-        scrollRect.move(box->borderLeft(), box->height() - box->borderBottom() - scrollbar->height());
+        scrollRect.move(horizontalScrollbarStart(0), box->height() - box->borderBottom() - scrollbar->height());
     renderer()->repaintRectangle(scrollRect);
 }
 
@@ -2176,13 +2200,13 @@
     const IntRect& scrollCorner = scrollCornerRect();
     IntRect absBounds(borderBox.location() + offsetFromLayer, borderBox.size());
     if (m_vBar)
-        m_vBar->setFrameRect(IntRect(absBounds.maxX() - box->borderRight() - m_vBar->width(),
+        m_vBar->setFrameRect(IntRect(verticalScrollbarStart(absBounds.x(), absBounds.maxX()),
                                      absBounds.y() + box->borderTop(),
                                      m_vBar->width(),
                                      absBounds.height() - (box->borderTop() + box->borderBottom()) - scrollCorner.height()));
 
     if (m_hBar)
-        m_hBar->setFrameRect(IntRect(absBounds.x() + box->borderLeft(),
+        m_hBar->setFrameRect(IntRect(horizontalScrollbarStart(absBounds.x()),
                                      absBounds.maxY() - box->borderBottom() - m_hBar->height(),
                                      absBounds.width() - (box->borderLeft() + box->borderRight()) - scrollCorner.width(),
                                      m_hBar->height()));
@@ -2593,7 +2617,7 @@
     int resizeControlSize = max(resizeControlRect.height(), 0);
 
     if (m_vBar && m_vBar->shouldParticipateInHitTesting()) {
-        LayoutRect vBarRect(box->width() - box->borderRight() - m_vBar->width(), 
+        LayoutRect vBarRect(verticalScrollbarStart(0, box->width()),
                             box->borderTop(),
                             m_vBar->width(),
                             box->height() - (box->borderTop() + box->borderBottom()) - (m_hBar ? m_hBar->height() : resizeControlSize));
@@ -2605,7 +2629,7 @@
 
     resizeControlSize = max(resizeControlRect.width(), 0);
     if (m_hBar && m_hBar->shouldParticipateInHitTesting()) {
-        LayoutRect hBarRect(box->borderLeft(),
+        LayoutRect hBarRect(horizontalScrollbarStart(0),
                             box->height() - box->borderBottom() - m_hBar->height(),
                             box->width() - (box->borderLeft() + box->borderRight()) - (m_vBar ? m_vBar->width() : resizeControlSize),
                             m_hBar->height());

Modified: trunk/Source/WebCore/rendering/RenderLayer.h (109511 => 109512)


--- trunk/Source/WebCore/rendering/RenderLayer.h	2012-03-02 06:28:45 UTC (rev 109511)
+++ trunk/Source/WebCore/rendering/RenderLayer.h	2012-03-02 06:33:00 UTC (rev 109512)
@@ -755,6 +755,9 @@
             ;
     }
 
+    LayoutUnit verticalScrollbarStart(int minX, int maxX) const;
+    LayoutUnit horizontalScrollbarStart(int minX) const;
+
 protected:
     // The bitfields are up here so they will fall into the padding from ScrollableArea on 64-bit.
 

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (109511 => 109512)


--- trunk/Source/WebCore/rendering/style/RenderStyle.h	2012-03-02 06:28:45 UTC (rev 109511)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h	2012-03-02 06:33:00 UTC (rev 109512)
@@ -970,6 +970,12 @@
 #else
     bool hasFilter() const { return false; }
 #endif
+
+#if USE(RTL_SCROLLBAR)
+    bool shouldPlaceBlockDirectionScrollbarOnLogicalLeft() const { return !isLeftToRightDirection() && isHorizontalWritingMode(); }
+#else
+    bool shouldPlaceBlockDirectionScrollbarOnLogicalLeft() const { return false; }
+#endif
         
 // attribute setter methods
 

Modified: trunk/Source/WebKit/chromium/ChangeLog (109511 => 109512)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-03-02 06:28:45 UTC (rev 109511)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-03-02 06:33:00 UTC (rev 109512)
@@ -1,3 +1,16 @@
+2012-03-01  Hironori Bono  <[email protected]>
+
+        Render overflow controls of an RTL element to its left-side.
+        https://bugs.webkit.org/show_bug.cgi?id=54623
+
+        This change adds a new flag WTF_USE_RTL_SCROLLBAR and render the
+        vertical scrollbars and resizers of RTL elements to their left side if
+        this new flag is enabled.
+
+        Reviewed by Ryosuke Niwa.
+
+        * features.gypi: Set WTF_USE_RTL_SCROLLBAR to 1 on Chromium.
+
 2012-03-01  James Robinson  <[email protected]>
 
         [chromium] Rename LayerChromium::name to debugName to be more consistent with other debug properties, make threadsafe

Modified: trunk/Source/WebKit/chromium/features.gypi (109511 => 109512)


--- trunk/Source/WebKit/chromium/features.gypi	2012-03-02 06:28:45 UTC (rev 109511)
+++ trunk/Source/WebKit/chromium/features.gypi	2012-03-02 06:33:00 UTC (rev 109512)
@@ -106,6 +106,7 @@
       # We can't define it here because it should be present only
       # in Debug or release_valgrind_build=1 builds.
       'WTF_USE_OPENTYPE_SANITIZER=1',
+      'WTF_USE_RTL_SCROLLBAR=1',
       'WTF_USE_SKIA_TEXT=<(enable_skia_text)',
       'WTF_USE_WEBP=1',
       'WTF_USE_WEBKIT_IMAGE_DECODERS=1',
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to