Title: [163166] trunk/Source/WebCore
- Revision
- 163166
- Author
- [email protected]
- Date
- 2014-01-31 00:10:11 -0800 (Fri, 31 Jan 2014)
Log Message
[CSS Grid Layout] Do log(n) search in the named line vectors when positioning named line spans.
https://bugs.webkit.org/show_bug.cgi?id=125396
Patch by László Langó <[email protected]> on 2014-01-30
Reviewed by Andreas Kling.
Implement the suggested FIXMEs and do a log search in the named line
vectors. This maintains the previous (somewhat tricky) behavior by
using std::lower_bound and std::upper_bound. No difference in existing
performance tests, but should scale much better for big grids.
Backported from Blink:
https://chromium.googlesource.com/chromium/blink/+/9fc477af0be708c490a6b90e65e412b0c22b161f
No new tests, no behavior change.
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::resolveRowStartColumnStartNamedGridLinePositionAgainstOppositePosition):
(WebCore::RenderGrid::resolveRowEndColumnEndNamedGridLinePositionAgainstOppositePosition):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (163165 => 163166)
--- trunk/Source/WebCore/ChangeLog 2014-01-31 08:09:07 UTC (rev 163165)
+++ trunk/Source/WebCore/ChangeLog 2014-01-31 08:10:11 UTC (rev 163166)
@@ -1,3 +1,24 @@
+2014-01-30 László Langó <[email protected]>
+
+ [CSS Grid Layout] Do log(n) search in the named line vectors when positioning named line spans.
+ https://bugs.webkit.org/show_bug.cgi?id=125396
+
+ Reviewed by Andreas Kling.
+
+ Implement the suggested FIXMEs and do a log search in the named line
+ vectors. This maintains the previous (somewhat tricky) behavior by
+ using std::lower_bound and std::upper_bound. No difference in existing
+ performance tests, but should scale much better for big grids.
+
+ Backported from Blink:
+ https://chromium.googlesource.com/chromium/blink/+/9fc477af0be708c490a6b90e65e412b0c22b161f
+
+ No new tests, no behavior change.
+
+ * rendering/RenderGrid.cpp:
+ (WebCore::RenderGrid::resolveRowStartColumnStartNamedGridLinePositionAgainstOppositePosition):
+ (WebCore::RenderGrid::resolveRowEndColumnEndNamedGridLinePositionAgainstOppositePosition):
+
2014-01-31 László Langó <[email protected]>
Fix table sizing when 'max-width' is used.
Modified: trunk/Source/WebCore/rendering/RenderGrid.cpp (163165 => 163166)
--- trunk/Source/WebCore/rendering/RenderGrid.cpp 2014-01-31 08:09:07 UTC (rev 163165)
+++ trunk/Source/WebCore/rendering/RenderGrid.cpp 2014-01-31 08:10:11 UTC (rev 163166)
@@ -979,9 +979,10 @@
{
// The grid line inequality needs to be strict (which doesn't match the after / end case) because |resolvedOppositePosition|
// is already converted to an index in our grid representation (ie one was removed from the grid line to account for the side).
- // FIXME: This could be a binary search as |gridLines| is ordered.
- int firstLineBeforeOppositePositionIndex = gridLines.size() - 1;
- for (; firstLineBeforeOppositePositionIndex >= 0 && gridLines[firstLineBeforeOppositePositionIndex] > resolvedOppositePosition; --firstLineBeforeOppositePositionIndex) { }
+ size_t firstLineBeforeOppositePositionIndex = 0;
+ const size_t* firstLineBeforeOppositePosition = std::lower_bound(gridLines.begin(), gridLines.end(), resolvedOppositePosition);
+ if (firstLineBeforeOppositePosition != gridLines.end())
+ firstLineBeforeOppositePositionIndex = firstLineBeforeOppositePosition - gridLines.begin();
size_t gridLineIndex = std::max<int>(0, firstLineBeforeOppositePositionIndex - position.spanPosition() + 1);
size_t resolvedGridLinePosition = gridLines[gridLineIndex];
@@ -992,9 +993,10 @@
PassOwnPtr<GridSpan> RenderGrid::resolveRowEndColumnEndNamedGridLinePositionAgainstOppositePosition(size_t resolvedOppositePosition, const GridPosition& position, const Vector<size_t>& gridLines) const
{
- // FIXME: This could be a binary search as |gridLines| is ordered.
- size_t firstLineAfterOppositePositionIndex = 0;
- for (; firstLineAfterOppositePositionIndex < gridLines.size() && gridLines[firstLineAfterOppositePositionIndex] <= resolvedOppositePosition; ++firstLineAfterOppositePositionIndex) { }
+ size_t firstLineAfterOppositePositionIndex = gridLines.size() - 1;
+ const size_t* firstLineAfterOppositePosition = std::upper_bound(gridLines.begin(), gridLines.end(), resolvedOppositePosition);
+ if (firstLineAfterOppositePosition != gridLines.end())
+ firstLineAfterOppositePositionIndex = firstLineAfterOppositePosition - gridLines.begin();
size_t gridLineIndex = std::min(gridLines.size() - 1, firstLineAfterOppositePositionIndex + position.spanPosition() - 1);
size_t resolvedGridLinePosition = adjustGridPositionForRowEndColumnEndSide(gridLines[gridLineIndex]);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes