Title: [94737] trunk/Source/WebCore
- Revision
- 94737
- Author
- [email protected]
- Date
- 2011-09-07 17:50:24 -0700 (Wed, 07 Sep 2011)
Log Message
https://bugs.webkit.org/show_bug.cgi?id=67739
adjustRectForColumns is O(# of columns) when it can be O(1). Fix the slow performance of this
function by removing the loop and just computing the start and end column for a repaint rect
and uniting everything in between.
Reviewed by Dan Bernstein.
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::adjustRectForColumns):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (94736 => 94737)
--- trunk/Source/WebCore/ChangeLog 2011-09-08 00:26:51 UTC (rev 94736)
+++ trunk/Source/WebCore/ChangeLog 2011-09-08 00:50:24 UTC (rev 94737)
@@ -1,3 +1,16 @@
+2011-09-07 David Hyatt <[email protected]>
+
+ https://bugs.webkit.org/show_bug.cgi?id=67739
+
+ adjustRectForColumns is O(# of columns) when it can be O(1). Fix the slow performance of this
+ function by removing the loop and just computing the start and end column for a repaint rect
+ and uniting everything in between.
+
+ Reviewed by Dan Bernstein.
+
+ * rendering/RenderBlock.cpp:
+ (WebCore::RenderBlock::adjustRectForColumns):
+
2011-09-07 Sheriff Bot <[email protected]>
Unreviewed, rolling out r94714 and r94723.
Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (94736 => 94737)
--- trunk/Source/WebCore/rendering/RenderBlock.cpp 2011-09-08 00:26:51 UTC (rev 94736)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp 2011-09-08 00:50:24 UTC (rev 94737)
@@ -4607,32 +4607,44 @@
return;
ColumnInfo* colInfo = columnInfo();
-
- // Begin with a result rect that is empty.
- LayoutRect result;
// Determine which columns we intersect.
unsigned colCount = columnCount(colInfo);
if (!colCount)
return;
+
+ // Begin with a result rect that is empty.
+ LayoutRect result;
+
+ bool isHorizontal = isHorizontalWritingMode();
+ LayoutUnit beforeBorderPadding = borderBefore() + paddingBefore();
+ LayoutUnit colHeight = colInfo->columnHeight();
+ if (!colHeight)
+ return;
+
+ LayoutUnit startOffset = max(isHorizontal ? r.y() : r.x(), beforeBorderPadding);
+ LayoutUnit endOffset = min<LayoutUnit>(isHorizontal ? r.maxY() : r.maxX(), beforeBorderPadding + colCount * colHeight);
- LayoutUnit logicalLeft = logicalLeftOffsetForContent();
- LayoutUnit currLogicalOffset = 0;
+ unsigned startColumn = (startOffset - beforeBorderPadding) / colHeight;
+ unsigned endColumn = (endOffset - beforeBorderPadding) / colHeight;
- for (unsigned i = 0; i < colCount; i++) {
- LayoutRect colRect = columnRectAt(colInfo, i);
+ if (startColumn == endColumn) {
+ // The rect is fully contained within one column. Adjust for our offsets
+ // and repaint only that portion.
+ LayoutUnit logicalLeftOffset = logicalLeftOffsetForContent();
+ LayoutRect colRect = columnRectAt(colInfo, startColumn);
LayoutRect repaintRect = r;
- if (isHorizontalWritingMode()) {
- LayoutUnit currXOffset = colRect.x() - logicalLeft;
- repaintRect.move(currXOffset, currLogicalOffset);
- currLogicalOffset -= colRect.height();
- } else {
- LayoutUnit currYOffset = colRect.y() - logicalLeft;
- repaintRect.move(currLogicalOffset, currYOffset);
- currLogicalOffset -= colRect.width();
- }
+ if (isHorizontal)
+ repaintRect.move(colRect.x() - logicalLeftOffset, -startColumn * colHeight);
+ else
+ repaintRect.move(-startColumn * colHeight, colRect.y() - logicalLeftOffset);
repaintRect.intersect(colRect);
result.unite(repaintRect);
+ } else {
+ // We span multiple columns. We can just unite the start and end column to get the final
+ // repaint rect.
+ result.unite(columnRectAt(colInfo, startColumn));
+ result.unite(columnRectAt(colInfo, endColumn));
}
r = result;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes