Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6114)

Unified Diff: Source/core/rendering/RenderBox.cpp

Issue 637033003: [CSS Grid Layout] Fix positioned grid children position and size (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Minor fix in a comment Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/rendering/RenderBox.cpp
diff --git a/Source/core/rendering/RenderBox.cpp b/Source/core/rendering/RenderBox.cpp
index 39befae260204bc7a2b5b40e9d6460cfa6e6109a..5a98fe12f3b3676faa67c2e32b6b0d74af46d445 100644
--- a/Source/core/rendering/RenderBox.cpp
+++ b/Source/core/rendering/RenderBox.cpp
@@ -2669,6 +2669,9 @@ LayoutUnit RenderBox::containingBlockLogicalWidthForPositioned(const RenderBoxMo
}
}
+ if (hasOverrideContainingBlockLogicalWidth())
+ return overrideContainingBlockContentLogicalWidth();
+
if (containingBlock->isBox())
return toRenderBox(containingBlock)->clientLogicalWidth();
@@ -2709,6 +2712,9 @@ LayoutUnit RenderBox::containingBlockLogicalHeightForPositioned(const RenderBoxM
}
}
+ if (hasOverrideContainingBlockLogicalHeight())
+ return overrideContainingBlockContentLogicalHeight();
+
if (containingBlock->isBox()) {
const RenderBlock* cb = containingBlock->isRenderBlock() ?
toRenderBlock(containingBlock) : containingBlock->containingBlock();
@@ -2735,14 +2741,37 @@ LayoutUnit RenderBox::containingBlockLogicalHeightForPositioned(const RenderBoxM
return heightResult;
}
+static LayoutUnit computeInlineStaticPositionForGridItem(Length& logicalLeft, Length& logicalRight, const RenderBox* child, LayoutUnit containerLogicalWidth)
+{
+ ASSERT(child->parent()->isRenderGrid());
Julien - ping for review 2014/11/11 17:27:35 I think this should be child->containingBlock()->i
+
+ LayoutUnit staticPosition = 0;
+ if (child->parent()->style()->direction() == LTR) {
Julien - ping for review 2014/11/11 17:27:35 Same comment.
+ if (!logicalLeft.isAuto())
+ staticPosition += valueForLength(logicalLeft, containerLogicalWidth);
+ else if (!logicalRight.isAuto())
+ staticPosition -= valueForLength(logicalRight, containerLogicalWidth);
+ } else {
+ if (!logicalRight.isAuto())
+ staticPosition += valueForLength(logicalRight, containerLogicalWidth);
+ else if (!logicalLeft.isAuto())
+ staticPosition -= valueForLength(logicalLeft, containerLogicalWidth);
+ }
+ return staticPosition;
+}
+
static void computeInlineStaticDistance(Length& logicalLeft, Length& logicalRight, const RenderBox* child, const RenderBoxModelObject* containerBlock, LayoutUnit containerLogicalWidth)
{
- if (!logicalLeft.isAuto() || !logicalRight.isAuto())
+ if ((!logicalLeft.isAuto() || !logicalRight.isAuto()) && !child->parent()->isRenderGrid())
return;
+ LayoutUnit staticPosition = 0;
+ if (child->parent()->isRenderGrid())
+ staticPosition = computeInlineStaticPositionForGridItem(logicalLeft, logicalRight, child, containerLogicalWidth);
+
// FIXME: The static distance computation has not been patched for mixed writing modes yet.
if (child->parent()->style()->direction() == LTR) {
- LayoutUnit staticPosition = child->layer()->staticInlinePosition() - containerBlock->borderLogicalLeft();
+ staticPosition += child->layer()->staticInlinePosition() - containerBlock->borderLogicalLeft();
for (RenderObject* curr = child->parent(); curr && curr != containerBlock; curr = curr->container()) {
if (curr->isBox()) {
staticPosition += toRenderBox(curr)->logicalLeft();
@@ -2760,7 +2789,7 @@ static void computeInlineStaticDistance(Length& logicalLeft, Length& logicalRigh
logicalLeft.setValue(Fixed, staticPosition);
} else {
RenderBox* enclosingBox = child->parent()->enclosingBox();
- LayoutUnit staticPosition = child->layer()->staticInlinePosition() + containerLogicalWidth + containerBlock->borderLogicalLeft();
+ staticPosition += child->layer()->staticInlinePosition() + containerLogicalWidth + containerBlock->borderLogicalLeft();
for (RenderObject* curr = child->parent(); curr; curr = curr->container()) {
if (curr->isBox()) {
if (curr != containerBlock) {
@@ -3103,13 +3132,29 @@ void RenderBox::computePositionedLogicalWidthUsing(Length logicalWidth, const Re
computeLogicalLeftPositionedOffset(computedValues.m_position, this, computedValues.m_extent, containerBlock, containerLogicalWidth);
}
-static void computeBlockStaticDistance(Length& logicalTop, Length& logicalBottom, const RenderBox* child, const RenderBoxModelObject* containerBlock)
+static LayoutUnit computeBlockStaticPositionForGridItem(Length& logicalTop, Length& logicalBottom, const RenderBox* child, LayoutUnit containerLogicalHeight)
{
- if (!logicalTop.isAuto() || !logicalBottom.isAuto())
+ ASSERT(child->parent()->isRenderGrid());
+
+ LayoutUnit staticPosition = 0;
+ if (!logicalTop.isAuto())
+ staticPosition += valueForLength(logicalTop, containerLogicalHeight);
+ else if (!logicalBottom.isAuto())
+ staticPosition -= valueForLength(logicalBottom, containerLogicalHeight);
+ return staticPosition;
+}
+
+static void computeBlockStaticDistance(Length& logicalTop, Length& logicalBottom, const RenderBox* child, const RenderBoxModelObject* containerBlock, LayoutUnit containerLogicalHeight)
+{
+ if ((!logicalTop.isAuto() || !logicalBottom.isAuto()) && !child->parent()->isRenderGrid())
return;
+ LayoutUnit staticLogicalTop = 0;
+ if (child->parent()->isRenderGrid())
+ staticLogicalTop = computeBlockStaticPositionForGridItem(logicalTop, logicalBottom, child, containerLogicalHeight);
+
// FIXME: The static distance computation has not been patched for mixed writing modes.
- LayoutUnit staticLogicalTop = child->layer()->staticBlockPosition() - containerBlock->borderBefore();
+ staticLogicalTop += child->layer()->staticBlockPosition() - containerBlock->borderBefore();
for (RenderObject* curr = child->parent(); curr && curr != containerBlock; curr = curr->container()) {
if (curr->isBox() && !curr->isTableRow())
staticLogicalTop += toRenderBox(curr)->logicalTop();
@@ -3162,7 +3207,7 @@ void RenderBox::computePositionedLogicalHeight(LogicalExtentComputedValues& comp
// see FIXME 1
// Calculate the static distance if needed.
- computeBlockStaticDistance(logicalTopLength, logicalBottomLength, this, containerBlock);
+ computeBlockStaticDistance(logicalTopLength, logicalBottomLength, this, containerBlock, containerLogicalHeight);
// Calculate constraint equation values for 'height' case.
LayoutUnit logicalHeight = computedValues.m_extent;
@@ -3568,7 +3613,7 @@ void RenderBox::computePositionedLogicalHeightReplaced(LogicalExtentComputedValu
* with the element's static position.
\*-----------------------------------------------------------------------*/
// see FIXME 1
- computeBlockStaticDistance(logicalTop, logicalBottom, this, containerBlock);
+ computeBlockStaticDistance(logicalTop, logicalBottom, this, containerBlock, containerLogicalHeight);
/*-----------------------------------------------------------------------*\
* 3. If 'bottom' is 'auto', replace any 'auto' on 'margin-top' or

Powered by Google App Engine
This is Rietveld 408576698