diff --git a/.gitignore b/.gitignore
index 519b7e3..c470e98 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,6 @@ Cargo.lock
libmozjs*
cargo-sources.json
-resources/
-!resources/panel.html
-!resources/context-menu.html
\ No newline at end of file
+resources/*
+!resources/components/
+!resources/prefs.json
\ No newline at end of file
diff --git a/Cargo.toml b/Cargo.toml
index 5f852af..d6f6213 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -106,8 +106,6 @@ cargo-packager-resource-resolver = { version = "0.1.1", features = [
url = { workspace = true }
headers = "0.3"
versoview_messages = { path = "./versoview_messages" }
-
-[target.'cfg(all(unix, not(apple), not(android)))'.dependencies]
serde_json = "1.0"
serde = { workspace = true }
diff --git a/resources/context_menu.html b/resources/components/context_menu.html
similarity index 100%
rename from resources/context_menu.html
rename to resources/components/context_menu.html
diff --git a/resources/panel.html b/resources/components/panel.html
similarity index 100%
rename from resources/panel.html
rename to resources/components/panel.html
diff --git a/resources/components/prompt/alert.html b/resources/components/prompt/alert.html
new file mode 100644
index 0000000..395597e
--- /dev/null
+++ b/resources/components/prompt/alert.html
@@ -0,0 +1,54 @@
+
+
+
+
+
+
+
+
+
diff --git a/resources/components/prompt/ok_cancel.html b/resources/components/prompt/ok_cancel.html
new file mode 100644
index 0000000..385fce5
--- /dev/null
+++ b/resources/components/prompt/ok_cancel.html
@@ -0,0 +1,57 @@
+
+
+
+
+
+
+
+
+
diff --git a/resources/components/prompt/prompt.html b/resources/components/prompt/prompt.html
new file mode 100644
index 0000000..14a63f8
--- /dev/null
+++ b/resources/components/prompt/prompt.html
@@ -0,0 +1,72 @@
+
+
+
+
+
+
+
+
+
diff --git a/resources/components/prompt/prompt_test.html b/resources/components/prompt/prompt_test.html
new file mode 100644
index 0000000..228325a
--- /dev/null
+++ b/resources/components/prompt/prompt_test.html
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/resources/components/prompt/yes_no.html b/resources/components/prompt/yes_no.html
new file mode 100644
index 0000000..6072fac
--- /dev/null
+++ b/resources/components/prompt/yes_no.html
@@ -0,0 +1,57 @@
+
+
+
+
+
+
+
+
+
diff --git a/src/compositor.rs b/src/compositor.rs
index efcf7de..e2498f8 100644
--- a/src/compositor.rs
+++ b/src/compositor.rs
@@ -916,19 +916,6 @@ impl IOCompositor {
.expect("Insert then get failed!")
}
- fn pipeline(&self, pipeline_id: PipelineId) -> Option<&CompositionPipeline> {
- match self.pipeline_details.get(&pipeline_id) {
- Some(details) => details.pipeline.as_ref(),
- None => {
- warn!(
- "Compositor layer has an unknown pipeline ({:?}).",
- pipeline_id
- );
- None
- }
- }
- }
-
/// Set the root pipeline for our WebRender scene to a display list that consists of an iframe
/// for each visible top-level browsing context, applying a transformation on the root for
/// pinch zoom, page zoom, and HiDPI scaling.
@@ -1246,6 +1233,10 @@ impl IOCompositor {
w.set_size(content_size);
self.on_resize_webview_event(w.webview_id, w.rect);
}
+ if let Some(prompt) = &mut window.prompt {
+ prompt.resize(content_size);
+ self.on_resize_webview_event(prompt.webview().webview_id, rect);
+ }
self.send_root_pipeline_display_list(window);
}
diff --git a/src/config.rs b/src/config.rs
index cfdcb05..c587fb7 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -314,7 +314,9 @@ impl ProtocolHandler for ResourceReader {
_done_chan: &mut net::fetch::methods::DoneChannel,
_context: &net::fetch::methods::FetchContext,
) -> std::pin::Pin + Send>> {
- let path = self.0.join(request.current_url().domain().unwrap());
+ let current_url = request.current_url();
+ let path = current_url.path();
+ let path = self.0.join(path.strip_prefix('/').unwrap_or(path));
let response = if let Ok(file) = fs::read(path) {
let mut response = Response::new(
diff --git a/src/lib.rs b/src/lib.rs
index bdbc716..73c34cb 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -29,5 +29,3 @@ pub use errors::{Error, Result};
pub use verso::Verso;
/// Re-exporting Winit for the sake of convenience.
pub use winit;
-/// Context
-pub mod context_menu;
diff --git a/src/context_menu.rs b/src/webview/context_menu.rs
similarity index 97%
rename from src/context_menu.rs
rename to src/webview/context_menu.rs
index f8ae73b..a107337 100644
--- a/src/context_menu.rs
+++ b/src/webview/context_menu.rs
@@ -131,7 +131,10 @@ impl ContextMenu {
/// Get resource URL of the context menu
fn resource_url(&self) -> ServoUrl {
let items_json: String = self.to_items_json();
- let url_str = format!("verso://context_menu.html?items={}", items_json);
+ let url_str = format!(
+ "verso://resources/components/context_menu.html?items={}",
+ items_json
+ );
ServoUrl::parse(&url_str).unwrap()
}
@@ -221,8 +224,9 @@ impl MenuItem {
/// Context Menu Click Result
#[cfg(linux)]
#[derive(Debug, Clone, Serialize, Deserialize)]
+
pub struct ContextMenuResult {
- /// The id of the menu ite /// Get the label of the menu item
+ /// The id of the menu item
pub id: String,
/// Close the context menu
pub close: bool,
diff --git a/src/webview/mod.rs b/src/webview/mod.rs
new file mode 100644
index 0000000..6e7bf8c
--- /dev/null
+++ b/src/webview/mod.rs
@@ -0,0 +1,7 @@
+mod webview;
+/// WebView
+pub use webview::{Panel, WebView};
+/// Context Menu
+pub mod context_menu;
+/// Prompt Dialog
+pub mod prompt;
diff --git a/src/webview/prompt.rs b/src/webview/prompt.rs
new file mode 100644
index 0000000..80b150a
--- /dev/null
+++ b/src/webview/prompt.rs
@@ -0,0 +1,229 @@
+use base::id::WebViewId;
+use compositing_traits::ConstellationMsg;
+use crossbeam_channel::Sender;
+use embedder_traits::{PermissionRequest, PromptResult};
+use ipc_channel::ipc::IpcSender;
+use serde::{Deserialize, Serialize};
+use servo_url::ServoUrl;
+use webrender_api::units::DeviceIntRect;
+
+use crate::{verso::send_to_constellation, webview::WebView};
+
+/// Prompt Type
+#[derive(Debug, Clone, Hash, PartialEq, Eq)]
+enum PromptType {
+ /// Alert dialog
+ ///
+ ///
+ Alert(String),
+ /// Confitm dialog, Ok/Cancel
+ ///
+ ///
+ OkCancel(String),
+ /// Confirm dialog, Yes/No
+ ///
+ ///
+ YesNo(String),
+ /// Input dialog
+ ///
+ ///
+ Input(String, Option),
+}
+
+/// Prompt Sender, used to send prompt result back to the caller
+#[derive(Clone)]
+pub enum PromptSender {
+ /// Alert sender
+ AlertSender(IpcSender<()>),
+ /// Ok/Cancel, Yes/No sender
+ ConfirmSender(IpcSender),
+ /// Input sender
+ InputSender(IpcSender