mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
auto merge of #2508 : SimonSapin/servo/direction, r=pcwalton
This commit is contained in:
commit
43b647feff
5 changed files with 54 additions and 7 deletions
|
@ -42,7 +42,8 @@ use std::fmt;
|
|||
use std::mem;
|
||||
use std::num::Zero;
|
||||
use style::computed_values::{LPA_Auto, LPA_Length, LPA_Percentage, LPN_Length, LPN_None};
|
||||
use style::computed_values::{LPN_Percentage, LP_Length, LP_Percentage, display, float, overflow};
|
||||
use style::computed_values::{LPN_Percentage, LP_Length, LP_Percentage};
|
||||
use style::computed_values::{display, direction, float, overflow};
|
||||
use sync::Arc;
|
||||
|
||||
/// Information specific to floated blocks.
|
||||
|
@ -1717,6 +1718,7 @@ pub struct WidthConstraintInput {
|
|||
pub right: MaybeAuto,
|
||||
pub available_width: Au,
|
||||
pub static_x_offset: Au,
|
||||
pub direction: direction::T,
|
||||
}
|
||||
|
||||
impl WidthConstraintInput {
|
||||
|
@ -1726,7 +1728,8 @@ impl WidthConstraintInput {
|
|||
left: MaybeAuto,
|
||||
right: MaybeAuto,
|
||||
available_width: Au,
|
||||
static_x_offset: Au)
|
||||
static_x_offset: Au,
|
||||
direction: direction::T)
|
||||
-> WidthConstraintInput {
|
||||
WidthConstraintInput {
|
||||
computed_width: computed_width,
|
||||
|
@ -1736,6 +1739,7 @@ impl WidthConstraintInput {
|
|||
right: right,
|
||||
available_width: available_width,
|
||||
static_x_offset: static_x_offset,
|
||||
direction: direction,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1814,7 +1818,8 @@ pub trait WidthAndMarginsComputer {
|
|||
left,
|
||||
right,
|
||||
available_width,
|
||||
block.static_x_offset());
|
||||
block.static_x_offset(),
|
||||
style.get_inheritedbox().direction);
|
||||
}
|
||||
|
||||
/// Set the used values for width and margins got from the relevant constraint equation.
|
||||
|
@ -1940,9 +1945,12 @@ pub trait WidthAndMarginsComputer {
|
|||
// If direction is ltr, ignore the specified right margin and
|
||||
// solve for it.
|
||||
// If it is rtl, ignore the specified left margin.
|
||||
// FIXME(eatkinson): this assumes the direction is ltr
|
||||
(Specified(margin_l), Specified(width), Specified(_margin_r)) =>
|
||||
(margin_l, width, available_width - (margin_l + width )),
|
||||
(Specified(margin_l), Specified(width), Specified(margin_r)) => {
|
||||
match input.direction {
|
||||
direction::ltr => (margin_l, width, available_width - (margin_l + width)),
|
||||
direction::rtl => (available_width - (margin_r + width), width, margin_r),
|
||||
}
|
||||
},
|
||||
|
||||
// If exactly one value is 'auto', solve for it
|
||||
(Auto, Specified(width), Specified(margin_r)) =>
|
||||
|
@ -2004,6 +2012,7 @@ impl WidthAndMarginsComputer for AbsoluteNonReplaced {
|
|||
right,
|
||||
available_width,
|
||||
static_x_offset,
|
||||
direction,
|
||||
} = input;
|
||||
|
||||
// TODO: Check for direction of parent flow (NOT Containing Block)
|
||||
|
@ -2152,6 +2161,7 @@ impl WidthAndMarginsComputer for AbsoluteReplaced {
|
|||
right,
|
||||
available_width,
|
||||
static_x_offset,
|
||||
direction,
|
||||
} = input;
|
||||
// TODO: Check for direction of static-position Containing Block (aka
|
||||
// parent flow, _not_ the actual Containing Block) when right-to-left
|
||||
|
|
|
@ -321,8 +321,14 @@ pub mod longhands {
|
|||
${single_keyword("float", "none left right")}
|
||||
${single_keyword("clear", "none left right both")}
|
||||
|
||||
${new_style_struct("InheritedBox", is_inherited=True)}
|
||||
|
||||
${single_keyword("direction", "ltr rtl")}
|
||||
|
||||
// CSS 2.1, Section 10 - Visual formatting model details
|
||||
|
||||
${switch_to_style_struct("Box")}
|
||||
|
||||
${predefined_type("width", "LengthOrPercentageOrAuto",
|
||||
"computed::LPA_Auto",
|
||||
"parse_non_negative")}
|
||||
|
@ -364,7 +370,7 @@ pub mod longhands {
|
|||
"computed::LPN_None",
|
||||
"parse_non_negative")}
|
||||
|
||||
${new_style_struct("InheritedBox", is_inherited=True)}
|
||||
${switch_to_style_struct("InheritedBox")}
|
||||
|
||||
<%self:single_component_value name="line-height">
|
||||
#[deriving(Clone)]
|
||||
|
|
|
@ -74,3 +74,4 @@
|
|||
== pseudo_element_a.html pseudo_element_b.html
|
||||
== linebreak_simple_a.html linebreak_simple_b.html
|
||||
== linebreak_inline_span_a.html linebreak_inline_span_b.html
|
||||
== overconstrained_block.html overconstrained_block_ref.html
|
||||
|
|
15
src/test/ref/overconstrained_block.html
Normal file
15
src/test/ref/overconstrained_block.html
Normal file
|
@ -0,0 +1,15 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Block with over-contrained margins+borders+padding+width = containing block width</title>
|
||||
<style>
|
||||
body { width: 300px; margin: 0 }
|
||||
p { background: green; width: 200px; height: 100px; margin: 20px 70px }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p style="margin: 20px 70px"></p>
|
||||
<p style="margin: 20px 70px; direction: rtl"></p>
|
||||
<p style="margin: 20px 120px"></p>
|
||||
<p style="margin: 20px 120px; direction: rtl"></p>
|
||||
</body>
|
||||
</html>
|
15
src/test/ref/overconstrained_block_ref.html
Normal file
15
src/test/ref/overconstrained_block_ref.html
Normal file
|
@ -0,0 +1,15 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Block with over-contrained margins+borders+padding+width = containing block width</title>
|
||||
<style>
|
||||
body { width: 300px; margin: 0; }
|
||||
p { background: green; width: 200px; height: 100px; margin: 0; position: absolute }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p style="top: 20px; left: 70px"></p>
|
||||
<p style="top: 140px; left: 30px"></p>
|
||||
<p style="top: 260px; left: 120px"></p>
|
||||
<p style="top: 380px; left: -20px"></p>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue