Skip to content

Commit

Permalink
Move panel to webview.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
Legend-Master committed Oct 18, 2024
1 parent 517ea96 commit 60c4e6b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
18 changes: 18 additions & 0 deletions src/webview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,24 @@ impl WebView {
}
}

/// 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 struct Panel {
/// The panel's webview
pub(crate) webview: WebView,
/// The URL to load when the panel gets loaded
pub(crate) initial_url: servo_url::ServoUrl,
}

impl Window {
/// Handle servo messages with corresponding web view ID.
pub fn handle_servo_messages_with_webview(
Expand Down
18 changes: 1 addition & 17 deletions src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,11 @@ use crate::{
keyboard::keyboard_event_from_winit,
rendering::{gl_config_picker, RenderingContext},
verso::send_to_constellation,
webview::WebView,
webview::{Panel, WebView},
};

use arboard::Clipboard;

/// 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 struct Panel {
pub(crate) webview: WebView,
pub(crate) initial_url: servo_url::ServoUrl,
}

/// A Verso window is a Winit window containing several web views.
pub struct Window {
/// Access to Winit window
Expand Down

0 comments on commit 60c4e6b

Please sign in to comment.