зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #10722 - layout: Add support for vertical alignment within table cells (from notriddle:table_cell_valign); r=SimonSapin
Fixes #10621 Source-Repo: https://github.com/servo/servo Source-Revision: 31a440867db54f5387aca3bd8ce2f644de84c5e1
This commit is contained in:
Родитель
2b99437a80
Коммит
dba4e0e71d
|
@ -29,6 +29,10 @@ impl FlowList {
|
|||
self.flows.push_back(new_tail);
|
||||
}
|
||||
|
||||
pub fn back(&self) -> Option<&Flow> {
|
||||
self.flows.back().map(|x| &**x)
|
||||
}
|
||||
|
||||
/// Add an element first in the list
|
||||
///
|
||||
/// O(1)
|
||||
|
@ -40,6 +44,10 @@ impl FlowList {
|
|||
self.flows.pop_front()
|
||||
}
|
||||
|
||||
pub fn front(&self) -> Option<&Flow> {
|
||||
self.flows.front().map(|x| &**x)
|
||||
}
|
||||
|
||||
/// Create an empty list
|
||||
#[inline]
|
||||
pub fn new() -> FlowList {
|
||||
|
|
|
@ -90,6 +90,14 @@ impl CollapsibleMargins {
|
|||
CollapsibleMargins::CollapseThrough(ref block_start) => block_start.collapse(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn block_end_margin_for_noncollapsible_context(&self) -> Au {
|
||||
match *self {
|
||||
CollapsibleMargins::None(_, block_end) => block_end,
|
||||
CollapsibleMargins::Collapse(_, ref block_end) |
|
||||
CollapsibleMargins::CollapseThrough(ref block_end) => block_end.collapse(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum FinalMarginState {
|
||||
|
|
|
@ -12,14 +12,15 @@ use context::LayoutContext;
|
|||
use cssparser::Color;
|
||||
use display_list_builder::{BlockFlowDisplayListBuilding, BorderPaintingMode, DisplayListBuildState};
|
||||
use euclid::{Point2D, Rect, SideOffsets2D, Size2D};
|
||||
use flow::{Flow, FlowClass, OpaqueFlow};
|
||||
use flow::{self, Flow, FlowClass, OpaqueFlow};
|
||||
use fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
|
||||
use gfx::display_list::{StackingContext, StackingContextId};
|
||||
use incremental::REFLOW;
|
||||
use layout_debug;
|
||||
use model::MaybeAuto;
|
||||
use std::fmt;
|
||||
use std::sync::Arc;
|
||||
use style::computed_values::{border_collapse, border_top_style};
|
||||
use style::computed_values::{border_collapse, border_top_style, vertical_align};
|
||||
use style::logical_geometry::{LogicalMargin, LogicalRect, LogicalSize, WritingMode};
|
||||
use style::properties::{ComputedValues, ServoComputedValues};
|
||||
use table::InternalTable;
|
||||
|
@ -74,6 +75,42 @@ impl TableCellFlow {
|
|||
None,
|
||||
MarginsMayCollapseFlag::MarginsMayNotCollapse);
|
||||
debug_assert!(remaining.is_none());
|
||||
if !flow::base(self).restyle_damage.contains(REFLOW) {
|
||||
return;
|
||||
}
|
||||
let first_start = flow::base(self).children.front().map(|kid| {
|
||||
flow::base(kid).position.start.b
|
||||
});
|
||||
if let Some(mut first_start) = first_start {
|
||||
let mut last_end = first_start;
|
||||
for kid in flow::base(self).children.iter() {
|
||||
let kid_base = flow::base(kid);
|
||||
let start = kid_base.position.start.b
|
||||
- kid_base.collapsible_margins.block_start_margin_for_noncollapsible_context();
|
||||
let end = kid_base.position.start.b + kid_base.position.size.block
|
||||
+ kid_base.collapsible_margins.block_end_margin_for_noncollapsible_context();
|
||||
if start < first_start {
|
||||
first_start = start;
|
||||
}
|
||||
if end > last_end {
|
||||
last_end = end;
|
||||
}
|
||||
}
|
||||
let kids_size = last_end - first_start;
|
||||
let self_size = flow::base(self).position.size.block -
|
||||
self.block_flow.fragment.border_padding.block_start_end();
|
||||
let kids_self_gap = self_size - kids_size;
|
||||
let offset = match self.block_flow.fragment.style().get_box().vertical_align {
|
||||
vertical_align::T::middle => kids_self_gap / 2,
|
||||
vertical_align::T::bottom => kids_self_gap,
|
||||
_ => Au(0),
|
||||
};
|
||||
if offset != Au(0) {
|
||||
for kid in flow::mut_base(self).children.iter_mut() {
|
||||
flow::mut_base(kid).position.start.b = flow::mut_base(kid).position.start.b + offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче