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

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