Skip to content

Commit

Permalink
feat(ui): set current url on the navbar (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Tsai authored Sep 5, 2024
1 parent d8af7c4 commit 5079f3c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
4 changes: 2 additions & 2 deletions resources/panel.html

Large diffs are not rendered by default.

25 changes: 23 additions & 2 deletions src/webview.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
use arboard::Clipboard;
use base::id::{PipelineNamespace, PipelineNamespaceId, WebViewId};
use base::id::{BrowsingContextId, PipelineNamespace, PipelineNamespaceId, WebViewId};
use compositing_traits::ConstellationMsg;
use crossbeam_channel::Sender;
use embedder_traits::{CompositorEventVariant, EmbedderMsg, PromptDefinition};
use script_traits::TraversalDirection;
use ipc_channel::ipc;
use script_traits::{
webdriver_msg::{WebDriverJSResult, WebDriverScriptCommand},
TraversalDirection, WebDriverCommandMsg,
};
use servo_url::ServoUrl;
use url::Url;
use webrender_api::units::DeviceIntRect;
Expand Down Expand Up @@ -119,6 +123,23 @@ impl Window {
}
}
}
EmbedderMsg::HistoryChanged(list, index) => {
let url = list.get(index).unwrap();
if let Some(panel) = self.panel.as_ref() {
let (tx, rx) = ipc::channel::<WebDriverJSResult>().unwrap();
send_to_constellation(
sender,
ConstellationMsg::WebDriverCommand(WebDriverCommandMsg::ScriptCommand(
BrowsingContextId::from(panel.webview_id),
WebDriverScriptCommand::ExecuteScript(
format!("window.navbar.setNavbarUrl('{}')", url.as_str()),
tx,
),
)),
);
let _ = rx.recv();
}
}
EmbedderMsg::EventDelivered(event) => {
if let CompositorEventVariant::MouseButtonEvent = event {
send_to_constellation(sender, ConstellationMsg::FocusWebView(webview_id));
Expand Down

0 comments on commit 5079f3c

Please sign in to comment.