Commit 896e8c6e authored by aroben@apple.com's avatar aroben@apple.com

Fix a couple of bugs where the node highlight would appear when it shouldn't

        There were at least two ways you could get the highlight to appear
        when it shouldn't:
          1) Selecting a node in the Inspector while the inspected WebView was
             in a background tab.
          2) Selecting a node in the Inspector, switching to another tab,
             closing the Inspector, then switching back to the inspected
             WebView's tab.

        This patch fixes the above two issues, and possibly others.

        show() and hide() are now private methods of WebNodeHighlight. They
        are replaced by a single public method,
        setShowsWhileWebViewIsVisible(bool). WebInspectorClient uses this to
        tell the highlight whether it should be showing when the inspected
        WebView is visible.

        Reviewed by John Sullivan.

        * WebCoreSupport/WebInspectorClient.cpp:
        (WebInspectorClient::highlight): If the highlight is already showing,
        it just needs to update since the highlighted node has changed. If the
        highlight is not showing, call setShowsWhileWebViewIsVisible(true) so
        that the highlight will show when the WebView is shown.
        (WebInspectorClient::hideHighlight): Changed to call
        setShowsWhileWebViewIsVisible(false) instead of hide().
        * WebNodeHighlight.cpp:
        (WebNodeHighlight::WebNodeHighlight): Initialize new member, and
        initialize m_inspectedWebViewWindow to its final value here instead of
        in show().
        (WebNodeHighlight::setShowsWhileWebViewIsVisible): Added. If we're not
        supposed to show ourselves when the WebView is visible, we hide
        ourselves and return. Otherwise, we make our visibility match the
        WebView's.
        (WebNodeHighlight::isWebViewVisible): Added.
        (WebNodeHighlight::show): Removed initialization of
        m_inspectedWebViewWindow (this is now done by our constructor). Added
        an assertion that we're supposed to show ourselves when the WebView is
        visible.
        (WebNodeHighlight::onWebViewShowWindow): If we shouldn't show
        ourselves when the WebView is visible, then we don't need to do
        anything at all when the WebView's visibility changes.
        * WebNodeHighlight.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@31164 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 86612616
2008-03-19 Adam Roben <aroben@apple.com>
Fix a couple of bugs where the node highlight would appear when it shouldn't
There were at least two ways you could get the highlight to appear
when it shouldn't:
1) Selecting a node in the Inspector while the inspected WebView was
in a background tab.
2) Selecting a node in the Inspector, switching to another tab,
closing the Inspector, then switching back to the inspected
WebView's tab.
This patch fixes the above two issues, and possibly others.
show() and hide() are now private methods of WebNodeHighlight. They
are replaced by a single public method,
setShowsWhileWebViewIsVisible(bool). WebInspectorClient uses this to
tell the highlight whether it should be showing when the inspected
WebView is visible.
Reviewed by John Sullivan.
* WebCoreSupport/WebInspectorClient.cpp:
(WebInspectorClient::highlight): If the highlight is already showing,
it just needs to update since the highlighted node has changed. If the
highlight is not showing, call setShowsWhileWebViewIsVisible(true) so
that the highlight will show when the WebView is shown.
(WebInspectorClient::hideHighlight): Changed to call
setShowsWhileWebViewIsVisible(false) instead of hide().
* WebNodeHighlight.cpp:
(WebNodeHighlight::WebNodeHighlight): Initialize new member, and
initialize m_inspectedWebViewWindow to its final value here instead of
in show().
(WebNodeHighlight::setShowsWhileWebViewIsVisible): Added. If we're not
supposed to show ourselves when the WebView is visible, we hide
ourselves and return. Otherwise, we make our visibility match the
WebView's.
(WebNodeHighlight::isWebViewVisible): Added.
(WebNodeHighlight::show): Removed initialization of
m_inspectedWebViewWindow (this is now done by our constructor). Added
an assertion that we're supposed to show ourselves when the WebView is
visible.
(WebNodeHighlight::onWebViewShowWindow): If we shouldn't show
ourselves when the WebView is visible, then we don't need to do
anything at all when the WebView's visibility changes.
* WebNodeHighlight.h:
2008-03-19 Adam Roben <aroben@apple.com>
Small WebNodeHighlight cleanup
......
......@@ -272,7 +272,10 @@ void WebInspectorClient::highlight(Node*)
if (!m_highlight)
m_highlight.set(new WebNodeHighlight(m_inspectedWebView));
m_highlight->show();
if (m_highlight->isShowing())
m_highlight->update();
else
m_highlight->setShowsWhileWebViewIsVisible(true);
if (IsWindowVisible(m_hwnd))
m_highlight->placeBehindWindow(m_hwnd);
......@@ -281,7 +284,7 @@ void WebInspectorClient::highlight(Node*)
void WebInspectorClient::hideHighlight()
{
if (m_highlight)
m_highlight->hide();
m_highlight->setShowsWhileWebViewIsVisible(false);
}
void WebInspectorClient::inspectedURLChanged(const String& newURL)
......
......@@ -48,10 +48,11 @@ static LPCTSTR kWebNodeHighlightPointerProp = TEXT("WebNodeHighlightPointer");
WebNodeHighlight::WebNodeHighlight(WebView* webView)
: m_inspectedWebView(webView)
, m_inspectedWebViewWindow(0)
, m_overlay(0)
, m_observedWindow(0)
, m_showsWhileWebViewIsVisible(false)
{
m_inspectedWebView->viewWindow(reinterpret_cast<OLE_HANDLE*>(&m_inspectedWebViewWindow));
}
WebNodeHighlight::~WebNodeHighlight()
......@@ -65,12 +66,39 @@ WebNodeHighlight::~WebNodeHighlight()
::DestroyWindow(m_overlay);
}
void WebNodeHighlight::setShowsWhileWebViewIsVisible(bool shows)
{
if (m_showsWhileWebViewIsVisible == shows)
return;
m_showsWhileWebViewIsVisible = shows;
if (!m_showsWhileWebViewIsVisible) {
hide();
return;
}
bool webViewVisible = isWebViewVisible();
if (isShowing() == webViewVisible)
return;
if (webViewVisible)
show();
else
hide();
}
bool WebNodeHighlight::isWebViewVisible() const
{
if (!m_inspectedWebViewWindow)
return false;
return IsWindowVisible(m_inspectedWebViewWindow);
}
void WebNodeHighlight::show()
{
if (!m_overlay) {
if (FAILED(m_inspectedWebView->viewWindow(reinterpret_cast<OLE_HANDLE*>(&m_inspectedWebViewWindow))) || !IsWindow(m_inspectedWebViewWindow))
return;
registerOverlayClass();
m_overlay = ::CreateWindowEx(WS_EX_LAYERED | WS_EX_TOOLWINDOW, kOverlayWindowClassName, 0, WS_POPUP,
......@@ -86,6 +114,8 @@ void WebNodeHighlight::show()
WindowMessageBroadcaster::addListener(m_inspectedWebViewWindow, this);
}
ASSERT(m_showsWhileWebViewIsVisible);
update();
SetWindowPos(m_overlay, 0, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
}
......@@ -202,6 +232,9 @@ LRESULT CALLBACK OverlayWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
void WebNodeHighlight::onWebViewShowWindow(bool showing)
{
if (!m_showsWhileWebViewIsVisible)
return;
if (isShowing() == showing)
return;
......
......@@ -42,8 +42,7 @@ public:
WebNodeHighlight(WebView*);
~WebNodeHighlight();
void show();
void hide();
void setShowsWhileWebViewIsVisible(bool);
bool isShowing() const;
......@@ -52,6 +51,11 @@ public:
void placeBehindWindow(HWND);
private:
void show();
void hide();
bool isWebViewVisible() const;
virtual void windowReceivedMessage(HWND, UINT message, WPARAM, LPARAM);
void onWebViewShowWindow(bool showing);
......@@ -62,6 +66,7 @@ private:
HWND m_inspectedWebViewWindow;
HWND m_overlay;
HWND m_observedWindow;
bool m_showsWhileWebViewIsVisible;
friend static LRESULT CALLBACK OverlayWndProc(HWND, UINT, WPARAM, LPARAM);
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment