From 7703896927101350f5333deab3f1c0634ce3daf2 Mon Sep 17 00:00:00 2001 From: "timothy@apple.com" Date: Thu, 17 May 2012 21:21:26 +0000 Subject: [PATCH] Make the docked Web Inspector use autoresizing masks so the view doesn't jitter when resizing the window. https://webkit.org/b/86765 Reviewed by John Sullivan. * UIProcess/mac/WebInspectorProxyMac.mm: (-[WKWebInspectorProxyObjCAdapter close]): Added. Zero out _inspectorProxy. (-[WKWebInspectorProxyObjCAdapter inspectedViewFrameDidChange:]): Preform the work on a delay to prevent interfering with Cocoa's resizing. (WebKit::WebInspectorProxy::createInspectorWindow): Added setAutoresizingMask: call. (WebKit::WebInspectorProxy::platformCreateInspectorPage): Removed setAutoresizingMask: call. createInspectorWindow and platformAttach do this now. (WebKit::WebInspectorProxy::platformDidClose): Call close on WKWebInspectorProxyObjCAdapter. (WebKit::WebInspectorProxy::platformAttach): Added setAutoresizingMask: call. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@117495 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebKit2/ChangeLog | 19 +++++++++++++++++++ .../WebKit2/UIProcess/mac/WebInspectorProxyMac.mm | 22 ++++++++++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog index eb0099d..352cf2e 100644 --- a/Source/WebKit2/ChangeLog +++ b/Source/WebKit2/ChangeLog @@ -1,3 +1,22 @@ +2012-05-17 Timothy Hatcher + + Make the docked Web Inspector use autoresizing masks so the view doesn't jitter when + resizing the window. + + https://webkit.org/b/86765 + + Reviewed by John Sullivan. + + * UIProcess/mac/WebInspectorProxyMac.mm: + (-[WKWebInspectorProxyObjCAdapter close]): Added. Zero out _inspectorProxy. + (-[WKWebInspectorProxyObjCAdapter inspectedViewFrameDidChange:]): Perform the work on a delay to + prevent interfering with Cocoa's resizing. + (WebKit::WebInspectorProxy::createInspectorWindow): Added setAutoresizingMask: call. + (WebKit::WebInspectorProxy::platformCreateInspectorPage): Removed setAutoresizingMask: call. + createInspectorWindow and platformAttach do this now. + (WebKit::WebInspectorProxy::platformDidClose): Call close on WKWebInspectorProxyObjCAdapter. + (WebKit::WebInspectorProxy::platformAttach): Added setAutoresizingMask: call. + 2012-05-16 Andreas Kling Make PluginInfoStore properly thread-safe. diff --git a/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm b/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm index bcdfbc2..5c6c73c 100644 --- a/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm +++ b/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm @@ -56,6 +56,7 @@ static const CGFloat windowContentBorderThickness = 55; @interface WKWebInspectorProxyObjCAdapter () - (id)initWithWebInspectorProxy:(WebInspectorProxy*)inspectorProxy; +- (void)close; @end @@ -78,6 +79,11 @@ static const CGFloat windowContentBorderThickness = 55; return self; } +- (void)close +{ + _inspectorProxy = 0; +} + - (void)windowWillClose:(NSNotification *)notification { static_cast(_inspectorProxy)->close(); @@ -85,7 +91,16 @@ static const CGFloat windowContentBorderThickness = 55; - (void)inspectedViewFrameDidChange:(NSNotification *)notification { - static_cast(_inspectorProxy)->inspectedViewFrameDidChange(); + // Resizing the views while inside this notification can lead to bad results when entering + // or exiting full screen. To avoid that we need to perform the work after a delay. We only + // depend on this for enforcing the height constraints, so a small delay isn't terrible. Most + // of the time the views will already have the correct frames because of autoresizing masks. + + dispatch_after(DISPATCH_TIME_NOW, dispatch_get_current_queue(), ^{ + if (!_inspectorProxy) + return; + static_cast(_inspectorProxy)->inspectedViewFrameDidChange(); + }); } @end @@ -143,6 +158,7 @@ void WebInspectorProxy::createInspectorWindow() NSView *contentView = [window contentView]; [m_inspectorView.get() setFrame:[contentView bounds]]; + [m_inspectorView.get() setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; [contentView addSubview:m_inspectorView.get()]; // Center the window initially before setting the frame autosave name so that the window will be in a good @@ -173,7 +189,6 @@ WebPageProxy* WebInspectorProxy::platformCreateInspectorPage() ASSERT(m_inspectorView); [m_inspectorView.get() setDrawsBackground:NO]; - [m_inspectorView.get() setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; m_inspectorProxyObjCAdapter.adoptNS([[WKWebInspectorProxyObjCAdapter alloc] initWithWebInspectorProxy:this]); @@ -207,6 +222,7 @@ void WebInspectorProxy::platformDidClose() m_inspectorView = 0; + [m_inspectorProxyObjCAdapter.get() close]; m_inspectorProxyObjCAdapter = 0; } @@ -267,6 +283,8 @@ void WebInspectorProxy::platformAttach() NSRect inspectedViewFrame = [inspectedView frame]; [m_inspectorView.get() setFrame:NSMakeRect(NSMinX(inspectedViewFrame), 0, NSWidth(inspectedViewFrame), inspectorPageGroup()->preferences()->inspectorAttachedHeight())]; + [m_inspectorView.get() setAutoresizingMask:NSViewWidthSizable | NSViewMaxYMargin]; + // Start out hidden if we are not visible yet. When platformOpen is called, hidden will be set to NO. [m_inspectorView.get() setHidden:!m_isVisible]; -- 2.7.4