mirror of
https://github.com/servo/servo.git
synced 2025-07-10 17:03:40 +01:00
Do not replace an ellipsis when reflowing a line
The ellipsis should be replaced, if needed, when the text itself is reflowed.
This commit is contained in:
parent
783829eccc
commit
8a90cda09f
2 changed files with 21 additions and 5 deletions
|
@ -764,14 +764,17 @@ impl Fragment {
|
|||
text_overflow_string: String)
|
||||
-> Fragment {
|
||||
let mut unscanned_ellipsis_fragments = LinkedList::new();
|
||||
unscanned_ellipsis_fragments.push_back(self.transform(
|
||||
let mut ellipsis_fragment = self.transform(
|
||||
self.border_box.size,
|
||||
SpecificFragmentInfo::UnscannedText(
|
||||
box UnscannedTextFragmentInfo::new(text_overflow_string, None))));
|
||||
box UnscannedTextFragmentInfo::new(text_overflow_string, None)));
|
||||
unscanned_ellipsis_fragments.push_back(ellipsis_fragment);
|
||||
let ellipsis_fragments = TextRunScanner::new().scan_for_runs(&mut layout_context.font_context(),
|
||||
unscanned_ellipsis_fragments);
|
||||
debug_assert!(ellipsis_fragments.len() == 1);
|
||||
ellipsis_fragments.fragments.into_iter().next().unwrap()
|
||||
ellipsis_fragment = ellipsis_fragments.fragments.into_iter().next().unwrap();
|
||||
ellipsis_fragment.flags |= IS_ELLIPSIS;
|
||||
ellipsis_fragment
|
||||
}
|
||||
|
||||
pub fn restyle_damage(&self) -> RestyleDamage {
|
||||
|
@ -2997,6 +3000,8 @@ bitflags! {
|
|||
const IS_INLINE_FLEX_ITEM = 0b0000_0001,
|
||||
/// Whether this fragment represents a child in a column flex container.
|
||||
const IS_BLOCK_FLEX_ITEM = 0b0000_0010,
|
||||
/// Whether this fragment represents the generated text from a text-overflow clip.
|
||||
const IS_ELLIPSIS = 0b0000_0100,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ use flow::{CONTAINS_TEXT_OR_REPLACED_FRAGMENTS, EarlyAbsolutePositionInfo, Mutab
|
|||
use flow::OpaqueFlow;
|
||||
use flow_ref::FlowRef;
|
||||
use fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, Overflow};
|
||||
use fragment::IS_ELLIPSIS;
|
||||
use fragment::SpecificFragmentInfo;
|
||||
use gfx::display_list::OpaqueNode;
|
||||
use gfx::font::FontMetrics;
|
||||
|
@ -332,6 +333,16 @@ impl LineBreaker {
|
|||
Some(fragment) => fragment,
|
||||
};
|
||||
|
||||
// If ellipsis are still needed, then they were already needed for the previous fragment.
|
||||
if fragment.flags.contains(IS_ELLIPSIS) {
|
||||
continue
|
||||
}
|
||||
|
||||
// If ellipsis are still needed, then they were already needed for the previous fragment.
|
||||
if fragment.flags.contains(IS_ELLIPSIS) {
|
||||
continue
|
||||
}
|
||||
|
||||
// Try to append the fragment.
|
||||
self.reflow_fragment(fragment, flow, layout_context);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue