Web Inspector: RDM: Toolbar hidden in when Inspector is docked to side.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Oct 2018 19:28:09 +0000 (19:28 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Oct 2018 19:28:09 +0000 (19:28 +0000)
commit2e80c976c0d496f47df48b914a11d23c0b50d925
treec40ff4986f721c72a5786d503630232f8a75df4a
parent09c1a108e877e03daeb68c658b327a634216d05a
Web Inspector: RDM: Toolbar hidden in when Inspector is docked to side.
https://bugs.webkit.org/show_bug.cgi?id=190545
rdar://problem/44674500

Patch by Remy Demarest <rdemarest@apple.com> on 2018-10-15
Reviewed by Brian Burg.

When the inspector is placed next to the web view it uses its _topContentInset and _totalHeightOfBanners
to lay out the inspector so it does not underlap the window toolbar, but this technique does not work when
in responsive design mode because of the different attachment view. This patch fixes the issue by using
-[NSWindow contentLayoutRect] to figure out the height of the inspector instead of relying on the content
insets of the web view. This requires observing -contentLayoutRect and ensure we only observe its changes
when the view is actually on the screen.

* UIProcess/WebInspectorProxy.h:
Declare helpers to add/remove observer on the attached inspector window.

* UIProcess/mac/WKInspectorViewController.h:
* UIProcess/mac/WKInspectorViewController.mm:
(-[WKInspectorViewController inspectorWKWebView:willMoveToWindow:]):
(-[WKInspectorViewController inspectorWKWebViewDidMoveToWindow:]):

* UIProcess/mac/WKInspectorWKWebView.h:
* UIProcess/mac/WKInspectorWKWebView.mm:
(-[WKInspectorWKWebView viewWillMoveToWindow:]):
(-[WKInspectorWKWebView viewDidMoveToWindow]):

* UIProcess/mac/WebInspectorProxyMac.mm:
(-[WKWebInspectorProxyObjCAdapter observeValueForKeyPath:ofObject:change:context:]): Update inspector layout
whenever the contentLayoutRect changes. Except when live resizing since the attachment view also sends
notifications at the same time.
(-[WKWebInspectorProxyObjCAdapter inspectorViewController:willMoveToWindow:]):
(-[WKWebInspectorProxyObjCAdapter inspectorViewControllerDidMoveToWindow:]):
(WebKit::WebInspectorProxy::attachmentWillMoveFromWindow): Remove the observer only if we set it up before.
(WebKit::WebInspectorProxy::attachmentDidMoveToWindow): Set up the observer and immediately update the frame
of the inspector since it just moved to its final destination.
(WebKit::WebInspectorProxy::inspectedViewFrameDidChange): Adjust the frame of the attached inspector based
on the contentLayoutRect of the window rather than the topContentInset of the web view.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237131 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/WebInspectorProxy.h
Source/WebKit/UIProcess/mac/WKInspectorViewController.h
Source/WebKit/UIProcess/mac/WKInspectorViewController.mm
Source/WebKit/UIProcess/mac/WKInspectorWKWebView.h
Source/WebKit/UIProcess/mac/WKInspectorWKWebView.mm
Source/WebKit/UIProcess/mac/WebInspectorProxyMac.mm