forked from mirrors/gecko-dev
Replaced content_type from DomString to Mime --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #16483 (https://github.com/servo/servo/issues/16483). <!-- Either: --> - [x] These changes do not require tests because they make changes to already existing files <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 7e501f50f7ef71c6f877bb2ebbaaeaf0162b5f43 --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : 1561b203307f82f8731f63c95f91587181a3ef15
109 lines
4 KiB
Rust
109 lines
4 KiB
Rust
/* 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/. */
|
|
|
|
use document_loader::DocumentLoader;
|
|
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
|
|
use dom::bindings::codegen::Bindings::XMLDocumentBinding::{self, XMLDocumentMethods};
|
|
use dom::bindings::inheritance::Castable;
|
|
use dom::bindings::reflector::reflect_dom_object;
|
|
use dom::bindings::root::DomRoot;
|
|
use dom::bindings::str::DOMString;
|
|
use dom::document::{Document, DocumentSource, HasBrowsingContext, IsHTMLDocument};
|
|
use dom::location::Location;
|
|
use dom::node::Node;
|
|
use dom::window::Window;
|
|
use dom_struct::dom_struct;
|
|
use js::jsapi::JSContext;
|
|
use js::jsapi::JSObject;
|
|
use mime::Mime;
|
|
use script_traits::DocumentActivity;
|
|
use servo_url::{MutableOrigin, ServoUrl};
|
|
use std::ptr::NonNull;
|
|
|
|
// https://dom.spec.whatwg.org/#xmldocument
|
|
#[dom_struct]
|
|
pub struct XMLDocument {
|
|
document: Document,
|
|
}
|
|
|
|
impl XMLDocument {
|
|
fn new_inherited(window: &Window,
|
|
has_browsing_context: HasBrowsingContext,
|
|
url: Option<ServoUrl>,
|
|
origin: MutableOrigin,
|
|
is_html_document: IsHTMLDocument,
|
|
content_type: Option<Mime>,
|
|
last_modified: Option<String>,
|
|
activity: DocumentActivity,
|
|
source: DocumentSource,
|
|
doc_loader: DocumentLoader) -> XMLDocument {
|
|
XMLDocument {
|
|
document: Document::new_inherited(window,
|
|
has_browsing_context,
|
|
url,
|
|
origin,
|
|
is_html_document,
|
|
content_type,
|
|
last_modified,
|
|
activity,
|
|
source,
|
|
doc_loader,
|
|
None,
|
|
None,
|
|
Default::default()),
|
|
}
|
|
}
|
|
|
|
pub fn new(window: &Window,
|
|
has_browsing_context: HasBrowsingContext,
|
|
url: Option<ServoUrl>,
|
|
origin: MutableOrigin,
|
|
doctype: IsHTMLDocument,
|
|
content_type: Option<Mime>,
|
|
last_modified: Option<String>,
|
|
activity: DocumentActivity,
|
|
source: DocumentSource,
|
|
doc_loader: DocumentLoader)
|
|
-> DomRoot<XMLDocument> {
|
|
let doc = reflect_dom_object(
|
|
Box::new(XMLDocument::new_inherited(
|
|
window,
|
|
has_browsing_context,
|
|
url,
|
|
origin,
|
|
doctype,
|
|
content_type,
|
|
last_modified,
|
|
activity,
|
|
source,
|
|
doc_loader
|
|
)),
|
|
window,
|
|
XMLDocumentBinding::Wrap
|
|
);
|
|
{
|
|
let node = doc.upcast::<Node>();
|
|
node.set_owner_doc(&doc.document);
|
|
}
|
|
doc
|
|
}
|
|
}
|
|
|
|
impl XMLDocumentMethods for XMLDocument {
|
|
// https://html.spec.whatwg.org/multipage/#dom-document-location
|
|
fn GetLocation(&self) -> Option<DomRoot<Location>> {
|
|
self.upcast::<Document>().GetLocation()
|
|
}
|
|
|
|
// https://html.spec.whatwg.org/multipage/#dom-tree-accessors:supported-property-names
|
|
fn SupportedPropertyNames(&self) -> Vec<DOMString> {
|
|
self.upcast::<Document>().SupportedPropertyNames()
|
|
}
|
|
|
|
#[allow(unsafe_code)]
|
|
// https://html.spec.whatwg.org/multipage/#dom-tree-accessors:dom-document-nameditem-filter
|
|
unsafe fn NamedGetter(&self, _cx: *mut JSContext, name: DOMString) -> Option<NonNull<JSObject>> {
|
|
self.upcast::<Document>().NamedGetter(_cx, name)
|
|
}
|
|
}
|