mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Auto merge of #20707 - gterzian:embedder_handling_of_prompts_and_alerts_2, r=payl
Embedder handling of prompts and alerts <!-- Please describe your changes on the following line: --> Allow embedder to allow alerts and prompts, but via constellation forwarding messages from script. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [ ] `./mach build-geckolib` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #19992 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20707) <!-- Reviewable:end -->
This commit is contained in:
commit
f6762d54e2
32 changed files with 413 additions and 375 deletions
|
@ -48,6 +48,7 @@ use dom::windowproxy::WindowProxy;
|
|||
use dom::worklet::Worklet;
|
||||
use dom::workletglobalscope::WorkletGlobalScopeType;
|
||||
use dom_struct::dom_struct;
|
||||
use embedder_traits::EmbedderMsg;
|
||||
use euclid::{Point2D, Vector2D, Rect, Size2D, TypedPoint2D, TypedScale, TypedSize2D};
|
||||
use fetch;
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
|
@ -114,8 +115,6 @@ use task_source::performance_timeline::PerformanceTimelineTaskSource;
|
|||
use task_source::user_interaction::UserInteractionTaskSource;
|
||||
use time;
|
||||
use timers::{IsInterval, TimerCallback};
|
||||
#[cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))]
|
||||
use tinyfiledialogs::{self, MessageBoxIcon};
|
||||
use url::Position;
|
||||
use webdriver_handlers::jsval_to_webdriver;
|
||||
use webrender_api::{ExternalScrollId, DeviceIntPoint, DeviceUintSize, DocumentId};
|
||||
|
@ -444,18 +443,6 @@ impl Window {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))]
|
||||
fn display_alert_dialog(message: &str) {
|
||||
if !opts::get().headless {
|
||||
tinyfiledialogs::message_box_ok("Alert!", message, MessageBoxIcon::Warning);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "macos", target_os = "linux", target_os = "windows")))]
|
||||
fn display_alert_dialog(_message: &str) {
|
||||
// tinyfiledialogs not supported on Android
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#atob
|
||||
pub fn base64_btoa(input: DOMString) -> Fallible<DOMString> {
|
||||
// "The btoa() method must throw an InvalidCharacterError exception if
|
||||
|
@ -541,14 +528,10 @@ impl WindowMethods for Window {
|
|||
stdout.flush().unwrap();
|
||||
stderr.flush().unwrap();
|
||||
}
|
||||
|
||||
let (sender, receiver) = ProfiledIpc::channel(self.global().time_profiler_chan().clone()).unwrap();
|
||||
self.send_to_constellation(ScriptMsg::Alert(s.to_string(), sender));
|
||||
|
||||
let should_display_alert_dialog = receiver.recv().unwrap();
|
||||
if should_display_alert_dialog {
|
||||
display_alert_dialog(&s);
|
||||
}
|
||||
let msg = EmbedderMsg::Alert(s.to_string(), sender);
|
||||
self.send_to_embedder(msg);
|
||||
receiver.recv().unwrap();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-window-closed
|
||||
|
@ -937,7 +920,7 @@ impl WindowMethods for Window {
|
|||
//TODO determine if this operation is allowed
|
||||
let dpr = self.device_pixel_ratio();
|
||||
let size = TypedSize2D::new(width, height).to_f32() * dpr;
|
||||
self.send_to_constellation(ScriptMsg::ResizeTo(size.to_u32()));
|
||||
self.send_to_embedder(EmbedderMsg::ResizeTo(size.to_u32()));
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom-view/#dom-window-resizeby
|
||||
|
@ -953,7 +936,8 @@ impl WindowMethods for Window {
|
|||
//TODO determine if this operation is allowed
|
||||
let dpr = self.device_pixel_ratio();
|
||||
let point = TypedPoint2D::new(x, y).to_f32() * dpr;
|
||||
self.send_to_constellation(ScriptMsg::MoveTo(point.to_i32()));
|
||||
let msg = EmbedderMsg::MoveTo(point.to_i32());
|
||||
self.send_to_embedder(msg);
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom-view/#dom-window-moveby
|
||||
|
@ -1742,7 +1726,11 @@ impl Window {
|
|||
self.navigation_start_precise.set(time::precise_time_ns());
|
||||
}
|
||||
|
||||
fn send_to_constellation(&self, msg: ScriptMsg) {
|
||||
pub fn send_to_embedder(&self, msg: EmbedderMsg) {
|
||||
self.send_to_constellation(ScriptMsg::ForwardToEmbedder(msg));
|
||||
}
|
||||
|
||||
pub fn send_to_constellation(&self, msg: ScriptMsg) {
|
||||
self.upcast::<GlobalScope>()
|
||||
.script_to_constellation_chan()
|
||||
.send(msg)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue