mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Make NodeTypeId include CharacterData variant
NodeTypeId is supposed to reflect the WebIDL inheritance hierarchy. All of Text/ProcessingInstruction/Comment inherit from CharacterData, which inherits from Node. There should be a CharacterDataTypeId value that differentiates between those, instead.
This commit is contained in:
parent
1e150140bd
commit
f404853c99
9 changed files with 67 additions and 78 deletions
|
@ -47,6 +47,7 @@ use text::TextRunScanner;
|
|||
use wrapper::{PostorderNodeMutTraversal, PseudoElementType, TLayoutNode, ThreadSafeLayoutNode};
|
||||
|
||||
use gfx::display_list::OpaqueNode;
|
||||
use script::dom::characterdata::CharacterDataTypeId;
|
||||
use script::dom::element::ElementTypeId;
|
||||
use script::dom::htmlelement::HTMLElementTypeId;
|
||||
use script::dom::htmlobjectelement::is_image_data;
|
||||
|
@ -789,7 +790,7 @@ impl<'a> FlowConstructor<'a> {
|
|||
// fragment that needs to be generated for this inline node.
|
||||
let mut fragments = LinkedList::new();
|
||||
match (node.get_pseudo_element_type(), node.type_id()) {
|
||||
(_, Some(NodeTypeId::Text)) => {
|
||||
(_, Some(NodeTypeId::CharacterData(CharacterDataTypeId::Text))) => {
|
||||
self.create_fragments_for_node_text_content(&mut fragments, node, &style)
|
||||
}
|
||||
(PseudoElementType::Normal, _) => {
|
||||
|
@ -1239,12 +1240,12 @@ impl<'a> PostorderNodeMutTraversal for FlowConstructor<'a> {
|
|||
};
|
||||
(munged_display, style.get_box().float, style.get_box().position)
|
||||
}
|
||||
Some(NodeTypeId::Text) => (display::T::inline, float::T::none, position::T::static_),
|
||||
Some(NodeTypeId::Comment) |
|
||||
Some(NodeTypeId::CharacterData(CharacterDataTypeId::Text)) => (display::T::inline, float::T::none, position::T::static_),
|
||||
Some(NodeTypeId::CharacterData(CharacterDataTypeId::Comment)) |
|
||||
Some(NodeTypeId::CharacterData(CharacterDataTypeId::ProcessingInstruction)) |
|
||||
Some(NodeTypeId::DocumentType) |
|
||||
Some(NodeTypeId::DocumentFragment) |
|
||||
Some(NodeTypeId::Document) |
|
||||
Some(NodeTypeId::ProcessingInstruction) => {
|
||||
Some(NodeTypeId::Document) => {
|
||||
(display::T::none, float::T::none, position::T::static_)
|
||||
}
|
||||
};
|
||||
|
@ -1382,9 +1383,7 @@ impl<'ln> NodeUtils for ThreadSafeLayoutNode<'ln> {
|
|||
fn is_replaced_content(&self) -> bool {
|
||||
match self.type_id() {
|
||||
None |
|
||||
Some(NodeTypeId::Text) |
|
||||
Some(NodeTypeId::ProcessingInstruction) |
|
||||
Some(NodeTypeId::Comment) |
|
||||
Some(NodeTypeId::CharacterData(_)) |
|
||||
Some(NodeTypeId::DocumentType) |
|
||||
Some(NodeTypeId::DocumentFragment) |
|
||||
Some(NodeTypeId::Document) |
|
||||
|
|
|
@ -14,6 +14,7 @@ use incremental::{self, RestyleDamage};
|
|||
use opaque_node::OpaqueNodeMethods;
|
||||
use wrapper::{LayoutElement, LayoutNode, TLayoutNode};
|
||||
|
||||
use script::dom::characterdata::CharacterDataTypeId;
|
||||
use script::dom::node::NodeTypeId;
|
||||
use script::layout_interface::Animation;
|
||||
use selectors::bloom::BloomFilter;
|
||||
|
@ -676,7 +677,7 @@ impl<'ln> MatchMethods for LayoutNode<'ln> {
|
|||
&mut None => panic!("no layout data"),
|
||||
&mut Some(ref mut layout_data) => {
|
||||
match self.type_id() {
|
||||
Some(NodeTypeId::Text) => {
|
||||
Some(NodeTypeId::CharacterData(CharacterDataTypeId::Text)) => {
|
||||
// Text nodes get a copy of the parent style. This ensures
|
||||
// that during fragment construction any non-inherited
|
||||
// CSS properties (such as vertical-align) are correctly
|
||||
|
|
|
@ -45,7 +45,7 @@ use script::dom::bindings::codegen::InheritTypes::{HTMLIFrameElementCast, HTMLCa
|
|||
use script::dom::bindings::codegen::InheritTypes::{HTMLImageElementCast, HTMLInputElementCast};
|
||||
use script::dom::bindings::codegen::InheritTypes::{HTMLTextAreaElementCast, NodeCast, TextCast};
|
||||
use script::dom::bindings::js::LayoutJS;
|
||||
use script::dom::characterdata::LayoutCharacterDataHelpers;
|
||||
use script::dom::characterdata::{CharacterDataTypeId, LayoutCharacterDataHelpers};
|
||||
use script::dom::element::{Element, ElementTypeId};
|
||||
use script::dom::element::{LayoutElementHelpers, RawLayoutElementHelpers};
|
||||
use script::dom::htmlelement::HTMLElementTypeId;
|
||||
|
@ -1048,7 +1048,7 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
|
|||
/// `empty_cells` per CSS 2.1 § 17.6.1.1.
|
||||
pub fn is_content(&self) -> bool {
|
||||
match self.type_id() {
|
||||
Some(NodeTypeId::Element(..)) | Some(NodeTypeId::Text(..)) => true,
|
||||
Some(NodeTypeId::Element(..)) | Some(NodeTypeId::CharacterData(CharacterDataTypeId::Text(..))) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue