Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(993)

Unified Diff: Source/core/rendering/InlineFlowBox.cpp

Issue 699683002: Continue with InlineBox float->LayoutUnit migration. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/rendering/InlineFlowBox.cpp
diff --git a/Source/core/rendering/InlineFlowBox.cpp b/Source/core/rendering/InlineFlowBox.cpp
index f4f36b70c970b2aba636d880191c06a67edce16c..f531a20b478df9419fbffcd7661ec14212c37df2 100644
--- a/Source/core/rendering/InlineFlowBox.cpp
+++ b/Source/core/rendering/InlineFlowBox.cpp
@@ -74,11 +74,11 @@ LayoutUnit InlineFlowBox::getFlowSpacingLogicalWidth()
IntRect InlineFlowBox::roundedFrameRect() const
{
// Begin by snapping the x and y coordinates to the nearest pixel.
- int snappedX = lroundf(x());
- int snappedY = lroundf(y());
+ int snappedX = LAYOUT_UNIT_ROUND(x());
+ int snappedY = LAYOUT_UNIT_ROUND(y());
- int snappedMaxX = lroundf(x() + width());
- int snappedMaxY = lroundf(y() + height());
+ int snappedMaxX = LAYOUT_UNIT_ROUND(x() + width());
+ int snappedMaxY = LAYOUT_UNIT_ROUND(y() + height());
return IntRect(snappedX, snappedY, snappedMaxX - snappedX, snappedMaxY - snappedY);
}
@@ -254,7 +254,7 @@ void InlineFlowBox::attachLineBoxToRenderObject()
rendererLineBoxes()->attachLineBox(this);
}
-void InlineFlowBox::adjustPosition(float dx, float dy)
+void InlineFlowBox::adjustPosition(FloatWillBeLayoutUnit dx, FloatWillBeLayoutUnit dy)
{
InlineBox::adjustPosition(dx, dy);
for (InlineBox* child = firstChild(); child; child = child->nextOnLine())
@@ -359,16 +359,16 @@ void InlineFlowBox::determineSpacingForFlowBoxes(bool lastLine, bool isLogically
}
}
-float InlineFlowBox::placeBoxesInInlineDirection(float logicalLeft, bool& needsWordSpacing)
+FloatWillBeLayoutUnit InlineFlowBox::placeBoxesInInlineDirection(FloatWillBeLayoutUnit logicalLeft, bool& needsWordSpacing)
{
// Set our x position.
beginPlacingBoxRangesInInlineDirection(logicalLeft);
- float startLogicalLeft = logicalLeft;
+ FloatWillBeLayoutUnit startLogicalLeft = logicalLeft;
logicalLeft += borderLogicalLeft() + paddingLogicalLeft();
- float minLogicalLeft = startLogicalLeft;
- float maxLogicalRight = logicalLeft;
+ FloatWillBeLayoutUnit minLogicalLeft = startLogicalLeft;
+ FloatWillBeLayoutUnit maxLogicalRight = logicalLeft;
placeBoxRangeInInlineDirection(firstChild(), 0, logicalLeft, minLogicalLeft, maxLogicalRight, needsWordSpacing);
@@ -377,14 +377,14 @@ float InlineFlowBox::placeBoxesInInlineDirection(float logicalLeft, bool& needsW
return logicalLeft;
}
-float InlineFlowBox::placeBoxRangeInInlineDirection(InlineBox* firstChild, InlineBox* lastChild,
- float& logicalLeft, float& minLogicalLeft, float& maxLogicalRight, bool& needsWordSpacing)
+FloatWillBeLayoutUnit InlineFlowBox::placeBoxRangeInInlineDirection(InlineBox* firstChild, InlineBox* lastChild,
+ FloatWillBeLayoutUnit& logicalLeft, FloatWillBeLayoutUnit& minLogicalLeft, FloatWillBeLayoutUnit& maxLogicalRight, bool& needsWordSpacing)
{
for (InlineBox* curr = firstChild; curr && curr != lastChild; curr = curr->nextOnLine()) {
if (curr->renderer().isText()) {
InlineTextBox* text = toInlineTextBox(curr);
RenderText& rt = text->renderer();
- float space = 0;
+ FloatWillBeLayoutUnit space = 0;
if (rt.textLength()) {
if (needsWordSpacing && isSpaceOrNewline(rt.characterAt(text->start())))
space = rt.style(isFirstLineStyle())->font().fontDescription().wordSpacing();
@@ -587,8 +587,8 @@ void InlineFlowBox::computeLogicalBoxHeights(RootInlineBox* rootBox, LayoutUnit&
// means is that ascent and descent (including leading), can end up being negative. The setMaxAscent and
// setMaxDescent booleans are used to ensure that we're willing to initially set maxAscent/Descent to negative
// values.
- ascent -= curr->logicalTop();
- descent += curr->logicalTop();
+ ascent -= WILL_BE_LAYOUT_UNIT_TO_INT(curr->logicalTop());
+ descent += WILL_BE_LAYOUT_UNIT_TO_INT(curr->logicalTop());
if (affectsAscent && (maxAscent < ascent || !setMaxAscent)) {
maxAscent = ascent;
setMaxAscent = true;
@@ -743,7 +743,7 @@ void InlineFlowBox::placeBoxesInBlockDirection(LayoutUnit top, LayoutUnit maxHei
}
}
-void InlineFlowBox::computeMaxLogicalTop(float& maxLogicalTop) const
+void InlineFlowBox::computeMaxLogicalTop(FloatWillBeLayoutUnit& maxLogicalTop) const
{
for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
if (curr->renderer().isOutOfFlowPositioned())
@@ -752,11 +752,11 @@ void InlineFlowBox::computeMaxLogicalTop(float& maxLogicalTop) const
if (descendantsHaveSameLineHeightAndBaseline())
continue;
- maxLogicalTop = std::max<float>(maxLogicalTop, curr->y());
- float localMaxLogicalTop = 0;
+ maxLogicalTop = std::max<FloatWillBeLayoutUnit>(maxLogicalTop, curr->y());
+ FloatWillBeLayoutUnit localMaxLogicalTop = 0;
if (curr->isInlineFlowBox())
toInlineFlowBox(curr)->computeMaxLogicalTop(localMaxLogicalTop);
- maxLogicalTop = std::max<float>(maxLogicalTop, localMaxLogicalTop);
+ maxLogicalTop = std::max<FloatWillBeLayoutUnit>(maxLogicalTop, localMaxLogicalTop);
}
}
@@ -1141,9 +1141,9 @@ bool InlineFlowBox::canAccommodateEllipsis(bool ltr, int blockEdge, int ellipsis
return true;
}
-float InlineFlowBox::placeEllipsisBox(bool ltr, float blockLeftEdge, float blockRightEdge, float ellipsisWidth, float &truncatedWidth, bool& foundBox)
+FloatWillBeLayoutUnit InlineFlowBox::placeEllipsisBox(bool ltr, FloatWillBeLayoutUnit blockLeftEdge, FloatWillBeLayoutUnit blockRightEdge, FloatWillBeLayoutUnit ellipsisWidth, FloatWillBeLayoutUnit &truncatedWidth, bool& foundBox)
{
- float result = -1;
+ FloatWillBeLayoutUnit result = -1;
// We iterate over all children, the foundBox variable tells us when we've found the
// box containing the ellipsis. All boxes after that one in the flow are hidden.
// If our flow is ltr then iterate over the boxes from left to right, otherwise iterate
@@ -1160,11 +1160,11 @@ float InlineFlowBox::placeEllipsisBox(bool ltr, float blockLeftEdge, float block
result = currResult;
if (ltr) {
- visibleLeftEdge += box->logicalWidth();
+ visibleLeftEdge += WILL_BE_LAYOUT_UNIT_TO_INT(box->logicalWidth());
box = box->nextOnLine();
}
else {
- visibleRightEdge -= box->logicalWidth();
+ visibleRightEdge -= WILL_BE_LAYOUT_UNIT_TO_INT(box->logicalWidth());
box = box->prevOnLine();
}
}

Powered by Google App Engine
This is Rietveld 408576698