Skip to content
Permalink
Browse files
Fix Bug 14143: Tooltips not displayed on Windows
http://bugs.webkit.org/show_bug.cgi?id=14143
<rdar://problem/4719799>

Reviewed by Oliver.

* WebChromeClient.cpp:
(WebChromeClient::setToolTip): Call up to WebView.
* WebView.cpp:
(WebView::WebView): Initialize m_toolTipHwnd member.
(WebView::initWithFrame): Set up the tool tip window.
(initCommonControls): Added.
(WebView::initializeToolTipWindow): Added.
(WebView::setToolTip): Set the tool tip text and enable/disable the
tool tip.
* WebView.h: Added/updated declarations.


Canonical link: https://commits.webkit.org/18764@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@24022 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
aroben committed Jul 5, 2007
1 parent a8ebc3d commit 8df1a9541628b4f35c377d7a0f3d0f7090f3e664
Showing 4 changed files with 87 additions and 1 deletion.
@@ -1,3 +1,22 @@
2007-07-05 Adam Roben <aroben@apple.com>

Fix Bug 14143: Tooltips not displayed on Windows
http://bugs.webkit.org/show_bug.cgi?id=14143
<rdar://problem/4719799>

Reviewed by Oliver.

* WebChromeClient.cpp:
(WebChromeClient::setToolTip): Call up to WebView.
* WebView.cpp:
(WebView::WebView): Initialize m_toolTipHwnd member.
(WebView::initWithFrame): Set up the tool tip window.
(initCommonControls): Added.
(WebView::initializeToolTipWindow): Added.
(WebView::setToolTip): Set the tool tip text and enable/disable the
tool tip.
* WebView.h: Added/updated declarations.

2007-07-04 Adam Roben <aroben@apple.com>

Added a stub for WebChromeClient::setToolTip
@@ -438,6 +438,7 @@ void WebChromeClient::mouseDidMoveOverElement(const HitTestResult& result, unsig
uiDelegate->mouseDidMoveOverElement(m_webView, element.get(), modifierFlags);
}

void WebChromeClient::setToolTip(const String&)
void WebChromeClient::setToolTip(const String& toolTip)
{
m_webView->setToolTip(toolTip);
}
@@ -101,6 +101,8 @@ const LPCWSTR kWebViewWindowClassName = L"WebViewWindowClass";
const int WM_XP_THEMECHANGED = 0x031A;
const int WM_VISTA_MOUSEHWHEEL = 0x020E;

static const int maxToolTipWidth = 250;

static ATOM registerWebView();
static LRESULT CALLBACK WebViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

@@ -132,6 +134,7 @@ WebView::WebView()
, m_hasSpellCheckerDocumentTag(false)
, m_smartInsertDeleteEnabled(false)
, m_didClose(false)
, m_toolTipHwnd(0)
{
KJS::Collector::registerAsMainThread();

@@ -1733,6 +1736,7 @@ HRESULT STDMETHODCALLTYPE WebView::initWithFrame(
ShowWindow(m_viewWindow, SW_SHOW);

initializeCacheSizesIfNecessary();
initializeToolTipWindow();

// Update WebCore with preferences. These values will either come from an archived WebPreferences,
// or from the standard preferences, depending on whether this method was called from initWithCoder:
@@ -1761,6 +1765,62 @@ HRESULT STDMETHODCALLTYPE WebView::initWithFrame(
return hr;
}

static bool initCommonControls()
{
static bool haveInitialized = false;
if (haveInitialized)
return true;

INITCOMMONCONTROLSEX init;
init.dwSize = sizeof(init);
init.dwICC = ICC_TREEVIEW_CLASSES;
haveInitialized = !!::InitCommonControlsEx(&init);
return haveInitialized;
}

void WebView::initializeToolTipWindow()
{
if (!initCommonControls())
return;

m_toolTipHwnd = CreateWindowEx(0, TOOLTIPS_CLASS, 0, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
m_viewWindow, 0, 0, 0);
if (!m_toolTipHwnd)
return;

TOOLINFO info = {0};
info.cbSize = sizeof(info);
info.uFlags = TTF_IDISHWND | TTF_SUBCLASS ;
info.uId = reinterpret_cast<UINT_PTR>(m_viewWindow);

::SendMessage(m_toolTipHwnd, TTM_ADDTOOL, 0, reinterpret_cast<LPARAM>(&info));
::SendMessage(m_toolTipHwnd, TTM_SETMAXTIPWIDTH, 0, maxToolTipWidth);

::SetWindowPos(m_toolTipHwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
}

void WebView::setToolTip(const String& toolTip)
{
if (!m_toolTipHwnd)
return;

if (toolTip == m_toolTip)
return;

m_toolTip = toolTip;

if (!m_toolTip.isEmpty()) {
TOOLINFO info = {0};
info.cbSize = sizeof(info);
info.uFlags = TTF_IDISHWND;
info.uId = reinterpret_cast<UINT_PTR>(m_viewWindow);
info.lpszText = _wcsdup(m_toolTip.charactersWithNullTermination());
::SendMessage(m_toolTipHwnd, TTM_UPDATETIPTEXT, 0, reinterpret_cast<LPARAM>(&info));
}

::SendMessage(m_toolTipHwnd, TTM_ACTIVATE, !m_toolTip.isEmpty(), 0);
}

HRESULT STDMETHODCALLTYPE WebView::setUIDelegate(
/* [in] */ IWebUIDelegate* d)
@@ -652,11 +652,14 @@ class WebView

bool isPainting() const { return m_paintCount > 0; }

void setToolTip(const WebCore::String&);

protected:
static bool allowSiteSpecificHacks() { return s_allowSiteSpecificHacks; }
void preflightSpellChecker();
bool continuousCheckingAllowed();
void initializeCacheSizesIfNecessary();
void initializeToolTipWindow();

ULONG m_refCount;
WebCore::String m_groupName;
@@ -698,6 +701,9 @@ class WebView
bool m_smartInsertDeleteEnabled;
bool m_didClose;

HWND m_toolTipHwnd;
WebCore::String m_toolTip;

static bool s_allowSiteSpecificHacks;
};

0 comments on commit 8df1a95

Please sign in to comment.