Skip to content

Commit

Permalink
rebase and review fix
Browse files Browse the repository at this point in the history
  • Loading branch information
atbrakhi committed May 21, 2024
1 parent 3a9adef commit b0ed6dd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 25 deletions.
36 changes: 16 additions & 20 deletions ports/servoshell/minibrowser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub struct Minibrowser {

load_status: LoadStatus,

hovered_link: Option<String>,
status_text: Option<String>,
}

pub enum MinibrowserEvent {
Expand Down Expand Up @@ -88,7 +88,7 @@ impl Minibrowser {
location: RefCell::new(initial_url.to_string()),
location_dirty: false.into(),
load_status: LoadStatus::LoadComplete,
hovered_link: None,
status_text: None,
}
}

Expand Down Expand Up @@ -239,20 +239,16 @@ impl Minibrowser {
};
let mut embedder_events = vec![];

if self.hovered_link.is_some() {
TopBottomPanel::bottom("innner_hover_links")
.max_height(0.0)
.show(ctx, |ui| {
let position = Some(pos2(0.0, ui.cursor().max.y));
egui::containers::popup::show_tooltip_at(
ctx,
"tooltip_for_hovered_link".into(),
position,
|ui| {
ui.label(self.hovered_link.clone().unwrap().to_string());
},
)
});
if let Some(status_text) = &self.status_text {
let position = Some(pos2(0.0, ctx.available_rect().max.y));
egui::containers::popup::show_tooltip_at(
ctx,
"tooltip_for_status_text".into(),
position,
|ui| {
ui.label(status_text.clone());
},
);
}

CentralPanel::default()
Expand Down Expand Up @@ -409,12 +405,12 @@ impl Minibrowser {
need_update
}

pub fn update_hovered_link(
pub fn update_status_text(
&mut self,
browser: &mut WebViewManager<dyn WindowPortsMethods>,
) -> bool {
let need_update = browser.hovered_link() != self.hovered_link;
self.hovered_link = browser.hovered_link();
let need_update = browser.status_text() != self.status_text;
self.status_text = browser.status_text();
need_update
}

Expand All @@ -430,6 +426,6 @@ impl Minibrowser {
// does not short-circuit.
self.update_location_in_toolbar(browser) |
self.update_spinner_in_toolbar(browser) |
self.update_hovered_link(browser)
self.update_status_text(browser)
}
}
10 changes: 5 additions & 5 deletions ports/servoshell/webview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use crate::window_trait::{WindowPortsMethods, LINE_HEIGHT};
pub struct WebViewManager<Window: WindowPortsMethods + ?Sized> {
current_url: Option<ServoUrl>,
current_url_string: Option<String>,
hovered_link: Option<String>,
status_text: Option<String>,

/// List of top-level browsing contexts.
/// Modified by EmbedderMsg::WebViewOpened and EmbedderMsg::WebViewClosed,
Expand Down Expand Up @@ -87,7 +87,7 @@ where
title: None,
current_url: None,
current_url_string: None,
hovered_link: None,
status_text: None,
webviews: HashMap::default(),
creation_order: vec![],
focused_webview_id: None,
Expand Down Expand Up @@ -132,8 +132,8 @@ where
self.load_status
}

pub fn hovered_link(&self) -> Option<String> {
self.hovered_link.clone()
pub fn status_text(&self) -> Option<String> {
self.status_text.clone()
}

pub fn get_events(&mut self) -> Vec<EmbedderEvent> {
Expand Down Expand Up @@ -448,7 +448,7 @@ where
}
match msg {
EmbedderMsg::Status(status) => {
self.hovered_link = status;
self.status_text = status;
need_update = true;
},
EmbedderMsg::ChangePageTitle(title) => {
Expand Down

0 comments on commit b0ed6dd

Please sign in to comment.