script: Include constructors and static methods in generated DOM traits (#33665)

* Add all constructors, special operations, and static methods to generated DOM interface traits.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Move all constructors and static methods defined in bare impl blocks inside FooMethods trait impls.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Add missing doc links.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2024-10-07 21:51:58 -04:00 committed by GitHub
parent 946fa9cdee
commit 7d931e673a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
133 changed files with 1479 additions and 1438 deletions

View file

@ -78,12 +78,28 @@ impl URL {
.extend_pairs(pairs);
}
}
/// <https://w3c.github.io/FileAPI/#unicodeSerializationOfBlobURL>
fn unicode_serialization_blob_url(origin: &str, id: &Uuid) -> String {
// Step 1, 2
let mut result = "blob:".to_string();
// Step 3
result.push_str(origin);
// Step 4
result.push('/');
// Step 5
result.push_str(&id.to_string());
result
}
}
#[allow(non_snake_case)]
impl URL {
impl URLMethods for URL {
/// <https://url.spec.whatwg.org/#constructors>
pub fn Constructor(
fn Constructor(
global: &GlobalScope,
proto: Option<HandleObject>,
can_gc: CanGc,
@ -125,7 +141,7 @@ impl URL {
}
/// <https://url.spec.whatwg.org/#dom-url-canparse>
pub fn CanParse(_global: &GlobalScope, url: USVString, base: Option<USVString>) -> bool {
fn CanParse(_global: &GlobalScope, url: USVString, base: Option<USVString>) -> bool {
// Step 1.
let parsed_base = match base {
None => None,
@ -142,7 +158,7 @@ impl URL {
}
/// <https://url.spec.whatwg.org/#dom-url-parse>
pub fn Parse(
fn Parse(
global: &GlobalScope,
url: USVString,
base: Option<USVString>,
@ -164,7 +180,7 @@ impl URL {
}
/// <https://w3c.github.io/FileAPI/#dfn-createObjectURL>
pub fn CreateObjectURL(global: &GlobalScope, blob: &Blob) -> DOMString {
fn CreateObjectURL(global: &GlobalScope, blob: &Blob) -> DOMString {
// XXX: Second field is an unicode-serialized Origin, it is a temporary workaround
// and should not be trusted. See issue https://github.com/servo/servo/issues/11722
let origin = get_blob_origin(&global.get_url());
@ -175,7 +191,7 @@ impl URL {
}
/// <https://w3c.github.io/FileAPI/#dfn-revokeObjectURL>
pub fn RevokeObjectURL(global: &GlobalScope, url: DOMString) {
fn RevokeObjectURL(global: &GlobalScope, url: DOMString) {
// If the value provided for the url argument is not a Blob URL OR
// if the value provided for the url argument does not have an entry in the Blob URL Store,
// this method call does nothing. User agents may display a message on the error console.
@ -195,26 +211,6 @@ impl URL {
}
}
/// <https://w3c.github.io/FileAPI/#unicodeSerializationOfBlobURL>
fn unicode_serialization_blob_url(origin: &str, id: &Uuid) -> String {
// Step 1, 2
let mut result = "blob:".to_string();
// Step 3
result.push_str(origin);
// Step 4
result.push('/');
// Step 5
result.push_str(&id.to_string());
result
}
}
#[allow(non_snake_case)]
impl URLMethods for URL {
/// <https://url.spec.whatwg.org/#dom-url-hash>
fn Hash(&self) -> USVString {
UrlHelper::Hash(&self.url.borrow())