[webkit-changes] cvs commit: WebKit/WebView.subproj WebView.m WebViewPrivate.h

John sullivan at opensource.apple.com
Wed Jul 20 11:30:16 PDT 2005


sullivan    05/07/20 11:30:16

  Modified:    .        ChangeLog
               WebView.subproj WebView.m WebViewPrivate.h
  Log:
          Reviewed by Adele Amchan.
  
          - added -[WebView selectedFrame] to SPI (pending public API), needed for 4180958
  
          * WebView.subproj/WebView.m:
          (-[WebView selectedFrame]):
          new method, extracted from _selectedOrMainFrame
          (-[WebView _selectedOrMainFrame]):
          now calls extracted method
  
          * WebView.subproj/WebViewPrivate.h:
          add -selectedFrame to PendingPublic category
  
  Revision  Changes    Path
  1.3239    +15 -0     WebKit/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebKit/ChangeLog,v
  retrieving revision 1.3238
  retrieving revision 1.3239
  diff -u -r1.3238 -r1.3239
  --- ChangeLog	20 Jul 2005 00:50:20 -0000	1.3238
  +++ ChangeLog	20 Jul 2005 18:30:13 -0000	1.3239
  @@ -1,3 +1,18 @@
  +2005-07-20  John Sullivan  <sullivan at apple.com>
  +
  +        Reviewed by Adele Amchan.
  +        
  +        - added -[WebView selectedFrame] to SPI (pending public API), needed for 4180958
  +
  +        * WebView.subproj/WebView.m:
  +        (-[WebView selectedFrame]):
  +        new method, extracted from _selectedOrMainFrame
  +        (-[WebView _selectedOrMainFrame]):
  +        now calls extracted method
  +        
  +        * WebView.subproj/WebViewPrivate.h:
  +        add -selectedFrame to PendingPublic category
  +
   2005-07-19  John Sullivan  <sullivan at apple.com>
   
           Reviewed by Darin Adler.
  
  
  
  1.295     +39 -26    WebKit/WebView.subproj/WebView.m
  
  Index: WebView.m
  ===================================================================
  RCS file: /cvs/root/WebKit/WebView.subproj/WebView.m,v
  retrieving revision 1.294
  retrieving revision 1.295
  diff -u -r1.294 -r1.295
  --- WebView.m	20 Jul 2005 00:50:23 -0000	1.294
  +++ WebView.m	20 Jul 2005 18:30:15 -0000	1.295
  @@ -191,6 +191,10 @@
   @end
   
   @interface WebView (WebFileInternal)
  +#ifndef NDEBUG
  +- (void)_debugCheckForMultipleSelectedFrames;
  +#endif
  +- (WebFrame *)_findSelectedFrame;
   - (WebFrame *)_selectedOrMainFrame;
   - (WebBridge *)_bridgeForSelectedOrMainFrame;
   - (BOOL)_isLoading;
  @@ -2537,6 +2541,37 @@
       return [self isEditable];
   }
   
  +- (WebFrame *)selectedFrame
  +{
  +    // If the first responder is a view in our tree, we get the frame containing the first responder.
  +    // This is faster than searching the frame hierarchy, and will give us a result even in the case
  +    // where the focused frame doesn't actually contain a selection.
  +    NSResponder *resp = [[self window] firstResponder];
  +    if (resp && [resp isKindOfClass:[NSView class]] && [(NSView *)resp isDescendantOf:self]) {
  +        WebFrameView *frameView = (WebFrameView *)[(NSView *)resp _web_superviewOfClass:[WebFrameView class]];
  +        ASSERT(frameView != nil);
  +#ifndef NDEBUG
  +        WebFrame *frameWithSelection = [self _findSelectedFrame];
  +        ASSERT(frameWithSelection == nil || frameWithSelection == [frameView webFrame]);
  +        [self _debugCheckForMultipleSelectedFrames];
  +#endif
  +        return [frameView webFrame];
  +    }
  +    
  +    // If the first responder is outside of our view tree, we search for a frame containing a selection.
  +    // There should be at most only one of these.
  +    WebFrame *frameWithSelection = [self _findSelectedFrame];
  +    if (frameWithSelection != nil) {
  +#ifndef NDEBUG
  +        [self _debugCheckForMultipleSelectedFrames];
  +#endif
  +        return frameWithSelection;
  +    }
  +    
  +    return nil;
  +}
  +
  +
   @end
   
   @implementation WebView (WebViewPrintingPrivate)
  @@ -3012,33 +3047,11 @@
   
   - (WebFrame *)_selectedOrMainFrame
   {
  -    // If the first responder is a view in our tree, we get the frame containing the first responder.
  -    // This is faster than searching the frame hierarchy, and will give us a result even in the case
  -    // where the focused frame doesn't actually contain a selection.
  -    NSResponder *resp = [[self window] firstResponder];
  -    if (resp && [resp isKindOfClass:[NSView class]] && [(NSView *)resp isDescendantOf:self]) {
  -        WebFrameView *frameView = (WebFrameView *)[(NSView *)resp _web_superviewOfClass:[WebFrameView class]];
  -        ASSERT(frameView != nil);
  -#ifndef NDEBUG
  -        WebFrame *frameWithSelection = [self _findSelectedFrame];
  -        ASSERT(frameWithSelection == nil || frameWithSelection == [frameView webFrame]);
  -        [self _debugCheckForMultipleSelectedFrames];
  -#endif
  -        return [frameView webFrame];
  -    }
  -    
  -    // If the first responder is outside of our view tree, we search for a frame containing a selection.
  -    // There should be at most only one of these.
  -    WebFrame *frameWithSelection = [self _findSelectedFrame];
  -    if (frameWithSelection != nil) {
  -#ifndef NDEBUG
  -        [self _debugCheckForMultipleSelectedFrames];
  -#endif
  -        return frameWithSelection;
  +    WebFrame *result = [self selectedFrame];
  +    if (result == nil) {
  +        result = [self mainFrame];
       }
  -    
  -    // The first responder is outside of our view tree, and no frame in our view tree has a selection.
  -    return [self mainFrame];
  +    return result;
   }
   
   - (WebBridge *)_bridgeForSelectedOrMainFrame
  
  
  
  1.144     +5 -0      WebKit/WebView.subproj/WebViewPrivate.h
  
  Index: WebViewPrivate.h
  ===================================================================
  RCS file: /cvs/root/WebKit/WebView.subproj/WebViewPrivate.h,v
  retrieving revision 1.143
  retrieving revision 1.144
  diff -u -r1.143 -r1.144
  --- WebViewPrivate.h	29 Jun 2005 22:53:51 -0000	1.143
  +++ WebViewPrivate.h	20 Jul 2005 18:30:15 -0000	1.144
  @@ -85,6 +85,11 @@
   // override to enforce additional criteria.
   - (BOOL)maintainsInactiveSelection;
   
  +// Returns the frame that contains the first responder, if any. Otherwise returns the
  +// frame that contains a non-zero-length selection, if any. Returns nil if no frame
  +// meets these criteria.
  +- (WebFrame *)selectedFrame;
  +
   @end
   
   @interface WebView (WebPrivate)
  
  
  



More information about the webkit-changes mailing list