Title: [110073] trunk
Revision
110073
Author
hb...@chromium.org
Date
2012-03-07 11:08:01 -0800 (Wed, 07 Mar 2012)

Log Message

[Chromium] Mirror the resizer image of an RTL element when WTF_USE_RTL_SCROLLBAR is 1
https://bugs.webkit.org/show_bug.cgi?id=9223

Reviewed by Tony Chang.

This change mirrors a resizer image of an RTL element horizontall as Firefox
does. This change also mirrors its dragging behavior, i.e. draging the resizer
of an RTL element to the left side increases its width. (This feature is enabled
only when WTF_USE_RTL_SCROLLBAR is 1.)

Source/WebCore:

Test: platform/chromium/scrollbars/drag-rtl-resizer.html

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::resize): Mirrored the x coordinate of mouse positions
when mirroring a resizer.
(WebCore::RenderLayer::offsetFromResizeCorner): Returned the offset from the
bottom-left corner when rendering a resizer there.
(WebCore::RenderLayer::drawPlatformResizerImage): Mirrored the resizer bitmap
horizontally when rendering a resizer to the bottom-left corner.

LayoutTests:

* platform/chromium/scrollbars: Added.
* platform/chromium/scrollbars/drag-rtl-resizer-expected.txt: Added.
* platform/chromium/scrollbars/drag-rtl-resizer.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (110072 => 110073)


--- trunk/LayoutTests/ChangeLog	2012-03-07 19:05:57 UTC (rev 110072)
+++ trunk/LayoutTests/ChangeLog	2012-03-07 19:08:01 UTC (rev 110073)
@@ -1,3 +1,19 @@
+2012-03-07  Hironori Bono  <hb...@chromium.org>
+
+        [Chromium] Mirror the resizer image of an RTL element when WTF_USE_RTL_SCROLLBAR is 1
+        https://bugs.webkit.org/show_bug.cgi?id=9223
+
+        Reviewed by Tony Chang.
+
+        This change mirrors a resizer image of an RTL element horizontall as Firefox
+        does. This change also mirrors its dragging behavior, i.e. draging the resizer
+        of an RTL element to the left side increases its width. (This feature is enabled
+        only when WTF_USE_RTL_SCROLLBAR is 1.)
+
+        * platform/chromium/scrollbars: Added.
+        * platform/chromium/scrollbars/drag-rtl-resizer-expected.txt: Added.
+        * platform/chromium/scrollbars/drag-rtl-resizer.html: Added.
+
 2012-03-07  Julien Chaffraix  <jchaffr...@webkit.org>
 
         Lazily allocate overflow: hidden layers if we have overflowing content

Added: trunk/LayoutTests/platform/chromium/scrollbars/drag-rtl-resizer-expected.txt (0 => 110073)


--- trunk/LayoutTests/platform/chromium/scrollbars/drag-rtl-resizer-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/scrollbars/drag-rtl-resizer-expected.txt	2012-03-07 19:08:01 UTC (rev 110073)
@@ -0,0 +1,10 @@
+Test that an RTL element renders a resizer to its bottom-left corner and dragging this resizer to the left changes its width. To test manually, dragging the resizer of the below element to left, and see this element increases its width.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.getElementById('overflow').offsetWidth > offsetWidth is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/platform/chromium/scrollbars/drag-rtl-resizer.html (0 => 110073)


--- trunk/LayoutTests/platform/chromium/scrollbars/drag-rtl-resizer.html	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/scrollbars/drag-rtl-resizer.html	2012-03-07 19:08:01 UTC (rev 110073)
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>Bug 9223</title>
+<script src=""
+</head>
+<body dir="rtl" style="margin:0px">
+<div id="overflow" dir="rtl" style="border:2px solid black; overflow:auto; width: 400px; height: 400px; resize:both;">
+<div style="background-color:red;height:720px"></div>
+<div style="background-color:green;height:1600px"></div>
+</div>
+<script>
+description('Test that an RTL element renders a resizer to its bottom-left corner and ' +
+            'dragging this resizer to the left changes its width. ' +
+            'To test manually, dragging the resizer of the below element to left, and ' +
+            'see this element increases its width.');
+
+// This test must be async because it needs to wait for WebKit to finish re-layouting elements
+// after sending mouse events.
+jsTestIsAsync = true;
+
+function finished()
+{
+    shouldBeTrue('document.getElementById(\'overflow\').offsetWidth > offsetWidth');
+    finishJSTest();
+}
+
+var offsetWidth = document.getElementById('overflow').offsetWidth;
+
+if (window.eventSender) {
+    var node = document.getElementById('overflow');
+    var offsetLeft = node.offsetLeft + 5;
+    var offsetTop = node.offsetTop + node.offsetHeight - 5;
+    eventSender.mouseMoveTo(offsetLeft, offsetTop);
+    eventSender.mouseDown();
+    eventSender.mouseMoveTo(offsetLeft - 30, offsetTop);
+    eventSender.mouseUp();
+    setTimeout(finished, 0);
+}
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (110072 => 110073)


--- trunk/Source/WebCore/ChangeLog	2012-03-07 19:05:57 UTC (rev 110072)
+++ trunk/Source/WebCore/ChangeLog	2012-03-07 19:08:01 UTC (rev 110073)
@@ -1,3 +1,25 @@
+2012-03-07  Hironori Bono  <hb...@chromium.org>
+
+        [Chromium] Mirror the resizer image of an RTL element when WTF_USE_RTL_SCROLLBAR is 1
+        https://bugs.webkit.org/show_bug.cgi?id=9223
+
+        Reviewed by Tony Chang.
+
+        This change mirrors a resizer image of an RTL element horizontall as Firefox
+        does. This change also mirrors its dragging behavior, i.e. draging the resizer
+        of an RTL element to the left side increases its width. (This feature is enabled
+        only when WTF_USE_RTL_SCROLLBAR is 1.)
+
+        Test: platform/chromium/scrollbars/drag-rtl-resizer.html
+
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::resize): Mirrored the x coordinate of mouse positions
+        when mirroring a resizer.
+        (WebCore::RenderLayer::offsetFromResizeCorner): Returned the offset from the
+        bottom-left corner when rendering a resizer there.
+        (WebCore::RenderLayer::drawPlatformResizerImage): Mirrored the resizer bitmap
+        horizontally when rendering a resizer to the bottom-left corner.
+
 2012-03-07  Julien Chaffraix  <jchaffr...@webkit.org>
 
         Lazily allocate overflow: hidden layers if we have overflowing content

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (110072 => 110073)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2012-03-07 19:05:57 UTC (rev 110072)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2012-03-07 19:08:01 UTC (rev 110073)
@@ -1738,6 +1738,10 @@
     element->setMinimumSizeForResizing(minimumSize);
     
     LayoutSize adjustedOldOffset = LayoutSize(oldOffset.width() / zoomFactor, oldOffset.height() / zoomFactor);
+    if (renderer->style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) {
+        newOffset.setWidth(-newOffset.width());
+        adjustedOldOffset.setWidth(-adjustedOldOffset.width());
+    }
     
     LayoutSize difference = (currentSize + newOffset - adjustedOldOffset).expandedTo(minimumSize) - currentSize;
 
@@ -2174,11 +2178,14 @@
 
 IntSize RenderLayer::offsetFromResizeCorner(const IntPoint& absolutePoint) const
 {
-    // Currently the resize corner is always the bottom right corner
+    // Currently the resize corner is either the bottom right corner or the bottom left corner.
     // FIXME: This assumes the location is 0, 0. Is this guaranteed to always be the case?
-    IntPoint bottomRight = toPoint(size());
+    IntSize elementSize = size();
+    if (renderer()->style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft())
+        elementSize.setWidth(0);
+    IntPoint resizerPoint = toPoint(elementSize);
     IntPoint localPoint = roundedIntPoint(absoluteToContents(absolutePoint));
-    return localPoint - bottomRight;
+    return localPoint - resizerPoint;
 }
 
 bool RenderLayer::hasOverflowControls() const
@@ -2516,6 +2523,16 @@
     }
 
     IntRect imageRect(resizerCornerRect.maxXMaxYCorner() - cornerResizerSize, cornerResizerSize);
+    if (renderer()->style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) {
+        context->save();
+        context->translate(imageRect.x(), imageRect.y());
+        imageRect.setX(0);
+        imageRect.setY(0);
+        context->scale(FloatSize(-1.0, 1.0));
+        context->drawImage(resizeCornerImage.get(), renderer()->style()->colorSpace(), imageRect);
+        context->restore();
+        return;
+    }
     context->drawImage(resizeCornerImage.get(), renderer()->style()->colorSpace(), imageRect);
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to