aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/fragment.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/layout/fragment.rs')
-rw-r--r--components/layout/fragment.rs29
1 files changed, 25 insertions, 4 deletions
diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs
index 1fa3ae0612a..2c193d09e41 100644
--- a/components/layout/fragment.rs
+++ b/components/layout/fragment.rs
@@ -49,7 +49,8 @@ use style::properties::ServoComputedValues;
use style::selector_impl::RestyleDamage;
use style::servo::restyle_damage::RECONSTRUCT_FLOW;
use style::str::char_is_whitespace;
-use style::values::computed::{LengthOrNone, LengthOrPercentage, LengthOrPercentageOrAuto};
+use style::values::Either;
+use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto};
use style::values::computed::LengthOrPercentageOrNone;
use text;
use text::TextRunScanner;
@@ -123,6 +124,9 @@ pub struct Fragment {
/// The pseudo-element that this fragment represents.
pub pseudo: PseudoElementType<()>,
+ /// Various flags for this fragment.
+ pub flags: FragmentFlags,
+
/// A debug ID that is consistent for the life of this fragment (via transform etc).
/// This ID should not be considered stable across multiple layouts or fragment
/// manipulations.
@@ -917,6 +921,7 @@ impl Fragment {
specific: specific,
inline_context: None,
pseudo: node.get_pseudo_element_type().strip(),
+ flags: FragmentFlags::empty(),
debug_id: DebugId::new(),
stacking_context_id: StackingContextId::new(0),
}
@@ -945,6 +950,7 @@ impl Fragment {
specific: specific,
inline_context: None,
pseudo: pseudo,
+ flags: FragmentFlags::empty(),
debug_id: DebugId::new(),
stacking_context_id: StackingContextId::new(0),
}
@@ -969,6 +975,7 @@ impl Fragment {
specific: specific,
inline_context: None,
pseudo: self.pseudo,
+ flags: FragmentFlags::empty(),
debug_id: DebugId::new(),
stacking_context_id: StackingContextId::new(0),
}
@@ -996,6 +1003,7 @@ impl Fragment {
specific: info,
inline_context: self.inline_context.clone(),
pseudo: self.pseudo.clone(),
+ flags: FragmentFlags::empty(),
debug_id: self.debug_id.clone(),
stacking_context_id: StackingContextId::new(0),
}
@@ -1029,12 +1037,15 @@ impl Fragment {
}
/// Transforms this fragment into an ellipsis fragment, preserving all the other data.
- pub fn transform_into_ellipsis(&self, layout_context: &LayoutContext) -> Fragment {
+ pub fn transform_into_ellipsis(&self,
+ layout_context: &LayoutContext,
+ text_overflow_string: String)
+ -> Fragment {
let mut unscanned_ellipsis_fragments = LinkedList::new();
unscanned_ellipsis_fragments.push_back(self.transform(
self.border_box.size,
SpecificFragmentInfo::UnscannedText(
- box UnscannedTextFragmentInfo::new("…".to_owned(), None))));
+ box UnscannedTextFragmentInfo::new(text_overflow_string, None))));
let ellipsis_fragments = TextRunScanner::new().scan_for_runs(&mut layout_context.font_context(),
unscanned_ellipsis_fragments);
debug_assert!(ellipsis_fragments.len() == 1);
@@ -2579,7 +2590,7 @@ impl Fragment {
// TODO(mrobinson): Determine if this is necessary, since blocks with
// transformations already create stacking contexts.
- if self.style().get_effects().perspective != LengthOrNone::None {
+ if let Either::First(ref _length) = self.style().get_effects().perspective {
return true
}
@@ -3111,6 +3122,16 @@ impl Overflow {
}
}
+bitflags! {
+ pub flags FragmentFlags: u8 {
+ // TODO(stshine): find a better name since these flags can also be used for grid item.
+ /// Whether this fragment represents a child in a row flex container.
+ 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,
+ }
+}
+
/// Specified distances from the margin edge of a block to its content in the inline direction.
/// These are returned by `guess_inline_content_edge_offsets()` and are used in the float placement
/// speculation logic.