mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Move the methods on bare Document onto DocumentHelpers.
This commit is contained in:
parent
d643ade7e8
commit
fff0491c01
7 changed files with 25 additions and 21 deletions
|
@ -4,7 +4,7 @@
|
|||
|
||||
use dom::bindings::js::{JS, JSRef, Temporary};
|
||||
use dom::bindings::utils::{Reflectable, WindowProxyHandler};
|
||||
use dom::document::Document;
|
||||
use dom::document::{Document, DocumentHelpers};
|
||||
use dom::window::Window;
|
||||
|
||||
use js::jsapi::JSObject;
|
||||
|
|
|
@ -162,6 +162,9 @@ impl CollectionFilter for AppletsFilter {
|
|||
}
|
||||
|
||||
pub trait DocumentHelpers<'a> {
|
||||
fn window(self) -> Temporary<Window>;
|
||||
fn encoding_name(self) -> Ref<'a, DOMString>;
|
||||
fn is_html_document(self) -> bool;
|
||||
fn url(self) -> &'a Url;
|
||||
fn quirks_mode(self) -> QuirksMode;
|
||||
fn set_quirks_mode(self, mode: QuirksMode);
|
||||
|
@ -178,6 +181,21 @@ pub trait DocumentHelpers<'a> {
|
|||
}
|
||||
|
||||
impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
|
||||
#[inline]
|
||||
fn window(self) -> Temporary<Window> {
|
||||
Temporary::new(self.window)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn encoding_name(self) -> Ref<'a, DOMString> {
|
||||
self.extended_deref().encoding_name.borrow()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_html_document(self) -> bool {
|
||||
self.is_html_document
|
||||
}
|
||||
|
||||
fn url(self) -> &'a Url {
|
||||
&self.extended_deref().url
|
||||
}
|
||||
|
@ -388,21 +406,6 @@ impl Document {
|
|||
node.set_owner_doc(*document);
|
||||
Temporary::from_rooted(*document)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn window(&self) -> Temporary<Window> {
|
||||
Temporary::new(self.window)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn encoding_name(&self) -> Ref<DOMString> {
|
||||
self.encoding_name.borrow()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_html_document(&self) -> bool {
|
||||
self.is_html_document
|
||||
}
|
||||
}
|
||||
|
||||
impl Reflectable for Document {
|
||||
|
|
|
@ -12,7 +12,8 @@ use dom::bindings::global::Window;
|
|||
use dom::bindings::js::{JS, JSRef, Root, Temporary, OptionalRootable};
|
||||
use dom::bindings::utils::{Reflector, Reflectable, reflect_dom_object};
|
||||
use dom::bindings::utils::{QName, Name, InvalidXMLName, xml_name_type};
|
||||
use dom::document::{Document, HTMLDocument, NonHTMLDocument, NotFromParser};
|
||||
use dom::document::{Document, DocumentHelpers, HTMLDocument, NonHTMLDocument};
|
||||
use dom::document::NotFromParser;
|
||||
use dom::documenttype::DocumentType;
|
||||
use dom::htmlbodyelement::HTMLBodyElement;
|
||||
use dom::htmlheadelement::HTMLHeadElement;
|
||||
|
|
|
@ -10,7 +10,7 @@ use dom::bindings::codegen::Bindings::HTMLImageElementBinding::HTMLImageElementM
|
|||
use dom::bindings::codegen::InheritTypes::{NodeCast, ElementCast, HTMLElementCast, HTMLImageElementDerived};
|
||||
use dom::bindings::js::{JS, JSRef, Temporary};
|
||||
use dom::bindings::utils::{Reflectable, Reflector};
|
||||
use dom::document::Document;
|
||||
use dom::document::{Document, DocumentHelpers};
|
||||
use dom::element::{Element, HTMLImageElementTypeId};
|
||||
use dom::element::AttributeHandlers;
|
||||
use dom::eventtarget::{EventTarget, NodeTargetTypeId};
|
||||
|
|
|
@ -9,7 +9,7 @@ use dom::bindings::error::Fallible;
|
|||
use dom::bindings::global::{GlobalRef, Window};
|
||||
use dom::bindings::js::{JSRef, Temporary};
|
||||
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
|
||||
use dom::document::Document;
|
||||
use dom::document::{Document, DocumentHelpers};
|
||||
|
||||
#[dom_struct]
|
||||
pub struct Range {
|
||||
|
|
|
@ -12,7 +12,7 @@ use dom::bindings::trace::JSTraceable;
|
|||
use dom::bindings::js::{JS, JSRef, Temporary};
|
||||
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
|
||||
use dom::node::TrustedNodeAddress;
|
||||
use dom::document::Document;
|
||||
use dom::document::{Document, DocumentHelpers};
|
||||
use parse::html::JSMessage;
|
||||
|
||||
use std::default::Default;
|
||||
|
|
|
@ -15,7 +15,7 @@ use dom::bindings::error::{ErrorResult, Fallible};
|
|||
use dom::bindings::global::Window;
|
||||
use dom::bindings::js::{JS, JSRef, OptionalRootable, Temporary};
|
||||
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
|
||||
use dom::document::Document;
|
||||
use dom::document::{Document, DocumentHelpers};
|
||||
use dom::node::{Node, NodeHelpers};
|
||||
|
||||
use std::cell::Cell;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue