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

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

Issue 2455093002: [css-align] Don't resolve 'auto' values for computed style. (Closed)
Patch Set: 'auto' is not valid for justify-items. 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/LayoutGrid.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutGrid.cpp b/third_party/WebKit/Source/core/layout/LayoutGrid.cpp
index f955002399cbeb49112738b948ec1f5b00a557b2..263f3abae4db187de05857a3e181dc050c139f31 100644
--- a/third_party/WebKit/Source/core/layout/LayoutGrid.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutGrid.cpp
@@ -97,12 +97,78 @@ void LayoutGrid::RemoveChild(LayoutObject* child) {
DirtyGrid();
}
+bool LayoutGrid::SelfAlignmentChangedToStretchInRowAxis(
+ const ComputedStyle& old_style,
+ const ComputedStyle& new_style,
+ const LayoutBox& child) {
+ return child.StyleRef()
+ .ResolvedJustifySelf(SelfAlignmentNormalBehavior(&child),
+ &old_style)
+ .GetPosition() != kItemPositionStretch &&
+ child.StyleRef()
+ .ResolvedJustifySelf(SelfAlignmentNormalBehavior(&child),
+ &new_style)
+ .GetPosition() == kItemPositionStretch;
+}
+
+bool LayoutGrid::SelfAlignmentChangedFromStretchInRowAxis(
+ const ComputedStyle& old_style,
+ const ComputedStyle& new_style,
+ const LayoutBox& child) {
+ return child.StyleRef()
+ .ResolvedJustifySelf(SelfAlignmentNormalBehavior(&child),
+ &old_style)
+ .GetPosition() == kItemPositionStretch &&
+ child.StyleRef()
+ .ResolvedJustifySelf(SelfAlignmentNormalBehavior(&child),
+ &new_style)
+ .GetPosition() != kItemPositionStretch;
+}
+
+bool LayoutGrid::SelfAlignmentChangedFromStretchInColumnAxis(
+ const ComputedStyle& old_style,
+ const ComputedStyle& new_style,
+ const LayoutBox& child) {
+ return child.StyleRef()
+ .ResolvedAlignSelf(SelfAlignmentNormalBehavior(&child),
+ &old_style)
+ .GetPosition() == kItemPositionStretch &&
+ child.StyleRef()
+ .ResolvedAlignSelf(SelfAlignmentNormalBehavior(&child),
+ &new_style)
+ .GetPosition() != kItemPositionStretch;
+}
svillar 2017/05/25 08:13:09 Very compact but impossible to read. Could we add
jfernandez 2017/05/25 11:25:15 Done.
+
void LayoutGrid::StyleDidChange(StyleDifference diff,
const ComputedStyle* old_style) {
LayoutBlock::StyleDidChange(diff, old_style);
if (!old_style)
return;
+ const ComputedStyle& new_style = StyleRef();
+ if (old_style &&
+ old_style->ResolvedAlignItems(SelfAlignmentNormalBehavior(this))
+ .GetPosition() == kItemPositionStretch &&
+ diff.NeedsFullLayout()) {
+ // Grid items that were not previously stretched in row-axis need to be
+ // relayed out so we can compute new available space.
+ // Grid items that were previously stretching in column-axis need to be
+ // relayed out so we can compute new available space.
+ // This is only necessary for stretching since other alignment values don't
+ // change the size of the box.
+ for (LayoutBox* child = FirstInFlowChildBox(); child;
+ child = child->NextInFlowSiblingBox()) {
+ if (SelfAlignmentChangedToStretchInRowAxis(*old_style, new_style,
+ *child) ||
+ SelfAlignmentChangedFromStretchInRowAxis(*old_style, new_style,
+ *child) ||
+ SelfAlignmentChangedFromStretchInColumnAxis(*old_style, new_style,
+ *child)) {
+ child->SetNeedsLayout(LayoutInvalidationReason::kGridChanged);
svillar 2017/05/25 08:13:09 Shouldn't we clear the stretch overrides here?
jfernandez 2017/05/25 11:25:15 Well, I'd rather let the Grid layout logic do it w
+ }
+ }
+ }
+
// FIXME: The following checks could be narrowed down if we kept track of
// which type of grid items we have:
// - explicit grid size changes impact negative explicitely positioned and
@@ -1530,26 +1596,12 @@ LayoutUnit LayoutGrid::AvailableAlignmentSpaceForChildBeforeStretching(
StyleSelfAlignmentData LayoutGrid::AlignSelfForChild(
const LayoutBox& child) const {
- if (!child.IsAnonymous()) {
- return child.StyleRef().ResolvedAlignSelf(
- SelfAlignmentNormalBehavior(&child));
- }
- // All the 'auto' values has been solved by the StyleAdjuster, but it's
- // possible that some grid items generate Anonymous boxes, which need to be
- // solved during layout.
return child.StyleRef().ResolvedAlignSelf(SelfAlignmentNormalBehavior(&child),
Style());
}
StyleSelfAlignmentData LayoutGrid::JustifySelfForChild(
const LayoutBox& child) const {
- if (!child.IsAnonymous()) {
- return child.StyleRef().ResolvedJustifySelf(
- SelfAlignmentNormalBehavior(&child));
- }
- // All the 'auto' values has been solved by the StyleAdjuster, but it's
- // possible that some grid items generate Anonymous boxes, which need to be
- // solved during layout.
return child.StyleRef().ResolvedJustifySelf(
SelfAlignmentNormalBehavior(&child), Style());
}
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutGrid.h ('k') | third_party/WebKit/Source/core/style/ComputedStyle.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698