Use std::min and std::max, not the misc versions.

This commit is contained in:
2025-08-10 17:08:42 -04:00
parent 6c3bf19bbd
commit 640ccd02d3
26 changed files with 216 additions and 226 deletions

View File

@ -37,8 +37,8 @@ Bullet::~Bullet ()
void Bullet::sizeRequestSimpl (core::Requisition *requisition) void Bullet::sizeRequestSimpl (core::Requisition *requisition)
{ {
requisition->width = lout::misc::max (getStyle()->font->xHeight * 4 / 5, 1); requisition->width = std::max (getStyle()->font->xHeight * 4 / 5, 1);
requisition->ascent = lout::misc::max (getStyle()->font->xHeight, 1); requisition->ascent = std::max (getStyle()->font->xHeight, 1);
requisition->descent = 0; requisition->descent = 0;
} }
@ -46,7 +46,7 @@ void Bullet::getExtremesSimpl (core::Extremes *extremes)
{ {
extremes->minWidth = extremes->maxWidth = extremes->adjustmentWidth = extremes->minWidth = extremes->maxWidth = extremes->adjustmentWidth =
extremes->minWidthIntrinsic = extremes->maxWidthIntrinsic = extremes->minWidthIntrinsic = extremes->maxWidthIntrinsic =
lout::misc::max (getStyle()->font->xHeight * 4 / 5, 1); std::max (getStyle()->font->xHeight * 4 / 5, 1);
} }
void Bullet::containerSizeChangedForChildren () void Bullet::containerSizeChangedForChildren ()
@ -62,7 +62,7 @@ void Bullet::draw (core::View *view, core::Rectangle *area,
int x, y, l; int x, y, l;
bool filled = true; bool filled = true;
l = lout::misc::min (allocation.width, allocation.ascent); l = std::min (allocation.width, allocation.ascent);
x = allocation.x; x = allocation.x;
y = allocation.y + allocation.ascent - getStyle()->font->xHeight; y = allocation.y + allocation.ascent - getStyle()->font->xHeight;

View File

@ -327,9 +327,9 @@ inline void FltkImgbuf::scaleBuffer (const core::byte *src, int srcWidth,
for(int x = 0; x < destWidth; x++) { for(int x = 0; x < destWidth; x++) {
for(int y = 0; y < destHeight; y++) { for(int y = 0; y < destHeight; y++) {
int xo1 = x * srcWidth / destWidth; int xo1 = x * srcWidth / destWidth;
int xo2 = lout::misc::max ((x + 1) * srcWidth / destWidth, xo1 + 1); int xo2 = std::max ((x + 1) * srcWidth / destWidth, xo1 + 1);
int yo1 = y * srcHeight / destHeight; int yo1 = y * srcHeight / destHeight;
int yo2 = lout::misc::max ((y + 1) * srcHeight / destHeight, yo1 + 1); int yo2 = std::max ((y + 1) * srcHeight / destHeight, yo1 + 1);
int n = (xo2 - xo1) * (yo2 - yo1); int n = (xo2 - xo1) * (yo2 - yo1);
for(int i = 0; i < bpp; i++) for(int i = 0; i < bpp; i++)
@ -489,8 +489,8 @@ void FltkImgbuf::copyTo (Imgbuf *dest, int xDestRoot, int yDestRoot,
FltkImgbuf *fDest = (FltkImgbuf*)dest; FltkImgbuf *fDest = (FltkImgbuf*)dest;
assert (bpp == fDest->bpp); assert (bpp == fDest->bpp);
int xSrc2 = lout::misc::min (xSrc + widthSrc, fDest->width - xDestRoot); int xSrc2 = std::min (xSrc + widthSrc, fDest->width - xDestRoot);
int ySrc2 = lout::misc::min (ySrc + heightSrc, fDest->height - yDestRoot); int ySrc2 = std::min (ySrc + heightSrc, fDest->height - yDestRoot);
//printf ("copying from (%d, %d), %d x %d to (%d, %d) (root) => " //printf ("copying from (%d, %d), %d x %d to (%d, %d) (root) => "
// "xSrc2 = %d, ySrc2 = %d\n", // "xSrc2 = %d, ySrc2 = %d\n",

View File

@ -118,7 +118,7 @@ FltkFont::FltkFont (core::style::FontAttrs *attrs)
fl_font(font, size); fl_font(font, size);
// WORKAROUND: A bug with fl_width(uint_t) on non-xft X was present in // WORKAROUND: A bug with fl_width(uint_t) on non-xft X was present in
// 1.3.0 (STR #2688). // 1.3.0 (STR #2688).
spaceWidth = misc::max(0, (int)fl_width(" ") + letterSpacing); spaceWidth = std::max(0, (int)fl_width(" ") + letterSpacing);
int xx, xy, xw, xh; int xx, xy, xw, xh;
fl_text_extents("x", xx, xy, xw, xh); fl_text_extents("x", xx, xy, xw, xh);
xHeight = xh; xHeight = xh;

View File

@ -486,11 +486,11 @@ void FltkViewport::scrollTo (int x, int y)
int hdiff = vscrollbar->visible () ? SCROLLBAR_THICKNESS : 0; int hdiff = vscrollbar->visible () ? SCROLLBAR_THICKNESS : 0;
int vdiff = hscrollbar->visible () ? SCROLLBAR_THICKNESS : 0; int vdiff = hscrollbar->visible () ? SCROLLBAR_THICKNESS : 0;
x = misc::min (x, canvasWidth - w() + hdiff); x = std::min (x, canvasWidth - w() + hdiff);
x = misc::max (x, 0); x = std::max (x, 0);
y = misc::min (y, canvasHeight - h() + vdiff); y = std::min (y, canvasHeight - h() + vdiff);
y = misc::max (y, 0); y = std::max (y, 0);
if (x == scrollX && y == scrollY) { if (x == scrollX && y == scrollY) {
return; return;

View File

@ -317,7 +317,7 @@ void Hyphenator::hyphenateSingleWord(core::Platform *platform,
if (p) { if (p) {
for (int k = 0; p[k]; k++) for (int k = 0; p[k]; k++)
points.set(i + k, points.set(i + k,
lout::misc::max (points.get (i + k), p[k] - '0')); std::max (points.get (i + k), p[k] - '0'));
} }
} }
} }
@ -352,7 +352,7 @@ void Hyphenator::hyphenateSingleWord(core::Platform *platform,
} }
// Examine the points to build the break point list. // Examine the points to build the break point list.
int n = lout::misc::min ((int)strlen (wordLc), points.size () - 2); int n = std::min ((int)strlen (wordLc), points.size () - 2);
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
if (points.get(i + 2) % 2) { if (points.get(i + 2) % 2) {
breakPos->increase (); breakPos->increase ();

View File

@ -244,7 +244,7 @@ void Image::getExtremesSimpl (core::Extremes *extremes)
correctExtremes (extremes, false); correctExtremes (extremes, false);
extremes->adjustmentWidth = extremes->adjustmentWidth =
misc::min (extremes->minWidthIntrinsic, extremes->minWidth); std::min (extremes->minWidthIntrinsic, extremes->minWidth);
} }
void Image::sizeAllocateImpl (core::Allocation *allocation) void Image::sizeAllocateImpl (core::Allocation *allocation)
@ -330,7 +330,7 @@ int Image::contentX (core::MousePositionEvent *event)
{ {
int ret = event->xWidget - boxOffsetX(); int ret = event->xWidget - boxOffsetX();
ret = misc::min(getContentWidth(), misc::max(ret, 0)); ret = std::min(getContentWidth(), std::max(ret, 0));
return ret; return ret;
} }
@ -338,7 +338,7 @@ int Image::contentY (core::MousePositionEvent *event)
{ {
int ret = event->yWidget - boxOffsetY(); int ret = event->yWidget - boxOffsetY();
ret = misc::min(getContentHeight(), misc::max(ret, 0)); ret = std::min(getContentHeight(), std::max(ret, 0));
return ret; return ret;
} }

View File

@ -135,10 +135,10 @@ void Iterator::scrollTo (Iterator *it1, Iterator *it2, int start, int end,
curEnd = INT_MAX; curEnd = INT_MAX;
eit3->getAllocation (curStart, curEnd, &alloc); eit3->getAllocation (curStart, curEnd, &alloc);
x1 = misc::min (x1, alloc.x); x1 = std::min (x1, alloc.x);
x2 = misc::max (x2, alloc.x + alloc.width); x2 = std::max (x2, alloc.x + alloc.width);
y1 = misc::min (y1, alloc.y); y1 = std::min (y1, alloc.y);
y2 = misc::max (y2, alloc.y + alloc.ascent + alloc.descent); y2 = std::max (y2, alloc.y + alloc.ascent + alloc.descent);
} }
delete eit3; delete eit3;

View File

@ -51,11 +51,11 @@ void Layout::LayoutImgRenderer::getRefArea (int *xRef, int *yRef, int *widthRef,
{ {
*xRef = 0; *xRef = 0;
*yRef = 0; *yRef = 0;
*widthRef = misc::max (layout->viewportWidth *widthRef = std::max (layout->viewportWidth
- (layout->canvasHeightGreater ? - (layout->canvasHeightGreater ?
layout->vScrollbarThickness : 0), layout->vScrollbarThickness : 0),
layout->canvasWidth); layout->canvasWidth);
*heightRef = misc::max (layout->viewportHeight *heightRef = std::max (layout->viewportHeight
- layout->hScrollbarThickness, - layout->hScrollbarThickness,
layout->canvasAscent + layout->canvasDescent); layout->canvasAscent + layout->canvasDescent);
} }
@ -470,9 +470,9 @@ void Layout::attachView (View *view)
view->scrollTo (scrollX, scrollY); view->scrollTo (scrollX, scrollY);
view->setViewportSize (viewportWidth, viewportHeight, view->setViewportSize (viewportWidth, viewportHeight,
hScrollbarThickness, vScrollbarThickness); hScrollbarThickness, vScrollbarThickness);
hScrollbarThickness = misc::max (hScrollbarThickness, hScrollbarThickness = std::max (hScrollbarThickness,
view->getHScrollbarThickness ()); view->getHScrollbarThickness ());
vScrollbarThickness = misc::max (vScrollbarThickness, vScrollbarThickness = std::max (vScrollbarThickness,
view->getVScrollbarThickness ()); view->getVScrollbarThickness ());
} }
else { else {
@ -620,13 +620,13 @@ void Layout::scrollIdle ()
void Layout::adjustScrollPos () void Layout::adjustScrollPos ()
{ {
scrollX = misc::min (scrollX, scrollX = std::min (scrollX,
canvasWidth - (viewportWidth - vScrollbarThickness)); canvasWidth - (viewportWidth - vScrollbarThickness));
scrollX = misc::max (scrollX, 0); scrollX = std::max (scrollX, 0);
scrollY = misc::min (scrollY, scrollY = std::min (scrollY,
canvasAscent + canvasDescent - (viewportHeight - hScrollbarThickness)); canvasAscent + canvasDescent - (viewportHeight - hScrollbarThickness));
scrollY = misc::max (scrollY, 0); scrollY = std::max (scrollY, 0);
_MSG("adjustScrollPos: scrollX=%d scrollY=%d\n", scrollX, scrollY); _MSG("adjustScrollPos: scrollX=%d scrollY=%d\n", scrollX, scrollY);
} }
@ -672,11 +672,11 @@ void Layout::draw (View *view, Rectangle *area)
area->height, 0, 0, area->height, 0, 0,
// Reference area: maximum of canvas size and // Reference area: maximum of canvas size and
// viewport size. // viewport size.
misc::max (viewportWidth std::max (viewportWidth
- (canvasHeightGreater ? - (canvasHeightGreater ?
vScrollbarThickness : 0), vScrollbarThickness : 0),
canvasWidth), canvasWidth),
misc::max (viewportHeight std::max (viewportHeight
- hScrollbarThickness, - hScrollbarThickness,
canvasAscent + canvasDescent)); canvasAscent + canvasDescent));
@ -994,11 +994,11 @@ void Layout::queueDrawExcept (int x, int y, int width, int height,
// Some or all of these may be empty. // Some or all of these may be empty.
// upper left corner of the intersection rectangle // upper left corner of the intersection rectangle
int ix1 = misc::max (x, ex); int ix1 = std::max (x, ex);
int iy1 = misc::max (y, ey); int iy1 = std::max (y, ey);
// lower right corner of the intersection rectangle // lower right corner of the intersection rectangle
int ix2 = misc::min (x + width, ex + ewidth); int ix2 = std::min (x + width, ex + ewidth);
int iy2 = misc::min (y + height, ey + eheight); int iy2 = std::min (y + height, ey + eheight);
queueDraw (x, y, width, iy1 - y); queueDraw (x, y, width, iy1 - y);
queueDraw (x, iy2, width, y + height - iy2); queueDraw (x, iy2, width, y + height - iy2);
@ -1244,7 +1244,7 @@ bool Layout::processMouseEvent (MousePositionEvent *event,
if (event->yCanvas < scrollY) if (event->yCanvas < scrollY)
event->yCanvas = scrollY; event->yCanvas = scrollY;
else { else {
int maxY = misc::min(scrollY + viewportHeight -currHScrollbarThickness(), int maxY = std::min(scrollY + viewportHeight -currHScrollbarThickness(),
canvasAscent + canvasDescent) - 1; canvasAscent + canvasDescent) - 1;
if (event->yCanvas > maxY) if (event->yCanvas > maxY)

View File

@ -258,7 +258,7 @@ void OOFAwareWidget::correctRequisitionByOOF (Requisition *requisition,
if (oofWidth > requisition->width) { if (oofWidth > requisition->width) {
if (outOfFlowMgr[i]->containerMustAdjustExtraSpace () && if (outOfFlowMgr[i]->containerMustAdjustExtraSpace () &&
adjustExtraSpaceWhenCorrectingRequisitionByOOF ()) { adjustExtraSpaceWhenCorrectingRequisitionByOOF ()) {
extraSpace.right = max (extraSpace.right, extraSpace.right = std::max (extraSpace.right,
oofWidth - requisition->width); oofWidth - requisition->width);
DBG_OBJ_SET_NUM ("extraSpace.right", extraSpace.right); DBG_OBJ_SET_NUM ("extraSpace.right", extraSpace.right);
} }
@ -269,7 +269,7 @@ void OOFAwareWidget::correctRequisitionByOOF (Requisition *requisition,
if (oofHeight > requisition->ascent + requisition->descent) { if (oofHeight > requisition->ascent + requisition->descent) {
if (outOfFlowMgr[i]->containerMustAdjustExtraSpace () && if (outOfFlowMgr[i]->containerMustAdjustExtraSpace () &&
adjustExtraSpaceWhenCorrectingRequisitionByOOF ()) { adjustExtraSpaceWhenCorrectingRequisitionByOOF ()) {
extraSpace.bottom = max (extraSpace.bottom, extraSpace.bottom = std::max (extraSpace.bottom,
oofHeight - (requisition->ascent + oofHeight - (requisition->ascent +
requisition->descent)); requisition->descent));
DBG_OBJ_SET_NUM ("extraSpace.bottom", extraSpace.bottom); DBG_OBJ_SET_NUM ("extraSpace.bottom", extraSpace.bottom);
@ -280,7 +280,7 @@ void OOFAwareWidget::correctRequisitionByOOF (Requisition *requisition,
} }
if (!adjustExtraSpaceWhenCorrectingRequisitionByOOF ()) { if (!adjustExtraSpaceWhenCorrectingRequisitionByOOF ()) {
requisitionWithoutOOF.width = max (requisitionWithoutOOF.width, requisitionWithoutOOF.width = std::max (requisitionWithoutOOF.width,
oofWidth); oofWidth);
if (oofHeight > if (oofHeight >
requisitionWithoutOOF.ascent + requisitionWithoutOOF.descent) requisitionWithoutOOF.ascent + requisitionWithoutOOF.descent)
@ -321,13 +321,13 @@ void OOFAwareWidget::correctExtremesByOOF (Extremes *extremes)
DBG_OBJ_MSGF ("resize", 1, "result: %d / %d", DBG_OBJ_MSGF ("resize", 1, "result: %d / %d",
oofMinWidth, oofMaxWidth); oofMinWidth, oofMaxWidth);
extremes->minWidth = max (extremes->minWidth, oofMinWidth); extremes->minWidth = std::max (extremes->minWidth, oofMinWidth);
extremes->minWidthIntrinsic = max (extremes->minWidthIntrinsic, extremes->minWidthIntrinsic = std::max (extremes->minWidthIntrinsic,
oofMinWidth); oofMinWidth);
extremes->maxWidth = max (extremes->maxWidth, oofMaxWidth); extremes->maxWidth = std::max (extremes->maxWidth, oofMaxWidth);
extremes->maxWidthIntrinsic = max (extremes->maxWidthIntrinsic, extremes->maxWidthIntrinsic = std::max (extremes->maxWidthIntrinsic,
oofMinWidth); oofMinWidth);
extremes->adjustmentWidth = max (extremes->adjustmentWidth, extremes->adjustmentWidth = std::max (extremes->adjustmentWidth,
oofMinWidth); oofMinWidth);
DBG_OBJ_MSGF ("resize", 1, "after correction: %d (%d) / %d (%d)", DBG_OBJ_MSGF ("resize", 1, "after correction: %d (%d) / %d (%d)",

View File

@ -447,7 +447,7 @@ int OOFFloatsMgr::calcFloatX (Float *vloat)
// it is corrected (but not left of the container). This way, we save // it is corrected (but not left of the container). This way, we save
// space and, especially within tables, avoid some problems. // space and, especially within tables, avoid some problems.
if (x + vloat->size.width > container->getMaxGeneratorWidth ()) if (x + vloat->size.width > container->getMaxGeneratorWidth ())
x = max (0, container->getMaxGeneratorWidth () - vloat->size.width); x = std::max (0, container->getMaxGeneratorWidth () - vloat->size.width);
break; break;
case FLOAT_RIGHT: case FLOAT_RIGHT:
@ -475,10 +475,10 @@ int OOFFloatsMgr::calcFloatX (Float *vloat)
// (ii) If there is more than one line, the line break will already be // (ii) If there is more than one line, the line break will already be
// exceeded, and so be smaller that GB width + float width. // exceeded, and so be smaller that GB width + float width.
effGeneratorWidth = effGeneratorWidth =
min (vloat->generator->getGeneratorWidth () + vloat->size.width, std::min (vloat->generator->getGeneratorWidth () + vloat->size.width,
vloat->generator->getMaxGeneratorWidth ()); vloat->generator->getMaxGeneratorWidth ());
x = max (generator->getGeneratorX (oofmIndex) + effGeneratorWidth x = std::max (generator->getGeneratorX (oofmIndex) + effGeneratorWidth
- vloat->size.width - generator->getStyle()->boxRestWidth(), - vloat->size.width - generator->getStyle()->boxRestWidth(),
// Do not exceed container allocation: // Do not exceed container allocation:
0); 0);
@ -959,9 +959,9 @@ void OOFFloatsMgr::getSize (Requisition *cbReq, int *oofWidth, int *oofHeight)
// boxRestHeight() are added here. // boxRestHeight() are added here.
*oofWidth = *oofWidth =
max (oofWidthtLeft, oofWidthRight) + container->boxRestWidth (); std::max (oofWidthtLeft, oofWidthRight) + container->boxRestWidth ();
*oofHeight = *oofHeight =
max (oofHeightLeft, oofHeightRight) + container->boxRestHeight (); std::max (oofHeightLeft, oofHeightRight) + container->boxRestHeight ();
SizeChanged = true; SizeChanged = true;
@ -994,8 +994,8 @@ void OOFFloatsMgr::getFloatsSize (Requisition *cbReq, Side side, int *width,
ensureFloatSize (vloat); ensureFloatSize (vloat);
*width = max (*width, calcFloatX (vloat) + vloat->size.width); *width = std::max (*width, calcFloatX (vloat) + vloat->size.width);
*height = max (*height, *height = std::max (*height,
vloat->yReal + vloat->size.ascent + vloat->size.descent); vloat->yReal + vloat->size.ascent + vloat->size.descent);
} }
@ -1017,8 +1017,8 @@ void OOFFloatsMgr::getExtremes (Extremes *cbExtr, int *oofMinWidth,
getFloatsExtremes (cbExtr, LEFT, &oofMinWidthtLeft, &oofMaxWidthLeft); getFloatsExtremes (cbExtr, LEFT, &oofMinWidthtLeft, &oofMaxWidthLeft);
getFloatsExtremes (cbExtr, RIGHT, &oofMinWidthRight, &oofMaxWidthRight); getFloatsExtremes (cbExtr, RIGHT, &oofMinWidthRight, &oofMaxWidthRight);
*oofMinWidth = max (oofMinWidthtLeft, oofMinWidthRight); *oofMinWidth = std::max (oofMinWidthtLeft, oofMinWidthRight);
*oofMaxWidth = max (oofMaxWidthLeft, oofMaxWidthRight); *oofMaxWidth = std::max (oofMaxWidthLeft, oofMaxWidthRight);
DBG_OBJ_MSGF ("resize.oofm", 1, DBG_OBJ_MSGF ("resize.oofm", 1,
"=> (l: %d, r: %d => %d) / (l: %d, r: %d => %d)", "=> (l: %d, r: %d => %d) / (l: %d, r: %d => %d)",
@ -1059,13 +1059,13 @@ void OOFFloatsMgr::getFloatsExtremes (Extremes *cbExtr, Side side,
// - This is also the case for the left border, as seen in calcFloatX() // - This is also the case for the left border, as seen in calcFloatX()
// ("... but when the float exceeds the line break width" ...). // ("... but when the float exceeds the line break width" ...).
*minWidth = max (*minWidth, extr.minWidth); *minWidth = std::max (*minWidth, extr.minWidth);
// For the maximal width, borders must be considered. // For the maximal width, borders must be considered.
*maxWidth = max (*maxWidth, *maxWidth = std::max ( std::max(*maxWidth,
extr.maxWidth extr.maxWidth
+ vloat->generator->getStyle()->boxDiffWidth(), + vloat->generator->getStyle()->boxDiffWidth() ) ,
+ max (container->getGeneratorWidth () + std::max (container->getGeneratorWidth ()
- vloat->generator->getGeneratorWidth (), - vloat->generator->getGeneratorWidth (),
0)); 0));
@ -1171,7 +1171,7 @@ int OOFFloatsMgr::getBorder (Side side, int y, int h, OOFAwareWidget *lastGB,
DBG_OBJ_MSGF ("border", 1, "thisBorder = %d + %d = %d", DBG_OBJ_MSGF ("border", 1, "thisBorder = %d + %d = %d",
vloat->size.width, d, thisBorder); vloat->size.width, d, thisBorder);
border = max (border, thisBorder); border = std::max (border, thisBorder);
} }
} }
} }
@ -1265,7 +1265,7 @@ int OOFFloatsMgr::getClearPosition (OOFAwareWidget *widget)
default: assertNotReached (); default: assertNotReached ();
} }
pos = max (left ? getClearPosition (widget, LEFT) : 0, pos = std::max (left ? getClearPosition (widget, LEFT) : 0,
right ? getClearPosition (widget, RIGHT) : 0); right ? getClearPosition (widget, RIGHT) : 0);
} else } else
pos = 0; pos = 0;
@ -1306,7 +1306,7 @@ int OOFFloatsMgr::getClearPosition (OOFAwareWidget *widget, Side side)
assert (vloat->generator != widget); assert (vloat->generator != widget);
ensureFloatSize (vloat); ensureFloatSize (vloat);
int yRel = widget->getGeneratorY (oofmIndex); int yRel = widget->getGeneratorY (oofmIndex);
pos = max (vloat->yReal + vloat->size.ascent + vloat->size.descent - yRel, pos = std::max (vloat->yReal + vloat->size.ascent + vloat->size.descent - yRel,
0); 0);
DBG_OBJ_MSGF ("resize.oofm", 1, "pos = max (%d + %d + %d - %d, 0)", DBG_OBJ_MSGF ("resize.oofm", 1, "pos = max (%d + %d + %d - %d, 0)",
vloat->yReal, vloat->size.ascent, vloat->size.descent, vloat->yReal, vloat->size.ascent, vloat->size.descent,

View File

@ -90,9 +90,9 @@ void OOFPosAbsLikeMgr::getSize (Requisition *containerReq, int *oofWidth,
int x, y, width, ascent, descent; int x, y, width, ascent, descent;
calcPosAndSizeChildOfChild (child, refWidth, refHeight, &x, &y, &width, calcPosAndSizeChildOfChild (child, refWidth, refHeight, &x, &y, &width,
&ascent, &descent); &ascent, &descent);
*oofWidth = max (*oofWidth, x + width) + containerBoxDiffWidth (); *oofWidth = std::max (*oofWidth, x + width) + containerBoxDiffWidth ();
*oofHeight = *oofHeight =
max (*oofHeight, y + ascent + descent) + containerBoxDiffHeight (); std::max (*oofHeight, y + ascent + descent) + containerBoxDiffHeight ();
child->consideredForSize = true; child->consideredForSize = true;
} else } else
@ -135,11 +135,11 @@ void OOFPosAbsLikeMgr::getExtremes (Extremes *containerExtr, int *oofMinWidth,
calcHPosAndSizeChildOfChild (child, containerExtr->minWidth, calcHPosAndSizeChildOfChild (child, containerExtr->minWidth,
childExtr.minWidth, &x, &width); childExtr.minWidth, &x, &width);
*oofMinWidth = max (*oofMinWidth, x + width); *oofMinWidth = std::max (*oofMinWidth, x + width);
calcHPosAndSizeChildOfChild (child, containerExtr->maxWidth, calcHPosAndSizeChildOfChild (child, containerExtr->maxWidth,
childExtr.maxWidth, &x, &width); childExtr.maxWidth, &x, &width);
*oofMaxWidth = max (*oofMaxWidth, x + width); *oofMaxWidth = std::max (*oofMaxWidth, x + width);
child->consideredForExtremes = true; child->consideredForExtremes = true;
} else } else
@ -174,7 +174,7 @@ int OOFPosAbsLikeMgr::getAvailWidthOfChild (Widget *child, bool forceValue)
if (!getPosLeft (child, availWidth, &left)) left = 0; if (!getPosLeft (child, availWidth, &left)) left = 0;
if (!getPosRight (child, availWidth, &right)) right = 0; if (!getPosRight (child, availWidth, &right)) right = 0;
width = max (availWidth - containerBoxDiffWidth () - left - right, 0); width = std::max (availWidth - containerBoxDiffWidth () - left - right, 0);
} else } else
width = -1; width = -1;
} else { } else {
@ -188,7 +188,7 @@ int OOFPosAbsLikeMgr::getAvailWidthOfChild (Widget *child, bool forceValue)
} }
if (width != -1) if (width != -1)
width = max (width, child->getMinWidth (NULL, forceValue)); width = std::max (width, child->getMinWidth (NULL, forceValue));
DBG_OBJ_MSGF ("resize.oofm", 1, "=> %d", width); DBG_OBJ_MSGF ("resize.oofm", 1, "=> %d", width);
DBG_OBJ_LEAVE (); DBG_OBJ_LEAVE ();
@ -218,7 +218,7 @@ int OOFPosAbsLikeMgr::getAvailHeightOfChild (Widget *child, bool forceValue)
if (!getPosBottom (child, availHeight, &bottom)) bottom = 0; if (!getPosBottom (child, availHeight, &bottom)) bottom = 0;
height = height =
max (availHeight - containerBoxDiffHeight () - top - bottom, 0); std::max (availHeight - containerBoxDiffHeight () - top - bottom, 0);
} else } else
height = -1; height = -1;
} else { } else {

View File

@ -114,8 +114,8 @@ void OOFPosRelMgr::getSize (Requisition *containerReq, int *oofWidth,
if (posXDefined (child) && posYDefined (child)) { if (posXDefined (child) && posYDefined (child)) {
Requisition childReq; Requisition childReq;
child->widget->sizeRequest (&childReq); child->widget->sizeRequest (&childReq);
*oofWidth = max (*oofWidth, getChildPosX (child) + childReq.width); *oofWidth = std::max (*oofWidth, getChildPosX (child) + childReq.width);
*oofHeight = max (*oofHeight, *oofHeight = std::max (*oofHeight,
getChildPosY (child) + childReq.ascent getChildPosY (child) + childReq.ascent
+ childReq.descent); + childReq.descent);
@ -144,10 +144,10 @@ void OOFPosRelMgr::getExtremes (Extremes *containerExtr, int *oofMinWidth,
// Put the extremes of the container in relation to the extremes // Put the extremes of the container in relation to the extremes
// of the child, as in OOFPosAbsLikeMgr::getExtremes (see // of the child, as in OOFPosAbsLikeMgr::getExtremes (see
// comment there). // comment there).
*oofMinWidth = max (*oofMinWidth, *oofMinWidth = std::max (*oofMinWidth,
getChildPosX (child, containerExtr->minWidth) getChildPosX (child, containerExtr->minWidth)
+ childExtr.minWidth); + childExtr.minWidth);
*oofMaxWidth = max (*oofMaxWidth, *oofMaxWidth = std::max (*oofMaxWidth,
getChildPosX (child, containerExtr->maxWidth) getChildPosX (child, containerExtr->maxWidth)
+ childExtr.maxWidth); + childExtr.maxWidth);

View File

@ -39,7 +39,7 @@ Ruler::~Ruler ()
void Ruler::sizeRequestSimpl (core::Requisition *requisition) void Ruler::sizeRequestSimpl (core::Requisition *requisition)
{ {
requisition->width = lout::misc::max (getAvailWidth (true), boxDiffWidth ()); requisition->width = std::max (getAvailWidth (true), boxDiffWidth ());
requisition->ascent = boxOffsetY (); requisition->ascent = boxOffsetY ();
requisition->descent = boxRestHeight (); requisition->descent = boxRestHeight ();
} }
@ -51,7 +51,7 @@ void Ruler::getExtremesSimpl (core::Extremes *extremes)
extremes->maxWidthIntrinsic = extremes->maxWidth; extremes->maxWidthIntrinsic = extremes->maxWidth;
correctExtremes (extremes, false); correctExtremes (extremes, false);
extremes->adjustmentWidth = extremes->adjustmentWidth =
lout::misc::min (extremes->minWidthIntrinsic, extremes->minWidth); std::min (extremes->minWidthIntrinsic, extremes->minWidth);
} }
bool Ruler::isBlockLevel () bool Ruler::isBlockLevel ()

View File

@ -363,7 +363,7 @@ int SelectionState::correctCharPos (DeepIterator *it, int charPos)
else else
len = 1; len = 1;
return misc::min(charPos, len); return std::min(charPos, len);
} }
void SelectionState::highlight0 (bool fl, DeepIterator *from, int fromChar, void SelectionState::highlight0 (bool fl, DeepIterator *from, int fromChar,

View File

@ -1,3 +1,4 @@
static_assert( __cplusplus > 2020'02 );
/* /*
* Dillo Widget * Dillo Widget
* *
@ -23,6 +24,8 @@
#include <ctype.h> #include <ctype.h>
#include <math.h> #include <math.h>
#include <algorithm>
#include "dlib/dlib.h" #include "dlib/dlib.h"
#include "core.hh" #include "core.hh"
#include "../lout/msg.h" #include "../lout/msg.h"
@ -475,7 +478,7 @@ int Color::shadeColor (int color, int d)
int green = (color >> 8) & 255; int green = (color >> 8) & 255;
int blue = color & 255; int blue = color & 255;
double oldLightness = ((double) misc::max (red, green, blue)) / 255; double oldLightness = ( (double) std::max( red, std::max( green, blue ) ) ) / 255;
double newLightness; double newLightness;
if (oldLightness > 0.8) { if (oldLightness > 0.8) {
@ -569,9 +572,9 @@ void StyleImage::StyleImgRenderer::setBuffer (core::Imgbuf *buffer, bool resize)
if (image->imgbufSrc->getRootWidth() * image->imgbufSrc->getRootHeight() if (image->imgbufSrc->getRootWidth() * image->imgbufSrc->getRootHeight()
< MIN_BG_IMG_W * MIN_BG_IMG_H) { < MIN_BG_IMG_W * MIN_BG_IMG_H) {
image->tilesX = image->tilesX =
misc::max (OPT_BG_IMG_W / image->imgbufSrc->getRootWidth(), 1); std::max (OPT_BG_IMG_W / image->imgbufSrc->getRootWidth(), 1);
image->tilesY = image->tilesY =
misc::max (OPT_BG_IMG_H / image->imgbufSrc->getRootHeight(), 1); std::max (OPT_BG_IMG_H / image->imgbufSrc->getRootHeight(), 1);
image->imgbufTiled = image->imgbufTiled =
image->imgbufSrc->createSimilarBuf image->imgbufSrc->createSimilarBuf
(image->tilesX * image->imgbufSrc->getRootWidth(), (image->tilesX * image->imgbufSrc->getRootWidth(),
@ -685,8 +688,8 @@ void StyleImage::ExternalImgRenderer::drawRow (int row)
// Only iterate over y, because the rows can be combined // Only iterate over y, because the rows can be combined
// horizontally. // horizontally.
for (int tileY = tileY1; tileY <= tileY2; tileY++) { for (int tileY = tileY1; tileY <= tileY2; tileY++) {
int x1 = misc::max (origX + tileX1 * imgWidth, x); int x1 = std::max (origX + tileX1 * imgWidth, x);
int x2 = misc::min (origX + (tileX2 + 1) * imgWidth, x + width); int x2 = std::min (origX + (tileX2 + 1) * imgWidth, x + width);
int yt = origY + tileY * imgHeight + row; int yt = origY + tileY * imgHeight + row;
if (yt >= y && yt < y + height) if (yt >= y && yt < y + height)
@ -1325,11 +1328,11 @@ void drawBackgroundImage (View *view, StyleImage *backgroundImage,
for (int tileX = tileX1; tileX <= tileX2; tileX += tilesX) for (int tileX = tileX1; tileX <= tileX2; tileX += tilesX)
for (int tileY = tileY1; tileY <= tileY2; tileY += tilesY) { for (int tileY = tileY1; tileY <= tileY2; tileY += tilesY) {
int xt = origX + tileX * imgWidthS; int xt = origX + tileX * imgWidthS;
int x1 = misc::max (xt, x); int x1 = std::max (xt, x);
int x2 = misc::min (xt + imgWidthT, x + width); int x2 = std::min (xt + imgWidthT, x + width);
int yt = origY + tileY * imgHeightS; int yt = origY + tileY * imgHeightS;
int y1 = misc::max (yt, y); int y1 = std::max (yt, y);
int y2 = misc::min (yt + imgHeightT, y + height); int y2 = std::min (yt + imgHeightT, y + height);
view->drawImage (imgbufT, xt, yt, x1 - xt, y1 - yt, view->drawImage (imgbufT, xt, yt, x1 - xt, y1 - yt,
x2 - x1, y2 - y1); x2 - x1, y2 - y1);

View File

@ -296,7 +296,7 @@ int Table::calcAvailWidthForDescendant (Widget *child)
int width = (colspanEff - 1) * getStyle()->hBorderSpacing; int width = (colspanEff - 1) * getStyle()->hBorderSpacing;
for (int i = 0; i < colspanEff; i++) for (int i = 0; i < colspanEff; i++)
width += colWidths->get (col + i); width += colWidths->get (col + i);
width = misc::max (width, 0); width = std::max (width, 0);
if (child != actualChild) { if (child != actualChild) {
// For table cells (direct children: child == actualChild), CSS // For table cells (direct children: child == actualChild), CSS
@ -308,7 +308,7 @@ int Table::calcAvailWidthForDescendant (Widget *child)
child->calcFinalWidth (child->getStyle(), -1, this, 0, true, &corrWidth); child->calcFinalWidth (child->getStyle(), -1, this, 0, true, &corrWidth);
// But better not exceed it ... (TODO: Only here?) // But better not exceed it ... (TODO: Only here?)
width = misc::min (width, corrWidth); width = std::min (width, corrWidth);
} }
DBG_OBJ_MSGF ("resize", 1, "=> %d", width); DBG_OBJ_MSGF ("resize", 1, "=> %d", width);
@ -496,7 +496,7 @@ void Table::addCell (Widget *widget, int colspan, int rowspan)
} }
if (colspan == 0) { if (colspan == 0) {
colspanEff = misc::max (numCols - curCol, 1); colspanEff = std::max (numCols - curCol, 1);
rowClosed = true; rowClosed = true;
} else } else
colspanEff = colspan; colspanEff = colspan;
@ -654,10 +654,10 @@ int Table::getExtreme (core::Extremes *extremes, ExtrMod mod)
return extremes->minWidthIntrinsic; return extremes->minWidthIntrinsic;
case MIN_MIN: case MIN_MIN:
return misc::min (extremes->minWidth, extremes->minWidthIntrinsic); return std::min (extremes->minWidth, extremes->minWidthIntrinsic);
case MAX_MIN: case MAX_MIN:
return misc::max (extremes->minWidth, extremes->minWidthIntrinsic); return std::max (extremes->minWidth, extremes->minWidthIntrinsic);
case MAX: case MAX:
return extremes->maxWidth; return extremes->maxWidth;
@ -915,7 +915,7 @@ void Table::actuallyCalcCellSizes (bool calcHeights)
// width for correction. (TODO: Is this necessary?) // width for correction. (TODO: Is this necessary?)
int corrWidth = int corrWidth =
Table::getAdjustTableMinWidth () ? extremes.adjustmentWidth : 0; Table::getAdjustTableMinWidth () ? extremes.adjustmentWidth : 0;
int totalWidth = misc::max (availWidth, corrWidth) int totalWidth = std::max (availWidth, corrWidth)
- ((numCols + 1) * getStyle()->hBorderSpacing + boxDiffWidth ()); - ((numCols + 1) * getStyle()->hBorderSpacing + boxDiffWidth ());
DBG_OBJ_MSGF ("resize", 1, DBG_OBJ_MSGF ("resize", 1,
@ -1144,7 +1144,7 @@ void Table::actuallyCalcCellSizes (bool calcHeights)
} else { } else {
// Normal apportioning. // Normal apportioning.
int width = int width =
totalWidthSpecified ? totalWidth : misc::min (totalWidth, maxWidth); totalWidthSpecified ? totalWidth : std::min (totalWidth, maxWidth);
DBG_OBJ_MSGF ("resize", 1, "case 3: else; width = %d", width); DBG_OBJ_MSGF ("resize", 1, "case 3: else; width = %d", width);
apportion2 (width, 0, colExtremes->size() - 1, MIN, MAX, NULL, colWidths, apportion2 (width, 0, colExtremes->size() - 1, MIN, MAX, NULL, colWidths,
0); 0);
@ -1155,7 +1155,7 @@ void Table::actuallyCalcCellSizes (bool calcHeights)
// performance gain actually play a role? // performance gain actually play a role?
for (int col = 0; col < colExtremes->size(); col++) { for (int col = 0; col < colExtremes->size(); col++) {
if (colWidths->get (col) != oldColWidths->get (col)) if (colWidths->get (col) != oldColWidths->get (col))
redrawX = lout::misc::min (redrawX, colWidths->get (col)); redrawX = std::min (redrawX, colWidths->get (col));
} }
DBG_IF_RTFL { DBG_IF_RTFL {
@ -1208,7 +1208,7 @@ void Table::actuallyCalcCellSizes (bool calcHeights)
children->get(n)->cell.widget->sizeRequest (&childRequisition); children->get(n)->cell.widget->sizeRequest (&childRequisition);
childHeight = childRequisition.ascent + childRequisition.descent; childHeight = childRequisition.ascent + childRequisition.descent;
if (children->get(n)->cell.rowspan == 1) { if (children->get(n)->cell.rowspan == 1) {
rowHeight = misc::max (rowHeight, childHeight); rowHeight = std::max (rowHeight, childHeight);
} else { } else {
rowSpanCells->increase(); rowSpanCells->increase();
rowSpanCells->set(rowSpanCells->size()-1, n); rowSpanCells->set(rowSpanCells->size()-1, n);
@ -1330,23 +1330,23 @@ void Table::forceCalcColumnExtremes ()
cellExtremes.minWidth, cellExtremes.maxWidth); cellExtremes.minWidth, cellExtremes.maxWidth);
colExtremes->getRef(col)->minWidthIntrinsic = colExtremes->getRef(col)->minWidthIntrinsic =
misc::max (colExtremes->getRef(col)->minWidthIntrinsic, std::max (colExtremes->getRef(col)->minWidthIntrinsic,
cellExtremes.minWidthIntrinsic); cellExtremes.minWidthIntrinsic);
colExtremes->getRef(col)->maxWidthIntrinsic = colExtremes->getRef(col)->maxWidthIntrinsic =
misc::max (colExtremes->getRef(col)->minWidthIntrinsic, std::max( colExtremes->getRef(col)->minWidthIntrinsic,
colExtremes->getRef(col)->maxWidthIntrinsic, std::max( colExtremes->getRef(col)->maxWidthIntrinsic,
cellExtremes.maxWidthIntrinsic); cellExtremes.maxWidthIntrinsic ) );
colExtremes->getRef(col)->minWidth = colExtremes->getRef(col)->minWidth =
misc::max (colExtremes->getRef(col)->minWidth, std::max (colExtremes->getRef(col)->minWidth,
cellExtremes.minWidth); cellExtremes.minWidth);
colExtremes->getRef(col)->maxWidth = colExtremes->getRef(col)->maxWidth =
misc::max (colExtremes->getRef(col)->minWidth, std::max( colExtremes->getRef(col)->minWidth,
colExtremes->getRef(col)->maxWidth, std::max( colExtremes->getRef(col)->maxWidth,
cellExtremes.maxWidth); cellExtremes.maxWidth ) );
colExtremes->getRef(col)->adjustmentWidth = colExtremes->getRef(col)->adjustmentWidth =
misc::max (colExtremes->getRef(col)->adjustmentWidth, std::max (colExtremes->getRef(col)->adjustmentWidth,
cellExtremes.adjustmentWidth); cellExtremes.adjustmentWidth);
core::style::Length childWidth = core::style::Length childWidth =
@ -1487,7 +1487,7 @@ void Table::calcExtremesSpanMultiCols (int col, int cs,
// For cases where min and max are somewhat confused: // For cases where min and max are somewhat confused:
setColExtreme (col + j, maxExtrMod, extrData, setColExtreme (col + j, maxExtrMod, extrData,
misc::max (getColExtreme (col + j, minExtrMod, std::max (getColExtreme (col + j, minExtrMod,
extrData), extrData),
getColExtreme (col + j, maxExtrMod, getColExtreme (col + j, maxExtrMod,
extrData))); extrData)));

View File

@ -458,7 +458,7 @@ private:
void setCumHeight (int row, int value) void setCumHeight (int row, int value)
{ {
if (value != cumHeight->get (row)) { if (value != cumHeight->get (row)) {
redrawY = lout::misc::min ( redrawY, value ); redrawY = std::min ( redrawY, value );
cumHeight->set (row, value); cumHeight->set (row, value);
} }
} }

View File

@ -57,11 +57,7 @@ int correctAvailWidthOfChild (core::Widget *widget, core::Widget *child,
int thisWidth = widget->getAvailWidth (forceValue); int thisWidth = widget->getAvailWidth (forceValue);
DBG_OBJ_MSGF_O ("resize", 1, widget, "thisWidth = %d", thisWidth); DBG_OBJ_MSGF_O ("resize", 1, widget, "thisWidth = %d", thisWidth);
if (thisWidth != -1) if (thisWidth != -1)
width = width = std::max (std::min (width, thisWidth - widget->boxDiffWidth ()), 0);
lout::misc::max (lout::misc::min (width,
thisWidth
- widget->boxDiffWidth ()),
0);
} }
DBG_OBJ_MSGF_O ("resize", 1, widget, "=> %d", width); DBG_OBJ_MSGF_O ("resize", 1, widget, "=> %d", width);
@ -96,11 +92,10 @@ void correctCorrectedRequisitionOfChild (core::Widget *widget,
int thisWidth = widget->getAvailWidth (true); int thisWidth = widget->getAvailWidth (true);
DBG_OBJ_MSGF_O ("resize", 1, widget, "thisWidth = %d", thisWidth); DBG_OBJ_MSGF_O ("resize", 1, widget, "thisWidth = %d", thisWidth);
int newWidth = int newWidth =
lout::misc::max (lout::misc::min (requisition->width, std::max (std::min (requisition->width,
thisWidth - widget->boxDiffWidth ()), thisWidth - widget->boxDiffWidth ()),
0); 0);
requisition->width = allowDecreaseWidth ? requisition->width = allowDecreaseWidth ? newWidth : std::max (requisition->width, newWidth);
newWidth : misc::max (requisition->width, newWidth);
DBG_OBJ_LEAVE_O (widget); DBG_OBJ_LEAVE_O (widget);
} }

View File

@ -603,7 +603,7 @@ void Textblock::sizeAllocateImpl (core::Allocation *allocation)
// //
// TODO: test case? // TODO: test case?
calcTextOffset (lineIndex, misc::min (allocation->width, lineBreakWidth)); calcTextOffset (lineIndex, std::min (allocation->width, lineBreakWidth));
line = lines->getRef (lineIndex); line = lines->getRef (lineIndex);
xCursor = line->textOffset; xCursor = line->textOffset;
@ -615,7 +615,7 @@ void Textblock::sizeAllocateImpl (core::Allocation *allocation)
word = words->getRef (wordIndex); word = words->getRef (wordIndex);
if (wordIndex == lastWordDrawn + 1) { if (wordIndex == lastWordDrawn + 1) {
redrawY = misc::min (redrawY, lineYOffsetWidget (line, allocation)); redrawY = std::min (redrawY, lineYOffsetWidget (line, allocation));
DBG_OBJ_SET_NUM ("redrawY", redrawY); DBG_OBJ_SET_NUM ("redrawY", redrawY);
} }
@ -652,10 +652,10 @@ void Textblock::sizeAllocateImpl (core::Allocation *allocation)
* so we need to redraw from this line onwards. * so we need to redraw from this line onwards.
*/ */
redrawY = redrawY =
misc::min (redrawY, lineYOffsetWidget (line, allocation)); std::min (redrawY, lineYOffsetWidget (line, allocation));
DBG_OBJ_SET_NUM ("redrawY", redrawY); DBG_OBJ_SET_NUM ("redrawY", redrawY);
if (word->content.widget->wasAllocated ()) { if (word->content.widget->wasAllocated ()) {
redrawY = misc::min (redrawY, redrawY = std::min (redrawY,
oldChildAllocation->y - this->allocation.y); oldChildAllocation->y - this->allocation.y);
DBG_OBJ_SET_NUM ("redrawY", redrawY); DBG_OBJ_SET_NUM ("redrawY", redrawY);
} }
@ -680,17 +680,17 @@ void Textblock::sizeAllocateImpl (core::Allocation *allocation)
core::Content::BREAK)) { core::Content::BREAK)) {
int childChangedY = int childChangedY =
misc::min(childAllocation.y - allocation->y + std::min(childAllocation.y - allocation->y +
childAllocation.ascent + childAllocation.descent, childAllocation.ascent + childAllocation.descent,
oldChildAllocation->y - this->allocation.y + oldChildAllocation->y - this->allocation.y +
oldChildAllocation->ascent + oldChildAllocation->ascent +
oldChildAllocation->descent); oldChildAllocation->descent);
redrawY = misc::min (redrawY, childChangedY); redrawY = std::min (redrawY, childChangedY);
DBG_OBJ_SET_NUM ("redrawY", redrawY); DBG_OBJ_SET_NUM ("redrawY", redrawY);
} else { } else {
redrawY = redrawY =
misc::min (redrawY, lineYOffsetWidget (line, allocation)); std::min (redrawY, lineYOffsetWidget (line, allocation));
DBG_OBJ_SET_NUM ("redrawY", redrawY); DBG_OBJ_SET_NUM ("redrawY", redrawY);
} }
} }
@ -742,10 +742,10 @@ void Textblock::calcExtraSpaceImpl (int numPos, Widget **references, int *x,
for (int i = 0; i < NUM_OOFM; i++) for (int i = 0; i < NUM_OOFM; i++)
if (searchOutOfFlowMgr (i) && findSizeRequestReference (i, NULL, NULL)) if (searchOutOfFlowMgr (i) && findSizeRequestReference (i, NULL, NULL))
clearPosition = clearPosition =
misc::max (clearPosition, std::max (clearPosition,
searchOutOfFlowMgr(i)->getClearPosition (this)); searchOutOfFlowMgr(i)->getClearPosition (this));
extraSpace.top = misc::max (extraSpace.top, clearPosition); extraSpace.top = std::max (extraSpace.top, clearPosition);
DBG_OBJ_LEAVE (); DBG_OBJ_LEAVE ();
} }
@ -767,7 +767,7 @@ int Textblock::getAvailWidthOfChild (Widget *child, bool forceValue)
// there), but "leftInnerPadding" has to be considered, too. // there), but "leftInnerPadding" has to be considered, too.
DBG_OBJ_MSG ("resize", 1, "no specification"); DBG_OBJ_MSG ("resize", 1, "no specification");
if (forceValue) { if (forceValue) {
width = misc::max (getAvailWidth (true) - boxDiffWidth () width = std::max (getAvailWidth (true) - boxDiffWidth ()
- leftInnerPadding, - leftInnerPadding,
0); 0);
@ -889,7 +889,7 @@ void Textblock::markSizeChange (int ref)
if (wrapRefLines == -1) if (wrapRefLines == -1)
wrapRefLines = getParentRefInFlowSubRef (ref); wrapRefLines = getParentRefInFlowSubRef (ref);
else else
wrapRefLines = misc::min (wrapRefLines, wrapRefLines = std::min (wrapRefLines,
getParentRefInFlowSubRef (ref)); getParentRefInFlowSubRef (ref));
} }
@ -924,7 +924,7 @@ void Textblock::markExtremesChange (int ref)
wrapRefParagraphs = getParentRefInFlowSubRef (ref); wrapRefParagraphs = getParentRefInFlowSubRef (ref);
else else
wrapRefParagraphs = wrapRefParagraphs =
misc::min (wrapRefParagraphs, getParentRefInFlowSubRef (ref)); std::min (wrapRefParagraphs, getParentRefInFlowSubRef (ref));
} }
DBG_OBJ_SET_NUM ("wrapRefParagraphs", wrapRefParagraphs); DBG_OBJ_SET_NUM ("wrapRefParagraphs", wrapRefParagraphs);
@ -1368,7 +1368,7 @@ void Textblock::drawWord0 (int wordIndex1, int wordIndex2,
firstCharIdx = 0; firstCharIdx = 0;
else { else {
firstCharIdx = firstCharIdx =
misc::min (hlStart[layer].nChar, std::min (hlStart[layer].nChar,
(int)strlen (words->getRef(hlStart[layer].index) (int)strlen (words->getRef(hlStart[layer].index)
->content.text)); ->content.text));
for (int i = wordIndex1; i < hlStart[layer].index; i++) for (int i = wordIndex1; i < hlStart[layer].index; i++)
@ -1381,7 +1381,7 @@ void Textblock::drawWord0 (int wordIndex1, int wordIndex2,
lastCharIdx = wordLen; lastCharIdx = wordLen;
else { else {
lastCharIdx = lastCharIdx =
misc::min (hlEnd[layer].nChar, std::min (hlEnd[layer].nChar,
(int)strlen (words->getRef(hlEnd[layer].index) (int)strlen (words->getRef(hlEnd[layer].index)
->content.text)); ->content.text));
for (int i = wordIndex1; i < hlEnd[layer].index; i++) for (int i = wordIndex1; i < hlEnd[layer].index; i++)
@ -2008,10 +2008,10 @@ void Textblock::calcTextSize (const char *text, size_t len,
*/ */
if (style->valign == core::style::VALIGN_SUB) { if (style->valign == core::style::VALIGN_SUB) {
int requiredDescent = style->font->descent + style->font->ascent / 3; int requiredDescent = style->font->descent + style->font->ascent / 3;
size->descent = misc::max (size->descent, requiredDescent); size->descent = std::max (size->descent, requiredDescent);
} else if (style->valign == core::style::VALIGN_SUPER) { } else if (style->valign == core::style::VALIGN_SUPER) {
int requiredAscent = style->font->ascent + style->font->ascent / 2; int requiredAscent = style->font->ascent + style->font->ascent / 2;
size->ascent = misc::max (size->ascent, requiredAscent); size->ascent = std::max (size->ascent, requiredAscent);
} }
} }
@ -2335,7 +2335,7 @@ bool Textblock::calcSizeOfWidgetInFlow (int wordIndex, Widget *widget,
int rightBorder = boxRestWidth (); int rightBorder = boxRestWidth ();
int lastMargin, yLine = yOffsetOfLineToBeCreated (&lastMargin); int lastMargin, yLine = yOffsetOfLineToBeCreated (&lastMargin);
int yRel = yLine - min (lastMargin, widget->getStyle()->margin.top); int yRel = yLine - std::min (lastMargin, widget->getStyle()->margin.top);
DBG_OBJ_MSGF ("resize", 1, DBG_OBJ_MSGF ("resize", 1,
"leftBorder = %d + %d + (%d == 0 ? %d : 0) = %d, " "leftBorder = %d + %d + (%d == 0 ? %d : 0) = %d, "
@ -2804,10 +2804,10 @@ void Textblock::addParbreak (int space, core::style::Style *style)
Line *lastLine = lines->getRef (lines->size () - 1); Line *lastLine = lines->getRef (lines->size () - 1);
word->content.breakSpace = word->content.breakSpace =
misc::max (word->content.breakSpace, space); std::max (word->content.breakSpace, space);
lastLine->breakSpace = lastLine->breakSpace =
misc::max (word->content.breakSpace, std::max( std::max( word->content.breakSpace,
lastLine->marginDescent - lastLine->borderDescent, lastLine->marginDescent - lastLine->borderDescent ),
lastLine->breakSpace); lastLine->breakSpace);
return; return;
} }
@ -3048,13 +3048,13 @@ void Textblock::queueDrawRange (int index1, int index2)
{ {
DBG_OBJ_ENTER ("draw", 0, "queueDrawRange", "%d, %d", index1, index2); DBG_OBJ_ENTER ("draw", 0, "queueDrawRange", "%d, %d", index1, index2);
int from = misc::min (index1, index2); int from = std::min (index1, index2);
int to = misc::max (index1, index2); int to = std::max (index1, index2);
from = misc::min (from, words->size () - 1); from = std::min (from, words->size () - 1);
from = misc::max (from, 0); from = std::max (from, 0);
to = misc::min (to, words->size () - 1); to = std::min (to, words->size () - 1);
to = misc::max (to, 0); to = std::max (to, 0);
int line1idx = findLineOfWord (from); int line1idx = findLineOfWord (from);
int line2idx = findLineOfWord (to); int line2idx = findLineOfWord (to);
@ -3193,7 +3193,7 @@ int Textblock::getGeneratorWidth ()
word->content.type == core::Content::WIDGET_IN_FLOW && word->content.type == core::Content::WIDGET_IN_FLOW &&
( tbChild= dynamic_cast< Textblock * >( word->content.widget ) )) { ( tbChild= dynamic_cast< Textblock * >( word->content.widget ) )) {
if(tbChild->findSizeRequestReference(this, &xRel, NULL)) if(tbChild->findSizeRequestReference(this, &xRel, NULL))
wChild = max(wChild, xRel + tbChild->getGeneratorWidth()); wChild = std::max(wChild, xRel + tbChild->getGeneratorWidth());
} }
} }
@ -3201,11 +3201,11 @@ int Textblock::getGeneratorWidth ()
int w0 = lines->size () > 0 ? lines->getLastRef()->maxLineWidth : 0; int w0 = lines->size () > 0 ? lines->getLastRef()->maxLineWidth : 0;
DBG_OBJ_MSGF ("resize", 1, "w0 = %d", w0); DBG_OBJ_MSGF ("resize", 1, "w0 = %d", w0);
int wThis = min(w0 + leftInnerPadding + boxDiffWidth (), lineBreakWidth); int wThis = std::min(w0 + leftInnerPadding + boxDiffWidth (), lineBreakWidth);
DBG_OBJ_MSGF ("resize", 1, "wThis = min(%d + %d + %d, %d) = %d", DBG_OBJ_MSGF ("resize", 1, "wThis = min(%d + %d + %d, %d) = %d",
w0, leftInnerPadding, boxDiffWidth (), lineBreakWidth, w0, leftInnerPadding, boxDiffWidth (), lineBreakWidth,
wThis); wThis);
int w = max(wThis, wChild); int w = std::max(wThis, wChild);
DBG_OBJ_LEAVE_VAL ("max(%d, %d) = %d", wThis, wChild, w); DBG_OBJ_LEAVE_VAL ("max(%d, %d) = %d", wThis, wChild, w);
return w; return w;
} }

View File

@ -1,8 +1,12 @@
static_assert( __cplusplus >= 2020'02 );
#ifndef __DW_TEXTBLOCK_HH__ #ifndef __DW_TEXTBLOCK_HH__
#define __DW_TEXTBLOCK_HH__ #define __DW_TEXTBLOCK_HH__
#include <limits.h> #include <limits.h>
#include <algorithm>
#include "regardingborder.hh" #include "regardingborder.hh"
#include "../lout/misc.hh" #include "../lout/misc.hh"
@ -401,8 +405,8 @@ protected:
inline int totalHeight (int marginNextLine) inline int totalHeight (int marginNextLine)
{ return borderAscent + borderDescent { return borderAscent + borderDescent
// Collapsing of the margins of adjacent lines is done here: // Collapsing of the margins of adjacent lines is done here:
+ lout::misc::max (marginDescent - borderDescent, marginNextLine, + std::max( marginDescent - borderDescent, std::max( marginNextLine,
breakSpace); } breakSpace ) ); }
/* Maximum of all line widths, including this line. Does not /* Maximum of all line widths, including this line. Does not
* include the last space, but the last hyphen width. Please * include the last space, but the last hyphen width. Please

View File

@ -217,7 +217,7 @@ void Textblock::TextblockIterator::getAllocation (int start, int end,
bool regardBorder = bool regardBorder =
textblock->mustBorderBeRegarded (textblock->lines->size ()); textblock->mustBorderBeRegarded (textblock->lines->size ());
textOffset = textOffset =
misc::max (regardBorder ? textblock->newLineLeftBorder : 0, std::max (regardBorder ? textblock->newLineLeftBorder : 0,
textblock->boxOffsetX () + textblock->leftInnerPadding textblock->boxOffsetX () + textblock->leftInnerPadding
+ (textblock->lines->size () == 0 ? + (textblock->lines->size () == 0 ?
textblock->line1OffsetEff : 0)); textblock->line1OffsetEff : 0));
@ -231,7 +231,7 @@ void Textblock::TextblockIterator::getAllocation (int start, int end,
w->content.type == core::Content::WIDGET_IN_FLOW ? w->content.type == core::Content::WIDGET_IN_FLOW ?
w->size.ascent - w->content.widget->getStyle()->margin.top : w->size.ascent - w->content.widget->getStyle()->margin.top :
w->size.ascent; w->size.ascent;
lineBorderAscent = misc::max (lineBorderAscent, borderAscent); lineBorderAscent = std::max (lineBorderAscent, borderAscent);
} }
} }
@ -255,7 +255,7 @@ void Textblock::TextblockIterator::getAllocation (int start, int end,
int wordEnd = strlen(word->content.text); int wordEnd = strlen(word->content.text);
if (start > 0 || end < wordEnd) { if (start > 0 || end < wordEnd) {
end = misc::min(end, wordEnd); /* end could be INT_MAX */ end = std::min(end, wordEnd); /* end could be INT_MAX */
allocation->width = allocation->width =
textblock->textWidth (word->content.text, start, end - start, textblock->textWidth (word->content.text, start, end - start,
word->style, word->style,

View File

@ -366,10 +366,10 @@ Textblock::Line *Textblock::addLine (int firstWord, int lastWord,
line->breakSpace = 0; line->breakSpace = 0;
bool regardBorder = mustBorderBeRegarded (line); bool regardBorder = mustBorderBeRegarded (line);
line->leftOffset = max (regardBorder ? newLineLeftBorder : 0, line->leftOffset = std::max (regardBorder ? newLineLeftBorder : 0,
boxOffsetX () + leftInnerPadding boxOffsetX () + leftInnerPadding
+ (lineIndex == 0 ? line1OffsetEff : 0)); + (lineIndex == 0 ? line1OffsetEff : 0));
line->rightOffset = max (regardBorder ? newLineRightBorder : 0, line->rightOffset = std::max (regardBorder ? newLineRightBorder : 0,
boxRestWidth ()); boxRestWidth ());
DBG_OBJ_MSGF ("construct.line", 1, DBG_OBJ_MSGF ("construct.line", 1,
@ -408,7 +408,7 @@ Textblock::Line *Textblock::addLine (int firstWord, int lastWord,
line->lastOofRefPositionedBeforeThisLine = -1; line->lastOofRefPositionedBeforeThisLine = -1;
} else { } else {
Line *prevLine = lines->getRef (lines->size () - 2); Line *prevLine = lines->getRef (lines->size () - 2);
line->maxLineWidth = max (lineWidth, prevLine->maxLineWidth); line->maxLineWidth = std::max (lineWidth, prevLine->maxLineWidth);
line->lastOofRefPositionedBeforeThisLine = line->lastOofRefPositionedBeforeThisLine =
prevLine->lastOofRefPositionedBeforeThisLine; prevLine->lastOofRefPositionedBeforeThisLine;
} }
@ -435,8 +435,8 @@ Textblock::Line *Textblock::addLine (int firstWord, int lastWord,
// zero height, which may cause endless loops. For this reasons, // zero height, which may cause endless loops. For this reasons,
// the height should be positive (assuming the caller passed // the height should be positive (assuming the caller passed
// minHeight > 0). // minHeight > 0).
line->borderAscent = max (line->borderAscent, minHeight); line->borderAscent = std::max (line->borderAscent, minHeight);
line->marginAscent = max (line->marginAscent, minHeight); line->marginAscent = std::max (line->marginAscent, minHeight);
DBG_OBJ_ARRATTRSET_NUM ("lines", lineIndex, "borderAscent", DBG_OBJ_ARRATTRSET_NUM ("lines", lineIndex, "borderAscent",
line->borderAscent); line->borderAscent);
@ -485,7 +485,7 @@ Textblock::Line *Textblock::addLine (int firstWord, int lastWord,
} }
line->lastOofRefPositionedBeforeThisLine = line->lastOofRefPositionedBeforeThisLine =
max (line->lastOofRefPositionedBeforeThisLine, newLastOofPos); std::max (line->lastOofRefPositionedBeforeThisLine, newLastOofPos);
DBG_OBJ_SET_NUM ("lastLine.lastOofRefPositionedBeforeThisLine", DBG_OBJ_SET_NUM ("lastLine.lastOofRefPositionedBeforeThisLine",
line->lastOofRefPositionedBeforeThisLine); line->lastOofRefPositionedBeforeThisLine);
@ -730,7 +730,7 @@ int Textblock::wrapWordInFlow (int wordIndex, bool wrapAll)
"breakPos = %d, height = %d, lastFloatPos = %d", "breakPos = %d, height = %d, lastFloatPos = %d",
breakPos, height, lastFloatPos); breakPos, height, lastFloatPos);
int startSearch = max (firstIndex, lastFloatPos + 1); int startSearch = std::max (firstIndex, lastFloatPos + 1);
int newFloatPos = -1; int newFloatPos = -1;
// Step 1: search for the next float. // Step 1: search for the next float.
@ -795,13 +795,13 @@ int Textblock::wrapWordInFlow (int wordIndex, bool wrapAll)
// Empty line. Too avoid too many lines one pixel high, we // Empty line. Too avoid too many lines one pixel high, we
// use the float heights. // use the float heights.
if (newLineHasFloatLeft && newLineHasFloatRight) if (newLineHasFloatLeft && newLineHasFloatRight)
minHeight = max (min (newLineLeftFloatHeight, minHeight = std::max (std::min (newLineLeftFloatHeight,
newLineRightFloatHeight), newLineRightFloatHeight),
1); 1);
else if (newLineHasFloatLeft && !newLineHasFloatRight) else if (newLineHasFloatLeft && !newLineHasFloatRight)
minHeight = max (newLineLeftFloatHeight, 1); minHeight = std::max (newLineLeftFloatHeight, 1);
else if (!newLineHasFloatLeft && newLineHasFloatRight) else if (!newLineHasFloatLeft && newLineHasFloatRight)
minHeight = max (newLineRightFloatHeight, 1); minHeight = std::max (newLineRightFloatHeight, 1);
else else
// May this happen? // May this happen?
minHeight = 1; minHeight = 1;
@ -1238,11 +1238,11 @@ int Textblock::calcLinePartHeight (int firstWord, int lastWord)
for (int i = firstWord; i <= lastWord; i++) { for (int i = firstWord; i <= lastWord; i++) {
Word *word = words->getRef (i); Word *word = words->getRef (i);
ascent = max (ascent, word->size.ascent); ascent = std::max (ascent, word->size.ascent);
descent = max (descent, word->size.descent); descent = std::max (descent, word->size.descent);
} }
return max (ascent + descent, 1); return std::max (ascent + descent, 1);
} }
/** /**
@ -1331,11 +1331,11 @@ void Textblock::handleWordExtremes (int wordIndex)
wordExtremes.minWidthIntrinsic + word->hyphenWidth + corrDiffMin; wordExtremes.minWidthIntrinsic + word->hyphenWidth + corrDiffMin;
lastPar->parAdjustmentWidth += lastPar->parAdjustmentWidth +=
wordExtremes.adjustmentWidth + word->hyphenWidth + corrDiffMin; wordExtremes.adjustmentWidth + word->hyphenWidth + corrDiffMin;
lastPar->maxParMin = max (lastPar->maxParMin, lastPar->parMin); lastPar->maxParMin = std::max (lastPar->maxParMin, lastPar->parMin);
lastPar->maxParMinIntrinsic = lastPar->maxParMinIntrinsic =
max (lastPar->maxParMinIntrinsic, lastPar->parMinIntrinsic); std::max (lastPar->maxParMinIntrinsic, lastPar->parMinIntrinsic);
lastPar->maxParAdjustmentWidth = lastPar->maxParAdjustmentWidth =
max (lastPar->maxParAdjustmentWidth, lastPar->parAdjustmentWidth); std::max (lastPar->maxParAdjustmentWidth, lastPar->parAdjustmentWidth);
DBG_OBJ_ARRATTRSET_NUM ("paragraphs", paragraphs->size() - 1, "parMin", DBG_OBJ_ARRATTRSET_NUM ("paragraphs", paragraphs->size() - 1, "parMin",
lastPar->parMin); lastPar->parMin);
@ -1369,9 +1369,9 @@ void Textblock::handleWordExtremes (int wordIndex)
lastPar->parMax += wordExtremes.maxWidth + word->hyphenWidth + corrDiffMax; lastPar->parMax += wordExtremes.maxWidth + word->hyphenWidth + corrDiffMax;
lastPar->parMaxIntrinsic += lastPar->parMaxIntrinsic +=
wordExtremes.maxWidthIntrinsic + word->hyphenWidth + corrDiffMax; wordExtremes.maxWidthIntrinsic + word->hyphenWidth + corrDiffMax;
lastPar->maxParMax = max (lastPar->maxParMax, lastPar->parMax); lastPar->maxParMax = std::max (lastPar->maxParMax, lastPar->parMax);
lastPar->maxParMaxIntrinsic = lastPar->maxParMaxIntrinsic =
max (lastPar->maxParMaxIntrinsic, lastPar->parMaxIntrinsic); std::max (lastPar->maxParMaxIntrinsic, lastPar->parMaxIntrinsic);
DBG_OBJ_ARRATTRSET_NUM ("paragraphs", paragraphs->size() - 1, "parMax", DBG_OBJ_ARRATTRSET_NUM ("paragraphs", paragraphs->size() - 1, "parMax",
lastPar->parMax); lastPar->parMax);
@ -1571,12 +1571,12 @@ void Textblock::accumulateWordForLine (int lineIndex, int wordIndex)
int len = word->style->font->ascent; int len = word->style->font->ascent;
if (word->style->valign == core::style::VALIGN_SUPER) if (word->style->valign == core::style::VALIGN_SUPER)
len += len / 2; len += len / 2;
line->contentAscent = max (line->contentAscent, len); line->contentAscent = std::max (line->contentAscent, len);
len = word->style->font->descent; len = word->style->font->descent;
if (word->style->valign == core::style::VALIGN_SUB) if (word->style->valign == core::style::VALIGN_SUB)
len += word->style->font->ascent / 3; len += word->style->font->ascent / 3;
line->contentDescent = max (line->contentDescent, len); line->contentDescent = std::max (line->contentDescent, len);
int borderAscent, borderDescent, marginAscent, marginDescent; int borderAscent, borderDescent, marginAscent, marginDescent;
@ -1600,7 +1600,7 @@ void Textblock::accumulateWordForLine (int lineIndex, int wordIndex)
borderDescent = marginDescent = word->size.descent; borderDescent = marginDescent = word->size.descent;
if (word->content.type == core::Content::BREAK) if (word->content.type == core::Content::BREAK)
line->breakSpace = max (word->content.breakSpace, line->breakSpace); line->breakSpace = std::max (word->content.breakSpace, line->breakSpace);
else if (word->content.type == core::Content::WIDGET_OOF_REF) { else if (word->content.type == core::Content::WIDGET_OOF_REF) {
word->content.widgetReference->parentRef = word->content.widgetReference->parentRef =
makeParentRefInFlow (lineIndex); makeParentRefInFlow (lineIndex);
@ -1613,10 +1613,10 @@ void Textblock::accumulateWordForLine (int lineIndex, int wordIndex)
"marginDescent = %d", "marginDescent = %d",
borderAscent, borderDescent, marginAscent, marginDescent); borderAscent, borderDescent, marginAscent, marginDescent);
line->borderAscent = max (line->borderAscent, borderAscent); line->borderAscent = std::max (line->borderAscent, borderAscent);
line->borderDescent = max (line->borderDescent, borderDescent); line->borderDescent = std::max (line->borderDescent, borderDescent);
line->marginAscent = max (line->marginAscent, marginAscent); line->marginAscent = std::max (line->marginAscent, marginAscent);
line->marginDescent = max (line->marginDescent, marginDescent); line->marginDescent = std::max (line->marginDescent, marginDescent);
DBG_OBJ_LEAVE (); DBG_OBJ_LEAVE ();
} }
@ -1670,8 +1670,8 @@ void Textblock::accumulateWordData (int wordIndex)
word->totalWidth = prevWord->totalWidth word->totalWidth = prevWord->totalWidth
+ prevWord->origSpace - prevWord->hyphenWidth + prevWord->origSpace - prevWord->hyphenWidth
+ word->size.width + word->hyphenWidth; + word->size.width + word->hyphenWidth;
word->maxAscent = max (prevWord->maxAscent, word->size.ascent); word->maxAscent = std::max (prevWord->maxAscent, word->size.ascent);
word->maxDescent = max (prevWord->maxDescent, word->size.descent); word->maxDescent = std::max (prevWord->maxDescent, word->size.descent);
word->totalSpaceStretchability = word->totalSpaceStretchability =
prevWord->totalSpaceStretchability + getSpaceStretchability(prevWord); prevWord->totalSpaceStretchability + getSpaceStretchability(prevWord);
word->totalSpaceShrinkability = word->totalSpaceShrinkability =
@ -1735,8 +1735,8 @@ int Textblock::calcLineBreakWidth (int lineIndex)
} else } else
leftBorder = rightBorder = 0; leftBorder = rightBorder = 0;
leftBorder = max (leftBorder, boxOffsetX()); leftBorder = std::max (leftBorder, boxOffsetX());
rightBorder = max (rightBorder, boxRestWidth()); rightBorder = std::max (rightBorder, boxRestWidth());
lineBreakWidth -= (leftBorder + rightBorder); lineBreakWidth -= (leftBorder + rightBorder);
@ -1917,7 +1917,7 @@ void Textblock::rewrap ()
// the line list up from this position is rebuild. // the line list up from this position is rebuild.
lines->setSize (wrapRefLines); lines->setSize (wrapRefLines);
DBG_OBJ_SET_NUM ("lines.size", lines->size ()); DBG_OBJ_SET_NUM ("lines.size", lines->size ());
nonTemporaryLines = min (nonTemporaryLines, wrapRefLines); nonTemporaryLines = std::min (nonTemporaryLines, wrapRefLines);
initNewLine (); initNewLine ();
@ -1930,7 +1930,7 @@ void Textblock::rewrap ()
DBG_OBJ_MSGF ("construct.line", 0, "starting with word %d", firstWord); DBG_OBJ_MSGF ("construct.line", 0, "starting with word %d", firstWord);
lastWordDrawn = min (lastWordDrawn, firstWord - 1); lastWordDrawn = std::min (lastWordDrawn, firstWord - 1);
DBG_OBJ_SET_NUM ("lastWordDrawn", lastWordDrawn); DBG_OBJ_SET_NUM ("lastWordDrawn", lastWordDrawn);
for (int i = firstWord; i < words->size (); i++) { for (int i = firstWord; i < words->size (); i++) {
@ -1993,7 +1993,7 @@ void Textblock::fillParagraphs ()
if (lines->size () > 0 && wrapRefParagraphs > 0) { if (lines->size () > 0 && wrapRefParagraphs > 0) {
// Sometimes, wrapRefParagraphs is larger than lines->size(), due to // Sometimes, wrapRefParagraphs is larger than lines->size(), due to
// floats? (Has to be clarified.) // floats? (Has to be clarified.)
int lineNo = min (wrapRefParagraphs, lines->size ()) - 1; int lineNo = std::min (wrapRefParagraphs, lines->size ()) - 1;
firstWordOfLine = lines->getRef(lineNo)->lastWord + 1; firstWordOfLine = lines->getRef(lineNo)->lastWord + 1;
} else } else
firstWordOfLine = 0; firstWordOfLine = 0;
@ -2011,7 +2011,7 @@ void Textblock::fillParagraphs ()
else else
// If there are no paragraphs yet, findParagraphOfWord will return // If there are no paragraphs yet, findParagraphOfWord will return
// -1: use 0 then instead. // -1: use 0 then instead.
parNo = max (0, findParagraphOfWord (firstWordOfLine)); parNo = std::max (0, findParagraphOfWord (firstWordOfLine));
paragraphs->setSize (parNo); paragraphs->setSize (parNo);
DBG_OBJ_SET_NUM ("paragraphs.size", paragraphs->size ()); DBG_OBJ_SET_NUM ("paragraphs.size", paragraphs->size ());
@ -2070,7 +2070,7 @@ void Textblock::calcBorders (int lastOofRef, int height)
if (oofmDefined) { if (oofmDefined) {
int firstWordOfLine = int firstWordOfLine =
lines->size() > 0 ? lines->getLastRef()->lastWord + 1 : 0; lines->size() > 0 ? lines->getLastRef()->lastWord + 1 : 0;
int effOofRef = max (lastOofRef, firstWordOfLine - 1); int effOofRef = std::max (lastOofRef, firstWordOfLine - 1);
int yRel = yOffsetOfLineToBeCreated (), yRef; int yRel = yOffsetOfLineToBeCreated (), yRef;
for (int i = 0; i < NUM_OOFM; i++) { for (int i = 0; i < NUM_OOFM; i++) {
@ -2122,21 +2122,21 @@ void Textblock::calcBorders (int lastOofRef, int height)
// meaningful values.) // meaningful values.)
if (thisHasLeft) { if (thisHasLeft) {
newLineLeftBorder = newLineLeftBorder =
max (newLineLeftBorder, std::max (newLineLeftBorder,
oofm->getLeftBorder (y, height, this, effOofRef) oofm->getLeftBorder (y, height, this, effOofRef)
- getGeneratorX (i)); - getGeneratorX (i));
newLineLeftFloatHeight = newLineLeftFloatHeight =
max (newLineLeftFloatHeight, std::max (newLineLeftFloatHeight,
oofm->getLeftFloatHeight (y, height, this, effOofRef)); oofm->getLeftFloatHeight (y, height, this, effOofRef));
} }
if (thisHasRight) { if (thisHasRight) {
newLineRightBorder = newLineRightBorder =
max (newLineRightBorder, std::max (newLineRightBorder,
oofm->getRightBorder (y, height, this, effOofRef) oofm->getRightBorder (y, height, this, effOofRef)
- getGeneratorRest (i)); - getGeneratorRest (i));
newLineRightFloatHeight = newLineRightFloatHeight =
max (newLineRightFloatHeight, std::max (newLineRightFloatHeight,
oofm->getRightFloatHeight (y, height, this, effOofRef)); oofm->getRightFloatHeight (y, height, this, effOofRef));
} }

View File

@ -59,11 +59,11 @@ bool Rectangle::intersectsWith (Rectangle *otherRect, Rectangle *dest)
otherRect->y < this->y + this->height; otherRect->y < this->y + this->height;
if (doIntersect) { if (doIntersect) {
dest->x = misc::max(this->x, otherRect->x); dest->x = std::max(this->x, otherRect->x);
dest->y = misc::max(this->y, otherRect->y); dest->y = std::max(this->y, otherRect->y);
dest->width = misc::min(this->x + this->width, dest->width = std::min(this->x + this->width,
otherRect->x + otherRect->width) - dest->x; otherRect->x + otherRect->width) - dest->x;
dest->height = misc::min(this->y + this->height, dest->height = std::min(this->y + this->height,
otherRect->y + otherRect->height) - dest->y; otherRect->y + otherRect->height) - dest->y;
} else { } else {
dest->x = dest->y = dest->width = dest->height = 0; dest->x = dest->y = dest->width = dest->height = 0;
@ -152,10 +152,10 @@ void Polygon::addPoint (int x, int y)
points.back().x = x; points.back().x = x;
points.back().y = y; points.back().y = y;
minx = misc::min(minx, x); minx = std::min(minx, x);
miny = misc::min(miny, y); miny = std::min(miny, y);
maxx = misc::max(maxx, x); maxx = std::max(maxx, x);
maxy = misc::max(maxy, y); maxy = std::max(maxy, y);
} }
/** /**
@ -233,18 +233,18 @@ void Region::addRectangle (Rectangle *rPointer)
auto &ownRect= *it++; auto &ownRect= *it++;
int combinedHeight = int combinedHeight =
misc::max(r->y + r->height, ownRect->y + ownRect->height) - std::max(r->y + r->height, ownRect->y + ownRect->height) -
misc::min(r->y, ownRect->y); std::min(r->y, ownRect->y);
int combinedWidth = int combinedWidth =
misc::max(r->x + r->width, ownRect->x + ownRect->width) - std::max(r->x + r->width, ownRect->x + ownRect->width) -
misc::min(r->x, ownRect->x); std::min(r->x, ownRect->x);
if (rectangleList.size() >= 16 || if (rectangleList.size() >= 16 ||
combinedWidth * combinedHeight <= combinedWidth * combinedHeight <=
ownRect->width * ownRect->height + r->width * r->height) { ownRect->width * ownRect->height + r->width * r->height) {
r->x = misc::min(r->x, ownRect->x); r->x = std::min(r->x, ownRect->x);
r->y = misc::min(r->y, ownRect->y); r->y = std::min(r->y, ownRect->y);
r->width = combinedWidth; r->width = combinedWidth;
r->height = combinedHeight; r->height = combinedHeight;

View File

@ -59,7 +59,7 @@ void Embed::getExtremesSimpl (Extremes *extremes)
resource->getExtremes (extremes); resource->getExtremes (extremes);
correctExtremes (extremes, false); correctExtremes (extremes, false);
extremes->adjustmentWidth = extremes->adjustmentWidth =
misc::min (extremes->minWidthIntrinsic, extremes->minWidth); std::min (extremes->minWidthIntrinsic, extremes->minWidth);
} }
void Embed::sizeAllocateImpl (Allocation *allocation) void Embed::sizeAllocateImpl (Allocation *allocation)
@ -408,7 +408,7 @@ int ComplexButtonResource::getAvailWidthOfChild (Widget *child, bool forceValue)
if (embedWidth == -1) if (embedWidth == -1)
return -1; return -1;
else else
return misc::max (embedWidth - 2 * reliefXThickness (), 0); return std::max (embedWidth - 2 * reliefXThickness (), 0);
} }
int ComplexButtonResource::getAvailHeightOfChild (Widget *child, int ComplexButtonResource::getAvailHeightOfChild (Widget *child,
@ -418,7 +418,7 @@ int ComplexButtonResource::getAvailHeightOfChild (Widget *child,
if (embedHeight == -1) if (embedHeight == -1)
return -1; return -1;
else else
return misc::max (embedHeight - 2 * reliefYThickness (), 0); return std::max (embedHeight - 2 * reliefYThickness (), 0);
} }
void ComplexButtonResource::correctRequisitionOfChild (Widget *child, void ComplexButtonResource::correctRequisitionOfChild (Widget *child,
@ -435,14 +435,14 @@ void ComplexButtonResource::correctRequisitionOfChild (Widget *child,
/* FIXME: Typo for getAvailWidth()? */ /* FIXME: Typo for getAvailWidth()? */
int availWidth = getEmbed()->getAvailHeight (false); int availWidth = getEmbed()->getAvailHeight (false);
if (availWidth != -1) { if (availWidth != -1) {
int baseWidth = misc::max (availWidth int baseWidth = std::max (availWidth
- getEmbed()->boxDiffWidth () - getEmbed()->boxDiffWidth ()
- 2 * reliefXThickness (), - 2 * reliefXThickness (),
0); 0);
int newWidth = int newWidth =
child->applyPerWidth (baseWidth, child->getStyle()->width); child->applyPerWidth (baseWidth, child->getStyle()->width);
requisition->width = allowDecreaseWidth ? requisition->width = allowDecreaseWidth ?
newWidth : misc::max (requisition->width, newWidth); newWidth : std::max (requisition->width, newWidth);
} }
} else } else
getEmbed()->correctReqWidthOfChildNoRec (child, requisition, getEmbed()->correctReqWidthOfChildNoRec (child, requisition,
@ -464,7 +464,7 @@ void ComplexButtonResource::correctExtremesOfChild (Widget *child,
if (style::isPerLength (child->getStyle()->width)) { if (style::isPerLength (child->getStyle()->width)) {
int availWidth = getEmbed()->getAvailHeight (false); int availWidth = getEmbed()->getAvailHeight (false);
if (availWidth != -1) { if (availWidth != -1) {
int baseWidth = misc::max (availWidth int baseWidth = std::max (availWidth
- getEmbed()->boxDiffWidth () - getEmbed()->boxDiffWidth ()
- 2 * reliefXThickness (), - 2 * reliefXThickness (),
0); 0);

View File

@ -941,19 +941,19 @@ int Widget::calcWidth (style::Length cssValue, int refWidth, Widget *refWidget,
if (style::isAbsLength (cssValue)) { if (style::isAbsLength (cssValue)) {
DBG_OBJ_MSGF ("resize", 1, "absolute width: %dpx", DBG_OBJ_MSGF ("resize", 1, "absolute width: %dpx",
style::absLengthVal (cssValue)); style::absLengthVal (cssValue));
width = misc::max (style::absLengthVal (cssValue) + boxDiffWidth (), width = std::max (style::absLengthVal (cssValue) + boxDiffWidth (),
limitMinWidth); limitMinWidth);
} else if (style::isPerLength (cssValue)) { } else if (style::isPerLength (cssValue)) {
DBG_OBJ_MSGF ("resize", 1, "percentage width: %g%%", DBG_OBJ_MSGF ("resize", 1, "percentage width: %g%%",
100 * style::perLengthVal_useThisOnlyForDebugging 100 * style::perLengthVal_useThisOnlyForDebugging
(cssValue)); (cssValue));
if (refWidth != -1) if (refWidth != -1)
width = misc::max (applyPerWidth (refWidth, cssValue), limitMinWidth); width = std::max (applyPerWidth (refWidth, cssValue), limitMinWidth);
else { else {
int availWidth = refWidget->getAvailWidth (forceValue); int availWidth = refWidget->getAvailWidth (forceValue);
if (availWidth != -1) { if (availWidth != -1) {
int containerWidth = availWidth - refWidget->boxDiffWidth (); int containerWidth = availWidth - refWidget->boxDiffWidth ();
width = misc::max (applyPerWidth (containerWidth, cssValue), width = std::max (applyPerWidth (containerWidth, cssValue),
limitMinWidth); limitMinWidth);
} else } else
width = -1; width = -1;
@ -1051,20 +1051,20 @@ int Widget::calcHeight (style::Length cssValue, bool usePercentage,
DBG_OBJ_MSGF ("resize", 1, "absolute height: %dpx", DBG_OBJ_MSGF ("resize", 1, "absolute height: %dpx",
style::absLengthVal (cssValue)); style::absLengthVal (cssValue));
height = height =
misc::max (style::absLengthVal (cssValue) + boxDiffHeight (), 0); std::max (style::absLengthVal (cssValue) + boxDiffHeight (), 0);
} else if (style::isPerLength (cssValue)) { } else if (style::isPerLength (cssValue)) {
DBG_OBJ_MSGF ("resize", 1, "percentage height: %g%%", DBG_OBJ_MSGF ("resize", 1, "percentage height: %g%%",
100 * 100 *
style::perLengthVal_useThisOnlyForDebugging (cssValue)); style::perLengthVal_useThisOnlyForDebugging (cssValue));
if (usePercentage) { if (usePercentage) {
if (refHeight != -1) if (refHeight != -1)
height = misc::max (applyPerHeight (refHeight, cssValue), 0); height = std::max (applyPerHeight (refHeight, cssValue), 0);
else { else {
int availHeight = refWidget->getAvailHeight (forceValue); int availHeight = refWidget->getAvailHeight (forceValue);
if (availHeight != -1) { if (availHeight != -1) {
int containerHeight = availHeight - refWidget->boxDiffHeight (); int containerHeight = availHeight - refWidget->boxDiffHeight ();
height = height =
misc::max (applyPerHeight (containerHeight, cssValue), 0); std::max (applyPerHeight (containerHeight, cssValue), 0);
} else } else
height = -1; height = -1;
} }
@ -1791,7 +1791,7 @@ int Widget::getAvailWidthOfChild (Widget *child, bool forceValue)
/* We only compute when forceValue is true */ /* We only compute when forceValue is true */
if (forceValue) { if (forceValue) {
width = misc::max (getAvailWidth (true) - boxDiffWidth (), 0); width = std::max (getAvailWidth (true) - boxDiffWidth (), 0);
if (width != -1) { if (width != -1) {
/* Clamp to min-width and max-width if given */ /* Clamp to min-width and max-width if given */
@ -1847,7 +1847,7 @@ int Widget::getAvailHeightOfChild (Widget *child, bool forceValue)
if (child->getStyle()->height == style::LENGTH_AUTO) { if (child->getStyle()->height == style::LENGTH_AUTO) {
DBG_OBJ_MSG ("resize", 1, "no specification"); DBG_OBJ_MSG ("resize", 1, "no specification");
if (forceValue) if (forceValue)
height = misc::max (getAvailHeight (true) - boxDiffHeight (), 0); height = std::max (getAvailHeight (true) - boxDiffHeight (), 0);
else else
height = -1; height = -1;
} else { } else {
@ -1859,7 +1859,7 @@ int Widget::getAvailHeightOfChild (Widget *child, bool forceValue)
if (style::isAbsLength (child->getStyle()->height)) { if (style::isAbsLength (child->getStyle()->height)) {
DBG_OBJ_MSGF ("resize", 1, "absolute height: %dpx", DBG_OBJ_MSGF ("resize", 1, "absolute height: %dpx",
style::absLengthVal (child->getStyle()->height)); style::absLengthVal (child->getStyle()->height));
height = misc::max (style::absLengthVal (child->getStyle()->height) height = std::max (style::absLengthVal (child->getStyle()->height)
+ child->boxDiffHeight (), 0); + child->boxDiffHeight (), 0);
} else { } else {
assert (style::isPerLength (child->getStyle()->height)); assert (style::isPerLength (child->getStyle()->height));
@ -1872,7 +1872,7 @@ int Widget::getAvailHeightOfChild (Widget *child, bool forceValue)
height = -1; height = -1;
else else
height = height =
misc::max (child->applyPerHeight (availHeight - std::max (child->applyPerHeight (availHeight -
boxDiffHeight (), boxDiffHeight (),
child->getStyle()->height), child->getStyle()->height),
0); 0);

View File

@ -37,18 +37,6 @@ namespace lout {
*/ */
namespace misc { namespace misc {
template <class T> inline T min (T a, T b) { return a < b ? a : b; }
template <class T> inline T max (T a, T b) { return a > b ? a : b; }
template <class T> inline T min (T a, T b, T c)
{
return (min (a, min (b, c)));
}
template <class T> inline T max (T a, T b, T c)
{
return (max (a, max (b, c)));
}
extern const char *prgName; extern const char *prgName;
void init (int argc, char *argv[]); void init (int argc, char *argv[]);