mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
WebIDL: Remove JSObject
from Document::NamedGetter
(#31841)
* WebIDL: Remove `JSObject` from `Document::NamedGetter` * fix: update rustdoc comment
This commit is contained in:
parent
1ab38fcd3f
commit
58081579e9
3 changed files with 16 additions and 29 deletions
|
@ -9,7 +9,6 @@ use std::collections::hash_map::Entry::{Occupied, Vacant};
|
||||||
use std::collections::{HashMap, HashSet, VecDeque};
|
use std::collections::{HashMap, HashSet, VecDeque};
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::ptr::NonNull;
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::slice::from_ref;
|
use std::slice::from_ref;
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
@ -26,7 +25,6 @@ use euclid::default::{Point2D, Rect, Size2D};
|
||||||
use html5ever::{local_name, namespace_url, ns, LocalName, Namespace, QualName};
|
use html5ever::{local_name, namespace_url, ns, LocalName, Namespace, QualName};
|
||||||
use hyper_serde::Serde;
|
use hyper_serde::Serde;
|
||||||
use ipc_channel::ipc::{self, IpcSender};
|
use ipc_channel::ipc::{self, IpcSender};
|
||||||
use js::jsapi::JSObject;
|
|
||||||
use js::rust::HandleObject;
|
use js::rust::HandleObject;
|
||||||
use keyboard_types::{Code, Key, KeyState};
|
use keyboard_types::{Code, Key, KeyState};
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
|
@ -80,7 +78,7 @@ use crate::dom::bindings::callback::ExceptionHandling;
|
||||||
use crate::dom::bindings::cell::{ref_filter_map, DomRefCell, Ref, RefMut};
|
use crate::dom::bindings::cell::{ref_filter_map, DomRefCell, Ref, RefMut};
|
||||||
use crate::dom::bindings::codegen::Bindings::BeforeUnloadEventBinding::BeforeUnloadEvent_Binding::BeforeUnloadEventMethods;
|
use crate::dom::bindings::codegen::Bindings::BeforeUnloadEventBinding::BeforeUnloadEvent_Binding::BeforeUnloadEventMethods;
|
||||||
use crate::dom::bindings::codegen::Bindings::DocumentBinding::{
|
use crate::dom::bindings::codegen::Bindings::DocumentBinding::{
|
||||||
DocumentMethods, DocumentReadyState,
|
DocumentMethods, DocumentReadyState, NamedPropertyValue,
|
||||||
};
|
};
|
||||||
use crate::dom::bindings::codegen::Bindings::EventBinding::Event_Binding::EventMethods;
|
use crate::dom::bindings::codegen::Bindings::EventBinding::Event_Binding::EventMethods;
|
||||||
use crate::dom::bindings::codegen::Bindings::HTMLIFrameElementBinding::HTMLIFrameElement_Binding::HTMLIFrameElementMethods;
|
use crate::dom::bindings::codegen::Bindings::HTMLIFrameElementBinding::HTMLIFrameElement_Binding::HTMLIFrameElementMethods;
|
||||||
|
@ -176,7 +174,7 @@ use crate::dom::window::{ReflowReason, Window};
|
||||||
use crate::dom::windowproxy::WindowProxy;
|
use crate::dom::windowproxy::WindowProxy;
|
||||||
use crate::fetch::FetchCanceller;
|
use crate::fetch::FetchCanceller;
|
||||||
use crate::realms::{AlreadyInRealm, InRealm};
|
use crate::realms::{AlreadyInRealm, InRealm};
|
||||||
use crate::script_runtime::{CommonScriptMsg, JSContext, ScriptThreadEventCategory};
|
use crate::script_runtime::{CommonScriptMsg, ScriptThreadEventCategory};
|
||||||
use crate::script_thread::{MainThreadScriptMsg, ScriptThread};
|
use crate::script_thread::{MainThreadScriptMsg, ScriptThread};
|
||||||
use crate::stylesheet_set::StylesheetSetRef;
|
use crate::stylesheet_set::StylesheetSetRef;
|
||||||
use crate::task::TaskBox;
|
use crate::task::TaskBox;
|
||||||
|
@ -4860,8 +4858,8 @@ impl DocumentMethods for Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-tree-accessors:dom-document-nameditem-filter
|
/// <https://html.spec.whatwg.org/multipage/#dom-tree-accessors:dom-document-nameditem-filter>
|
||||||
fn NamedGetter(&self, _cx: JSContext, name: DOMString) -> Option<NonNull<JSObject>> {
|
fn NamedGetter(&self, name: DOMString) -> Option<NamedPropertyValue> {
|
||||||
if name.is_empty() {
|
if name.is_empty() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
@ -4886,19 +4884,11 @@ impl DocumentMethods for Document {
|
||||||
.downcast::<HTMLIFrameElement>()
|
.downcast::<HTMLIFrameElement>()
|
||||||
.and_then(|iframe| iframe.GetContentWindow())
|
.and_then(|iframe| iframe.GetContentWindow())
|
||||||
{
|
{
|
||||||
unsafe {
|
return Some(NamedPropertyValue::WindowProxy(nested_window_proxy));
|
||||||
return Some(NonNull::new_unchecked(
|
|
||||||
nested_window_proxy.reflector().get_jsobject().get(),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 3.
|
// Step 3.
|
||||||
unsafe {
|
return Some(NamedPropertyValue::Element(DomRoot::from_ref(first)));
|
||||||
return Some(NonNull::new_unchecked(
|
|
||||||
first.reflector().get_jsobject().get(),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 4.
|
// Step 4.
|
||||||
|
@ -4933,11 +4923,7 @@ impl DocumentMethods for Document {
|
||||||
self.upcast(),
|
self.upcast(),
|
||||||
Box::new(DocumentNamedGetter { name }),
|
Box::new(DocumentNamedGetter { name }),
|
||||||
);
|
);
|
||||||
unsafe {
|
Some(NamedPropertyValue::HTMLCollection(collection))
|
||||||
Some(NonNull::new_unchecked(
|
|
||||||
collection.reflector().get_jsobject().get(),
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-tree-accessors:supported-property-names
|
// https://html.spec.whatwg.org/multipage/#dom-tree-accessors:supported-property-names
|
||||||
|
|
|
@ -97,7 +97,7 @@ partial /*sealed*/ interface Document {
|
||||||
readonly attribute DocumentReadyState readyState;
|
readonly attribute DocumentReadyState readyState;
|
||||||
|
|
||||||
// DOM tree accessors
|
// DOM tree accessors
|
||||||
getter object (DOMString name);
|
getter NamedPropertyValue (DOMString name);
|
||||||
[CEReactions]
|
[CEReactions]
|
||||||
attribute DOMString title;
|
attribute DOMString title;
|
||||||
// [CEReactions]
|
// [CEReactions]
|
||||||
|
@ -212,3 +212,6 @@ partial interface Document {
|
||||||
[Throws]
|
[Throws]
|
||||||
ShadowRoot servoGetMediaControls(DOMString id);
|
ShadowRoot servoGetMediaControls(DOMString id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/#dom-document-nameditem-filter
|
||||||
|
typedef (WindowProxy or Element or HTMLCollection) NamedPropertyValue;
|
||||||
|
|
|
@ -2,16 +2,15 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use std::ptr::NonNull;
|
|
||||||
|
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use js::jsapi::JSObject;
|
|
||||||
use mime::Mime;
|
use mime::Mime;
|
||||||
use script_traits::DocumentActivity;
|
use script_traits::DocumentActivity;
|
||||||
use servo_url::{MutableOrigin, ServoUrl};
|
use servo_url::{MutableOrigin, ServoUrl};
|
||||||
|
|
||||||
use crate::document_loader::DocumentLoader;
|
use crate::document_loader::DocumentLoader;
|
||||||
use crate::dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
|
use crate::dom::bindings::codegen::Bindings::DocumentBinding::{
|
||||||
|
DocumentMethods, NamedPropertyValue,
|
||||||
|
};
|
||||||
use crate::dom::bindings::codegen::Bindings::XMLDocumentBinding::XMLDocumentMethods;
|
use crate::dom::bindings::codegen::Bindings::XMLDocumentBinding::XMLDocumentMethods;
|
||||||
use crate::dom::bindings::inheritance::Castable;
|
use crate::dom::bindings::inheritance::Castable;
|
||||||
use crate::dom::bindings::reflector::reflect_dom_object;
|
use crate::dom::bindings::reflector::reflect_dom_object;
|
||||||
|
@ -21,7 +20,6 @@ use crate::dom::document::{Document, DocumentSource, HasBrowsingContext, IsHTMLD
|
||||||
use crate::dom::location::Location;
|
use crate::dom::location::Location;
|
||||||
use crate::dom::node::Node;
|
use crate::dom::node::Node;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
use crate::script_runtime::JSContext;
|
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#xmldocument
|
// https://dom.spec.whatwg.org/#xmldocument
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -108,7 +106,7 @@ impl XMLDocumentMethods for XMLDocument {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-tree-accessors:dom-document-nameditem-filter
|
// https://html.spec.whatwg.org/multipage/#dom-tree-accessors:dom-document-nameditem-filter
|
||||||
fn NamedGetter(&self, _cx: JSContext, name: DOMString) -> Option<NonNull<JSObject>> {
|
fn NamedGetter(&self, name: DOMString) -> Option<NamedPropertyValue> {
|
||||||
self.upcast::<Document>().NamedGetter(_cx, name)
|
self.upcast::<Document>().NamedGetter(name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue