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

hyatt at apple.com hyatt at apple.com
Wed Dec 22 17:52:08 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit a26422b05caa4c260e3d4917bf0edd4b08919057
Author: hyatt at apple.com <hyatt at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Dec 1 21:31:50 2010 +0000

    https://bugs.webkit.org/show_bug.cgi?id=46645
    
    Reviewed by Darin Adler.
    
    Part 1 of making scrolling work with vertical text. This patch generalizes the scrollOriginX concept
    recently added for horizontal RTL documents and applies it to writing modes as well.  Now the
    scrollOrigin is a point, since you can start off locked to the bottom or locked to the right.
    
    This patch also fixes numerous bugs with the scrollOrigin code using native Mac NSScrollViews and
    makes them behave the same as the cross-platform code (allowing for cross-platform results to be
    landed).
    
    WebCore:
    
    * page/FrameView.cpp:
    (WebCore::FrameView::adjustViewSize):
    * page/mac/WebCoreFrameView.h:
    * platform/ScrollView.cpp:
    (WebCore::ScrollView::ScrollView):
    (WebCore::ScrollView::maximumScrollPosition):
    (WebCore::ScrollView::minimumScrollPosition):
    (WebCore::ScrollView::valueChanged):
    (WebCore::ScrollView::updateScrollbars):
    (WebCore::ScrollView::wheelEvent):
    * platform/ScrollView.h:
    (WebCore::ScrollView::scrollOrigin):
    * platform/mac/ScrollViewMac.mm:
    (WebCore::ScrollView::platformSetScrollPosition):
    (WebCore::ScrollView::platformSetScrollOrigin):
    * rendering/RenderBox.cpp:
    (WebCore::RenderBox::paintRootBoxDecorations):
    * rendering/RenderView.cpp:
    (WebCore::RenderView::layout):
    (WebCore::RenderView::docTop):
    (WebCore::RenderView::docHeight):
    (WebCore::RenderView::docLeft):
    (WebCore::RenderView::docWidth):
    * rendering/RenderView.h:
    
    WebKit/mac:
    
    * WebView/WebDynamicScrollBarsView.mm:
    (-[WebDynamicScrollBarsView adjustForScrollOriginChange]):
    (-[WebDynamicScrollBarsView updateScrollers]):
    (-[WebDynamicScrollBarsView reflectScrolledClipView:]):
    (-[WebDynamicScrollBarsView setScrollOrigin:updatePosition:]):
    (-[WebDynamicScrollBarsView scrollOrigin]):
    * WebView/WebFrameView.mm:
    (-[WebFrameView _scrollToBeginningOfDocument]):
    (-[WebFrameView _scrollToEndOfDocument]):
    
    LayoutTests:
    
    * fast/dom/vertical-scrollbar-in-rtl-doesnt-fire-onscroll-expected.txt: Added.
    * fast/dom/vertical-scrollbar-in-rtl-doesnt-fire-onscroll.html: Added.
    * fast/dom/vertical-scrollbar-in-rtl-expected.txt: Added.
    * fast/dom/vertical-scrollbar-in-rtl.html: Added.
    * fast/dom/vertical-scrollbar-when-dir-change-expected.txt: Added.
    * fast/dom/vertical-scrollbar-when-dir-change.html: Added.
    * platform/mac/fast/dom/horizontal-scrollbar-in-rtl-expected.txt: Removed.
    * platform/mac/fast/dom/horizontal-scrollbar-when-dir-change-expected.txt: Removed.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73063 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 99bd0e3..f3b1c2a 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,26 @@
+2010-12-01  David Hyatt  <hyatt at apple.com>
+
+        Reviewed by Darin Adler.
+
+        https://bugs.webkit.org/show_bug.cgi?id=46645
+        
+        Part 1 of making scrolling work with vertical text. This patch generalizes the scrollOriginX concept
+        recently added for horizontal RTL documents and applies it to writing modes as well.  Now the
+        scrollOrigin is a point, since you can start off locked to the bottom or locked to the right.
+        
+        This patch also fixes numerous bugs with the scrollOrigin code using native Mac NSScrollViews and
+        makes them behave the same as the cross-platform code (allowing for cross-platform results to be
+        landed).
+
+        * fast/dom/vertical-scrollbar-in-rtl-doesnt-fire-onscroll-expected.txt: Added.
+        * fast/dom/vertical-scrollbar-in-rtl-doesnt-fire-onscroll.html: Added.
+        * fast/dom/vertical-scrollbar-in-rtl-expected.txt: Added.
+        * fast/dom/vertical-scrollbar-in-rtl.html: Added.
+        * fast/dom/vertical-scrollbar-when-dir-change-expected.txt: Added.
+        * fast/dom/vertical-scrollbar-when-dir-change.html: Added.
+        * platform/mac/fast/dom/horizontal-scrollbar-in-rtl-expected.txt: Removed.
+        * platform/mac/fast/dom/horizontal-scrollbar-when-dir-change-expected.txt: Removed.
+
 2010-12-01  Victor Wang  <victorw at chromium.org>
 
         Unreviewed.
diff --git a/LayoutTests/fast/dom/horizontal-scrollbar-in-rtl-expected.txt b/LayoutTests/fast/dom/horizontal-scrollbar-in-rtl-expected.txt
new file mode 100644
index 0000000..61b3fc6
--- /dev/null
+++ b/LayoutTests/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: 0
+KeyDown END move x-scroll position to right for RTL page: 0
+selectAll selects all document: Success
diff --git a/LayoutTests/platform/win/fast/dom/horizontal-scrollbar-when-dir-change-expected.txt b/LayoutTests/fast/dom/horizontal-scrollbar-when-dir-change-expected.txt
similarity index 100%
copy from LayoutTests/platform/win/fast/dom/horizontal-scrollbar-when-dir-change-expected.txt
copy to LayoutTests/fast/dom/horizontal-scrollbar-when-dir-change-expected.txt
diff --git a/LayoutTests/fast/dom/vertical-scrollbar-in-rtl-doesnt-fire-onscroll-expected.txt b/LayoutTests/fast/dom/vertical-scrollbar-in-rtl-doesnt-fire-onscroll-expected.txt
new file mode 100644
index 0000000..e2f641f
--- /dev/null
+++ b/LayoutTests/fast/dom/vertical-scrollbar-in-rtl-doesnt-fire-onscroll-expected.txt
@@ -0,0 +1,4 @@
+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/vertical-scrollbar-in-rtl-doesnt-fire-onscroll.html b/LayoutTests/fast/dom/vertical-scrollbar-in-rtl-doesnt-fire-onscroll.html
new file mode 100644
index 0000000..a3c0be0
--- /dev/null
+++ b/LayoutTests/fast/dom/vertical-scrollbar-in-rtl-doesnt-fire-onscroll.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html dir=rtl style="-webkit-writing-mode:vertical-lr">
+    <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: 1000px; height: 4000px; 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/vertical-scrollbar-in-rtl-expected.txt b/LayoutTests/fast/dom/vertical-scrollbar-in-rtl-expected.txt
new file mode 100644
index 0000000..bf6b029
--- /dev/null
+++ b/LayoutTests/fast/dom/vertical-scrollbar-in-rtl-expected.txt
@@ -0,0 +1,9 @@
+original scroll y for RTL page : Success
+vertical scroll: : Success
+continuously call window.scrollY : Success
+zoom in and out preserve scroll position: Success
+resize preserves scroll position: Success
+wheel scroll preserves vertical scroll position: Success
+KeyDown HOME move y-scroll position to bottom for RTL page: 0
+KeyDown END move y-scroll position to bottom for RTL page: 0
+selectAll selects all document: Success
diff --git a/LayoutTests/fast/dom/vertical-scrollbar-in-rtl.html b/LayoutTests/fast/dom/vertical-scrollbar-in-rtl.html
new file mode 100644
index 0000000..1d23175
--- /dev/null
+++ b/LayoutTests/fast/dom/vertical-scrollbar-in-rtl.html
@@ -0,0 +1,104 @@
+<html dir=rtl style="-webkit-writing-mode:vertical-lr">
+    <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 assertClose(message, actual, expected)
+            {
+                if ((actual >= expected && actual - expected < 5) ||
+                    (expected >= actual && expected - actual < 5))
+                    log("\n" + message + ": Success");
+                else
+                    log("\n" + message + ": Failure, actual: " + actual + "; expected: " + expected);
+            }
+            
+            var expectedScrollX = 500;
+            var expectedScrollY = -1000;
+
+            function mousewheelHandler(e) 
+            {
+                assertEqual("wheel scroll preserves vertical scroll position", window.scrollY, expectedScrollY);
+            }
+            
+            onload = function()
+            {
+                if (window.layoutTestController)
+                    layoutTestController.dumpAsText();
+
+                // Test vertical scrollbar presence and that it is initially at the bottom for RTL page.
+                assertEqual("original scroll y for RTL page ", window.scrollY, 0);
+            
+                // Test horizontal scroll.
+                window.scrollTo(expectedScrollX, expectedScrollY);
+                assertEqual("vertical scroll: ", window.scrollY, expectedScrollY);
+                // Test calling window.scrollY continuously wont change the scrollY position.
+                assertEqual("continuously call window.scrollY ", window.scrollY, expectedScrollY);
+            
+
+                // Test zooming wont reset scroll position.
+                if (window.eventSender) {
+                    window.scrollTo(expectedScrollX, expectedScrollY);
+                    eventSender.zoomPageIn();
+                    eventSender.zoomPageOut();
+                    assertClose("zoom in and out preserve scroll position", window.scrollY, expectedScrollY);
+                }
+               
+                // Test resize wont reset scroll position.
+                window.resizeTo(window.innerWidth, 1000);
+                window.scrollTo(expectedScrollX, expectedScrollY);
+                window.resizeTo(window.innerWidth, 2000);
+                assertEqual("resize preserves scroll position", window.scrollY, expectedScrollY);
+                
+                // Test wheel scroll preserves horizontal scroll position.
+                window.scrollTo(expectedScrollX / 2, expectedScrollY);
+                var div = document.getElementById("div");
+                div.addEventListener("mousewheel", mousewheelHandler, false);
+                var wheelEvent = document.createEvent("WheelEvent");
+                wheelEvent.initWebKitWheelEvent(expectedScrollX / 2, 0, 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 y-scroll position to bottom for RTL page: " + window.scrollY, 0);
+                    window.scrollTo(expectedScrollX, expectedScrollY);
+                    eventSender.keyDown("end");
+                    log("KeyDown END move y-scroll position to bottom for RTL page: " + window.scrollY, 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: 1000px; height: 4000px; 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/vertical-scrollbar-when-dir-change-expected.txt b/LayoutTests/fast/dom/vertical-scrollbar-when-dir-change-expected.txt
new file mode 100644
index 0000000..e028475
--- /dev/null
+++ b/LayoutTests/fast/dom/vertical-scrollbar-when-dir-change-expected.txt
@@ -0,0 +1,6 @@
+original scroll y for RTL page : Success
+vertical scroll y for RTL page : Success
+original scroll y for LTR page : Success
+vertical scroll y for LTR page : Success
+
+
diff --git a/LayoutTests/fast/dom/vertical-scrollbar-when-dir-change.html b/LayoutTests/fast/dom/vertical-scrollbar-when-dir-change.html
new file mode 100644
index 0000000..1e11823
--- /dev/null
+++ b/LayoutTests/fast/dom/vertical-scrollbar-when-dir-change.html
@@ -0,0 +1,46 @@
+<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");
+}
+
+onload = function()
+{
+    if (window.layoutTestController)                    
+        layoutTestController.dumpAsText();
+
+    assertEqual("original scroll y for RTL page ", window.scrollY, 0);
+    window.scrollTo(0, -100);
+    assertEqual("vertical scroll y for RTL page ", window.scrollY, -100);
+
+    document.body.dir = "ltr";
+    assertEqual("original scroll y for LTR page ", window.scrollY, 0);
+    window.scrollTo(0, 100);
+    assertEqual("vertical scroll y for LTR page ", window.scrollY, 100);
+
+    document.getElementById("div").style.display = "none";
+}
+</script>
+</head>
+<body dir="rtl" style="-webkit-writing-mode:vertical-lr">
+
+<div style="height: 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/platform/mac/fast/dom/horizontal-scrollbar-in-rtl-expected.txt b/LayoutTests/platform/mac/fast/dom/horizontal-scrollbar-in-rtl-expected.txt
deleted file mode 100644
index 24217c5..0000000
--- a/LayoutTests/platform/mac/fast/dom/horizontal-scrollbar-in-rtl-expected.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-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
deleted file mode 100644
index 664c0cc..0000000
--- a/LayoutTests/platform/mac/fast/dom/horizontal-scrollbar-when-dir-change-expected.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-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/WebCore/ChangeLog b/WebCore/ChangeLog
index 2e85930..2ac9a8c 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,42 @@
+2010-12-01  David Hyatt  <hyatt at apple.com>
+
+        Reviewed by Darin Adler.
+
+        https://bugs.webkit.org/show_bug.cgi?id=46645
+        
+        Part 1 of making scrolling work with vertical text. This patch generalizes the scrollOriginX concept
+        recently added for horizontal RTL documents and applies it to writing modes as well.  Now the
+        scrollOrigin is a point, since you can start off locked to the bottom or locked to the right.
+        
+        This patch also fixes numerous bugs with the scrollOrigin code using native Mac NSScrollViews and
+        makes them behave the same as the cross-platform code (allowing for cross-platform results to be
+        landed).
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::adjustViewSize):
+        * page/mac/WebCoreFrameView.h:
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::ScrollView):
+        (WebCore::ScrollView::maximumScrollPosition):
+        (WebCore::ScrollView::minimumScrollPosition):
+        (WebCore::ScrollView::valueChanged):
+        (WebCore::ScrollView::updateScrollbars):
+        (WebCore::ScrollView::wheelEvent):
+        * platform/ScrollView.h:
+        (WebCore::ScrollView::scrollOrigin):
+        * platform/mac/ScrollViewMac.mm:
+        (WebCore::ScrollView::platformSetScrollPosition):
+        (WebCore::ScrollView::platformSetScrollOrigin):
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::paintRootBoxDecorations):
+        * rendering/RenderView.cpp:
+        (WebCore::RenderView::layout):
+        (WebCore::RenderView::docTop):
+        (WebCore::RenderView::docHeight):
+        (WebCore::RenderView::docLeft):
+        (WebCore::RenderView::docWidth):
+        * rendering/RenderView.h:
+
 2010-11-30  Steve Block  <steveblock at google.com>
 
         Reviewed by Jeremy Orlow.
diff --git a/WebCore/page/FrameView.cpp b/WebCore/page/FrameView.cpp
index 067a8e8..6fea8cf 100644
--- a/WebCore/page/FrameView.cpp
+++ b/WebCore/page/FrameView.cpp
@@ -435,15 +435,10 @@ void FrameView::adjustViewSize()
     if (!root)
         return;
 
-    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();
+    IntSize size = IntSize(root->rightLayoutOverflow() - root->leftLayoutOverflow(), root->bottomLayoutOverflow() - root->topLayoutOverflow());
+
+    ScrollView::setScrollOrigin(IntPoint(-root->leftLayoutOverflow(), -root->topLayoutOverflow()), size == contentsSize());
+    
     setContentsSize(size);
 }
 
diff --git a/WebCore/page/mac/WebCoreFrameView.h b/WebCore/page/mac/WebCoreFrameView.h
index 8b25102..b76350d 100644
--- a/WebCore/page/mac/WebCoreFrameView.h
+++ b/WebCore/page/mac/WebCoreFrameView.h
@@ -33,8 +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;
+- (void)setScrollOrigin:(NSPoint)origin updatePosition:(BOOL)updatePosition;
+- (NSPoint)scrollOrigin;
 @end
 
 @protocol WebCoreFrameView
diff --git a/WebCore/platform/ScrollView.cpp b/WebCore/platform/ScrollView.cpp
index 70e1772..424c4d7 100644
--- a/WebCore/platform/ScrollView.cpp
+++ b/WebCore/platform/ScrollView.cpp
@@ -54,7 +54,6 @@ ScrollView::ScrollView()
     , m_useFixedLayout(false)
     , m_paintsEntireContents(false)
     , m_delegatesScrolling(false)
-    , m_scrollOriginX(0)
 {
     platformInit();
 }
@@ -279,14 +278,14 @@ void ScrollView::setContentsSize(const IntSize& newSize)
 
 IntPoint ScrollView::maximumScrollPosition() const
 {
-    IntPoint maximumOffset(contentsWidth() - visibleWidth() - m_scrollOriginX, contentsHeight() - visibleHeight());
+    IntPoint maximumOffset(contentsWidth() - visibleWidth() - m_scrollOrigin.x(), contentsHeight() - visibleHeight() - m_scrollOrigin.y());
     maximumOffset.clampNegativeToZero();
     return maximumOffset;
 }
 
 IntPoint ScrollView::minimumScrollPosition() const
 {
-    return IntPoint(-m_scrollOriginX, 0);
+    return IntPoint(-m_scrollOrigin.x(), -m_scrollOrigin.y());
 }
 
 IntPoint ScrollView::adjustScrollPositionWithinRange(const IntPoint& scrollPoint) const
@@ -316,9 +315,9 @@ void ScrollView::valueChanged(Scrollbar* scrollbar)
     IntSize newOffset = m_scrollOffset;
     if (scrollbar) {
         if (scrollbar->orientation() == HorizontalScrollbar)
-            newOffset.setWidth(scrollbar->value() - m_scrollOriginX);
+            newOffset.setWidth(scrollbar->value() - m_scrollOrigin.x());
         else if (scrollbar->orientation() == VerticalScrollbar)
-            newOffset.setHeight(scrollbar->value());
+            newOffset.setHeight(scrollbar->value() - m_scrollOrigin.y());
     }
 
     IntSize scrollDelta = newOffset - m_scrollOffset;
@@ -503,7 +502,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() + m_scrollOriginX, Scrollbar::NotFromScrollAnimator);
+        m_horizontalScrollbar->setValue(scroll.width() + m_scrollOrigin.x(), Scrollbar::NotFromScrollAnimator);
         if (m_scrollbarsSuppressed)
             m_horizontalScrollbar->setSuppressInvalidation(false); 
     } 
@@ -525,7 +524,7 @@ void ScrollView::updateScrollbars(const IntSize& desiredOffset)
             m_verticalScrollbar->setSuppressInvalidation(true);
         m_verticalScrollbar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep);
         m_verticalScrollbar->setProportion(clientHeight, contentsHeight());
-        m_verticalScrollbar->setValue(scroll.height(), Scrollbar::NotFromScrollAnimator);
+        m_verticalScrollbar->setValue(scroll.height() + m_scrollOrigin.y(), Scrollbar::NotFromScrollAnimator);
         if (m_scrollbarsSuppressed)
             m_verticalScrollbar->setSuppressInvalidation(false);
     }
@@ -1027,19 +1026,21 @@ void ScrollView::removePanScrollIcon()
     hostWindow()->invalidateContentsAndWindow(IntRect(m_panScrollIconPoint, IntSize(panIconSizeLength, panIconSizeLength)), true /*immediate*/);
 }
 
-void ScrollView::setScrollOriginX(int x)
+void ScrollView::setScrollOrigin(const IntPoint& origin, bool updatePosition)
 {
-    if (platformWidget())
-        platformSetScrollOriginX(x);
+    if (m_scrollOrigin == origin)
+        return;
 
-    m_scrollOriginX = x;
-}
+    m_scrollOrigin = origin;
 
-void ScrollView::updateScrollbars()
-{
-    if (!platformWidget())
+    if (platformWidget()) {
+        platformSetScrollOrigin(origin, updatePosition);
+        return;
+    }
+    
+    // Update if the scroll origin changes, since our position will be different if the content size did not change.
+    if (updatePosition)
         updateScrollbars(scrollOffset());
-    // FIXME: need corresponding functionality from platformWidget.
 }
 
 #if !PLATFORM(WX) && !PLATFORM(GTK) && !PLATFORM(EFL)
@@ -1072,7 +1073,7 @@ void ScrollView::platformSetScrollbarsSuppressed(bool)
 {
 }
 
-void ScrollView::platformSetScrollOriginX(int)
+void ScrollView::platformSetScrollOrigin(const IntPoint&, bool updatePosition)
 {
 }
 
diff --git a/WebCore/platform/ScrollView.h b/WebCore/platform/ScrollView.h
index d4df2cc..7e846bc 100644
--- a/WebCore/platform/ScrollView.h
+++ b/WebCore/platform/ScrollView.h
@@ -161,7 +161,7 @@ public:
     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.
+    // Adjust the passed in scroll position to keep it between the minimum and maximum positions.
     IntPoint adjustScrollPositionWithinRange(const IntPoint&) const; 
     int scrollX() const { return scrollPosition().x(); }
     int scrollY() const { return scrollPosition().y(); }
@@ -282,9 +282,8 @@ protected:
     // Scroll the content by invalidating everything.
     virtual void scrollContentsSlowPath(const IntRect& updateRect);
 
-    void setScrollOriginX(int);
-    int scrollOriginX() { return m_scrollOriginX; }
-    void updateScrollbars();
+    void setScrollOrigin(const IntPoint&, bool updatePosition);
+    IntPoint scrollOrigin() { return m_scrollOrigin; }
 
 private:
     RefPtr<Scrollbar> m_horizontalScrollbar;
@@ -321,10 +320,18 @@ 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;
+    // There are 8 possible combinations of writing mode and direction.  Scroll origin will be non-zero in the x or y axis
+    // if there is any reversed direction or writing-mode.  The combinations are:
+    // writing-mode / direction     scrollOrigin.x() set    scrollOrigin.y() set
+    // horizontal-tb / ltr          NO                      NO
+    // horizontal-tb / rtl          YES                     NO
+    // horizontal-bt / ltr          NO                      YES
+    // horizontal-bt / rtl          YES                     YES
+    // vertical-lr / ltr            NO                      NO
+    // vertical-lr / rtl            NO                      YES
+    // vertical-rl / ltr            YES                     NO
+    // vertical-rl / rtl            YES                     YES
+    IntPoint m_scrollOrigin;
 
     void init();
     void destroy();
@@ -354,7 +361,7 @@ private:
     void platformRepaintContentRectangle(const IntRect&, bool now);
     bool platformIsOffscreen() const;
    
-    void platformSetScrollOriginX(int);
+    void platformSetScrollOrigin(const IntPoint&, bool updatePosition);
 
 #if PLATFORM(MAC) && defined __OBJC__
 public:
diff --git a/WebCore/platform/mac/ScrollViewMac.mm b/WebCore/platform/mac/ScrollViewMac.mm
index 7e415da..93ec971 100644
--- a/WebCore/platform/mac/ScrollViewMac.mm
+++ b/WebCore/platform/mac/ScrollViewMac.mm
@@ -147,7 +147,8 @@ void ScrollView::platformSetScrollbarsSuppressed(bool repaintOnUnsuppress)
 void ScrollView::platformSetScrollPosition(const IntPoint& scrollPoint)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    NSPoint tempPoint = { max(-[scrollView() scrollOriginX], scrollPoint.x()), max(0, scrollPoint.y()) };  // Don't use NSMakePoint to work around 4213314.
+    NSPoint floatPoint = scrollPoint;
+    NSPoint tempPoint = { max(-[scrollView() scrollOrigin].x, floatPoint.x), max(-[scrollView() scrollOrigin].y, floatPoint.y) };  // Don't use NSMakePoint to work around 4213314.
     [documentView() scrollPoint:tempPoint];
     END_BLOCK_OBJC_EXCEPTIONS;
 }
@@ -202,10 +203,10 @@ bool ScrollView::platformIsOffscreen() const
     return ![platformWidget() window] || ![[platformWidget() window] isVisible];
 }
 
-void ScrollView::platformSetScrollOriginX(int x)
+void ScrollView::platformSetScrollOrigin(const IntPoint& origin, bool updatePosition)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    [scrollView() setScrollOriginX:x];
+    [scrollView() setScrollOrigin:origin updatePosition:updatePosition];
     END_BLOCK_OBJC_EXCEPTIONS;
 }
 
diff --git a/WebCore/rendering/RenderBox.cpp b/WebCore/rendering/RenderBox.cpp
index 20d627a..cf00df0 100644
--- a/WebCore/rendering/RenderBox.cpp
+++ b/WebCore/rendering/RenderBox.cpp
@@ -773,7 +773,7 @@ void RenderBox::paintRootBoxDecorations(PaintInfo& paintInfo, int tx, int ty)
     // The background of the box generated by the root element covers the entire canvas including
     // its margins.
     int bx = tx - marginLeft() + view()->leftLayoutOverflow();
-    int by = ty - marginTop();
+    int by = ty - marginTop() + view()->topLayoutOverflow();
     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 93d2196..d6790fc 100644
--- a/WebCore/rendering/RenderView.cpp
+++ b/WebCore/rendering/RenderView.cpp
@@ -132,7 +132,8 @@ void RenderView::layout()
     // Reset overflow and then replace it with docWidth and docHeight.
     m_overflow.clear();
     int leftOverflow = docLeft();
-    addLayoutOverflow(IntRect(leftOverflow, 0, docWidth(leftOverflow), docHeight()));
+    int topOverflow = docTop();
+    addLayoutOverflow(IntRect(leftOverflow, topOverflow, docWidth(leftOverflow), docHeight(topOverflow)));
 
     ASSERT(layoutDelta() == IntSize());
     ASSERT(m_layoutStateDisableCount == 0);
@@ -617,9 +618,18 @@ IntRect RenderView::viewRect() const
     return IntRect();
 }
 
-int RenderView::docHeight() const
+int RenderView::docTop() const
 {
-    int h = lowestPosition();
+    // Clip out top overflow in vertical LTR pages or horizontal-tb pages.
+    if ((!style()->isHorizontalWritingMode() && style()->isLeftToRightDirection()) || style()->writingMode() == TopToBottomWritingMode)
+        return 0;
+    return std::min(0, topmostPosition());
+}
+
+int RenderView::docHeight(int topOverflow) const
+{
+    int h = ((!style()->isHorizontalWritingMode() && style()->isLeftToRightDirection()) || style()->writingMode() == TopToBottomWritingMode) ?
+                lowestPosition() : height() - topOverflow;
 
     // FIXME: This doesn't do any margin collapsing.
     // Instead of this dh computation we should keep the result
@@ -636,13 +646,16 @@ int RenderView::docHeight() const
 
 int RenderView::docLeft() const
 {
-    // Clip out left overflow in LTR page.
-    return style()->isLeftToRightDirection() ? 0 : std::min(0, leftmostPosition());
+    // Clip out left overflow in horizontal LTR pages or vertical-lr pages.
+    if ((style()->isHorizontalWritingMode() && style()->isLeftToRightDirection()) || style()->writingMode() == LeftToRightWritingMode)
+        return 0;
+    return std::min(0, leftmostPosition());
 }
 
 int RenderView::docWidth(int leftOverflow) const
 {
-    int w = style()->isLeftToRightDirection() ? rightmostPosition() : width() - leftOverflow;
+    int w = ((style()->isHorizontalWritingMode() && style()->isLeftToRightDirection()) || style()->writingMode() == LeftToRightWritingMode) ? 
+                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 41a0506..b5d0294 100644
--- a/WebCore/rendering/RenderView.h
+++ b/WebCore/rendering/RenderView.h
@@ -172,8 +172,9 @@ protected:
 
 private:
     bool shouldRepaint(const IntRect& r) const;
-        
-    int docHeight() const;
+    
+    int docTop() const;
+    int docHeight(int topOverflow) const;
     int docLeft() const;
     int docWidth(int leftOverflow) const;
 
diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index d0c7a64..87a814a 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,3 +1,27 @@
+2010-12-01  David Hyatt  <hyatt at apple.com>
+
+        Reviewed by Darin Adler.
+
+        https://bugs.webkit.org/show_bug.cgi?id=46645
+        
+        Part 1 of making scrolling work with vertical text. This patch generalizes the scrollOriginX concept
+        recently added for horizontal RTL documents and applies it to writing modes as well.  Now the
+        scrollOrigin is a point, since you can start off locked to the bottom or locked to the right.
+        
+        This patch also fixes numerous bugs with the scrollOrigin code using native Mac NSScrollViews and
+        makes them behave the same as the cross-platform code (allowing for cross-platform results to be
+        landed).
+
+        * WebView/WebDynamicScrollBarsView.mm:
+        (-[WebDynamicScrollBarsView adjustForScrollOriginChange]):
+        (-[WebDynamicScrollBarsView updateScrollers]):
+        (-[WebDynamicScrollBarsView reflectScrolledClipView:]):
+        (-[WebDynamicScrollBarsView setScrollOrigin:updatePosition:]):
+        (-[WebDynamicScrollBarsView scrollOrigin]):
+        * WebView/WebFrameView.mm:
+        (-[WebFrameView _scrollToBeginningOfDocument]):
+        (-[WebFrameView _scrollToEndOfDocument]):
+
 2010-11-29  Dan Bernstein  <mitz at apple.com>
 
         Reviewed by Darin Adler.
diff --git a/WebKit/mac/WebView/WebDynamicScrollBarsView.mm b/WebKit/mac/WebView/WebDynamicScrollBarsView.mm
index 480d146..1c6980f 100644
--- a/WebKit/mac/WebView/WebDynamicScrollBarsView.mm
+++ b/WebKit/mac/WebView/WebDynamicScrollBarsView.mm
@@ -63,12 +63,14 @@ struct WebDynamicScrollBarsViewPrivate {
     bool horizontalScrollingAllowedButScrollerHidden;
     bool verticalScrollingAllowedButScrollerHidden;
 
-    // scrollOriginX is 0 for LTR page and is the negative of left layout overflow value for RTL page.
-    int scrollOriginX;
+    // scrollOrigin is set for various combinations of writing mode and direction.
+    // See the comment next to the corresponding member in ScrollView.h.
+    NSPoint scrollOrigin;
 
     // Flag to indicate that the scrollbar thumb's initial position needs to
     // be manually set.
-    bool setScrollbarThumbInitialPosition;
+    bool scrollOriginChanged;
+    NSPoint scrollPositionExcludingOrigin;
 
     bool inProgrammaticScroll;
 };
@@ -215,27 +217,22 @@ struct WebDynamicScrollBarsViewPrivate {
 #endif
 }
 
-- (void)refreshInitialScrollbarPosition
+- (void)adjustForScrollOriginChange
 {
-    if (_private->setScrollbarThumbInitialPosition) {
-        NSView *documentView = [self documentView];
-        NSRect documentRect = [documentView bounds];
+    if (!_private->scrollOriginChanged)
+        return;
 
-        // 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;
-    }
+    _private->scrollOriginChanged = false;
+
+    NSView *documentView = [self documentView];
+    NSRect documentRect = [documentView bounds];
+
+    // 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(_private->scrollPositionExcludingOrigin.x + documentRect.origin.x, _private->scrollPositionExcludingOrigin.y + documentRect.origin.y)];
+    _private->inProgrammaticScroll = false;
 }
 
 static const unsigned cMaxUpdateScrollbarsPass = 2;
@@ -339,14 +336,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;
+        NSView *documentView = [self documentView];
+        NSRect documentRect = [documentView bounds];
+        if (documentRect.origin.y < 0 && !newHasHorizontalScroller)
+            [documentView setBoundsOrigin:NSMakePoint(documentRect.origin.x, documentRect.origin.y + 15)];
     }
 
     if (hasVerticalScroller != newHasVerticalScroller) {
@@ -354,6 +349,10 @@ static const unsigned cMaxUpdateScrollbarsPass = 2;
         [self setHasVerticalScroller:newHasVerticalScroller];
         _private->inUpdateScrollers = NO;
         needsLayout = YES;
+        NSView *documentView = [self documentView];
+        NSRect documentRect = [documentView bounds];
+        if (documentRect.origin.x < 0 && !newHasVerticalScroller)
+            [documentView setBoundsOrigin:NSMakePoint(documentRect.origin.x + 15, documentRect.origin.y)];
     }
 
     if (needsLayout && _private->inUpdateScrollersLayoutPass < cMaxUpdateScrollbarsPass &&
@@ -410,7 +409,7 @@ static const unsigned cMaxUpdateScrollbarsPass = 2;
     // 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];
+    [self adjustForScrollOriginChange];
 
 #if USE(ACCELERATED_COMPOSITING) && defined(BUILDING_ON_LEOPARD)
     NSView *documentView = [self documentView];
@@ -573,22 +572,30 @@ static const unsigned cMaxUpdateScrollbarsPass = 2;
     return [super accessibilityIsIgnored];
 }
 
-- (void)setScrollOriginX:(int)scrollOriginX
+- (void)setScrollOrigin:(NSPoint)scrollOrigin updatePosition:(BOOL)updatePosition
 {
-    _private->scrollOriginX = scrollOriginX;
-    
+    // The cross-platform ScrollView call already checked to see if the old/new scroll origins were the same or not
+    // so we don't have to check for equivalence here.
+    _private->scrollOrigin = scrollOrigin;
     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)];
-    }
+    NSPoint docOrigin = [docView bounds].origin;
+
+    NSRect visibleRect = [self documentVisibleRect];
+
+    [docView setBoundsOrigin:NSMakePoint(-scrollOrigin.x, -scrollOrigin.y)];
+
+    _private->scrollOriginChanged = true;
+
+    // Maintain our original position in the presence of the new scroll origin.
+    _private->scrollPositionExcludingOrigin = NSMakePoint(visibleRect.origin.x + scrollOrigin.x, visibleRect.origin.y + scrollOrigin.y);
 
+    if (updatePosition) // Otherwise we'll just let the snap happen when we update for the resize.
+        [self adjustForScrollOriginChange];
 }
 
-- (int)scrollOriginX
+- (NSPoint)scrollOrigin
 {
-    return _private->scrollOriginX;
+    return _private->scrollOrigin;
 }
 
 @end
diff --git a/WebKit/mac/WebView/WebFrameView.mm b/WebKit/mac/WebView/WebFrameView.mm
index 40ee0b1..20905d0 100644
--- a/WebKit/mac/WebView/WebFrameView.mm
+++ b/WebKit/mac/WebView/WebFrameView.mm
@@ -536,7 +536,8 @@ 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];
+    point.x += [[self _scrollView] scrollOrigin].x;
+    point.y += [[self _scrollView] scrollOrigin].y;
     return [[self _contentView] _scrollTo:&point animate:YES];
 }
 
@@ -548,7 +549,8 @@ 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];
+    point.x += [[self _scrollView] scrollOrigin].x;
+    point.y += [[self _scrollView] scrollOrigin].y;
     return [[self _contentView] _scrollTo:&point animate:YES];
 }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list