mirror of
https://github.com/servo/servo.git
synced 2025-09-30 08:39:16 +01:00
servoshell: Display favicons in tab bar (#36680)
Before:  After:  This PR moves the favicon, title and close button into a single egui Frame. Doing this allows us to get rid of some of the previous layout magic (like setting a border radius on the left corners of the label and the right corners of the button so they appear as one widget). It also ensures that the tab is highlighted when the close button (not the label) is hovered. Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
parent
461ff26812
commit
d65e16dd84
2 changed files with 154 additions and 66 deletions
|
@ -5,6 +5,7 @@
|
|||
use std::cell::{Ref, RefCell, RefMut};
|
||||
use std::collections::HashMap;
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::mem;
|
||||
use std::path::PathBuf;
|
||||
use std::rc::Rc;
|
||||
|
||||
|
@ -84,6 +85,10 @@ pub struct RunningAppStateInner {
|
|||
/// Whether or not Servo needs to repaint its display. Currently this is global
|
||||
/// because every `WebView` shares a `RenderingContext`.
|
||||
need_repaint: bool,
|
||||
|
||||
/// List of webviews that have favicon textures which are not yet uploaded
|
||||
/// to the GPU by egui.
|
||||
pending_favicon_loads: Vec<WebViewId>,
|
||||
}
|
||||
|
||||
impl Drop for RunningAppState {
|
||||
|
@ -114,6 +119,7 @@ impl RunningAppState {
|
|||
gamepad_support: GamepadSupport::maybe_new(),
|
||||
need_update: false,
|
||||
need_repaint: false,
|
||||
pending_favicon_loads: Default::default(),
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
@ -513,6 +519,11 @@ impl RunningAppState {
|
|||
.load_status_senders
|
||||
.remove(&webview_id);
|
||||
}
|
||||
|
||||
/// Return a list of all webviews that have favicons that have not yet been loaded by egui.
|
||||
pub(crate) fn take_pending_favicon_loads(&self) -> Vec<WebViewId> {
|
||||
mem::take(&mut self.inner_mut().pending_favicon_loads)
|
||||
}
|
||||
}
|
||||
|
||||
struct ServoShellServoDelegate;
|
||||
|
@ -800,4 +811,10 @@ impl WebViewDelegate for RunningAppState {
|
|||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn notify_favicon_changed(&self, webview: WebView) {
|
||||
let mut inner = self.inner_mut();
|
||||
inner.pending_favicon_loads.push(webview.id());
|
||||
inner.need_repaint = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue