Skip to content

Commit

Permalink
Auto merge of #16794 - emilio:table-text-fixup, r=Manishearth
Browse files Browse the repository at this point in the history
style: Adjust text-align properly for -moz- values in tables.

Fixes bug 1363576.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16794)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed May 10, 2017
2 parents c6c0252 + 3ec2b4f commit 15f3db5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
1 change: 0 additions & 1 deletion components/style/properties/gecko.mako.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3383,7 +3383,6 @@ fn static_assert() {
<% text_align_keyword = Keyword("text-align",
"start end left right center justify -moz-center -moz-left -moz-right char",
gecko_strip_moz_prefix=False) %>
<% text_align_reachable_keyword = Keyword("text-align", "start end left right center justify char") %>
${impl_keyword('text_align', 'mTextAlign', text_align_keyword, need_clone=False)}
${impl_keyword_clone('text_align', 'mTextAlign', text_align_keyword)}

Expand Down
24 changes: 24 additions & 0 deletions components/style/style_adjuster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,29 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
}
}

/// -moz-center, -moz-left and -moz-right are used for HTML's alignment.
///
/// This is covering the <div align="right"><table>...</table></div> case.
///
/// In this case, we don't want to inherit the text alignment into the
/// table.
#[cfg(feature = "gecko")]
fn adjust_for_table_text_align(&mut self) {
use properties::longhands::text_align::computed_value::T as text_align;
if self.style.get_box().clone_display() != display::table {
return;
}

match self.style.get_inheritedtext().clone_text_align() {
text_align::_moz_left |
text_align::_moz_center |
text_align::_moz_right => {}
_ => return,
}

self.style.mutate_inheritedtext().set_text_align(text_align::start);
}

/// Adjusts the style to account for various fixups that don't fit naturally
/// into the cascade.
///
Expand All @@ -274,6 +297,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
self.adjust_for_overflow();
#[cfg(feature = "gecko")]
{
self.adjust_for_table_text_align();
self.adjust_for_contain();
}
#[cfg(feature = "servo")]
Expand Down

0 comments on commit 15f3db5

Please sign in to comment.