Changeset 16975 in webkit


Ignore:
Timestamp:
Oct 10, 2006 2:18:03 PM (18 years ago)
Author:
adele
Message:

WebCore:

Reviewed by Beth.

  • Fix for <rdar://problem/4707489> After timers fix, crash below RenderLayer::autoscroll after moving/destroying active <input type=text> and <rdar://problem/4707519> After timers fix, crash below RenderLayer::autoscroll after moving/destroying active textarea

Moved autoscroll code to the Frame class

  • bridge/mac/FrameMac.h: Moved _mouseDownMayStartDrag and _mouseDownMayStartAutoscroll flags to the frame.
  • bridge/mac/FrameMac.mm: Use new getters and setters for drag and autoscroll flags. Moved autoscroll code to Frame::handleMouseMoveEvent. (WebCore::FrameMac::FrameMac): (WebCore::FrameMac::handleMousePressEvent): (WebCore::FrameMac::eventMayStartDrag): (WebCore::FrameMac::handleMouseMoveEvent): (WebCore::FrameMac::mouseDown):
  • bridge/mac/WebCoreFrameBridge.h: Removed handleAutoscrollForMouseDragged, which called over the bridge for AppKit to do autoscroll for us. Now we scroll our views in WebCore.
  • page/Frame.cpp: (WebCore::Frame::handleMousePressEvent): Initialize the mouseDownMayStartAutoscroll flag. (WebCore::Frame::handleMouseMoveEvent): Now kicks off autoscroll if appropriate. Moved from FrameMac. (WebCore::Frame::updateSelectionForMouseDragOverPosition): Factored code out from handleMouseMoveEvent so we can update the selection from autoscroll too. (WebCore::Frame::mouseDownMayStartAutoscroll): Added. (WebCore::Frame::setMouseDownMayStartAutoscroll): Added. (WebCore::Frame::mouseDownMayStartDrag): Added. (WebCore::Frame::setMouseDownMayStartDrag): Added. (WebCore::Frame::autoscrollRenderer): Added (WebCore::Frame::setAutoscrollRenderer): Added. (WebCore::Frame::handleAutoscroll): Updated to use autoscrollRenderer getter and setter. (WebCore::Frame::autoscrollTimerFired): ditto. (WebCore::Frame::stopAutoscrollTimer): ditto.
  • page/Frame.h: Made autoscrollRenderer and stopAutoscrollTimer public, so the renderer being autoscrolled can kill the timer when it dies.
  • page/FramePrivate.h: (WebCore::FramePrivate::FramePrivate): Added mouseDownMayStartDrag and mouseDownMayStartAutoscroll flags. Moved from FrameMac.
  • page/FrameView.cpp: Store the current mouse position in window coordinates. The callers can convert to their own coordinate space. (WebCore::FrameView::handleMousePressEvent): (WebCore::FrameView::handleMouseDoubleClickEvent): (WebCore::FrameView::handleMouseMoveEvent): (WebCore::FrameView::handleMouseReleaseEvent):
  • rendering/RenderLayer.cpp: (WebCore::RenderLayer::autoscroll): Rewrote this to scroll recursively, and to scroll based on the mouse position (not the selection). We also need to update the selection here, since autoscroll can occur without a mouseMove event, and the selection needs to get reset as we scroll.
  • rendering/RenderListBox.cpp: (WebCore::RenderListBox::autoscroll): Convert the mouse coordinates to the right space.
  • rendering/RenderObject.cpp: (WebCore::RenderObject::shouldAutoscroll): Also return true if the renderer is a root (so we know to autoscroll views too) (WebCore::RenderObject::destroy): If this renderer is being autoscrolled, stop the frame's autoscroll timer.

WebKit:

Reviewed by Beth.

Removed handleAutoscrollForMouseDragged. Except for autoscroll caused by drag and drop, all other
autoscrolling should be done in WebCore instead of in AppKit.

  • WebCoreSupport/WebFrameBridge.m:
  • WebView/WebHTMLView.m:
  • WebView/WebHTMLViewPrivate.h:
Location:
trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r16973 r16975  
     12006-10-10  Adele Peterson  <adele@apple.com>
     2
     3        Reviewed by Beth.
     4
     5
     6        - Fix for <rdar://problem/4707489> After timers fix, crash below RenderLayer::autoscroll after moving/destroying active <input type=text>
     7          and <rdar://problem/4707519> After timers fix, crash below RenderLayer::autoscroll after moving/destroying active textarea
     8
     9        Moved autoscroll code to the Frame class
     10
     11        * bridge/mac/FrameMac.h: Moved _mouseDownMayStartDrag and _mouseDownMayStartAutoscroll flags to the frame.
     12        * bridge/mac/FrameMac.mm: Use new getters and setters for drag and autoscroll flags.  Moved autoscroll code to Frame::handleMouseMoveEvent.
     13        (WebCore::FrameMac::FrameMac):
     14        (WebCore::FrameMac::handleMousePressEvent):
     15        (WebCore::FrameMac::eventMayStartDrag):
     16        (WebCore::FrameMac::handleMouseMoveEvent):
     17        (WebCore::FrameMac::mouseDown):
     18
     19        * bridge/mac/WebCoreFrameBridge.h: Removed handleAutoscrollForMouseDragged, which called over the bridge for AppKit to do autoscroll for us.
     20        Now we scroll our views in WebCore.
     21
     22        * page/Frame.cpp:
     23        (WebCore::Frame::handleMousePressEvent): Initialize the mouseDownMayStartAutoscroll flag.
     24        (WebCore::Frame::handleMouseMoveEvent): Now kicks off autoscroll if appropriate.  Moved from FrameMac.
     25        (WebCore::Frame::updateSelectionForMouseDragOverPosition): Factored code out from handleMouseMoveEvent so we can update the selection from autoscroll too.
     26        (WebCore::Frame::mouseDownMayStartAutoscroll): Added.
     27        (WebCore::Frame::setMouseDownMayStartAutoscroll): Added.
     28        (WebCore::Frame::mouseDownMayStartDrag): Added.
     29        (WebCore::Frame::setMouseDownMayStartDrag): Added.
     30        (WebCore::Frame::autoscrollRenderer): Added
     31        (WebCore::Frame::setAutoscrollRenderer): Added.
     32        (WebCore::Frame::handleAutoscroll): Updated to use autoscrollRenderer getter and setter.
     33        (WebCore::Frame::autoscrollTimerFired): ditto.
     34        (WebCore::Frame::stopAutoscrollTimer): ditto.
     35        * page/Frame.h: Made autoscrollRenderer and stopAutoscrollTimer public, so the renderer being autoscrolled can kill the timer when it dies.
     36
     37        * page/FramePrivate.h:
     38        (WebCore::FramePrivate::FramePrivate): Added mouseDownMayStartDrag and mouseDownMayStartAutoscroll flags.  Moved from FrameMac.
     39
     40        * page/FrameView.cpp: Store the current mouse position in window coordinates.  The callers can convert to their own coordinate space.
     41        (WebCore::FrameView::handleMousePressEvent):
     42        (WebCore::FrameView::handleMouseDoubleClickEvent):
     43        (WebCore::FrameView::handleMouseMoveEvent):
     44        (WebCore::FrameView::handleMouseReleaseEvent):
     45
     46        * rendering/RenderLayer.cpp:
     47        (WebCore::RenderLayer::autoscroll): Rewrote this to scroll recursively, and to scroll based on the mouse position (not the selection). 
     48         We also need to update the selection here, since autoscroll can occur without a mouseMove event, and the selection needs to get reset as we scroll.
     49
     50        * rendering/RenderListBox.cpp:
     51        (WebCore::RenderListBox::autoscroll): Convert the mouse coordinates to the right space.
     52
     53        * rendering/RenderObject.cpp:
     54        (WebCore::RenderObject::shouldAutoscroll): Also return true if the renderer is a root (so we know to autoscroll views too)
     55        (WebCore::RenderObject::destroy): If this renderer is being autoscrolled, stop the frame's autoscroll timer.
     56
    1572006-10-10  Darin Adler  <darin@apple.com>
    258
  • trunk/WebCore/bridge/mac/FrameMac.h

    r16927 r16975  
    354354    bool _mouseDownWasInSubframe;
    355355    bool _sendingEventToSubview;
    356     bool _mouseDownMayStartDrag;
    357356    bool _mouseDownMayStartSelect;
    358     bool _mouseDownMayStartAutoscroll;
    359357    PlatformMouseEvent m_mouseDown;
    360358    // in our view's coords
  • trunk/WebCore/bridge/mac/FrameMac.mm

    r16927 r16975  
    153153    , _mouseDownView(nil)
    154154    , _sendingEventToSubview(false)
    155     , _mouseDownMayStartDrag(false)
    156155    , _mouseDownMayStartSelect(false)
    157     , _mouseDownMayStartAutoscroll(false)
    158156    , _activationEventNumber(0)
    159157    , _bindingRoot(0)
     
    14091407   
    14101408    // Careful that the drag starting logic stays in sync with eventMayStartDrag()
    1411     _mouseDownMayStartDrag = singleClick;
     1409    setMouseDownMayStartDrag(singleClick);
    14121410
    14131411    d->m_mousePressNode = event.targetNode();
    1414 
    1415     _mouseDownMayStartAutoscroll = d->m_mousePressNode && d->m_mousePressNode->renderer() && d->m_mousePressNode->renderer()->shouldAutoscroll();
    14161412   
    14171413    if (!passWidgetMouseDownEventToWidget(event)) {
     
    15881584{
    15891585    // This is a pre-flight check of whether the event might lead to a drag being started.  Be careful
    1590     // that its logic needs to stay in sync with handleMouseMoveEvent() and the way we set
    1591     // _mouseDownMayStartDrag in handleMousePressEvent
     1586    // that its logic needs to stay in sync with handleMouseMoveEvent() and the way we setMouseDownMayStartDrag
     1587    // in handleMousePressEvent
    15921588   
    15931589    if ([event type] != NSLeftMouseDown || [event clickCount] != 1) {
     
    16511647        // Careful that the drag starting logic stays in sync with eventMayStartDrag()
    16521648   
    1653         if (_mouseDownMayStartDrag && !_dragSrc) {
     1649        if (mouseDownMayStartDrag() && !_dragSrc) {
    16541650            BOOL tempFlag1, tempFlag2;
    16551651            [_bridge allowDHTMLDrag:&tempFlag1 UADrag:&tempFlag2];
     
    16571653            _dragSrcMayBeUA = tempFlag2;
    16581654            if (!_dragSrcMayBeDHTML && !_dragSrcMayBeUA) {
    1659                 _mouseDownMayStartDrag = false;     // no element is draggable
     1655                setMouseDownMayStartDrag(false);     // no element is draggable
    16601656            }
    16611657        }
    16621658       
    1663         if (_mouseDownMayStartDrag && !_dragSrc) {
     1659        if (mouseDownMayStartDrag() && !_dragSrc) {
    16641660            // try to find an element that wants to be dragged
    16651661            RenderObject::NodeInfo nodeInfo(true, false);
     
    16681664            _dragSrc = (node && node->renderer()) ? node->renderer()->draggableNode(_dragSrcMayBeDHTML, _dragSrcMayBeUA, m_mouseDownPos.x(), m_mouseDownPos.y(), _dragSrcIsDHTML) : 0;
    16691665            if (!_dragSrc) {
    1670                 _mouseDownMayStartDrag = false;     // no element is draggable
     1666                setMouseDownMayStartDrag(false);     // no element is draggable
    16711667            } else {
    16721668                // remember some facts about this source, while we have a NodeInfo handy
     
    16831679        // For drags starting in the selection, the user must wait between the mousedown and mousedrag,
    16841680        // or else we bail on the dragging stuff and allow selection to occur
    1685         if (_mouseDownMayStartDrag && _dragSrcInSelection && [_currentEvent timestamp] - _mouseDownTimestamp < TextDragDelay) {
    1686             _mouseDownMayStartDrag = false;
     1681        if (mouseDownMayStartDrag() && _dragSrcInSelection && [_currentEvent timestamp] - _mouseDownTimestamp < TextDragDelay) {
     1682            setMouseDownMayStartDrag(false);
    16871683            // ...but if this was the first click in the window, we don't even want to start selection
    16881684            if (_activationEventNumber == [_currentEvent eventNumber]) {
     
    16911687        }
    16921688
    1693         if (_mouseDownMayStartDrag) {
     1689        if (mouseDownMayStartDrag()) {
    16941690            // We are starting a text/image/url drag, so the cursor should be an arrow
    16951691            d->m_view->setCursor(pointerCursor());
     
    17241720                    }
    17251721
    1726                     _mouseDownMayStartDrag = dispatchDragSrcEvent(dragstartEvent, m_mouseDown) && mayCopy();
     1722                    setMouseDownMayStartDrag(dispatchDragSrcEvent(dragstartEvent, m_mouseDown) && mayCopy());
    17271723                    // Invalidate clipboard here against anymore pasteboard writing for security.  The drag
    17281724                    // image can still be changed as we drag, but not the pasteboard data.
    17291725                    _dragClipboard->setAccessPolicy(ClipboardMac::ImageWritable);
    17301726                   
    1731                     if (_mouseDownMayStartDrag) {
     1727                    if (mouseDownMayStartDrag()) {
    17321728                        // gather values from DHTML element, if it set any
    17331729                        _dragClipboard->sourceOperation(&srcOp);
     
    17471743                }
    17481744               
    1749                 if (_mouseDownMayStartDrag) {
     1745                if (mouseDownMayStartDrag()) {
    17501746                    BOOL startedDrag = [_bridge startDraggingImage:dragImage at:dragLoc operation:srcOp event:_currentEvent sourceIsDHTML:_dragSrcIsDHTML DHTMLWroteData:wcWrotePasteboard];
    17511747                    if (!startedDrag && _dragSrcMayBeDHTML) {
     
    17531749                        PlatformMouseEvent event(PlatformMouseEvent::currentEvent);
    17541750                        dispatchDragSrcEvent(dragendEvent, event);
    1755                         _mouseDownMayStartDrag = false;
     1751                        setMouseDownMayStartDrag(false);
    17561752                    }
    17571753                }
    17581754
    1759                 if (!_mouseDownMayStartDrag) {
     1755                if (!mouseDownMayStartDrag()) {
    17601756                    // something failed to start the drag, cleanup
    17611757                    freeClipboard();
     
    17671763            return;
    17681764        }
    1769         if (!_mouseDownMayStartSelect && !_mouseDownMayStartAutoscroll) {
     1765        if (!mouseDownMayStartSelect() && !mouseDownMayStartAutoscroll())
    17701766            return;
    1771         }
    1772 
    1773         // Don't allow dragging or click handling after we've started selecting.
    1774         _mouseDownMayStartDrag = false;
    1775         d->m_view->invalidateClick();
    1776 
    1777         Node* node = event.targetNode();
    1778         RenderObject* renderer = 0;
    1779         if (node)
    1780             renderer = node->renderer();
    1781            
    1782         // If the selection is contained in a layer that can scroll, that layer should handle the autoscroll
    1783         // Otherwise, let the bridge handle it so the view can scroll itself.
    1784         while (renderer && !renderer->shouldAutoscroll())
    1785             renderer = renderer->parent();
    1786         if (renderer)
    1787             handleAutoscroll(renderer);
    1788         else {
    1789             if (!d->m_autoscrollTimer.isActive())
    1790                 startAutoscrollTimer();
    1791             [_bridge handleAutoscrollForMouseDragged:_currentEvent];
    1792         }
    17931767           
    17941768    } else {
     
    20091983    _mouseDownTimestamp = [event timestamp];
    20101984
    2011     _mouseDownMayStartDrag = false;
     1985    setMouseDownMayStartDrag(false);
    20121986    _mouseDownMayStartSelect = false;
    2013     _mouseDownMayStartAutoscroll = false;
    2014 
     1987    setMouseDownMayStartAutoscroll(false);
     1988   
    20151989    v->handleMousePressEvent(event);
    20161990   
  • trunk/WebCore/bridge/mac/WebCoreFrameBridge.h

    r16962 r16975  
    626626- (void)allowDHTMLDrag:(BOOL *)flagDHTML UADrag:(BOOL *)flagUA;
    627627- (BOOL)startDraggingImage:(NSImage *)dragImage at:(NSPoint)dragLoc operation:(NSDragOperation)op event:(NSEvent *)event sourceIsDHTML:(BOOL)flag DHTMLWroteData:(BOOL)dhtmlWroteData;
    628 - (void)handleAutoscrollForMouseDragged:(NSEvent *)event;
    629628- (BOOL)mayStartDragAtEventLocation:(NSPoint)location;
    630629
  • trunk/WebCore/page/Frame.cpp

    r16955 r16975  
    19331933        handleMousePressEventSingleClick(event);
    19341934    }
     1935   
     1936   setMouseDownMayStartAutoscroll(mouseDownMayStartSelect() ||
     1937        (d->m_mousePressNode && d->m_mousePressNode->renderer() && d->m_mousePressNode->renderer()->shouldAutoscroll()));
    19351938}
    19361939
     
    19431946    Node *innerNode = event.targetNode();
    19441947
    1945     if (event.event().button() != 0 || !innerNode || !innerNode->renderer() || !mouseDownMayStartSelect() || !innerNode->renderer()->shouldSelect())
    1946         return;
    1947 
    1948     // handle making selection
    1949 
    1950     IntPoint vPoint = view()->windowToContents(event.event().pos());
    1951     VisiblePosition pos(innerNode->renderer()->positionForPoint(vPoint));
    1952 
     1948    if (event.event().button() != 0 || !innerNode || !innerNode->renderer())
     1949        return;
     1950
     1951     if (mouseDownMayStartAutoscroll()) {           
     1952        // If the selection is contained in a layer that can scroll, that layer should handle the autoscroll
     1953        // Otherwise, let the bridge handle it so the view can scroll itself.
     1954        RenderObject* renderer = innerNode->renderer();
     1955        while (renderer && !renderer->shouldAutoscroll())
     1956            renderer = renderer->parent();
     1957        if (renderer)
     1958            handleAutoscroll(renderer);
     1959               
     1960        setMouseDownMayStartDrag(false);
     1961        view()->invalidateClick();
     1962    }
     1963   
     1964    if (mouseDownMayStartSelect() && innerNode->renderer()->shouldSelect()) {
     1965        // handle making selection
     1966        IntPoint vPoint = view()->windowToContents(event.event().pos());       
     1967        VisiblePosition pos(innerNode->renderer()->positionForPoint(vPoint));
     1968
     1969        updateSelectionForMouseDragOverPosition(pos);
     1970    }
     1971
     1972}
     1973
     1974void Frame::updateSelectionForMouseDragOverPosition(const VisiblePosition& pos)
     1975{
    19531976    // Don't modify the selection if we're not on a node.
    19541977    if (pos.isNull())
     
    26282651}
    26292652
     2653bool Frame::mouseDownMayStartAutoscroll() const
     2654{
     2655    return d->m_mouseDownMayStartAutoscroll;
     2656}
     2657
     2658void Frame::setMouseDownMayStartAutoscroll(bool b)
     2659{
     2660    d->m_mouseDownMayStartAutoscroll = b;
     2661}
     2662
     2663bool Frame::mouseDownMayStartDrag() const
     2664{
     2665    return d->m_mouseDownMayStartDrag;
     2666}
     2667
     2668void Frame::setMouseDownMayStartDrag(bool b)
     2669{
     2670    d->m_mouseDownMayStartDrag = b;
     2671}
     2672
    26302673void Frame::handleFallbackContent()
    26312674{
     
    28472890    if (d->m_autoscrollTimer.isActive())
    28482891        return;
    2849     d->m_autoscrollRenderer = renderer;
     2892    setAutoscrollRenderer(renderer);
    28502893    startAutoscrollTimer();
    28512894}
     
    28572900        return;
    28582901    }
    2859     if (d->m_autoscrollRenderer) {
    2860         d->m_autoscrollRenderer->autoscroll();
    2861     }
     2902    if (RenderObject* r = autoscrollRenderer())
     2903        r->autoscroll();
     2904}
     2905
     2906RenderObject* Frame::autoscrollRenderer() const
     2907{
     2908    return d->m_autoscrollRenderer;
     2909}
     2910
     2911void Frame::setAutoscrollRenderer(RenderObject* renderer)
     2912{
     2913    d->m_autoscrollRenderer = renderer;
    28622914}
    28632915
     
    29232975void Frame::stopAutoscrollTimer()
    29242976{
    2925     d->m_autoscrollRenderer = 0;
     2977    setAutoscrollRenderer(0);
    29262978    d->m_autoscrollTimer.stop();
    29272979}
  • trunk/WebCore/page/Frame.h

    r16954 r16975  
    525525  virtual void handleMouseReleaseEvent(const MouseEventWithHitTestResults&);
    526526 
     527  void updateSelectionForMouseDragOverPosition(const VisiblePosition&);
     528
    527529  void selectClosestWordFromMouseEvent(const PlatformMouseEvent&, Node* innerNode);
    528530
     
    641643 
    642644  virtual bool mouseDownMayStartSelect() const { return true; }
    643 
     645  bool mouseDownMayStartAutoscroll() const;
     646  void setMouseDownMayStartAutoscroll(bool b);
     647
     648  bool mouseDownMayStartDrag() const;
     649  void setMouseDownMayStartDrag(bool b);
     650 
    644651  void handleFallbackContent();
    645652
     
    750757
    751758  virtual IntRect windowResizerRect() const { return IntRect(); }
     759 
     760  void stopAutoscrollTimer();
     761  RenderObject* autoscrollRenderer() const;
    752762
    753763protected:
     
    759769    void handleAutoscroll(RenderObject*);
    760770    void startAutoscrollTimer();
    761     void stopAutoscrollTimer();
     771    void setAutoscrollRenderer(RenderObject*);
    762772
    763773 private:
  • trunk/WebCore/page/FramePrivate.h

    r16727 r16975  
    103103            , m_autoscrollTimer(thisFrame, &Frame::autoscrollTimerFired)
    104104            , m_autoscrollRenderer(0)
     105            , m_mouseDownMayStartAutoscroll(false)
     106            , m_mouseDownMayStartDrag(false)
    105107            , m_paintRestriction(PaintRestrictionNone)
    106108            , m_markedTextUsesUnderlines(false)
     
    223225        Timer<Frame> m_autoscrollTimer;
    224226        RenderObject* m_autoscrollRenderer;
     227        bool m_mouseDownMayStartAutoscroll;
     228        bool m_mouseDownMayStartDrag;
    225229       
    226230        RefPtr<Node> m_elementToDraw;
  • trunk/WebCore/page/FrameView.cpp

    r16879 r16975  
    589589
    590590    d->mousePressed = true;
    591     d->m_currentMousePosition = windowToContents(mouseEvent.pos());
     591    d->m_currentMousePosition = mouseEvent.pos();
    592592   
    593593    MouseEventWithHitTestResults mev = prepareMouseEvent(false, true, false, mouseEvent);
     
    648648    // We get this instead of a second mouse-up
    649649    d->mousePressed = false;
    650     d->m_currentMousePosition = windowToContents(mouseEvent.pos());
     650    d->m_currentMousePosition = mouseEvent.pos();
    651651
    652652    MouseEventWithHitTestResults mev = prepareMouseEvent(false, true, false, mouseEvent);
     
    804804
    805805    RefPtr<FrameView> protector(this);
    806     d->m_currentMousePosition = windowToContents(mouseEvent.pos());
     806    d->m_currentMousePosition = mouseEvent.pos();
    807807   
    808808    if (d->hoverTimer.isActive())
     
    880880
    881881    d->mousePressed = false;
    882     d->m_currentMousePosition = windowToContents(mouseEvent.pos());
     882    d->m_currentMousePosition = mouseEvent.pos();
    883883
    884884    if (d->resizingFrameSet) {
  • trunk/WebCore/rendering/RenderLayer.cpp

    r16879 r16975  
    755755
    756756void RenderLayer::autoscroll()
    757 {   
    758     int xOffset = scrollXOffset();
    759     int yOffset = scrollYOffset();
    760 
    761     // Get the rectangle for the extent of the selection
    762     Selection selection(renderer()->document()->frame()->selectionController()->selection());
    763     IntRect extentRect = VisiblePosition(selection.extent()).caretRect();
    764     extentRect.move(xOffset, yOffset);
    765 
    766     IntRect bounds = IntRect(xPos() + xOffset, yPos() + yOffset, width() - verticalScrollbarWidth(), height() - horizontalScrollbarHeight());
    767    
    768     // Calculate how much the layer should scroll horizontally.
    769     int diffX = 0;
    770     if (extentRect.right() > bounds.right())
    771         diffX = extentRect.right() - bounds.right();
    772     else if (extentRect.x() < bounds.x())
    773         diffX = extentRect.x() - bounds.x();
     757{
     758    if (!renderer() || !renderer()->document() || !renderer()->document()->frame() || !renderer()->document()->frame()->view())
     759        return;
    774760       
    775     // Calculate how much the layer should scroll vertically.
    776     int diffY = 0;
    777     if (extentRect.bottom() > bounds.bottom())
    778         diffY = extentRect.bottom() - bounds.bottom();
    779     else if (extentRect.y() < bounds.y())
    780         diffY = extentRect.y() - bounds.y();
    781 
    782     scrollToOffset(xOffset + diffX, yOffset + diffY);
     761    Frame* currentFrame = renderer()->document()->frame();
     762    IntPoint currentPos = currentFrame->view()->windowToContents(currentFrame->view()->currentMousePosition());
     763   
     764    if (currentFrame->mouseDownMayStartSelect()) {
     765        VisiblePosition pos(renderer()->positionForPoint(currentPos));
     766        currentFrame->updateSelectionForMouseDragOverPosition(pos);
     767    }
     768
     769    scrollRectToVisible(IntRect(currentPos, IntSize(1, 1)), gAlignToEdgeIfNeeded, gAlignToEdgeIfNeeded);   
    783770}
    784771
  • trunk/WebCore/rendering/RenderListBox.cpp

    r16836 r16975  
    356356void RenderListBox::autoscroll()
    357357{
    358     int mouseX = document()->frame()->view()->currentMousePosition().x();
    359     int mouseY = document()->frame()->view()->currentMousePosition().y();
     358    IntPoint pos = document()->frame()->view()->windowToContents(document()->frame()->view()->currentMousePosition());
    360359    IntRect bounds = absoluteBoundingBoxRect();
    361360
     
    365364    int rows = size();
    366365    int offset = m_indexOffset;
    367     if (mouseY < bounds.y() && scrollToRevealElementAtListIndex(offset - 1) && items[offset - 1]->hasTagName(optionTag))
     366    if (pos.y() < bounds.y() && scrollToRevealElementAtListIndex(offset - 1) && items[offset - 1]->hasTagName(optionTag))
    368367        element = static_cast<HTMLOptionElement*>(items[offset - 1]);
    369     else if (mouseY > bounds.bottom() && scrollToRevealElementAtListIndex(offset + rows) && items[offset + rows - 1]->hasTagName(optionTag))
     368    else if (pos.y() > bounds.bottom() && scrollToRevealElementAtListIndex(offset + rows) && items[offset + rows - 1]->hasTagName(optionTag))
    370369        element = static_cast<HTMLOptionElement*>(items[offset + rows - 1]);
    371370    else
    372         element = optionAtPoint(mouseX, mouseY);
     371        element = optionAtPoint(pos.x(), pos.y());
    373372       
    374373    if (element) {
  • trunk/WebCore/rendering/RenderObject.cpp

    r16721 r16975  
    686686bool RenderObject::shouldAutoscroll() const
    687687{
    688     return (hasOverflowClip() && (scrollsOverflow() || (node() && node()->isContentEditable())));
     688    return ((isRoot()) || (hasOverflowClip() && (scrollsOverflow() || (node() && node()->isContentEditable()))));
    689689}
    690690
     
    24212421void RenderObject::destroy()
    24222422{
     2423    // If this renderer is being autoscrolled, stop the autoscroll timer
     2424    if (document() && document()->frame() && document()->frame()->autoscrollRenderer() == this)
     2425        document()->frame()->stopAutoscrollTimer();
     2426
    24232427    if (m_hasCounterNodeMap) {
    24242428        RenderObjectsToCounterNodeMaps* objectsMap = getRenderObjectsToCounterNodeMaps();
  • trunk/WebKit/ChangeLog

    r16970 r16975  
     12006-10-10  Adele Peterson  <adele@apple.com>
     2
     3        Reviewed by Beth.
     4
     5        Removed handleAutoscrollForMouseDragged.  Except for autoscroll caused by drag and drop, all other
     6        autoscrolling should be done in WebCore instead of in AppKit.
     7
     8        * WebCoreSupport/WebFrameBridge.m:
     9        * WebView/WebHTMLView.m:
     10        * WebView/WebHTMLViewPrivate.h:
     11
    1122006-10-10  Darin Adler  <darin@apple.com>
    213
  • trunk/WebKit/WebCoreSupport/WebFrameBridge.m

    r16967 r16975  
    12031203}
    12041204
    1205 - (void)handleAutoscrollForMouseDragged:(NSEvent *)event;
    1206 {
    1207     WebHTMLView *docView = (WebHTMLView *)[[_frame frameView] documentView];
    1208 
    1209     ASSERT([docView isKindOfClass:[WebHTMLView class]]);
    1210 
    1211     [docView _handleAutoscrollForMouseDragged:event];
    1212 }
    1213 
    12141205- (BOOL)mayStartDragAtEventLocation:(NSPoint)location
    12151206{
  • trunk/WebKit/WebView/WebHTMLView.m

    r16967 r16975  
    14661466    }
    14671467    return startedDrag;
    1468 }
    1469 
    1470 - (void)_handleAutoscrollForMouseDragged:(NSEvent *)event
    1471 {
    1472     [self autoscroll:event];
    1473     [self _startAutoscrollTimer:event];
    14741468}
    14751469
  • trunk/WebKit/WebView/WebHTMLViewPrivate.h

    r16593 r16975  
    7070- (NSImage *)_dragImageForLinkElement:(NSDictionary *)element;
    7171- (BOOL)_startDraggingImage:(NSImage *)dragImage at:(NSPoint)dragLoc operation:(NSDragOperation)op event:(NSEvent *)event sourceIsDHTML:(BOOL)flag DHTMLWroteData:(BOOL)dhtmlWroteData;
    72 - (void)_handleAutoscrollForMouseDragged:(NSEvent *)event;
    7372- (BOOL)_mayStartDragAtEventLocation:(NSPoint)location;
    7473
Note: See TracChangeset for help on using the changeset viewer.