Commit 137fc51c authored by rego@igalia.com's avatar rego@igalia.com

Fixed positioned element with relative percentage positioned parent is wrongly placed

The usage of Length::value() is causing a bug as 25% was translated to 25px,
which is wrong.
Use valueForLength() instead in order to get the accurate value.

Modified current test to add some examples using percentages.

BUG=31286,425991
TEST=fast/css/css-properties-position-relative-as-parent-fixed.html

Review URL: https://codereview.chromium.org/720003002

git-svn-id: svn://svn.chromium.org/blink/trunk@185274 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 661ec796
......@@ -158,5 +158,25 @@
</div>
</div>
<h5>Case 13: fixed text box (blue) should be just after relative2 text box (green).</h5>
<div class="container">
<div class="main relative grey" style="left: 100px;">
relative
<span class="relative green" style="left: 25%;">
relative2<div class="inline blue">fixed</div>
</span>
</div>
</div>
<h5>Case 14: fixed text box (blue) should be after relative text box (grey) in some distance and before the other relative2 text box (green) in some distance.</h5>
<div class="container">
<div class="main relative grey rtl" style="left: 100px;">
relative
<span class="relative green" style="left: 25%;">
relative2<div class="inline blue">fixed</div>
</span>
</div>
</div>
</body>
</html>
......@@ -189,5 +189,31 @@
</div>
</div>
<h5>Case 13: fixed text box (blue) should be just after relative2 text box (green).</h5>
<div class="container">
<div class="main relative grey" style="left: 100px;">
relative
<span class="relative green" style="left: 25%;">
relative2
<span class="fixed blue">
fixed
</span>
</span>
</div>
</div>
<h5>Case 14: fixed text box (blue) should be after relative text box (grey) in some distance and before the other relative2 text box (green) in some distance.</h5>
<div class="container">
<div class="main relative grey rtl" style="left: 100px;">
relative
<span class="relative green" style="left: 25%;">
relative2
<span class="fixed blue">
fixed
</span>
</span>
</div>
</div>
</body>
</html>
......@@ -2699,9 +2699,9 @@ static void computeInlineStaticDistance(Length& logicalLeft, Length& logicalRigh
} else if (curr->isInline()) {
if (curr->isRelPositioned()) {
if (!curr->style()->logicalLeft().isAuto())
staticPosition += curr->style()->logicalLeft().value();
staticPosition += valueForLength(curr->style()->logicalLeft(), curr->containingBlock()->availableWidth());
else
staticPosition -= curr->style()->logicalRight().value();
staticPosition -= valueForLength(curr->style()->logicalRight(), curr->containingBlock()->availableWidth());
}
}
}
......@@ -2721,9 +2721,9 @@ static void computeInlineStaticDistance(Length& logicalLeft, Length& logicalRigh
} else if (curr->isInline()) {
if (curr->isRelPositioned()) {
if (!curr->style()->logicalLeft().isAuto())
staticPosition -= curr->style()->logicalLeft().value();
staticPosition -= valueForLength(curr->style()->logicalLeft(), curr->containingBlock()->availableWidth());
else
staticPosition += curr->style()->logicalRight().value();
staticPosition += valueForLength(curr->style()->logicalRight(), curr->containingBlock()->availableWidth());
}
}
if (curr == containerBlock)
......
......@@ -144,6 +144,7 @@ public:
return *this;
}
// FIXME: Make this private (if possible) or at least rename it (http://crbug.com/432707).
inline float value() const
{
return getFloatValue();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment