Title: [246960] trunk/Source
Revision
246960
Author
hironori.fu...@sony.com
Date
2019-06-30 19:32:19 -0700 (Sun, 30 Jun 2019)

Log Message

[Win] Multiline mode of tooltip control does word-wrapping very slowly
https://bugs.webkit.org/show_bug.cgi?id=198989

Reviewed by Ross Kirsling.

Source/WebKit:

* UIProcess/win/WebView.cpp:
(WebKit::truncatedString): Added.
(WebKit::WebView::setToolTip): Use truncatedString.

Source/WebKitLegacy/win:

* WebView.cpp:
(truncatedString): Added.
(WebView::setToolTip): Use truncatedString.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (246959 => 246960)


--- trunk/Source/WebKit/ChangeLog	2019-07-01 02:30:40 UTC (rev 246959)
+++ trunk/Source/WebKit/ChangeLog	2019-07-01 02:32:19 UTC (rev 246960)
@@ -1,3 +1,14 @@
+2019-06-30  Fujii Hironori  <hironori.fu...@sony.com>
+
+        [Win] Multiline mode of tooltip control does word-wrapping very slowly
+        https://bugs.webkit.org/show_bug.cgi?id=198989
+
+        Reviewed by Ross Kirsling.
+
+        * UIProcess/win/WebView.cpp:
+        (WebKit::truncatedString): Added.
+        (WebKit::WebView::setToolTip): Use truncatedString.
+
 2019-06-30  Basuke Suzuki  <basuke.suz...@sony.com>
 
         Pass WebProcess information to platformInitializeWebProcess().

Modified: trunk/Source/WebKit/UIProcess/win/WebView.cpp (246959 => 246960)


--- trunk/Source/WebKit/UIProcess/win/WebView.cpp	2019-07-01 02:30:40 UTC (rev 246959)
+++ trunk/Source/WebKit/UIProcess/win/WebView.cpp	2019-07-01 02:32:19 UTC (rev 246960)
@@ -869,6 +869,20 @@
     }
 }
 
+static Vector<wchar_t> truncatedString(const String& string)
+{
+    // Truncate tooltip texts because multiline mode of tooltip control does word-wrapping very slowly
+    auto maxLength = 1024;
+    auto buffer = string.wideCharacters();
+    if (buffer.size() > maxLength) {
+        buffer[maxLength - 4] = L'.';
+        buffer[maxLength - 3] = L'.';
+        buffer[maxLength - 2] = L'.';
+        buffer[maxLength - 1] = L'\0';
+    }
+    return buffer;
+}
+
 void WebView::setToolTip(const String& toolTip)
 {
     if (!m_toolTipWindow)
@@ -879,8 +893,8 @@
         info.cbSize = sizeof(info);
         info.uFlags = TTF_IDISHWND;
         info.uId = reinterpret_cast<UINT_PTR>(nativeWindow());
-        Vector<wchar_t> toolTipCharacters = toolTip.wideCharacters(); // Retain buffer long enough to make the SendMessage call
-        info.lpszText = const_cast<wchar_t*>(toolTipCharacters.data());
+        auto toolTipCharacters = truncatedString(toolTip); // Retain buffer long enough to make the SendMessage call
+        info.lpszText = toolTipCharacters.data();
         ::SendMessage(m_toolTipWindow, TTM_UPDATETIPTEXT, 0, reinterpret_cast<LPARAM>(&info));
     }
 

Modified: trunk/Source/WebKitLegacy/win/ChangeLog (246959 => 246960)


--- trunk/Source/WebKitLegacy/win/ChangeLog	2019-07-01 02:30:40 UTC (rev 246959)
+++ trunk/Source/WebKitLegacy/win/ChangeLog	2019-07-01 02:32:19 UTC (rev 246960)
@@ -1,3 +1,14 @@
+2019-06-30  Fujii Hironori  <hironori.fu...@sony.com>
+
+        [Win] Multiline mode of tooltip control does word-wrapping very slowly
+        https://bugs.webkit.org/show_bug.cgi?id=198989
+
+        Reviewed by Ross Kirsling.
+
+        * WebView.cpp:
+        (truncatedString): Added.
+        (WebView::setToolTip): Use truncatedString.
+
 2019-06-16  Darin Adler  <da...@apple.com>
 
         Rename AtomicString to AtomString

Modified: trunk/Source/WebKitLegacy/win/WebView.cpp (246959 => 246960)


--- trunk/Source/WebKitLegacy/win/WebView.cpp	2019-07-01 02:30:40 UTC (rev 246959)
+++ trunk/Source/WebKitLegacy/win/WebView.cpp	2019-07-01 02:32:19 UTC (rev 246960)
@@ -3216,6 +3216,20 @@
     ::SetWindowPos(m_toolTipHwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
 }
 
+static Vector<wchar_t> truncatedString(const String& string)
+{
+    // Truncate tooltip texts because multiline mode of tooltip control does word-wrapping very slowly
+    auto maxLength = 1024;
+    auto buffer = string.wideCharacters();
+    if (buffer.size() > maxLength) {
+        buffer[maxLength - 4] = L'.';
+        buffer[maxLength - 3] = L'.';
+        buffer[maxLength - 2] = L'.';
+        buffer[maxLength - 1] = L'\0';
+    }
+    return buffer;
+}
+
 void WebView::setToolTip(const String& toolTip)
 {
     if (!m_toolTipHwnd)
@@ -3231,8 +3245,8 @@
         info.cbSize = sizeof(info);
         info.uFlags = TTF_IDISHWND;
         info.uId = reinterpret_cast<UINT_PTR>(m_viewWindow);
-        Vector<wchar_t> toolTipCharacters = m_toolTip.wideCharacters(); // Retain buffer long enough to make the SendMessage call
-        info.lpszText = const_cast<wchar_t*>(toolTipCharacters.data());
+        auto toolTipCharacters = truncatedString(m_toolTip); // Retain buffer long enough to make the SendMessage call
+        info.lpszText = toolTipCharacters.data();
         ::SendMessage(m_toolTipHwnd, TTM_UPDATETIPTEXT, 0, reinterpret_cast<LPARAM>(&info));
     }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to