Commit e007fb25 authored by hyatt@apple.com's avatar hyatt@apple.com

2009-01-25 David Hyatt <hyatt@apple.com>

        Fix for <rdar://problem/6525392> REGRESSION (r40180): Scroll wheel events over text scroll the page
        instead of the ancestor overflow (23525)
        
        Make sure that we always call scroll() on the nearest enclosing RenderBox.  No test case is possible
        here, since wheel scrolling is currently untestable (the offset varies from machine to machine).

        Reviewed by Dan Bernstein

        * page/EventHandler.cpp:
        (WebCore::scrollAndAcceptEvent):
        (WebCore::EventHandler::scrollOverflow):
        * rendering/RenderObject.cpp:
        (WebCore::RenderObject::enclosingBox):
        * rendering/RenderObject.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@40235 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 38d96eff
2009-01-25 David Hyatt <hyatt@apple.com>
Fix for <rdar://problem/6525392> REGRESSION (r40180): Scroll wheel events over text scroll the page
instead of the ancestor overflow (23525)
Make sure that we always call scroll() on the nearest enclosing RenderBox. No test case is possible
here, since wheel scrolling is currently untestable (the offset varies from machine to machine).
Reviewed by Dan Bernstein
* page/EventHandler.cpp:
(WebCore::scrollAndAcceptEvent):
(WebCore::EventHandler::scrollOverflow):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::enclosingBox):
* rendering/RenderObject.h:
2009-01-25 Darin Adler <darin@apple.com>
Reviewed by Dan Bernstein.
......@@ -100,17 +100,21 @@ static Frame* subframeForHitTestResult(const MouseEventWithHitTestResults&);
static inline void scrollAndAcceptEvent(float delta, ScrollDirection positiveDirection, ScrollDirection negativeDirection, PlatformWheelEvent& e, Node* node)
{
if (!delta || !node->renderBox())
if (!delta)
return;
// Find the nearest enclosing box.
RenderBox* enclosingBox = node->renderer()->enclosingBox();
if (e.granularity() == ScrollByPageWheelEvent) {
if (node->renderBox()->scroll(delta < 0 ? negativeDirection : positiveDirection, ScrollByPage, 1))
if (enclosingBox->scroll(delta < 0 ? negativeDirection : positiveDirection, ScrollByPage, 1))
e.accept();
return;
}
float pixelsToScroll = delta > 0 ? delta : -delta;
if (e.granularity() == ScrollByLineWheelEvent)
pixelsToScroll *= cMouseWheelPixelsPerLineStep;
if (node->renderBox()->scroll(delta < 0 ? negativeDirection : positiveDirection, ScrollByPixel, pixelsToScroll))
if (enclosingBox->scroll(delta < 0 ? negativeDirection : positiveDirection, ScrollByPixel, pixelsToScroll))
e.accept();
}
......@@ -788,8 +792,8 @@ bool EventHandler::scrollOverflow(ScrollDirection direction, ScrollGranularity g
if (node) {
RenderObject* r = node->renderer();
if (r && r->isBox() && !r->isListBox())
return toRenderBox(r)->scroll(direction, granularity);
if (r && !r->isListBox())
return r->enclosingBox()->scroll(direction, granularity);
}
return false;
......
......@@ -480,6 +480,19 @@ RenderLayer* RenderObject::enclosingLayer() const
return 0;
}
RenderBox* RenderObject::enclosingBox() const
{
RenderObject* curr = const_cast<RenderObject*>(this);
while (curr) {
if (curr->isBox())
return toRenderBox(curr);
curr = curr->parent();
}
ASSERT_NOT_REACHED();
return 0;
}
RenderBlock* RenderObject::firstLineBlock() const
{
return 0;
......
......@@ -148,6 +148,9 @@ public:
void moveLayers(RenderLayer* oldParent, RenderLayer* newParent);
RenderLayer* findNextLayer(RenderLayer* parentLayer, RenderObject* startPoint, bool checkParent = true);
// Convenience function for getting to the nearest enclosing box of a RenderObject.
RenderBox* enclosingBox() const;
virtual IntRect getOverflowClipRect(int /*tx*/, int /*ty*/) { return IntRect(0, 0, 0, 0); }
virtual IntRect getClipRect(int /*tx*/, int /*ty*/) { return IntRect(0, 0, 0, 0); }
bool hasClip() { return isPositioned() && style()->hasClip(); }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment