Reviewed by Tim Hatcher.
authortomernic <tomernic@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Mar 2006 21:20:50 +0000 (21:20 +0000)
committertomernic <tomernic@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Mar 2006 21:20:50 +0000 (21:20 +0000)
        Removed tabs & reformatted code.

        * Carbon/HIViewAdapter.m:
        (+[NSView bindHIViewToNSView:nsView:]):
        (+[NSView getHIViewForNSView:]):
        (+[NSView unbindNSView:]):
        (-[NSView setNeedsDisplay:]):
        (-[NSView setNeedsDisplayInRect:]):
        (-[NSView nextValidKeyView]):
        (SetViewNeedsDisplay):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@13493 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/Carbon/HIViewAdapter.m
WebKit/ChangeLog

index d44b5837fd1de29b9e9d69c034e51ec6b147e3cc..9db98f2629d8f8a8155876d6024a00ff299bf6c8 100644 (file)
@@ -20,7 +20,7 @@
  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #import "HIViewAdapter.h"
 
-//extern OSStatus              _HIViewSetNeedsDisplayInRect( HIViewRef inView, const HIRect* inBounds, Boolean inNeedsDisplay );
-static void                    SetViewNeedsDisplay( HIViewRef inView, RgnHandle inRegion, Boolean inNeedsDisplay );
+static void SetViewNeedsDisplay(HIViewRef inView, RgnHandle inRegion, Boolean inNeedsDisplay);
 
-#define WATCH_INVALIDATION             0
+#define WATCH_INVALIDATION 0
 
 @interface NSView(ShhhhDontTell)
 - (NSRect)_dirtyRect;
@@ -39,246 +38,180 @@ static void                       SetViewNeedsDisplay( HIViewRef inView, RgnHandle inRegion, Boolean
 
 @implementation HIViewAdapter
 
-static CFMutableDictionaryRef  sViewMap;
+static CFMutableDictionaryRef sViewMap;
 
 + (void)bindHIViewToNSView:(HIViewRef)hiView nsView:(NSView*)nsView
 {
-       if ( sViewMap == NULL )
-       {
-               [HIViewAdapter poseAsClass: [NSView class]];
-               sViewMap = CFDictionaryCreateMutable( NULL, 0, NULL, NULL );
-       }
-       
-       CFDictionaryAddValue( sViewMap, nsView, hiView );
+    if (sViewMap == NULL) {
+        [HIViewAdapter poseAsClass:[NSView class]];
+        sViewMap = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
+    }
+    
+    CFDictionaryAddValue(sViewMap, nsView, hiView);
 }
 
 + (HIViewRef)getHIViewForNSView:(NSView*)inView
 {
-       return sViewMap ? (HIViewRef)CFDictionaryGetValue( sViewMap, inView ) : NULL;
+    return sViewMap ? (HIViewRef)CFDictionaryGetValue(sViewMap, inView) : NULL;
 }
 
 + (void)unbindNSView:(NSView*)inView
 {
-       CFDictionaryRemoveValue( sViewMap, inView );
+    CFDictionaryRemoveValue(sViewMap, inView);
 }
 
-- (id)initWithFrame:(NSRect)frame view:(HIViewRef) inView {
-    self = [super initWithFrame:frame];
-//    if (self) {
-//       _hiView = inView;
-//    }
-    return self;
-}
-
-#if 0
-- (HIViewRef)hiView {
-       return _hiView;
-}
-
-- (NSView*)nextValidKeyView {
-       //fprintf( stderr, "spoofing next valid key view\n" );
-       return [_window contentView];
-}
-#endif
-
-- (void)setNeedsDisplay:(BOOL)flag {
-       [super setNeedsDisplay:flag];
-       
-       if ( flag == NO )
-       {
-       HIViewRef       hiView = NULL;
-       NSRect          targetBounds = [self visibleRect];
-               NSRect          validRect = targetBounds;
-       NSView*         view = self;
-       
-       while ( view ) {
-                       targetBounds = [view visibleRect];
-                       if ( (hiView = [HIViewAdapter getHIViewForNSView:view]) != NULL )
-                               break;
-                       validRect = [view convertRect:validRect toView:[view superview]];
-               view = [view superview];
-               }
-       
-       if ( hiView )
-               {
-                       HIRect          rect;
-                       
-                       //printf( "validating %g %g %g %g\n", validRect.origin.y, validRect.origin.x,
-                       //      NSMaxY( validRect ), NSMaxX( validRect ) );
-               
-               //printf( "targetBounds.size.height = %g, NSMaxY( validRect ) = %g\n", targetBounds.size.height, NSMaxY( validRect ) );
-                       
-                       // flip rect here and convert to region
-                       
-                       rect.origin.x           = validRect.origin.x;
-                       rect.origin.y           = targetBounds.size.height - NSMaxY( validRect );
-                       rect.size.height        = validRect.size.height;
-                       rect.size.width         = validRect.size.width;
-
-                       //printf( "  flipped to %g %g %g %g\n", rect.origin.y, rect.origin.x,
-                       //      CGRectGetMaxY( rect ), CGRectGetMaxX( rect ) );
-
-                       // For now, call the region-based API.
-                       {
-                               RgnHandle rgn = NewRgn();
-                               if ( rgn )
-                               {
-                                       Rect            qdRect;
-                                       qdRect.top = (SInt16)rect.origin.y;
-                                       qdRect.left = (SInt16)rect.origin.x;
-                                       qdRect.bottom = CGRectGetMaxY( rect );
-                                       qdRect.right = CGRectGetMaxX( rect );
-                               
-                                       RectRgn( rgn, &qdRect );
-                                       SetViewNeedsDisplay( hiView, rgn, false );
-                                       DisposeRgn( rgn );
-                               }
-                       }
-                       //_HIViewSetNeedsDisplayInRect( hiView, &rect, false );
-               }
-       }
+- (void)setNeedsDisplay:(BOOL)flag
+{
+    [super setNeedsDisplay:flag];
+    
+    if (!flag) {
+        HIViewRef hiView = NULL;
+        NSRect targetBounds = [self visibleRect];
+        NSRect validRect = targetBounds;
+        NSView *view = self;
+        
+        while (view) {
+            targetBounds = [view visibleRect];
+            if ((hiView = [HIViewAdapter getHIViewForNSView:view]) != NULL)
+                break;
+            validRect = [view convertRect:validRect toView:[view superview]];
+            view = [view superview];
+        }
+        
+        if (hiView) {            
+            // Flip rect here and convert to region
+            HIRect rect;
+            rect.origin.x = validRect.origin.x;
+            rect.origin.y = targetBounds.size.height - NSMaxY(validRect);
+            rect.size.height = validRect.size.height;
+            rect.size.width = validRect.size.width;
+            
+            // For now, call the region-based API.
+            RgnHandle rgn = NewRgn();
+            if (rgn) {
+                Rect qdRect;
+                qdRect.top = (SInt16)rect.origin.y;
+                qdRect.left = (SInt16)rect.origin.x;
+                qdRect.bottom = CGRectGetMaxY(rect);
+                qdRect.right = CGRectGetMaxX(rect);
+                
+                RectRgn(rgn, &qdRect);
+                SetViewNeedsDisplay(hiView, rgn, false);
+                DisposeRgn(rgn);
+            }
+        }
+    }
 }
 
-- (void)setNeedsDisplayInRect:(NSRect)invalidRect {
-        invalidRect = NSUnionRect(invalidRect, [self _dirtyRect]);
-       [super setNeedsDisplayInRect:invalidRect];
-       
-    if (!NSIsEmptyRect(invalidRect)) 
-    {
-       HIViewRef       hiView = NULL;
-       NSRect          targetBounds = _bounds;
-       NSView*         view = self;
-               
-       while ( view ) {
-                       targetBounds = [view bounds];
-                       if ( (hiView = [HIViewAdapter getHIViewForNSView:view]) != NULL )
-                               break;
-                       invalidRect = [view convertRect:invalidRect toView:[view superview]];
-               view = [view superview];
-               }
-       
-       if ( hiView )
-       {
-               if ( NSWidth( invalidRect ) > 0 && NSHeight( invalidRect ) )
-               {
-                       HIRect          rect;
-                       
-                       //printf( "invalidating %g %g %g %g\n", invalidRect.origin.y, invalidRect.origin.x,
-                       //      NSMaxY( invalidRect ), NSMaxX( invalidRect ) );
-               
-                       //printf( "targetBounds.size.height = %g, NSMaxY( invalidRect ) = %g\n", targetBounds.size.height, NSMaxY( invalidRect ) );
-                       
-                       // flip rect here and convert to region
-                       
-                               rect.origin.x           = invalidRect.origin.x;
-                               rect.origin.y           = targetBounds.size.height - NSMaxY( invalidRect );
-                               rect.size.height        = invalidRect.size.height;
-                               rect.size.width         = invalidRect.size.width;
-
-                       //printf( "  flipped to %g %g %g %g\n", rect.origin.y, rect.origin.x,
-                       //      CGRectGetMaxY( rect ), CGRectGetMaxX( rect ) );
-
-                               // For now, call the region-based API.
-                               {
-                                       RgnHandle rgn = NewRgn();
-                                       if ( rgn )
-                                       {
-                                               Rect            qdRect;
-                                               qdRect.top = (SInt16)rect.origin.y;
-                                               qdRect.left = (SInt16)rect.origin.x;
-                                               qdRect.bottom = CGRectGetMaxY( rect );
-                                               qdRect.right = CGRectGetMaxX( rect );
-                                       
-                                               RectRgn( rgn, &qdRect );
-                                               SetViewNeedsDisplay( hiView, rgn, true );
-                                               DisposeRgn( rgn );
-                                       }
-                               }
-                       //_HIViewSetNeedsDisplayInRect( hiView, &rect, true );
-               }
-       }
-       else
-               [_window setViewsNeedDisplay:YES];
-       }
+- (void)setNeedsDisplayInRect:(NSRect)invalidRect
+{
+    invalidRect = NSUnionRect(invalidRect, [self _dirtyRect]);
+    [super setNeedsDisplayInRect:invalidRect];
+    
+    if (!NSIsEmptyRect(invalidRect)) {
+        HIViewRef hiView = NULL;
+        NSRect targetBounds = [self bounds];
+        NSView *view = self;
+        
+        while (view) {
+            targetBounds = [view bounds];
+            if ((hiView = [HIViewAdapter getHIViewForNSView:view]) != NULL)
+                break;
+            invalidRect = [view convertRect:invalidRect toView:[view superview]];
+            view = [view superview];
+        }
+        
+        if (hiView) {
+            if (NSWidth(invalidRect) > 0 && NSHeight(invalidRect)) {                
+                // Flip rect here and convert to region
+                HIRect rect;
+                rect.origin.x = invalidRect.origin.x;
+                rect.origin.y = targetBounds.size.height - NSMaxY(invalidRect);
+                rect.size.height = invalidRect.size.height;
+                rect.size.width = invalidRect.size.width;
+                
+                // For now, call the region-based API.
+                RgnHandle rgn = NewRgn();
+                if (rgn) {
+                    Rect qdRect;
+                    qdRect.top = (SInt16)rect.origin.y;
+                    qdRect.left = (SInt16)rect.origin.x;
+                    qdRect.bottom = CGRectGetMaxY(rect);
+                    qdRect.right = CGRectGetMaxX(rect);
+                    
+                    RectRgn(rgn, &qdRect);
+                    SetViewNeedsDisplay(hiView, rgn, true);
+                    DisposeRgn(rgn);
+                }
+            }
+        } else
+            [_window setViewsNeedDisplay:YES];
+    }
 }
 
 - (NSView *)nextValidKeyView
 {
-       HIViewRef               hiView = [HIViewAdapter getHIViewForNSView:self];
-       NSView*                 retVal = NULL;
-
-       if ( hiView )
-       {
-               //fprintf( stderr, "spoofing next valid key view\n" );
-               retVal = [_window contentView];
-       }
-       else
-       {
-               retVal = [super nextValidKeyView];
-       }
-       
-       return retVal;
+    if ([HIViewAdapter getHIViewForNSView:self])
+        return [_window contentView];
+    else
+        return [super nextValidKeyView];
 }
 
 @end
 
-static void
-SetViewNeedsDisplay( HIViewRef inHIView, RgnHandle inRegion, Boolean inNeedsDisplay )
+static void SetViewNeedsDisplay(HIViewRef inHIView, RgnHandle inRegion, Boolean inNeedsDisplay)
 {
-       WindowAttributes                attrs;
-       
-       GetWindowAttributes( GetControlOwner( inHIView ), &attrs );
-
-       if ( attrs & kWindowCompositingAttribute )
-       {
+    WindowAttributes attrs;
+    
+    GetWindowAttributes(GetControlOwner(inHIView), &attrs);
+    
+    if (attrs & kWindowCompositingAttribute) {
 #if WATCH_INVALIDATION
-               Rect            bounds;
-               GetRegionBounds( inRegion, &bounds );
-               printf( "%s: rect on input %d %d %d %d\n", inNeedsDisplay ? "INVALIDATE" : "VALIDATE",
-                       bounds.top, bounds.left, bounds.bottom, bounds.right );
+        Rect bounds;
+        GetRegionBounds(inRegion, &bounds);
+        printf("%s: rect on input %d %d %d %d\n", inNeedsDisplay ? "INVALIDATE" : "VALIDATE",
+                bounds.top, bounds.left, bounds.bottom, bounds.right);
 #endif
-               HIViewSetNeedsDisplayInRegion( inHIView, inRegion, inNeedsDisplay );
-       }
-       else
-       {
-               Rect                    bounds, cntlBounds;
-               GrafPtr                 port, savePort;
-               Rect                    portBounds;
-               
+        HIViewSetNeedsDisplayInRegion(inHIView, inRegion, inNeedsDisplay);
+    } else {
+        Rect bounds, cntlBounds;
+        GrafPtr port, savePort;
+        Rect portBounds;
+        
 #if WATCH_INVALIDATION
-               printf( "%s: rect on input %d %d %d %d\n", inNeedsDisplay ? "INVALIDATE" : "VALIDATE",
-                       bounds.top, bounds.left, bounds.bottom, bounds.right );
+        printf("%s: rect on input %d %d %d %d\n", inNeedsDisplay ? "INVALIDATE" : "VALIDATE",
+                bounds.top, bounds.left, bounds.bottom, bounds.right);
 #endif
-               GetControlBounds( inHIView, &cntlBounds );
-
+        GetControlBounds(inHIView, &cntlBounds);
+        
 #if WATCH_INVALIDATION
-               printf( "%s: control bounds are %d %d %d %d\n", inNeedsDisplay ? "INVALIDATE" : "VALIDATE",
-                       cntlBounds.top, cntlBounds.left, cntlBounds.bottom, cntlBounds.right );
+        printf("%s: control bounds are %d %d %d %d\n", inNeedsDisplay ? "INVALIDATE" : "VALIDATE",
+                cntlBounds.top, cntlBounds.left, cntlBounds.bottom, cntlBounds.right);
 #endif
-
-               port = GetWindowPort( GetControlOwner( inHIView ) );
-               
-               GetPort( &savePort );
-               SetPort( port );
-               GetPortBounds( port, &portBounds );
-               SetOrigin( 0, 0 );
-               
-               OffsetRgn( inRegion, cntlBounds.left, cntlBounds.top );
-
-               GetRegionBounds( inRegion, &bounds );
-
+        
+        port = GetWindowPort(GetControlOwner(inHIView));
+        
+        GetPort(&savePort);
+        SetPort(port);
+        GetPortBounds(port, &portBounds);
+        SetOrigin(0, 0);
+        
+        OffsetRgn(inRegion, cntlBounds.left, cntlBounds.top);
+        
+        GetRegionBounds(inRegion, &bounds);
+        
 #if WATCH_INVALIDATION
-               printf( "%s: rect in port coords %d %d %d %d\n", inNeedsDisplay ? "INVALIDATE" : "VALIDATE",
-                       bounds.top, bounds.left, bounds.bottom, bounds.right );
+        printf("%s: rect in port coords %d %d %d %d\n", inNeedsDisplay ? "INVALIDATE" : "VALIDATE",
+                bounds.top, bounds.left, bounds.bottom, bounds.right);
 #endif
-
-               if ( inNeedsDisplay )
-                       InvalWindowRgn( GetControlOwner( inHIView ), inRegion );
-               else
-                       ValidWindowRgn( GetControlOwner( inHIView ), inRegion );
-               
-               SetOrigin( portBounds.left, portBounds.top );
-               SetPort( savePort );
-       }
+        
+        if (inNeedsDisplay)
+            InvalWindowRgn(GetControlOwner(inHIView), inRegion);
+        else
+            ValidWindowRgn(GetControlOwner(inHIView), inRegion);
+        
+        SetOrigin(portBounds.left, portBounds.top);
+        SetPort(savePort);
+    }
 }
 
index df92ec98ab95a37eab0af046cf6bf7978292ab24..fe2f007641f0bf3901ce501cb4b70630f9782076 100644 (file)
@@ -1,3 +1,18 @@
+2006-03-27  Tim Omernick  <timo@apple.com>
+
+        Reviewed by Tim Hatcher.
+
+        Removed tabs & reformatted code.
+        
+        * Carbon/HIViewAdapter.m:
+        (+[NSView bindHIViewToNSView:nsView:]):
+        (+[NSView getHIViewForNSView:]):
+        (+[NSView unbindNSView:]):
+        (-[NSView setNeedsDisplay:]):
+        (-[NSView setNeedsDisplayInRect:]):
+        (-[NSView nextValidKeyView]):
+        (SetViewNeedsDisplay):
+
 2006-03-26  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by darin