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

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: Applied suggested changes 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..0e772a526583e616f31b0891b075391ebb458cdd 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,13 +3863,28 @@ void LayoutBox::ComputeInlineStaticDistance(
if (!logical_left.IsAuto() || !logical_right.IsAuto())
return;
+ LayoutObject* parent = child->Parent();
+ TextDirection parent_direction = parent->Style()->Direction();
+
+ // This method is using EnclosingBox() which is wrong for absolutely
+ // positioned grid items, as they rely on the grid area. So for grid items if
+ // both "left" and "right" properties are "auto", we can consider that one of
+ // them (depending on the direction) is simply "0".
+ if (parent->IsLayoutGrid() && parent == child->ContainingBlock()) {
+ if (parent_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();
// FIXME: The static distance computation has not been patched for mixed
// writing modes yet.
- if (child->Parent()->Style()->Direction() == TextDirection::kLtr) {
+ if (parent_direction == TextDirection::kLtr) {
LayoutUnit static_position = child->Layer()->StaticInlinePosition() -
container_block->BorderLogicalLeft();
for (LayoutObject* curr = child->Parent(); curr && curr != container_block;
@@ -4078,9 +4060,6 @@ void LayoutBox::ComputePositionedLogicalWidth(
}
}
- if (!Style()->HasStaticInlinePosition(is_horizontal))
- computed_values.position_ += ExtraInlineOffset();
-
computed_values.extent_ += borders_plus_padding;
}
@@ -4486,9 +4465,6 @@ void LayoutBox::ComputePositionedLogicalHeight(
}
}
- if (!Style()->HasStaticBlockPosition(IsHorizontalWritingMode()))
- computed_values.position_ += ExtraBlockOffset();
-
// Set final height value.
computed_values.extent_ += borders_plus_padding;
}
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBox.h ('k') | third_party/WebKit/Source/core/layout/LayoutGrid.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698