mirror of
https://github.com/servo/servo.git
synced 2025-06-16 20:34:30 +00:00
dom: Implement Navigator.languages.
This commit is contained in:
parent
9fe92ecb4c
commit
2acd295ea6
10 changed files with 670 additions and 15 deletions
|
@ -6,6 +6,7 @@ use crate::dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorMethods;
|
|||
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
|
||||
use crate::dom::bindings::root::{DomRoot, MutNullableDom};
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::bindings::utils::to_frozen_array;
|
||||
use crate::dom::bluetooth::Bluetooth;
|
||||
use crate::dom::gamepadlist::GamepadList;
|
||||
use crate::dom::gpu::GPU;
|
||||
|
@ -18,7 +19,9 @@ use crate::dom::pluginarray::PluginArray;
|
|||
use crate::dom::serviceworkercontainer::ServiceWorkerContainer;
|
||||
use crate::dom::window::Window;
|
||||
use crate::dom::xrsystem::XRSystem;
|
||||
use crate::script_runtime::JSContext;
|
||||
use dom_struct::dom_struct;
|
||||
use js::jsval::JSVal;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct Navigator {
|
||||
|
@ -122,6 +125,12 @@ impl NavigatorMethods for Navigator {
|
|||
navigatorinfo::Language()
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-navigator-languages
|
||||
#[allow(unsafe_code)]
|
||||
fn Languages(&self, cx: JSContext) -> JSVal {
|
||||
to_frozen_array(&[self.Language()], cx)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-navigator-plugins
|
||||
fn Plugins(&self) -> DomRoot<PluginArray> {
|
||||
self.plugins.or_init(|| PluginArray::new(&self.global()))
|
||||
|
|
|
@ -44,8 +44,7 @@ partial interface Navigator {
|
|||
[Exposed=(Window,Worker)]
|
||||
interface mixin NavigatorLanguage {
|
||||
readonly attribute DOMString language;
|
||||
// https://github.com/servo/servo/issues/10073
|
||||
//readonly attribute DOMString[] languages;
|
||||
readonly attribute any languages;
|
||||
};
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#navigatorplugins
|
||||
|
|
|
@ -6,11 +6,14 @@ use crate::dom::bindings::codegen::Bindings::WorkerNavigatorBinding::WorkerNavig
|
|||
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
|
||||
use crate::dom::bindings::root::{DomRoot, MutNullableDom};
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::bindings::utils::to_frozen_array;
|
||||
use crate::dom::gpu::GPU;
|
||||
use crate::dom::navigatorinfo;
|
||||
use crate::dom::permissions::Permissions;
|
||||
use crate::dom::workerglobalscope::WorkerGlobalScope;
|
||||
use crate::script_runtime::JSContext;
|
||||
use dom_struct::dom_struct;
|
||||
use js::jsval::JSVal;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#workernavigator
|
||||
#[dom_struct]
|
||||
|
@ -90,6 +93,12 @@ impl WorkerNavigatorMethods for WorkerNavigator {
|
|||
navigatorinfo::Language()
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-navigator-languages
|
||||
#[allow(unsafe_code)]
|
||||
fn Languages(&self, cx: JSContext) -> JSVal {
|
||||
to_frozen_array(&[self.Language()], cx)
|
||||
}
|
||||
|
||||
// https://w3c.github.io/permissions/#navigator-and-workernavigator-extension
|
||||
fn Permissions(&self) -> DomRoot<Permissions> {
|
||||
self.permissions
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue