8000 Fix Bug 22262: Clicking close ("X") button in docked Web Insp… · WebKit/WebKit@c1aa642 · GitHub
[go: up one dir, main page]

Skip to content

Commit c1aa642

Browse files
committed
Fix Bug 22262: Clicking close ("X") button in docked Web Inspector clears Web Inspector but doesn't close it
<https://bugs.webkit.org/show_bug.cgi?id=22262> <rdar://problem/6371873> Reviewed by Darin Adler. * WebCoreSupport/WebInspectorClient.cpp: (WebInspectorClient::WebInspectorClient): Initialize new member. (WebInspectorClient::showWindow): Moved code from here to showWindowWithoutNotifications. (WebInspectorClient::closeWindow): Moved code from here to closeWindowWithoutNotifications. (WebInspectorClient::attachWindow): (WebInspectorClient::detachWindow): Record whether or not we should be attached, then close and reopen the window without notifying the InspectorController. Code that was in these functions moved to showWindowWithoutNotifications and closeWindowWithoutNotifications, respectively. (WebInspectorClient::closeWindowWithoutNotifications): Added. Code came from closeWindow and detachWindow. (WebInspectorClient::showWindowWithoutNotifications): Added. Code came from showWindow and attachWindow. * WebCoreSupport/WebInspectorClient.h: Added {close,show}WindowWithoutNotifications and m_shouldAttachWhenShown. Canonical link: https://commits.webkit.org/31881@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@39682 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 92e92ef commit c1aa642

File tree

3 files changed

+113
-39
lines changed

3 files changed

+113
-39
lines changed

WebKit/win/ChangeLog

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1+
2009-01-06 Adam Roben <aroben@apple.com>
2+
3+
Fix Bug 22262: Clicking close ("X") button in docked Web Inspector
4+
clears Web Inspector but doesn't close it
5+
6+
<https://bugs.webkit.org/show_bug.cgi?id=22262>
7+
<rdar://problem/6371873>
8+
9+
Reviewed by Darin Adler.
10+
11+
* WebCoreSupport/WebInspectorClient.cpp:
12+
(WebInspectorClient::WebInspectorClient): Initialize new member.
13+
(WebInspectorClient::showWindow): Moved code from here to
14+
showWindowWithoutNotifications.
15+
(WebInspectorClient::closeWindow): Moved code from here to
16+
closeWindowWithoutNotifications.
17+
18+
(WebInspectorClient::attachWindow):
19+
(WebInspectorClient::detachWindow):
20+
Record whether or not we should be attached, then close and reopen the
21+
window without notifying the InspectorController. Code that was in
22+
these functions moved to showWindowWithoutNotifications and
23+
closeWindowWithoutNotifications, respectively.
24+
25+
(WebInspectorClient::closeWindowWithoutNotifications): Added. Code
26+
came from closeWindow and detachWindow.
27+
(WebInspectorClient::showWindowWithoutNotifications): Added. Code came
28+
from showWindow and attachWindow.
29+
30+
* WebCoreSupport/WebInspectorClient.h: Added
31+
{close,show}WindowWithoutNotifications and m_shouldAttachWhenShown.
32+
133
2009-01-06 Anders Carlsson <andersca@apple.com>
234

335
Reviewed by Sam Weinig.

WebKit/win/WebCoreSupport/WebInspectorClient.cpp

Lines changed: 77 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ WebInspectorClient::WebInspectorClient(WebView* webView)
7272
: m_inspectedWebView(webView)
7373
, m_hwnd(0)
7474
, m_webViewHwnd(0)
75+
, m_shouldAttachWhenShown(false)
7576
, m_attached(false)
7677
{
7778
ASSERT(m_inspectedWebView);
@@ -202,20 +203,13 @@ String WebInspectorClient::localizedStringsURL()
202203

203204
void WebInspectorClient::showWindow()
204205
{
205-
if (!m_hwnd)
206-
return;
207-
208-
updateWindowTitle();
209-
::SetWindowPos(m_hwnd, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
206+
showWindowWithoutNotifications();
210207
m_inspectedWebView->page()->inspectorController()->setWindowVisible(true);
211208
}
212209

213210
void WebInspectorClient::closeWindow()
214211
{
215-
if (!m_webView)
216-
return;
217-
218-
::ShowWindow(m_hwnd, SW_HIDE);
212+
closeWindowWithoutNotifications();
219213
m_inspectedWebView->page()->inspectorController()->setWindowVisible(false);
220214
}
221215

@@ -226,48 +220,24 @@ bool WebInspectorClient::windowVisible()
226220

227221
void WebInspectorClient::attachWindow()
228222
{
229-
ASSERT(m_hwnd);
230-
ASSERT(m_webView);
231-
ASSERT(m_inspectedWebViewHwnd);
232-
233223
if (m_attached)
234224
return;
235225

236-
WindowMessageBroadcaster::addListener(m_inspectedWebViewHwnd, this);
226+
m_shouldAttachWhenShown = true;
237227

238-
HWND hostWindow;
239-
if (FAILED(m_inspectedWebView->hostWindow((OLE_HANDLE*)&hostWindow)))
240-
return;
241-
242-
m_webView->setHostWindow((OLE_HANDLE)(ULONG64)hostWindow);
243-
::ShowWindow(m_hwnd, SW_HIDE);
244-
m_attached = true;
245-
246-
::SendMessage(hostWindow, WM_SIZE, 0, 0);
247-
248-
if (m_highlight && m_highlight->isShowing())
249-
m_highlight->update();
228+
closeWindowWithoutNotifications();
229+
showWindowWithoutNotifications();
250230
}
251231

252232
void WebInspectorClient::detachWindow()
253233
{
254234
if (!m_attached)
255235
return;
256236

257-
WindowMessageBroadcaster::removeListener(m_inspectedWebViewHwnd, this);
258-
259-
m_attached = false;
260-
261-
m_webView->setHostWindow((OLE_HANDLE)(ULONG64)m_hwnd);
262-
::ShowWindow(m_hwnd, SW_SHOW);
263-
::SendMessage(m_hwnd, WM_SIZE, 0, 0);
237+
m_shouldAttachWhenShown = false;
264238

265-
HWND hostWindow;
266-
if (SUCCEEDED(m_inspectedWebView->hostWindow((OLE_HANDLE*)&hostWindow)))
267-
::SendMessage(hostWindow, WM_SIZE, 0, 0);
268-
269-
if (m_highlight && m_highlight->isShowing())
270-
m_highlight->update();
239+
closeWindowWithoutNotifications();
240+
showWindowWithoutNotifications();
271241
}
272242

273243
void WebInspectorClient::setAttachedWindowHeight(unsigned height)
@@ -303,6 +273,74 @@ void WebInspectorClient::inspectedURLChanged(const String& newURL)
303273
updateWindowTitle();
304274
}
305275

276+
void WebInspectorClient::closeWindowWithoutNotifications()
277+
{
278+
if (!m_hwnd)
279+
return;
280+
281+
if (!m_attached) {
282+
ShowWindow(m_hwnd, SW_HIDE);
283+
return;
284+
}
285+
286+
ASSERT(m_webView);
287+
ASSERT(m_inspectedWebViewHwnd);
288+
ASSERT(!IsWindowVisible(m_hwnd));
289+
290+
// Remove the Inspector's WebView from the inspected WebView's parent window.
291+
WindowMessageBroadcaster::removeListener(m_inspectedWebViewHwnd, this);
292+
293+
m_attached = false;
294+
295+
m_webView->setHostWindow(reinterpret_cast<OLE_HANDLE>(m_hwnd));
296+
297+
// Make sure everything has the right size/position.
298+
HWND hostWindow;
299+
if (SUCCEEDED(m_inspectedWebView->hostWindow((OLE_HANDLE*)&hostWindow)))
300+
SendMessage(hostWindow, WM_SIZE, 0, 0);
301+
302+
if (m_highlight && m_highlight->isShowing())
303+
m_highlight->update();
304+
}
305+
306+
void WebInspectorClient::showWindowWithoutNotifications()
307+
{
308+
if (!m_hwnd)
309+
return;
310+
311+
ASSERT(m_webView);
312+
ASSERT(m_inspectedWebViewHwnd);
313+
314+
if (!m_shouldAttachWhenShown) {
315+
// Put the Inspector's WebView inside our window and show it.
316+
m_webView->setHostWindow(reinterpret_cast<OLE_HANDLE>(m_hwnd));
317+
SendMessage(m_hwnd, WM_SIZE, 0, 0);
318+
updateWindowTitle();
319+
320+
SetWindowPos(m_hwnd, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
321+
return;
322+
}
323+
324+
// Put the Inspector's WebView inside the inspected WebView's parent window.
325+
WindowMessageBroadcaster::addListener(m_inspectedWebViewHwnd, this);
326+
327+
HWND hostWindow;
328+
if (FAILED(m_inspectedWebView->hostWindow(reinterpret_cast<OLE_HANDLE*>(&hostWindow))))
329+
return;
330+
331+
m_webView->setHostWindow(reinterpret_cast<OLE_HANDLE>(hostWindow));
332+
333+
// Then hide our own window.
334+
ShowWindow(m_hwnd, SW_HIDE);
335+
336+
m_attached = true;
337+
338+
// Make sure everything has the right size/position.
339+
SendMessage(hostWindow, WM_SIZE, 0, 0);
340+
if (m_highlight && m_highlight->isShowing())
341+
m_highlight->update();
342+
}
343+
306344
void WebInspectorClient::updateWindowTitle()
307345
{
308346
// FIXME: The series of appends should be replaced with a call to String::format()

WebKit/win/WebCoreSupport/WebInspectorClient.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ class WebInspectorClient : public WebCore::InspectorClient, WebCore::WindowMessa
7171
private:
7272
~WebInspectorClient();
7373

74+
void closeWindowWithoutNotifications();
75+
void showWindowWithoutNotifications();
76+
7477
void updateWindowTitle();
7578

7679
LRESULT onGetMinMaxInfo(WPARAM, LPARAM);
@@ -88,6 +91,7 @@ class WebInspectorClient : public WebCore::InspectorClient, WebCore::WindowMessa
8891
COMPtr<WebView> m_webView;
8992
HWND m_webViewHwnd;
9093

94+
bool m_shouldAttachWhenShown;
9195
bool m_attached;
9296

9397
OwnPtr<WebNodeHighlight> m_highlight;

0 commit comments

Comments
 (0)
0