Fixed positioned elements at very top or bottom of page remain fixed but clip during...
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Feb 2011 17:25:20 +0000 (17:25 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Feb 2011 17:25:20 +0000 (17:25 +0000)
<rdar://problem/7615997>
https://bugs.webkit.org/show_bug.cgi?id=54054

Reviewed by Dan Bernstein.

Take the overhang into account when calculating position for elements with position: fixed.

* platform/ScrollView.cpp:
(WebCore::ScrollView::scrollXForFixedPosition):
(WebCore::ScrollView::scrollYForFixedPosition):
(WebCore::ScrollView::scrollOffsetForFixedPosition):
* platform/ScrollView.h:
* rendering/RenderView.cpp:
(WebCore::RenderView::mapLocalToContainer):
(WebCore::RenderView::mapAbsoluteToLocalPoint):
(WebCore::RenderView::computeRectForRepaint):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/ScrollView.cpp
Source/WebCore/platform/ScrollView.h
Source/WebCore/rendering/RenderView.cpp

index 51d68b5e1531511cca0b25ed40cbfc50af2dd405..079635dc27ac1122844add8ce1ee283d7947d3be 100644 (file)
@@ -1,3 +1,23 @@
+2011-02-09  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Dan Bernstein.
+
+        Fixed positioned elements at very top or bottom of page remain fixed but clip during rubber-banding
+        <rdar://problem/7615997>
+        https://bugs.webkit.org/show_bug.cgi?id=54054
+
+        Take the overhang into account when calculating position for elements with position: fixed.
+
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::scrollXForFixedPosition):
+        (WebCore::ScrollView::scrollYForFixedPosition):
+        (WebCore::ScrollView::scrollOffsetForFixedPosition):
+        * platform/ScrollView.h:
+        * rendering/RenderView.cpp:
+        (WebCore::RenderView::mapLocalToContainer):
+        (WebCore::RenderView::mapAbsoluteToLocalPoint):
+        (WebCore::RenderView::computeRectForRepaint):
+
 2011-02-09  Simon Fraser  <simon.fraser@apple.com>
 
         Reviewed by Dirk Schulze.
index 8f1e846902340197f62447d902097767949d8c25..09918a3b8b5c7f09865b13e85999beafce1228ba 100644 (file)
@@ -318,6 +318,31 @@ IntPoint ScrollView::adjustScrollPositionWithinRange(const IntPoint& scrollPoint
     return newScrollPosition;
 }
 
+int ScrollView::scrollXForFixedPosition() const
+{
+    int x = scrollX();
+    if (x < 0)
+        x = 0;
+    else if (x > contentsWidth() - visibleContentRect().width())
+        x = contentsWidth() - visibleContentRect().width();
+    return x;
+}
+
+int ScrollView::scrollYForFixedPosition() const
+{
+    int y = scrollY();
+    if (y < 0)
+        y = 0;
+    else if (y > contentsHeight() - visibleContentRect().height())
+        y = contentsHeight() - visibleContentRect().height();
+    return y;
+}
+
+IntSize ScrollView::scrollOffsetForFixedPosition() const
+{
+    return IntSize(scrollXForFixedPosition(), scrollYForFixedPosition());
+}
+
 int ScrollView::scrollSize(ScrollbarOrientation orientation) const
 {
     Scrollbar* scrollbar = ((orientation == HorizontalScrollbar) ? m_horizontalScrollbar : m_verticalScrollbar).get();
index 203c034ff3780cc51016e5e9524fa9684deebab6..0fdb8969a3f525c0923c5147d026a2372f34c595 100644 (file)
@@ -173,6 +173,11 @@ public:
     int scrollX() const { return scrollPosition().x(); }
     int scrollY() const { return scrollPosition().y(); }
 
+    // Functions for querying the current scrolled position, negating the effects of overhang.
+    int scrollXForFixedPosition() const;
+    int scrollYForFixedPosition() const;
+    IntSize scrollOffsetForFixedPosition() const;
+
     IntSize overhangAmount() const;
 
     // Functions for scrolling the view.
index 69227aebb79ef8de0d8cc88182f76af8733d8bf2..6dd5767d9a3e24d0bce2fde661b83675403bf00a 100644 (file)
@@ -149,13 +149,13 @@ void RenderView::mapLocalToContainer(RenderBoxModelObject* repaintContainer, boo
     }
     
     if (fixed && m_frameView)
-        transformState.move(m_frameView->scrollOffset());
+        transformState.move(m_frameView->scrollOffsetForFixedPosition());
 }
 
 void RenderView::mapAbsoluteToLocalPoint(bool fixed, bool useTransforms, TransformState& transformState) const
 {
     if (fixed && m_frameView)
-        transformState.move(-m_frameView->scrollOffset());
+        transformState.move(-m_frameView->scrollOffsetForFixedPosition());
 
     if (useTransforms && shouldUseTransformFromContainer(0)) {
         TransformationMatrix t;
@@ -310,7 +310,7 @@ void RenderView::computeRectForRepaint(RenderBoxModelObject* repaintContainer, I
     }
 
     if (fixed && m_frameView)
-        rect.move(m_frameView->scrollX(), m_frameView->scrollY());
+        rect.move(m_frameView->scrollXForFixedPosition(), m_frameView->scrollYForFixedPosition());
         
     // Apply our transform if we have one (because of full page zooming).
     if (m_layer && m_layer->transform())