mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
layout: Take relative position offsets for inlines and inline-blocks
into account only once. There were two bugs here: (1) relative position applied to scanned/unscanned text fragments independently of the container element that applied that relative position, causing double-counting; (2) relative position applied to inline block fragments independently of the wrapped block itself, causing double-counting. This commit also removes the `cascade_anonymous` function and the related `Fragment` constructor. They were unused, and their functionality has been replaced by the `modify_style_for_*` series of functions. Closes #7067.
This commit is contained in:
parent
3ad49fc689
commit
8640cf5588
11 changed files with 102 additions and 88 deletions
|
@ -227,6 +227,20 @@ impl InlineFragmentsAccumulator {
|
|||
}
|
||||
}
|
||||
|
||||
fn from_inline_node_and_style(node: &ThreadSafeLayoutNode, style: Arc<ComputedValues>)
|
||||
-> InlineFragmentsAccumulator {
|
||||
InlineFragmentsAccumulator {
|
||||
fragments: IntermediateInlineFragments::new(),
|
||||
enclosing_node: Some(InlineFragmentNodeInfo {
|
||||
address: node.opaque(),
|
||||
pseudo: node.get_pseudo_element_type().strip(),
|
||||
style: style,
|
||||
}),
|
||||
bidi_control_chars: None,
|
||||
restyle_damage: node.restyle_damage(),
|
||||
}
|
||||
}
|
||||
|
||||
fn push(&mut self, fragment: Fragment) {
|
||||
self.fragments.fragments.push_back(fragment)
|
||||
}
|
||||
|
@ -686,7 +700,15 @@ impl<'a> FlowConstructor<'a> {
|
|||
fragments: &mut IntermediateInlineFragments,
|
||||
node: &ThreadSafeLayoutNode,
|
||||
style: &Arc<ComputedValues>) {
|
||||
for content_item in node.text_content().into_iter() {
|
||||
// Fast path: If there is no text content, return immediately.
|
||||
let text_content = node.text_content();
|
||||
if text_content.len() == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
let mut style = (*style).clone();
|
||||
properties::modify_style_for_text(&mut style);
|
||||
for content_item in text_content.into_iter() {
|
||||
let specific = match content_item {
|
||||
ContentItem::String(string) => {
|
||||
let info = UnscannedTextFragmentInfo::from_text(string);
|
||||
|
@ -910,11 +932,18 @@ impl<'a> FlowConstructor<'a> {
|
|||
_ => unreachable!()
|
||||
};
|
||||
|
||||
let mut modified_style = (*node.style()).clone();
|
||||
properties::modify_style_for_outer_inline_block_fragment(&mut modified_style);
|
||||
let fragment_info = SpecificFragmentInfo::InlineBlock(InlineBlockFragmentInfo::new(
|
||||
block_flow));
|
||||
let fragment = Fragment::new(node, fragment_info);
|
||||
let fragment = Fragment::from_opaque_node_and_style(node.opaque(),
|
||||
node.get_pseudo_element_type().strip(),
|
||||
modified_style.clone(),
|
||||
node.restyle_damage(),
|
||||
fragment_info);
|
||||
|
||||
let mut fragment_accumulator = InlineFragmentsAccumulator::from_inline_node(node);
|
||||
let mut fragment_accumulator =
|
||||
InlineFragmentsAccumulator::from_inline_node_and_style(node, modified_style);
|
||||
fragment_accumulator.fragments.fragments.push_back(fragment);
|
||||
|
||||
let construction_item =
|
||||
|
@ -1317,6 +1346,12 @@ impl<'a> FlowConstructor<'a> {
|
|||
inline_absolute_fragment.flow_ref
|
||||
.repair_style_and_bubble_inline_sizes(&style);
|
||||
}
|
||||
SpecificFragmentInfo::ScannedText(_) |
|
||||
SpecificFragmentInfo::UnscannedText(_) => {
|
||||
properties::modify_style_for_text(&mut style);
|
||||
properties::modify_style_for_replaced_content(&mut style);
|
||||
fragment.repair_style(&style);
|
||||
}
|
||||
_ => {
|
||||
if node.is_replaced_content() {
|
||||
properties::modify_style_for_replaced_content(&mut style);
|
||||
|
|
|
@ -39,7 +39,7 @@ use style::computed_values::content::ContentItem;
|
|||
use style::computed_values::{border_collapse, clear, mix_blend_mode, overflow_wrap, overflow_x};
|
||||
use style::computed_values::{position, text_align, text_decoration, transform_style, white_space};
|
||||
use style::computed_values::{word_break, z_index};
|
||||
use style::properties::{self, ComputedValues, cascade_anonymous};
|
||||
use style::properties::{self, ComputedValues};
|
||||
use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto};
|
||||
use style::values::computed::{LengthOrPercentageOrNone};
|
||||
use text::TextRunScanner;
|
||||
|
@ -761,37 +761,6 @@ impl Fragment {
|
|||
}
|
||||
}
|
||||
|
||||
/// Constructs a new `Fragment` instance for an anonymous table object.
|
||||
pub fn new_anonymous_from_specific_info(node: &ThreadSafeLayoutNode,
|
||||
specific: SpecificFragmentInfo)
|
||||
-> Fragment {
|
||||
// CSS 2.1 § 17.2.1 This is for non-inherited properties on anonymous table fragments
|
||||
// example:
|
||||
//
|
||||
// <div style="display: table">
|
||||
// Foo
|
||||
// </div>
|
||||
//
|
||||
// Anonymous table fragments, SpecificFragmentInfo::TableRow and
|
||||
// SpecificFragmentInfo::TableCell, are generated around `Foo`, but they shouldn't inherit
|
||||
// the border.
|
||||
|
||||
let node_style = cascade_anonymous(&**node.style());
|
||||
let writing_mode = node_style.writing_mode;
|
||||
Fragment {
|
||||
node: node.opaque(),
|
||||
style: Arc::new(node_style),
|
||||
restyle_damage: node.restyle_damage(),
|
||||
border_box: LogicalRect::zero(writing_mode),
|
||||
border_padding: LogicalMargin::zero(writing_mode),
|
||||
margin: LogicalMargin::zero(writing_mode),
|
||||
specific: specific,
|
||||
inline_context: None,
|
||||
pseudo: node.get_pseudo_element_type().strip(),
|
||||
debug_id: layout_debug::generate_unique_debug_id(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Constructs a new `Fragment` instance from an opaque node.
|
||||
pub fn from_opaque_node_and_style(node: OpaqueNode,
|
||||
pseudo: PseudoElementType<()>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue