[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da

xji at chromium.org xji at chromium.org
Wed Dec 22 17:45:32 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 506e6f6b079e103ba9a3c82d68c0b5acb07fce86
Author: xji at chromium.org <xji at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Nov 30 01:11:08 2010 +0000

    2010-11-29  Jeremy Moskovich  <jeremy at chromium.org>
    
            Reviewed by David Hyatt.
    
            Right-to-left pages should be scrollable to reveal left overflow.
            https://bugs.webkit.org/show_bug.cgi?id=23556
    
            Set and get the original x-axis scroll position and reset scroll position on HOME/END key press.
            Modify WebFrameView to support setting the initial horizontal scroller's thumb position to the right for
            pages with a left overflow.
    
            * WebView/WebDynamicScrollBarsView.h:
            * WebView/WebDynamicScrollBarsView.mm:
            (-[WebDynamicScrollBarsView inProgramaticScroll]):
            (-[WebDynamicScrollBarsView refreshInitialScrollbarPosition]):
            (-[WebDynamicScrollBarsView updateScrollers]):
            (-[WebDynamicScrollBarsView reflectScrolledClipView:]):
            (-[WebDynamicScrollBarsView setScrollOriginX:]):
            (-[WebDynamicScrollBarsView scrollOriginX]):
            * WebView/WebFrameView.mm:
            (-[WebFrameView _scrollToBeginningOfDocument]):
            (-[WebFrameView _scrollToEndOfDocument]):
            * WebView/WebHTMLView.mm:
            (-[WebHTMLView _frameOrBoundsChanged]):
    2010-11-29  Xiaomei Ji  <xji at chromium.org>
    
            Reviewed by David Hyatt.
    
            Right-to-left pages should be scrollable to reveal left overflow.
            https://bugs.webkit.org/show_bug.cgi?id=23556
    
            For RTL page, save left layout overflow and include it into the document
            size during layout. Use the left layout overflow when scroll and paint
            the page. Behavior on LTR page should be untouched since left layout
            overflow is set as 0 for LTR page.
    
            Tests: fast/dom/horizontal-scrollbar-in-rtl-doesnt-fire-onscroll.html
                   fast/dom/horizontal-scrollbar-in-rtl.html
                   fast/dom/horizontal-scrollbar-when-dir-change.html
                   fast/dom/left-overflow-in-ltr.html
                   fast/dom/right-overflow-in-rtl.html
    
            * page/FrameView.cpp:
            (WebCore::FrameView::adjustViewSize): Save negative of left layout overflow as scroll X origin. And includes left layout overflow into document size.
            * page/mac/WebCoreFrameView.h: Add methods for setting and getting scroll X origin.
            * platform/ScrollView.cpp:
            (WebCore::ScrollView::ScrollView):
            (WebCore::ScrollView::maximumScrollPosition): Minus scroll X origin from maximum horizontal scroll position.
            (WebCore::ScrollView::minimumScrollPosition):
            (WebCore::ScrollView::adjustScrollPositionWithinRange):
            (WebCore::ScrollView::valueChanged):
            (WebCore::ScrollView::setScrollPosition):
            (WebCore::ScrollView::updateScrollbars):
            (WebCore::ScrollView::wheelEvent):
            * platform/ScrollView.h:
            * platform/mac/ScrollViewMac.mm:
            (WebCore::ScrollView::platformSetContentsSize):
            (WebCore::ScrollView::platformSetScrollPosition):
            (WebCore::ScrollView::platformSetScrollOriginX):
            * rendering/RenderBox.cpp:
            (WebCore::RenderBox::styleDidChange):
            (WebCore::RenderBox::paintRootBoxDecorations): Include left layout overflow into canvas size.
            * rendering/RenderView.cpp:
            (WebCore::RenderView::layout): Save left layout overflow.
            (WebCore::RenderView::docLeft):
            (WebCore::RenderView::docWidth): Include left layout overflow into doc width for RTL page.
            * rendering/RenderView.h:
    2010-11-29  Xiaomei Ji  <xji at chromium.org>
    
            Reviewed by David Hyatt.
    
            Right-to-left pages should be scrollable to reveal left overflow.
            https://bugs.webkit.org/show_bug.cgi?id=23556
    
            For RTL page, save left layout overflow and include it into the document
            size during layout. Use the left layout overflow when scroll and paint
            the page. Behavior on LTR page should be untouched since left layout
            overflow is set as 0 for LTR page.
    
            * fast/dom/horizontal-scrollbar-in-rtl-doesnt-fire-onscroll-expected.txt: Added.
            * fast/dom/horizontal-scrollbar-in-rtl-doesnt-fire-onscroll.html: Added.
            * fast/dom/horizontal-scrollbar-in-rtl.html: Added.
            * fast/dom/horizontal-scrollbar-when-dir-change.html: Added.
            * fast/dom/left-overflow-in-ltr.html: Added.
            * fast/dom/right-overflow-in-rtl.html: Added.
            * platform/chromium/fast/dom/horizontal-scrollbar-in-rtl-expected.txt: Added.
            * platform/chromium/fast/dom/horizontal-scrollbar-when-dir-change-expected.txt: Added.
            * platform/mac/fast/block/basic/truncation-rtl-expected.checksum:
            * platform/mac/fast/block/basic/truncation-rtl-expected.txt:
            * platform/mac/fast/dom/horizontal-scrollbar-in-rtl-expected.txt: Added.
            * platform/mac/fast/dom/horizontal-scrollbar-when-dir-change-expected.txt: Added.
            * platform/mac/fast/dom/left-overflow-in-ltr-expected.txt: Added.
            * platform/mac/fast/dom/right-overflow-in-rtl-expected.txt: Added.
    
    
            * fast/dom/horizontal-scrollbar-in-rtl-doesnt-fire-onscroll-expected.txt: Added.
            * fast/dom/horizontal-scrollbar-in-rtl-doesnt-fire-onscroll.html: Added.
            * fast/dom/horizontal-scrollbar-in-rtl.html: Added.
            * fast/dom/horizontal-scrollbar-when-dir-change.html: Added.
            * fast/dom/left-overflow-in-ltr.html: Added.
            * fast/dom/right-overflow-in-rtl.html: Added.
            * platform/chromium/fast/dom/horizontal-scrollbar-in-rtl-expected.txt: Added.
            * platform/chromium/fast/dom/horizontal-scrollbar-when-dir-change-expected.txt: Added.
            * platform/mac/fast/block/basic/truncation-rtl-expected.checksum:
            * platform/mac/fast/block/basic/truncation-rtl-expected.txt:
            * platform/mac/fast/dom/horizontal-scrollbar-in-rtl-expected.txt: Added.
            * platform/mac/fast/dom/horizontal-scrollbar-when-dir-change-expected.txt: Added.
            * platform/mac/fast/dom/left-overflow-in-ltr-expected.txt: Added.
            * platform/mac/fast/dom/right-overflow-in-rtl-expected.txt: Added.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@72852 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 0d5ce18..016089e 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,46 @@
+2010-11-29  Xiaomei Ji  <xji at chromium.org>
+
+        Reviewed by David Hyatt.
+
+        Right-to-left pages should be scrollable to reveal left overflow.
+        https://bugs.webkit.org/show_bug.cgi?id=23556
+
+        For RTL page, save left layout overflow and include it into the document
+        size during layout. Use the left layout overflow when scroll and paint
+        the page. Behavior on LTR page should be untouched since left layout 
+        overflow is set as 0 for LTR page.
+
+        * fast/dom/horizontal-scrollbar-in-rtl-doesnt-fire-onscroll-expected.txt: Added.
+        * fast/dom/horizontal-scrollbar-in-rtl-doesnt-fire-onscroll.html: Added.
+        * fast/dom/horizontal-scrollbar-in-rtl.html: Added.
+        * fast/dom/horizontal-scrollbar-when-dir-change.html: Added.
+        * fast/dom/left-overflow-in-ltr.html: Added.
+        * fast/dom/right-overflow-in-rtl.html: Added.
+        * platform/chromium/fast/dom/horizontal-scrollbar-in-rtl-expected.txt: Added.
+        * platform/chromium/fast/dom/horizontal-scrollbar-when-dir-change-expected.txt: Added.
+        * platform/mac/fast/block/basic/truncation-rtl-expected.checksum:
+        * platform/mac/fast/block/basic/truncation-rtl-expected.txt:
+        * platform/mac/fast/dom/horizontal-scrollbar-in-rtl-expected.txt: Added.
+        * platform/mac/fast/dom/horizontal-scrollbar-when-dir-change-expected.txt: Added.
+        * platform/mac/fast/dom/left-overflow-in-ltr-expected.txt: Added.
+        * platform/mac/fast/dom/right-overflow-in-rtl-expected.txt: Added.
+
+
+        * fast/dom/horizontal-scrollbar-in-rtl-doesnt-fire-onscroll-expected.txt: Added.
+        * fast/dom/horizontal-scrollbar-in-rtl-doesnt-fire-onscroll.html: Added.
+        * fast/dom/horizontal-scrollbar-in-rtl.html: Added.
+        * fast/dom/horizontal-scrollbar-when-dir-change.html: Added.
+        * fast/dom/left-overflow-in-ltr.html: Added.
+        * fast/dom/right-overflow-in-rtl.html: Added.
+        * platform/chromium/fast/dom/horizontal-scrollbar-in-rtl-expected.txt: Added.
+        * platform/chromium/fast/dom/horizontal-scrollbar-when-dir-change-expected.txt: Added.
+        * platform/mac/fast/block/basic/truncation-rtl-expected.checksum:
+        * platform/mac/fast/block/basic/truncation-rtl-expected.txt:
+        * platform/mac/fast/dom/horizontal-scrollbar-in-rtl-expected.txt: Added.
+        * platform/mac/fast/dom/horizontal-scrollbar-when-dir-change-expected.txt: Added.
+        * platform/mac/fast/dom/left-overflow-in-ltr-expected.txt: Added.
+        * platform/mac/fast/dom/right-overflow-in-rtl-expected.txt: Added.
+
 2010-11-29  Simon Fraser  <simon.fraser at apple.com>
 
         Reviewed by Ojan Vafai.
diff --git a/LayoutTests/fast/dom/horizontal-scrollbar-in-rtl-doesnt-fire-onscroll-expected.txt b/LayoutTests/fast/dom/horizontal-scrollbar-in-rtl-doesnt-fire-onscroll-expected.txt
new file mode 100644
index 0000000..bc53c98
--- /dev/null
+++ b/LayoutTests/fast/dom/horizontal-scrollbar-in-rtl-doesnt-fire-onscroll-expected.txt
@@ -0,0 +1,6 @@
+This tests that when a page with an RTL overflow is initially loaded, no scroll event is sent.
+
+This test has passed if the text "FAIL - scroll event received!" does not appear below.
+
+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."
+
diff --git a/LayoutTests/fast/dom/horizontal-scrollbar-in-rtl-doesnt-fire-onscroll.html b/LayoutTests/fast/dom/horizontal-scrollbar-in-rtl-doesnt-fire-onscroll.html
new file mode 100644
index 0000000..1323a06
--- /dev/null
+++ b/LayoutTests/fast/dom/horizontal-scrollbar-in-rtl-doesnt-fire-onscroll.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html dir=rtl>
+    <head>
+        <script language="javascript">
+            function log(str)
+            {
+                var li = document.createElement("li");
+                li.appendChild(document.createTextNode(str));
+                var console = document.getElementById("console");
+                console.appendChild(li);
+            }
+
+            onload = function()
+            {
+                if (window.layoutTestController)
+                    layoutTestController.dumpAsText();
+            }
+
+            document.onscroll=function(){log("FAIL - scroll event received!");}
+        </script>
+    </head>
+    <body>
+        <div dir=ltr>
+        <p>This tests that when a page with an RTL overflow is initially loaded, no scroll event is sent.</p>
+        <p>This test has passed if the text "FAIL - scroll event received!" does not appear below.</p>
+        </div>
+        <div id="div" style="whitespace:nowrap; width: 4000px; height: 1000px; border: 1px solid red;">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."</div>
+        <ul id="console"></ul>
+    </body>
+</html>
diff --git a/LayoutTests/fast/dom/horizontal-scrollbar-in-rtl.html b/LayoutTests/fast/dom/horizontal-scrollbar-in-rtl.html
new file mode 100644
index 0000000..bdd1281
--- /dev/null
+++ b/LayoutTests/fast/dom/horizontal-scrollbar-in-rtl.html
@@ -0,0 +1,103 @@
+<html dir=rtl>
+    <head>
+        <script language="javascript">
+            function log(str)
+            {
+                var li = document.createElement("li");
+                li.appendChild(document.createTextNode(str));
+                var console = document.getElementById("console");
+                console.appendChild(li);
+            }
+            
+            function assertEqual(message, actual, expected)
+            {
+                if (actual != expected)
+                    log("\n" + message + ": Failure, actual: " + actual + "; expected: " + expected);
+                else
+                    log("\n" + message + ": Success");
+            }
+            
+            function assertTrue(message, fact)
+            {
+                if (fact)
+                    log("\n" + message + ": Failure");
+                else
+                    log("\n" + message + ": Success");
+            }
+            
+            var expectedScrollX = -1000;
+            var expectedScrollY = 500;
+
+            function mousewheelHandler(e) 
+            {
+                assertEqual("wheel scroll preserves horizontal scroll position", window.scrollX, expectedScrollX);
+            }
+            
+            onload = function()
+            {
+                if (window.layoutTestController)
+                    layoutTestController.dumpAsText();
+
+                // Test horizontal scroll bar presents and was initially at the right for RTL page.
+                assertEqual("original scroll x for RTL page ", window.scrollX, 0);
+            
+                // Test horizontal scroll.
+                window.scrollTo(expectedScrollX, expectedScrollY);
+                assertEqual("horizontal scroll: ", window.scrollX, expectedScrollX);
+                // Test calling window.scrollX continuously wont change the scrollX position.
+                assertEqual("continuously call window.scrollX ", window.scrollX, expectedScrollX);
+            
+
+                // Test zooming wont reset scroll position.
+                if (window.eventSender) {
+                    window.scrollTo(expectedScrollX, expectedScrollY);
+                    eventSender.zoomPageIn();
+                    eventSender.zoomPageOut();
+                    assertEqual("zoom in and out preserve scroll position", window.scrollX,expectedScrollX);
+                }
+               
+                // Test resize wont reset scroll position.
+                window.resizeTo(1000, window.innerHeight);
+                window.scrollTo(expectedScrollX, expectedScrollY);
+                window.resizeTo(2000, window.innerHeight);
+                assertEqual("resize preserves scroll position", window.scrollX, expectedScrollX);
+                
+                // Test wheel scroll preserves horizontal scroll position.
+                window.scrollTo(expectedScrollX, expectedScrollY / 2);
+                var div = document.getElementById("div");
+                div.addEventListener("mousewheel", mousewheelHandler, false);
+                var wheelEvent = document.createEvent("WheelEvent");
+                wheelEvent.initWebKitWheelEvent(0, expectedScrollY / 2, window, 0, 0, 0, 0, false, false, false, false);
+                div.dispatchEvent(wheelEvent);
+            
+                // Test HOME/END operation.
+                if (window.eventSender) {
+                    // Not using assert equal here since the behavior is different in each port. 
+                    // For example, in Mac, HOME/END key reset both x and y scroll position. 
+                    // In Chromium, HOME/END key only reset y scroll position, and x scroll position is preserved.
+                    window.scrollTo(expectedScrollX, expectedScrollY);
+                    eventSender.keyDown("home");
+                    log("KeyDown HOME move x-scroll position to right for RTL page: " + window.scrollX, 0);
+                    window.scrollTo(expectedScrollX, expectedScrollY);
+                    eventSender.keyDown("end");
+                    log("KeyDown END move x-scroll position to right for RTL page: " + window.scrollX, 0);
+                }
+            
+                // Test select all selects all document content.
+                window.resizeTo(500, 500);
+                var div = document.getElementById("div");
+                div.focus();
+                document.execCommand("SelectAll");
+                var selection = window.getSelection();
+                assertEqual("selectAll selects all document", selection.toString().substring(0, div.innerHTML.length), div.innerHTML);
+
+                div.style.display = "none";
+               
+            }
+        </script>
+    </head>
+    <body>
+        <div id="div" style="whitespace:nowrap; width: 4000px; height: 1000px; border: 1px solid red;">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."</div>
+        <ul id="console" dir=ltr></ul>
+    </body>
+</html>
diff --git a/LayoutTests/fast/dom/horizontal-scrollbar-when-dir-change.html b/LayoutTests/fast/dom/horizontal-scrollbar-when-dir-change.html
new file mode 100644
index 0000000..21127b0
--- /dev/null
+++ b/LayoutTests/fast/dom/horizontal-scrollbar-when-dir-change.html
@@ -0,0 +1,52 @@
+<html>
+<head>
+<script>
+function log(str)
+{
+    var li = document.createElement("li");
+    li.appendChild(document.createTextNode(str));
+    var console = document.getElementById("console");
+    console.appendChild(li);
+}
+
+function assertEqual(message, actual, expected)
+{
+    if (actual != expected)
+        log("\n" + message + ": Failure, actual: " + actual + "; expected: " + expected);
+    else
+        log("\n" + message + ": Success");
+}
+
+function changeDir(new_dir) 
+{
+    document.body.dir = new_dir;
+    return false;
+}
+
+onload = function()
+{
+    if (window.layoutTestController)                    
+        layoutTestController.dumpAsText();
+
+    assertEqual("original scroll x for RTL page ", window.scrollX, 0);
+    window.scrollTo(-100, 0);
+    assertEqual("horizontal scroll x for RTL page ", window.scrollX, -100);
+
+    document.body.dir = "ltr";
+    assertEqual("original scroll x for LTR page ", window.scrollX, 0);
+    window.scrollTo(100, 0);
+    assertEqual("horizontal scroll x for LTR page ", window.scrollX, 100);
+
+    document.getElementById("div").style.display = "none";
+}
+</script>
+</head>
+<body dir="rtl">
+
+<div style="width: 4000px; border: 1px solid red;" id="div">
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc et nisl tellus. Vivamus aliquam elit non arcu scelerisque eget dapibus nunc vulputate. Maecenas scelerisque egestas purus, id bibendum magna venenatis vel. Vestibulum bibendum volutpat aliquam. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vestibulum eget risus sodales mi tristique dignissim et sed lectus. Cras convallis, nibh ut dapibus gravida, enim mauris molestie elit, eget fringilla augue est nec est. Curabitur eu quam non purus sodales pulvinar. Donec ultrices dui eget dolor lobortis in porta quam rutrum. Nulla risus lacus, adipiscing quis ullamcorper vestibulum, condimentum sed lacus. Sed in nunc dolor, quis egestas turpis. Integer arcu tellus, posuere sit amet pellentesque a, molestie at mi. Nulla blandit, mi et euismod imperdiet, augue arcu ornare felis, nec viverra lacus ligula ut metus. Proin ut leo ante, at consectetur sem. Nullam non nunc ligula. Proin sed ante sem, id rutrum purus.
+</div>
+<ul id="console"></ul>
+<br>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/left-overflow-in-ltr.html b/LayoutTests/fast/dom/left-overflow-in-ltr.html
new file mode 100644
index 0000000..51a0829
--- /dev/null
+++ b/LayoutTests/fast/dom/left-overflow-in-ltr.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" >
+    <head>
+        <title>Test left overflow in LTR page</title>
+        <script>
+            function log(str)
+            {
+                var li = document.createElement("li");
+                li.appendChild(document.createTextNode(str));
+                var console = document.getElementById("console");
+                console.appendChild(li);
+            }
+            
+            function assertEqual(message, actual, expected)
+            {
+                if (actual != expected)
+                    log("\n" + message + ": Failure, actual: " + actual + "; expected: " + expected);
+                else
+                    log("\n" + message + ": Success");
+            }
+    
+            onload = function()
+            {
+                if (window.layoutTestController)
+                    layoutTestController.dumpAsText();
+                var div = document.getElementById("div");
+                var original = window.scrollX;
+                window.scrollTo(-1, 0);
+                assertEqual("scroll", window.scrollX, 0);
+    
+            }
+        </script>
+    </head>
+    <body>
+        <div id="div" style="position:relative; right:40px">test left overflow in LTR page.</div>
+        <ul id="console"></ul>
+    </body>
+</html>
diff --git a/LayoutTests/fast/dom/right-overflow-in-rtl.html b/LayoutTests/fast/dom/right-overflow-in-rtl.html
new file mode 100644
index 0000000..21ba792
--- /dev/null
+++ b/LayoutTests/fast/dom/right-overflow-in-rtl.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html  style="direction:rtl" xmlns="http://www.w3.org/1999/xhtml" >
+    <head>
+        <title>Test right overflow in RTL page</title>
+        <script>
+            function log(str)
+            {
+                var li = document.createElement("li");
+                li.appendChild(document.createTextNode(str));
+                var console = document.getElementById("console");
+                console.appendChild(li);
+            }
+            
+            function assertEqual(message, actual, expected)
+            {
+                if (actual != expected)
+                    log("\n" + message + ": Failure, actual: " + actual + "; expected: " + expected);
+                else
+                    log("\n" + message + ": Success");
+            }
+    
+            onload = function()
+            {
+                if (window.layoutTestController)
+                    layoutTestController.dumpAsText();
+                var div = document.getElementById("div");
+                var original = window.scrollX;
+                window.scrollTo(1, 0);
+                assertEqual("scroll", window.scrollX, 0);
+    
+            }
+        </script>
+    </head>
+    <body>
+        <div id="div" style="position:relative; left:40px">test right overflow in RTL page.</div>
+        <ul id="console"></ul>
+    </body>
+</html>
diff --git a/LayoutTests/platform/chromium/fast/dom/horizontal-scrollbar-in-rtl-expected.txt b/LayoutTests/platform/chromium/fast/dom/horizontal-scrollbar-in-rtl-expected.txt
new file mode 100644
index 0000000..699fda8
--- /dev/null
+++ b/LayoutTests/platform/chromium/fast/dom/horizontal-scrollbar-in-rtl-expected.txt
@@ -0,0 +1,9 @@
+original scroll x for RTL page : Success
+horizontal scroll: : Success
+continuously call window.scrollX : Success
+zoom in and out preserve scroll position: Success
+resize preserves scroll position: Success
+wheel scroll preserves horizontal scroll position: Success
+KeyDown HOME move x-scroll position to right for RTL page: -1000
+KeyDown END move x-scroll position to right for RTL page: -1000
+selectAll selects all document: Success
diff --git a/LayoutTests/platform/chromium/fast/dom/horizontal-scrollbar-when-dir-change-expected.txt b/LayoutTests/platform/chromium/fast/dom/horizontal-scrollbar-when-dir-change-expected.txt
new file mode 100644
index 0000000..d2f6681
--- /dev/null
+++ b/LayoutTests/platform/chromium/fast/dom/horizontal-scrollbar-when-dir-change-expected.txt
@@ -0,0 +1,4 @@
+original scroll x for RTL page : Success
+horizontal scroll x for RTL page : Success
+original scroll x for LTR page : Success
+horizontal scroll x for LTR page : Success
diff --git a/LayoutTests/platform/mac/fast/block/basic/truncation-rtl-expected.checksum b/LayoutTests/platform/mac/fast/block/basic/truncation-rtl-expected.checksum
index a798eb1..a6366b4 100644
--- a/LayoutTests/platform/mac/fast/block/basic/truncation-rtl-expected.checksum
+++ b/LayoutTests/platform/mac/fast/block/basic/truncation-rtl-expected.checksum
@@ -1 +1 @@
-291f00911973580263696627c376c32f
\ No newline at end of file
+d17e731e4deb9d3843d82e420c26336b
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/block/basic/truncation-rtl-expected.txt b/LayoutTests/platform/mac/fast/block/basic/truncation-rtl-expected.txt
index a03b791..133a7e1 100644
--- a/LayoutTests/platform/mac/fast/block/basic/truncation-rtl-expected.txt
+++ b/LayoutTests/platform/mac/fast/block/basic/truncation-rtl-expected.txt
@@ -1,5 +1,5 @@
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x585
+  RenderView at (0,0) size 800x585
 layer at (0,0) size 800x222
   RenderBlock {HTML} at (0,0) size 800x222
     RenderBody {BODY} at (8,16) size 784x198
@@ -28,3 +28,4 @@ layer at (0,0) size 800x222
           text run at (51,91) width 950: "a, molestie at mi. Nulla blandit, mi et euismod imperdiet, augue arcu ornare felis, nec viverra lacus ligula ut metus. Proin ut leo ante, at consectetur sem."
           text run at (617,109) width 4 RTL: "."
           text run at (621,109) width 380: "Nullam non nunc ligula. Proin sed ante sem, id rutrum purus"
+scrolled to 210,0
diff --git a/LayoutTests/platform/mac/fast/dom/horizontal-scrollbar-in-rtl-expected.txt b/LayoutTests/platform/mac/fast/dom/horizontal-scrollbar-in-rtl-expected.txt
new file mode 100644
index 0000000..24217c5
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/dom/horizontal-scrollbar-in-rtl-expected.txt
@@ -0,0 +1,9 @@
+original scroll x for RTL page : Success
+horizontal scroll: : Success
+continuously call window.scrollX : Success
+zoom in and out preserve scroll position: Failure, actual: -866; expected: -1000
+resize preserves scroll position: Success
+wheel scroll preserves horizontal scroll position: Success
+KeyDown HOME move x-scroll position to right for RTL page: 0
+KeyDown END move x-scroll position to right for RTL page: 0
+selectAll selects all document: Success
diff --git a/LayoutTests/platform/mac/fast/dom/horizontal-scrollbar-when-dir-change-expected.txt b/LayoutTests/platform/mac/fast/dom/horizontal-scrollbar-when-dir-change-expected.txt
new file mode 100644
index 0000000..664c0cc
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/dom/horizontal-scrollbar-when-dir-change-expected.txt
@@ -0,0 +1,6 @@
+original scroll x for RTL page : Success
+horizontal scroll x for RTL page : Success
+original scroll x for LTR page : Failure, actual: 3110; expected: 0
+horizontal scroll x for LTR page : Success
+
+
diff --git a/LayoutTests/platform/mac/fast/dom/left-overflow-in-ltr-expected.txt b/LayoutTests/platform/mac/fast/dom/left-overflow-in-ltr-expected.txt
new file mode 100644
index 0000000..fbac4d1
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/dom/left-overflow-in-ltr-expected.txt
@@ -0,0 +1,2 @@
+test left overflow in LTR page.
+scroll: Success
diff --git a/LayoutTests/platform/mac/fast/dom/right-overflow-in-rtl-expected.txt b/LayoutTests/platform/mac/fast/dom/right-overflow-in-rtl-expected.txt
new file mode 100644
index 0000000..d3579cd
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/dom/right-overflow-in-rtl-expected.txt
@@ -0,0 +1,2 @@
+test right overflow in RTL page.
+scroll: Success
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 437b8a3..c170276 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,47 @@
+2010-11-29  Xiaomei Ji  <xji at chromium.org>
+
+        Reviewed by David Hyatt.
+
+        Right-to-left pages should be scrollable to reveal left overflow.
+        https://bugs.webkit.org/show_bug.cgi?id=23556
+
+        For RTL page, save left layout overflow and include it into the document
+        size during layout. Use the left layout overflow when scroll and paint
+        the page. Behavior on LTR page should be untouched since left layout 
+        overflow is set as 0 for LTR page.
+
+        Tests: fast/dom/horizontal-scrollbar-in-rtl-doesnt-fire-onscroll.html
+               fast/dom/horizontal-scrollbar-in-rtl.html
+               fast/dom/horizontal-scrollbar-when-dir-change.html
+               fast/dom/left-overflow-in-ltr.html
+               fast/dom/right-overflow-in-rtl.html
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::adjustViewSize): Save negative of left layout overflow as scroll X origin. And includes left layout overflow into document size.
+        * page/mac/WebCoreFrameView.h: Add methods for setting and getting scroll X origin.
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::ScrollView):
+        (WebCore::ScrollView::maximumScrollPosition): Minus scroll X origin from maximum horizontal scroll position.
+        (WebCore::ScrollView::minimumScrollPosition):
+        (WebCore::ScrollView::adjustScrollPositionWithinRange):
+        (WebCore::ScrollView::valueChanged):
+        (WebCore::ScrollView::setScrollPosition):
+        (WebCore::ScrollView::updateScrollbars):
+        (WebCore::ScrollView::wheelEvent):
+        * platform/ScrollView.h:
+        * platform/mac/ScrollViewMac.mm:
+        (WebCore::ScrollView::platformSetContentsSize):
+        (WebCore::ScrollView::platformSetScrollPosition):
+        (WebCore::ScrollView::platformSetScrollOriginX):
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::styleDidChange):
+        (WebCore::RenderBox::paintRootBoxDecorations): Include left layout overflow into canvas size.
+        * rendering/RenderView.cpp:
+        (WebCore::RenderView::layout): Save left layout overflow.
+        (WebCore::RenderView::docLeft):
+        (WebCore::RenderView::docWidth): Include left layout overflow into doc width for RTL page.
+        * rendering/RenderView.h:
+
 2010-11-29  Simon Fraser  <simon.fraser at apple.com>
 
         Reviewed by Ojan Vafai.
diff --git a/WebCore/page/FrameView.cpp b/WebCore/page/FrameView.cpp
index 770225b..067a8e8 100644
--- a/WebCore/page/FrameView.cpp
+++ b/WebCore/page/FrameView.cpp
@@ -435,7 +435,16 @@ void FrameView::adjustViewSize()
     if (!root)
         return;
 
-    setContentsSize(IntSize(root->rightLayoutOverflow(), root->bottomLayoutOverflow()));
+    int prevScrollOriginX = scrollOriginX();
+    ScrollView::setScrollOriginX(-root->leftLayoutOverflow());
+    IntSize size = IntSize(root->rightLayoutOverflow() - root->leftLayoutOverflow(), root->bottomLayoutOverflow());
+    // Take care of the case when contents remain but the RenderView's direction has changed.
+    // In which case, we need to update scroller position, for example, from leftmost to
+    // rightmost when direction changes from left-to-right to right-to-left.
+    bool directionChanged = (!prevScrollOriginX || !scrollOriginX()) && (scrollOriginX() != prevScrollOriginX);
+    if (size == contentsSize() && directionChanged)
+        ScrollView::updateScrollbars();
+    setContentsSize(size);
 }
 
 void FrameView::applyOverflowToViewport(RenderObject* o, ScrollbarMode& hMode, ScrollbarMode& vMode)
diff --git a/WebCore/page/mac/WebCoreFrameView.h b/WebCore/page/mac/WebCoreFrameView.h
index 977b1a7..8b25102 100644
--- a/WebCore/page/mac/WebCoreFrameView.h
+++ b/WebCore/page/mac/WebCoreFrameView.h
@@ -33,6 +33,8 @@ namespace WebCore {
 - (void)setScrollingModes:(WebCore::ScrollbarMode)hMode vertical:(WebCore::ScrollbarMode)vMode andLock:(BOOL)lock;
 - (void)scrollingModes:(WebCore::ScrollbarMode*)hMode vertical:(WebCore::ScrollbarMode*)vMode;
 - (void)setScrollBarsSuppressed:(BOOL)suppressed repaintOnUnsuppress:(BOOL)repaint;
+- (void)setScrollOriginX:(int)scrollOriginX;
+- (int)scrollOriginX;
 @end
 
 @protocol WebCoreFrameView
diff --git a/WebCore/platform/ScrollView.cpp b/WebCore/platform/ScrollView.cpp
index 5fe3bee..defd8d3 100644
--- a/WebCore/platform/ScrollView.cpp
+++ b/WebCore/platform/ScrollView.cpp
@@ -54,6 +54,7 @@ ScrollView::ScrollView()
     , m_useFixedLayout(false)
     , m_paintsEntireContents(false)
     , m_delegatesScrolling(false)
+    , m_scrollOriginX(0)
 {
     platformInit();
 }
@@ -278,9 +279,22 @@ void ScrollView::setContentsSize(const IntSize& newSize)
 
 IntPoint ScrollView::maximumScrollPosition() const
 {
-    IntSize maximumOffset = contentsSize() - visibleContentRect().size();
+    IntPoint maximumOffset(contentsWidth() - visibleWidth() - m_scrollOriginX, contentsHeight() - visibleHeight());
     maximumOffset.clampNegativeToZero();
-    return IntPoint(maximumOffset.width(), maximumOffset.height());
+    return maximumOffset;
+}
+
+IntPoint ScrollView::minimumScrollPosition() const
+{
+    return IntPoint(-m_scrollOriginX, 0);
+}
+
+IntPoint ScrollView::adjustScrollPositionWithinRange(const IntPoint& scrollPoint) const
+{
+    IntPoint newScrollPosition = scrollPoint.shrunkTo(maximumScrollPosition());
+    newScrollPosition = newScrollPosition.expandedTo(minimumScrollPosition());
+    newScrollPosition.clampNegativeToZero();
+    return newScrollPosition;
 }
 
 int ScrollView::scrollSize(ScrollbarOrientation orientation) const
@@ -303,7 +317,7 @@ void ScrollView::valueChanged(Scrollbar* scrollbar)
     IntSize newOffset = m_scrollOffset;
     if (scrollbar) {
         if (scrollbar->orientation() == HorizontalScrollbar)
-            newOffset.setWidth(scrollbar->value());
+            newOffset.setWidth(scrollbar->value() - m_scrollOriginX);
         else if (scrollbar->orientation() == VerticalScrollbar)
             newOffset.setHeight(scrollbar->value());
     }
@@ -348,8 +362,7 @@ void ScrollView::setScrollPosition(const IntPoint& scrollPoint)
     }
 #endif
 
-    IntPoint newScrollPosition = scrollPoint.shrunkTo(maximumScrollPosition());
-    newScrollPosition.clampNegativeToZero();
+    IntPoint newScrollPosition = adjustScrollPositionWithinRange(scrollPoint);
 
     if (newScrollPosition == scrollPosition())
         return;
@@ -470,10 +483,10 @@ void ScrollView::updateScrollbars(const IntSize& desiredOffset)
         return;
 
     m_inUpdateScrollbars = true;
-    IntSize maxScrollPosition(contentsWidth() - visibleWidth(), contentsHeight() - visibleHeight());
-    IntSize scroll = desiredOffset.shrunkTo(maxScrollPosition);
-    scroll.clampNegativeToZero();
- 
+
+    IntPoint scrollPoint = adjustScrollPositionWithinRange(IntPoint(desiredOffset.width(), desiredOffset.height()));
+    IntSize scroll(scrollPoint.x(), scrollPoint.y());
+
     if (m_horizontalScrollbar) {
         int clientWidth = visibleWidth();
         m_horizontalScrollbar->setEnabled(contentsWidth() > clientWidth);
@@ -491,7 +504,7 @@ void ScrollView::updateScrollbars(const IntSize& desiredOffset)
             m_horizontalScrollbar->setSuppressInvalidation(true);
         m_horizontalScrollbar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep);
         m_horizontalScrollbar->setProportion(clientWidth, contentsWidth());
-        m_horizontalScrollbar->setValue(scroll.width(), Scrollbar::NotFromScrollAnimator);
+        m_horizontalScrollbar->setValue(scroll.width() + m_scrollOriginX, Scrollbar::NotFromScrollAnimator);
         if (m_scrollbarsSuppressed)
             m_horizontalScrollbar->setSuppressInvalidation(false); 
     } 
@@ -1015,6 +1028,21 @@ void ScrollView::removePanScrollIcon()
     hostWindow()->invalidateContentsAndWindow(IntRect(m_panScrollIconPoint, IntSize(panIconSizeLength, panIconSizeLength)), true /*immediate*/);
 }
 
+void ScrollView::setScrollOriginX(int x)
+{
+    if (platformWidget())
+        platformSetScrollOriginX(x);
+
+    m_scrollOriginX = x;
+}
+
+void ScrollView::updateScrollbars()
+{
+    if (!platformWidget())
+        updateScrollbars(scrollOffset());
+    // FIXME: need corresponding functionality from platformWidget.
+}
+
 #if !PLATFORM(WX) && !PLATFORM(GTK) && !PLATFORM(EFL)
 
 void ScrollView::platformInit()
@@ -1045,6 +1073,10 @@ void ScrollView::platformSetScrollbarsSuppressed(bool)
 {
 }
 
+void ScrollView::platformSetScrollOriginX(int)
+{
+}
+
 #endif
 
 #if !PLATFORM(MAC) && !PLATFORM(WX)
diff --git a/WebCore/platform/ScrollView.h b/WebCore/platform/ScrollView.h
index 4dea56f..d4df2cc 100644
--- a/WebCore/platform/ScrollView.h
+++ b/WebCore/platform/ScrollView.h
@@ -160,6 +160,9 @@ public:
     IntPoint scrollPosition() const { return visibleContentRect().location(); }
     IntSize scrollOffset() const { return visibleContentRect().location() - IntPoint(); } // Gets the scrolled position as an IntSize. Convenient for adding to other sizes.
     IntPoint maximumScrollPosition() const; // The maximum position we can be scrolled to.
+    IntPoint minimumScrollPosition() const; // The minimum position we can be scrolled to.
+    // Adjust the pass in scroll position within the minimum and maximum positions.
+    IntPoint adjustScrollPositionWithinRange(const IntPoint&) const; 
     int scrollX() const { return scrollPosition().x(); }
     int scrollY() const { return scrollPosition().y(); }
     
@@ -279,6 +282,10 @@ protected:
     // Scroll the content by invalidating everything.
     virtual void scrollContentsSlowPath(const IntRect& updateRect);
 
+    void setScrollOriginX(int);
+    int scrollOriginX() { return m_scrollOriginX; }
+    void updateScrollbars();
+
 private:
     RefPtr<Scrollbar> m_horizontalScrollbar;
     RefPtr<Scrollbar> m_verticalScrollbar;
@@ -314,6 +321,11 @@ private:
     bool m_paintsEntireContents;
     bool m_delegatesScrolling;
 
+    // m_scrollOriginX is 0 for LTR page. And it is negative of left layout
+    // overflow for RTL page. It is mainly used to set the horizontal scrollbar
+    // position for RTL page.
+    int m_scrollOriginX;
+
     void init();
     void destroy();
 
@@ -341,6 +353,8 @@ private:
     void platformSetScrollbarsSuppressed(bool repaintOnUnsuppress);
     void platformRepaintContentRectangle(const IntRect&, bool now);
     bool platformIsOffscreen() const;
+   
+    void platformSetScrollOriginX(int);
 
 #if PLATFORM(MAC) && defined __OBJC__
 public:
diff --git a/WebCore/platform/mac/ScrollViewMac.mm b/WebCore/platform/mac/ScrollViewMac.mm
index 7ef5dc4..7e415da 100644
--- a/WebCore/platform/mac/ScrollViewMac.mm
+++ b/WebCore/platform/mac/ScrollViewMac.mm
@@ -147,7 +147,7 @@ void ScrollView::platformSetScrollbarsSuppressed(bool repaintOnUnsuppress)
 void ScrollView::platformSetScrollPosition(const IntPoint& scrollPoint)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    NSPoint tempPoint = { max(0, scrollPoint.x()), max(0, scrollPoint.y()) }; // Don't use NSMakePoint to work around 4213314.
+    NSPoint tempPoint = { max(-[scrollView() scrollOriginX], scrollPoint.x()), max(0, scrollPoint.y()) };  // Don't use NSMakePoint to work around 4213314.
     [documentView() scrollPoint:tempPoint];
     END_BLOCK_OBJC_EXCEPTIONS;
 }
@@ -202,4 +202,11 @@ bool ScrollView::platformIsOffscreen() const
     return ![platformWidget() window] || ![[platformWidget() window] isVisible];
 }
 
+void ScrollView::platformSetScrollOriginX(int x)
+{
+    BEGIN_BLOCK_OBJC_EXCEPTIONS;
+    [scrollView() setScrollOriginX:x];
+    END_BLOCK_OBJC_EXCEPTIONS;
+}
+
 } // namespace WebCore
diff --git a/WebCore/rendering/RenderBox.cpp b/WebCore/rendering/RenderBox.cpp
index e2a4a53..20d627a 100644
--- a/WebCore/rendering/RenderBox.cpp
+++ b/WebCore/rendering/RenderBox.cpp
@@ -772,7 +772,7 @@ void RenderBox::paintRootBoxDecorations(PaintInfo& paintInfo, int tx, int ty)
     // CSS2 14.2:
     // The background of the box generated by the root element covers the entire canvas including
     // its margins.
-    int bx = tx - marginLeft();
+    int bx = tx - marginLeft() + view()->leftLayoutOverflow();
     int by = ty - marginTop();
     int bw = max(w + marginLeft() + marginRight() + borderLeft() + borderRight(), rw);
     int bh = max(h + marginTop() + marginBottom() + borderTop() + borderBottom(), rh);
diff --git a/WebCore/rendering/RenderView.cpp b/WebCore/rendering/RenderView.cpp
index 6b4b65c..93d2196 100644
--- a/WebCore/rendering/RenderView.cpp
+++ b/WebCore/rendering/RenderView.cpp
@@ -131,7 +131,8 @@ void RenderView::layout()
 
     // Reset overflow and then replace it with docWidth and docHeight.
     m_overflow.clear();
-    addLayoutOverflow(IntRect(0, 0, docWidth(), docHeight()));
+    int leftOverflow = docLeft();
+    addLayoutOverflow(IntRect(leftOverflow, 0, docWidth(leftOverflow), docHeight()));
 
     ASSERT(layoutDelta() == IntSize());
     ASSERT(m_layoutStateDisableCount == 0);
@@ -633,9 +634,15 @@ int RenderView::docHeight() const
     return h;
 }
 
-int RenderView::docWidth() const
+int RenderView::docLeft() const
 {
-    int w = rightmostPosition();
+    // Clip out left overflow in LTR page.
+    return style()->isLeftToRightDirection() ? 0 : std::min(0, leftmostPosition());
+}
+
+int RenderView::docWidth(int leftOverflow) const
+{
+    int w = style()->isLeftToRightDirection() ? rightmostPosition() : width() - leftOverflow;
 
     for (RenderBox* c = firstChildBox(); c; c = c->nextSiblingBox()) {
         int dw = c->width() + c->marginLeft() + c->marginRight();
diff --git a/WebCore/rendering/RenderView.h b/WebCore/rendering/RenderView.h
index 07f933f..41a0506 100644
--- a/WebCore/rendering/RenderView.h
+++ b/WebCore/rendering/RenderView.h
@@ -174,7 +174,8 @@ private:
     bool shouldRepaint(const IntRect& r) const;
         
     int docHeight() const;
-    int docWidth() const;
+    int docLeft() const;
+    int docWidth(int leftOverflow) const;
 
     // These functions may only be accessed by LayoutStateMaintainer.
     bool pushLayoutState(RenderBox* renderer, const IntSize& offset, int pageHeight = 0, bool pageHeightChanged = false, ColumnInfo* colInfo = 0)
diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index 5b9ab92..fe5c984 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,3 +1,28 @@
+2010-11-29  Jeremy Moskovich  <jeremy at chromium.org>
+
+        Reviewed by David Hyatt.
+
+        Right-to-left pages should be scrollable to reveal left overflow.
+        https://bugs.webkit.org/show_bug.cgi?id=23556
+
+        Set and get the original x-axis scroll position and reset scroll position on HOME/END key press.
+        Modify WebFrameView to support setting the initial horizontal scroller's thumb position to the right for
+        pages with a left overflow.
+
+        * WebView/WebDynamicScrollBarsView.h:
+        * WebView/WebDynamicScrollBarsView.mm:
+        (-[WebDynamicScrollBarsView inProgramaticScroll]):
+        (-[WebDynamicScrollBarsView refreshInitialScrollbarPosition]):
+        (-[WebDynamicScrollBarsView updateScrollers]):
+        (-[WebDynamicScrollBarsView reflectScrolledClipView:]):
+        (-[WebDynamicScrollBarsView setScrollOriginX:]):
+        (-[WebDynamicScrollBarsView scrollOriginX]):
+        * WebView/WebFrameView.mm:
+        (-[WebFrameView _scrollToBeginningOfDocument]):
+        (-[WebFrameView _scrollToEndOfDocument]):
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView _frameOrBoundsChanged]):
+
 2010-11-22  Ryosuke Niwa  <rniwa at webkit.org>
 
         Reviewed by Tony Chang.
diff --git a/WebKit/mac/WebView/WebDynamicScrollBarsView.h b/WebKit/mac/WebView/WebDynamicScrollBarsView.h
index c289a04..b89462d 100644
--- a/WebKit/mac/WebView/WebDynamicScrollBarsView.h
+++ b/WebKit/mac/WebView/WebDynamicScrollBarsView.h
@@ -58,4 +58,10 @@ struct WebDynamicScrollBarsViewPrivate;
 // visible is that they have been suppressed by setAlwaysHideHorizontal/VerticalScroller:.
 - (BOOL)horizontalScrollingAllowed;
 - (BOOL)verticalScrollingAllowed;
+
+// Returns YES if we're currently in the middle of programmatically moving the
+// scrollbar.
+// NOTE: As opposed to other places in the code, programmatically moving the
+// scrollers from inside this class should not fire JS events.
+- (BOOL)inProgramaticScroll;
 @end
diff --git a/WebKit/mac/WebView/WebDynamicScrollBarsView.mm b/WebKit/mac/WebView/WebDynamicScrollBarsView.mm
index 74439dd..480d146 100644
--- a/WebKit/mac/WebView/WebDynamicScrollBarsView.mm
+++ b/WebKit/mac/WebView/WebDynamicScrollBarsView.mm
@@ -62,6 +62,15 @@ struct WebDynamicScrollBarsViewPrivate {
     bool alwaysHideVerticalScroller;
     bool horizontalScrollingAllowedButScrollerHidden;
     bool verticalScrollingAllowedButScrollerHidden;
+
+    // scrollOriginX is 0 for LTR page and is the negative of left layout overflow value for RTL page.
+    int scrollOriginX;
+
+    // Flag to indicate that the scrollbar thumb's initial position needs to
+    // be manually set.
+    bool setScrollbarThumbInitialPosition;
+
+    bool inProgrammaticScroll;
 };
 
 @implementation WebDynamicScrollBarsView
@@ -149,6 +158,11 @@ struct WebDynamicScrollBarsViewPrivate {
     return _private->verticalScrollingAllowedButScrollerHidden || [self hasVerticalScroller];
 }
 
+- (BOOL)inProgramaticScroll
+{
+    return _private->inProgrammaticScroll;
+}
+
 @end
 
 @implementation WebDynamicScrollBarsView (WebInternal)
@@ -201,6 +215,29 @@ struct WebDynamicScrollBarsViewPrivate {
 #endif
 }
 
+- (void)refreshInitialScrollbarPosition
+{
+    if (_private->setScrollbarThumbInitialPosition) {
+        NSView *documentView = [self documentView];
+        NSRect documentRect = [documentView bounds];
+
+        // If scrollOriginX is non-zero that means that there's a left overflow <=> this is an RTL document and thus
+        // the initial position of the horizontal scrollbar thumb should be on the right.
+        // FIXME: If knowledge of document directionality is ever propagated to the scroll view, it probably makes
+        // more sense to use the directionality directly in the below if statement, rather than doing so indirectly
+        // through scrollOriginX.
+        if (_private->scrollOriginX != 0) {
+            // The call to [NSView scrollPoint:] fires off notification the handler for which needs to know that
+            // we're setting the initial scroll position so it doesn't interpret this as a user action and
+            // fire off a JS event.
+            _private->inProgrammaticScroll = true;
+            [documentView scrollPoint:NSMakePoint(NSMaxX(documentRect) - NSWidth([self contentViewFrame]), 0)];
+            _private->inProgrammaticScroll = false;
+        }
+        _private->setScrollbarThumbInitialPosition = false;
+    }
+}
+
 static const unsigned cMaxUpdateScrollbarsPass = 2;
 
 - (void)updateScrollers
@@ -302,6 +339,12 @@ static const unsigned cMaxUpdateScrollbarsPass = 2;
     if (hasHorizontalScroller != newHasHorizontalScroller) {
         _private->inUpdateScrollers = YES;
         [self setHasHorizontalScroller:newHasHorizontalScroller];
+        
+        // For RTL documents, we need to set the initial position of the
+        // horizontal scrollbar thumb to be on the right.
+        if (newHasHorizontalScroller)
+            _private->setScrollbarThumbInitialPosition = true;
+        
         _private->inUpdateScrollers = NO;
         needsLayout = YES;
     }
@@ -364,6 +407,11 @@ static const unsigned cMaxUpdateScrollbarsPass = 2;
     }
 #endif
 
+    // The call to [NSView reflectScrolledClipView] sets the scrollbar thumb
+    // position to 0 (the left) when the view is initially displayed.
+    // This call updates the initial position correctly.
+    [self refreshInitialScrollbarPosition];
+
 #if USE(ACCELERATED_COMPOSITING) && defined(BUILDING_ON_LEOPARD)
     NSView *documentView = [self documentView];
     if ([documentView isKindOfClass:[WebHTMLView class]]) {
@@ -525,4 +573,22 @@ static const unsigned cMaxUpdateScrollbarsPass = 2;
     return [super accessibilityIsIgnored];
 }
 
+- (void)setScrollOriginX:(int)scrollOriginX
+{
+    _private->scrollOriginX = scrollOriginX;
+    
+    id docView = [self documentView];
+    if (scrollOriginX != [docView bounds].origin.x) {
+        // "-[self scrollOriginX]" is equal to the left layout overflow.
+        // Make Document bounds origin x coordinate correspond to the left overflow so the entire canvas is covered by the document.
+        [docView setBoundsOrigin:NSMakePoint(-scrollOriginX, [docView bounds].origin.y)];
+    }
+
+}
+
+- (int)scrollOriginX
+{
+    return _private->scrollOriginX;
+}
+
 @end
diff --git a/WebKit/mac/WebView/WebFrameView.mm b/WebKit/mac/WebView/WebFrameView.mm
index 0db12c0..40ee0b1 100644
--- a/WebKit/mac/WebView/WebFrameView.mm
+++ b/WebKit/mac/WebView/WebFrameView.mm
@@ -536,6 +536,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
     if (![self _isScrollable])
         return NO;
     NSPoint point = [[[self _scrollView] documentView] frame].origin;
+    point.x += [[self _scrollView] scrollOriginX];
     return [[self _contentView] _scrollTo:&point animate:YES];
 }
 
@@ -547,6 +548,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
         return NO;
     NSRect frame = [[[self _scrollView] documentView] frame];
     NSPoint point = NSMakePoint(frame.origin.x, NSMaxY(frame));
+    point.x += [[self _scrollView] scrollOriginX];
     return [[self _contentView] _scrollTo:&point animate:YES];
 }
 
diff --git a/WebKit/mac/WebView/WebHTMLView.mm b/WebKit/mac/WebView/WebHTMLView.mm
index ec2473f..07e4876 100644
--- a/WebKit/mac/WebView/WebHTMLView.mm
+++ b/WebKit/mac/WebView/WebHTMLView.mm
@@ -1198,8 +1198,11 @@ static void _updateMouseoverTimerCallback(CFRunLoopTimerRef timer, void *info)
 
 - (void)_frameOrBoundsChanged
 {
+    WebView *webView = [self _webView];
+    WebDynamicScrollBarsView *scrollView = [[[webView mainFrame] frameView] _scrollView];
+
     NSPoint origin = [[self superview] bounds].origin;
-    if (!NSEqualPoints(_private->lastScrollPosition, origin)) {
+    if (!NSEqualPoints(_private->lastScrollPosition, origin) && ![scrollView inProgramaticScroll]) {
         if (Frame* coreFrame = core([self _frame])) {
             if (FrameView* coreView = coreFrame->view()) {
 #ifndef BUILDING_ON_TIGER
@@ -1214,7 +1217,6 @@ static void _updateMouseoverTimerCallback(CFRunLoopTimerRef timer, void *info)
     
         [_private->completionController endRevertingChange:NO moveLeft:NO];
         
-        WebView *webView = [self _webView];
         [[webView _UIDelegateForwarder] webView:webView didScrollDocumentInFrameView:[self _frameView]];
     }
     _private->lastScrollPosition = origin;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list