Title: [134935] trunk/Source/WebCore
Revision
134935
Author
jchaffr...@webkit.org
Date
2012-11-16 05:32:18 -0800 (Fri, 16 Nov 2012)

Log Message

RenderGrid should have a function to resolve grid position
https://bugs.webkit.org/show_bug.cgi?id=102441

Reviewed by Ojan Vafai.

The code was doing this conversion implicitly inside RenderGrid::findChildLogicalPosition.
Also note that we also provided a fallback by returning LayoutPoint() (ie the (0, 0) position
on the grid) if we couldn't handle the value. The explicit conversion is needed in order to
support render areas and add a proper grid model to RenderGrid.

No expected change in behavior.

* rendering/RenderGrid.h:
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::resolveGridPosition):
Added this new function to handle the conversion. We re-use Length but should never see
a lot of the <length> values so I added some ASSERTs to enforce and catch that.

(WebCore::RenderGrid::findChildLogicalPosition):
Simplified the function now that it just use resolveGridPosition.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (134934 => 134935)


--- trunk/Source/WebCore/ChangeLog	2012-11-16 13:19:56 UTC (rev 134934)
+++ trunk/Source/WebCore/ChangeLog	2012-11-16 13:32:18 UTC (rev 134935)
@@ -1,3 +1,26 @@
+2012-11-16  Julien Chaffraix  <jchaffr...@webkit.org>
+
+        RenderGrid should have a function to resolve grid position
+        https://bugs.webkit.org/show_bug.cgi?id=102441
+
+        Reviewed by Ojan Vafai.
+
+        The code was doing this conversion implicitly inside RenderGrid::findChildLogicalPosition.
+        Also note that we also provided a fallback by returning LayoutPoint() (ie the (0, 0) position
+        on the grid) if we couldn't handle the value. The explicit conversion is needed in order to
+        support render areas and add a proper grid model to RenderGrid.
+
+        No expected change in behavior.
+
+        * rendering/RenderGrid.h:
+        * rendering/RenderGrid.cpp:
+        (WebCore::RenderGrid::resolveGridPosition):
+        Added this new function to handle the conversion. We re-use Length but should never see
+        a lot of the <length> values so I added some ASSERTs to enforce and catch that.
+
+        (WebCore::RenderGrid::findChildLogicalPosition):
+        Simplified the function now that it just use resolveGridPosition.
+
 2012-11-16  Ulan Degenbaev  <u...@chromium.org>
 
         [V8] Increment the amount of externally allocated memory for the receiving V8 isolate when transferring ArrayBuffer

Modified: trunk/Source/WebCore/rendering/RenderGrid.cpp (134934 => 134935)


--- trunk/Source/WebCore/rendering/RenderGrid.cpp	2012-11-16 13:19:56 UTC (rev 134934)
+++ trunk/Source/WebCore/rendering/RenderGrid.cpp	2012-11-16 13:32:18 UTC (rev 134935)
@@ -175,23 +175,47 @@
         setLogicalHeight(logicalHeight() + rowTracks[i].m_usedBreadth);
 }
 
-LayoutPoint RenderGrid::findChildLogicalPosition(RenderBox* child, const Vector<GridTrack>& columnTracks, const Vector<GridTrack>& rowTracks)
+size_t RenderGrid::resolveGridPosition(const Length& position) const
 {
-    Length column = child->style()->gridItemColumn();
-    Length row = child->style()->gridItemRow();
+    // FIXME: Handle other values for grid-{row,column} like ranges or line names.
+    switch (position.type()) {
+    case Fixed:
+        // FIXME: What does a non-positive integer mean for a column/row?
+        if (!position.isPositive())
+            return 0;
 
-    // FIXME: What does a non-positive integer mean for a column/row?
-    if (!column.isPositive() || !row.isPositive())
-        return LayoutPoint();
+        return position.intValue() - 1;
+    case Auto:
+        // FIXME: We should follow 'grid-auto-flow' for resolution.
+        // Until then, we use the 'grid-auto-flow: none' behavior (which is the default)
+        // and resolve 'auto' as the first row / column.
+        return 0;
+    case Relative:
+    case Percent:
+    case Intrinsic:
+    case MinIntrinsic:
+    case MinContent:
+    case MaxContent:
+    case FillAvailable:
+    case FitContent:
+    case Calculated:
+    case ViewportPercentageWidth:
+    case ViewportPercentageHeight:
+    case ViewportPercentageMin:
+    case Undefined:
+        break;
+    }
+    ASSERT_NOT_REACHED();
+    return 0;
+}
 
-    // FIXME: Handle other values for grid-{row,column} like ranges or line names.
-    if (!column.isFixed() || !row.isFixed())
-        return LayoutPoint();
+LayoutPoint RenderGrid::findChildLogicalPosition(RenderBox* child, const Vector<GridTrack>& columnTracks, const Vector<GridTrack>& rowTracks)
+{
+    size_t columnTrack = resolveGridPosition(child->style()->gridItemColumn());
+    size_t rowTrack = resolveGridPosition(child->style()->gridItemRow());
 
-    size_t columnTrack = static_cast<size_t>(column.intValue()) - 1;
-    size_t rowTrack = static_cast<size_t>(row.intValue()) - 1;
-
     LayoutPoint offset;
+    // FIXME: |columnTrack| and |rowTrack| should be smaller than our column / row count.
     for (size_t i = 0; i < columnTrack && i < columnTracks.size(); ++i)
         offset.setX(offset.x() + columnTracks[i].m_usedBreadth);
     for (size_t i = 0; i < rowTrack && i < rowTracks.size(); ++i)

Modified: trunk/Source/WebCore/rendering/RenderGrid.h (134934 => 134935)


--- trunk/Source/WebCore/rendering/RenderGrid.h	2012-11-16 13:19:56 UTC (rev 134934)
+++ trunk/Source/WebCore/rendering/RenderGrid.h	2012-11-16 13:32:18 UTC (rev 134935)
@@ -50,6 +50,7 @@
     void layoutGridItems();
 
     LayoutPoint findChildLogicalPosition(RenderBox*, const Vector<GridTrack>& columnTracks, const Vector<GridTrack>& rowTracks);
+    size_t resolveGridPosition(const Length&) const;
 };
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to