Fix attaching and detaching the Web Inspector. This change removes
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 May 2008 08:03:56 +0000 (08:03 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 May 2008 08:03:56 +0000 (08:03 +0000)
the clunky animation that never looked right and was causing issues
where the inspected WebView would get into a no useable state.

<rdar://problem/5958812> Attaching and Detaching the Web Inspector
can cause the inspected WebVIew to be unusable

Reviewed by Adam Roben.

* WebCoreSupport/WebInspectorClient.mm:
(-[WebInspectorWindowController close]): Removes animation code.
Sets the frame directly and does a displayIfNeeded to prevent
showing the Inspector in the page and in the Inspector window.
(-[WebInspectorWindowController showWindow:]): Removes animation code.
Sets the frame directly.
(-[WebInspectorWindowController attach]): Simplified.
(-[WebInspectorWindowController detach]): Ditto.

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

WebKit/mac/ChangeLog
WebKit/mac/WebCoreSupport/WebInspectorClient.mm

index f4b0195..5768f1d 100644 (file)
@@ -1,3 +1,23 @@
+2008-05-23  Timothy Hatcher  <timothy@apple.com>
+
+        Fix attaching and detaching the Web Inspector. This change removes
+        the clunky animation that never looked right and was causing issues
+        where the inspected WebView would get into a no useable state.
+
+        <rdar://problem/5958812> Attaching and Detaching the Web Inspector
+        can cause the inspected WebVIew to be unusable
+
+        Reviewed by Adam Roben.
+
+        * WebCoreSupport/WebInspectorClient.mm:
+        (-[WebInspectorWindowController close]): Removes animation code.
+        Sets the frame directly and does a displayIfNeeded to prevent
+        showing the Inspector in the page and in the Inspector window.
+        (-[WebInspectorWindowController showWindow:]): Removes animation code.
+        Sets the frame directly.
+        (-[WebInspectorWindowController attach]): Simplified.
+        (-[WebInspectorWindowController detach]): Ditto.
+
 2008-05-22  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by Darin Adler.
index 930fb76..1d92b70 100644 (file)
@@ -56,7 +56,6 @@ using namespace WebCore;
 @private
     WebView *_inspectedWebView;
     WebView *_webView;
-    NSImageView *_shadowView;
     WebNodeHighlight *_currentHighlight;
     BOOL _attachedToInspectedWebView;
     BOOL _shouldAttach;
@@ -202,7 +201,6 @@ void WebInspectorClient::updateWindowTitle() const
 - (void)dealloc
 {
     ASSERT(!_currentHighlight);
-    [_shadowView release];
     [_webView release];
     [super dealloc];
 }
@@ -270,8 +268,7 @@ void WebInspectorClient::updateWindowTitle() const
 
     [_inspectedWebView page]->inspectorController()->setWindowVisible(false);
 
-    if (!_movingWindows)
-        [self hideHighlight];
+    [self hideHighlight];
 
     if (_attachedToInspectedWebView) {
         if ([_inspectedWebView _isClosed])
@@ -280,39 +277,14 @@ void WebInspectorClient::updateWindowTitle() const
         WebFrameView *frameView = [[_inspectedWebView mainFrame] frameView];
 
         NSRect frameViewRect = [frameView frame];
-        NSRect finalFrameViewRect = NSMakeRect(0, 0, NSWidth(frameViewRect), NSHeight([_inspectedWebView frame]));
-        NSMutableDictionary *frameViewAnimationInfo = [[NSMutableDictionary alloc] init];
-        [frameViewAnimationInfo setObject:frameView forKey:NSViewAnimationTargetKey];
-        [frameViewAnimationInfo setObject:[NSValue valueWithRect:finalFrameViewRect] forKey:NSViewAnimationEndFrameKey];
-
-        ASSERT(_shadowView);
-        NSRect shadowFrame = [_shadowView frame];
-        shadowFrame = NSMakeRect(0, NSMinY(frameViewRect) - NSHeight(shadowFrame), NSWidth(frameViewRect), NSHeight(shadowFrame));
-        [_shadowView setFrame:shadowFrame];
-
-        [_shadowView removeFromSuperview];
-        [_inspectedWebView addSubview:_shadowView positioned:NSWindowAbove relativeTo:_webView];
-
-        NSRect finalShadowRect = NSMakeRect(0, -NSHeight(shadowFrame), NSWidth(shadowFrame), NSHeight(shadowFrame));
-        NSMutableDictionary *shadowAnimationInfo = [[NSMutableDictionary alloc] init];
-        [shadowAnimationInfo setObject:_shadowView forKey:NSViewAnimationTargetKey];
-        [shadowAnimationInfo setObject:[NSValue valueWithRect:finalShadowRect] forKey:NSViewAnimationEndFrameKey];
-
-        NSArray *animationInfo = [[NSArray alloc] initWithObjects:frameViewAnimationInfo, shadowAnimationInfo, nil];
-        [frameViewAnimationInfo release];
-        [shadowAnimationInfo release];
-
-        NSViewAnimation *slideAnimation = [[NSViewAnimation alloc] initWithViewAnimations:animationInfo]; // released in animationDidEnd
-        [animationInfo release];
+        frameViewRect = NSMakeRect(0, 0, NSWidth(frameViewRect), NSHeight([_inspectedWebView frame]));
 
-        [slideAnimation setAnimationBlockingMode:NSAnimationBlocking];
-        [slideAnimation setDelegate:self];
+        [frameView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
+        [frameView setFrame:frameViewRect];
 
-        [[_inspectedWebView window] display]; // display once to make sure we start in a good state
-        [slideAnimation startAnimation];
-    } else {
+        [_inspectedWebView displayIfNeeded];
+    } else
         [super close];
-    }
 }
 
 - (IBAction)showWindow:(id)sender
@@ -325,63 +297,24 @@ void WebInspectorClient::updateWindowTitle() const
 
     _visible = YES;
 
-    [_inspectedWebView page]->inspectorController()->setWindowVisible(true);
-
     if (_shouldAttach) {
         WebFrameView *frameView = [[_inspectedWebView mainFrame] frameView];
 
         NSRect frameViewRect = [frameView frame];
         float attachedHeight = [[NSUserDefaults standardUserDefaults] integerForKey:WebKitInspectorAttachedViewHeightKey];
         attachedHeight = MAX(300.0, MIN(attachedHeight, (NSHeight(frameViewRect) * 0.6)));
+        frameViewRect = NSMakeRect(0, attachedHeight, NSWidth(frameViewRect), NSHeight(frameViewRect) - attachedHeight);
 
         [_webView removeFromSuperview];
         [_inspectedWebView addSubview:_webView positioned:NSWindowBelow relativeTo:(NSView*)frameView];
-        [_webView setFrame:NSMakeRect(0, 0, NSWidth(frameViewRect), attachedHeight)];
+
         [_webView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable | NSViewMaxYMargin)];
+        [_webView setFrame:NSMakeRect(0, 0, NSWidth(frameViewRect), attachedHeight)];
 
         [frameView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable | NSViewMinYMargin)];
-
-        NSRect finalFrameViewRect = NSMakeRect(0, attachedHeight, NSWidth(frameViewRect), NSHeight(frameViewRect) - attachedHeight);
-        NSMutableDictionary *frameViewAnimationInfo = [[NSMutableDictionary alloc] init];
-        [frameViewAnimationInfo setObject:frameView forKey:NSViewAnimationTargetKey];
-        [frameViewAnimationInfo setObject:[NSValue valueWithRect:finalFrameViewRect] forKey:NSViewAnimationEndFrameKey];
-
-        if (!_shadowView) {
-            NSString *imagePath = [[NSBundle bundleWithIdentifier:@"com.apple.WebCore"] pathForResource:@"attachedShadow" ofType:@"png" inDirectory:@"inspector/Images"];
-            NSImage *image = [[NSImage alloc] initWithContentsOfFile:imagePath];
-            _shadowView = [[NSImageView alloc] initWithFrame:NSMakeRect(0, -[image size].height, NSWidth(frameViewRect), [image size].height)];
-            [_shadowView setImage:image];
-            [_shadowView setImageScaling:NSScaleToFit];
-            [_shadowView setImageFrameStyle:NSImageFrameNone];
-            [_shadowView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable | NSViewMaxYMargin)];
-        }
-
-        NSRect shadowFrame = [_shadowView frame];
-        shadowFrame = NSMakeRect(0, -NSHeight(shadowFrame), NSWidth(frameViewRect), NSHeight(shadowFrame));
-        [_shadowView setFrame:shadowFrame];
-
-        [_shadowView removeFromSuperview];
-        [_inspectedWebView addSubview:_shadowView positioned:NSWindowAbove relativeTo:_webView];
-
-        NSRect finalShadowRect = NSMakeRect(0, attachedHeight - NSHeight(shadowFrame), NSWidth(shadowFrame), NSHeight(shadowFrame));
-        NSMutableDictionary *shadowAnimationInfo = [[NSMutableDictionary alloc] init];
-        [shadowAnimationInfo setObject:_shadowView forKey:NSViewAnimationTargetKey];
-        [shadowAnimationInfo setObject:[NSValue valueWithRect:finalShadowRect] forKey:NSViewAnimationEndFrameKey];
-
-        NSArray *animationInfo = [[NSArray alloc] initWithObjects:frameViewAnimationInfo, shadowAnimationInfo, nil];
-        [frameViewAnimationInfo release];
-        [shadowAnimationInfo release];
-
-        NSViewAnimation *slideAnimation = [[NSViewAnimation alloc] initWithViewAnimations:animationInfo]; // released in animationDidEnd
-        [animationInfo release];
-
-        [slideAnimation setAnimationBlockingMode:NSAnimationBlocking];
-        [slideAnimation setDelegate:self];
+        [frameView setFrame:frameViewRect];
 
         _attachedToInspectedWebView = YES;
-
-        [[_inspectedWebView window] display]; // display once to make sure we start in a good state
-        [slideAnimation startAnimation];
     } else {
         _attachedToInspectedWebView = NO;
 
@@ -393,6 +326,8 @@ void WebInspectorClient::updateWindowTitle() const
 
         [super showWindow:nil];
     }
+
+    [_inspectedWebView page]->inspectorController()->setWindowVisible(true);
 }
 
 #pragma mark -
@@ -403,14 +338,12 @@ void WebInspectorClient::updateWindowTitle() const
         return;
 
     _shouldAttach = YES;
+    _movingWindows = YES;
 
-    if (_visible) {
-        _movingWindows = YES;
-        [self close];
-        _movingWindows = NO;
-    }
-
+    [self close];
     [self showWindow:nil];
+
+    _movingWindows = NO;
 }
 
 - (void)detach
@@ -419,13 +352,12 @@ void WebInspectorClient::updateWindowTitle() const
         return;
 
     _shouldAttach = NO;
+    _movingWindows = YES;
 
-    if (_visible) {
-        _movingWindows = YES; // set back to NO in animationDidEnd
-        [self close];
-    } else {
-        [self showWindow:nil];
-    }
+    [self close];
+    [self showWindow:nil];
+
+    _movingWindows = NO;
 }
 
 #pragma mark -
@@ -481,21 +413,6 @@ void WebInspectorClient::updateWindowTitle() const
 }
 
 #pragma mark -
-#pragma mark Animation delegate
-
-- (void)animationDidEnd:(NSAnimation*)animation
-{
-    [animation release];
-
-    [_shadowView removeFromSuperview];
-
-    if (_movingWindows) {
-        _movingWindows = NO;
-        [self showWindow:nil];
-    }
-}
-
-#pragma mark -
 #pragma mark UI delegate
 
 - (NSUInteger)webView:(WebView *)sender dragDestinationActionMaskForDraggingInfo:(id <NSDraggingInfo>)draggingInfo