mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Pass the document instead of the documentElement to reflow.
This commit is contained in:
parent
85596b5510
commit
441c84d75d
5 changed files with 51 additions and 26 deletions
|
@ -43,6 +43,7 @@ use script::dom::bindings::codegen::InheritTypes::{HTMLElementTypeId, NodeTypeId
|
|||
use script::dom::bindings::conversions::Castable;
|
||||
use script::dom::bindings::js::LayoutJS;
|
||||
use script::dom::characterdata::LayoutCharacterDataHelpers;
|
||||
use script::dom::document::{Document, LayoutDocumentHelpers};
|
||||
use script::dom::element;
|
||||
use script::dom::element::{Element, LayoutElementHelpers, RawLayoutElementHelpers};
|
||||
use script::dom::htmlcanvaselement::{LayoutHTMLCanvasElementHelpers, HTMLCanvasData};
|
||||
|
@ -105,6 +106,12 @@ impl<'ln> LayoutNode<'ln> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn is_element(&self) -> bool {
|
||||
unsafe {
|
||||
self.node.is_element_for_layout()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn dump(self) {
|
||||
self.dump_indent(0);
|
||||
}
|
||||
|
@ -336,6 +343,30 @@ impl<'a> Iterator for LayoutTreeIterator<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
// A wrapper around documents that ensures ayout can only ever access safe properties.
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct LayoutDocument<'le> {
|
||||
document: LayoutJS<Document>,
|
||||
chain: PhantomData<&'le ()>,
|
||||
}
|
||||
|
||||
impl<'le> LayoutDocument<'le> {
|
||||
pub fn as_node(&self) -> LayoutNode<'le> {
|
||||
LayoutNode {
|
||||
node: self.document.upcast(),
|
||||
chain: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn root_node(&self) -> Option<LayoutNode<'le>> {
|
||||
let mut node = self.as_node().first_child();
|
||||
while node.is_some() && !node.unwrap().is_element() {
|
||||
node = node.unwrap().next_sibling();
|
||||
}
|
||||
node
|
||||
}
|
||||
}
|
||||
|
||||
/// A wrapper around elements that ensures layout can only ever access safe properties.
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct LayoutElement<'le> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue