mirror of
https://github.com/servo/servo.git
synced 2025-08-11 08:25:32 +01:00
feat: add Notification
Web API binding (#34842)
* feat: add Notification Web API binding Signed-off-by: Jason Tsai <git@pews.dev> * chore: update spec link Signed-off-by: Jason Tsai <git@pews.dev> * chore: fix clippy Signed-off-by: Jason Tsai <git@pews.dev> * fix: index overflow Signed-off-by: Jason Tsai <git@pews.dev> * test(tidy): add notification WebIDL standard URL Signed-off-by: Jason Tsai <git@pews.dev> * fix: allow crown::unrooted_must_root Signed-off-by: Jason Tsai <git@pews.dev> * implement GetPermission Signed-off-by: Jason Tsai <git@pews.dev> * fix silent type Signed-off-by: Jason Tsai <git@pews.dev> * add all properties Signed-off-by: Jason Tsai <git@pews.dev> * test: add Notification to global Signed-off-by: Jason Tsai <git@pews.dev> * chore: update wpt manifest and fix clippy Signed-off-by: Jason Tsai <git@pews.dev> * test: temp skip notifications Signed-off-by: Jason Tsai <git@pews.dev> * add vibration and apply suggestions Signed-off-by: Jason Tsai <git@pews.dev> * partially implement RequestPermission Signed-off-by: Jason Tsai <git@pews.dev> * call Permission request permission algorithm Signed-off-by: Jason Tsai <git@pews.dev> * chore: pub crate Notification Signed-off-by: Jason Tsai <git@pews.dev> * chore: fix clippy Signed-off-by: Jason Tsai <git@pews.dev> * chore: crown attribute Signed-off-by: Jason Tsai <git@pews.dev> * fix part of suggestions Signed-off-by: Jason Tsai <git@pews.dev> * fix: store private `Action` structure Signed-off-by: Jason Tsai <git@pews.dev> * chore: fix typo Signed-off-by: Jason Tsai <git@pews.dev> * fix: serialize images URL Signed-off-by: Jason Tsai <git@pews.dev> * fix: use globalscope as environment settings object Signed-off-by: Jason Tsai <git@pews.dev> * chore: add pref `dom_notification_enabled` and default to disabled Signed-off-by: Jason Tsai <git@pews.dev> * fix: use `descriptor_permission_state` Signed-off-by: Jason Tsai <git@pews.dev> * apply suggestions Signed-off-by: Jason Tsai <git@pews.dev> Co-authored-by: Josh Matthews <josh@joshmatthews.net> * test: remove passed meta Signed-off-by: Jason Tsai <git@pews.dev> * test: enable notification prefs in mozilla tests Signed-off-by: Jason Tsai <git@pews.dev> --------- Signed-off-by: Jason Tsai <git@pews.dev> Co-authored-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
14d591c462
commit
22c3a63737
21 changed files with 717 additions and 370 deletions
|
@ -80,6 +80,7 @@ use crate::dom::bindings::codegen::Bindings::ImageBitmapBinding::{
|
|||
ImageBitmapOptions, ImageBitmapSource,
|
||||
};
|
||||
use crate::dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorMethods;
|
||||
use crate::dom::bindings::codegen::Bindings::NotificationBinding::NotificationPermissionCallback;
|
||||
use crate::dom::bindings::codegen::Bindings::PerformanceBinding::Performance_Binding::PerformanceMethods;
|
||||
use crate::dom::bindings::codegen::Bindings::PermissionStatusBinding::{
|
||||
PermissionName, PermissionState,
|
||||
|
@ -370,6 +371,10 @@ pub(crate) struct GlobalScope {
|
|||
/// <https://streams.spec.whatwg.org/#count-queuing-strategy-size-function>
|
||||
#[ignore_malloc_size_of = "Rc<T> is hard"]
|
||||
count_queuing_strategy_size_function: OnceCell<Rc<Function>>,
|
||||
|
||||
#[ignore_malloc_size_of = "Rc<T> is hard"]
|
||||
notification_permission_request_callback_map:
|
||||
DomRefCell<HashMap<String, Rc<NotificationPermissionCallback>>>,
|
||||
}
|
||||
|
||||
/// A wrapper for glue-code between the ipc router and the event-loop.
|
||||
|
@ -763,6 +768,7 @@ impl GlobalScope {
|
|||
unminified_js_dir: unminify_js.then(|| unminified_path("unminified-js")),
|
||||
byte_length_queuing_strategy_size_function: OnceCell::new(),
|
||||
count_queuing_strategy_size_function: OnceCell::new(),
|
||||
notification_permission_request_callback_map: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3268,6 +3274,25 @@ impl GlobalScope {
|
|||
pub(crate) fn get_count_queuing_strategy_size(&self) -> Option<Rc<Function>> {
|
||||
self.count_queuing_strategy_size_function.get().cloned()
|
||||
}
|
||||
|
||||
pub(crate) fn add_notification_permission_request_callback(
|
||||
&self,
|
||||
callback_id: String,
|
||||
callback: Rc<NotificationPermissionCallback>,
|
||||
) {
|
||||
self.notification_permission_request_callback_map
|
||||
.borrow_mut()
|
||||
.insert(callback_id, callback.clone());
|
||||
}
|
||||
|
||||
pub(crate) fn remove_notification_permission_request_callback(
|
||||
&self,
|
||||
callback_id: String,
|
||||
) -> Option<Rc<NotificationPermissionCallback>> {
|
||||
self.notification_permission_request_callback_map
|
||||
.borrow_mut()
|
||||
.remove(&callback_id)
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the Rust global scope from a JS global object.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue