mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Implement HTMLDocument API (#38433)
This updates the pull request from here https://github.com/servo/servo/pull/32553 that looks to be dormant. The main change is that I've switched out `reflector` with `document` based off this suggestion https://github.com/servo/servo/pull/32553#issuecomment-2179568743, and the `GetLocation` and `SupportedPropertyNames` methods pass through the values from `Document`. The implementation details are otherwise the same as the original PR Testing: I don't see any WPT tests for this feature, I could make a custom test if desired Fixes: https://github.com/servo/servo/issues/32536 --------- Signed-off-by: Leo Ring <leoring03@gmail.com>
This commit is contained in:
parent
f0eb6c2b97
commit
79a45c7da3
9 changed files with 52 additions and 13 deletions
36
components/script/dom/htmldocument.rs
Normal file
36
components/script/dom/htmldocument.rs
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
use dom_struct::dom_struct;
|
||||||
|
use script_bindings::codegen::GenericBindings::DocumentBinding::DocumentMethods;
|
||||||
|
use script_bindings::codegen::GenericBindings::HTMLDocumentBinding::HTMLDocumentMethods;
|
||||||
|
use script_bindings::root::DomRoot;
|
||||||
|
use script_bindings::script_runtime::CanGc;
|
||||||
|
use script_bindings::str::DOMString;
|
||||||
|
|
||||||
|
use super::types::{Document, Location};
|
||||||
|
use crate::dom::bindings::codegen::Bindings::DocumentBinding::NamedPropertyValue;
|
||||||
|
|
||||||
|
/// <https://html.spec.whatwg.org/multipage/#htmldocument>
|
||||||
|
#[dom_struct]
|
||||||
|
pub(crate) struct HTMLDocument {
|
||||||
|
document: Document,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl HTMLDocumentMethods<crate::DomTypeHolder> for HTMLDocument {
|
||||||
|
/// <https://html.spec.whatwg.org/multipage/#dom-document-location>
|
||||||
|
fn GetLocation(&self) -> Option<DomRoot<Location>> {
|
||||||
|
self.document.GetLocation()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <https://html.spec.whatwg.org/multipage/#dom-tree-accessors:supported-property-names>
|
||||||
|
fn SupportedPropertyNames(&self) -> Vec<DOMString> {
|
||||||
|
self.document.SupportedPropertyNames()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <https://html.spec.whatwg.org/multipage/#dom-tree-accessors:dom-document-nameditem-filter>
|
||||||
|
fn NamedGetter(&self, name: DOMString) -> Option<NamedPropertyValue> {
|
||||||
|
self.document.NamedGetter(name, CanGc::note())
|
||||||
|
}
|
||||||
|
}
|
|
@ -362,6 +362,7 @@ pub(crate) mod htmldialogelement;
|
||||||
pub(crate) mod htmldirectoryelement;
|
pub(crate) mod htmldirectoryelement;
|
||||||
pub(crate) mod htmldivelement;
|
pub(crate) mod htmldivelement;
|
||||||
pub(crate) mod htmldlistelement;
|
pub(crate) mod htmldlistelement;
|
||||||
|
pub(crate) mod htmldocument;
|
||||||
pub(crate) mod htmlelement;
|
pub(crate) mod htmlelement;
|
||||||
pub(crate) mod htmlembedelement;
|
pub(crate) mod htmlembedelement;
|
||||||
pub(crate) mod htmlfieldsetelement;
|
pub(crate) mod htmlfieldsetelement;
|
||||||
|
|
13
components/script_bindings/webidls/HTMLDocument.webidl
Normal file
13
components/script_bindings/webidls/HTMLDocument.webidl
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
|
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/#htmldocument
|
||||||
|
|
||||||
|
[LegacyOverrideBuiltIns,
|
||||||
|
Exposed=Window]
|
||||||
|
interface HTMLDocument : Document {
|
||||||
|
// DOM tree accessors
|
||||||
|
getter NamedPropertyValue (DOMString name);
|
||||||
|
};
|
|
@ -1,3 +0,0 @@
|
||||||
[historical.html]
|
|
||||||
[ondragexit must not be present on the GlobalEventHandlers locations]
|
|
||||||
expected: FAIL
|
|
|
@ -1,3 +0,0 @@
|
||||||
[contextmenu-historical.html]
|
|
||||||
[onshow must not be present on the GlobalEventHandlers locations]
|
|
||||||
expected: FAIL
|
|
|
@ -1,3 +0,0 @@
|
||||||
[interface-prototype-constructor-set-receiver.html]
|
|
||||||
[Direct [[Set\]\] preserves [[Enumerable\]\]: false property attribute]
|
|
||||||
expected: FAIL
|
|
|
@ -1,3 +0,0 @@
|
||||||
[invalid-this-value-cross-realm.html]
|
|
||||||
[Cross-realm operation throws when called on incompatible object]
|
|
||||||
expected: FAIL
|
|
2
tests/wpt/mozilla/meta/MANIFEST.json
vendored
2
tests/wpt/mozilla/meta/MANIFEST.json
vendored
|
@ -13725,7 +13725,7 @@
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"interfaces.https.html": [
|
"interfaces.https.html": [
|
||||||
"efb780c382456b1fda514b33fe5b317c447fa09e",
|
"05ead2c3e2c362586506be77c8093c8bc4f0fb53",
|
||||||
[
|
[
|
||||||
null,
|
null,
|
||||||
{}
|
{}
|
||||||
|
|
|
@ -164,6 +164,7 @@ test_interfaces([
|
||||||
"HTMLDirectoryElement",
|
"HTMLDirectoryElement",
|
||||||
"HTMLDivElement",
|
"HTMLDivElement",
|
||||||
"HTMLDListElement",
|
"HTMLDListElement",
|
||||||
|
"HTMLDocument",
|
||||||
"HTMLElement",
|
"HTMLElement",
|
||||||
"HTMLEmbedElement",
|
"HTMLEmbedElement",
|
||||||
"HTMLFieldSetElement",
|
"HTMLFieldSetElement",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue