mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
layout: Stop exposing raw Element
types to layout as well.
This should make layout memory-safe as is, though we will need to do more stuff for incremental reflow and parallelism.
This commit is contained in:
parent
9e2b63ddd3
commit
8f886e599e
7 changed files with 59 additions and 39 deletions
|
@ -29,7 +29,6 @@ use std::cast;
|
|||
use std::hashmap::HashMap;
|
||||
use std::str::eq_slice;
|
||||
use std::unstable::raw::Box;
|
||||
use style::{TElement, TNode};
|
||||
|
||||
#[deriving(Eq)]
|
||||
pub enum DocumentTypeId {
|
||||
|
|
|
@ -20,7 +20,6 @@ use dom::namespace::Namespace;
|
|||
use layout_interface::{ContentBoxQuery, ContentBoxResponse, ContentBoxesQuery};
|
||||
use layout_interface::{ContentBoxesResponse, ContentChangedDocumentDamage};
|
||||
use layout_interface::{MatchSelectorsDocumentDamage};
|
||||
use style::{TElement, TNode};
|
||||
use style;
|
||||
|
||||
use std::comm;
|
||||
|
@ -125,31 +124,6 @@ pub enum ElementTypeId {
|
|||
// Element methods
|
||||
//
|
||||
|
||||
impl TElement for Element {
|
||||
fn get_local_name<'a>(&'a self) -> &'a str {
|
||||
self.tag_name.as_slice()
|
||||
}
|
||||
|
||||
fn get_namespace_url<'a>(&'a self) -> &'a str {
|
||||
self.namespace.to_str().unwrap_or("")
|
||||
}
|
||||
|
||||
fn get_attr(&self, ns_url: Option<~str>, name: &str) -> Option<~str> {
|
||||
self.get_attribute(ns_url, name).map(|attr| attr.value.clone())
|
||||
}
|
||||
|
||||
fn get_link(&self) -> Option<~str>{
|
||||
// FIXME: This is HTML only.
|
||||
match self.node.type_id {
|
||||
// http://www.whatwg.org/specs/web-apps/current-work/multipage/selectors.html#selector-link
|
||||
ElementNodeTypeId(HTMLAnchorElementTypeId) |
|
||||
ElementNodeTypeId(HTMLAreaElementTypeId) |
|
||||
ElementNodeTypeId(HTMLLinkElementTypeId)
|
||||
=> self.get_attr(None, "href"),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'self> Element {
|
||||
pub fn new_inherited(type_id: ElementTypeId, tag_name: ~str, namespace: Namespace, document: AbstractDocument) -> Element {
|
||||
|
@ -187,6 +161,11 @@ impl<'self> Element {
|
|||
})
|
||||
}
|
||||
|
||||
// FIXME(pcwalton): This is kind of confusingly named relative to the above...
|
||||
pub fn get_attr(&self, ns_url: Option<~str>, name: &str) -> Option<~str> {
|
||||
self.get_attribute(ns_url, name).map(|attr| attr.value.clone())
|
||||
}
|
||||
|
||||
pub fn set_attr(&mut self, abstract_self: AbstractNode, name: DOMString, value: DOMString)
|
||||
-> ErrorResult {
|
||||
self.set_attribute(abstract_self, namespace::Null, name, value)
|
||||
|
|
|
@ -25,7 +25,6 @@ use std::cast::transmute;
|
|||
use std::cast;
|
||||
use std::unstable::raw::Box;
|
||||
use std::util;
|
||||
use style::TNode;
|
||||
|
||||
//
|
||||
// The basic Node structure
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue