Rename LayoutJS<T> to LayoutDom<T>

This commit is contained in:
Anthony Ramine 2017-09-26 01:30:06 +02:00
parent c52fd0a780
commit e2dac78d36
27 changed files with 104 additions and 104 deletions

View file

@ -12,7 +12,7 @@
//!
//! 1. Layout is not allowed to mutate the DOM.
//!
//! 2. Layout is not allowed to see anything with `LayoutJS` in the name, because it could hang
//! 2. Layout is not allowed to see anything with `LayoutDom` in the name, because it could hang
//! onto these objects and cause use-after-free.
//!
//! When implementing wrapper functions, be careful that you do not touch the borrow flags, or you

View file

@ -12,7 +12,7 @@
//!
//! 1. Layout is not allowed to mutate the DOM.
//!
//! 2. Layout is not allowed to see anything with `LayoutJS` in the name, because it could hang
//! 2. Layout is not allowed to see anything with `LayoutDom` in the name, because it could hang
//! onto these objects and cause use-after-free.
//!
//! When implementing wrapper functions, be careful that you do not touch the borrow flags, or you
@ -44,7 +44,7 @@ use script::layout_exports::{Document, Element, Node, Text};
use script::layout_exports::{HANDLED_SNAPSHOT, HAS_SNAPSHOT};
use script::layout_exports::{LayoutCharacterDataHelpers, LayoutDocumentHelpers};
use script::layout_exports::{LayoutElementHelpers, LayoutNodeHelpers, RawLayoutElementHelpers};
use script::layout_exports::LayoutJS;
use script::layout_exports::LayoutDom;
use script::layout_exports::PendingRestyle;
use script_layout_interface::{HTMLCanvasData, LayoutNodeType, SVGSVGData, TrustedNodeAddress};
use script_layout_interface::{OpaqueStyleAndLayoutData, StyleData};
@ -87,7 +87,7 @@ pub unsafe fn drop_style_and_layout_data(data: OpaqueStyleAndLayoutData) {
#[derive(Clone, Copy)]
pub struct ServoLayoutNode<'a> {
/// The wrapped node.
node: LayoutJS<Node>,
node: LayoutDom<Node>,
/// Being chained to a PhantomData prevents `LayoutNode`s from escaping.
chain: PhantomData<&'a ()>,
@ -115,7 +115,7 @@ impl<'a> PartialEq for ServoLayoutNode<'a> {
}
impl<'ln> ServoLayoutNode<'ln> {
fn from_layout_js(n: LayoutJS<Node>) -> ServoLayoutNode<'ln> {
fn from_layout_js(n: LayoutDom<Node>) -> ServoLayoutNode<'ln> {
ServoLayoutNode {
node: n,
chain: PhantomData,
@ -123,11 +123,11 @@ impl<'ln> ServoLayoutNode<'ln> {
}
pub unsafe fn new(address: &TrustedNodeAddress) -> ServoLayoutNode {
ServoLayoutNode::from_layout_js(LayoutJS::from_trusted_node_address(*address))
ServoLayoutNode::from_layout_js(LayoutDom::from_trusted_node_address(*address))
}
/// Creates a new layout node with the same lifetime as this layout node.
pub unsafe fn new_with_this_lifetime(&self, node: &LayoutJS<Node>) -> ServoLayoutNode<'ln> {
pub unsafe fn new_with_this_lifetime(&self, node: &LayoutDom<Node>) -> ServoLayoutNode<'ln> {
ServoLayoutNode {
node: *node,
chain: self.chain,
@ -301,9 +301,9 @@ impl<'le> GetLayoutData for ServoThreadSafeLayoutElement<'le> {
}
impl<'ln> ServoLayoutNode<'ln> {
/// Returns the interior of this node as a `LayoutJS`. This is highly unsafe for layout to
/// Returns the interior of this node as a `LayoutDom`. This is highly unsafe for layout to
/// call and as such is marked `unsafe`.
pub unsafe fn get_jsmanaged(&self) -> &LayoutJS<Node> {
pub unsafe fn get_jsmanaged(&self) -> &LayoutDom<Node> {
&self.node
}
}
@ -311,7 +311,7 @@ impl<'ln> ServoLayoutNode<'ln> {
// A wrapper around documents that ensures ayout can only ever access safe properties.
#[derive(Clone, Copy)]
pub struct ServoLayoutDocument<'ld> {
document: LayoutJS<Document>,
document: LayoutDom<Document>,
chain: PhantomData<&'ld ()>,
}
@ -341,7 +341,7 @@ impl<'ld> ServoLayoutDocument<'ld> {
unsafe { self.document.style_shared_lock() }
}
pub fn from_layout_js(doc: LayoutJS<Document>) -> ServoLayoutDocument<'ld> {
pub fn from_layout_js(doc: LayoutDom<Document>) -> ServoLayoutDocument<'ld> {
ServoLayoutDocument {
document: doc,
chain: PhantomData,
@ -352,7 +352,7 @@ impl<'ld> ServoLayoutDocument<'ld> {
/// A wrapper around elements that ensures layout can only ever access safe properties.
#[derive(Clone, Copy)]
pub struct ServoLayoutElement<'le> {
element: LayoutJS<Element>,
element: LayoutDom<Element>,
chain: PhantomData<&'le ()>,
}
@ -560,7 +560,7 @@ impl<'le> Hash for ServoLayoutElement<'le> {
impl<'le> Eq for ServoLayoutElement<'le> {}
impl<'le> ServoLayoutElement<'le> {
fn from_layout_js(el: LayoutJS<Element>) -> ServoLayoutElement<'le> {
fn from_layout_js(el: LayoutDom<Element>) -> ServoLayoutElement<'le> {
ServoLayoutElement {
element: el,
chain: PhantomData,
@ -611,7 +611,7 @@ impl<'le> ServoLayoutElement<'le> {
}
}
fn as_element<'le>(node: LayoutJS<Node>) -> Option<ServoLayoutElement<'le>> {
fn as_element<'le>(node: LayoutDom<Node>) -> Option<ServoLayoutElement<'le>> {
node.downcast().map(ServoLayoutElement::from_layout_js)
}
@ -828,7 +828,7 @@ impl<'ln> DangerousThreadSafeLayoutNode for ServoThreadSafeLayoutNode<'ln> {
impl<'ln> ServoThreadSafeLayoutNode<'ln> {
/// Creates a new layout node with the same lifetime as this layout node.
pub unsafe fn new_with_this_lifetime(&self, node: &LayoutJS<Node>) -> ServoThreadSafeLayoutNode<'ln> {
pub unsafe fn new_with_this_lifetime(&self, node: &LayoutDom<Node>) -> ServoThreadSafeLayoutNode<'ln> {
ServoThreadSafeLayoutNode {
node: self.node.new_with_this_lifetime(node),
pseudo: PseudoElementType::Normal,
@ -843,9 +843,9 @@ impl<'ln> ServoThreadSafeLayoutNode<'ln> {
}
}
/// Returns the interior of this node as a `LayoutJS`. This is highly unsafe for layout to
/// Returns the interior of this node as a `LayoutDom`. This is highly unsafe for layout to
/// call and as such is marked `unsafe`.
unsafe fn get_jsmanaged(&self) -> &LayoutJS<Node> {
unsafe fn get_jsmanaged(&self) -> &LayoutDom<Node> {
self.node.get_jsmanaged()
}
}
@ -915,7 +915,7 @@ impl<'ln> ThreadSafeLayoutNode for ServoThreadSafeLayoutNode<'ln> {
fn is_ignorable_whitespace(&self, context: &SharedStyleContext) -> bool {
unsafe {
let text: LayoutJS<Text> = match self.get_jsmanaged().downcast() {
let text: LayoutDom<Text> = match self.get_jsmanaged().downcast() {
Some(text) => text,
None => return false
};

View file

@ -7,7 +7,7 @@ use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::AttrBinding::{self, AttrMethods};
use dom::bindings::inheritance::Castable;
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::root::{LayoutJS, MutNullableDom, Root, RootedReference};
use dom::bindings::root::{LayoutDom, MutNullableDom, Root, RootedReference};
use dom::bindings::str::DOMString;
use dom::customelementregistry::CallbackReaction;
use dom::element::{AttributeMutation, Element};
@ -256,7 +256,7 @@ pub trait AttrHelpersForLayout {
}
#[allow(unsafe_code)]
impl AttrHelpersForLayout for LayoutJS<Attr> {
impl AttrHelpersForLayout for LayoutDom<Attr> {
#[inline]
unsafe fn value_forever(&self) -> &'static AttrValue {
// This transmute is used to cheat the lifetime restriction.

View file

@ -7195,7 +7195,7 @@ class GlobalGenRoots():
imports = [CGGeneric("use dom::types::*;\n"),
CGGeneric("use dom::bindings::conversions::{DerivedFrom, get_dom_class};\n"),
CGGeneric("use dom::bindings::inheritance::Castable;\n"),
CGGeneric("use dom::bindings::root::{Dom, LayoutJS, Root};\n"),
CGGeneric("use dom::bindings::root::{Dom, LayoutDom, Root};\n"),
CGGeneric("use dom::bindings::trace::JSTraceable;\n"),
CGGeneric("use dom::bindings::reflector::DomObject;\n"),
CGGeneric("use js::jsapi::JSTracer;\n\n"),

View file

@ -68,10 +68,10 @@ impl<T> HeapSizeOf for Dom<T> {
}
impl<T> Dom<T> {
/// Returns `LayoutJS<T>` containing the same pointer.
pub unsafe fn to_layout(&self) -> LayoutJS<T> {
/// Returns `LayoutDom<T>` containing the same pointer.
pub unsafe fn to_layout(&self) -> LayoutDom<T> {
debug_assert!(thread_state::get().is_layout());
LayoutJS {
LayoutDom {
ptr: self.ptr.clone(),
}
}
@ -124,32 +124,32 @@ unsafe impl<T: DomObject> JSTraceable for Dom<T> {
/// An unrooted reference to a DOM object for use in layout. `Layout*Helpers`
/// traits must be implemented on this.
#[allow_unrooted_interior]
pub struct LayoutJS<T> {
pub struct LayoutDom<T> {
ptr: NonZero<*const T>,
}
impl<T: Castable> LayoutJS<T> {
impl<T: Castable> LayoutDom<T> {
/// Cast a DOM object root upwards to one of the interfaces it derives from.
pub fn upcast<U>(&self) -> LayoutJS<U>
pub fn upcast<U>(&self) -> LayoutDom<U>
where U: Castable,
T: DerivedFrom<U>
{
debug_assert!(thread_state::get().is_layout());
let ptr: *const T = self.ptr.get();
LayoutJS {
LayoutDom {
ptr: unsafe { NonZero::new_unchecked(ptr as *const U) },
}
}
/// Cast a DOM object downwards to one of the interfaces it might implement.
pub fn downcast<U>(&self) -> Option<LayoutJS<U>>
pub fn downcast<U>(&self) -> Option<LayoutDom<U>>
where U: DerivedFrom<T>
{
debug_assert!(thread_state::get().is_layout());
unsafe {
if (*self.unsafe_get()).is::<U>() {
let ptr: *const T = self.ptr.get();
Some(LayoutJS {
Some(LayoutDom {
ptr: NonZero::new_unchecked(ptr as *const U),
})
} else {
@ -159,7 +159,7 @@ impl<T: Castable> LayoutJS<T> {
}
}
impl<T: DomObject> LayoutJS<T> {
impl<T: DomObject> LayoutDom<T> {
/// Get the reflector.
pub unsafe fn get_jsobject(&self) -> *mut JSObject {
debug_assert!(thread_state::get().is_layout());
@ -167,7 +167,7 @@ impl<T: DomObject> LayoutJS<T> {
}
}
impl<T> Copy for LayoutJS<T> {}
impl<T> Copy for LayoutDom<T> {}
impl<T> PartialEq for Dom<T> {
fn eq(&self, other: &Dom<T>) -> bool {
@ -177,13 +177,13 @@ impl<T> PartialEq for Dom<T> {
impl<T> Eq for Dom<T> {}
impl<T> PartialEq for LayoutJS<T> {
fn eq(&self, other: &LayoutJS<T>) -> bool {
impl<T> PartialEq for LayoutDom<T> {
fn eq(&self, other: &LayoutDom<T>) -> bool {
self.ptr == other.ptr
}
}
impl<T> Eq for LayoutJS<T> {}
impl<T> Eq for LayoutDom<T> {}
impl<T> Hash for Dom<T> {
fn hash<H: Hasher>(&self, state: &mut H) {
@ -191,7 +191,7 @@ impl<T> Hash for Dom<T> {
}
}
impl<T> Hash for LayoutJS<T> {
impl<T> Hash for LayoutDom<T> {
fn hash<H: Hasher>(&self, state: &mut H) {
self.ptr.hash(state)
}
@ -208,23 +208,23 @@ impl <T> Clone for Dom<T> {
}
}
impl <T> Clone for LayoutJS<T> {
impl <T> Clone for LayoutDom<T> {
#[inline]
fn clone(&self) -> LayoutJS<T> {
fn clone(&self) -> LayoutDom<T> {
debug_assert!(thread_state::get().is_layout());
LayoutJS {
LayoutDom {
ptr: self.ptr.clone(),
}
}
}
impl LayoutJS<Node> {
impl LayoutDom<Node> {
/// Create a new JS-owned value wrapped from an address known to be a
/// `Node` pointer.
pub unsafe fn from_trusted_node_address(inner: TrustedNodeAddress) -> LayoutJS<Node> {
pub unsafe fn from_trusted_node_address(inner: TrustedNodeAddress) -> LayoutDom<Node> {
debug_assert!(thread_state::get().is_layout());
let TrustedNodeAddress(addr) = inner;
LayoutJS {
LayoutDom {
ptr: NonZero::new_unchecked(addr as *const Node),
}
}
@ -327,10 +327,10 @@ impl<T: DomObject> MutNullableDom<T> {
}
}
/// Retrieve a copy of the inner optional `Dom<T>` as `LayoutJS<T>`.
/// Retrieve a copy of the inner optional `Dom<T>` as `LayoutDom<T>`.
/// For use by layout, which can't use safe types like Temporary.
#[allow(unrooted_must_root)]
pub unsafe fn get_inner_as_layout(&self) -> Option<LayoutJS<T>> {
pub unsafe fn get_inner_as_layout(&self) -> Option<LayoutDom<T>> {
debug_assert!(thread_state::get().is_layout());
ptr::read(self.ptr.get()).map(|js| js.to_layout())
}
@ -442,7 +442,7 @@ unsafe impl<T: DomObject> JSTraceable for OnceCellJS<T> {
}
}
impl<T: DomObject> LayoutJS<T> {
impl<T: DomObject> LayoutDom<T> {
/// Returns an unsafe pointer to the interior of this JS object. This is
/// the only method that be safely accessed from layout. (The fact that
/// this is unsafe is what necessitates the layout wrappers.)

View file

@ -23,7 +23,7 @@ use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::inheritance::Castable;
use dom::bindings::num::Finite;
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::bindings::root::{Dom, LayoutJS, Root};
use dom::bindings::root::{Dom, LayoutDom, Root};
use dom::bindings::str::DOMString;
use dom::canvasgradient::{CanvasGradient, CanvasGradientStyle, ToFillOrStrokeStyle};
use dom::canvaspattern::CanvasPattern;
@ -585,7 +585,7 @@ pub trait LayoutCanvasRenderingContext2DHelpers {
unsafe fn get_ipc_renderer(&self) -> IpcSender<CanvasMsg>;
}
impl LayoutCanvasRenderingContext2DHelpers for LayoutJS<CanvasRenderingContext2D> {
impl LayoutCanvasRenderingContext2DHelpers for LayoutDom<CanvasRenderingContext2D> {
#[allow(unsafe_code)]
unsafe fn get_ipc_renderer(&self) -> IpcSender<CanvasMsg> {
(*self.unsafe_get()).ipc_renderer.clone()

View file

@ -12,7 +12,7 @@ use dom::bindings::codegen::InheritTypes::{CharacterDataTypeId, NodeTypeId};
use dom::bindings::codegen::UnionTypes::NodeOrString;
use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::inheritance::Castable;
use dom::bindings::root::{LayoutJS, Root};
use dom::bindings::root::{LayoutDom, Root};
use dom::bindings::str::DOMString;
use dom::comment::Comment;
use dom::document::Document;
@ -253,7 +253,7 @@ pub trait LayoutCharacterDataHelpers {
}
#[allow(unsafe_code)]
impl LayoutCharacterDataHelpers for LayoutJS<CharacterData> {
impl LayoutCharacterDataHelpers for LayoutDom<CharacterData> {
#[inline]
unsafe fn data_for_layout(&self) -> &str {
&(*self.unsafe_get()).data.borrow_for_layout()

View file

@ -27,7 +27,7 @@ use dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, Nod
use dom::bindings::num::Finite;
use dom::bindings::refcounted::{Trusted, TrustedPromise};
use dom::bindings::reflector::{DomObject, reflect_dom_object};
use dom::bindings::root::{Dom, LayoutJS, MutNullableDom, Root, RootedReference};
use dom::bindings::root::{Dom, LayoutDom, MutNullableDom, Root, RootedReference};
use dom::bindings::str::{DOMString, USVString};
use dom::bindings::xmlname::{namespace_from_domstring, validate_and_extract, xml_name_type};
use dom::bindings::xmlname::XMLName::InvalidXMLName;
@ -2082,7 +2082,7 @@ pub enum DocumentSource {
#[allow(unsafe_code)]
pub trait LayoutDocumentHelpers {
unsafe fn is_html_document_for_layout(&self) -> bool;
unsafe fn drain_pending_restyles(&self) -> Vec<(LayoutJS<Element>, PendingRestyle)>;
unsafe fn drain_pending_restyles(&self) -> Vec<(LayoutDom<Element>, PendingRestyle)>;
unsafe fn needs_paint_from_layout(&self);
unsafe fn will_paint(&self);
unsafe fn quirks_mode(&self) -> QuirksMode;
@ -2090,7 +2090,7 @@ pub trait LayoutDocumentHelpers {
}
#[allow(unsafe_code)]
impl LayoutDocumentHelpers for LayoutJS<Document> {
impl LayoutDocumentHelpers for LayoutDom<Document> {
#[inline]
unsafe fn is_html_document_for_layout(&self) -> bool {
(*self.unsafe_get()).is_html_document
@ -2098,7 +2098,7 @@ impl LayoutDocumentHelpers for LayoutJS<Document> {
#[inline]
#[allow(unrooted_must_root)]
unsafe fn drain_pending_restyles(&self) -> Vec<(LayoutJS<Element>, PendingRestyle)> {
unsafe fn drain_pending_restyles(&self) -> Vec<(LayoutDom<Element>, PendingRestyle)> {
let mut elements = (*self.unsafe_get()).pending_restyles.borrow_mut_for_layout();
// Elements were in a document when they were adding to this list, but that
// may no longer be true when the next layout occurs.

View file

@ -24,7 +24,7 @@ use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId};
use dom::bindings::refcounted::{Trusted, TrustedPromise};
use dom::bindings::reflector::DomObject;
use dom::bindings::root::{Dom, LayoutJS, MutNullableDom, Root, RootedReference};
use dom::bindings::root::{Dom, LayoutDom, MutNullableDom, Root, RootedReference};
use dom::bindings::str::DOMString;
use dom::bindings::xmlname::{namespace_from_domstring, validate_and_extract, xml_name_type};
use dom::bindings::xmlname::XMLName::InvalidXMLName;
@ -384,7 +384,7 @@ pub trait RawLayoutElementHelpers {
#[inline]
#[allow(unsafe_code)]
pub unsafe fn get_attr_for_layout<'a>(elem: &'a Element, namespace: &Namespace, name: &LocalName)
-> Option<LayoutJS<Attr>> {
-> Option<LayoutDom<Attr>> {
// cast to point to T in RefCell<T> directly
let attrs = elem.attrs.borrow_for_layout();
attrs.iter().find(|attr| {
@ -453,7 +453,7 @@ pub trait LayoutElementHelpers {
fn has_selector_flags(&self, flags: ElementSelectorFlags) -> bool;
}
impl LayoutElementHelpers for LayoutJS<Element> {
impl LayoutElementHelpers for LayoutDom<Element> {
#[allow(unsafe_code)]
#[inline]
unsafe fn has_class_for_layout(&self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool {

View file

@ -7,7 +7,7 @@ use dom::attr::Attr;
use dom::bindings::codegen::Bindings::HTMLBodyElementBinding::{self, HTMLBodyElementMethods};
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
use dom::bindings::inheritance::Castable;
use dom::bindings::root::{LayoutJS, Root};
use dom::bindings::root::{LayoutDom, Root};
use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::element::{AttributeMutation, Element, RawLayoutElementHelpers};
@ -88,7 +88,7 @@ pub trait HTMLBodyElementLayoutHelpers {
fn get_background(&self) -> Option<ServoUrl>;
}
impl HTMLBodyElementLayoutHelpers for LayoutJS<HTMLBodyElement> {
impl HTMLBodyElementLayoutHelpers for LayoutDom<HTMLBodyElement> {
#[allow(unsafe_code)]
fn get_background_color(&self) -> Option<RGBA> {
unsafe {

View file

@ -15,7 +15,7 @@ use dom::bindings::conversions::ConversionResult;
use dom::bindings::error::{Error, Fallible};
use dom::bindings::inheritance::Castable;
use dom::bindings::num::Finite;
use dom::bindings::root::{Dom, LayoutJS, Root};
use dom::bindings::root::{Dom, LayoutDom, Root};
use dom::bindings::str::DOMString;
use dom::canvasrenderingcontext2d::{CanvasRenderingContext2D, LayoutCanvasRenderingContext2DHelpers};
use dom::document::Document;
@ -101,7 +101,7 @@ pub trait LayoutHTMLCanvasElementHelpers {
fn get_height(&self) -> LengthOrPercentageOrAuto;
}
impl LayoutHTMLCanvasElementHelpers for LayoutJS<HTMLCanvasElement> {
impl LayoutHTMLCanvasElementHelpers for LayoutDom<HTMLCanvasElement> {
#[allow(unsafe_code)]
fn data(&self) -> HTMLCanvasData {
unsafe {

View file

@ -7,7 +7,7 @@ use dom::attr::Attr;
use dom::bindings::codegen::Bindings::HTMLFontElementBinding;
use dom::bindings::codegen::Bindings::HTMLFontElementBinding::HTMLFontElementMethods;
use dom::bindings::inheritance::Castable;
use dom::bindings::root::{LayoutJS, Root};
use dom::bindings::root::{LayoutDom, Root};
use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::element::{Element, RawLayoutElementHelpers};
@ -96,7 +96,7 @@ pub trait HTMLFontElementLayoutHelpers {
fn get_size(&self) -> Option<u32>;
}
impl HTMLFontElementLayoutHelpers for LayoutJS<HTMLFontElement> {
impl HTMLFontElementLayoutHelpers for LayoutDom<HTMLFontElement> {
#[allow(unsafe_code)]
fn get_color(&self) -> Option<RGBA> {
unsafe {

View file

@ -5,7 +5,7 @@
use cssparser::RGBA;
use dom::bindings::codegen::Bindings::HTMLHRElementBinding::{self, HTMLHRElementMethods};
use dom::bindings::inheritance::Castable;
use dom::bindings::root::{LayoutJS, Root};
use dom::bindings::root::{LayoutDom, Root};
use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::element::{Element, RawLayoutElementHelpers};
@ -63,7 +63,7 @@ pub trait HTMLHRLayoutHelpers {
fn get_width(&self) -> LengthOrPercentageOrAuto;
}
impl HTMLHRLayoutHelpers for LayoutJS<HTMLHRElement> {
impl HTMLHRLayoutHelpers for LayoutDom<HTMLHRElement> {
#[allow(unsafe_code)]
fn get_color(&self) -> Option<RGBA> {
unsafe {

View file

@ -21,7 +21,7 @@ use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::inheritance::Castable;
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::DomObject;
use dom::bindings::root::{LayoutJS, MutNullableDom, Root};
use dom::bindings::root::{LayoutDom, MutNullableDom, Root};
use dom::bindings::str::DOMString;
use dom::customevent::CustomEvent;
use dom::document::Document;
@ -419,7 +419,7 @@ pub trait HTMLIFrameElementLayoutMethods {
fn get_height(&self) -> LengthOrPercentageOrAuto;
}
impl HTMLIFrameElementLayoutMethods for LayoutJS<HTMLIFrameElement> {
impl HTMLIFrameElementLayoutMethods for LayoutDom<HTMLIFrameElement> {
#[inline]
#[allow(unsafe_code)]
fn pipeline_id(&self) -> Option<PipelineId> {

View file

@ -17,7 +17,7 @@ use dom::bindings::error::Fallible;
use dom::bindings::inheritance::Castable;
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::DomObject;
use dom::bindings::root::{LayoutJS, MutNullableDom, Root};
use dom::bindings::root::{LayoutDom, MutNullableDom, Root};
use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::element::{AttributeMutation, Element, RawLayoutElementHelpers};
@ -694,7 +694,7 @@ pub trait LayoutHTMLImageElementHelpers {
fn get_height(&self) -> LengthOrPercentageOrAuto;
}
impl LayoutHTMLImageElementHelpers for LayoutJS<HTMLImageElement> {
impl LayoutHTMLImageElementHelpers for LayoutDom<HTMLImageElement> {
#[allow(unsafe_code)]
unsafe fn image(&self) -> Option<Arc<Image>> {
(*self.unsafe_get()).current_request.borrow_for_layout().image.clone()

View file

@ -15,7 +15,7 @@ use dom::bindings::codegen::Bindings::MouseEventBinding::MouseEventMethods;
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
use dom::bindings::error::{Error, ErrorResult};
use dom::bindings::inheritance::Castable;
use dom::bindings::root::{Dom, LayoutJS, MutNullableDom, Root, RootedReference};
use dom::bindings::root::{Dom, LayoutDom, MutNullableDom, Root, RootedReference};
use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::element::{AttributeMutation, Element, LayoutElementHelpers, RawLayoutElementHelpers};
@ -206,15 +206,15 @@ pub trait LayoutHTMLInputElementHelpers {
}
#[allow(unsafe_code)]
unsafe fn get_raw_textinput_value(input: LayoutJS<HTMLInputElement>) -> DOMString {
unsafe fn get_raw_textinput_value(input: LayoutDom<HTMLInputElement>) -> DOMString {
(*input.unsafe_get()).textinput.borrow_for_layout().get_content()
}
impl LayoutHTMLInputElementHelpers for LayoutJS<HTMLInputElement> {
impl LayoutHTMLInputElementHelpers for LayoutDom<HTMLInputElement> {
#[allow(unsafe_code)]
unsafe fn value_for_layout(self) -> String {
#[allow(unsafe_code)]
unsafe fn get_raw_attr_value(input: LayoutJS<HTMLInputElement>, default: &str) -> String {
unsafe fn get_raw_attr_value(input: LayoutDom<HTMLInputElement>, default: &str) -> String {
let elem = input.upcast::<Element>();
let value = (*elem.unsafe_get())
.get_attr_val_for_layout(&ns!(), &local_name!("value"))

View file

@ -6,7 +6,7 @@ use cssparser::RGBA;
use dom::bindings::codegen::Bindings::HTMLTableCellElementBinding::HTMLTableCellElementMethods;
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
use dom::bindings::inheritance::Castable;
use dom::bindings::root::LayoutJS;
use dom::bindings::root::LayoutDom;
use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::element::{Element, RawLayoutElementHelpers};
@ -88,7 +88,7 @@ pub trait HTMLTableCellElementLayoutHelpers {
}
#[allow(unsafe_code)]
impl HTMLTableCellElementLayoutHelpers for LayoutJS<HTMLTableCellElement> {
impl HTMLTableCellElementLayoutHelpers for LayoutDom<HTMLTableCellElement> {
fn get_background_color(&self) -> Option<RGBA> {
unsafe {
(&*self.upcast::<Element>().unsafe_get())

View file

@ -10,7 +10,7 @@ use dom::bindings::codegen::Bindings::HTMLTableElementBinding::HTMLTableElementM
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::inheritance::Castable;
use dom::bindings::root::{Dom, LayoutJS, MutNullableDom, Root, RootedReference};
use dom::bindings::root::{Dom, LayoutDom, MutNullableDom, Root, RootedReference};
use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::element::{AttributeMutation, Element, RawLayoutElementHelpers};
@ -379,7 +379,7 @@ pub trait HTMLTableElementLayoutHelpers {
fn get_width(&self) -> LengthOrPercentageOrAuto;
}
impl HTMLTableElementLayoutHelpers for LayoutJS<HTMLTableElement> {
impl HTMLTableElementLayoutHelpers for LayoutDom<HTMLTableElement> {
#[allow(unsafe_code)]
fn get_background_color(&self) -> Option<RGBA> {
unsafe {

View file

@ -9,7 +9,7 @@ use dom::bindings::codegen::Bindings::HTMLTableSectionElementBinding::HTMLTableS
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
use dom::bindings::error::{ErrorResult, Fallible};
use dom::bindings::inheritance::Castable;
use dom::bindings::root::{LayoutJS, MutNullableDom, Root, RootedReference};
use dom::bindings::root::{LayoutDom, MutNullableDom, Root, RootedReference};
use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::element::{Element, RawLayoutElementHelpers};
@ -142,7 +142,7 @@ pub trait HTMLTableRowElementLayoutHelpers {
}
#[allow(unsafe_code)]
impl HTMLTableRowElementLayoutHelpers for LayoutJS<HTMLTableRowElement> {
impl HTMLTableRowElementLayoutHelpers for LayoutDom<HTMLTableRowElement> {
fn get_background_color(&self) -> Option<RGBA> {
unsafe {
(&*self.upcast::<Element>().unsafe_get())

View file

@ -7,7 +7,7 @@ use dom::bindings::codegen::Bindings::HTMLTableSectionElementBinding::{self, HTM
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
use dom::bindings::error::{ErrorResult, Fallible};
use dom::bindings::inheritance::Castable;
use dom::bindings::root::{LayoutJS, Root, RootedReference};
use dom::bindings::root::{LayoutDom, Root, RootedReference};
use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::element::{Element, RawLayoutElementHelpers};
@ -81,7 +81,7 @@ pub trait HTMLTableSectionElementLayoutHelpers {
}
#[allow(unsafe_code)]
impl HTMLTableSectionElementLayoutHelpers for LayoutJS<HTMLTableSectionElement> {
impl HTMLTableSectionElementLayoutHelpers for LayoutDom<HTMLTableSectionElement> {
fn get_background_color(&self) -> Option<RGBA> {
unsafe {
(&*self.upcast::<Element>().unsafe_get())

View file

@ -9,7 +9,7 @@ use dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding;
use dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding::HTMLTextAreaElementMethods;
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
use dom::bindings::inheritance::Castable;
use dom::bindings::root::{LayoutJS, MutNullableDom, Root};
use dom::bindings::root::{LayoutDom, MutNullableDom, Root};
use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::element::{AttributeMutation, Element};
@ -57,7 +57,7 @@ pub trait LayoutHTMLTextAreaElementHelpers {
fn get_rows(self) -> u32;
}
impl LayoutHTMLTextAreaElementHelpers for LayoutJS<HTMLTextAreaElement> {
impl LayoutHTMLTextAreaElementHelpers for LayoutDom<HTMLTextAreaElement> {
#[allow(unrooted_must_root)]
#[allow(unsafe_code)]
unsafe fn get_value_for_layout(self) -> String {

View file

@ -195,11 +195,11 @@
//! =================================
//!
//! Layout code can access the DOM through the
//! [`LayoutJS`](bindings/root/struct.LayoutJS.html) smart pointer. This does not
//! [`LayoutDom`](bindings/root/struct.LayoutDom.html) smart pointer. This does not
//! keep the DOM object alive; we ensure that no DOM code (Garbage Collection
//! in particular) runs while the layout thread is accessing the DOM.
//!
//! Methods accessible to layout are implemented on `LayoutJS<Foo>` using
//! Methods accessible to layout are implemented on `LayoutDom<Foo>` using
//! `LayoutFooHelpers` traits.
#[macro_use]

View file

@ -23,7 +23,7 @@ use dom::bindings::inheritance::{Castable, CharacterDataTypeId, ElementTypeId};
use dom::bindings::inheritance::{EventTargetTypeId, HTMLElementTypeId, NodeTypeId};
use dom::bindings::inheritance::{SVGElementTypeId, SVGGraphicsElementTypeId};
use dom::bindings::reflector::{DomObject, reflect_dom_object};
use dom::bindings::root::{Dom, LayoutJS, MutNullableDom, Root, RootedReference};
use dom::bindings::root::{Dom, LayoutDom, MutNullableDom, Root, RootedReference};
use dom::bindings::str::{DOMString, USVString};
use dom::bindings::xmlname::namespace_from_domstring;
use dom::characterdata::{CharacterData, LayoutCharacterDataHelpers};
@ -999,13 +999,13 @@ pub unsafe fn from_untrusted_node_address(_runtime: *mut JSRuntime, candidate: U
pub trait LayoutNodeHelpers {
unsafe fn type_id_for_layout(&self) -> NodeTypeId;
unsafe fn parent_node_ref(&self) -> Option<LayoutJS<Node>>;
unsafe fn first_child_ref(&self) -> Option<LayoutJS<Node>>;
unsafe fn last_child_ref(&self) -> Option<LayoutJS<Node>>;
unsafe fn prev_sibling_ref(&self) -> Option<LayoutJS<Node>>;
unsafe fn next_sibling_ref(&self) -> Option<LayoutJS<Node>>;
unsafe fn parent_node_ref(&self) -> Option<LayoutDom<Node>>;
unsafe fn first_child_ref(&self) -> Option<LayoutDom<Node>>;
unsafe fn last_child_ref(&self) -> Option<LayoutDom<Node>>;
unsafe fn prev_sibling_ref(&self) -> Option<LayoutDom<Node>>;
unsafe fn next_sibling_ref(&self) -> Option<LayoutDom<Node>>;
unsafe fn owner_doc_for_layout(&self) -> LayoutJS<Document>;
unsafe fn owner_doc_for_layout(&self) -> LayoutDom<Document>;
unsafe fn is_element_for_layout(&self) -> bool;
unsafe fn get_flag(&self, flag: NodeFlags) -> bool;
@ -1027,7 +1027,7 @@ pub trait LayoutNodeHelpers {
fn opaque(&self) -> OpaqueNode;
}
impl LayoutNodeHelpers for LayoutJS<Node> {
impl LayoutNodeHelpers for LayoutDom<Node> {
#[inline]
#[allow(unsafe_code)]
unsafe fn type_id_for_layout(&self) -> NodeTypeId {
@ -1042,37 +1042,37 @@ impl LayoutNodeHelpers for LayoutJS<Node> {
#[inline]
#[allow(unsafe_code)]
unsafe fn parent_node_ref(&self) -> Option<LayoutJS<Node>> {
unsafe fn parent_node_ref(&self) -> Option<LayoutDom<Node>> {
(*self.unsafe_get()).parent_node.get_inner_as_layout()
}
#[inline]
#[allow(unsafe_code)]
unsafe fn first_child_ref(&self) -> Option<LayoutJS<Node>> {
unsafe fn first_child_ref(&self) -> Option<LayoutDom<Node>> {
(*self.unsafe_get()).first_child.get_inner_as_layout()
}
#[inline]
#[allow(unsafe_code)]
unsafe fn last_child_ref(&self) -> Option<LayoutJS<Node>> {
unsafe fn last_child_ref(&self) -> Option<LayoutDom<Node>> {
(*self.unsafe_get()).last_child.get_inner_as_layout()
}
#[inline]
#[allow(unsafe_code)]
unsafe fn prev_sibling_ref(&self) -> Option<LayoutJS<Node>> {
unsafe fn prev_sibling_ref(&self) -> Option<LayoutDom<Node>> {
(*self.unsafe_get()).prev_sibling.get_inner_as_layout()
}
#[inline]
#[allow(unsafe_code)]
unsafe fn next_sibling_ref(&self) -> Option<LayoutJS<Node>> {
unsafe fn next_sibling_ref(&self) -> Option<LayoutDom<Node>> {
(*self.unsafe_get()).next_sibling.get_inner_as_layout()
}
#[inline]
#[allow(unsafe_code)]
unsafe fn owner_doc_for_layout(&self) -> LayoutJS<Document> {
unsafe fn owner_doc_for_layout(&self) -> LayoutDom<Document> {
(*self.unsafe_get()).owner_doc.get_inner_as_layout().unwrap()
}

View file

@ -5,7 +5,7 @@
use dom::attr::Attr;
use dom::bindings::codegen::Bindings::SVGSVGElementBinding;
use dom::bindings::inheritance::Castable;
use dom::bindings::root::{LayoutJS, Root};
use dom::bindings::root::{LayoutDom, Root};
use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::element::{AttributeMutation, Element, RawLayoutElementHelpers};
@ -49,7 +49,7 @@ pub trait LayoutSVGSVGElementHelpers {
fn data(&self) -> SVGSVGData;
}
impl LayoutSVGSVGElementHelpers for LayoutJS<SVGSVGElement> {
impl LayoutSVGSVGElementHelpers for LayoutDom<SVGSVGElement> {
#[allow(unsafe_code)]
fn data(&self) -> SVGSVGData {
unsafe {

View file

@ -20,7 +20,7 @@ use dom::bindings::conversions::{ConversionResult, FromJSValConvertible, ToJSVal
use dom::bindings::error::{Error, Fallible};
use dom::bindings::inheritance::Castable;
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
use dom::bindings::root::{Dom, LayoutJS, MutNullableDom, Root};
use dom::bindings::root::{Dom, LayoutDom, MutNullableDom, Root};
use dom::bindings::str::DOMString;
use dom::event::{Event, EventBubbles, EventCancelable};
use dom::htmlcanvaselement::HTMLCanvasElement;
@ -3384,7 +3384,7 @@ pub trait LayoutCanvasWebGLRenderingContextHelpers {
unsafe fn canvas_data_source(&self) -> HTMLCanvasDataSource;
}
impl LayoutCanvasWebGLRenderingContextHelpers for LayoutJS<WebGLRenderingContext> {
impl LayoutCanvasWebGLRenderingContextHelpers for LayoutDom<WebGLRenderingContext> {
#[allow(unsafe_code)]
unsafe fn canvas_data_source(&self) -> HTMLCanvasDataSource {
HTMLCanvasDataSource::WebGL((*self.unsafe_get()).layout_handle())

View file

@ -141,7 +141,7 @@ mod webdriver_handlers;
pub mod layout_exports {
pub use dom::bindings::inheritance::{CharacterDataTypeId, ElementTypeId};
pub use dom::bindings::inheritance::{HTMLElementTypeId, NodeTypeId};
pub use dom::bindings::root::LayoutJS;
pub use dom::bindings::root::LayoutDom;
pub use dom::characterdata::LayoutCharacterDataHelpers;
pub use dom::document::{Document, LayoutDocumentHelpers, PendingRestyle};
pub use dom::element::{Element, LayoutElementHelpers, RawLayoutElementHelpers};

View file

@ -79,7 +79,7 @@ pub trait GetLayoutData {
}
/// A wrapper so that layout can access only the methods that it should have access to. Layout must
/// only ever see these and must never see instances of `LayoutJS`.
/// only ever see these and must never see instances of `LayoutDom`.
pub trait LayoutNode: Debug + GetLayoutData + TNode {
type ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode;
fn to_threadsafe(&self) -> Self::ConcreteThreadSafeLayoutNode;