Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fully implement the "align descendants" rule for div. #7825

Merged
merged 2 commits into from Oct 8, 2015
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

Make "align descendants" rule use parent's text-align.

Flows never care about their own text-align, only the text-align of
their parent; change the text-align flags to account for that.  Make the
"align descendants" rule use the flags instead of the current node's style.

Fixes #7301.
  • Loading branch information
eefriedman committed Oct 2, 2015
commit a31461bad9c36999ad63c0dcfcc09f11b098f184
@@ -1466,8 +1466,9 @@ impl BlockFlow {

// Per CSS 2.1 § 16.3.1, text alignment propagates to all children in flow.
//
// TODO(#2018, pcwalton): Do this in the cascade instead.
flow::mut_base(kid).flags.propagate_text_alignment_from_parent(flags.clone());
// TODO(#2265, pcwalton): Do this in the cascade instead.
let containing_block_text_align = self.fragment.style().get_inheritedtext().text_align;
flow::mut_base(kid).flags.set_text_align(containing_block_text_align);

// Handle `text-indent` on behalf of any inline children that we have. This is
// necessary because any percentages are relative to the containing block, which only
@@ -2276,9 +2277,6 @@ pub trait ISizeAndMarginsComputer {
(_, box_sizing::T::content_box) => {}
}

// The text alignment of a block flow is the text alignment of its box's style.
block.base.flags.set_text_align(style.get_inheritedtext().text_align);

let margin = style.logical_margin();
let position = style.logical_position();

@@ -2442,6 +2440,7 @@ pub trait ISizeAndMarginsComputer {
// Check for direction of parent flow (NOT Containing Block)
let block_mode = block.base.writing_mode;
let container_mode = block.base.block_container_writing_mode;
let block_align = block.base.flags.text_align();

// FIXME (mbrubeck): Handle vertical writing modes.
let parent_has_same_direction = container_mode.is_bidi_ltr() == block_mode.is_bidi_ltr();
@@ -2472,9 +2471,6 @@ pub trait ISizeAndMarginsComputer {
MaybeAuto::Specified(margin_end)) => {
// servo_left, servo_right, and servo_center are used to implement
// the "align descendants" rule in HTML5 § 14.2.
// FIXME(#7301): block_align is supposed to be the text-align of the
// parent, not the current node.
let block_align = input.text_align;
if block_align == text_align::T::servo_center {
// Ignore any existing margins, and make the inline-start and
// inline-end margins equal.
@@ -655,14 +655,6 @@ static HAS_FLOATED_DESCENDANTS_BITMASK: FlowFlags = FlowFlags { bits: 0b0000_001
static TEXT_ALIGN_SHIFT: usize = 11;

impl FlowFlags {
/// Propagates text alignment flags from an appropriate parent flow per CSS 2.1.
///
/// FIXME(#2265, pcwalton): It would be cleaner and faster to make this a derived CSS property
/// `-servo-text-align-in-effect`.
pub fn propagate_text_alignment_from_parent(&mut self, parent_flags: FlowFlags) {
self.set_text_align_override(parent_flags);
}

#[inline]
pub fn text_align(self) -> text_align::T {
text_align::T::from_u32((self & TEXT_ALIGN).bits() >> TEXT_ALIGN_SHIFT).unwrap()
@@ -674,11 +666,6 @@ impl FlowFlags {
FlowFlags::from_bits(value.to_u32() << TEXT_ALIGN_SHIFT).unwrap();
}

#[inline]
pub fn set_text_align_override(&mut self, parent: FlowFlags) {
self.insert(parent & TEXT_ALIGN);
}

#[inline]
pub fn union_floated_descendants_flags(&mut self, other: FlowFlags) {
self.insert(other & HAS_FLOATED_DESCENDANTS_BITMASK);
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.