[webkit-changes] cvs commit: WebKit/WebView.subproj WebFrameView.m WebFrameViewPrivate.h WebPDFView.m WebView.m

John sullivan at opensource.apple.com
Thu Jan 5 15:57:13 PST 2006


sullivan    06/01/05 15:57:13

  Modified:    .        ChangeLog
               WebView.subproj WebFrameView.m WebFrameViewPrivate.h
                        WebPDFView.m WebView.m
  Log:
          Reviewed by Tim O.
  
          - fixed these bugs:
          <rdar://problem/3021785> page up/down don't work on frameset pages unless you click
          <rdar://problem/3021788> Page Up/Down moves an unscrollable frame if you click on it first
  
          and the WebKit part of this (need new Safari too for complete fix):
          <rdar://problem/4378905> Page up/down don't work in PDFs when address field is focused
  
          I moved some logic down from Safari that dealt with finding the largest scrollable child frame in a frameset,
          and added support for standard scrolling-related selectors to WebPDFView. The latter was needed for 4378905;
          the former was needed due to side effects of the Safari part of the change. As long as I was doing the former,
          I also used that logic to fix 3021785 and 3021788.
  
          * WebView.subproj/WebFrameViewPrivate.h:
          new currently-private methods _hasScrollBars and _largestChildWithScrollBars
  
          * WebView.subproj/WebFrameView.m:
          (-[WebFrameView scrollToBeginningOfDocument:]):
          if we don't have scroll bars, operate on our largest child with scroll bars instead
          (-[WebFrameView scrollToEndOfDocument:]):
          ditto
          (-[WebFrameView _pageVertically:]):
          ditto
          (-[WebFrameView _pageHorizontally:]):
          ditto
          (-[WebFrameView _scrollLineVertically:]):
          ditto
          (-[WebFrameView _scrollLineHorizontally:]):
          ditto
          (-[WebFrameView keyDown:]):
          where we were bailing out if ![self allowsScrolling], also check for whether there's a
          child with scroll bars, and don't bail out if so
          (-[WebFrameView _area]):
          new helper method used to implement _largestChildWithScrollBars (code moved from Safari)
          (-[WebFrameView _hasScrollBars]):
          new method, just returns YES if either scroll bar is showing (code moved from Safari)
          (-[WebFrameView _largestChildWithScrollBars]):
          new method, returns the child with the largest area that is showing at least one scroll bar
          (code moved from Safari and tweaked a little)
  
          * WebView.subproj/WebPDFView.m:
          (-[WebPDFView _fakeKeyEventWithFunctionKey:]):
          new method, hackaround for the fact that PDFView handles key downs from standard scrolling keys
          but does not implement the standard responder selectors
          (-[WebPDFView scrollPageDown:]):
          use _fakeKeyEventWithFunctionKey: to get the PDFView to scroll appropriately
          (-[WebPDFView scrollPageUp:]):
          ditto
          (-[WebPDFView scrollToBeginningOfDocument:]):
          ditto
          (-[WebPDFView scrollToEndOfDocument:]):
          ditto
  
          * WebView.subproj/WebView.m:
          add scrollToBeginningOfDocument and scrollToEndOfDocument to the list of responder operations
          that we hand off appropriately to the responder chain. These two aren't defined in any header
          but are generated by Home and End keys and used by the text system.
  
  Revision  Changes    Path
  1.3444    +61 -0     WebKit/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebKit/ChangeLog,v
  retrieving revision 1.3443
  retrieving revision 1.3444
  diff -u -r1.3443 -r1.3444
  --- ChangeLog	5 Jan 2006 22:23:04 -0000	1.3443
  +++ ChangeLog	5 Jan 2006 23:57:04 -0000	1.3444
  @@ -1,3 +1,64 @@
  +2006-01-05  John Sullivan  <sullivan at apple.com>
  +
  +        Reviewed by Tim O.
  +        
  +        - fixed these bugs:
  +        <rdar://problem/3021785> page up/down don't work on frameset pages unless you click        
  +        <rdar://problem/3021788> Page Up/Down moves an unscrollable frame if you click on it first
  +        
  +        and the WebKit part of this (need new Safari too for complete fix):
  +        <rdar://problem/4378905> Page up/down don't work in PDFs when address field is focused
  +        
  +        I moved some logic down from Safari that dealt with finding the largest scrollable child frame in a frameset,
  +        and added support for standard scrolling-related selectors to WebPDFView. The latter was needed for 4378905;
  +        the former was needed due to side effects of the Safari part of the change. As long as I was doing the former,
  +        I also used that logic to fix 3021785 and 3021788.
  +        
  +        * WebView.subproj/WebFrameViewPrivate.h:
  +        new currently-private methods _hasScrollBars and _largestChildWithScrollBars
  +
  +        * WebView.subproj/WebFrameView.m:
  +        (-[WebFrameView scrollToBeginningOfDocument:]):
  +        if we don't have scroll bars, operate on our largest child with scroll bars instead
  +        (-[WebFrameView scrollToEndOfDocument:]):
  +        ditto
  +        (-[WebFrameView _pageVertically:]):
  +        ditto
  +        (-[WebFrameView _pageHorizontally:]):
  +        ditto
  +        (-[WebFrameView _scrollLineVertically:]):
  +        ditto
  +        (-[WebFrameView _scrollLineHorizontally:]):
  +        ditto
  +        (-[WebFrameView keyDown:]):
  +        where we were bailing out if ![self allowsScrolling], also check for whether there's a
  +        child with scroll bars, and don't bail out if so
  +        (-[WebFrameView _area]):
  +        new helper method used to implement _largestChildWithScrollBars (code moved from Safari)
  +        (-[WebFrameView _hasScrollBars]):
  +        new method, just returns YES if either scroll bar is showing (code moved from Safari)
  +        (-[WebFrameView _largestChildWithScrollBars]):
  +        new method, returns the child with the largest area that is showing at least one scroll bar
  +        (code moved from Safari and tweaked a little)
  +        
  +        * WebView.subproj/WebPDFView.m:
  +        (-[WebPDFView _fakeKeyEventWithFunctionKey:]):
  +        new method, hackaround for the fact that PDFView handles key downs from standard scrolling keys
  +        but does not implement the standard responder selectors
  +        (-[WebPDFView scrollPageDown:]):
  +        use _fakeKeyEventWithFunctionKey: to get the PDFView to scroll appropriately
  +        (-[WebPDFView scrollPageUp:]):
  +        ditto
  +        (-[WebPDFView scrollToBeginningOfDocument:]):
  +        ditto
  +        (-[WebPDFView scrollToEndOfDocument:]):
  +        ditto
  +        
  +        * WebView.subproj/WebView.m:
  +        add scrollToBeginningOfDocument and scrollToEndOfDocument to the list of responder operations
  +        that we hand off appropriately to the responder chain. These two aren't defined in any header
  +        but are generated by Home and End keys and used by the text system.
  +
   2006-01-05  Geoffrey Garen  <ggaren at apple.com>
   
           Reviewed by Darin.
  
  
  
  1.192     +71 -17    WebKit/WebView.subproj/WebFrameView.m
  
  Index: WebFrameView.m
  ===================================================================
  RCS file: /cvs/root/WebKit/WebView.subproj/WebFrameView.m,v
  retrieving revision 1.191
  retrieving revision 1.192
  diff -u -r1.191 -r1.192
  --- WebFrameView.m	29 Dec 2005 22:02:39 -0000	1.191
  +++ WebFrameView.m	5 Jan 2006 23:57:11 -0000	1.192
  @@ -36,6 +36,7 @@
   #import <WebKit/WebDynamicScrollBarsView.h>
   #import <WebKit/WebFrame.h>
   #import <WebKit/WebFrameViewInternal.h>
  +#import <WebKit/WebFrameViewPrivate.h>
   #import <WebKit/WebHTMLViewPrivate.h>
   #import <WebKit/WebGraphicsBridge.h>
   #import <WebKit/WebImageRenderer.h>
  @@ -514,6 +515,12 @@
   - (void)scrollToBeginningOfDocument:(id)sender
   {
       if (![self _scrollOverflowInDirection:WebScrollUp granularity:WebScrollDocument]) {
  +
  +        if (![self _hasScrollBars]) {
  +            [[self _largestChildWithScrollBars] scrollToBeginningOfDocument:sender];
  +            return;
  +        }
  +
           [[self _contentView] scrollPoint:[[[self _scrollView] documentView] frame].origin];
       }
   }
  @@ -521,6 +528,12 @@
   - (void)scrollToEndOfDocument:(id)sender
   {
       if (![self _scrollOverflowInDirection:WebScrollDown granularity:WebScrollDocument]) {
  +
  +        if (![self _hasScrollBars]) {
  +            [[self _largestChildWithScrollBars] scrollToEndOfDocument:sender];
  +            return;
  +        }
  +        
           NSRect frame = [[[self _scrollView] documentView] frame];
           [[self _contentView] scrollPoint:NSMakePoint(frame.origin.x, NSMaxY(frame))];
       }
  @@ -570,36 +583,48 @@
   
   - (BOOL)_pageVertically:(BOOL)up
   {
  -    if ([self _scrollOverflowInDirection:up ? WebScrollUp : WebScrollDown granularity:WebScrollPage]) {
  +    if ([self _scrollOverflowInDirection:up ? WebScrollUp : WebScrollDown granularity:WebScrollPage])
           return YES;
  -    }
  +    
  +    if (![self _hasScrollBars])
  +        return [[self _largestChildWithScrollBars] _pageVertically:up];
  +
       float delta = [self _verticalPageScrollDistance];
       return [self _scrollVerticallyBy:up ? -delta : delta];
   }
   
   - (BOOL)_pageHorizontally:(BOOL)left
   {
  -    if ([self _scrollOverflowInDirection:left ? WebScrollLeft : WebScrollRight granularity:WebScrollPage]) {
  +    if ([self _scrollOverflowInDirection:left ? WebScrollLeft : WebScrollRight granularity:WebScrollPage])
           return YES;
  -    }
  +
  +    if (![self _hasScrollBars])
  +        return [[self _largestChildWithScrollBars] _pageHorizontally:left];
  +    
       float delta = [self _horizontalPageScrollDistance];
       return [self _scrollHorizontallyBy:left ? -delta : delta];
   }
   
   - (BOOL)_scrollLineVertically:(BOOL)up
   {
  -    if ([self _scrollOverflowInDirection:up ? WebScrollUp : WebScrollDown granularity:WebScrollLine]) {
  +    if ([self _scrollOverflowInDirection:up ? WebScrollUp : WebScrollDown granularity:WebScrollLine])
           return YES;
  -    }
  +
  +    if (![self _hasScrollBars])
  +        return [[self _largestChildWithScrollBars] _scrollLineVertically:up];
  +    
       float delta = [self _verticalKeyboardScrollDistance];
       return [self _scrollVerticallyBy:up ? -delta : delta];
   }
   
   - (BOOL)_scrollLineHorizontally:(BOOL)left
   {
  -    if ([self _scrollOverflowInDirection:left ? WebScrollLeft : WebScrollRight granularity:WebScrollLine]) {
  +    if ([self _scrollOverflowInDirection:left ? WebScrollLeft : WebScrollRight granularity:WebScrollLine])
           return YES;
  -    }
  +
  +    if (![self _hasScrollBars])
  +        return [[self _largestChildWithScrollBars] _scrollLineHorizontally:left];
  +
       float delta = [self _horizontalKeyboardScrollDistance];
       return [self _scrollHorizontallyBy:left ? -delta : delta];
   }
  @@ -669,7 +694,7 @@
                   // Checking for a control will allow events to percolate 
                   // correctly when the focus is on a form control and we
                   // are in full keyboard access mode.
  -                if (![self allowsScrolling] || [self _firstResponderIsFormControl]) {
  +                if ((![self allowsScrolling] && ![self _largestChildWithScrollBars]) || [self _firstResponderIsFormControl]) {
                       callSuper = YES;
                       break;
                   }
  @@ -681,7 +706,7 @@
                   callSuper = NO;
                   break;
               case NSPageUpFunctionKey:
  -                if (![self allowsScrolling]) {
  +                if (![self allowsScrolling] && ![self _largestChildWithScrollBars]) {
                       callSuper = YES;
                       break;
                   }
  @@ -689,7 +714,7 @@
                   callSuper = NO;
                   break;
               case NSPageDownFunctionKey:
  -                if (![self allowsScrolling]) {
  +                if (![self allowsScrolling] && ![self _largestChildWithScrollBars]) {
                       callSuper = YES;
                       break;
                   }
  @@ -697,7 +722,7 @@
                   callSuper = NO;
                   break;
               case NSHomeFunctionKey:
  -                if (![self allowsScrolling]) {
  +                if (![self allowsScrolling] && ![self _largestChildWithScrollBars]) {
                       callSuper = YES;
                       break;
                   }
  @@ -705,7 +730,7 @@
                   callSuper = NO;
                   break;
               case NSEndFunctionKey:
  -                if (![self allowsScrolling]) {
  +                if (![self allowsScrolling] && ![self _largestChildWithScrollBars]) {
                       callSuper = YES;
                       break;
                   }
  @@ -718,7 +743,7 @@
                       callSuper = YES;
                       break;
                   }
  -                if (![self allowsScrolling] ||
  +                if ((![self allowsScrolling] && ![self _largestChildWithScrollBars]) ||
                       [[[self window] firstResponder] isKindOfClass:[NSPopUpButton class]]) {
                       // Let arrow keys go through to pop up buttons
                       // <rdar://problem/3455910>: hitting up or down arrows when focus is on a 
  @@ -741,7 +766,7 @@
                       callSuper = YES;
                       break;
                   }
  -                if (![self allowsScrolling] ||
  +                if ((![self allowsScrolling] && ![self _largestChildWithScrollBars]) ||
                       [[[self window] firstResponder] isKindOfClass:[NSPopUpButton class]]) {
                       // Let arrow keys go through to pop up buttons
                       // <rdar://problem/3455910>: hitting up or down arrows when focus is on a 
  @@ -773,7 +798,7 @@
                       [self _goBack];
                   } else {
                       // Now check scrolling related keys.
  -                    if (![self allowsScrolling]) {
  +                    if ((![self allowsScrolling] && ![self _largestChildWithScrollBars])) {
                           callSuper = YES;
                           break;
                       }
  @@ -801,7 +826,7 @@
                       [self _goForward];
                   } else {
                       // Now check scrolling related keys.
  -                    if (![self allowsScrolling]) {
  +                    if ((![self allowsScrolling] && ![self _largestChildWithScrollBars])) {
                           callSuper = YES;
                           break;
                       }
  @@ -856,4 +881,33 @@
       return [NSPrintOperation printOperationWithView:documentView printInfo:printInfo];
   }
   
  +- (float)_area
  +{
  +    NSRect frame = [self frame];
  +    return frame.size.height * frame.size.width;
  +}
  +
  +- (BOOL)_hasScrollBars
  +{
  +    NSScrollView *scrollView = [self _scrollView];
  +    return [scrollView hasHorizontalScroller] || [scrollView hasVerticalScroller];
  +}
  +
  +- (WebFrameView *)_largestChildWithScrollBars
  +{
  +    WebFrameView *largest = nil;
  +    NSArray *frameChildren = [[self webFrame] childFrames];
  +    
  +    unsigned i;
  +    for (i=0; i < [frameChildren count]; i++) {
  +        WebFrameView *childFrameView = [[frameChildren objectAtIndex:i] frameView];
  +        WebFrameView *scrollableFrameView = [childFrameView _hasScrollBars] ? childFrameView : [childFrameView _largestChildWithScrollBars];
  +        if (scrollableFrameView && (!largest || ([scrollableFrameView _area] > [largest _area]))) {
  +            largest = scrollableFrameView;
  +        }
  +    }
  +    
  +    return largest;
  +}
  +
   @end
  
  
  
  1.51      +13 -0     WebKit/WebView.subproj/WebFrameViewPrivate.h
  
  Index: WebFrameViewPrivate.h
  ===================================================================
  RCS file: /cvs/root/WebKit/WebView.subproj/WebFrameViewPrivate.h,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- WebFrameViewPrivate.h	5 Jun 2005 17:54:47 -0000	1.50
  +++ WebFrameViewPrivate.h	5 Jan 2006 23:57:11 -0000	1.51
  @@ -44,4 +44,17 @@
   */
   - (NSPrintOperation *)printOperationWithPrintInfo:(NSPrintInfo *)printInfo;
   
  +/*!
  +    @method _largestChildWithScrollBars
  +    @abstract Of the child WebFrameViews that are displaying scroll bars, determines which has the largest area.
  +    @result A child WebFrameView that is displaying scroll bars, or nil if none.
  +*/
  +- (WebFrameView *)_largestChildWithScrollBars;
  +
  +/*!
  +    @method _hasScrollBars
  +    @result YES if at least one scroll bar is currently displayed
  + */
  +- (BOOL)_hasScrollBars;
  +
   @end
  
  
  
  1.33      +39 -0     WebKit/WebView.subproj/WebPDFView.m
  
  Index: WebPDFView.m
  ===================================================================
  RCS file: /cvs/root/WebKit/WebView.subproj/WebPDFView.m,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- WebPDFView.m	24 Dec 2005 00:54:10 -0000	1.32
  +++ WebPDFView.m	5 Jan 2006 23:57:11 -0000	1.33
  @@ -499,6 +499,45 @@
       [PDFSubview scrollSelectionToVisible:nil];
   }
   
  +- (NSEvent *)_fakeKeyEventWithFunctionKey:(unichar)functionKey
  +{
  +    NSString *keyAsString = [NSString stringWithCharacters:&functionKey length:1];
  +    return [NSEvent keyEventWithType:NSKeyDown
  +                            location:NSZeroPoint
  +                       modifierFlags:0
  +                           timestamp:0
  +                        windowNumber:0
  +                             context:nil
  +                          characters:keyAsString
  +         charactersIgnoringModifiers:keyAsString
  +                           isARepeat:NO
  +                             keyCode:0];
  +}
  +
  +- (void)scrollPageDown:(id)sender
  +{
  +    // PDFView doesn't support this responder method directly, so we pass it a fake key event
  +    [PDFSubview keyDown:[self _fakeKeyEventWithFunctionKey:NSPageDownFunctionKey]];
  +}
  +
  +- (void)scrollPageUp:(id)sender
  +{
  +    // PDFView doesn't support this responder method directly, so we pass it a fake key event
  +    [PDFSubview keyDown:[self _fakeKeyEventWithFunctionKey:NSPageUpFunctionKey]];
  +}
  +
  +- (void)scrollToBeginningOfDocument:(id)sender
  +{
  +    // PDFView doesn't support this responder method directly, so we pass it a fake key event
  +    [PDFSubview keyDown:[self _fakeKeyEventWithFunctionKey:NSHomeFunctionKey]];
  +}
  +
  +- (void)scrollToEndOfDocument:(id)sender
  +{
  +    // PDFView doesn't support this responder method directly, so we pass it a fake key event
  +    [PDFSubview keyDown:[self _fakeKeyEventWithFunctionKey:NSEndFunctionKey]];
  +}
  +
   // jumpToSelection is the old name for what AppKit now calls centerSelectionInVisibleArea. Safari
   // was using the old jumpToSelection selector in its menu. Newer versions of Safari will us the
   // selector centerSelectionInVisibleArea. We'll leave this old selector in place for two reasons:
  
  
  
  1.326     +2 -0      WebKit/WebView.subproj/WebView.m
  
  Index: WebView.m
  ===================================================================
  RCS file: /cvs/root/WebKit/WebView.subproj/WebView.m,v
  retrieving revision 1.325
  retrieving revision 1.326
  diff -u -r1.325 -r1.326
  --- WebView.m	5 Jan 2006 06:41:36 -0000	1.325
  +++ WebView.m	5 Jan 2006 23:57:11 -0000	1.326
  @@ -178,6 +178,8 @@
   macro(scrollLineUp) \
   macro(scrollPageDown) \
   macro(scrollPageUp) \
  +macro(scrollToBeginningOfDocument) \
  +macro(scrollToEndOfDocument) \
   macro(selectAll) \
   macro(selectLine) \
   macro(selectParagraph) \
  
  
  



More information about the webkit-changes mailing list