Remove unused code from gfx and layout crates

This commit is contained in:
est31 2019-05-29 21:16:11 +02:00
parent 8dc7a25893
commit 3efc5e59bc
9 changed files with 2 additions and 222 deletions

View file

@ -105,8 +105,6 @@ fn is_simple_advance(advance: Au) -> bool {
} }
} }
pub type DetailedGlyphCount = u16;
// Getters and setters for GlyphEntry. Setter methods are functional, // Getters and setters for GlyphEntry. Setter methods are functional,
// because GlyphEntry is immutable and only a u32 in size. // because GlyphEntry is immutable and only a u32 in size.
impl GlyphEntry { impl GlyphEntry {

View file

@ -280,10 +280,6 @@ impl<'a> TextRun {
self.font_metrics.ascent self.font_metrics.ascent
} }
pub fn descent(&self) -> Au {
self.font_metrics.descent
}
pub fn advance_for_range(&self, range: &Range<ByteIndex>) -> Au { pub fn advance_for_range(&self, range: &Range<ByteIndex>) -> Au {
if range.is_empty() { if range.is_empty() {
return Au(0); return Au(0);

View file

@ -27,7 +27,7 @@ use webrender_api as wr;
use webrender_api::{BorderRadius, ClipMode}; use webrender_api::{BorderRadius, ClipMode};
use webrender_api::{ComplexClipRegion, ExternalScrollId, FilterOp}; use webrender_api::{ComplexClipRegion, ExternalScrollId, FilterOp};
use webrender_api::{GlyphInstance, GradientStop, ImageKey, LayoutPoint}; use webrender_api::{GlyphInstance, GradientStop, ImageKey, LayoutPoint};
use webrender_api::{LayoutRect, LayoutSize, LayoutTransform, LayoutVector2D}; use webrender_api::{LayoutRect, LayoutSize, LayoutTransform};
use webrender_api::{MixBlendMode, ScrollSensitivity, Shadow}; use webrender_api::{MixBlendMode, ScrollSensitivity, Shadow};
use webrender_api::{StickyOffsetBounds, TransformStyle}; use webrender_api::{StickyOffsetBounds, TransformStyle};
@ -510,62 +510,6 @@ impl ClippingRegion {
} }
} }
/// Mutates this clipping region to intersect with the given rectangle.
///
/// TODO(pcwalton): This could more eagerly eliminate complex clipping regions, at the cost of
/// complexity.
#[inline]
pub fn intersect_rect(&mut self, rect: &LayoutRect) {
self.main = self.main.intersection(rect).unwrap_or(LayoutRect::zero())
}
/// Returns true if this clipping region might be nonempty. This can return false positives,
/// but never false negatives.
#[inline]
pub fn might_be_nonempty(&self) -> bool {
!self.main.is_empty()
}
/// Returns true if this clipping region might contain the given point and false otherwise.
/// This is a quick, not a precise, test; it can yield false positives.
#[inline]
pub fn might_intersect_point(&self, point: &LayoutPoint) -> bool {
self.main.contains(point) &&
self.complex
.iter()
.all(|complex| complex.rect.contains(point))
}
/// Returns true if this clipping region might intersect the given rectangle and false
/// otherwise. This is a quick, not a precise, test; it can yield false positives.
#[inline]
pub fn might_intersect_rect(&self, rect: &LayoutRect) -> bool {
self.main.intersects(rect) &&
self.complex
.iter()
.all(|complex| complex.rect.intersects(rect))
}
/// Returns true if this clipping region completely surrounds the given rect.
#[inline]
pub fn does_not_clip_rect(&self, rect: &LayoutRect) -> bool {
self.main.contains(&rect.origin) &&
self.main.contains(&rect.bottom_right()) &&
self.complex.iter().all(|complex| {
complex.rect.contains(&rect.origin) && complex.rect.contains(&rect.bottom_right())
})
}
/// Returns a bounding rect that surrounds this entire clipping region.
#[inline]
pub fn bounding_rect(&self) -> LayoutRect {
let mut rect = self.main;
for complex in &*self.complex {
rect = rect.union(&complex.rect)
}
rect
}
/// Intersects this clipping region with the given rounded rectangle. /// Intersects this clipping region with the given rounded rectangle.
#[inline] #[inline]
pub fn intersect_with_rounded_rect(&mut self, rect: LayoutRect, radii: BorderRadius) { pub fn intersect_with_rounded_rect(&mut self, rect: LayoutRect, radii: BorderRadius) {
@ -593,28 +537,6 @@ impl ClippingRegion {
self.complex.push(new_complex_region); self.complex.push(new_complex_region);
} }
/// Translates this clipping region by the given vector.
#[inline]
pub fn translate(&self, delta: &LayoutVector2D) -> ClippingRegion {
ClippingRegion {
main: self.main.translate(delta),
complex: self
.complex
.iter()
.map(|complex| ComplexClipRegion {
rect: complex.rect.translate(delta),
radii: complex.radii,
mode: complex.mode,
})
.collect(),
}
}
#[inline]
pub fn is_max(&self) -> bool {
self.main == LayoutRect::max_rect() && self.complex.is_empty()
}
} }
impl fmt::Debug for ClippingRegion { impl fmt::Debug for ClippingRegion {
@ -776,10 +698,6 @@ impl DisplayItem {
} }
} }
pub fn scroll_node_index(&self) -> ClipScrollNodeIndex {
self.base().clipping_and_scrolling.scrolling
}
pub fn clipping_and_scrolling(&self) -> ClippingAndScrolling { pub fn clipping_and_scrolling(&self) -> ClippingAndScrolling {
self.base().clipping_and_scrolling self.base().clipping_and_scrolling
} }
@ -795,14 +713,6 @@ impl DisplayItem {
pub fn bounds(&self) -> LayoutRect { pub fn bounds(&self) -> LayoutRect {
self.base().bounds self.base().bounds
} }
pub fn debug_with_level(&self, level: u32) {
let mut indent = String::new();
for _ in 0..level {
indent.push_str("| ")
}
println!("{}+ {:?}", indent, self);
}
} }
impl fmt::Debug for DisplayItem { impl fmt::Debug for DisplayItem {

View file

@ -870,10 +870,6 @@ impl Flow for FlexFlow {
FlowClass::Flex FlowClass::Flex
} }
fn as_mut_flex(&mut self) -> &mut FlexFlow {
self
}
fn as_flex(&self) -> &FlexFlow { fn as_flex(&self) -> &FlexFlow {
self self
} }

View file

@ -35,11 +35,9 @@ use crate::flow_list::{FlowList, FlowListIterator, MutFlowListIterator};
use crate::flow_ref::{FlowRef, WeakFlowRef}; use crate::flow_ref::{FlowRef, WeakFlowRef};
use crate::fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, Overflow}; use crate::fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, Overflow};
use crate::inline::InlineFlow; use crate::inline::InlineFlow;
use crate::model::{CollapsibleMargins, IntrinsicISizes, MarginCollapseInfo}; use crate::model::{CollapsibleMargins, IntrinsicISizes};
use crate::multicol::MulticolFlow;
use crate::parallel::FlowParallelInfo; use crate::parallel::FlowParallelInfo;
use crate::table::TableFlow; use crate::table::TableFlow;
use crate::table_caption::TableCaptionFlow;
use crate::table_cell::TableCellFlow; use crate::table_cell::TableCellFlow;
use crate::table_colgroup::TableColGroupFlow; use crate::table_colgroup::TableColGroupFlow;
use crate::table_row::TableRowFlow; use crate::table_row::TableRowFlow;
@ -146,12 +144,6 @@ pub trait Flow: HasBaseFlow + fmt::Debug + Sync + Send + 'static {
panic!("called as_mut_inline() on a non-inline flow") panic!("called as_mut_inline() on a non-inline flow")
} }
/// If this is a table wrapper flow, returns the underlying object, borrowed mutably. Fails
/// otherwise.
fn as_mut_table_wrapper(&mut self) -> &mut TableWrapperFlow {
panic!("called as_mut_table_wrapper() on a non-tablewrapper flow")
}
/// If this is a table wrapper flow, returns the underlying object. Fails otherwise. /// If this is a table wrapper flow, returns the underlying object. Fails otherwise.
fn as_table_wrapper(&self) -> &TableWrapperFlow { fn as_table_wrapper(&self) -> &TableWrapperFlow {
panic!("called as_table_wrapper() on a non-tablewrapper flow") panic!("called as_table_wrapper() on a non-tablewrapper flow")
@ -201,24 +193,12 @@ pub trait Flow: HasBaseFlow + fmt::Debug + Sync + Send + 'static {
panic!("called as_table_row() on a non-tablerow flow") panic!("called as_table_row() on a non-tablerow flow")
} }
/// If this is a table cell flow, returns the underlying object, borrowed mutably. Fails
/// otherwise.
fn as_mut_table_caption(&mut self) -> &mut TableCaptionFlow {
panic!("called as_mut_table_caption() on a non-tablecaption flow")
}
/// If this is a table cell flow, returns the underlying object, borrowed mutably. Fails /// If this is a table cell flow, returns the underlying object, borrowed mutably. Fails
/// otherwise. /// otherwise.
fn as_mut_table_cell(&mut self) -> &mut TableCellFlow { fn as_mut_table_cell(&mut self) -> &mut TableCellFlow {
panic!("called as_mut_table_cell() on a non-tablecell flow") panic!("called as_mut_table_cell() on a non-tablecell flow")
} }
/// If this is a multicol flow, returns the underlying object, borrowed mutably. Fails
/// otherwise.
fn as_mut_multicol(&mut self) -> &mut MulticolFlow {
panic!("called as_mut_multicol() on a non-multicol flow")
}
/// If this is a table cell flow, returns the underlying object. Fails otherwise. /// If this is a table cell flow, returns the underlying object. Fails otherwise.
fn as_table_cell(&self) -> &TableCellFlow { fn as_table_cell(&self) -> &TableCellFlow {
panic!("called as_table_cell() on a non-tablecell flow") panic!("called as_table_cell() on a non-tablecell flow")
@ -432,14 +412,6 @@ pub trait Flow: HasBaseFlow + fmt::Debug + Sync + Send + 'static {
/// Mutably iterates through fragments in this flow. /// Mutably iterates through fragments in this flow.
fn mutate_fragments(&mut self, mutator: &mut dyn FnMut(&mut Fragment)); fn mutate_fragments(&mut self, mutator: &mut dyn FnMut(&mut Fragment));
fn compute_collapsible_block_start_margin(
&mut self,
_layout_context: &mut LayoutContext,
_margin_collapse_info: &mut MarginCollapseInfo,
) {
// The default implementation is a no-op.
}
/// Marks this flow as the root flow. The default implementation is a no-op. /// Marks this flow as the root flow. The default implementation is a no-op.
fn mark_as_root(&mut self) { fn mark_as_root(&mut self) {
debug!("called mark_as_root() on a flow of type {:?}", self.class()); debug!("called mark_as_root() on a flow of type {:?}", self.class());
@ -530,9 +502,6 @@ pub trait ImmutableFlowUtils {
/// Returns true if this flow is a table caption flow. /// Returns true if this flow is a table caption flow.
fn is_table_caption(self) -> bool; fn is_table_caption(self) -> bool;
/// Returns true if this flow is a proper table child.
fn is_proper_table_child(self) -> bool;
/// Returns true if this flow is a table row flow. /// Returns true if this flow is a table row flow.
fn is_table_row(self) -> bool; fn is_table_row(self) -> bool;
@ -545,18 +514,9 @@ pub trait ImmutableFlowUtils {
/// Returns true if this flow is a table rowgroup flow. /// Returns true if this flow is a table rowgroup flow.
fn is_table_rowgroup(self) -> bool; fn is_table_rowgroup(self) -> bool;
/// Returns true if this flow is one of table-related flows.
fn is_table_kind(self) -> bool;
/// Returns true if this flow has no children.
fn is_leaf(self) -> bool;
/// Returns the number of children that this flow possesses. /// Returns the number of children that this flow possesses.
fn child_count(self) -> usize; fn child_count(self) -> usize;
/// Return true if this flow is a Block Container.
fn is_block_container(self) -> bool;
/// Returns true if this flow is a block flow. /// Returns true if this flow is a block flow.
fn is_block_flow(self) -> bool; fn is_block_flow(self) -> bool;
@ -1205,10 +1165,6 @@ impl BaseFlow {
p as usize p as usize
} }
pub fn flow_id(&self) -> usize {
return self as *const BaseFlow as usize;
}
pub fn collect_stacking_contexts_for_children( pub fn collect_stacking_contexts_for_children(
&mut self, &mut self,
state: &mut StackingContextCollectionState, state: &mut StackingContextCollectionState,
@ -1252,19 +1208,6 @@ impl<'a> ImmutableFlowUtils for &'a dyn Flow {
self.class().is_block_like() self.class().is_block_like()
} }
/// Returns true if this flow is a proper table child.
/// 'Proper table child' is defined as table-row flow, table-rowgroup flow,
/// table-column-group flow, or table-caption flow.
fn is_proper_table_child(self) -> bool {
match self.class() {
FlowClass::TableRow |
FlowClass::TableRowGroup |
FlowClass::TableColGroup |
FlowClass::TableCaption => true,
_ => false,
}
}
/// Returns true if this flow is a table row flow. /// Returns true if this flow is a table row flow.
fn is_table_row(self) -> bool { fn is_table_row(self) -> bool {
match self.class() { match self.class() {
@ -1313,47 +1256,11 @@ impl<'a> ImmutableFlowUtils for &'a dyn Flow {
} }
} }
/// Returns true if this flow is one of table-related flows.
fn is_table_kind(self) -> bool {
match self.class() {
FlowClass::TableWrapper |
FlowClass::Table |
FlowClass::TableColGroup |
FlowClass::TableRowGroup |
FlowClass::TableRow |
FlowClass::TableCaption |
FlowClass::TableCell => true,
_ => false,
}
}
/// Returns true if this flow has no children.
fn is_leaf(self) -> bool {
self.base().children.is_empty()
}
/// Returns the number of children that this flow possesses. /// Returns the number of children that this flow possesses.
fn child_count(self) -> usize { fn child_count(self) -> usize {
self.base().children.len() self.base().children.len()
} }
/// Return true if this flow is a Block Container.
///
/// Except for table fragments and replaced elements, block-level fragments (`BlockFlow`) are
/// also block container fragments.
/// Non-replaced inline blocks and non-replaced table cells are also block
/// containers.
fn is_block_container(self) -> bool {
match self.class() {
// TODO: Change this when inline-blocks are supported.
FlowClass::Block | FlowClass::TableCaption | FlowClass::TableCell => {
// FIXME: Actually check the type of the node
self.child_count() != 0
},
_ => false,
}
}
/// Returns true if this flow is a block flow. /// Returns true if this flow is a block flow.
fn is_block_flow(self) -> bool { fn is_block_flow(self) -> bool {
match self.class() { match self.class() {

View file

@ -73,17 +73,6 @@ impl FlowList {
self.flows.push_back(FlowRef::new(new_head)); self.flows.push_back(FlowRef::new(new_head));
} }
pub fn back(&self) -> Option<&dyn Flow> {
self.flows.back().map(|x| &**x)
}
/// Add an element first in the list
///
/// O(1)
pub fn push_front(&mut self, new_head: FlowRef) {
self.flows.push_front(new_head);
}
pub fn push_front_arc(&mut self, new_head: Arc<dyn Flow>) { pub fn push_front_arc(&mut self, new_head: Arc<dyn Flow>) {
self.flows.push_front(FlowRef::new(new_head)); self.flows.push_front(FlowRef::new(new_head));
} }
@ -92,10 +81,6 @@ impl FlowList {
self.flows.pop_front().map(FlowRef::into_arc) self.flows.pop_front().map(FlowRef::into_arc)
} }
pub fn front(&self) -> Option<&dyn Flow> {
self.flows.front().map(|x| &**x)
}
/// Create an empty list /// Create an empty list
#[inline] #[inline]
pub fn new() -> FlowList { pub fn new() -> FlowList {

View file

@ -74,10 +74,6 @@ impl Flow for MulticolFlow {
&self.block_flow &self.block_flow
} }
fn as_mut_multicol(&mut self) -> &mut MulticolFlow {
self
}
fn bubble_inline_sizes(&mut self) { fn bubble_inline_sizes(&mut self) {
// FIXME(SimonSapin) http://dev.w3.org/csswg/css-sizing/#multicol-intrinsic // FIXME(SimonSapin) http://dev.w3.org/csswg/css-sizing/#multicol-intrinsic
self.block_flow.bubble_inline_sizes(); self.block_flow.bubble_inline_sizes();

View file

@ -40,10 +40,6 @@ impl Flow for TableCaptionFlow {
FlowClass::TableCaption FlowClass::TableCaption
} }
fn as_mut_table_caption(&mut self) -> &mut TableCaptionFlow {
self
}
fn as_mut_block(&mut self) -> &mut BlockFlow { fn as_mut_block(&mut self) -> &mut BlockFlow {
&mut self.block_flow &mut self.block_flow
} }

View file

@ -333,10 +333,6 @@ impl Flow for TableWrapperFlow {
FlowClass::TableWrapper FlowClass::TableWrapper
} }
fn as_mut_table_wrapper(&mut self) -> &mut TableWrapperFlow {
self
}
fn as_table_wrapper(&self) -> &TableWrapperFlow { fn as_table_wrapper(&self) -> &TableWrapperFlow {
self self
} }