- Revision
- 223403
- Author
- [email protected]
- Date
- 2017-10-16 06:28:18 -0700 (Mon, 16 Oct 2017)
Log Message
Merge r222441 - [css-grid] Small refactoring adding RenderGrid::contentAlignment()
https://bugs.webkit.org/show_bug.cgi?id=177130
Reviewed by Sergio Villar Senin.
As a follow-up of r221931, this patch does a small refactoring
adding a new method RenderGrid::contentAlignment()
that is used from RenderGrid and GridTrackSizingAlgorithm.
No new tests, no change of behavior.
* rendering/GridTrackSizingAlgorithm.cpp:
(WebCore::GridTrackSizingAlgorithm::stretchAutoTracks):
* rendering/RenderGrid.cpp:
(WebCore::contentAlignmentNormalBehaviorGrid):
(WebCore::RenderGrid::contentAlignment const):
(WebCore::RenderGrid::computeContentPositionAndDistributionOffset const):
(WebCore::RenderGrid::contentAlignmentNormalBehaviorGrid): Deleted.
* rendering/RenderGrid.h:
* rendering/style/RenderStyle.cpp:
(WebCore::resolvedContentAlignment):
(WebCore::RenderStyle::resolvedAlignContent const):
(WebCore::RenderStyle::resolvedJustifyContent const):
* rendering/style/RenderStyle.h:
Modified Paths
Diff
Modified: releases/WebKitGTK/webkit-2.18/Source/WebCore/ChangeLog (223402 => 223403)
--- releases/WebKitGTK/webkit-2.18/Source/WebCore/ChangeLog 2017-10-16 13:16:27 UTC (rev 223402)
+++ releases/WebKitGTK/webkit-2.18/Source/WebCore/ChangeLog 2017-10-16 13:28:18 UTC (rev 223403)
@@ -1,5 +1,32 @@
2017-09-25 Manuel Rego Casasnovas <[email protected]>
+ [css-grid] Small refactoring adding RenderGrid::contentAlignment()
+ https://bugs.webkit.org/show_bug.cgi?id=177130
+
+ Reviewed by Sergio Villar Senin.
+
+ As a follow-up of r221931, this patch does a small refactoring
+ adding a new method RenderGrid::contentAlignment()
+ that is used from RenderGrid and GridTrackSizingAlgorithm.
+
+ No new tests, no change of behavior.
+
+ * rendering/GridTrackSizingAlgorithm.cpp:
+ (WebCore::GridTrackSizingAlgorithm::stretchAutoTracks):
+ * rendering/RenderGrid.cpp:
+ (WebCore::contentAlignmentNormalBehaviorGrid):
+ (WebCore::RenderGrid::contentAlignment const):
+ (WebCore::RenderGrid::computeContentPositionAndDistributionOffset const):
+ (WebCore::RenderGrid::contentAlignmentNormalBehaviorGrid): Deleted.
+ * rendering/RenderGrid.h:
+ * rendering/style/RenderStyle.cpp:
+ (WebCore::resolvedContentAlignment):
+ (WebCore::RenderStyle::resolvedAlignContent const):
+ (WebCore::RenderStyle::resolvedJustifyContent const):
+ * rendering/style/RenderStyle.h:
+
+2017-09-25 Manuel Rego Casasnovas <[email protected]>
+
[css-grid] fit-content() tracks shouldn't stretch
https://bugs.webkit.org/show_bug.cgi?id=177300
Modified: releases/WebKitGTK/webkit-2.18/Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp (223402 => 223403)
--- releases/WebKitGTK/webkit-2.18/Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp 2017-10-16 13:16:27 UTC (rev 223402)
+++ releases/WebKitGTK/webkit-2.18/Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp 2017-10-16 13:28:18 UTC (rev 223403)
@@ -1071,14 +1071,11 @@
void GridTrackSizingAlgorithm::stretchAutoTracks()
{
- if (m_autoSizedTracksForStretchIndex.isEmpty())
- return;
-
auto currentFreeSpace = freeSpace(m_direction);
- if (!currentFreeSpace
+ if (m_autoSizedTracksForStretchIndex.isEmpty()
+ || !currentFreeSpace
|| currentFreeSpace.value() <= 0
- || (m_direction == ForColumns && m_renderGrid->style().resolvedJustifyContentDistribution(m_renderGrid->contentAlignmentNormalBehaviorGrid()) != ContentDistributionStretch)
- || (m_direction == ForRows && m_renderGrid->style().resolvedAlignContentDistribution(m_renderGrid->contentAlignmentNormalBehaviorGrid()) != ContentDistributionStretch))
+ || (m_renderGrid->contentAlignment(m_direction).distribution() != ContentDistributionStretch))
return;
Vector<GridTrack>& allTracks = tracks(m_direction);
Modified: releases/WebKitGTK/webkit-2.18/Source/WebCore/rendering/RenderGrid.cpp (223402 => 223403)
--- releases/WebKitGTK/webkit-2.18/Source/WebCore/rendering/RenderGrid.cpp 2017-10-16 13:16:27 UTC (rev 223402)
+++ releases/WebKitGTK/webkit-2.18/Source/WebCore/rendering/RenderGrid.cpp 2017-10-16 13:28:18 UTC (rev 223403)
@@ -877,7 +877,7 @@
return tracks;
}
-const StyleContentAlignmentData& RenderGrid::contentAlignmentNormalBehaviorGrid()
+static const StyleContentAlignmentData& contentAlignmentNormalBehaviorGrid()
{
static const StyleContentAlignmentData normalBehavior = {ContentPositionNormal, ContentDistributionStretch};
return normalBehavior;
@@ -1581,19 +1581,23 @@
return ContentAlignmentData::defaultOffsets();
}
+StyleContentAlignmentData RenderGrid::contentAlignment(GridTrackSizingDirection direction) const
+{
+ return direction == ForColumns ? style().resolvedJustifyContent(contentAlignmentNormalBehaviorGrid()) : style().resolvedAlignContent(contentAlignmentNormalBehaviorGrid());
+}
+
ContentAlignmentData RenderGrid::computeContentPositionAndDistributionOffset(GridTrackSizingDirection direction, const LayoutUnit& availableFreeSpace, unsigned numberOfGridTracks) const
{
bool isRowAxis = direction == ForColumns;
- auto position = isRowAxis ? style().resolvedJustifyContentPosition(contentAlignmentNormalBehaviorGrid()) : style().resolvedAlignContentPosition(contentAlignmentNormalBehaviorGrid());
- auto distribution = isRowAxis ? style().resolvedJustifyContentDistribution(contentAlignmentNormalBehaviorGrid()) : style().resolvedAlignContentDistribution(contentAlignmentNormalBehaviorGrid());
+ auto contentAlignmentData = contentAlignment(direction);
+ auto position = contentAlignmentData.position();
// If <content-distribution> value can't be applied, 'position' will become the associated
// <content-position> fallback value.
- auto contentAlignment = contentDistributionOffset(availableFreeSpace, position, distribution, numberOfGridTracks);
+ auto contentAlignment = contentDistributionOffset(availableFreeSpace, position, contentAlignmentData.distribution(), numberOfGridTracks);
if (contentAlignment.isValid())
return contentAlignment;
- auto overflow = (isRowAxis ? style().justifyContent() : style().alignContent()).overflow();
- if (availableFreeSpace <= 0 && overflow == OverflowAlignmentSafe)
+ if (availableFreeSpace <= 0 && contentAlignmentData.overflow() == OverflowAlignmentSafe)
return {0, 0};
switch (position) {
Modified: releases/WebKitGTK/webkit-2.18/Source/WebCore/rendering/RenderGrid.h (223402 => 223403)
--- releases/WebKitGTK/webkit-2.18/Source/WebCore/rendering/RenderGrid.h 2017-10-16 13:16:27 UTC (rev 223402)
+++ releases/WebKitGTK/webkit-2.18/Source/WebCore/rendering/RenderGrid.h 2017-10-16 13:28:18 UTC (rev 223403)
@@ -65,7 +65,7 @@
bool isOrthogonalChild(const RenderBox&) const;
LayoutUnit guttersSize(const Grid&, GridTrackSizingDirection, unsigned startLine, unsigned span, std::optional<LayoutUnit> availableSize) const;
- static const StyleContentAlignmentData& contentAlignmentNormalBehaviorGrid();
+ StyleContentAlignmentData contentAlignment(GridTrackSizingDirection) const;
protected:
ItemPosition selfAlignmentNormalBehavior(const RenderBox* child = nullptr) const override
Modified: releases/WebKitGTK/webkit-2.18/Source/WebCore/rendering/style/RenderStyle.cpp (223402 => 223403)
--- releases/WebKitGTK/webkit-2.18/Source/WebCore/rendering/style/RenderStyle.cpp 2017-10-16 13:16:27 UTC (rev 223402)
+++ releases/WebKitGTK/webkit-2.18/Source/WebCore/rendering/style/RenderStyle.cpp 2017-10-16 13:28:18 UTC (rev 223403)
@@ -280,6 +280,23 @@
return parentStyle->resolvedJustifyItems(normalValueBehaviour);
}
+static inline StyleContentAlignmentData resolvedContentAlignment(const StyleContentAlignmentData& value, const StyleContentAlignmentData& normalValueBehavior)
+{
+ return (value.position() == ContentPositionNormal && value.distribution() == ContentDistributionDefault) ? normalValueBehavior : value;
+}
+
+StyleContentAlignmentData RenderStyle::resolvedAlignContent(const StyleContentAlignmentData& normalValueBehavior) const
+{
+ // We will return the behaviour of 'normal' value if needed, which is specific of each layout model.
+ return resolvedContentAlignment(alignContent(), normalValueBehavior);
+}
+
+StyleContentAlignmentData RenderStyle::resolvedJustifyContent(const StyleContentAlignmentData& normalValueBehavior) const
+{
+ // We will return the behaviour of 'normal' value if needed, which is specific of each layout model.
+ return resolvedContentAlignment(justifyContent(), normalValueBehavior);
+}
+
static inline ContentPosition resolvedContentAlignmentPosition(const StyleContentAlignmentData& value, const StyleContentAlignmentData& normalValueBehavior)
{
return (value.position() == ContentPositionNormal && value.distribution() == ContentDistributionDefault) ? normalValueBehavior.position() : value.position();
Modified: releases/WebKitGTK/webkit-2.18/Source/WebCore/rendering/style/RenderStyle.h (223402 => 223403)
--- releases/WebKitGTK/webkit-2.18/Source/WebCore/rendering/style/RenderStyle.h 2017-10-16 13:16:27 UTC (rev 223402)
+++ releases/WebKitGTK/webkit-2.18/Source/WebCore/rendering/style/RenderStyle.h 2017-10-16 13:28:18 UTC (rev 223403)
@@ -166,8 +166,10 @@
ContentDistributionType resolvedAlignContentDistribution(const StyleContentAlignmentData& normalValueBehavior) const;
StyleSelfAlignmentData resolvedAlignItems(ItemPosition normalValueBehaviour) const;
StyleSelfAlignmentData resolvedAlignSelf(const RenderStyle* parentStyle, ItemPosition normalValueBehaviour) const;
+ StyleContentAlignmentData resolvedAlignContent(const StyleContentAlignmentData& normalValueBehaviour) const;
StyleSelfAlignmentData resolvedJustifyItems(ItemPosition normalValueBehaviour) const;
StyleSelfAlignmentData resolvedJustifySelf(const RenderStyle* parentStyle, ItemPosition normalValueBehaviour) const;
+ StyleContentAlignmentData resolvedJustifyContent(const StyleContentAlignmentData& normalValueBehaviour) const;
PseudoId styleType() const { return static_cast<PseudoId>(m_nonInheritedFlags.styleType); }
void setStyleType(PseudoId styleType) { m_nonInheritedFlags.styleType = styleType; }