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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutBox.cpp

Issue 2665133003: [css-grid] Fix behavior of positioned items without specific dimensions (Closed)
Patch Set: Add comment requested in the review Created 3 years, 7 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: third_party/WebKit/Source/core/layout/LayoutBox.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBox.cpp b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
index dbf533cd0cb10eed0c1323ae9409b1a2c23b8edd..51855315f783e997338c332207ff216ec7cfaaea 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBox.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
@@ -75,9 +75,6 @@ namespace blink {
// Used by flexible boxes when flexing this element and by table cells.
typedef WTF::HashMap<const LayoutBox*, LayoutUnit> OverrideSizeMap;
-static OverrideSizeMap* g_extra_inline_offset_map = nullptr;
-static OverrideSizeMap* g_extra_block_offset_map = nullptr;
-
// Size of border belt for autoscroll. When mouse pointer in border belt,
// autoscroll is started.
static const int kAutoscrollBeltSize = 20;
@@ -124,7 +121,6 @@ PaintLayerType LayoutBox::LayerTypeRequired() const {
void LayoutBox::WillBeDestroyed() {
ClearOverrideSize();
ClearContainingBlockOverrideSize();
- ClearExtraInlineAndBlockOffests();
if (IsOutOfFlowPositioned())
LayoutBlock::RemovePositionedObject(this);
@@ -1445,35 +1441,6 @@ void LayoutBox::ClearOverrideContainingBlockContentLogicalHeight() {
false;
}
-LayoutUnit LayoutBox::ExtraInlineOffset() const {
- return g_extra_inline_offset_map ? g_extra_inline_offset_map->at(this)
- : LayoutUnit();
-}
-
-LayoutUnit LayoutBox::ExtraBlockOffset() const {
- return g_extra_block_offset_map ? g_extra_block_offset_map->at(this)
- : LayoutUnit();
-}
-
-void LayoutBox::SetExtraInlineOffset(LayoutUnit inline_offest) {
- if (!g_extra_inline_offset_map)
- g_extra_inline_offset_map = new OverrideSizeMap;
- g_extra_inline_offset_map->Set(this, inline_offest);
-}
-
-void LayoutBox::SetExtraBlockOffset(LayoutUnit block_offest) {
- if (!g_extra_block_offset_map)
- g_extra_block_offset_map = new OverrideSizeMap;
- g_extra_block_offset_map->Set(this, block_offest);
-}
-
-void LayoutBox::ClearExtraInlineAndBlockOffests() {
- if (g_extra_inline_offset_map)
- g_extra_inline_offset_map->erase(this);
- if (g_extra_block_offset_map)
- g_extra_block_offset_map->erase(this);
-}
-
LayoutUnit LayoutBox::AdjustBorderBoxLogicalWidthForBoxSizing(
float width) const {
LayoutUnit borders_plus_padding = CollapsedBorderAndCSSPaddingLogicalWidth();
@@ -3896,6 +3863,18 @@ void LayoutBox::ComputeInlineStaticDistance(
if (!logical_left.IsAuto() || !logical_right.IsAuto())
return;
+ // This method is using EnclosingBox() which is wrong for absolutely
+ // positioned gird items, as they rely on the grid area. So for grid items if
svillar 2017/05/08 11:18:10 Nit. gird->grid
Manuel Rego 2017/05/08 13:29:44 Fixed.
+ // both "left" and "right" properties are "auto", we can consider that one of
+ // them (depending on the direction) is simply "0".
+ if (child->IsGridItem() && child->ContainingBlock() == child->Parent()) {
jfernandez 2017/05/08 12:56:07 Wouldn't be better to use the child's parent inste
Manuel Rego 2017/05/08 13:29:44 Done.
+ if (child->Parent()->Style()->Direction() == TextDirection::kLtr)
+ logical_left.SetValue(kFixed, 0);
+ else
+ logical_right.SetValue(kFixed, 0);
+ return;
+ }
+
// For multicol we also need to keep track of the block position, since that
// determines which column we're in and thus affects the inline position.
LayoutUnit static_block_position = child->Layer()->StaticBlockPosition();
@@ -4078,9 +4057,6 @@ void LayoutBox::ComputePositionedLogicalWidth(
}
}
- if (!Style()->HasStaticInlinePosition(is_horizontal))
- computed_values.position_ += ExtraInlineOffset();
-
computed_values.extent_ += borders_plus_padding;
}
@@ -4486,9 +4462,6 @@ void LayoutBox::ComputePositionedLogicalHeight(
}
}
- if (!Style()->HasStaticBlockPosition(IsHorizontalWritingMode()))
- computed_values.position_ += ExtraBlockOffset();
-
// Set final height value.
computed_values.extent_ += borders_plus_padding;
}

Powered by Google App Engine
This is Rietveld 408576698