mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Merge pull request #2953 from glennw/inline-whitespace
Change layout to handle whitespace between inline elements in HTML file.
This commit is contained in:
commit
d6c86c44d6
5 changed files with 54 additions and 12 deletions
|
@ -329,15 +329,6 @@ impl<'a> FlowConstructor<'a> {
|
|||
} else if flow.get().need_anonymous_flow(kid_flow.get()) {
|
||||
consecutive_siblings.push(kid_flow)
|
||||
} else {
|
||||
// Strip ignorable whitespace from the start of this flow per CSS 2.1 §
|
||||
// 9.2.1.1.
|
||||
let whitespace_stripping = if flow.get().is_table_kind() || *first_fragment {
|
||||
*first_fragment = false;
|
||||
StripWhitespaceFromStart
|
||||
} else {
|
||||
NoWhitespaceStripping
|
||||
};
|
||||
|
||||
// Flush any inline fragments that we were gathering up. This allows us to handle
|
||||
// {ib} splits.
|
||||
debug!("flushing {} inline box(es) to flow A",
|
||||
|
@ -346,7 +337,7 @@ impl<'a> FlowConstructor<'a> {
|
|||
mem::replace(inline_fragment_accumulator, InlineFragmentsAccumulator::new()),
|
||||
flow,
|
||||
consecutive_siblings,
|
||||
whitespace_stripping,
|
||||
StripWhitespaceFromStart,
|
||||
node);
|
||||
if !consecutive_siblings.is_empty() {
|
||||
let consecutive_siblings = mem::replace(consecutive_siblings, vec!());
|
||||
|
@ -407,8 +398,14 @@ impl<'a> FlowConstructor<'a> {
|
|||
inline_fragment_accumulator.fragments.push_all(successor_fragments);
|
||||
abs_descendants.push_descendants(kid_abs_descendants);
|
||||
}
|
||||
ConstructionItemConstructionResult(WhitespaceConstructionItem(..)) => {
|
||||
// Nothing to do here.
|
||||
ConstructionItemConstructionResult(WhitespaceConstructionItem(whitespace_node, whitespace_style)) => {
|
||||
// Add whitespace results. They will be stripped out later on when
|
||||
// between block elements, and retained when between inline elements.
|
||||
let fragment_info = UnscannedTextFragment(UnscannedTextFragmentInfo::from_text(" ".to_string()));
|
||||
let fragment = Fragment::from_opaque_node_and_style(whitespace_node,
|
||||
whitespace_style.clone(),
|
||||
fragment_info);
|
||||
inline_fragment_accumulator.fragments.push(fragment, whitespace_style);
|
||||
}
|
||||
ConstructionItemConstructionResult(TableColumnFragmentConstructionItem(_)) => {
|
||||
// TODO: Implement anonymous table objects for missing parents
|
||||
|
|
|
@ -88,3 +88,5 @@
|
|||
== pseudo_inherit.html pseudo_inherit_ref.html
|
||||
== float_intrinsic_height.html float_intrinsic_height_ref.html
|
||||
== table_auto_width.html table_auto_width_ref.html
|
||||
== inline_whitespace_b.html inline_whitespace_ref.html
|
||||
== inline_whitespace_a.html inline_whitespace_ref.html
|
||||
|
|
14
src/test/ref/inline_whitespace_a.html
Normal file
14
src/test/ref/inline_whitespace_a.html
Normal file
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style type="text/css">
|
||||
body {
|
||||
background-color: #f6f6f6;
|
||||
font-size: 128px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<span>A</span> <span>B</span>
|
||||
</body>
|
||||
</html>
|
15
src/test/ref/inline_whitespace_b.html
Normal file
15
src/test/ref/inline_whitespace_b.html
Normal file
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style type="text/css">
|
||||
body {
|
||||
background-color: #f6f6f6;
|
||||
font-size: 128px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<span>A</span>
|
||||
<span>B</span>
|
||||
</body>
|
||||
</html>
|
14
src/test/ref/inline_whitespace_ref.html
Normal file
14
src/test/ref/inline_whitespace_ref.html
Normal file
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style type="text/css">
|
||||
body {
|
||||
background-color: #f6f6f6;
|
||||
font-size: 128px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<span>A B</span>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue