mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Replace a pair of macros by methods
This commit is contained in:
parent
01034b10e1
commit
038f83fbc5
1 changed files with 16 additions and 17 deletions
|
@ -17,7 +17,7 @@ use app_units::Au;
|
||||||
use gfx::text::text_run::GlyphRun;
|
use gfx::text::text_run::GlyphRun;
|
||||||
use servo_arc::Arc;
|
use servo_arc::Arc;
|
||||||
use style::properties::ComputedValues;
|
use style::properties::ComputedValues;
|
||||||
use style::values::computed::{Length, Percentage};
|
use style::values::computed::{Length, LengthPercentage, Percentage};
|
||||||
use style::Zero;
|
use style::Zero;
|
||||||
use webrender_api::FontInstanceKey;
|
use webrender_api::FontInstanceKey;
|
||||||
|
|
||||||
|
@ -103,25 +103,14 @@ impl InlineFormattingContext {
|
||||||
let padding = inline_box.style.padding();
|
let padding = inline_box.style.padding();
|
||||||
let border = inline_box.style.border_width();
|
let border = inline_box.style.border_width();
|
||||||
let margin = inline_box.style.margin();
|
let margin = inline_box.style.margin();
|
||||||
macro_rules! add_length {
|
|
||||||
($x: expr) => {{
|
|
||||||
let length = $x;
|
|
||||||
self.current_line.min_content += length;
|
|
||||||
self.current_line.max_content += length;
|
|
||||||
}};
|
|
||||||
}
|
|
||||||
macro_rules! add_lengthpercentage {
|
|
||||||
($x: expr) => {{
|
|
||||||
add_length!($x.length_component());
|
|
||||||
self.current_line_percentages += $x.percentage_component();
|
|
||||||
}};
|
|
||||||
}
|
|
||||||
macro_rules! add {
|
macro_rules! add {
|
||||||
($condition: ident, $side: ident) => {
|
($condition: ident, $side: ident) => {
|
||||||
if inline_box.$condition {
|
if inline_box.$condition {
|
||||||
add_lengthpercentage!(padding.$side);
|
self.add_lengthpercentage(padding.$side);
|
||||||
add_length!(border.$side);
|
self.add_length(border.$side);
|
||||||
margin.$side.non_auto().map(|x| add_lengthpercentage!(x));
|
if let Some(lp) = margin.$side.non_auto() {
|
||||||
|
self.add_lengthpercentage(lp)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -161,6 +150,16 @@ impl InlineFormattingContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn add_lengthpercentage(&mut self, lp: LengthPercentage) {
|
||||||
|
self.add_length(lp.length_component());
|
||||||
|
self.current_line_percentages += lp.percentage_component();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn add_length(&mut self, l: Length) {
|
||||||
|
self.current_line.min_content += l;
|
||||||
|
self.current_line.max_content += l;
|
||||||
|
}
|
||||||
|
|
||||||
fn line_break_opportunity(&mut self) {
|
fn line_break_opportunity(&mut self) {
|
||||||
self.paragraph
|
self.paragraph
|
||||||
.min_content
|
.min_content
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue