Roll r78424 [Extra scrolling required when scrolling with a scroll wheel (Mighty...
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 13 Feb 2011 19:05:09 +0000 (19:05 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 13 Feb 2011 19:05:09 +0000 (19:05 +0000)
in with fixes to make it work with render layers.

* platform/mac/ScrollAnimatorMac.h:
* platform/mac/ScrollAnimatorMac.mm:
(WebCore::ScrollAnimatorMac::scrollToOffsetWithoutAnimation):
(WebCore::ScrollAnimatorMac::adjustScrollXPositionIfNecessary):
(WebCore::ScrollAnimatorMac::adjustScrollYPositionIfNecessary):
(WebCore::ScrollAnimatorMac::adjustScrollPositionIfNecessary):
(WebCore::ScrollAnimatorMac::immediateScrollToPoint):
(WebCore::ScrollAnimatorMac::immediateScrollByDeltaX):
(WebCore::ScrollAnimatorMac::immediateScrollByDeltaY):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::RenderLayer):
(WebCore::RenderLayer::contentsSize):
(WebCore::RenderLayer::visibleHeight):
(WebCore::RenderLayer::visibleWidth):
(WebCore::RenderLayer::updateScrollInfoAfterLayout):
* rendering/RenderLayer.h:
* rendering/RenderListBox.cpp:
(WebCore::RenderListBox::visibleHeight):
(WebCore::RenderListBox::visibleWidth):
* rendering/RenderListBox.h:

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

Source/WebCore/ChangeLog
Source/WebCore/platform/mac/ScrollAnimatorMac.h
Source/WebCore/platform/mac/ScrollAnimatorMac.mm
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderLayer.h
Source/WebCore/rendering/RenderListBox.cpp
Source/WebCore/rendering/RenderListBox.h

index 6088843..e90aa4c 100644 (file)
@@ -1,5 +1,31 @@
 2011-02-13  Sam Weinig  <sam@webkit.org>
 
+        Roll r78424 [Extra scrolling required when scrolling with a scroll wheel (Mighty Mouse)] back
+        in with fixes to make it work with render layers.
+
+        * platform/mac/ScrollAnimatorMac.h:
+        * platform/mac/ScrollAnimatorMac.mm:
+        (WebCore::ScrollAnimatorMac::scrollToOffsetWithoutAnimation):
+        (WebCore::ScrollAnimatorMac::adjustScrollXPositionIfNecessary):
+        (WebCore::ScrollAnimatorMac::adjustScrollYPositionIfNecessary):
+        (WebCore::ScrollAnimatorMac::adjustScrollPositionIfNecessary):
+        (WebCore::ScrollAnimatorMac::immediateScrollToPoint):
+        (WebCore::ScrollAnimatorMac::immediateScrollByDeltaX):
+        (WebCore::ScrollAnimatorMac::immediateScrollByDeltaY):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::RenderLayer):
+        (WebCore::RenderLayer::contentsSize):
+        (WebCore::RenderLayer::visibleHeight):
+        (WebCore::RenderLayer::visibleWidth):
+        (WebCore::RenderLayer::updateScrollInfoAfterLayout):
+        * rendering/RenderLayer.h:
+        * rendering/RenderListBox.cpp:
+        (WebCore::RenderListBox::visibleHeight):
+        (WebCore::RenderListBox::visibleWidth):
+        * rendering/RenderListBox.h:
+
+2011-02-13  Sam Weinig  <sam@webkit.org>
+
         Reviewed by Dan Bernstein.
 
         Some Scrollbar functions assume an attached ScrollableArea but can be called without one
index 79201e7..3f7612a 100644 (file)
@@ -97,6 +97,10 @@ private:
     virtual void didAddHorizontalScrollbar(Scrollbar*);
     virtual void willRemoveHorizontalScrollbar(Scrollbar*);
 
+    float adjustScrollXPositionIfNecessary(float) const;
+    float adjustScrollYPositionIfNecessary(float) const;
+    FloatPoint adjustScrollPositionIfNecessary(const FloatPoint&) const;
+
 #if ENABLE(RUBBER_BANDING)
     bool allowsVerticalStretching() const;
     bool allowsHorizontalStretching() const;
index c75a900..c1154d5 100644 (file)
@@ -40,6 +40,9 @@
 #include <wtf/PassOwnPtr.h>
 #include <wtf/UnusedParam.h>
 
+using namespace WebCore;
+using namespace std;
+
 @interface NSObject (ScrollAnimationHelperDetails)
 - (id)initWithDelegate:(id)delegate;
 - (void)_stopRun;
@@ -47,8 +50,6 @@
 - (NSPoint)targetOrigin;
 @end
 
-using namespace WebCore;
-
 @interface ScrollAnimationHelperDelegate : NSObject
 {
     WebCore::ScrollAnimatorMac* _animator;
@@ -506,25 +507,54 @@ bool ScrollAnimatorMac::scroll(ScrollbarOrientation orientation, ScrollGranulari
 void ScrollAnimatorMac::scrollToOffsetWithoutAnimation(const FloatPoint& offset)
 {
     [m_scrollAnimationHelper.get() _stopRun];
-    ScrollAnimator::scrollToOffsetWithoutAnimation(offset);
+    immediateScrollToPoint(offset);
+}
+
+float ScrollAnimatorMac::adjustScrollXPositionIfNecessary(float position) const
+{
+    if (!m_scrollableArea->constrainsScrollingToContentEdge())
+        return position;
+
+    return max<float>(min<float>(position, m_scrollableArea->contentsSize().width() - m_scrollableArea->visibleWidth()), 0);
+}
+
+float ScrollAnimatorMac::adjustScrollYPositionIfNecessary(float position) const
+{
+    if (!m_scrollableArea->constrainsScrollingToContentEdge())
+        return position;
+
+    return max<float>(min<float>(position, m_scrollableArea->contentsSize().height() - m_scrollableArea->visibleHeight()), 0);
+}
+
+FloatPoint ScrollAnimatorMac::adjustScrollPositionIfNecessary(const FloatPoint& position) const
+{
+    if (!m_scrollableArea->constrainsScrollingToContentEdge())
+        return position;
+
+    float newX = max<float>(min<float>(position.x(), m_scrollableArea->contentsSize().width() - m_scrollableArea->visibleWidth()), 0);
+    float newY = max<float>(min<float>(position.y(), m_scrollableArea->contentsSize().height() - m_scrollableArea->visibleHeight()), 0);
+
+    return FloatPoint(newX, newY);
 }
 
 void ScrollAnimatorMac::immediateScrollToPoint(const FloatPoint& newPosition)
 {
-    m_currentPosX = newPosition.x();
-    m_currentPosY = newPosition.y();
+    FloatPoint adjustedPosition = adjustScrollPositionIfNecessary(newPosition);
+    m_currentPosX = adjustedPosition.x();
+    m_currentPosY = adjustedPosition.y();
     notityPositionChanged();
 }
 
 void ScrollAnimatorMac::immediateScrollByDeltaX(float deltaX)
 {
-    m_currentPosX += deltaX;
+    m_currentPosX = adjustScrollXPositionIfNecessary(m_currentPosX + deltaX);
     notityPositionChanged();
 }
 
 void ScrollAnimatorMac::immediateScrollByDeltaY(float deltaY)
 {
-    m_currentPosY += deltaY;
+    m_currentPosY = adjustScrollYPositionIfNecessary(m_currentPosY + deltaY);
     notityPositionChanged();
 }
 
index e7f41f7..43e3f34 100644 (file)
@@ -182,6 +182,8 @@ RenderLayer::RenderLayer(RenderBoxModelObject* renderer)
     , m_scrollCorner(0)
     , m_resizer(0)
 {
+    ScrollableArea::setConstrainsScrollingToContentEdge(false);
+
     if (!renderer->firstChild() && renderer->style()) {
         m_visibleContentStatusDirty = false;
         m_hasVisibleContent = renderer->style()->visibility() == VISIBLE;
@@ -1773,6 +1775,21 @@ IntPoint RenderLayer::convertFromContainingViewToScrollbar(const Scrollbar* scro
     return point;
 }
 
+IntSize RenderLayer::contentsSize() const
+{
+    return IntSize(const_cast<RenderLayer*>(this)->scrollWidth(), const_cast<RenderLayer*>(this)->scrollHeight());
+}
+
+int RenderLayer::visibleHeight() const
+{
+    return m_height;
+}
+
+int RenderLayer::visibleWidth() const
+{
+    return m_width;
+}
+
 IntSize RenderLayer::scrollbarOffset(const Scrollbar* scrollbar) const
 {
     RenderBox* box = renderBox();
@@ -2124,7 +2141,10 @@ void RenderLayer::updateScrollInfoAfterLayout()
         m_vBar->setProportion(clientHeight, m_scrollHeight);
     }
  
+    RenderView* view = renderer()->view();
+    view->disableLayoutState();
     scrollToOffset(scrollXOffset(), scrollYOffset());
+    view->enableLayoutState();
  
     if (renderer()->node() && renderer()->document()->hasListenerType(Document::OVERFLOWCHANGED_LISTENER))
         updateOverflowStatus(horizontalOverflow, verticalOverflow);
index 065a4aa..7ea5b39 100644 (file)
@@ -524,7 +524,9 @@ private:
     virtual IntRect convertFromContainingViewToScrollbar(const Scrollbar*, const IntRect&) const;
     virtual IntPoint convertFromScrollbarToContainingView(const Scrollbar*, const IntPoint&) const;
     virtual IntPoint convertFromContainingViewToScrollbar(const Scrollbar*, const IntPoint&) const;
-    virtual IntSize contentsSize() const { return size(); }
+    virtual IntSize contentsSize() const;
+    virtual int visibleHeight() const;
+    virtual int visibleWidth() const;
 
     // NOTE: This should only be called by the overriden setScrollOffset from ScrollableArea.
     void scrollTo(int x, int y);
index 10c17eb..13e8e58 100644 (file)
@@ -703,6 +703,16 @@ IntSize RenderListBox::contentsSize() const
     return IntSize(scrollWidth(), scrollHeight());
 }
 
+int RenderListBox::visibleHeight() const
+{
+    return height();
+}
+
+int RenderListBox::visibleWidth() const
+{
+    return width();
+}
+
 IntPoint RenderListBox::currentMousePosition() const
 {
     RenderView* view = this->view();
index fb2b9e1..1eb2036 100644 (file)
@@ -107,6 +107,8 @@ private:
     virtual IntPoint convertFromContainingViewToScrollbar(const Scrollbar*, const IntPoint&) const;
     virtual Scrollbar* verticalScrollbar() const { return m_vBar.get(); }
     virtual IntSize contentsSize() const;
+    virtual int visibleHeight() const;
+    virtual int visibleWidth() const;
     virtual IntPoint currentMousePosition() const;
     virtual bool scrollbarWillRenderIntoCompositingLayer() const;