Title: [189037] trunk/Source/WebCore
Revision
189037
Author
mmaxfi...@apple.com
Date
2015-08-27 11:03:43 -0700 (Thu, 27 Aug 2015)

Log Message

Update Grid Layout to use fewer magic -1s
https://bugs.webkit.org/show_bug.cgi?id=148505

Reviewed by Javier Fernandez.

After r188873, there were still some -1s left in Grid Layout code. This patch cleans them
up after consulting with Javier Fernandez.

No new tests because there is no behavior change.

* rendering/RenderBox.cpp:
(WebCore::RenderBox::containingBlockLogicalWidthForContent):
(WebCore::RenderBox::containingBlockLogicalHeightForContent):
(WebCore::RenderBox::perpendicularContainingBlockLogicalHeight):
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::applyStretchAlignmentToChildIfNeeded):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (189036 => 189037)


--- trunk/Source/WebCore/ChangeLog	2015-08-27 17:54:29 UTC (rev 189036)
+++ trunk/Source/WebCore/ChangeLog	2015-08-27 18:03:43 UTC (rev 189037)
@@ -1,3 +1,22 @@
+2015-08-27  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        Update Grid Layout to use fewer magic -1s
+        https://bugs.webkit.org/show_bug.cgi?id=148505
+
+        Reviewed by Javier Fernandez.
+
+        After r188873, there were still some -1s left in Grid Layout code. This patch cleans them
+        up after consulting with Javier Fernandez.
+
+        No new tests because there is no behavior change.
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::containingBlockLogicalWidthForContent):
+        (WebCore::RenderBox::containingBlockLogicalHeightForContent):
+        (WebCore::RenderBox::perpendicularContainingBlockLogicalHeight):
+        * rendering/RenderGrid.cpp:
+        (WebCore::RenderGrid::applyStretchAlignmentToChildIfNeeded):
+
 2015-08-27  Brian Burg  <bb...@apple.com>
 
         Web Inspector: FrontendChannel should know its own connection type

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (189036 => 189037)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2015-08-27 17:54:29 UTC (rev 189036)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2015-08-27 18:03:43 UTC (rev 189037)
@@ -1879,8 +1879,10 @@
 LayoutUnit RenderBox::containingBlockLogicalWidthForContent() const
 {
 #if ENABLE(CSS_GRID_LAYOUT)
-    if (hasOverrideContainingBlockLogicalWidth())
-        return overrideContainingBlockContentLogicalWidth().valueOr(-1);
+    if (hasOverrideContainingBlockLogicalWidth()) {
+        if (auto overrideLogicalWidth = overrideContainingBlockContentLogicalWidth())
+            return overrideLogicalWidth.value();
+    }
 #endif
 
     if (RenderBlock* cb = containingBlock())
@@ -1891,8 +1893,10 @@
 LayoutUnit RenderBox::containingBlockLogicalHeightForContent(AvailableLogicalHeightType heightType) const
 {
 #if ENABLE(CSS_GRID_LAYOUT)
-    if (hasOverrideContainingBlockLogicalHeight())
-        return overrideContainingBlockContentLogicalHeight().valueOr(-1);
+    if (hasOverrideContainingBlockLogicalHeight()) {
+        if (auto overrideLogicalHeight = overrideContainingBlockContentLogicalHeight())
+            return overrideLogicalHeight.value();
+    }
 #endif
 
     if (RenderBlock* cb = containingBlock())
@@ -1932,8 +1936,10 @@
 LayoutUnit RenderBox::perpendicularContainingBlockLogicalHeight() const
 {
 #if ENABLE(CSS_GRID_LAYOUT)
-    if (hasOverrideContainingBlockLogicalHeight())
-        return overrideContainingBlockContentLogicalHeight().valueOr(-1);
+    if (hasOverrideContainingBlockLogicalHeight()) {
+        if (auto overrideLogicalHeight = overrideContainingBlockContentLogicalHeight())
+            return overrideLogicalHeight.value();
+    }
 #endif
 
     RenderBlock* cb = containingBlock();

Modified: trunk/Source/WebCore/rendering/RenderGrid.cpp (189036 => 189037)


--- trunk/Source/WebCore/rendering/RenderGrid.cpp	2015-08-27 17:54:29 UTC (rev 189036)
+++ trunk/Source/WebCore/rendering/RenderGrid.cpp	2015-08-27 18:03:43 UTC (rev 189037)
@@ -1298,6 +1298,8 @@
 // FIXME: This logic is shared by RenderFlexibleBox, so it should be moved to RenderBox.
 void RenderGrid::applyStretchAlignmentToChildIfNeeded(RenderBox& child)
 {
+    ASSERT(child.overrideContainingBlockContentLogicalWidth() && child.overrideContainingBlockContentLogicalHeight());
+
     // We clear both width and height override values because we will decide now whether they
     // are allowed or not, evaluating the conditions which might have changed since the old
     // values were set.
@@ -1310,11 +1312,11 @@
     bool allowedToStretchChildAlongRowAxis = hasAutoSizeInRowAxis && !childStyle.marginStartUsing(&gridStyle).isAuto() && !childStyle.marginEndUsing(&gridStyle).isAuto();
     if (!allowedToStretchChildAlongRowAxis || RenderStyle::resolveJustification(gridStyle, childStyle, ItemPositionStretch) != ItemPositionStretch) {
         bool hasAutoMinSizeInRowAxis = isHorizontalMode ? childStyle.minWidth().isAuto() : childStyle.minHeight().isAuto();
-        bool canShrinkToFitInRowAxisForChild = !hasAutoMinSizeInRowAxis || (child.overrideContainingBlockContentLogicalWidth() && child.minPreferredLogicalWidth() <= child.overrideContainingBlockContentLogicalWidth().value());
+        bool canShrinkToFitInRowAxisForChild = !hasAutoMinSizeInRowAxis || child.minPreferredLogicalWidth() <= child.overrideContainingBlockContentLogicalWidth().value();
         // TODO(lajava): how to handle orthogonality in this case ?.
         // TODO(lajava): grid track sizing and positioning do not support orthogonal modes yet.
         if (hasAutoSizeInRowAxis && canShrinkToFitInRowAxisForChild) {
-            LayoutUnit childWidthToFitContent = std::max(std::min(child.maxPreferredLogicalWidth(), child.overrideContainingBlockContentLogicalWidth().valueOr(-1) - child.marginLogicalWidth()), child.minPreferredLogicalWidth());
+            LayoutUnit childWidthToFitContent = std::max(std::min(child.maxPreferredLogicalWidth(), child.overrideContainingBlockContentLogicalWidth().value() - child.marginLogicalWidth()), child.minPreferredLogicalWidth());
             LayoutUnit desiredLogicalWidth = child.constrainLogicalHeightByMinMax(childWidthToFitContent, Nullopt);
             child.setOverrideLogicalContentWidth(desiredLogicalWidth - child.borderAndPaddingLogicalWidth());
             if (desiredLogicalWidth != child.logicalWidth())
@@ -1328,7 +1330,7 @@
         // TODO (lajava): If the child has orthogonal flow, then it already has an override height set, so use it.
         // TODO (lajava): grid track sizing and positioning do not support orthogonal modes yet.
         if (child.isHorizontalWritingMode() == isHorizontalMode) {
-            LayoutUnit stretchedLogicalHeight = availableAlignmentSpaceForChildBeforeStretching(child.overrideContainingBlockContentLogicalHeight().valueOr(-1), child);
+            LayoutUnit stretchedLogicalHeight = availableAlignmentSpaceForChildBeforeStretching(child.overrideContainingBlockContentLogicalHeight().value(), child);
             LayoutUnit desiredLogicalHeight = child.constrainLogicalHeightByMinMax(stretchedLogicalHeight, Nullopt);
             child.setOverrideLogicalContentHeight(desiredLogicalHeight - child.borderAndPaddingLogicalHeight());
             if (desiredLogicalHeight != child.logicalHeight()) {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to