LayoutTests:
authormjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Mar 2007 01:17:07 +0000 (01:17 +0000)
committermjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Mar 2007 01:17:07 +0000 (01:17 +0000)
        Reviewed by Darin.

        - <rdar://problem/4820817> Autoscroll is broken in Mail.app (message jumps around when trying to select text)

        * fast/overflow/scrollRevealButton-expected.checksum:
        * fast/overflow/scrollRevealButton-expected.png:
        * fast/overflow/scrollRevealButton-expected.txt:

WebCore:

        Reviewed by Darin.

        - fixed <rdar://problem/4820817> Autoscroll is broken in Mail.app (message jumps around when trying to select text)

        Handle scrolling external scrollviews around the webview during
        autoscroll or when scrolling into view.

        This should also restore performance on BenchJS test 6 lost due to Tim's partial fix.

        * page/FrameView.cpp:
        (WebCore::FrameView::scrollRectIntoViewRecursively):
        * page/FrameView.h:
        * platform/ScrollView.h:
        * platform/gdk/ScrollViewGdk.cpp:
        (WebCore::ScrollView::visibleContentRectConsideringExternalScrollers):
        (WebCore::ScrollView::scrollRectIntoViewRecursively):
        * platform/mac/ScrollViewMac.mm:
        (WebCore::ScrollView::visibleContentRect):
        (WebCore::ScrollView::visibleContentRectConsideringExternalScrollers):
        (WebCore::ScrollView::scrollRectIntoViewRecursively):
        (WebCore::ScrollView::updateContents):
        * platform/qt/ScrollViewQt.cpp:
        (WebCore::ScrollView::visibleContentRectConsideringExternalScrollers):
        (WebCore::ScrollView::scrollRectIntoViewRecursively):
        * platform/win/ScrollViewWin.cpp:
        (WebCore::ScrollView::visibleContentRectConsideringExternalScrollers):
        * platform/win/TemporaryLinkStubs.cpp:
        (WebCore::ScrollView::scrollRectIntoViewRecursively):
        * rendering/RenderLayer.cpp:
        (WebCore::RenderLayer::scrollRectToVisible):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@20565 268f45cc-cd09-0410-ab3c-d52691b4dbfc

14 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/overflow/scrollRevealButton-expected.checksum
LayoutTests/fast/overflow/scrollRevealButton-expected.png
LayoutTests/fast/overflow/scrollRevealButton-expected.txt
WebCore/ChangeLog
WebCore/page/FrameView.cpp
WebCore/page/FrameView.h
WebCore/platform/ScrollView.h
WebCore/platform/gdk/ScrollViewGdk.cpp
WebCore/platform/mac/ScrollViewMac.mm
WebCore/platform/qt/ScrollViewQt.cpp
WebCore/platform/win/ScrollViewWin.cpp
WebCore/platform/win/TemporaryLinkStubs.cpp
WebCore/rendering/RenderLayer.cpp

index b97da65527ec6225137230b8f77b30465314a4c0..221c07217c6fce2d2579db6378139f68c2f4a28f 100644 (file)
@@ -1,3 +1,13 @@
+2007-03-28  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Darin.
+        
+        - <rdar://problem/4820817> Autoscroll is broken in Mail.app (message jumps around when trying to select text)
+
+        * fast/overflow/scrollRevealButton-expected.checksum:
+        * fast/overflow/scrollRevealButton-expected.png:
+        * fast/overflow/scrollRevealButton-expected.txt:
+
 2007-03-28  Alexey Proskuryakov  <ap@webkit.org>
 
         Reviewed by Darin.
index 7fa23ec5decbffc0f163a8ba73f89ff6bb38e2ab..a60c3f3d6c56f77ecb19c6c2cb1f8003b319f7cf 100644 (file)
@@ -1 +1 @@
-1a3eb440919a835d1c2d8b87e3e75d51
\ No newline at end of file
+09a85baee72e3618e0e122168b061246
\ No newline at end of file
index e9fd43cf6934f431dab3d597ddd8c88b334c50e4..73e4076ad56f8f6db89c6a8948c23c096e3004e6 100644 (file)
Binary files a/LayoutTests/fast/overflow/scrollRevealButton-expected.png and b/LayoutTests/fast/overflow/scrollRevealButton-expected.png differ
index 3e8ea0c9cbd4460007409d6f692584551513a6cf..cd1819d7fbb2e5229c5cf15db74b27e59cc433ed 100644 (file)
@@ -39,4 +39,5 @@ layer at (0,0) size 785x1188
               RenderBlock {DIV} at (0,558) size 135x300
         RenderText {#text} at (0,0) size 0x0
       RenderBlock {DIV} at (0,672) size 769x500
-frame 'fr' scrolled to 0,122
+scrolled to 0,4
+frame 'fr' scrolled to 0,91
index ac30131e7bf299a98ee16e62f4d13963541562c5..9917510c5b422c5b43546f35dd0a2857547dfd29 100644 (file)
@@ -1,3 +1,36 @@
+2007-03-28  Maciej Stachowiak  <mjs@apple.com>
+        
+        Reviewed by Darin.
+        
+        - fixed <rdar://problem/4820817> Autoscroll is broken in Mail.app (message jumps around when trying to select text)
+                
+        Handle scrolling external scrollviews around the webview during
+        autoscroll or when scrolling into view.
+        
+        This should also restore performance on BenchJS test 6 lost due to Tim's partial fix.
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::scrollRectIntoViewRecursively):
+        * page/FrameView.h:
+        * platform/ScrollView.h:
+        * platform/gdk/ScrollViewGdk.cpp:
+        (WebCore::ScrollView::visibleContentRectConsideringExternalScrollers):
+        (WebCore::ScrollView::scrollRectIntoViewRecursively):
+        * platform/mac/ScrollViewMac.mm:
+        (WebCore::ScrollView::visibleContentRect):
+        (WebCore::ScrollView::visibleContentRectConsideringExternalScrollers):
+        (WebCore::ScrollView::scrollRectIntoViewRecursively):
+        (WebCore::ScrollView::updateContents):
+        * platform/qt/ScrollViewQt.cpp:
+        (WebCore::ScrollView::visibleContentRectConsideringExternalScrollers):
+        (WebCore::ScrollView::scrollRectIntoViewRecursively):
+        * platform/win/ScrollViewWin.cpp:
+        (WebCore::ScrollView::visibleContentRectConsideringExternalScrollers):
+        * platform/win/TemporaryLinkStubs.cpp:
+        (WebCore::ScrollView::scrollRectIntoViewRecursively):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::scrollRectToVisible):
+       
 2007-03-28  Jungshik Shin  <jungshik.shin@gmail.com>
 
         Reviewed  and landed by Darin
index 00b504e87d9e607b6809d2edac855bc718c8ce7c..fff72af8f8b7bbfcc8a7b8c49fd0c7ebf0803d67 100644 (file)
@@ -603,11 +603,11 @@ void FrameView::restoreScrollbar()
     suppressScrollbars(false);
 }
 
-void FrameView::scrollPointRecursively(int x, int y)
+void FrameView::scrollRectIntoViewRecursively(const IntRect& r)
 {
     if (frame()->prohibitsScrolling())
         return;
-    ScrollView::scrollPointRecursively(x, y);
+    ScrollView::scrollRectIntoViewRecursively(r);
 }
 
 void FrameView::setContentsPos(int x, int y)
index 05c7b63746f83d7d2ab3c524d213cc970884a4d6..1f858a980bfffe096781085cf30d8d52194b64ed 100644 (file)
@@ -110,7 +110,7 @@ public:
     IntRect windowClipRect(bool clipToContents) const;
     IntRect windowClipRectForLayer(const RenderLayer*, bool clipToLayerContents) const;
 
-    virtual void scrollPointRecursively(int x, int y);
+    virtual void scrollRectIntoViewRecursively(const IntRect& r);
     virtual void setContentsPos(int x, int y);
 
     String mediaType() const;
index 06ba7ffb690c58505e3f622b228bbec02c8ff07e..40956dcfd636e3a86d35313f379ad6519f99177b 100644 (file)
@@ -50,6 +50,7 @@ namespace WebCore {
         int visibleWidth() const;
         int visibleHeight() const;
         FloatRect visibleContentRect() const;
+        FloatRect visibleContentRectConsideringExternalScrollers() const;
 
         int contentsWidth() const;
         int contentsHeight() const;
@@ -57,7 +58,7 @@ namespace WebCore {
         int contentsY() const;
         IntSize scrollOffset() const;
         void scrollBy(int dx, int dy);
-        virtual void scrollPointRecursively(int dx, int dy);
+        virtual void scrollRectIntoViewRecursively(const IntRect&);
 
         virtual void setContentsPos(int x, int y);
 
index 7e65c6859e8316a1b47d1ed407a8f2688f966cd5..f5d20440338f5bfc74c56c7a196328c371f6b038 100644 (file)
@@ -116,6 +116,12 @@ FloatRect ScrollView::visibleContentRect() const
     return contentRect;
 }
 
+FloatRect ScrollView::visibleContentRectConsideringExternalScrollers() const
+{
+    // external scrollers not supported for now
+    return visibleContentRect();
+}
+
 void ScrollView::setContentsPos(int newX, int newY)
 {
     int dx = newX - contentsX();
@@ -274,7 +280,7 @@ void ScrollView::removeChild(Widget*)
     notImplementedGdk();
 }
 
-void ScrollView::scrollPointRecursively(int x, int y)
+void ScrollView::scrollRectIntoViewRecursively(const IntRect&)
 {
     notImplementedGdk();
 }
@@ -308,7 +314,7 @@ IntPoint ScrollView::windowToContents(const IntPoint& point) const
 }
 
 IntPoint ScrollView::contentsToWindow(const IntPoint& point) const
-{
+`{
     notImplementedGdk();
     return point;
 }
index 0d07e1ccc768f89b1442dea98d994e79d798d510..42f16f33766f1e497e146c3eeecd093de16b0d4b 100644 (file)
@@ -78,14 +78,30 @@ int ScrollView::visibleHeight() const
 }
 
 FloatRect ScrollView::visibleContentRect() const
+{
+    NSScrollView *view = (NSScrollView *)getView(); 
+      
+    BEGIN_BLOCK_OBJC_EXCEPTIONS; 
+    if ([view isKindOfClass:[NSScrollView class]]) 
+        return [view documentVisibleRect]; 
+    else 
+        return [view visibleRect]; 
+    END_BLOCK_OBJC_EXCEPTIONS; 
+
+    return FloatRect();
+}
+
+FloatRect ScrollView::visibleContentRectConsideringExternalScrollers() const
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
     if (NSView *docView = getDocumentView())
         return [docView visibleRect];
     END_BLOCK_OBJC_EXCEPTIONS;
+
     return FloatRect();
 }
 
+
 int ScrollView::contentsWidth() const
 {
     NSView *docView, *view = getView();
@@ -160,11 +176,9 @@ void ScrollView::scrollBy(int dx, int dy)
     setContentsPos(contentsX() + dx, contentsY() + dy);
 }
 
-void ScrollView::scrollPointRecursively(int x, int y)
+void ScrollView::scrollRectIntoViewRecursively(const IntRect& r)
 { 
-    x = (x < 0) ? 0 : x;
-    y = (y < 0) ? 0 : y;
-    NSPoint p = NSMakePoint(x,y);
+    NSRect rect = r;
 
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
     NSView *docView;
@@ -178,8 +192,7 @@ void ScrollView::scrollPointRecursively(int x, int y)
         if ([view isKindOfClass:[NSClipView class]]) {
             NSClipView *clipView = (NSClipView *)view;
             NSView *documentView = [clipView documentView];
-            NSPoint viewPoint = [clipView constrainScrollPoint:[documentView convertPoint:p fromView:originalView]];
-            [documentView scrollPoint:viewPoint];
+            [documentView scrollRectToVisible:[documentView convertRect:rect fromView:originalView]];
         }
 
         view = [view superview];
@@ -338,10 +351,12 @@ void ScrollView::updateContents(const IntRect &rect, bool now)
     if ([view isKindOfClass:[NSScrollView class]])
         view = getDocumentView();
 
+    NSRect visibleRect = visibleContentRect();
+
     // Checking for rect visibility is an important optimization for the case of
     // Select All of a large document. AppKit does not do this check, and so ends
     // up building a large complicated NSRegion if we don't perform the check.
-    NSRect dirtyRect = NSIntersectionRect(rect, [view visibleRect]);
+    NSRect dirtyRect = NSIntersectionRect(rect, visibleRect);
     if (!NSIsEmptyRect(dirtyRect)) {
         [view setNeedsDisplayInRect:dirtyRect];
         if (now) {
index 35c08a7afff142d7be74ceae137303c27dec9705..fd14869f5629b290a8fb49b8025c0f0feb93b84a 100644 (file)
@@ -106,6 +106,12 @@ FloatRect ScrollView::visibleContentRect() const
                      visibleHeight());
 }
 
+FloatRect ScrollView::visibleContentRectConsideringExternalScrollers() const
+{
+    // external scrollers not supported for now
+    return visibleContentRect();
+}
+
 void ScrollView::setContentsPos(int newX, int newY)
 {
     if (!m_area)
@@ -290,8 +296,11 @@ void ScrollView::removeChild(Widget* child)
     child->hide();
 }
 
-void ScrollView::scrollPointRecursively(int x, int y)
+void ScrollView::scrollRectIntoViewRecursively(const IntRect& r)
 {
+    int x = r.x();
+    int y = r.y();
+
     x = (x < 0) ? 0 : x;
     y = (y < 0) ? 0 : y;
 
index 17445d64f4624fb8855846bb5e42fc5c563130ff..8c564141bb6100743fde87ff13e1e118b7060e6b 100644 (file)
@@ -103,6 +103,12 @@ FloatRect ScrollView::visibleContentRect() const
     return contentRect;
 }
 
+FloatRect ScrollView::visibleContentRectConsideringExternalScrollers() const
+{
+    // external scrollers not supported for now
+    return visibleContentRect();
+}
+
 void ScrollView::setContentsPos(int newX, int newY)
 {
     int dx = newX - contentsX();
index 93225a15a182603c9df2b57ab33e35c20d6ba901..8a11214132bc48ab0549b87ad53a2c1e82c97b74 100644 (file)
@@ -346,7 +346,7 @@ bool ResourceHandle::loadsBlocked() { notImplemented(); return false; }
 
 void ScrollView::addChild(Widget*) { notImplemented(); }
 void ScrollView::removeChild(Widget*) { notImplemented(); }
-void ScrollView::scrollPointRecursively(int x, int y) { notImplemented(); }
+void ScrollView::scrollRectIntoViewRecursively(const IntRect&) { notImplemented(); }
 bool ScrollView::inWindow() const { notImplemented(); return true; }
 void ScrollView::paint(GraphicsContext*, const IntRect&) { notImplemented(); }
 void ScrollView::wheelEvent(PlatformWheelEvent&) { notImplemented(); }
index 505e148f0180c42bbd5eff16c30e354a796740f6..77c54f3973a542799caf5ace5aa5a3125ad803ca 100644 (file)
@@ -759,24 +759,27 @@ void RenderLayer::scrollRectToVisible(const IntRect &rect, const ScrollAlignment
             parentLayer = m_object->parent()->enclosingLayer();
     } else {
         if (frameView) {
-            IntRect viewRect = enclosingIntRect(frameView->visibleContentRect());
-            IntRect r = getRectToExpose(viewRect, rect, alignX, alignY);
-            
-            xOffset = r.x();
-            yOffset = r.y();
-            // Adjust offsets if they're outside of the allowable range.
-            xOffset = max(0, min(frameView->contentsWidth(), xOffset));
-            yOffset = max(0, min(frameView->contentsHeight(), yOffset));
-
             if (m_object->document() && m_object->document()->ownerElement() && m_object->document()->ownerElement()->renderer()) {
+                IntRect viewRect = enclosingIntRect(frameView->visibleContentRect());
+                IntRect r = getRectToExpose(viewRect, rect, alignX, alignY);
+                
+                xOffset = r.x();
+                yOffset = r.y();
+                // Adjust offsets if they're outside of the allowable range.
+                xOffset = max(0, min(frameView->contentsWidth(), xOffset));
+                yOffset = max(0, min(frameView->contentsHeight(), yOffset));
+
                 frameView->setContentsPos(xOffset, yOffset);
                 parentLayer = m_object->document()->ownerElement()->renderer()->enclosingLayer();
                 newRect.setX(rect.x() - frameView->contentsX() + frameView->x());
                 newRect.setY(rect.y() - frameView->contentsY() + frameView->y());
             } else {
+                IntRect viewRect = enclosingIntRect(frameView->visibleContentRectConsideringExternalScrollers());
+                IntRect r = getRectToExpose(viewRect, rect, alignX, alignY);
+                
                 // If this is the outermost view that RenderLayer needs to scroll, then we should scroll the view recursively
                 // Other apps, like Mail, rely on this feature.
-                frameView->scrollPointRecursively(xOffset, yOffset);
+                frameView->scrollRectIntoViewRecursively(r);
             }
         }
     }