[webkit-changes] cvs commit: WebCore/kwq KWQScrollView.h KWQScrollView.mm

Adele adele at opensource.apple.com
Wed Dec 14 20:29:53 PST 2005


adele       05/12/14 20:29:52

  Modified:    .        ChangeLog
               khtml/rendering render_layer.cpp
               kwq      KWQScrollView.h KWQScrollView.mm
  Log:
          Reviewed by NOBODY (OOPS!).
  
          - fixed <rdar://problem/4375502> 10.4.4 REGRESSION: Clicking on anchor tag in email causes unwanted horizontal scroll
  
          When scrolling views, we were failing to take the current scroll position into account when calculating the new scroll position.
  
          * kwq/KWQScrollView.h: Added scrollPointRecursively.
          * kwq/KWQScrollView.mm:
          (QScrollView::scrollXOffset): Calculates the x-coordinate scroll offset for a view.
          (QScrollView::scrollYOffset): Calculates the y-coordinate scroll offset for a view.
          (QScrollView::scrollPointRecursively): This function walks up the view hierarchy to scroll to a point.
          I moved this from setContentsPos so that function would only have an effect on the current view.
          (QScrollView::setContentsPos): return to old behavior where this function calls scrollPoint on a view and doesn't recurse.
  
          * khtml/rendering/render_layer.cpp: (khtml::RenderLayer::scrollRectToVisible):
          Uses new QScrollView functions scrollXOffset and scrollYOffset to correctly calculate how a view should scroll.
          Also determines whether or not QScrollView should try to scroll recursively (which happens when scrollRectToVisible is done calling itself recursively).
  
  Revision  Changes    Path
  1.533     +20 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.532
  retrieving revision 1.533
  diff -u -r1.532 -r1.533
  --- ChangeLog	14 Dec 2005 23:31:33 -0000	1.532
  +++ ChangeLog	15 Dec 2005 04:29:45 -0000	1.533
  @@ -1,3 +1,23 @@
  +2005-12-14  Adele Peterson  <adele at apple.com>
  +
  +        Reviewed by Darin and Tim Hatcher.
  +
  +        - fixed <rdar://problem/4375502> 10.4.4 REGRESSION: Clicking on anchor tag in email causes unwanted horizontal scroll
  +
  +        When scrolling views, we were failing to take the current scroll position into account when calculating the new scroll position. 
  +
  +        * kwq/KWQScrollView.h: Added scrollPointRecursively.
  +        * kwq/KWQScrollView.mm:
  +        (QScrollView::scrollXOffset): Calculates the x-coordinate scroll offset for a view.
  +        (QScrollView::scrollYOffset): Calculates the y-coordinate scroll offset for a view.
  +        (QScrollView::scrollPointRecursively): This function walks up the view hierarchy to scroll to a point.  
  +        I moved this from setContentsPos so that function would only have an effect on the current view.
  +        (QScrollView::setContentsPos): return to old behavior where this function calls scrollPoint on a view and doesn't recurse.
  +
  +        * khtml/rendering/render_layer.cpp: (khtml::RenderLayer::scrollRectToVisible): 
  +        Uses new QScrollView functions scrollXOffset and scrollYOffset to correctly calculate how a view should scroll.
  +        Also determines whether or not QScrollView should try to scroll recursively (which happens when scrollRectToVisible is done calling itself recursively).
  +
   2005-12-14  Eric Seidel  <eseidel at apple.com>
   
           Reviewed by darin.
  
  
  
  1.129     +22 -9     WebCore/khtml/rendering/render_layer.cpp
  
  Index: render_layer.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/rendering/render_layer.cpp,v
  retrieving revision 1.128
  retrieving revision 1.129
  diff -u -r1.128 -r1.129
  --- render_layer.cpp	10 Dec 2005 20:21:56 -0000	1.128
  +++ render_layer.cpp	15 Dec 2005 04:29:51 -0000	1.129
  @@ -557,14 +557,15 @@
   {
       RenderLayer* parentLayer = 0;
       QRect newRect = rect;
  +    int xOffset = 0, yOffset = 0;
       
       if (m_object->hasOverflowClip()) {
           QRect layerBounds = QRect(m_x + scrollXOffset(), m_y + m_scrollY, m_width, m_height);
           QRect exposeRect = QRect(rect.x() + scrollXOffset(), rect.y() + m_scrollY, rect.width(), rect.height());
           QRect r = getRectToExpose(layerBounds, exposeRect, alignX, alignY);
           
  -        int xOffset = r.x() - m_x;
  -        int yOffset = r.y() - m_y;
  +        xOffset = r.x() - m_x;
  +        yOffset = r.y() - m_y;
           // Adjust offsets if they're outside of the allowable range.
           xOffset = kMax(0, kMin(m_scrollWidth - m_width, xOffset));
           yOffset = kMax(0, kMin(m_scrollHeight - m_height, yOffset));
  @@ -583,15 +584,27 @@
               parentLayer = m_object->parent()->enclosingLayer();
       } else {
           QScrollView* view = m_object->document()->view();
  -        QRect viewRect = QRect(view->contentsX(), view->contentsY(), view->visibleWidth(), view->visibleHeight());
           if (view) {
  +            QRect viewRect = QRect(view->scrollXOffset(), view->scrollYOffset(), view->visibleWidth(), view->visibleHeight());
               QRect r = getRectToExpose(viewRect, rect, alignX, alignY);
  -            view->setContentsPos(r.x(), r.y());
  -        }
  -        if (m_object->document() && m_object->document()->ownerElement() && m_object->document()->ownerElement()->renderer()) {
  -            parentLayer = m_object->document()->ownerElement()->renderer()->enclosingLayer();
  -            newRect.setX(rect.x() - view->contentsX() + view->viewport()->x());
  -            newRect.setY(rect.y() - view->contentsY() + view->viewport()->y());
  +            
  +            xOffset = r.x();
  +            yOffset = r.y();
  +            // Adjust offsets if they're outside of the allowable range.
  +            xOffset = kMax(0, kMin(view->contentsWidth(), xOffset));
  +            yOffset = kMax(0, kMin(view->contentsHeight(), yOffset));
  +            
  +
  +            if (m_object->document() && m_object->document()->ownerElement() && m_object->document()->ownerElement()->renderer()) {
  +                view->setContentsPos(xOffset, yOffset);
  +                parentLayer = m_object->document()->ownerElement()->renderer()->enclosingLayer();
  +                newRect.setX(rect.x() - view->contentsX() + view->viewport()->x());
  +                newRect.setY(rect.y() - view->contentsY() + view->viewport()->y());
  +            } else {
  +                // If this is the outermost view that RenderLayer needs to scroll, then we should scroll the view recursively
  +                // Other apps, like Mail, rely on this feature.
  +                view->scrollPointRecursively(xOffset, yOffset);
  +            }
           }
       }
       
  
  
  
  1.42      +3 -0      WebCore/kwq/KWQScrollView.h
  
  Index: KWQScrollView.h
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQScrollView.h,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- KWQScrollView.h	3 Nov 2005 19:12:06 -0000	1.41
  +++ KWQScrollView.h	15 Dec 2005 04:29:52 -0000	1.42
  @@ -47,7 +47,10 @@
       int contentsHeight() const;
       int contentsX() const;
       int contentsY() const;
  +    int scrollXOffset() const;
  +    int scrollYOffset() const;
       void scrollBy(int dx, int dy);
  +    void scrollPointRecursively(int dx, int dy);
   
       void setContentsPos(int x, int y);
   
  
  
  
  1.88      +45 -6     WebCore/kwq/KWQScrollView.mm
  
  Index: KWQScrollView.mm
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQScrollView.mm,v
  retrieving revision 1.87
  retrieving revision 1.88
  diff -u -r1.87 -r1.88
  --- KWQScrollView.mm	9 Dec 2005 23:48:57 -0000	1.87
  +++ KWQScrollView.mm	15 Dec 2005 04:29:52 -0000	1.88
  @@ -155,6 +155,30 @@
       return 0;
   }
   
  +int QScrollView::scrollXOffset() const
  +{
  +    NSView *view = getView();
  +    
  +    KWQ_BLOCK_EXCEPTIONS;
  +    if ([view _KWQ_isScrollView]) {
  +        return (int)[[(NSScrollView *)view contentView] visibleRect].origin.x;
  +    }
  +    KWQ_UNBLOCK_EXCEPTIONS;
  +    return 0;
  +}
  +
  +int QScrollView::scrollYOffset() const
  +{
  +    NSView *view = getView();
  +    
  +    KWQ_BLOCK_EXCEPTIONS;
  +    if ([view _KWQ_isScrollView]) {
  +        return (int)[[(NSScrollView *)view contentView] visibleRect].origin.y;
  +    }
  +    KWQ_UNBLOCK_EXCEPTIONS;
  +    return 0;
  +}
  +
   int QScrollView::childX(QWidget* w)
   {
       return w->x();
  @@ -170,28 +194,43 @@
       setContentsPos(contentsX() + dx, contentsY() + dy);
   }
   
  -void QScrollView::setContentsPos(int x, int y)
  -{
  +void QScrollView::scrollPointRecursively(int x, int y)
  +{ 
       x = (x < 0) ? 0 : x;
       y = (y < 0) ? 0 : y;
  -    NSPoint p =  NSMakePoint(x,y);
  -
  +    NSPoint p = NSMakePoint(x,y);
  +    
       KWQ_BLOCK_EXCEPTIONS;
       NSView *docView;
       NSView *view = getView();    
       docView = getDocumentView();
       if (docView)
           view = docView;
  -        
  +    
       NSView *originalView = view;
       while (view) {
           if ([view isKindOfClass:[NSClipView class]]) {
               NSPoint viewPoint = [view convertPoint:p fromView:originalView];
  -            [view scrollRectToVisible:NSMakeRect(viewPoint.x, viewPoint.y, 1, NSHeight([view bounds]))];
  +            [view scrollPoint:viewPoint];
           }
           view = [view superview];
       }
  +    KWQ_UNBLOCK_EXCEPTIONS;
  +}
  +
  +void QScrollView::setContentsPos(int x, int y)
  +{
  +    x = (x < 0) ? 0 : x;
  +    y = (y < 0) ? 0 : y;
  +    NSPoint p =  NSMakePoint(x,y);
   
  +    KWQ_BLOCK_EXCEPTIONS;
  +    NSView *docView;
  +    NSView *view = getView();    
  +    docView = getDocumentView();
  +    if (docView)
  +        view = docView;
  +    [view scrollPoint:p];
       KWQ_UNBLOCK_EXCEPTIONS;
   }
   
  
  
  



More information about the webkit-changes mailing list