Title: [264217] trunk/Tools
- Revision
- 264217
- Author
- [email protected]
- Date
- 2020-07-10 06:20:20 -0700 (Fri, 10 Jul 2020)
Log Message
[GTK] MiniBrowser: title of back-forward menu items needs to be truncated when it's too large
https://bugs.webkit.org/show_bug.cgi?id=214180
Reviewed by Adrian Perez de Castro.
The popover menu doesn't set ellipsize on the inner label, so we need to do it manually. In the case of GTK4 we
also need to markup escape it.
* MiniBrowser/gtk/BrowserWindow.c:
(browserWindowCreateBackForwardMenu):
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (264216 => 264217)
--- trunk/Tools/ChangeLog 2020-07-10 12:47:51 UTC (rev 264216)
+++ trunk/Tools/ChangeLog 2020-07-10 13:20:20 UTC (rev 264217)
@@ -1,3 +1,16 @@
+2020-07-10 Carlos Garcia Campos <[email protected]>
+
+ [GTK] MiniBrowser: title of back-forward menu items needs to be truncated when it's too large
+ https://bugs.webkit.org/show_bug.cgi?id=214180
+
+ Reviewed by Adrian Perez de Castro.
+
+ The popover menu doesn't set ellipsize on the inner label, so we need to do it manually. In the case of GTK4 we
+ also need to markup escape it.
+
+ * MiniBrowser/gtk/BrowserWindow.c:
+ (browserWindowCreateBackForwardMenu):
+
2020-07-09 Yusuke Suzuki <[email protected]>
Add Slack-aware WebKitBot implementation
Modified: trunk/Tools/MiniBrowser/gtk/BrowserWindow.c (264216 => 264217)
--- trunk/Tools/MiniBrowser/gtk/BrowserWindow.c 2020-07-10 12:47:51 UTC (rev 264216)
+++ trunk/Tools/MiniBrowser/gtk/BrowserWindow.c 2020-07-10 13:20:20 UTC (rev 264217)
@@ -225,6 +225,28 @@
if (!title || !*title)
title = webkit_back_forward_list_item_get_uri(item);
+ char *displayTitle;
+#define MAX_TITLE 100
+#if GTK_CHECK_VERSION(3, 98, 5)
+ char *escapedTitle = g_markup_escape_text(title, -1);
+ if (strlen(escapedTitle) > MAX_TITLE) {
+ displayTitle = g_strndup(escapedTitle, MAX_TITLE);
+ g_free(escapedTitle);
+ displayTitle[MAX_TITLE - 1] = 0xA6;
+ displayTitle[MAX_TITLE - 2] = 0x80;
+ displayTitle[MAX_TITLE - 3] = 0xE2;
+ } else
+ displayTitle = escapedTitle;
+#else
+ displayTitle = g_strndup(title, MIN(MAX_TITLE, strlen(title)));
+ if (strlen(title) > MAX_TITLE) {
+ displayTitle[MAX_TITLE - 1] = 0xA6;
+ displayTitle[MAX_TITLE - 2] = 0x80;
+ displayTitle[MAX_TITLE - 3] = 0xE2;
+ }
+#endif
+#undef MAX_TITLE
+
char *actionName = g_strdup_printf("action-%lu", ++actionId);
GSimpleAction *action = "" NULL);
g_object_set_data_full(G_OBJECT(action), "back-forward-list-item", g_object_ref(item), g_object_unref);
@@ -233,10 +255,11 @@
g_object_unref(action);
char *detailedActionName = g_strdup_printf("%s.%s", isBack ? "bf-back" : "bf-forward", actionName);
- GMenuItem *menuItem = g_menu_item_new(title, detailedActionName);
+ GMenuItem *menuItem = g_menu_item_new(displayTitle, detailedActionName);
g_menu_append_item(menu, menuItem);
g_object_unref(menuItem);
+ g_free(displayTitle);
g_free(detailedActionName);
g_free(actionName);
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes