Auto merge of #18075 - upsuper:text-in-ruby, r=Manishearth

Apply line break suppression to text when in any ruby

This should fix [bug 1388904](https://bugzilla.mozilla.org/show_bug.cgi?id=1388904).

<!-- 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/18075)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-08-14 19:10:06 -05:00 committed by GitHub
commit 6f5e763934
2 changed files with 16 additions and 2 deletions

View file

@ -108,8 +108,9 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
/// ///
/// Note that this, for Gecko, comes through Servo_ComputedValues_Inherit. /// Note that this, for Gecko, comes through Servo_ComputedValues_Inherit.
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
pub fn adjust_for_text(&mut self) { pub fn adjust_for_text(&mut self, parent_style: &ComputedValues) {
self.adjust_for_text_combine_upright(); self.adjust_for_text_combine_upright();
self.adjust_for_text_in_ruby(parent_style);
self.set_bits(); self.set_bits();
} }
@ -138,6 +139,19 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
} }
} }
/// Applies the line break suppression flag to text if it is in any ruby
/// box. This is necessary because its parent may not itself have the flag
/// set (e.g. ruby or ruby containers), thus we may not inherit the flag
/// from them.
#[cfg(feature = "gecko")]
fn adjust_for_text_in_ruby(&mut self, parent_style: &ComputedValues) {
use properties::computed_value_flags::SHOULD_SUPPRESS_LINEBREAK;
let parent_display = parent_style.get_box().clone_display();
if parent_display.is_ruby_type() {
self.style.flags.insert(SHOULD_SUPPRESS_LINEBREAK);
}
}
/// https://drafts.csswg.org/css-writing-modes-3/#block-flow: /// https://drafts.csswg.org/css-writing-modes-3/#block-flow:
/// ///
/// If a box has a different writing-mode value than its containing /// If a box has a different writing-mode value than its containing

View file

@ -1821,7 +1821,7 @@ pub extern "C" fn Servo_ComputedValues_Inherit(
if for_text { if for_text {
StyleAdjuster::new(&mut style) StyleAdjuster::new(&mut style)
.adjust_for_text(); .adjust_for_text(reference);
} }
style.build() style.build()