From 0275afdfb48738ccb20ff1850f2b05ef3c2c3786 Mon Sep 17 00:00:00 2001 From: Paul Rouget Date: Mon, 10 Aug 2020 15:10:15 +0200 Subject: [PATCH] Do not beautify title in libsimpleservo --- ports/libsimpleservo/api/src/lib.rs | 12 +----------- ports/libsimpleservo/capi/src/lib.rs | 11 ++++++++--- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/ports/libsimpleservo/api/src/lib.rs b/ports/libsimpleservo/api/src/lib.rs index 909714ecb0b..4c1523b6067 100644 --- a/ports/libsimpleservo/api/src/lib.rs +++ b/ports/libsimpleservo/api/src/lib.rs @@ -112,7 +112,7 @@ pub trait HostTrait { /// Throbber stops spinning. fn on_load_ended(&self); /// Page title has changed. - fn on_title_changed(&self, title: String); + fn on_title_changed(&self, title: Option); /// Allow Navigation. fn on_allow_navigation(&self, url: String) -> bool; /// Page URL has changed. @@ -590,16 +590,6 @@ impl ServoGlue { for (browser_id, event) in self.servo.get_events() { match event { EmbedderMsg::ChangePageTitle(title) => { - let fallback_title: String = if let Some(ref current_url) = self.current_url { - current_url.to_string() - } else { - String::from("Untitled") - }; - let title = match title { - Some(ref title) if title.len() > 0 => &**title, - _ => &fallback_title, - }; - let title = format!("{} - Servo", title); self.callbacks.host_callbacks.on_title_changed(title); }, EmbedderMsg::AllowNavigationRequest(pipeline_id, url) => { diff --git a/ports/libsimpleservo/capi/src/lib.rs b/ports/libsimpleservo/capi/src/lib.rs index fd5ca9165f5..0ea0e83e12f 100644 --- a/ports/libsimpleservo/capi/src/lib.rs +++ b/ports/libsimpleservo/capi/src/lib.rs @@ -764,10 +764,15 @@ impl HostTrait for HostCallbacks { (self.0.on_load_ended)(); } - fn on_title_changed(&self, title: String) { + fn on_title_changed(&self, title: Option) { debug!("on_title_changed"); - let title = CString::new(title).expect("Can't create string"); - (self.0.on_title_changed)(title.as_ptr()); + match title { + None => (self.0.on_title_changed)(std::ptr::null()), + Some(title) => { + let title = CString::new(title).expect("Can't create string"); + (self.0.on_title_changed)(title.as_ptr()); + }, + }; } fn on_allow_navigation(&self, url: String) -> bool {