mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
libservo: Allow embedders to execute JavaScript scripts via the API (#35720)
This change adds a new `WebView` API `evaluate_javascript()`, which allows embedders to execute JavaScript code and wait for a reply asynchronously. Ongoing script execution is tracked by a libservo `JavaScriptEvaluator` struct, which maps an id to the callback passed to the `evaluate_javascript()` method. The id is used to track the script and its execution through the other parts of Servo. Testing: This changes includes `WebView` unit tests. --------- Signed-off-by: Narfinger <Narfinger@users.noreply.github.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
91c4c7b998
commit
991be359a3
12 changed files with 391 additions and 18 deletions
|
@ -19,8 +19,8 @@ use base::Epoch;
|
|||
use base::cross_process_instant::CrossProcessInstant;
|
||||
use base::id::{MessagePortId, PipelineId, WebViewId};
|
||||
use embedder_traits::{
|
||||
CompositorHitTestResult, Cursor, InputEvent, MediaSessionActionType, Theme, ViewportDetails,
|
||||
WebDriverCommandMsg,
|
||||
CompositorHitTestResult, Cursor, InputEvent, JavaScriptEvaluationId, MediaSessionActionType,
|
||||
Theme, ViewportDetails, WebDriverCommandMsg,
|
||||
};
|
||||
use euclid::Vector2D;
|
||||
pub use from_script_message::*;
|
||||
|
@ -92,6 +92,9 @@ pub enum EmbedderToConstellationMessage {
|
|||
SetScrollStates(PipelineId, Vec<ScrollState>),
|
||||
/// Notify the constellation that a particular paint metric event has happened for the given pipeline.
|
||||
PaintMetric(PipelineId, PaintMetricEvent),
|
||||
/// Evaluate a JavaScript string in the context of a `WebView`. When execution is complete or an
|
||||
/// error is encountered, a correpsonding message will be sent to the embedding layer.
|
||||
EvaluateJavaScript(WebViewId, JavaScriptEvaluationId, String),
|
||||
}
|
||||
|
||||
/// A description of a paint metric that is sent from the Servo renderer to the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue