diff --git a/src/verso.rs b/src/verso.rs index bab97d6a..f97413ca 100644 --- a/src/verso.rs +++ b/src/verso.rs @@ -5,7 +5,7 @@ use std::{ }; use arboard::Clipboard; -use base::id::WebViewId; +use base::id::{PipelineNamespace, PipelineNamespaceId, WebViewId}; use bluetooth::BluetoothThreadFactory; use bluetooth_traits::BluetoothRequest; use canvas::canvas_paint_thread::CanvasPaintThread; @@ -82,6 +82,8 @@ impl Verso { // Initialize configurations and Verso window let protocols = config.create_protocols(); config.init(); + // Reserving a namespace to create TopLevelBrowsingContextId. + PipelineNamespace::install(PipelineNamespaceId(0)); let (window, rendering_context) = Window::new(evl); let event_loop_waker = Box::new(Waker(proxy)); let opts = opts::get(); diff --git a/src/webview.rs b/src/webview.rs index 6c559fa4..b44561d2 100644 --- a/src/webview.rs +++ b/src/webview.rs @@ -1,5 +1,5 @@ use arboard::Clipboard; -use base::id::{BrowsingContextId, PipelineNamespace, PipelineNamespaceId, WebViewId}; +use base::id::{BrowsingContextId, WebViewId}; use compositing_traits::ConstellationMsg; use crossbeam_channel::Sender; use embedder_traits::{CompositorEventVariant, EmbedderMsg, PromptDefinition}; @@ -29,27 +29,6 @@ impl WebView { Self { webview_id, rect } } - /// Create a panel view from Winit window. A panel is a special web view that focus on controlling states around window. - /// It could be treated as the control panel or navigation bar of the window depending on usages. - /// - /// At the moment, following Web API is supported: - /// - Close window: `window.close()` - /// - Navigate to previous page: `window.prompt('PREV')` - /// - Navigate to next page: `window.prompt('FORWARD')` - /// - Refresh the page: `window.prompt('REFRESH')` - /// - Minimize the window: `window.prompt('MINIMIZE')` - /// - Maximize the window: `window.prompt('MAXIMIZE')` - /// - Navigate to a specific URL: `window.prompt('NAVIGATE_TO:${url}')` - pub fn new_panel(rect: DeviceIntRect) -> Self { - // Reserving a namespace to create TopLevelBrowsingContextId. - PipelineNamespace::install(PipelineNamespaceId(0)); - let id = WebViewId::new(); - Self { - webview_id: id, - rect, - } - } - /// Set the webview size corresponding to the window size. pub fn set_size(&mut self, mut rect: DeviceIntRect) { rect.min.y = rect.max.y.min(100); diff --git a/src/window.rs b/src/window.rs index 3fa20ad4..f3bdd6cb 100644 --- a/src/window.rs +++ b/src/window.rs @@ -39,7 +39,17 @@ pub struct Window { pub(crate) window: WinitWindow, /// GL surface of the window pub(crate) surface: Surface, - /// The main control panel of this window. + /// The main panel of this window. A panel is a special web view that focus on controlling states around window. + /// It could be treated as the control panel or navigation bar of the window depending on usages. + /// + /// At the moment, following Web API is supported: + /// - Close window: `window.close()` + /// - Navigate to previous page: `window.prompt('PREV')` + /// - Navigate to next page: `window.prompt('FORWARD')` + /// - Refresh the page: `window.prompt('REFRESH')` + /// - Minimize the window: `window.prompt('MINIMIZE')` + /// - Maximize the window: `window.prompt('MAXIMIZE')` + /// - Navigate to a specific URL: `window.prompt('NAVIGATE_TO:${url}')` pub(crate) panel: Option, /// The WebView of this window. pub(crate) webview: Option, @@ -89,7 +99,10 @@ impl Window { Self { window, surface, - panel: Some(WebView::new_panel(DeviceIntRect::from_size(size))), + panel: Some(WebView::new( + WebViewId::new(), + DeviceIntRect::from_size(size), + )), webview: None, mouse_position: Cell::new(PhysicalPosition::default()), modifiers_state: Cell::new(ModifiersState::default()),