use crate::_js_extern;
#[cfg(feature = "unsafe_ffi")]
#[cfg(not(feature = "safe_lang"))]
crate::items! {
use crate::{WebDocument, WebPermission, WebPermissionState, WebWindow};
use crate::{_js_doc, js_int32, js_number, JsInstant};
#[cfg(feature = "event")]
use crate::{WebEventKind, js_uint32};
}
#[doc = crate::_tags!(web namespace)]
#[doc = crate::_doc_meta!{location("sys/os/browser/web")}]
#[derive(Clone, Copy, Debug)]
pub struct Web;
#[rustfmt::skip]
#[cfg(not(feature = "safe_lang"))]
#[cfg(all(feature = "unsafe_ffi", not(windows)))]
#[cfg_attr(nightly_doc, doc(cfg(all(feature = "unsafe_ffi", target_arch = "wasm32"))))]
impl Web {
#[doc = _js_doc!("Window")]
#[doc = _js_doc!("Screen")]
pub fn window() -> WebWindow { WebWindow }
#[doc = _js_doc!("Document")]
pub fn document() -> WebDocument { WebDocument }
}
#[rustfmt::skip]
#[cfg(not(feature = "safe_lang"))]
#[cfg(all(feature = "unsafe_ffi", not(windows)))]
#[cfg_attr(nightly_doc, doc(cfg(all(feature = "unsafe_ffi", target_arch = "wasm32"))))]
impl Web {
#[doc = _js_doc!("Permissions", "query")]
pub fn permissions_query(permission: WebPermission) -> WebPermissionState {
unsafe { permissions_query(permission.as_str().as_ptr(), permission.as_str().len()) }
.into()
}
}
_js_extern! {
[ module: "api_permissions" ]
unsafe fn permissions_query(name_ptr: *const u8, name_len: usize) -> js_int32;
}
#[rustfmt::skip]
#[cfg(not(feature = "safe_lang"))]
#[cfg(all(feature = "unsafe_ffi", not(windows)))]
#[cfg_attr(nightly_doc, doc(cfg(all(feature = "unsafe_ffi", target_arch = "wasm32"))))]
impl Web {
#[doc = _js_doc!("Performance", "now")]
pub fn performance_now() -> JsInstant { JsInstant::from_millis_f64(performance_now()) }
#[doc = _js_doc!("Performance", "timeOrigin")]
pub fn performance_time_origin() -> JsInstant {
JsInstant::from_millis_f64(performance_time_origin()) }
#[doc = _js_doc!("Performance", "eventCounts")]
#[cfg(feature = "event")]
pub fn performance_event_count(event: WebEventKind) -> js_uint32 {
let name = event.as_str();
unsafe { performance_event_count(name.as_ptr(), name.len()) }
}
}
_js_extern! {
[ module: "api_performance" ]
safe fn "now" performance_now() -> js_number;
safe fn "timeOrigin" performance_time_origin() -> js_number;
#[cfg(feature = "event")]
unsafe fn "eventCounts" performance_event_count(event_ptr: *const u8, event_len: usize)
-> js_uint32;
}