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

Adele adele at opensource.apple.com
Wed Dec 14 20:52:00 PST 2005


adele       05/12/14 20:52:00

  Modified:    .        Tag: Safari-2-0-branch ChangeLog
               khtml/rendering Tag: Safari-2-0-branch render_layer.cpp
               kwq      Tag: Safari-2-0-branch KWQScrollView.h
                        KWQScrollView.mm
  Log:
          Merged fix from TOT to Safari-2-0-branch
  
      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).
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.105 +24 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.1.2.104
  retrieving revision 1.1.2.105
  diff -u -r1.1.2.104 -r1.1.2.105
  --- ChangeLog	14 Dec 2005 22:49:47 -0000	1.1.2.104
  +++ ChangeLog	15 Dec 2005 04:51:49 -0000	1.1.2.105
  @@ -1,3 +1,27 @@
  +2005-12-14  Adele Peterson  <adele at apple.com>
  +
  +        Merged fix from TOT to Safari-2-0-branch
  +
  +    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  Timothy Hatcher  <timothy at apple.com>
   
           Merged fix from TOT to Safari-2-0-branch
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.94.6.8  +23 -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.94.6.7
  retrieving revision 1.94.6.8
  diff -u -r1.94.6.7 -r1.94.6.8
  --- render_layer.cpp	2 Dec 2005 21:13:02 -0000	1.94.6.7
  +++ render_layer.cpp	15 Dec 2005 04:51:58 -0000	1.94.6.8
  @@ -558,14 +558,15 @@
   {
       RenderLayer* parentLayer = 0;
       QRect newRect = rect;
  +    int xOffset = 0, yOffset = 0;
       
       if (m_object->hasOverflowClip()) {
           QRect layerBounds = QRect(m_x + m_scrollX, m_y + m_scrollY, m_width, m_height);
           QRect exposeRect = QRect(rect.x() + m_scrollX, 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));
  @@ -584,15 +585,28 @@
               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);
  +            }
           }
       }
       
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.39.8.2  +3 -0      WebCore/kwq/KWQScrollView.h
  
  Index: KWQScrollView.h
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQScrollView.h,v
  retrieving revision 1.39.8.1
  retrieving revision 1.39.8.2
  diff -u -r1.39.8.1 -r1.39.8.2
  --- KWQScrollView.h	12 Nov 2005 01:57:18 -0000	1.39.8.1
  +++ KWQScrollView.h	15 Dec 2005 04:51:59 -0000	1.39.8.2
  @@ -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.80.8.5  +45 -6     WebCore/kwq/KWQScrollView.mm
  
  Index: KWQScrollView.mm
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQScrollView.mm,v
  retrieving revision 1.80.8.4
  retrieving revision 1.80.8.5
  diff -u -r1.80.8.4 -r1.80.8.5
  --- KWQScrollView.mm	12 Dec 2005 23:53:22 -0000	1.80.8.4
  +++ KWQScrollView.mm	15 Dec 2005 04:51:59 -0000	1.80.8.5
  @@ -154,6 +154,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();
  @@ -169,28 +193,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