mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Various fixes
Fix the behavior of block-direction margins of replaced element both as block level or inline level, and no longer query fragment info when building display list for canvas.
This commit is contained in:
parent
b1b17f1869
commit
b0de105bb0
3 changed files with 54 additions and 52 deletions
|
@ -46,7 +46,7 @@ use gfx::display_list::{ClippingRegion, StackingContext};
|
|||
use gfx_traits::ScrollRootId;
|
||||
use gfx_traits::print_tree::PrintTree;
|
||||
use layout_debug;
|
||||
use model::{CollapsibleMargins, IntrinsicISizes, MarginCollapseInfo, MaybeAuto};
|
||||
use model::{AdjoiningMargins, CollapsibleMargins, IntrinsicISizes, MarginCollapseInfo, MaybeAuto};
|
||||
use model::{specified, specified_or_none};
|
||||
use sequential;
|
||||
use serde::{Serialize, Serializer};
|
||||
|
@ -1887,6 +1887,14 @@ impl Flow for BlockFlow {
|
|||
self.fragment.assign_replaced_block_size_if_necessary();
|
||||
if !self.base.flags.contains(IS_ABSOLUTELY_POSITIONED) {
|
||||
self.base.position.size.block = self.fragment.border_box.size.block;
|
||||
let mut block_start = AdjoiningMargins::from_margin(self.fragment.margin.block_start);
|
||||
let block_end = AdjoiningMargins::from_margin(self.fragment.margin.block_end);
|
||||
if self.fragment.border_box.size.block == Au(0) {
|
||||
block_start.union(block_end);
|
||||
self.base.collapsible_margins = CollapsibleMargins::CollapseThrough(block_start);
|
||||
} else {
|
||||
self.base.collapsible_margins = CollapsibleMargins::Collapse(block_start, block_end);
|
||||
}
|
||||
self.base.restyle_damage.remove(REFLOW_OUT_OF_FLOW | REFLOW);
|
||||
self.fragment.restyle_damage.remove(REFLOW_OUT_OF_FLOW | REFLOW);
|
||||
}
|
||||
|
|
|
@ -1489,13 +1489,8 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
}
|
||||
}
|
||||
SpecificFragmentInfo::Canvas(ref canvas_fragment_info) => {
|
||||
let width = canvas_fragment_info.replaced_image_fragment_info
|
||||
.computed_inline_size.map_or(0, |w| w.to_px() as usize);
|
||||
let height = canvas_fragment_info.replaced_image_fragment_info
|
||||
.computed_block_size.map_or(0, |h| h.to_px() as usize);
|
||||
if width > 0 && height > 0 {
|
||||
let computed_width = canvas_fragment_info.canvas_inline_size().to_px();
|
||||
let computed_height = canvas_fragment_info.canvas_block_size().to_px();
|
||||
let computed_width = canvas_fragment_info.dom_width.to_px();
|
||||
let computed_height = canvas_fragment_info.dom_height.to_px();
|
||||
|
||||
let canvas_data = match canvas_fragment_info.ipc_renderer {
|
||||
Some(ref ipc_renderer) => {
|
||||
|
@ -1540,7 +1535,6 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
|
||||
state.add_display_item(display_item);
|
||||
}
|
||||
}
|
||||
SpecificFragmentInfo::UnscannedText(_) => {
|
||||
panic!("Shouldn't see unscanned fragments here.")
|
||||
}
|
||||
|
|
|
@ -1990,10 +1990,10 @@ impl Fragment {
|
|||
SpecificFragmentInfo::Canvas(_) | SpecificFragmentInfo::Iframe(_) |
|
||||
SpecificFragmentInfo::Image(_) | SpecificFragmentInfo::Svg(_) |
|
||||
SpecificFragmentInfo::Generic | SpecificFragmentInfo::GeneratedContent(_) => {
|
||||
let ascent = self.border_box.size.block + self.margin.block_start;
|
||||
let ascent = self.border_box.size.block + self.margin.block_end;
|
||||
InlineMetrics {
|
||||
space_above_baseline: ascent,
|
||||
space_below_baseline: self.margin.block_end,
|
||||
space_above_baseline: ascent + self.margin.block_start,
|
||||
space_below_baseline: Au(0),
|
||||
ascent: ascent,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue