Diff
Modified: trunk/Source/WebCore/ChangeLog (90832 => 90833)
--- trunk/Source/WebCore/ChangeLog 2011-07-12 18:37:09 UTC (rev 90832)
+++ trunk/Source/WebCore/ChangeLog 2011-07-12 18:42:18 UTC (rev 90833)
@@ -1,3 +1,47 @@
+2011-07-12 Emil A Eklund <[email protected]>
+
+ Switch preferred width/height and columns to to new layout types
+ https://bugs.webkit.org/show_bug.cgi?id=64329
+
+ Reviewed by Eric Seidel.
+
+ No new tests, no new functionality.
+
+ * rendering/LayoutTypes.h:
+ (WebCore::ceiledLayoutUnit):
+ Add ceiledLayoutUnit to go with the floored version.
+
+ * rendering/RenderBlock.cpp:
+ (WebCore::RenderBlock::adjustRectForColumns):
+ (WebCore::RenderBlock::flipForWritingModeIncludingColumns):
+ (WebCore::RenderBlock::adjustStartEdgeForWritingModeIncludingColumns):
+ Rename rect version of flipForWritingModeIncludingColumns to
+ adjustStartEdgeForWritingModeIncludingColumns as it adjust the start edge
+ and does not flip the rect.
+
+ (WebCore::RenderBlock::adjustForColumns):
+ (WebCore::updatePreferredWidth):
+ * rendering/RenderBlock.h:
+ * rendering/RenderBox.cpp:
+ (WebCore::RenderBox::minPreferredLogicalWidth):
+ (WebCore::RenderBox::maxPreferredLogicalWidth):
+ (WebCore::RenderBox::offsetFromContainer):
+ (WebCore::RenderBox::computePercentageLogicalHeight):
+ (WebCore::RenderBox::flipForWritingMode):
+ (WebCore::RenderBox::flipForWritingModeIncludingColumns):
+ * rendering/RenderBox.h:
+ * rendering/RenderListBox.cpp:
+ (WebCore::RenderListBox::itemBoundingBoxRect):
+ * rendering/RenderListBox.h:
+ * rendering/RenderObject.h:
+ (WebCore::RenderObject::minPreferredLogicalWidth):
+ (WebCore::RenderObject::maxPreferredLogicalWidth):
+ (WebCore::RenderObject::adjustForColumns):
+ * rendering/RenderReplaced.cpp:
+ (WebCore::RenderReplaced::computeReplacedLogicalWidth):
+ (WebCore::RenderReplaced::computeReplacedLogicalHeight):
+ * rendering/TableLayout.h:
+
2011-07-12 Levi Weintraub <[email protected]>
Change roundedIntRect to roundedRect
Modified: trunk/Source/WebCore/rendering/LayoutTypes.h (90832 => 90833)
--- trunk/Source/WebCore/rendering/LayoutTypes.h 2011-07-12 18:37:09 UTC (rev 90832)
+++ trunk/Source/WebCore/rendering/LayoutTypes.h 2011-07-12 18:42:18 UTC (rev 90833)
@@ -71,6 +71,11 @@
return lroundf(value);
}
+inline LayoutUnit ceiledLayoutUnit(float value)
+{
+ return ceilf(value);
+}
+
inline LayoutSize toLayoutSize(const LayoutPoint& p)
{
return LayoutSize(p.x(), p.y());
Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (90832 => 90833)
--- trunk/Source/WebCore/rendering/RenderBlock.cpp 2011-07-12 18:37:09 UTC (rev 90832)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp 2011-07-12 18:42:18 UTC (rev 90833)
@@ -4494,7 +4494,7 @@
}
}
-void RenderBlock::adjustRectForColumns(IntRect& r) const
+void RenderBlock::adjustRectForColumns(LayoutRect& r) const
{
// Just bail if we have no columns.
if (!hasColumns())
@@ -4503,25 +4503,25 @@
ColumnInfo* colInfo = columnInfo();
// Begin with a result rect that is empty.
- IntRect result;
+ LayoutRect result;
// Determine which columns we intersect.
unsigned colCount = columnCount(colInfo);
if (!colCount)
return;
- int logicalLeft = logicalLeftOffsetForContent();
- int currLogicalOffset = 0;
+ LayoutUnit logicalLeft = logicalLeftOffsetForContent();
+ LayoutUnit currLogicalOffset = 0;
for (unsigned i = 0; i < colCount; i++) {
- IntRect colRect = columnRectAt(colInfo, i);
- IntRect repaintRect = r;
+ LayoutRect colRect = columnRectAt(colInfo, i);
+ LayoutRect repaintRect = r;
if (isHorizontalWritingMode()) {
- int currXOffset = colRect.x() - logicalLeft;
+ LayoutUnit currXOffset = colRect.x() - logicalLeft;
repaintRect.move(currXOffset, currLogicalOffset);
currLogicalOffset -= colRect.height();
} else {
- int currYOffset = colRect.y() - logicalLeft;
+ LayoutUnit currYOffset = colRect.y() - logicalLeft;
repaintRect.move(currLogicalOffset, currYOffset);
currLogicalOffset -= colRect.width();
}
@@ -4532,56 +4532,57 @@
r = result;
}
-IntPoint RenderBlock::flipForWritingModeIncludingColumns(const IntPoint& point) const
+LayoutPoint RenderBlock::flipForWritingModeIncludingColumns(const LayoutPoint& point) const
{
ASSERT(hasColumns());
if (!hasColumns() || !style()->isFlippedBlocksWritingMode())
return point;
ColumnInfo* colInfo = columnInfo();
- int columnLogicalHeight = colInfo->columnHeight();
- int expandedLogicalHeight = borderBefore() + paddingBefore() + columnCount(colInfo) * columnLogicalHeight + borderAfter() + paddingAfter() + scrollbarLogicalHeight();
+ LayoutUnit columnLogicalHeight = colInfo->columnHeight();
+ LayoutUnit expandedLogicalHeight = borderBefore() + paddingBefore() + columnCount(colInfo) * columnLogicalHeight + borderAfter() + paddingAfter() + scrollbarLogicalHeight();
if (isHorizontalWritingMode())
- return IntPoint(point.x(), expandedLogicalHeight - point.y());
- return IntPoint(expandedLogicalHeight - point.x(), point.y());
+ return LayoutPoint(point.x(), expandedLogicalHeight - point.y());
+ return LayoutPoint(expandedLogicalHeight - point.x(), point.y());
}
-void RenderBlock::flipForWritingModeIncludingColumns(IntRect& rect) const
+void RenderBlock::adjustStartEdgeForWritingModeIncludingColumns(LayoutRect& rect) const
{
ASSERT(hasColumns());
if (!hasColumns() || !style()->isFlippedBlocksWritingMode())
return;
ColumnInfo* colInfo = columnInfo();
- int columnLogicalHeight = colInfo->columnHeight();
- int expandedLogicalHeight = borderBefore() + paddingBefore() + columnCount(colInfo) * columnLogicalHeight + borderAfter() + paddingAfter() + scrollbarLogicalHeight();
+ LayoutUnit columnLogicalHeight = colInfo->columnHeight();
+ LayoutUnit expandedLogicalHeight = borderBefore() + paddingBefore() + columnCount(colInfo) * columnLogicalHeight + borderAfter() + paddingAfter() + scrollbarLogicalHeight();
+
if (isHorizontalWritingMode())
rect.setY(expandedLogicalHeight - rect.maxY());
else
rect.setX(expandedLogicalHeight - rect.maxX());
}
-void RenderBlock::adjustForColumns(IntSize& offset, const IntPoint& point) const
+void RenderBlock::adjustForColumns(LayoutSize& offset, const LayoutPoint& point) const
{
if (!hasColumns())
return;
ColumnInfo* colInfo = columnInfo();
- int logicalLeft = logicalLeftOffsetForContent();
+ LayoutUnit logicalLeft = logicalLeftOffsetForContent();
size_t colCount = columnCount(colInfo);
- int colLogicalWidth = colInfo->desiredColumnWidth();
- int colLogicalHeight = colInfo->columnHeight();
+ LayoutUnit colLogicalWidth = colInfo->desiredColumnWidth();
+ LayoutUnit colLogicalHeight = colInfo->columnHeight();
for (size_t i = 0; i < colCount; ++i) {
// Compute the edges for a given column in the block progression direction.
- IntRect sliceRect = IntRect(logicalLeft, borderBefore() + paddingBefore() + i * colLogicalHeight, colLogicalWidth, colLogicalHeight);
+ LayoutRect sliceRect = LayoutRect(logicalLeft, borderBefore() + paddingBefore() + i * colLogicalHeight, colLogicalWidth, colLogicalHeight);
if (!isHorizontalWritingMode())
sliceRect = sliceRect.transposedRect();
// If we have a flipped blocks writing mode, then convert the column so that it's coming from the after edge (either top or left edge).
- flipForWritingModeIncludingColumns(sliceRect);
+ adjustStartEdgeForWritingModeIncludingColumns(sliceRect);
- int logicalOffset = style()->isFlippedBlocksWritingMode() ? (colCount - 1 - i) * colLogicalHeight : i * colLogicalHeight;
+ LayoutUnit logicalOffset = style()->isFlippedBlocksWritingMode() ? (colCount - 1 - i) * colLogicalHeight : i * colLogicalHeight;
// Now we're in the same coordinate space as the point. See if it is inside the rectangle.
if (isHorizontalWritingMode()) {
@@ -4758,9 +4759,9 @@
}
}
-static inline void updatePreferredWidth(int& preferredWidth, float& result)
+static inline void updatePreferredWidth(LayoutUnit& preferredWidth, float& result)
{
- int snappedResult = ceilf(result);
+ LayoutUnit snappedResult = ceiledLayoutUnit(result);
preferredWidth = max(snappedResult, preferredWidth);
}
Modified: trunk/Source/WebCore/rendering/RenderBlock.h (90832 => 90833)
--- trunk/Source/WebCore/rendering/RenderBlock.h 2011-07-12 18:37:09 UTC (rev 90832)
+++ trunk/Source/WebCore/rendering/RenderBlock.h 2011-07-12 18:42:18 UTC (rev 90833)
@@ -127,8 +127,8 @@
// Block flows subclass availableWidth to handle multi column layout (shrinking the width available to children when laying out.)
virtual LayoutUnit availableLogicalWidth() const;
- IntPoint flipForWritingModeIncludingColumns(const IntPoint&) const;
- void flipForWritingModeIncludingColumns(IntRect&) const;
+ LayoutPoint flipForWritingModeIncludingColumns(const LayoutPoint&) const;
+ void adjustStartEdgeForWritingModeIncludingColumns(LayoutRect&) const;
RootInlineBox* firstRootBox() const { return static_cast<RootInlineBox*>(firstLineBox()); }
RootInlineBox* lastRootBox() const { return static_cast<RootInlineBox*>(lastLineBox()); }
@@ -149,8 +149,8 @@
int heightForLineCount(int);
void clearTruncation();
- void adjustRectForColumns(IntRect&) const;
- virtual void adjustForColumns(IntSize&, const IntPoint&) const;
+ void adjustRectForColumns(LayoutRect&) const;
+ virtual void adjustForColumns(LayoutSize&, const LayoutPoint&) const;
void addContinuationWithOutline(RenderInline*);
bool paintsContinuationOutline(RenderInline*);
Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (90832 => 90833)
--- trunk/Source/WebCore/rendering/RenderBox.cpp 2011-07-12 18:37:09 UTC (rev 90832)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp 2011-07-12 18:42:18 UTC (rev 90833)
@@ -667,7 +667,7 @@
return style()->paddingStart().isPercent() || style()->paddingEnd().isPercent();
}
-int RenderBox::minPreferredLogicalWidth() const
+LayoutUnit RenderBox::minPreferredLogicalWidth() const
{
if (preferredLogicalWidthsDirty())
const_cast<RenderBox*>(this)->computePreferredLogicalWidths();
@@ -675,7 +675,7 @@
return m_minPreferredLogicalWidth;
}
-int RenderBox::maxPreferredLogicalWidth() const
+LayoutUnit RenderBox::maxPreferredLogicalWidth() const
{
if (preferredLogicalWidthsDirty())
const_cast<RenderBox*>(this)->computePreferredLogicalWidths();
@@ -1298,7 +1298,7 @@
if (style()->position() != AbsolutePosition && style()->position() != FixedPosition) {
if (o->hasColumns()) {
LayoutRect columnRect(frameRect());
- toRenderBlock(o)->flipForWritingModeIncludingColumns(columnRect);
+ toRenderBlock(o)->adjustStartEdgeForWritingModeIncludingColumns(columnRect);
offset += LayoutSize(columnRect.location().x(), columnRect.location().y());
columnRect.moveBy(point);
o->adjustForColumns(offset, columnRect.location());
@@ -1927,7 +1927,7 @@
// box model. This is essential for sizing inside
// table cells using percentage heights.
result -= borderAndPaddingLogicalHeight();
- result = max(0, result);
+ result = max<LayoutUnit>(0, result);
}
}
return result;
@@ -3393,7 +3393,7 @@
return rect;
}
-IntPoint RenderBox::flipForWritingMode(const RenderBox* child, const IntPoint& point, FlippingAdjustment adjustment) const
+LayoutPoint RenderBox::flipForWritingMode(const RenderBox* child, const LayoutPoint& point, FlippingAdjustment adjustment) const
{
if (!style()->isFlippedBlocksWritingMode())
return point;
@@ -3401,8 +3401,8 @@
// The child is going to add in its x() and y(), so we have to make sure it ends up in
// the right place.
if (isHorizontalWritingMode())
- return IntPoint(point.x(), point.y() + height() - child->height() - child->y() - (adjustment == ParentToChildFlippingAdjustment ? child->y() : 0));
- return IntPoint(point.x() + width() - child->width() - child->x() - (adjustment == ParentToChildFlippingAdjustment ? child->x() : 0), point.y());
+ return LayoutPoint(point.x(), point.y() + height() - child->height() - child->y() - (adjustment == ParentToChildFlippingAdjustment ? child->y() : 0));
+ return LayoutPoint(point.x() + width() - child->width() - child->x() - (adjustment == ParentToChildFlippingAdjustment ? child->x() : 0), point.y());
}
void RenderBox::flipForWritingMode(IntRect& rect) const
@@ -3430,7 +3430,7 @@
return isHorizontalWritingMode() ? IntPoint(position.x(), height() - position.y()) : IntPoint(width() - position.x(), position.y());
}
-IntPoint RenderBox::flipForWritingModeIncludingColumns(const IntPoint& point) const
+LayoutPoint RenderBox::flipForWritingModeIncludingColumns(const LayoutPoint& point) const
{
if (!hasColumns() || !style()->isFlippedBlocksWritingMode())
return flipForWritingMode(point);
Modified: trunk/Source/WebCore/rendering/RenderBox.h (90832 => 90833)
--- trunk/Source/WebCore/rendering/RenderBox.h 2011-07-12 18:37:09 UTC (rev 90832)
+++ trunk/Source/WebCore/rendering/RenderBox.h 2011-07-12 18:42:18 UTC (rev 90833)
@@ -239,8 +239,8 @@
virtual void paint(PaintInfo&, const LayoutPoint&);
virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
- virtual int minPreferredLogicalWidth() const;
- virtual int maxPreferredLogicalWidth() const;
+ virtual LayoutUnit minPreferredLogicalWidth() const;
+ virtual LayoutUnit maxPreferredLogicalWidth() const;
LayoutSize overrideSize() const;
LayoutUnit overrideWidth() const;
@@ -388,10 +388,10 @@
virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
enum FlippingAdjustment { ChildToParentFlippingAdjustment, ParentToChildFlippingAdjustment };
- IntPoint flipForWritingMode(const RenderBox* child, const IntPoint&, FlippingAdjustment) const;
+ LayoutPoint flipForWritingMode(const RenderBox* child, const LayoutPoint&, FlippingAdjustment) const;
int flipForWritingMode(int position) const; // The offset is in the block direction (y for horizontal writing modes, x for vertical writing modes).
IntPoint flipForWritingMode(const IntPoint&) const;
- IntPoint flipForWritingModeIncludingColumns(const IntPoint&) const;
+ LayoutPoint flipForWritingModeIncludingColumns(const LayoutPoint&) const;
IntSize flipForWritingMode(const IntSize&) const;
void flipForWritingMode(IntRect&) const;
FloatPoint flipForWritingMode(const FloatPoint&) const;
@@ -474,10 +474,10 @@
LayoutUnit m_marginBottom;
// The preferred logical width of the element if it were to break its lines at every possible opportunity.
- int m_minPreferredLogicalWidth;
+ LayoutUnit m_minPreferredLogicalWidth;
// The preferred logical width of the element if it never breaks any lines at all.
- int m_maxPreferredLogicalWidth;
+ LayoutUnit m_maxPreferredLogicalWidth;
// For inline replaced elements, the inline box that owns us.
InlineBox* m_inlineBoxWrapper;
Modified: trunk/Source/WebCore/rendering/RenderListBox.cpp (90832 => 90833)
--- trunk/Source/WebCore/rendering/RenderListBox.cpp 2011-07-12 18:37:09 UTC (rev 90832)
+++ trunk/Source/WebCore/rendering/RenderListBox.cpp 2011-07-12 18:42:18 UTC (rev 90833)
@@ -254,7 +254,7 @@
return RenderBox::baselinePosition(baselineType, firstLine, lineDirection, linePositionMode) - baselineAdjustment;
}
-IntRect RenderListBox::itemBoundingBoxRect(const IntPoint& additionalOffset, int index)
+IntRect RenderListBox::itemBoundingBoxRect(const LayoutPoint& additionalOffset, int index)
{
return IntRect(additionalOffset.x() + borderLeft() + paddingLeft(),
additionalOffset.y() + borderTop() + paddingTop() + itemHeight() * (index - m_indexOffset),
Modified: trunk/Source/WebCore/rendering/RenderListBox.h (90832 => 90833)
--- trunk/Source/WebCore/rendering/RenderListBox.h 2011-07-12 18:37:09 UTC (rev 90832)
+++ trunk/Source/WebCore/rendering/RenderListBox.h 2011-07-12 18:42:18 UTC (rev 90833)
@@ -46,7 +46,7 @@
void setOptionsChanged(bool changed) { m_optionsChanged = changed; }
int listIndexAtOffset(int x, int y);
- IntRect itemBoundingBoxRect(const IntPoint&, int index);
+ IntRect itemBoundingBoxRect(const LayoutPoint&, int index);
bool scrollToRevealElementAtListIndex(int index);
bool listIndexIsVisible(int index);
Modified: trunk/Source/WebCore/rendering/RenderObject.h (90832 => 90833)
--- trunk/Source/WebCore/rendering/RenderObject.h 2011-07-12 18:37:09 UTC (rev 90832)
+++ trunk/Source/WebCore/rendering/RenderObject.h 2011-07-12 18:42:18 UTC (rev 90833)
@@ -604,8 +604,8 @@
// the rect that will be painted if this object is passed as the paintingRoot
LayoutRect paintingRootRect(LayoutRect& topLevelRect);
- virtual int minPreferredLogicalWidth() const { return 0; }
- virtual int maxPreferredLogicalWidth() const { return 0; }
+ virtual LayoutUnit minPreferredLogicalWidth() const { return 0; }
+ virtual LayoutUnit maxPreferredLogicalWidth() const { return 0; }
RenderStyle* style() const { return m_style.get(); }
RenderStyle* firstLineStyle() const { return document()->usesFirstLineRules() ? firstLineStyleSlowCase() : style(); }
@@ -669,7 +669,7 @@
// If multiple-column layout results in applying an offset to the given point, add the same
// offset to the given size.
- virtual void adjustForColumns(IntSize&, const IntPoint&) const { }
+ virtual void adjustForColumns(LayoutSize&, const LayoutPoint&) const { }
virtual unsigned int length() const { return 1; }
Modified: trunk/Source/WebCore/rendering/RenderReplaced.cpp (90832 => 90833)
--- trunk/Source/WebCore/rendering/RenderReplaced.cpp 2011-07-12 18:37:09 UTC (rev 90832)
+++ trunk/Source/WebCore/rendering/RenderReplaced.cpp 2011-07-12 18:42:18 UTC (rev 90833)
@@ -219,7 +219,7 @@
return contentRenderer->computeReplacedLogicalHeightRespectingMinMaxHeight(contentRenderer->computeReplacedLogicalHeightUsing(contentRenderer->style()->logicalHeight()));
}
-int RenderReplaced::computeReplacedLogicalWidth(bool includeMaxWidth) const
+LayoutUnit RenderReplaced::computeReplacedLogicalWidth(bool includeMaxWidth) const
{
if (style()->logicalWidth().isSpecified())
return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedLogicalWidthUsing(style()->logicalWidth()), includeMaxWidth);
@@ -304,7 +304,7 @@
return computeReplacedLogicalWidthRespectingMinMaxWidth(intrinsicLogicalWidth(), includeMaxWidth);
}
-int RenderReplaced::computeReplacedLogicalHeight() const
+LayoutUnit RenderReplaced::computeReplacedLogicalHeight() const
{
// 10.5 Content height: the 'height' property: http://www.w3.org/TR/CSS21/visudet.html#propdef-height
// If the height of the containing block is not specified explicitly (i.e., it depends on
Modified: trunk/Source/WebCore/rendering/TableLayout.h (90832 => 90833)
--- trunk/Source/WebCore/rendering/TableLayout.h 2011-07-12 18:37:09 UTC (rev 90832)
+++ trunk/Source/WebCore/rendering/TableLayout.h 2011-07-12 18:42:18 UTC (rev 90833)
@@ -38,7 +38,7 @@
virtual ~TableLayout() { }
- virtual void computePreferredLogicalWidths(int& minWidth, int& maxWidth) = 0;
+ virtual void computePreferredLogicalWidths(LayoutUnit& minWidth, LayoutUnit& maxWidth) = 0;
virtual void layout() = 0;
protected: