Title: [147471] trunk
Revision
147471
Author
[email protected]
Date
2013-04-02 11:25:41 -0700 (Tue, 02 Apr 2013)

Log Message

Viewport constrained elements should work properly with headers and footers
https://bugs.webkit.org/show_bug.cgi?id=113743

Reviewed by Simon Fraser.

Source/WebCore: 

ScrollableArea::constrainScrollPositionForOverhang() needs to take headerHeight 
and footerHeight into account. It also needs to use totalContentsSize() instead of 
contentsSize().

Send totalContentsSize() instead of contentsSize() and also send headerHeight() 
and footerHeight().
* page/FrameView.cpp:
(WebCore::FrameView::scrollOffsetForFixedPosition):
* page/FrameView.h:
(FrameView):

The scrolling tree will also need to know about header and footer heights since it 
will need these values to call 
ScrollableArea::constrainScrollPositionForOverhang().
* page/scrolling/ScrollingStateScrollingNode.cpp:
(WebCore::ScrollingStateScrollingNode::ScrollingStateScrollingNode):
(WebCore::ScrollingStateScrollingNode::setHeaderHeight):
(WebCore::ScrollingStateScrollingNode::setFooterHeight):
* page/scrolling/ScrollingStateScrollingNode.h:
(WebCore::ScrollingStateScrollingNode::headerHeight):
(ScrollingStateScrollingNode):
(WebCore::ScrollingStateScrollingNode::footerHeight):
* page/scrolling/ScrollingTreeScrollingNode.cpp:
(WebCore::ScrollingTreeScrollingNode::ScrollingTreeScrollingNode):
(WebCore::ScrollingTreeScrollingNode::updateBeforeChildren):
* page/scrolling/ScrollingTreeScrollingNode.h:
(WebCore::ScrollingTreeScrollingNode::headerHeight):
(WebCore::ScrollingTreeScrollingNode::footerHeight):
(ScrollingTreeScrollingNode):
* page/scrolling/mac/ScrollingCoordinatorMac.h:
(ScrollParameters):
* page/scrolling/mac/ScrollingCoordinatorMac.mm:
(WebCore::ScrollingCoordinatorMac::frameViewLayoutUpdated):
(WebCore::ScrollingCoordinatorMac::setScrollParametersForNode):
* page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm:
(WebCore::ScrollingTreeScrollingNodeMac::setScrollLayerPosition):

Use footerHeight when calculating the maxValue and use headerHeight in determining 
what the minimum value is. 
* platform/ScrollableArea.cpp:
(WebCore::constrainedScrollPosition):
(WebCore::ScrollableArea::constrainScrollPositionForOverhang):
* platform/ScrollableArea.h:
(ScrollableArea):

LayoutTests: 

* platform/mac-wk2/tiled-drawing/fixed/four-bars-with-header-and-footer-expected.txt: Added.
* platform/mac-wk2/tiled-drawing/fixed/four-bars-with-header-and-footer.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (147470 => 147471)


--- trunk/LayoutTests/ChangeLog	2013-04-02 18:23:30 UTC (rev 147470)
+++ trunk/LayoutTests/ChangeLog	2013-04-02 18:25:41 UTC (rev 147471)
@@ -1,3 +1,13 @@
+2013-04-02  Beth Dakin  <[email protected]>
+
+        Viewport constrained elements should work properly with headers and footers
+        https://bugs.webkit.org/show_bug.cgi?id=113743
+
+        Reviewed by Simon Fraser.
+
+        * platform/mac-wk2/tiled-drawing/fixed/four-bars-with-header-and-footer-expected.txt: Added.
+        * platform/mac-wk2/tiled-drawing/fixed/four-bars-with-header-and-footer.html: Added.
+
 2013-04-02  Stephen White  <[email protected]>
 
         [Skia] Enable GPU-accelerated Skia path for FEComposite filter.

Added: trunk/LayoutTests/platform/mac-wk2/tiled-drawing/fixed/four-bars-with-header-and-footer-expected.txt (0 => 147471)


--- trunk/LayoutTests/platform/mac-wk2/tiled-drawing/fixed/four-bars-with-header-and-footer-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-wk2/tiled-drawing/fixed/four-bars-with-header-and-footer-expected.txt	2013-04-02 18:25:41 UTC (rev 147471)
@@ -0,0 +1,28 @@
+(Scrolling node
+  (viewport rect 0 0 785 600)
+  (contents size 785 2421)
+  (requested scroll position 0 200)
+  (children 4
+    (Fixed node
+      (anchor edges: AnchorEdgeLeft AnchorEdgeTop)
+      (viewport rect at last layout: 0.00 100.00 785.00 600.00)
+      (layer position at last layout 0.00 100.00)
+    )
+    (Fixed node
+      (anchor edges: AnchorEdgeLeft AnchorEdgeTop)
+      (viewport rect at last layout: 0.00 100.00 785.00 600.00)
+      (layer position at last layout 10.00 300.00)
+    )
+    (Fixed node
+      (anchor edges: AnchorEdgeRight AnchorEdgeTop)
+      (viewport rect at last layout: 0.00 100.00 785.00 600.00)
+      (layer position at last layout 601.00 300.00)
+    )
+    (Fixed node
+      (anchor edges: AnchorEdgeLeft AnchorEdgeBottom)
+      (viewport rect at last layout: 0.00 100.00 785.00 600.00)
+      (layer position at last layout 0.00 616.00)
+    )
+  )
+)
+This is the top bar. This is the left bar. This is the right bar. This is the bottom bar.

Added: trunk/LayoutTests/platform/mac-wk2/tiled-drawing/fixed/four-bars-with-header-and-footer.html (0 => 147471)


--- trunk/LayoutTests/platform/mac-wk2/tiled-drawing/fixed/four-bars-with-header-and-footer.html	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-wk2/tiled-drawing/fixed/four-bars-with-header-and-footer.html	2013-04-02 18:25:41 UTC (rev 147471)
@@ -0,0 +1,88 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <style type="text/css" media="screen">
+      body {
+        height: 2200px;
+      }
+      
+      .fixed {
+        position: fixed;
+        top: 0;
+        left: 0;
+        margin: 10px;
+        height: 50px;
+        background-color: rgba(0, 128, 0, 0.8);
+        border: 2px solid black;
+        -webkit-box-shadow: 0 0 10px black;
+      }
+      
+      .top, .bottom {
+        width: 96%;
+      }
+
+      .left {
+        top: 200px;
+        left: 10px;
+        width: 150px;
+        height: 300px;
+      }
+
+      .right {
+        top: 200px;
+        left: auto;
+        right: 10px;
+        width: 150px;
+        height: 300px;
+      }
+      
+      .bottom {
+        top: auto;
+        bottom: 10px;
+      }
+      
+    </style>
+    <script>
+      if (window.testRunner) {
+        testRunner.waitUntilDone();
+        testRunner.dumpAsText();
+      }
+        if (window.internals) {
+            window.internals.setHeaderHeight(document, 100);
+            window.internals.setFooterHeight(document, 100);
+        }
+
+      function doScroll()
+      {
+        window.setTimeout(function() {
+          window.scrollTo(0, 200);
+          if (window.testRunner) {
+            document.getElementById('results').innerText = window.internals.scrollingStateTreeAsText(document);
+            testRunner.notifyDone();
+          }
+        }, 10);
+      }
+      
+      window.addEventListener('load', doScroll, false);
+    </script>
+</head>
+<body>
+
+<pre id="results"></pre>
+
+<div class="fixed top">
+  This is the top bar.
+</div>
+<div class="fixed left">
+  This is the left bar.
+</div>
+<div class="fixed right">
+  This is the right bar.
+</div>
+<div class="fixed bottom">
+  This is the bottom bar.
+</div>
+
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (147470 => 147471)


--- trunk/Source/WebCore/ChangeLog	2013-04-02 18:23:30 UTC (rev 147470)
+++ trunk/Source/WebCore/ChangeLog	2013-04-02 18:25:41 UTC (rev 147471)
@@ -1,3 +1,55 @@
+2013-04-02  Beth Dakin  <[email protected]>
+
+        Viewport constrained elements should work properly with headers and footers
+        https://bugs.webkit.org/show_bug.cgi?id=113743
+
+        Reviewed by Simon Fraser.
+
+        ScrollableArea::constrainScrollPositionForOverhang() needs to take headerHeight 
+        and footerHeight into account. It also needs to use totalContentsSize() instead of 
+        contentsSize().
+
+        Send totalContentsSize() instead of contentsSize() and also send headerHeight() 
+        and footerHeight().
+        * page/FrameView.cpp:
+        (WebCore::FrameView::scrollOffsetForFixedPosition):
+        * page/FrameView.h:
+        (FrameView):
+
+        The scrolling tree will also need to know about header and footer heights since it 
+        will need these values to call 
+        ScrollableArea::constrainScrollPositionForOverhang().
+        * page/scrolling/ScrollingStateScrollingNode.cpp:
+        (WebCore::ScrollingStateScrollingNode::ScrollingStateScrollingNode):
+        (WebCore::ScrollingStateScrollingNode::setHeaderHeight):
+        (WebCore::ScrollingStateScrollingNode::setFooterHeight):
+        * page/scrolling/ScrollingStateScrollingNode.h:
+        (WebCore::ScrollingStateScrollingNode::headerHeight):
+        (ScrollingStateScrollingNode):
+        (WebCore::ScrollingStateScrollingNode::footerHeight):
+        * page/scrolling/ScrollingTreeScrollingNode.cpp:
+        (WebCore::ScrollingTreeScrollingNode::ScrollingTreeScrollingNode):
+        (WebCore::ScrollingTreeScrollingNode::updateBeforeChildren):
+        * page/scrolling/ScrollingTreeScrollingNode.h:
+        (WebCore::ScrollingTreeScrollingNode::headerHeight):
+        (WebCore::ScrollingTreeScrollingNode::footerHeight):
+        (ScrollingTreeScrollingNode):
+        * page/scrolling/mac/ScrollingCoordinatorMac.h:
+        (ScrollParameters):
+        * page/scrolling/mac/ScrollingCoordinatorMac.mm:
+        (WebCore::ScrollingCoordinatorMac::frameViewLayoutUpdated):
+        (WebCore::ScrollingCoordinatorMac::setScrollParametersForNode):
+        * page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm:
+        (WebCore::ScrollingTreeScrollingNodeMac::setScrollLayerPosition):
+
+        Use footerHeight when calculating the maxValue and use headerHeight in determining 
+        what the minimum value is. 
+        * platform/ScrollableArea.cpp:
+        (WebCore::constrainedScrollPosition):
+        (WebCore::ScrollableArea::constrainScrollPositionForOverhang):
+        * platform/ScrollableArea.h:
+        (ScrollableArea):
+
 2013-04-02  Stephen White  <[email protected]>
 
         [Skia] Enable GPU-accelerated Skia path for FEComposite filter.

Modified: trunk/Source/WebCore/page/FrameView.cpp (147470 => 147471)


--- trunk/Source/WebCore/page/FrameView.cpp	2013-04-02 18:23:30 UTC (rev 147470)
+++ trunk/Source/WebCore/page/FrameView.cpp	2013-04-02 18:25:41 UTC (rev 147471)
@@ -1604,14 +1604,14 @@
     return viewportRect;
 }
 
-IntSize FrameView::scrollOffsetForFixedPosition(const IntRect& visibleContentRect, const IntSize& contentsSize, const IntPoint& scrollPosition, const IntPoint& scrollOrigin, float frameScaleFactor, bool fixedElementsLayoutRelativeToFrame)
+IntSize FrameView::scrollOffsetForFixedPosition(const IntRect& visibleContentRect, const IntSize& totalContentsSize, const IntPoint& scrollPosition, const IntPoint& scrollOrigin, float frameScaleFactor, bool fixedElementsLayoutRelativeToFrame, int headerHeight, int footerHeight)
 {
-    IntPoint constrainedPosition = ScrollableArea::constrainScrollPositionForOverhang(visibleContentRect, contentsSize, scrollPosition, scrollOrigin);
+    IntPoint constrainedPosition = ScrollableArea::constrainScrollPositionForOverhang(visibleContentRect, totalContentsSize, scrollPosition, scrollOrigin, headerHeight, footerHeight);
 
-    IntSize maxSize = contentsSize - visibleContentRect.size();
+    IntSize maxSize = totalContentsSize - visibleContentRect.size();
 
-    float dragFactorX = (fixedElementsLayoutRelativeToFrame || !maxSize.width()) ? 1 : (contentsSize.width() - visibleContentRect.width() * frameScaleFactor) / maxSize.width();
-    float dragFactorY = (fixedElementsLayoutRelativeToFrame || !maxSize.height()) ? 1 : (contentsSize.height() - visibleContentRect.height() * frameScaleFactor) / maxSize.height();
+    float dragFactorX = (fixedElementsLayoutRelativeToFrame || !maxSize.width()) ? 1 : (totalContentsSize.width() - visibleContentRect.width() * frameScaleFactor) / maxSize.width();
+    float dragFactorY = (fixedElementsLayoutRelativeToFrame || !maxSize.height()) ? 1 : (totalContentsSize.height() - visibleContentRect.height() * frameScaleFactor) / maxSize.height();
 
     return IntSize(constrainedPosition.x() * dragFactorX / frameScaleFactor, constrainedPosition.y() * dragFactorY / frameScaleFactor);
 }
@@ -1619,11 +1619,11 @@
 IntSize FrameView::scrollOffsetForFixedPosition() const
 {
     IntRect visibleContentRect = this->visibleContentRect();
-    IntSize contentsSize = this->contentsSize();
+    IntSize totalContentsSize = this->totalContentsSize();
     IntPoint scrollPosition = this->scrollPosition();
     IntPoint scrollOrigin = this->scrollOrigin();
     float frameScaleFactor = m_frame ? m_frame->frameScaleFactor() : 1;
-    return scrollOffsetForFixedPosition(visibleContentRect, contentsSize, scrollPosition, scrollOrigin, frameScaleFactor, fixedElementsLayoutRelativeToFrame());
+    return scrollOffsetForFixedPosition(visibleContentRect, totalContentsSize, scrollPosition, scrollOrigin, frameScaleFactor, fixedElementsLayoutRelativeToFrame(), headerHeight(), footerHeight());
 }
 
 bool FrameView::fixedElementsLayoutRelativeToFrame() const

Modified: trunk/Source/WebCore/page/FrameView.h (147470 => 147471)


--- trunk/Source/WebCore/page/FrameView.h	2013-04-02 18:23:30 UTC (rev 147470)
+++ trunk/Source/WebCore/page/FrameView.h	2013-04-02 18:25:41 UTC (rev 147471)
@@ -225,7 +225,7 @@
     // and adjusting for page scale.
     IntSize scrollOffsetForFixedPosition() const;
     // Static function can be called from another thread.
-    static IntSize scrollOffsetForFixedPosition(const IntRect& visibleContentRect, const IntSize& contentsSize, const IntPoint& scrollPosition, const IntPoint& scrollOrigin, float frameScaleFactor, bool fixedElementsLayoutRelativeToFrame);
+    static IntSize scrollOffsetForFixedPosition(const IntRect& visibleContentRect, const IntSize& totalContentsSize, const IntPoint& scrollPosition, const IntPoint& scrollOrigin, float frameScaleFactor, bool fixedElementsLayoutRelativeToFrame, int headerHeight, int footerHeight);
 
     bool fixedElementsLayoutRelativeToFrame() const;
 

Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp (147470 => 147471)


--- trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp	2013-04-02 18:23:30 UTC (rev 147470)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp	2013-04-02 18:25:41 UTC (rev 147471)
@@ -52,6 +52,8 @@
     , m_requestedScrollPositionRepresentsProgrammaticScroll(false)
     , m_horizontalScrollbarMode(ScrollbarAuto)
     , m_verticalScrollbarMode(ScrollbarAuto)
+    , m_headerHeight(0)
+    , m_footerHeight(0)
 {
 }
 
@@ -72,6 +74,8 @@
     , m_verticalScrollbarMode(stateNode.verticalScrollbarMode())
     , m_requestedScrollPosition(stateNode.requestedScrollPosition())
     , m_scrollOrigin(stateNode.scrollOrigin())
+    , m_headerHeight(stateNode.headerHeight())
+    , m_footerHeight(stateNode.footerHeight())
 {
     setCounterScrollingLayer(stateNode.counterScrollingLayer());
 }
@@ -224,6 +228,26 @@
     m_scrollingStateTree->setHasChangedProperties(true);
 }
 
+void ScrollingStateScrollingNode::setHeaderHeight(int headerHeight)
+{
+    if (m_headerHeight == headerHeight)
+        return;
+
+    m_headerHeight = headerHeight;
+    setPropertyChanged(HeaderHeight);
+    m_scrollingStateTree->setHasChangedProperties(true);
+}
+
+void ScrollingStateScrollingNode::setFooterHeight(int footerHeight)
+{
+    if (m_footerHeight == footerHeight)
+        return;
+
+    m_footerHeight = footerHeight;
+    setPropertyChanged(FooterHeight);
+    m_scrollingStateTree->setHasChangedProperties(true);
+}
+
 void ScrollingStateScrollingNode::dumpProperties(TextStream& ts, int indent) const
 {
     ts << "(" << "Scrolling node" << "\n";

Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h (147470 => 147471)


--- trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h	2013-04-02 18:23:30 UTC (rev 147470)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h	2013-04-02 18:25:41 UTC (rev 147471)
@@ -60,7 +60,9 @@
         VerticalScrollbarMode,
         ScrollOrigin,
         RequestedScrollPosition,
-        CounterScrollingLayer
+        CounterScrollingLayer,
+        HeaderHeight,
+        FooterHeight
     };
 
     virtual bool isScrollingNode() OVERRIDE { return true; }
@@ -107,6 +109,12 @@
     const IntPoint& scrollOrigin() const { return m_scrollOrigin; }
     void setScrollOrigin(const IntPoint&);
 
+    int headerHeight() const { return m_headerHeight; }
+    void setHeaderHeight(int);
+
+    int footerHeight() const { return m_footerHeight; }
+    void setFooterHeight(int);
+
     // This is a layer moved in the opposite direction to scrolling, for example for background-attachment:fixed
     GraphicsLayer* counterScrollingLayer() const { return m_counterScrollingLayer; }
     void setCounterScrollingLayer(GraphicsLayer*);
@@ -148,6 +156,9 @@
 
     IntPoint m_requestedScrollPosition;
     IntPoint m_scrollOrigin;
+
+    int m_headerHeight;
+    int m_footerHeight;
 };
 
 inline ScrollingStateScrollingNode* toScrollingStateScrollingNode(ScrollingStateNode* node)

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp (147470 => 147471)


--- trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp	2013-04-02 18:23:30 UTC (rev 147470)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp	2013-04-02 18:25:41 UTC (rev 147471)
@@ -42,6 +42,8 @@
     , m_hasEnabledVerticalScrollbar(false)
     , m_horizontalScrollbarMode(ScrollbarAuto)
     , m_verticalScrollbarMode(ScrollbarAuto)
+    , m_headerHeight(0)
+    , m_footerHeight(0)
 {
 }
 
@@ -85,6 +87,12 @@
 
     if (state->hasChangedProperty(ScrollingStateScrollingNode::ScrollOrigin))
         m_scrollOrigin = state->scrollOrigin();
+
+    if (state->hasChangedProperty(ScrollingStateScrollingNode::HeaderHeight))
+        m_headerHeight = state->headerHeight();
+
+    if (state->hasChangedProperty(ScrollingStateScrollingNode::FooterHeight))
+        m_footerHeight = state->footerHeight();
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h (147470 => 147471)


--- trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h	2013-04-02 18:23:30 UTC (rev 147470)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h	2013-04-02 18:25:41 UTC (rev 147471)
@@ -73,6 +73,9 @@
 
     const IntPoint& scrollOrigin() const { return m_scrollOrigin; }
 
+    int headerHeight() const { return m_headerHeight; }
+    int footerHeight() const { return m_footerHeight; }
+
 private:
     IntRect m_viewportRect;
     IntSize m_totalContentsSize;
@@ -90,6 +93,9 @@
 
     ScrollbarMode m_horizontalScrollbarMode;
     ScrollbarMode m_verticalScrollbarMode;
+
+    int m_headerHeight;
+    int m_footerHeight;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.h (147470 => 147471)


--- trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.h	2013-04-02 18:23:30 UTC (rev 147470)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.h	2013-04-02 18:25:41 UTC (rev 147471)
@@ -114,6 +114,9 @@
         IntSize totalContentsSize;
         
         float frameScaleFactor;
+
+        int headerHeight;
+        int footerHeight;
     };
 
     void setScrollParametersForNode(const ScrollParameters&, ScrollingStateScrollingNode*);

Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm (147470 => 147471)


--- trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm	2013-04-02 18:23:30 UTC (rev 147470)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm	2013-04-02 18:25:41 UTC (rev 147471)
@@ -159,6 +159,8 @@
     scrollParameters.viewportRect = IntRect(IntPoint(), frameView->visibleContentRect().size());
     scrollParameters.totalContentsSize = frameView->totalContentsSize();
     scrollParameters.frameScaleFactor = frameView->frame()->frameScaleFactor();
+    scrollParameters.headerHeight = frameView->headerHeight();
+    scrollParameters.footerHeight = frameView->footerHeight();
 
     setScrollParametersForNode(scrollParameters, node);
 }
@@ -291,6 +293,8 @@
     node->setViewportRect(scrollParameters.viewportRect);
     node->setTotalContentsSize(scrollParameters.totalContentsSize);
     node->setFrameScaleFactor(scrollParameters.frameScaleFactor);
+    node->setHeaderHeight(scrollParameters.headerHeight);
+    node->setFooterHeight(scrollParameters.footerHeight);
 
     scheduleTreeStateCommit();
 }

Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm (147470 => 147471)


--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm	2013-04-02 18:23:30 UTC (rev 147470)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm	2013-04-02 18:25:41 UTC (rev 147471)
@@ -305,7 +305,7 @@
     ASSERT(!shouldUpdateScrollLayerPositionOnMainThread());
     m_scrollLayer.get().position = CGPointMake(-position.x() + scrollOrigin().x(), -position.y() + scrollOrigin().y());
 
-    IntSize scrollOffsetForFixedChildren = FrameView::scrollOffsetForFixedPosition(viewportRect(), totalContentsSize(), position, scrollOrigin(), frameScaleFactor(), false);
+    IntSize scrollOffsetForFixedChildren = FrameView::scrollOffsetForFixedPosition(viewportRect(), totalContentsSize(), position, scrollOrigin(), frameScaleFactor(), false, headerHeight(), footerHeight());
     if (m_counterScrollingLayer)
         m_counterScrollingLayer.get().position = FloatPoint(scrollOffsetForFixedChildren);
 

Modified: trunk/Source/WebCore/platform/ScrollableArea.cpp (147470 => 147471)


--- trunk/Source/WebCore/platform/ScrollableArea.cpp	2013-04-02 18:23:30 UTC (rev 147470)
+++ trunk/Source/WebCore/platform/ScrollableArea.cpp	2013-04-02 18:25:41 UTC (rev 147471)
@@ -428,18 +428,23 @@
                    std::max(0, visibleHeight() + horizontalScrollbarHeight));
 }
 
-static int constrainedScrollPosition(int visibleContentSize, int contentsSize, int scrollPosition, int scrollOrigin)
+static int constrainedScrollPosition(int visibleContentSize, int totalContentsSize, int scrollPosition, int scrollOrigin, int headerHeight, int footerHeight)
 {
-    int maxValue = contentsSize - visibleContentSize;
+    int maxValue = totalContentsSize - visibleContentSize - footerHeight;
     if (maxValue <= 0)
         return 0;
 
     if (!scrollOrigin) {
-        if (scrollPosition <= 0)
+        if (scrollPosition <= headerHeight)
             return 0;
         if (scrollPosition > maxValue)
-            scrollPosition = maxValue;
+            scrollPosition = maxValue - headerHeight;
+        else
+            scrollPosition -= headerHeight;
     } else {
+        // FIXME: position:fixed elements are currently broken when there is a non-zero y-value in the scroll origin
+        // such as when -webkit-writing-mode:horizontal-bt; is set. But when we fix that, we need to make such
+        // pages work correctly with headers and footers as well. https://bugs.webkit.org/show_bug.cgi?id=113741
         if (scrollPosition >= 0)
             return 0;
         if (scrollPosition < -maxValue)
@@ -449,15 +454,15 @@
     return scrollPosition;
 }
 
-IntPoint ScrollableArea::constrainScrollPositionForOverhang(const IntRect& visibleContentRect, const IntSize& contentsSize, const IntPoint& scrollPosition, const IntPoint& scrollOrigin)
+IntPoint ScrollableArea::constrainScrollPositionForOverhang(const IntRect& visibleContentRect, const IntSize& totalContentsSize, const IntPoint& scrollPosition, const IntPoint& scrollOrigin, int headerHeight, int footerHeight)
 {
-    return IntPoint(constrainedScrollPosition(visibleContentRect.width(), contentsSize.width(), scrollPosition.x(), scrollOrigin.x()),
-        constrainedScrollPosition(visibleContentRect.height(), contentsSize.height(), scrollPosition.y(), scrollOrigin.y()));
+    return IntPoint(constrainedScrollPosition(visibleContentRect.width(), totalContentsSize.width(), scrollPosition.x(), scrollOrigin.x(), 0, 0),
+        constrainedScrollPosition(visibleContentRect.height(), totalContentsSize.height(), scrollPosition.y(), scrollOrigin.y(), headerHeight, footerHeight));
 }
 
 IntPoint ScrollableArea::constrainScrollPositionForOverhang(const IntPoint& scrollPosition)
 {
-    return constrainScrollPositionForOverhang(visibleContentRect(), contentsSize(), scrollPosition, scrollOrigin());
+    return constrainScrollPositionForOverhang(visibleContentRect(), totalContentsSize(), scrollPosition, scrollOrigin(), headerHeight(), footerHeight());
 }
 
 void ScrollableArea::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const

Modified: trunk/Source/WebCore/platform/ScrollableArea.h (147470 => 147471)


--- trunk/Source/WebCore/platform/ScrollableArea.h	2013-04-02 18:23:30 UTC (rev 147470)
+++ trunk/Source/WebCore/platform/ScrollableArea.h	2013-04-02 18:25:41 UTC (rev 147471)
@@ -173,7 +173,7 @@
     // NOTE: Only called from Internals for testing.
     void setScrollOffsetFromInternals(const IntPoint&);
 
-    static IntPoint constrainScrollPositionForOverhang(const IntRect& visibleContentRect, const IntSize& contentsSize, const IntPoint& scrollPosition, const IntPoint& scrollOrigin);
+    static IntPoint constrainScrollPositionForOverhang(const IntRect& visibleContentRect, const IntSize& totalContentsSize, const IntPoint& scrollPosition, const IntPoint& scrollOrigin, int headerHeight, int footetHeight);
     IntPoint constrainScrollPositionForOverhang(const IntPoint& scrollPosition);
 
     // Let subclasses provide a way of asking for and servicing scroll
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to