mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Update rust-css and fix some dynamic borrow check failures
This commit is contained in:
parent
0b91af3677
commit
72ca765cd0
4 changed files with 25 additions and 40 deletions
|
@ -106,8 +106,9 @@ impl BlockFlowData {
|
|||
these widths will not include child elements, just padding etc. */
|
||||
self.box.map(|&box| {
|
||||
//Can compute border width here since it doesn't depend on anything
|
||||
let style = box.style();
|
||||
do box.with_model |model| {
|
||||
model.compute_borders(box.style())
|
||||
model.compute_borders(style)
|
||||
}
|
||||
min_width = min_width.add(&box.get_min_width(ctx));
|
||||
pref_width = pref_width.add(&box.get_pref_width(ctx));
|
||||
|
@ -184,17 +185,18 @@ impl BlockFlowData {
|
|||
let mut x_offset = Au(0);
|
||||
|
||||
self.box.map(|&box| {
|
||||
let style = box.style();
|
||||
do box.with_model |model| {
|
||||
model.compute_padding(box.style(), remaining_width);
|
||||
model.compute_padding(style, remaining_width);
|
||||
|
||||
let available_width = remaining_width - model.noncontent_width();
|
||||
|
||||
let margin_top = MaybeAuto::from_margin(box.style().margin_top()).spec_or_default(Au(0));
|
||||
let margin_bottom = MaybeAuto::from_margin(box.style().margin_bottom()).spec_or_default(Au(0));
|
||||
let margin_top = MaybeAuto::from_margin(style.margin_top()).spec_or_default(Au(0));
|
||||
let margin_bottom = MaybeAuto::from_margin(style.margin_bottom()).spec_or_default(Au(0));
|
||||
|
||||
let (width, margin_left, margin_right) = (MaybeAuto::from_width(box.style().width()),
|
||||
MaybeAuto::from_margin(box.style().margin_left()),
|
||||
MaybeAuto::from_margin(box.style().margin_right()));
|
||||
let (width, margin_left, margin_right) = (MaybeAuto::from_width(style.width()),
|
||||
MaybeAuto::from_margin(style.margin_left()),
|
||||
MaybeAuto::from_margin(style.margin_right()));
|
||||
|
||||
let (width, margin_left, margin_right) =
|
||||
self.compute_horiz(width, margin_left, margin_right, available_width);
|
||||
|
|
|
@ -8,7 +8,7 @@ use css::node_style::StyledNode;
|
|||
use layout::context::LayoutContext;
|
||||
use layout::display_list_builder::{DisplayListBuilder, ExtraDisplayListData, ToGfxColor};
|
||||
use layout::flow::FlowContext;
|
||||
use layout::model::{BoxModel};
|
||||
use layout::model::BoxModel;
|
||||
use layout::text;
|
||||
|
||||
use core::cell::Cell;
|
||||
|
@ -454,41 +454,15 @@ pub impl RenderBox {
|
|||
}
|
||||
}
|
||||
|
||||
fn compute_borders(&self){
|
||||
do self.with_mut_base |base| {
|
||||
base.model.compute_borders(base.node.style());
|
||||
}
|
||||
}
|
||||
|
||||
fn get_noncontent_width(&self) -> Au {
|
||||
do self.with_imm_base |base| {
|
||||
base.model.border.left + base.model.padding.left + base.model.border.right +
|
||||
base.model.padding.right
|
||||
}
|
||||
}
|
||||
|
||||
fn compute_width(&self,
|
||||
cb_width: Au,
|
||||
callback: &fn(MaybeAuto, MaybeAuto, MaybeAuto) -> (Au, Au, Au)) {
|
||||
let computed_width = MaybeAuto::from_width(self.style().width());
|
||||
let computed_margin_left = MaybeAuto::from_margin(self.style().margin_left());
|
||||
let computed_margin_right = MaybeAuto::from_margin(self.style().margin_right());
|
||||
|
||||
let (used_width, used_margin_left, used_margin_right) =
|
||||
callback(computed_width, computed_margin_left, computed_margin_right);
|
||||
|
||||
let noncontent_width = self.get_noncontent_width();
|
||||
|
||||
do self.with_mut_base |base| {
|
||||
base.model.margin.left = used_margin_left;
|
||||
base.model.margin.right = used_margin_right;
|
||||
base.position.size.width = used_width + noncontent_width;
|
||||
base.position.origin.x = used_margin_left;
|
||||
base.model.border.left + base.model.padding.left +
|
||||
base.model.border.right + base.model.padding.right
|
||||
}
|
||||
}
|
||||
|
||||
fn with_model<R>(&self, callback: &fn(&mut BoxModel) -> R) -> R {
|
||||
do self.with_imm_base |base| {
|
||||
do self.with_mut_base |base| {
|
||||
callback(&mut base.model)
|
||||
}
|
||||
}
|
||||
|
@ -496,6 +470,15 @@ pub impl RenderBox {
|
|||
/// The box formed by the content edge as defined in CSS 2.1 § 8.1. Coordinates are relative to
|
||||
/// the owning flow.
|
||||
fn content_box(&self) -> Rect<Au> {
|
||||
do self.with_imm_base |base| {
|
||||
let origin = Point2D(base.position.origin.x +
|
||||
base.model.border.left +
|
||||
base.model.padding.left,
|
||||
base.position.origin.y);
|
||||
let size = Size2D(base.position.size.width - self.get_noncontent_width(),
|
||||
base.position.size.height);
|
||||
Rect(origin, size)
|
||||
}
|
||||
}
|
||||
|
||||
/// The box formed by the border edge as defined in CSS 2.1 § 8.1. Coordinates are relative to
|
||||
|
|
|
@ -31,12 +31,12 @@ pub struct BoxModel {
|
|||
}
|
||||
|
||||
/// Useful helper data type when computing values for blocks and positioned elements.
|
||||
pub enum MaybeAuto{
|
||||
pub enum MaybeAuto {
|
||||
Auto,
|
||||
Specified(Au),
|
||||
}
|
||||
|
||||
impl MaybeAuto{
|
||||
impl MaybeAuto {
|
||||
pub fn from_margin(margin: CSSMargin) -> MaybeAuto{
|
||||
match margin {
|
||||
CSSMarginAuto => Auto,
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 7a59bc7f27a2135668b9ca0f681f31a17dd68879
|
||||
Subproject commit 2f3f03cbafb88608d4f89216da7172d3b754fbef
|
Loading…
Add table
Add a link
Reference in a new issue