Make lossy LayoutUnit constructors explicit
https://bugs.webkit.org/show_bug.cgi?id=191811
Reviewed by Antti Koivisto.
Source/WebCore:
* platform/LayoutUnit.h:
Make lossy unary constructors explicit.
For ergonomics, give float overloads to copy constructor and round/floor/ceil functions.
* css/LengthFunctions.h:
* platform/graphics/LayoutPoint.h:
* platform/graphics/LayoutRect.h:
* platform/graphics/LayoutSize.h:
* rendering/RenderBox.h:
* rendering/RenderElement.h:
Templatize common functions to allow LayoutUnit itself to dictate which types it allows.
* html/shadow/SliderThumbElement.cpp:
* page/FrameView.cpp:
* page/Page.cpp:
* page/SpatialNavigation.cpp:
* page/scrolling/AxisScrollSnapOffsets.cpp:
* page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
* layout/FormattingContextGeometry.cpp:
* layout/FormattingContextQuirks.cpp:
* layout/LayoutState.cpp:
* layout/displaytree/DisplayBox.h:
* layout/inlineformatting/InlineFormattingContextLineLayout.cpp:
* layout/layouttree/LayoutReplaced.cpp:
* platform/animation/AnimationUtilities.h:
* platform/cocoa/ScrollSnapAnimatorState.mm:
* rendering/BorderEdge.cpp:
* rendering/EllipsisBox.cpp:
* rendering/FixedTableLayout.cpp:
* rendering/InlineBox.cpp:
* rendering/InlineFlowBox.cpp:
* rendering/InlineFlowBox.h:
* rendering/InlineTextBox.cpp:
* rendering/RenderBlock.cpp:
* rendering/RenderBlockFlow.cpp:
* rendering/RenderBlockLineLayout.cpp:
* rendering/RenderBox.cpp:
* rendering/RenderBoxModelObject.cpp:
* rendering/RenderBoxModelObject.h:
* rendering/RenderDeprecatedFlexibleBox.cpp:
* rendering/RenderElement.cpp:
* rendering/RenderImage.cpp:
* rendering/RenderInline.cpp:
* rendering/RenderLineBreak.cpp:
* rendering/RenderListMarker.cpp:
* rendering/RenderMultiColumnSet.cpp:
* rendering/RenderMultiColumnSet.h:
* rendering/RenderObject.cpp:
* rendering/RenderReplaced.cpp:
* rendering/RenderTable.cpp:
* rendering/RenderTableCell.cpp:
* rendering/RenderTableSection.cpp:
* rendering/RenderText.cpp:
* rendering/RenderTextControlMultiLine.cpp:
* rendering/RenderThemeMac.mm:
* rendering/RenderVTTCue.cpp:
* rendering/RenderView.cpp:
* rendering/RootInlineBox.cpp:
* rendering/SimpleLineLayoutFunctions.cpp:
* rendering/SimpleLineLayoutPagination.cpp:
* rendering/SimpleLineLayoutResolver.cpp:
* rendering/line/LineWidth.cpp:
* rendering/mathml/MathOperator.cpp:
* rendering/mathml/RenderMathMLBlock.cpp:
* rendering/mathml/RenderMathMLBlock.h:
* rendering/mathml/RenderMathMLFencedOperator.h:
* rendering/mathml/RenderMathMLFraction.cpp:
* rendering/mathml/RenderMathMLMenclose.cpp:
* rendering/mathml/RenderMathMLOperator.cpp:
* rendering/mathml/RenderMathMLRoot.cpp:
* rendering/mathml/RenderMathMLScripts.cpp:
* rendering/mathml/RenderMathMLToken.cpp:
* rendering/shapes/BoxShape.cpp:
* rendering/shapes/ShapeOutsideInfo.cpp:
* rendering/style/CollapsedBorderValue.h:
* rendering/style/NinePieceImage.cpp:
* rendering/style/NinePieceImage.h:
* rendering/style/RenderStyle.cpp:
* rendering/style/RenderStyle.h:
* rendering/svg/RenderSVGText.cpp:
* rendering/svg/SVGInlineTextBox.cpp:
Make usage of LayoutUnit(float) and LayoutUnit(double) explicit where needed.
Source/WebKit:
* WebProcess/WebPage/WebPage.cpp:
* WebProcess/WebPage/ios/WebPageIOS.mm:
Make usage of LayoutUnit(float) explicit.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@245543 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/rendering/RenderBlockFlow.cpp b/Source/WebCore/rendering/RenderBlockFlow.cpp
index 766591c..6bfaa82 100644
--- a/Source/WebCore/rendering/RenderBlockFlow.cpp
+++ b/Source/WebCore/rendering/RenderBlockFlow.cpp
@@ -388,7 +388,7 @@
LayoutUnit availWidth = desiredColumnWidth;
LayoutUnit colGap = columnGap();
- LayoutUnit colWidth = std::max<LayoutUnit>(1, style().columnWidth());
+ LayoutUnit colWidth = std::max(1_lu, LayoutUnit(style().columnWidth()));
unsigned colCount = std::max<unsigned>(1, style().columnCount());
if (style().hasAutoColumnWidth() && !style().hasAutoColumnCount()) {
@@ -3096,7 +3096,7 @@
selectionState() != SelectionStart && selectionState() != SelectionBoth && !isRubyBase())
result.uniteCenter(blockSelectionGap(rootBlock, rootBlockPhysicalPosition, offsetFromRootBlock, lastLogicalTop, lastLogicalLeft, lastLogicalRight, selTop, cache, paintInfo));
- LayoutRect logicalRect(curr->logicalLeft(), selTop, curr->logicalWidth(), selTop + selHeight);
+ LayoutRect logicalRect { LayoutUnit(curr->logicalLeft()), selTop, LayoutUnit(curr->logicalWidth()), selTop + selHeight };
logicalRect.move(isHorizontalWritingMode() ? offsetFromRootBlock : offsetFromRootBlock.transposedSize());
LayoutRect physicalRect = rootBlock.logicalRectToPhysicalRect(rootBlockPhysicalPosition, logicalRect);
if (!paintInfo || (isHorizontalWritingMode() && physicalRect.y() < paintInfo->rect.maxY() && physicalRect.maxY() > paintInfo->rect.y())
@@ -3412,7 +3412,7 @@
if (closestBox) {
if (moveCaretToBoundary) {
- LayoutUnit firstRootBoxWithChildrenTop = std::min<LayoutUnit>(firstRootBoxWithChildren->selectionTop(), firstRootBoxWithChildren->logicalTop());
+ LayoutUnit firstRootBoxWithChildrenTop = std::min(firstRootBoxWithChildren->selectionTop(), LayoutUnit(firstRootBoxWithChildren->logicalTop()));
if (pointInLogicalContents.y() < firstRootBoxWithChildrenTop
|| (blocksAreFlipped && pointInLogicalContents.y() == firstRootBoxWithChildrenTop)) {
InlineBox* box = firstRootBoxWithChildren->firstLeafChild();
@@ -3465,9 +3465,9 @@
{
ASSERT(childrenInline());
for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) {
- LayoutUnit top = std::max<LayoutUnit>(curr->lineTop(), curr->top());
- LayoutUnit bottom = std::min<LayoutUnit>(curr->lineBottom(), curr->top() + curr->height());
- LayoutRect rect(additionalOffset.x() + curr->x(), additionalOffset.y() + top, curr->width(), bottom - top);
+ LayoutUnit top = std::max(curr->lineTop(), LayoutUnit(curr->top()));
+ LayoutUnit bottom = std::min(curr->lineBottom(), LayoutUnit(curr->top() + curr->height()));
+ LayoutRect rect { LayoutUnit(additionalOffset.x() + curr->x()), additionalOffset.y() + top, LayoutUnit(curr->width()), bottom - top };
if (!rect.isEmpty())
rects.append(rect);
}
@@ -4228,7 +4228,7 @@
// Add in text-indent. This is added in only once.
if (!addedTextIndent && !child->isFloating()) {
- LayoutUnit ceiledIndent = textIndent.ceilToFloat();
+ LayoutUnit ceiledIndent { textIndent.ceilToFloat() };
childMin += ceiledIndent;
childMax += ceiledIndent;