Reviewed by Darin.
authorantti <antti@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Mar 2007 22:01:08 +0000 (22:01 +0000)
committerantti <antti@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Mar 2007 22:01:08 +0000 (22:01 +0000)
        - fix http://bugs.webkit.org/show_bug.cgi?id=10747
        REGRESSION: Using two fingers on a trackpad to scroll inside a text area makes the whole page move
        <rdar://problem/5045710>

        Eat smooth scroll events in WebCore if pointer is over scrollable area. Not
        really a good fix, smooth scrolling should be supported properly. It should do for now.

        * page/EventHandler.cpp:
        (WebCore::EventHandler::handleWheelEvent):
        * rendering/RenderListBox.cpp:
        (WebCore::RenderListBox::isScrollable):
        * rendering/RenderListBox.h:
        * rendering/RenderObject.cpp:
        (WebCore::RenderObject::isScrollable):
        * rendering/RenderObject.h:
        * rendering/RenderTextControl.cpp:
        (WebCore::RenderTextControl::isScrollable):
        * rendering/RenderTextControl.h:

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

WebCore/ChangeLog
WebCore/page/EventHandler.cpp
WebCore/rendering/RenderListBox.cpp
WebCore/rendering/RenderListBox.h
WebCore/rendering/RenderObject.cpp
WebCore/rendering/RenderObject.h
WebCore/rendering/RenderTextControl.cpp
WebCore/rendering/RenderTextControl.h

index 93a492242d4fb4b719b794ff8d1a95689e7bbab9..07c277b277fae847f56e6fdc28901a543e6a4efd 100644 (file)
@@ -1,3 +1,26 @@
+2007-03-20  Antti Koivisto  <antti@apple.com>
+
+        Reviewed by Darin.
+
+        - fix http://bugs.webkit.org/show_bug.cgi?id=10747
+        REGRESSION: Using two fingers on a trackpad to scroll inside a text area makes the whole page move
+        <rdar://problem/5045710>
+        
+        Eat smooth scroll events in WebCore if pointer is over scrollable area. Not
+        really a good fix, smooth scrolling should be supported properly. It should do for now.
+
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::handleWheelEvent):
+        * rendering/RenderListBox.cpp:
+        (WebCore::RenderListBox::isScrollable):
+        * rendering/RenderListBox.h:
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::isScrollable):
+        * rendering/RenderObject.h:
+        * rendering/RenderTextControl.cpp:
+        (WebCore::RenderTextControl::isScrollable):
+        * rendering/RenderTextControl.h:
+
 2007-03-20  Beth Dakin  <bdakin@apple.com>
 
         Reviewed by Geoff.
index dfa79eff5ce9a2c5724ff9a93634be5f315b1036..1965c4d9eb5824eb8caf04e8d3ece5d8b32dae2e 100644 (file)
@@ -1167,6 +1167,13 @@ bool EventHandler::handleWheelEvent(PlatformWheelEvent& e)
     if (!node->renderer())
         return false;
 
+#if PLATFORM(MAC)
+    if (!e.deltaX() && !e.deltaY() && node->renderer()->isScrollable())
+        // smooth scroll events on mac may have (0,0) deltas
+        // they need to be eaten until we start supporting them
+        e.accept();
+#endif
+    
     // Just break up into two scrolls if we need to.  Diagonal movement on 
     // a MacBook pro is an example of a 2-dimensional mouse wheel event (where both deltaX and deltaY can be set).
     if (e.deltaX() && node->renderer()->scroll(e.deltaX() < 0 ? ScrollRight : ScrollLeft, ScrollByWheel,
index d00450a4c2f64f13d76bee1af533985733e6e917..7bf16e495af649777d6f58cc6b30acb137de4293 100644 (file)
@@ -546,4 +546,11 @@ IntRect RenderListBox::windowClipRect() const
     return frameView->windowClipRectForLayer(enclosingLayer(), true);
 }
 
+bool RenderListBox::isScrollable() const
+{
+    if (numVisibleItems() < numItems())
+        return true;
+    return RenderObject::isScrollable();
+}
+
 } // namespace WebCore
index 57d5bf697d968724244beb0a1fbfa8f9704b367f..d4f46e040c89261f4101a13edc7ed8bf6d6120c7 100644 (file)
@@ -59,6 +59,7 @@ public:
     virtual bool isPointInScrollbar(HitTestResult&, int x, int y, int tx, int ty);
 
     virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1.0f);
+    virtual bool isScrollable() const;
 
     virtual void calcMinMaxWidth();
     virtual short baselinePosition(bool firstLine, bool isRootLineBox) const;
index b3dea80c494aae3ba9a119fe9193766356888e47..8c3644c1f4cd66921de7616405616a23563b01cf 100644 (file)
@@ -3055,6 +3055,12 @@ IntRect RenderObject::absoluteOutlineBox() const
     return box;
 }
 
+bool RenderObject::isScrollable() const
+{
+    RenderLayer* l = enclosingLayer();
+    return l && (l->verticalScrollbar() || l->horizontalScrollbar());
+}
+
 #if ENABLE(SVG)
 
 FloatRect RenderObject::relativeBBox(bool) const
index 002c0173345cb71a7feeba850ebc2b543446a82c..6562a46af84ff2fcf906647150bc7a4cb481f4df 100644 (file)
@@ -640,6 +640,7 @@ public:
     virtual bool shouldAutoscroll() const;
     virtual void autoscroll();
     virtual void stopAutoscroll() { }
+    virtual bool isScrollable() const;
 
     // The following seven functions are used to implement collapsing margins.
     // All objects know their maximal positive and negative margins.  The
index 309b18b8af23662e4a6061b93f583d34a670971d..00ad305b4eddb18abaf3eef1ff6ba82d4dd70d5b 100644 (file)
@@ -1033,4 +1033,11 @@ void RenderTextControl::startSearchEventTimer()
     m_searchEventTimer.startOneShot(max(0.2, 0.6 - 0.1 * length));
 }
 
+bool RenderTextControl::isScrollable() const
+{
+    if (m_innerText && m_innerText->renderer()->isScrollable())
+        return true;
+    return RenderObject::isScrollable();
+}
+
 } // namespace WebCore
index ce9d7919745bcc222cf262f08111ca5be5842c69..a1e8ae5102c07cfe059fb37f056a7f0183645772 100644 (file)
@@ -82,6 +82,7 @@ public:
     virtual void setScrollLeft(int);
     virtual void setScrollTop(int);
     virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1.0f);
+    virtual bool isScrollable() const;
 
     VisiblePosition visiblePositionForIndex(int index);
     int indexForVisiblePosition(const VisiblePosition&);