script/dom/html/
htmldocument.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5use dom_struct::dom_struct;
6use js::context::JSContext;
7use script_bindings::codegen::GenericBindings::DocumentBinding::DocumentMethods;
8use script_bindings::codegen::GenericBindings::HTMLDocumentBinding::HTMLDocumentMethods;
9use script_bindings::root::DomRoot;
10use script_bindings::script_runtime::CanGc;
11use script_bindings::str::DOMString;
12
13use crate::dom::bindings::codegen::Bindings::DocumentBinding::NamedPropertyValue;
14use crate::dom::types::{Document, Location};
15
16/// <https://html.spec.whatwg.org/multipage/#htmldocument>
17#[dom_struct]
18pub(crate) struct HTMLDocument {
19    document: Document,
20}
21
22impl HTMLDocumentMethods<crate::DomTypeHolder> for HTMLDocument {
23    /// <https://html.spec.whatwg.org/multipage/#dom-document-location>
24    fn GetLocation(&self, cx: &mut JSContext) -> Option<DomRoot<Location>> {
25        self.document.GetLocation(cx)
26    }
27
28    /// <https://html.spec.whatwg.org/multipage/#dom-tree-accessors:supported-property-names>
29    fn SupportedPropertyNames(&self) -> Vec<DOMString> {
30        self.document.SupportedPropertyNames()
31    }
32
33    /// <https://html.spec.whatwg.org/multipage/#dom-tree-accessors:dom-document-nameditem-filter>
34    fn NamedGetter(&self, name: DOMString, can_gc: CanGc) -> Option<NamedPropertyValue> {
35        self.document.NamedGetter(name, can_gc)
36    }
37}