layout: Deduplicate Node::fragment_type and FragmentDisplayListBuilding::fragment_type.

This commit is contained in:
Emilio Cobos Álvarez 2018-01-14 21:31:59 +01:00
parent e32d6f6adf
commit bc29a16285
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 12 additions and 15 deletions

View file

@ -45,7 +45,6 @@ use msg::constellation_msg::{BrowsingContextId, PipelineId};
use net_traits::image::base::PixelFormat;
use net_traits::image_cache::UsePlaceholder;
use range::Range;
use script_layout_interface::wrapper_traits::PseudoElementType;
use servo_config::opts;
use servo_geometry::max_rect;
use std::{cmp, f32};
@ -2276,13 +2275,7 @@ impl FragmentDisplayListBuilding for Fragment {
}
fn fragment_type(&self) -> FragmentType {
match self.pseudo {
PseudoElementType::Normal => FragmentType::FragmentBody,
PseudoElementType::Before => FragmentType::BeforePseudoContent,
PseudoElementType::After => FragmentType::AfterPseudoContent,
PseudoElementType::DetailsSummary => FragmentType::FragmentBody,
PseudoElementType::DetailsContent => FragmentType::FragmentBody,
}
self.pseudo.fragment_type()
}
}

View file

@ -37,6 +37,16 @@ pub enum PseudoElementType {
}
impl PseudoElementType {
pub fn fragment_type(&self) -> FragmentType {
match *self {
PseudoElementType::Normal => FragmentType::FragmentBody,
PseudoElementType::Before => FragmentType::BeforePseudoContent,
PseudoElementType::After => FragmentType::AfterPseudoContent,
PseudoElementType::DetailsSummary => FragmentType::FragmentBody,
PseudoElementType::DetailsContent => FragmentType::FragmentBody,
}
}
pub fn is_before(&self) -> bool {
match *self {
PseudoElementType::Before => true,
@ -254,13 +264,7 @@ pub trait ThreadSafeLayoutNode: Clone + Copy + Debug + GetLayoutData + NodeInfo
fn get_rowspan(&self) -> u32;
fn fragment_type(&self) -> FragmentType {
match self.get_pseudo_element_type() {
PseudoElementType::Normal => FragmentType::FragmentBody,
PseudoElementType::Before => FragmentType::BeforePseudoContent,
PseudoElementType::After => FragmentType::AfterPseudoContent,
PseudoElementType::DetailsSummary => FragmentType::FragmentBody,
PseudoElementType::DetailsContent => FragmentType::FragmentBody,
}
self.get_pseudo_element_type().fragment_type()
}
fn generate_scroll_root_id(&self, pipeline_id: PipelineId) -> ClipId {