From 7c4ba51f51febe36dda0a11a1403c5804c18746a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20W=C3=BClker?= Date: Wed, 28 Aug 2024 18:57:28 +0200 Subject: [PATCH] Don't allow minibrowser tab titles to be empty (#33229) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * avoid unnecessary clones when setting tab title in minibrowser This is of course not a performance issue, but rather just bad style. Especially since the url doesn't even need to be .clone()'d in the first place. Signed-off-by: Simon Wülker * Don't allow empty tab titles in minibrowser These look very confusing. If the page has no title its better to fall back to the url instead of displaying absolutely nothing. (This is what firefox seems to do too) Signed-off-by: Simon Wülker --------- Signed-off-by: Simon Wülker --- ports/servoshell/desktop/minibrowser.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ports/servoshell/desktop/minibrowser.rs b/ports/servoshell/desktop/minibrowser.rs index af02a49538c..36c46b6455e 100644 --- a/ports/servoshell/desktop/minibrowser.rs +++ b/ports/servoshell/desktop/minibrowser.rs @@ -275,10 +275,10 @@ impl Minibrowser { egui::Layout::left_to_right(egui::Align::Center), |ui| { for (webview_id, webview) in webviews.webviews().into_iter() { - let msg = match (webview.title.clone(), webview.url.clone()) { - (Some(title), _) => title, - (None, Some(url)) => url.to_string(), - _ => "".to_owned(), + let msg = match (&webview.title, &webview.url) { + (Some(title), _) if !title.is_empty() => title.clone(), + (_, Some(url)) => url.to_string(), + _ => "New Tab".to_owned(), }; let tab = ui.add(SelectableLabel::new( webview.focused,