WebCore:
authorhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Apr 2009 23:09:14 +0000 (23:09 +0000)
committerhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Apr 2009 23:09:14 +0000 (23:09 +0000)
2009-04-07  David Hyatt  <hyatt@apple.com>

        Reviewed by Adam Roben

        Fix ScrollView's algorithm that determines whether or not to show scrollbars.  There was a bug
        with the method mainly because RenderView will size itself to the viewport's size, making it
        impossible to really know the document's "true" size.

        In order to solve this problem ScrollView now has a minimumContentsSize method.  This method
        returns the document size excluding the RenderView from the calculation.  This width/height
        is now cached on RenderView in m_docWidth/m_docHeight member variables.

        * WebCore.base.exp:
        * page/FrameView.cpp:
        (WebCore::FrameView::adjustPageHeight):
        (WebCore::FrameView::minimumContentsSize):
        * page/FrameView.h:
        * platform/ScrollView.cpp:
        (WebCore::ScrollView::updateScrollbars):
        * platform/ScrollView.h:
        (WebCore::ScrollView::minimumContentsSize):
        * rendering/RenderView.cpp:
        (WebCore::RenderView::layout):
        (WebCore::RenderView::calcDocHeight):
        (WebCore::RenderView::calcDocWidth):
        * rendering/RenderView.h:
        (WebCore::RenderView::docWidth):
        (WebCore::RenderView::docHeight):

WebKit/mac:

2009-04-07  David Hyatt  <hyatt@apple.com>

        Reviewed by Adam Roben

        Mac portion of fix to make DumpRenderTree always produce accurate scrollbar results.  Change
        updateScrollers to call minimumContentsSize when a WebHTMLView is inside the WebDynamicScrollbarsView.

        * WebView/WebDynamicScrollBarsView.m:
        (-[WebDynamicScrollBarsView updateScrollers]):

LayoutTests:

2009-04-07  David Hyatt  <hyatt@apple.com>

        Reviewed by Adam Roben

        Land updated layout test results now that DRT is doing the right thing
        with scrollbar results.

        * platform/mac/css2.1/t0803-c5502-mrgn-r-02-c-expected.checksum:
        * platform/mac/css2.1/t0803-c5502-mrgn-r-02-c-expected.png:
        * platform/mac/css2.1/t0803-c5502-mrgn-r-02-c-expected.txt:
        * platform/mac/css2.1/t0803-c5505-mrgn-02-c-expected.checksum:
        * platform/mac/css2.1/t0803-c5505-mrgn-02-c-expected.png:
        * platform/mac/css2.1/t0803-c5505-mrgn-02-c-expected.txt:
        * platform/mac/fast/block/float/013-expected.checksum:
        * platform/mac/fast/block/float/013-expected.png:
        * platform/mac/fast/block/float/013-expected.txt:

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

20 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac/css2.1/t0803-c5502-mrgn-r-02-c-expected.checksum
LayoutTests/platform/mac/css2.1/t0803-c5502-mrgn-r-02-c-expected.png
LayoutTests/platform/mac/css2.1/t0803-c5502-mrgn-r-02-c-expected.txt
LayoutTests/platform/mac/css2.1/t0803-c5505-mrgn-02-c-expected.checksum
LayoutTests/platform/mac/css2.1/t0803-c5505-mrgn-02-c-expected.png
LayoutTests/platform/mac/css2.1/t0803-c5505-mrgn-02-c-expected.txt
LayoutTests/platform/mac/fast/block/float/013-expected.checksum
LayoutTests/platform/mac/fast/block/float/013-expected.png
LayoutTests/platform/mac/fast/block/float/013-expected.txt
WebCore/ChangeLog
WebCore/WebCore.base.exp
WebCore/page/FrameView.cpp
WebCore/page/FrameView.h
WebCore/platform/ScrollView.cpp
WebCore/platform/ScrollView.h
WebCore/rendering/RenderView.cpp
WebCore/rendering/RenderView.h
WebKit/mac/ChangeLog
WebKit/mac/WebView/WebDynamicScrollBarsView.m

index 1c01f0cf543105e673ea606cdb942adf8f344836..c8bb74aa7c4eff830b76719d7a040ba1ceca647b 100644 (file)
@@ -1,3 +1,20 @@
+2009-04-07  David Hyatt  <hyatt@apple.com>
+
+        Reviewed by Adam Roben
+
+        Land updated layout test results now that DRT is doing the right thing
+        with scrollbar results.
+
+        * platform/mac/css2.1/t0803-c5502-mrgn-r-02-c-expected.checksum:
+        * platform/mac/css2.1/t0803-c5502-mrgn-r-02-c-expected.png:
+        * platform/mac/css2.1/t0803-c5502-mrgn-r-02-c-expected.txt:
+        * platform/mac/css2.1/t0803-c5505-mrgn-02-c-expected.checksum:
+        * platform/mac/css2.1/t0803-c5505-mrgn-02-c-expected.png:
+        * platform/mac/css2.1/t0803-c5505-mrgn-02-c-expected.txt:
+        * platform/mac/fast/block/float/013-expected.checksum:
+        * platform/mac/fast/block/float/013-expected.png:
+        * platform/mac/fast/block/float/013-expected.txt:
+
 2009-04-07  Brian Weinstein  <bweinstein@gmail.com>
 
         Reviewed by Darin Adler.
index 333f3fbc76f01faf03eaf3d72af8105d1ea101b0..06e68617edd00fcf29f0035d582a3b5bb5c86e37 100644 (file)
@@ -1 +1 @@
-63eaff280f1a5667c3feaa9b980c9eb3
\ No newline at end of file
+d1e6e39e61dd10446c07f309f4c6fbfb
\ No newline at end of file
index afaa663cf6cdddf49394327281c87b84b42f72c2..4e151998672a20b98a3e24af1a6a1cbeb40b3e71 100644 (file)
Binary files a/LayoutTests/platform/mac/css2.1/t0803-c5502-mrgn-r-02-c-expected.png and b/LayoutTests/platform/mac/css2.1/t0803-c5502-mrgn-r-02-c-expected.png differ
index 409dbf60dcea207cd869ac9fa4d8deb8f9ba0a64..28f87e1b4ebce26dd3e89e7d305d7112a87a1c32 100644 (file)
@@ -1,5 +1,5 @@
-layer at (0,0) size 802x600
-  RenderView at (0,0) size 800x600
+layer at (0,0) size 802x585
+  RenderView at (0,0) size 800x585
 layer at (0,0) size 802x66
   RenderBlock {HTML} at (0,0) size 800x66
     RenderBody {BODY} at (8,24) size 784x18
index 594675f119d2c8e99265fc8e59d87414eb34101c..394db12886b1f9b2e4ece067bcaa42b737f2b0e0 100644 (file)
@@ -1 +1 @@
-43a4729c4ea26a2b126fa2af993d346f
\ No newline at end of file
+553336b9dd74f1d2a8124226a77664b7
\ No newline at end of file
index c45f229f0983cbe358040dd4d6a802cbd7099013..8f358d34cfd7ae25b895635014337294b8ce658c 100644 (file)
Binary files a/LayoutTests/platform/mac/css2.1/t0803-c5505-mrgn-02-c-expected.png and b/LayoutTests/platform/mac/css2.1/t0803-c5505-mrgn-02-c-expected.png differ
index 2d2e9f855f47990bc00081351b29db041681b695..9c2685e38ee9256dc02c2582837ef8f439b6a915 100644 (file)
@@ -1,5 +1,5 @@
-layer at (0,0) size 802x600
-  RenderView at (0,0) size 800x600
+layer at (0,0) size 802x585
+  RenderView at (0,0) size 800x585
 layer at (0,0) size 802x34
   RenderBlock {HTML} at (0,0) size 800x32
     RenderBody {BODY} at (8,-2) size 784x36
index 0a6024018a4054440a025684bfdeb37acfb9bd2c..a6c80b42165a3a75eb1e4a9a110cb6845e0c8d8c 100644 (file)
@@ -1 +1 @@
-03d4b406d734a806ba0d6e57d9e2b508
\ No newline at end of file
+ecdad59c884a27f63ce9e076e5cc1396
\ No newline at end of file
index d6916f15cbda1bb2e8b798613bf75e48e46f7e57..3623e6560c87c96494e5c2ee8f0186554ecc6773 100644 (file)
Binary files a/LayoutTests/platform/mac/fast/block/float/013-expected.png and b/LayoutTests/platform/mac/fast/block/float/013-expected.png differ
index 563e5f203fe95304ff04d9c394b5fd3aaa18f579..0c98889373402fef112f8c373dddffcc317cba01 100644 (file)
@@ -1,5 +1,5 @@
-layer at (0,0) size 808x600
-  RenderView at (0,0) size 800x600
+layer at (0,0) size 808x585
+  RenderView at (0,0) size 800x585
 layer at (0,0) size 800x8
   RenderBlock {HTML} at (0,0) size 800x8
     RenderBody {BODY} at (8,8) size 784x0
index 34bcdd696f82996ddb3e98003afd5c077dfabcdb..505332fb73fccd59164adcd331209b630ad6f1e4 100644 (file)
@@ -1,3 +1,32 @@
+2009-04-07  David Hyatt  <hyatt@apple.com>
+
+        Reviewed by Adam Roben
+
+        Fix ScrollView's algorithm that determines whether or not to show scrollbars.  There was a bug
+        with the method mainly because RenderView will size itself to the viewport's size, making it
+        impossible to really know the document's "true" size.
+
+        In order to solve this problem ScrollView now has a minimumContentsSize method.  This method
+        returns the document size excluding the RenderView from the calculation.  This width/height
+        is now cached on RenderView in m_docWidth/m_docHeight member variables.
+
+        * WebCore.base.exp:
+        * page/FrameView.cpp:
+        (WebCore::FrameView::adjustPageHeight):
+        (WebCore::FrameView::minimumContentsSize):
+        * page/FrameView.h:
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::updateScrollbars):
+        * platform/ScrollView.h:
+        (WebCore::ScrollView::minimumContentsSize):
+        * rendering/RenderView.cpp:
+        (WebCore::RenderView::layout):
+        (WebCore::RenderView::calcDocHeight):
+        (WebCore::RenderView::calcDocWidth):
+        * rendering/RenderView.h:
+        (WebCore::RenderView::docWidth):
+        (WebCore::RenderView::docHeight):
+
 2009-04-07  Dimitri Glazkov  <dglazkov@chromium.org>
 
         Build fix, not reviewed.
index 818335c8c545feef2fb3d6f4b2053c2fa2e4f300..2a305fdc63164063b393e392279c5d680f4b9604 100644 (file)
@@ -572,6 +572,7 @@ __ZN7WebCore7CStringC1EPKc
 __ZN7WebCore7Console21shouldPrintExceptionsEv
 __ZN7WebCore7Console24setShouldPrintExceptionsEb
 __ZN7WebCore7IntSizeC1ERK7_NSSize
+__ZNK7WebCore7IntSizecv7_NSSizeEv
 __ZN7WebCore7cookiesEPKNS_8DocumentERKNS_4KURLE
 __ZN7WebCore7nsColorERKNS_5ColorE
 __ZN7WebCore8Document11createRangeEv
index 8dc951d6a7266037d2439cd1a7b67df7ed4f6d2c..fe11532cf95cbd2ea15a0585e13d26b05bb6faa3 100644 (file)
@@ -1448,4 +1448,12 @@ void FrameView::adjustPageHeight(float *newBottom, float oldTop, float oldBottom
         *newBottom = oldBottom;
 }
 
+IntSize FrameView::minimumContentsSize() const
+{
+    RenderView* root = m_frame->contentRenderer();
+    if (!root)
+        return ScrollView::minimumContentsSize();
+    return IntSize(root->docWidth(), root->docHeight());
+}
+
 } // namespace WebCore
index 07295d337c937f38a2cacbaa8416491b9dae1b67..d9896d0bfeecd91148995161ebb04372fbf66dbe 100644 (file)
@@ -73,6 +73,8 @@ public:
     void setMarginWidth(int);
     void setMarginHeight(int);
 
+    virtual IntSize minimumContentsSize() const;
+
     virtual void setCanHaveScrollbars(bool);
 
     virtual PassRefPtr<Scrollbar> createScrollbar(ScrollbarOrientation);
index 22c5512080513a9439765b1d1c85c3e5b7760cf8..f24b5e99ddccf9c8286386bb07e1194c2507e273 100644 (file)
@@ -339,13 +339,15 @@ void ScrollView::updateScrollbars(const IntSize& desiredOffset)
             if (hasVerticalScrollbar != oldHasVertical || hasHorizontalScrollbar != oldHasHorizontal)
                 visibleContentsResized();
 
-            scrollsVertically = (vScroll == ScrollbarAlwaysOn) || (vScroll == ScrollbarAuto && contentsHeight() > height());
+            IntSize docSize = minimumContentsSize();
+
+            scrollsVertically = (vScroll == ScrollbarAlwaysOn) || (vScroll == ScrollbarAuto && docSize.height() > height());
             if (scrollsVertically)
-                scrollsHorizontally = (hScroll == ScrollbarAlwaysOn) || (hScroll == ScrollbarAuto && contentsWidth() + scrollbarThickness > width());
+                scrollsHorizontally = (hScroll == ScrollbarAlwaysOn) || (hScroll == ScrollbarAuto && docSize.width() + scrollbarThickness > width());
             else {
-                scrollsHorizontally = (hScroll == ScrollbarAlwaysOn) || (hScroll == ScrollbarAuto && contentsWidth() > width());
+                scrollsHorizontally = (hScroll == ScrollbarAlwaysOn) || (hScroll == ScrollbarAuto && docSize.width() > width());
                 if (scrollsHorizontally)
-                    scrollsVertically = (vScroll == ScrollbarAlwaysOn) || (vScroll == ScrollbarAuto && contentsHeight() + scrollbarThickness > height());
+                    scrollsVertically = (vScroll == ScrollbarAlwaysOn) || (vScroll == ScrollbarAuto && docSize.height() + scrollbarThickness > height());
             }
         } else {
             scrollsHorizontally = (hScroll == ScrollbarAuto) ? hasHorizontalScrollbar : (hScroll == ScrollbarAlwaysOn);
index f588508e8105421b5a78a733751284883903b8b0..9e4d3b17d0e91076b620ac2a2ea2e8e82277228d 100644 (file)
@@ -125,7 +125,8 @@ public:
     
     // Methods for getting/setting the size of the document contained inside the ScrollView (as an IntSize or as individual width and height
     // values).
-    IntSize contentsSize() const;
+    IntSize contentsSize() const; // Always at least as big as the visibleWidth()/visibleHeight().
+    virtual IntSize minimumContentsSize() const { return contentsSize(); } // Allows a subclass to indicate a smaller size than the viewport (used for scrollbar checking).
     int contentsWidth() const { return contentsSize().width(); }
     int contentsHeight() const { return contentsSize().height(); }
     virtual void setContentsSize(const IntSize&);
index e2bfa840dfb3e919e04a4b9e5da600a1910801b5..d11e74491edfaf918621fa6854d32056bf4e24c5 100644 (file)
@@ -121,12 +121,11 @@ void RenderView::layout()
     if (needsLayout())
         RenderBlock::layout();
 
-    // Ensure that docWidth() >= width() and docHeight() >= height().
-    setOverflowWidth(width());
-    setOverflowHeight(height());
+    m_docWidth = calcDocWidth();
+    m_docHeight = calcDocHeight();
 
-    setOverflowWidth(docWidth());
-    setOverflowHeight(docHeight());
+    setOverflowWidth(max(width(), m_docWidth));
+    setOverflowHeight(max(height(), m_docHeight));
 
     ASSERT(layoutDelta() == IntSize());
     ASSERT(m_layoutStateDisableCount == 0);
@@ -550,12 +549,12 @@ IntRect RenderView::viewRect() const
     return IntRect();
 }
 
-int RenderView::docHeight() const
+int RenderView::calcDocHeight() const
 {
-    int h = height();
-    int lowestPos = lowestPosition();
-    if (lowestPos > h)
-        h = lowestPos;
+    // Exclude our own height, since it always matches the viewport height.  We want to know the height
+    // of the document if it is potentially smaller than the viewport (this value will be used when trying
+    // to figure out if scrollbars are needed).
+    int h = max(0, lowestPosition(true, false));
 
     // FIXME: This doesn't do any margin collapsing.
     // Instead of this dh computation we should keep the result
@@ -570,13 +569,13 @@ int RenderView::docHeight() const
     return h;
 }
 
-int RenderView::docWidth() const
+int RenderView::calcDocWidth() const
 {
-    int w = width();
-    int rightmostPos = rightmostPosition();
-    if (rightmostPos > w)
-        w = rightmostPos;
-    
+    // Exclude our own width, since it always matches the viewport width.  We want to know the width
+    // of the document if it is potentially smaller than the viewport (this value will be used when trying
+    // to figure out if scrollbars are needed).
+    int w = max(0, rightmostPosition(true, false));
+
     for (RenderBox* c = firstChildBox(); c; c = c->nextSiblingBox()) {
         int dw = c->width() + c->marginLeft() + c->marginRight();
         if (dw > w)
index 1c6925c8215126331cd7ad99e3bfd9a67dcda0cc..65913575feeb8beff8e1dd8fee2e7b31d663b7b3 100644 (file)
@@ -50,14 +50,14 @@ public:
     virtual void calcWidth();
     virtual void calcHeight();
     virtual void calcPrefWidths();
-    
-    int docHeight() const;
-    int docWidth() const;
 
     // The same as the FrameView's layoutHeight/layoutWidth but with null check guards.
     int viewHeight() const;
     int viewWidth() const;
     
+    int docWidth() const { return m_docWidth; }
+    int docHeight() const { return m_docHeight; }
+
     float zoomFactor() const;
 
     FrameView* frameView() const { return m_frameView; }
@@ -171,6 +171,9 @@ protected:
 
 private:
     bool shouldRepaint(const IntRect& r) const;
+        
+    int calcDocHeight() const;
+    int calcDocWidth() const;
 
 protected:
     FrameView* m_frameView;
@@ -192,6 +195,9 @@ protected:
     RenderWidgetSet m_widgets;
 
 private:
+    int m_docWidth;
+    int m_docHeight;
+
     int m_bestTruncatedAt;
     int m_truncatorWidth;
     bool m_forcedPageBreak;
index 5428047554b51f462e9d01935d125e4f6eb1331e..e950536dedfc77bdb0103a31d8eff46ce7526e68 100644 (file)
@@ -1,3 +1,13 @@
+2009-04-07  David Hyatt  <hyatt@apple.com>
+
+        Reviewed by Adam Roben
+
+        Mac portion of fix to make DumpRenderTree always produce accurate scrollbar results.  Change
+        updateScrollers to call minimumContentsSize when a WebHTMLView is inside the WebDynamicScrollbarsView.
+
+        * WebView/WebDynamicScrollBarsView.m:
+        (-[WebDynamicScrollBarsView updateScrollers]):
+
 2009-04-07  Gustavo Noronha Silva  <gustavo.noronha@collabora.co.uk>
 
         Reviewed by Anders Carlsson.
index de19ef6e74d22df43acf1eb4a7b6ffdc851876bc..a988d846b2b69be0dd007bb728a0b6db0606c9fd 100644 (file)
 #import "WebDynamicScrollBarsViewInternal.h"
 
 #import "WebDocument.h"
+#import "WebFrameInternal.h"
 #import "WebFrameView.h"
+#import "WebHTMLViewInternal.h"
+#import <WebCore/Frame.h>
+#import <WebCore/FrameView.h>
 #import <WebKitSystemInterface.h>
 
 using namespace WebCore;
@@ -118,6 +122,14 @@ const int WebCoreScrollbarAlwaysOn = ScrollbarAlwaysOn;
                 }
 
                 NSSize documentSize = [documentView frame].size;
+                if ([documentView isKindOfClass:[WebHTMLView class]]) {
+                    WebHTMLView *htmlView = (WebHTMLView*)documentView;
+                    if (Frame* coreFrame = core([htmlView _frame])) {
+                        if (FrameView* coreView = coreFrame->view())
+                            documentSize = coreView->minimumContentsSize();
+                    }
+                }
+
                 NSSize frameSize = [self frame].size;
 
                 scrollsVertically = (vScroll == ScrollbarAlwaysOn) ||