Changeset 24022 in webkit


Ignore:
Timestamp:
Jul 5, 2007 1:16:06 PM (17 years ago)
Author:
aroben
Message:

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.
Location:
trunk/WebKit/win
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/win/ChangeLog

    r24000 r24022  
     12007-07-05  Adam Roben  <aroben@apple.com>
     2
     3        Fix Bug 14143: Tooltips not displayed on Windows
     4        http://bugs.webkit.org/show_bug.cgi?id=14143
     5        <rdar://problem/4719799>
     6
     7        Reviewed by Oliver.
     8
     9        * WebChromeClient.cpp:
     10        (WebChromeClient::setToolTip): Call up to WebView.
     11        * WebView.cpp:
     12        (WebView::WebView): Initialize m_toolTipHwnd member.
     13        (WebView::initWithFrame): Set up the tool tip window.
     14        (initCommonControls): Added.
     15        (WebView::initializeToolTipWindow): Added.
     16        (WebView::setToolTip): Set the tool tip text and enable/disable the
     17        tool tip.
     18        * WebView.h: Added/updated declarations.
     19
    1202007-07-04  Adam Roben  <aroben@apple.com>
    221
  • trunk/WebKit/win/WebChromeClient.cpp

    r24000 r24022  
    439439}
    440440
    441 void WebChromeClient::setToolTip(const String&)
    442 {
    443 }
     441void WebChromeClient::setToolTip(const String& toolTip)
     442{
     443    m_webView->setToolTip(toolTip);
     444}
  • trunk/WebKit/win/WebView.cpp

    r23999 r24022  
    102102const int WM_VISTA_MOUSEHWHEEL = 0x020E;
    103103
     104static const int maxToolTipWidth = 250;
     105
    104106static ATOM registerWebView();
    105107static LRESULT CALLBACK WebViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
     
    133135, m_smartInsertDeleteEnabled(false)
    134136, m_didClose(false)
     137, m_toolTipHwnd(0)
    135138{
    136139    KJS::Collector::registerAsMainThread();
     
    17341737
    17351738    initializeCacheSizesIfNecessary();
     1739    initializeToolTipWindow();
    17361740
    17371741    // Update WebCore with preferences.  These values will either come from an archived WebPreferences,
     
    17621766}
    17631767
     1768static bool initCommonControls()
     1769{
     1770    static bool haveInitialized = false;
     1771    if (haveInitialized)
     1772        return true;
     1773
     1774    INITCOMMONCONTROLSEX init;
     1775    init.dwSize = sizeof(init);
     1776    init.dwICC = ICC_TREEVIEW_CLASSES;
     1777    haveInitialized = !!::InitCommonControlsEx(&init);
     1778    return haveInitialized;
     1779}
     1780
     1781void WebView::initializeToolTipWindow()
     1782{
     1783    if (!initCommonControls())
     1784        return;
     1785
     1786    m_toolTipHwnd = CreateWindowEx(0, TOOLTIPS_CLASS, 0, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
     1787                                   CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
     1788                                   m_viewWindow, 0, 0, 0);
     1789    if (!m_toolTipHwnd)
     1790        return;
     1791
     1792    TOOLINFO info = {0};
     1793    info.cbSize = sizeof(info);
     1794    info.uFlags = TTF_IDISHWND | TTF_SUBCLASS ;
     1795    info.uId = reinterpret_cast<UINT_PTR>(m_viewWindow);
     1796
     1797    ::SendMessage(m_toolTipHwnd, TTM_ADDTOOL, 0, reinterpret_cast<LPARAM>(&info));
     1798    ::SendMessage(m_toolTipHwnd, TTM_SETMAXTIPWIDTH, 0, maxToolTipWidth);
     1799
     1800    ::SetWindowPos(m_toolTipHwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
     1801}
     1802
     1803void WebView::setToolTip(const String& toolTip)
     1804{
     1805    if (!m_toolTipHwnd)
     1806        return;
     1807
     1808    if (toolTip == m_toolTip)
     1809        return;
     1810
     1811    m_toolTip = toolTip;
     1812
     1813    if (!m_toolTip.isEmpty()) {
     1814        TOOLINFO info = {0};
     1815        info.cbSize = sizeof(info);
     1816        info.uFlags = TTF_IDISHWND;
     1817        info.uId = reinterpret_cast<UINT_PTR>(m_viewWindow);
     1818        info.lpszText = _wcsdup(m_toolTip.charactersWithNullTermination());
     1819        ::SendMessage(m_toolTipHwnd, TTM_UPDATETIPTEXT, 0, reinterpret_cast<LPARAM>(&info));
     1820    }
     1821
     1822    ::SendMessage(m_toolTipHwnd, TTM_ACTIVATE, !m_toolTip.isEmpty(), 0);
     1823}
    17641824
    17651825HRESULT STDMETHODCALLTYPE WebView::setUIDelegate(
  • trunk/WebKit/win/WebView.h

    r23677 r24022  
    653653    bool isPainting() const { return m_paintCount > 0; }
    654654
     655    void setToolTip(const WebCore::String&);
     656
    655657protected:
    656658    static bool allowSiteSpecificHacks() { return s_allowSiteSpecificHacks; }
     
    658660    bool continuousCheckingAllowed();
    659661    void initializeCacheSizesIfNecessary();
     662    void initializeToolTipWindow();
    660663
    661664    ULONG m_refCount;
     
    699702    bool m_didClose;
    700703
     704    HWND m_toolTipHwnd;
     705    WebCore::String m_toolTip;
     706
    701707    static bool s_allowSiteSpecificHacks;
    702708};
Note: See TracChangeset for help on using the changeset viewer.