mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Remove some unused methods
Simply use `Fragment::is_replaced()` in block, and remove `content_inline_size()` method from Fragment.
This commit is contained in:
parent
07250a7d58
commit
b1b17f1869
2 changed files with 10 additions and 81 deletions
|
@ -42,7 +42,6 @@ use flow::IS_ABSOLUTELY_POSITIONED;
|
||||||
use flow_list::FlowList;
|
use flow_list::FlowList;
|
||||||
use fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, Overflow};
|
use fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, Overflow};
|
||||||
use fragment::{IS_INLINE_FLEX_ITEM, IS_BLOCK_FLEX_ITEM};
|
use fragment::{IS_INLINE_FLEX_ITEM, IS_BLOCK_FLEX_ITEM};
|
||||||
use fragment::SpecificFragmentInfo;
|
|
||||||
use gfx::display_list::{ClippingRegion, StackingContext};
|
use gfx::display_list::{ClippingRegion, StackingContext};
|
||||||
use gfx_traits::ScrollRootId;
|
use gfx_traits::ScrollRootId;
|
||||||
use gfx_traits::print_tree::PrintTree;
|
use gfx_traits::print_tree::PrintTree;
|
||||||
|
@ -555,7 +554,7 @@ impl BlockFlow {
|
||||||
/// relevant margins for this Block.
|
/// relevant margins for this Block.
|
||||||
pub fn block_type(&self) -> BlockType {
|
pub fn block_type(&self) -> BlockType {
|
||||||
if self.base.flags.contains(IS_ABSOLUTELY_POSITIONED) {
|
if self.base.flags.contains(IS_ABSOLUTELY_POSITIONED) {
|
||||||
if self.is_replaced_content() {
|
if self.fragment.is_replaced() {
|
||||||
BlockType::AbsoluteReplaced
|
BlockType::AbsoluteReplaced
|
||||||
} else {
|
} else {
|
||||||
BlockType::AbsoluteNonReplaced
|
BlockType::AbsoluteNonReplaced
|
||||||
|
@ -563,19 +562,19 @@ impl BlockFlow {
|
||||||
} else if self.is_inline_flex_item() {
|
} else if self.is_inline_flex_item() {
|
||||||
BlockType::InlineFlexItem
|
BlockType::InlineFlexItem
|
||||||
} else if self.base.flags.is_float() {
|
} else if self.base.flags.is_float() {
|
||||||
if self.is_replaced_content() {
|
if self.fragment.is_replaced() {
|
||||||
BlockType::FloatReplaced
|
BlockType::FloatReplaced
|
||||||
} else {
|
} else {
|
||||||
BlockType::FloatNonReplaced
|
BlockType::FloatNonReplaced
|
||||||
}
|
}
|
||||||
} else if self.is_inline_block() {
|
} else if self.is_inline_block() {
|
||||||
if self.is_replaced_content() {
|
if self.fragment.is_replaced() {
|
||||||
BlockType::InlineBlockReplaced
|
BlockType::InlineBlockReplaced
|
||||||
} else {
|
} else {
|
||||||
BlockType::InlineBlockNonReplaced
|
BlockType::InlineBlockNonReplaced
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if self.is_replaced_content() {
|
if self.fragment.is_replaced() {
|
||||||
BlockType::Replaced
|
BlockType::Replaced
|
||||||
} else {
|
} else {
|
||||||
BlockType::NonReplaced
|
BlockType::NonReplaced
|
||||||
|
@ -668,22 +667,6 @@ impl BlockFlow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return true if this has a replaced fragment.
|
|
||||||
///
|
|
||||||
/// Text, Images, Inline Block and Canvas
|
|
||||||
/// (https://html.spec.whatwg.org/multipage/#replaced-elements) fragments are considered as
|
|
||||||
/// replaced fragments.
|
|
||||||
fn is_replaced_content(&self) -> bool {
|
|
||||||
match self.fragment.specific {
|
|
||||||
SpecificFragmentInfo::ScannedText(_) |
|
|
||||||
SpecificFragmentInfo::Svg(_) |
|
|
||||||
SpecificFragmentInfo::Image(_) |
|
|
||||||
SpecificFragmentInfo::Canvas(_) |
|
|
||||||
SpecificFragmentInfo::InlineBlock(_) => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Return shrink-to-fit inline-size.
|
/// Return shrink-to-fit inline-size.
|
||||||
///
|
///
|
||||||
/// This is where we use the preferred inline-sizes and minimum inline-sizes
|
/// This is where we use the preferred inline-sizes and minimum inline-sizes
|
||||||
|
@ -1267,7 +1250,7 @@ impl BlockFlow {
|
||||||
|
|
||||||
let available_block_size = containing_block_block_size -
|
let available_block_size = containing_block_block_size -
|
||||||
self.fragment.border_padding.block_start_end();
|
self.fragment.border_padding.block_start_end();
|
||||||
if self.is_replaced_content() {
|
if self.fragment.is_replaced() {
|
||||||
// Calculate used value of block-size just like we do for inline replaced elements.
|
// Calculate used value of block-size just like we do for inline replaced elements.
|
||||||
// TODO: Pass in the containing block block-size when Fragment's
|
// TODO: Pass in the containing block block-size when Fragment's
|
||||||
// assign-block-size can handle it correctly.
|
// assign-block-size can handle it correctly.
|
||||||
|
@ -1896,7 +1879,7 @@ impl Flow for BlockFlow {
|
||||||
fn fragment(&mut self, layout_context: &LayoutContext,
|
fn fragment(&mut self, layout_context: &LayoutContext,
|
||||||
fragmentation_context: Option<FragmentationContext>)
|
fragmentation_context: Option<FragmentationContext>)
|
||||||
-> Option<Arc<Flow>> {
|
-> Option<Arc<Flow>> {
|
||||||
if self.is_replaced_content() {
|
if self.fragment.is_replaced() {
|
||||||
let _scope = layout_debug_scope!("assign_replaced_block_size_if_necessary {:x}",
|
let _scope = layout_debug_scope!("assign_replaced_block_size_if_necessary {:x}",
|
||||||
self.base.debug_id());
|
self.base.debug_id());
|
||||||
|
|
||||||
|
@ -2868,7 +2851,7 @@ impl ISizeAndMarginsComputer for AbsoluteReplaced {
|
||||||
fragment.assign_replaced_inline_size_if_necessary(containing_block_inline_size, container_block_size);
|
fragment.assign_replaced_inline_size_if_necessary(containing_block_inline_size, container_block_size);
|
||||||
// For replaced absolute flow, the rest of the constraint solving will
|
// For replaced absolute flow, the rest of the constraint solving will
|
||||||
// take inline-size to be specified as the value computed here.
|
// take inline-size to be specified as the value computed here.
|
||||||
MaybeAuto::Specified(fragment.content_inline_size())
|
MaybeAuto::Specified(fragment.content_box().size.inline)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn containing_block_inline_size(&self,
|
fn containing_block_inline_size(&self,
|
||||||
|
@ -2927,7 +2910,7 @@ impl ISizeAndMarginsComputer for BlockReplaced {
|
||||||
fragment.assign_replaced_inline_size_if_necessary(parent_flow_inline_size, container_block_size);
|
fragment.assign_replaced_inline_size_if_necessary(parent_flow_inline_size, container_block_size);
|
||||||
// For replaced block flow, the rest of the constraint solving will
|
// For replaced block flow, the rest of the constraint solving will
|
||||||
// take inline-size to be specified as the value computed here.
|
// take inline-size to be specified as the value computed here.
|
||||||
MaybeAuto::Specified(fragment.content_inline_size())
|
MaybeAuto::Specified(fragment.content_box().size.inline)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2985,7 +2968,7 @@ impl ISizeAndMarginsComputer for FloatReplaced {
|
||||||
fragment.assign_replaced_inline_size_if_necessary(parent_flow_inline_size, container_block_size);
|
fragment.assign_replaced_inline_size_if_necessary(parent_flow_inline_size, container_block_size);
|
||||||
// For replaced block flow, the rest of the constraint solving will
|
// For replaced block flow, the rest of the constraint solving will
|
||||||
// take inline-size to be specified as the value computed here.
|
// take inline-size to be specified as the value computed here.
|
||||||
MaybeAuto::Specified(fragment.content_inline_size())
|
MaybeAuto::Specified(fragment.content_box().size.inline)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3073,7 +3056,7 @@ impl ISizeAndMarginsComputer for InlineBlockReplaced {
|
||||||
fragment.assign_replaced_inline_size_if_necessary(parent_flow_inline_size, container_block_size);
|
fragment.assign_replaced_inline_size_if_necessary(parent_flow_inline_size, container_block_size);
|
||||||
// For replaced block flow, the rest of the constraint solving will
|
// For replaced block flow, the rest of the constraint solving will
|
||||||
// take inline-size to be specified as the value computed here.
|
// take inline-size to be specified as the value computed here.
|
||||||
MaybeAuto::Specified(fragment.content_inline_size())
|
MaybeAuto::Specified(fragment.content_box().size.inline)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -250,21 +250,6 @@ impl fmt::Debug for SpecificFragmentInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Clamp a value obtained from style_length, based on min / max lengths.
|
|
||||||
fn clamp_size(size: Au,
|
|
||||||
min_size: LengthOrPercentage,
|
|
||||||
max_size: LengthOrPercentageOrNone,
|
|
||||||
container_size: Au)
|
|
||||||
-> Au {
|
|
||||||
let min_size = model::specified(min_size, container_size);
|
|
||||||
let max_size = model::specified_or_none(max_size, container_size);
|
|
||||||
|
|
||||||
max(min_size, match max_size {
|
|
||||||
None => size,
|
|
||||||
Some(max_size) => min(size, max_size),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Information for generated content.
|
/// Information for generated content.
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub enum GeneratedContentInfo {
|
pub enum GeneratedContentInfo {
|
||||||
|
@ -1580,45 +1565,6 @@ impl Fragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// TODO: What exactly does this function return? Why is it Au(0) for
|
|
||||||
/// `SpecificFragmentInfo::Generic`?
|
|
||||||
pub fn content_inline_size(&self) -> Au {
|
|
||||||
match self.specific {
|
|
||||||
SpecificFragmentInfo::Generic |
|
|
||||||
SpecificFragmentInfo::GeneratedContent(_) |
|
|
||||||
SpecificFragmentInfo::Iframe(_) |
|
|
||||||
SpecificFragmentInfo::Table |
|
|
||||||
SpecificFragmentInfo::TableCell |
|
|
||||||
SpecificFragmentInfo::TableRow |
|
|
||||||
SpecificFragmentInfo::TableWrapper |
|
|
||||||
SpecificFragmentInfo::Multicol |
|
|
||||||
SpecificFragmentInfo::MulticolColumn |
|
|
||||||
SpecificFragmentInfo::InlineBlock(_) |
|
|
||||||
SpecificFragmentInfo::InlineAbsoluteHypothetical(_) |
|
|
||||||
SpecificFragmentInfo::InlineAbsolute(_) => Au(0),
|
|
||||||
SpecificFragmentInfo::Canvas(ref canvas_fragment_info) => {
|
|
||||||
canvas_fragment_info.replaced_image_fragment_info.computed_inline_size()
|
|
||||||
}
|
|
||||||
SpecificFragmentInfo::Svg(ref svg_fragment_info) => {
|
|
||||||
svg_fragment_info.replaced_image_fragment_info.computed_inline_size()
|
|
||||||
}
|
|
||||||
SpecificFragmentInfo::Image(ref image_fragment_info) => {
|
|
||||||
image_fragment_info.replaced_image_fragment_info.computed_inline_size()
|
|
||||||
}
|
|
||||||
SpecificFragmentInfo::ScannedText(ref text_fragment_info) => {
|
|
||||||
let (range, run) = (&text_fragment_info.range, &text_fragment_info.run);
|
|
||||||
let text_bounds = run.metrics_for_range(range).bounding_box;
|
|
||||||
text_bounds.size.width
|
|
||||||
}
|
|
||||||
SpecificFragmentInfo::TableColumn(_) => {
|
|
||||||
panic!("Table column fragments do not have inline_size")
|
|
||||||
}
|
|
||||||
SpecificFragmentInfo::UnscannedText(_) => {
|
|
||||||
panic!("Unscanned text fragments should have been scanned by now!")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the dimensions of the content box.
|
/// Returns the dimensions of the content box.
|
||||||
///
|
///
|
||||||
/// This is marked `#[inline]` because it is frequently called when only one or two of the
|
/// This is marked `#[inline]` because it is frequently called when only one or two of the
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue