Changeset 13302 in webkit


Ignore:
Timestamp:
Mar 15, 2006 1:05:41 AM (18 years ago)
Author:
adele
Message:

Reviewed by Maciej.

No test case. There doesn't appear to be a way to trigger the autoscroll with the EventSender.

  • bridge/mac/MacFrame.mm: (WebCore::MacFrame::khtmlMouseMoveEvent): If we have a layer that can scroll, let the layer handle its autoscroll. Otherwise, call over the bridge to let AppKit scroll the view. (WebCore::MacFrame::khtmlMouseReleaseEvent): Stops the autoscroll timer.
  • page/Frame.cpp: (WebCore::Frame::khtmlMouseReleaseEvent): Stops the autoscroll timer. (WebCore::Frame::handleAutoscroll): Added. Saves the layer, and starts the timer. (WebCore::Frame::autoscrollTimerFired): Added. Calls autoscroll() on the layer. (WebCore::Frame::startAutoscrollTimer): Added. (WebCore::Frame::stopAutoscrollTimer): Added.
  • page/Frame.h: Added new autoscroll methods.
  • page/FramePrivate.h: (WebCore::FramePrivate::FramePrivate): Initialize m_autoscrollTimer and m_autoscrollLayer.
  • rendering/render_layer.cpp: (WebCore::RenderLayer::autoscroll): Calculates how much the layer should scroll, and actually scrolls. (WebCore::RenderLayer::shouldAutoscroll): If the layer has overflow then it should be able to scroll. Except for overflow:hidden areas that aren't editable. In the future, we may want to have a css property that indicates an overflow:hidden style that should also scroll.
  • rendering/render_layer.h: Added new autoscroll methods.
Location:
trunk/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r13301 r13302  
     12006-03-15  Adele Peterson  <adele@apple.com>
     2
     3        Reviewed by Maciej.
     4
     5        - Fix for http://bugzilla.opendarwin.org/show_bug.cgi?id=7114
     6        Dragging to scroll doesn't work for overflow areas
     7
     8        No test case.  There doesn't appear to be a way to trigger the autoscroll with the EventSender.
     9
     10        * bridge/mac/MacFrame.mm:
     11        (WebCore::MacFrame::khtmlMouseMoveEvent):  If we have a layer that can scroll, let the layer handle its autoscroll. 
     12         Otherwise, call over the bridge to let AppKit scroll the view.
     13        (WebCore::MacFrame::khtmlMouseReleaseEvent): Stops the autoscroll timer.
     14        * page/Frame.cpp:
     15        (WebCore::Frame::khtmlMouseReleaseEvent): Stops the autoscroll timer.
     16        (WebCore::Frame::handleAutoscroll): Added. Saves the layer, and starts the timer.
     17        (WebCore::Frame::autoscrollTimerFired): Added. Calls autoscroll() on the layer.
     18        (WebCore::Frame::startAutoscrollTimer): Added.
     19        (WebCore::Frame::stopAutoscrollTimer): Added.
     20        * page/Frame.h: Added new autoscroll methods.
     21        * page/FramePrivate.h: (WebCore::FramePrivate::FramePrivate): Initialize m_autoscrollTimer and m_autoscrollLayer.
     22        * rendering/render_layer.cpp:
     23        (WebCore::RenderLayer::autoscroll): Calculates how much the layer should scroll, and actually scrolls.
     24        (WebCore::RenderLayer::shouldAutoscroll): If the layer has overflow then it should be able to scroll. 
     25         Except for overflow:hidden areas that aren't editable. 
     26         In the future, we may want to have a css property that indicates an overflow:hidden style that should also scroll.
     27        * rendering/render_layer.h: Added new autoscroll methods.
     28
    1292006-03-14  Justin Garcia  <justin.garcia@apple.com>
    230
  • trunk/WebCore/bridge/mac/MacFrame.mm

    r13260 r13302  
    17631763        d->m_view->invalidateClick();
    17641764
    1765         // We use khtml's selection but our own autoscrolling.
    1766         [_bridge handleAutoscrollForMouseDragged:_currentEvent];
     1765        NodeImpl* node = event->innerNode();
     1766        RenderLayer* layer = 0;
     1767        if (node && node->renderer())
     1768            layer = node->renderer()->enclosingLayer();
     1769           
     1770        // If the selection began in a layer that can scroll, the layer should handle the autoscroll
     1771        // Otherwise, let the bridge handle it so the view can scroll itself.
     1772        if (layer && layer->shouldAutoscroll())
     1773            handleAutoscroll(layer);
     1774        else
     1775            [_bridge handleAutoscrollForMouseDragged:_currentEvent];
     1776           
    17671777    } else {
    17681778        // If we allowed the other side of the bridge to handle a drag
     
    18581868        return;
    18591869    }
     1870    stopAutoscrollTimer();
    18601871   
    18611872    _sendingEventToSubview = true;
  • trunk/WebCore/page/Frame.cpp

    r13301 r13302  
    7272#include "render_canvas.h"
    7373#include "render_frames.h"
     74#include "render_layer.h"
    7475#include "visible_text.h"
    7576#include "visible_units.h"
     
    103104
    104105const double caretBlinkFrequency = 0.5;
     106const double autoscrollInterval = 0.1;
    105107
    106108class UserStyleSheetLoader : public CachedObjectClient {
     
    18801882void Frame::khtmlMouseReleaseEvent(MouseEventWithHitTestResults* event)
    18811883{
     1884    stopAutoscrollTimer();
     1885   
    18821886    // Used to prevent mouseMoveEvent from initiating a drag before
    18831887    // the mouse is pressed again.
     
    26712675}
    26722676
     2677void Frame::handleAutoscroll(RenderLayer* layer)
     2678{
     2679    if (d->m_autoscrollTimer.isActive())
     2680        return;
     2681    d->m_autoscrollLayer = layer;
     2682    startAutoscrollTimer();
     2683}
     2684
     2685void Frame::autoscrollTimerFired(Timer<Frame>*)
     2686{
     2687    bool isStillDown = CGEventSourceButtonState(kCGEventSourceStateCombinedSessionState, kCGMouseButtonLeft);   
     2688    if (!isStillDown){
     2689        stopAutoscrollTimer();
     2690        return;
     2691    }
     2692    if (d->m_autoscrollLayer) {
     2693        d->m_autoscrollLayer->autoscroll();
     2694    }
     2695}
     2696
     2697void Frame::startAutoscrollTimer()
     2698{
     2699    d->m_autoscrollTimer.startRepeating(autoscrollInterval);
     2700}
     2701
     2702void Frame::stopAutoscrollTimer()
     2703{
     2704    d->m_autoscrollTimer.stop();
     2705}
     2706
    26732707// FIXME: why is this here instead of on the FrameView?
    26742708void Frame::paint(GraphicsContext* p, const IntRect& rect)
  • trunk/WebCore/page/Frame.h

    r13260 r13302  
    7070class MouseEventWithHitTestResults;
    7171class RangeImpl;
     72class RenderLayer;
    7273class Selection;
    7374class SelectionController;
     
    778779    virtual void startRedirectionTimer();
    779780    virtual void stopRedirectionTimer();
     781   
     782    void handleAutoscroll(RenderLayer*);
     783    void startAutoscrollTimer();
     784    void stopAutoscrollTimer();
    780785
    781786 private:
     
    800805
    801806    virtual void setStatusBarText(const String&);
     807   
     808    void autoscrollTimerFired(Timer<Frame>*);
    802809
    803810public:
  • trunk/WebCore/page/FramePrivate.h

    r13260 r13302  
    9595            , m_lifeSupportTimer(thisFrame, &Frame::lifeSupportTimerFired)
    9696            , m_userStyleSheetLoader(0)
     97            , m_autoscrollTimer(thisFrame, &Frame::autoscrollTimerFired)
     98            , m_autoscrollLayer(0)
    9799        {
    98100        }
     
    202204
    203205        UserStyleSheetLoader* m_userStyleSheetLoader;
     206       
     207        Timer<Frame> m_autoscrollTimer;
     208        RenderLayer* m_autoscrollLayer;
    204209    };
    205210
  • trunk/WebCore/rendering/render_layer.cpp

    r13291 r13302  
    4848#include "EventNames.h"
    4949#include "FrameView.h"
     50#include "Frame.h"
    5051#include "GraphicsContext.h"
    5152#include "dom2_eventsimpl.h"
     
    5657#include "render_inline.h"
    5758#include "render_theme.h"
     59#include "SelectionController.h"
    5860#include <assert.h>
    5961#include <kxmlcore/Vector.h>
     
    725727
    726728    return IntRect(IntPoint(x, y), visibleRect.size());
     729}
     730
     731void RenderLayer::autoscroll()
     732{   
     733    int xOffset = scrollXOffset();
     734    int yOffset = scrollYOffset();
     735
     736    // Get the rectangle for the extent of the selection
     737    SelectionController sel = renderer()->document()->frame()->selection();
     738    IntRect extentRect = SelectionController(sel.extent(), sel.affinity()).caretRect();
     739    extentRect.move(xOffset, yOffset);
     740
     741    IntRect bounds = IntRect(xPos() + xOffset, yPos() + yOffset, width() - verticalScrollbarWidth(), height() - horizontalScrollbarHeight());
     742   
     743    // Calculate how much the layer should scroll horizontally.
     744    int diffX = 0;
     745    if (extentRect.right() > bounds.right())
     746        diffX = extentRect.right() - bounds.right();
     747    else if (extentRect.x() < bounds.x())
     748        diffX = extentRect.x() - bounds.x();
     749       
     750    // Calculate how much the layer should scroll vertically.
     751    int diffY = 0;
     752    if (extentRect.bottom() > bounds.bottom())
     753        diffY = extentRect.bottom() - bounds.bottom();
     754    else if (extentRect.y() < bounds.y())
     755        diffY = extentRect.y() - bounds.y();
     756
     757    scrollToOffset(xOffset + diffX, yOffset + diffY);
     758}
     759
     760bool RenderLayer::shouldAutoscroll()
     761{
     762    if (renderer()->hasOverflowClip() && (m_object->style()->overflow() != OHIDDEN || renderer()->node()->isContentEditable()))
     763        return true;
     764    return false;
    727765}
    728766
  • trunk/WebCore/rendering/render_layer.h

    r13291 r13302  
    247247    void slotValueChanged(int);
    248248    bool scroll(KWQScrollDirection direction, KWQScrollGranularity granularity, float multiplier=1.0);
     249    void autoscroll();
     250    bool shouldAutoscroll();
    249251   
    250252    void updateLayerPosition();
Note: See TracChangeset for help on using the changeset viewer.