aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Geerken <devnull@localhost>2014-05-29 19:26:24 +0200
committerSebastian Geerken <devnull@localhost>2014-05-29 19:26:24 +0200
commitd65e9300723acb265e5e67925f155b85c4e3725f (patch)
treed0cfb867680a3f3061a282a64c8a2916bb6b6b66
parent8b7eb5032c7d40e6fe0fe21aff2523b7fa14e8f2 (diff)
Some renaming and cleanup.
-rw-r--r--dw/outofflowmgr.cc133
-rw-r--r--dw/outofflowmgr.hh10
-rw-r--r--dw/textblock.cc66
-rw-r--r--dw/textblock.hh10
-rw-r--r--dw/textblock_linebreaking.cc6
5 files changed, 63 insertions, 162 deletions
diff --git a/dw/outofflowmgr.cc b/dw/outofflowmgr.cc
index bbfe42e0..ea089cdb 100644
--- a/dw/outofflowmgr.cc
+++ b/dw/outofflowmgr.cc
@@ -616,7 +616,7 @@ void OutOfFlowMgr::sizeAllocateEnd (Textblock *caller)
Textblock *tb = key->getTypedValue();
tbInfo->updateAllocation ();
- tbInfo->availWidth = tb->getAvailWidth ();
+ tbInfo->lineBreakWidth = tb->getLineBreakWidth ();
}
// There are cases where some allocated floats (TODO: later also
@@ -709,8 +709,8 @@ bool OutOfFlowMgr::hasRelationChanged (TBInfo *tbInfo, Side side,
int newFlx =
calcFloatX (vloat, side,
- gba->x - containingBlockAllocation.x,
- gba->width, vloat->generatingBlock->getAvailWidth ());
+ gba->x - containingBlockAllocation.x, gba->width,
+ vloat->generatingBlock->getLineBreakWidth ());
int newFly = vloat->generatingBlock->getAllocation()->y
- containingBlockAllocation.y + vloat->yReal;
@@ -1042,11 +1042,11 @@ void OutOfFlowMgr::sizeAllocateFloats (Side side, int newLastAllocatedFloat)
ensureFloatSize (vloat);
Allocation *gba = getAllocation (vloat->generatingBlock);
- int availWidth = vloat->generatingBlock->getAvailWidth();
+ int lineBreakWidth = vloat->generatingBlock->getLineBreakWidth();
Allocation childAllocation;
childAllocation.x = cba->x +
- calcFloatX (vloat, side, gba->x - cba->x, gba->width, availWidth);
+ calcFloatX (vloat, side, gba->x - cba->x, gba->width, lineBreakWidth);
childAllocation.y = gba->y + vloat->yReal;
childAllocation.width = vloat->size.width;
childAllocation.ascent = vloat->size.ascent;
@@ -1067,11 +1067,11 @@ void OutOfFlowMgr::sizeAllocateFloats (Side side, int newLastAllocatedFloat)
* gbX is given relative to the CB, as is the return value.
*/
int OutOfFlowMgr::calcFloatX (Float *vloat, Side side, int gbX, int gbWidth,
- int gbAvailWidth)
+ int gbLineBreakWidth)
{
DBG_OBJ_MSGF ("resize.oofm", 0, "<b>calcFloatX</b> (%p, %s, %d, %d, %d)",
vloat->getWidget (), side == LEFT ? "LEFT" : "RIGHT", gbX,
- gbWidth, gbAvailWidth);
+ gbWidth, gbLineBreakWidth);
DBG_OBJ_MSG_START ();
int gbActualWidth, x;
@@ -1087,11 +1087,11 @@ int OutOfFlowMgr::calcFloatX (Float *vloat, Side side, int gbX, int gbWidth,
case RIGHT:
// In some cases, the actual (allocated) width is too large; we
- // use the "available" width here.
- gbActualWidth = min (gbWidth, gbAvailWidth);
+ // use the line break width here.
+ gbActualWidth = min (gbWidth, gbLineBreakWidth);
DBG_OBJ_MSGF ("resize.oofm", 1,
"right: gbActualWidth = min (%d, %d) = %d",
- gbWidth, gbAvailWidth, gbActualWidth);
+ gbWidth, gbLineBreakWidth, gbActualWidth);
// Similar for right floats, but in this case, floats are
// shifted to the right when they are too big (instead of
@@ -1560,7 +1560,7 @@ bool OutOfFlowMgr::collidesH (Float *vloat, Float *other, SFVType type)
if (vloat->generatingBlock == other->generatingBlock)
collidesH = vloat->size.width + other->size.width
+ vloat->generatingBlock->getStyle()->boxDiffWidth()
- > vloat->generatingBlock->getAvailWidth();
+ > vloat->generatingBlock->getLineBreakWidth();
else {
assert (wasAllocated (vloat->generatingBlock));
assert (wasAllocated (other->generatingBlock));
@@ -1577,7 +1577,7 @@ bool OutOfFlowMgr::collidesH (Float *vloat, Float *other, SFVType type)
vloat->getWidget()->getStyle()->vloat == FLOAT_LEFT ?
LEFT : RIGHT,
gba->x, gba->width,
- vloat->generatingBlock->getAvailWidth ());
+ vloat->generatingBlock->getLineBreakWidth ());
// Generally: right border of the left float > left border of
// the right float (all in canvas coordinates).
@@ -1676,13 +1676,13 @@ void OutOfFlowMgr::getFloatsSize (Requisition *cbReq, Side side, int *width,
if (vloat->generatingBlock == containingBlock) {
x = calcFloatX (vloat, side, 0, cbReq->width,
- vloat->generatingBlock->getAvailWidth ());
+ vloat->generatingBlock->getLineBreakWidth ());
y = vloat->yReal;
} else {
Allocation *gba = getAllocation(vloat->generatingBlock);
x = calcFloatX (vloat, side,
gba->x - containingBlockAllocation.x, gba->width,
- vloat->generatingBlock->getAvailWidth ());
+ vloat->generatingBlock->getLineBreakWidth ());
y = gba->y - containingBlockAllocation.y + vloat->yReal;
}
@@ -1926,7 +1926,7 @@ int OutOfFlowMgr::getBorder (Textblock *textblock, Side side, int y, int h,
fla->x, fla->width, tba->x, thisBorder);
} else {
// See also calcFloatX.
- int tbAvWidth = textblock->getAvailWidth ();
+ int tbAvWidth = textblock->getLineBreakWidth ();
thisBorder = tba->x + min (tba->width, tbAvWidth) - fla->x;
DBG_OBJ_MSGF ("border", 1,
"not GB: thisBorder = %d + min (%d, %d) - %d "
@@ -2066,9 +2066,9 @@ int OutOfFlowMgr::getClearPosition (Textblock *tb, Side side)
void OutOfFlowMgr::ensureFloatSize (Float *vloat)
{
if (vloat->dirty ||
- (vloat->cbAvailWidth != containingBlock->getAvailWidth () &&
+ (vloat->cbLineBreakWidth != containingBlock->getLineBreakWidth () &&
(// If the size of the containing block has changed (represented
- // currently by the available width), a recalculation of a relative
+ // currently by the line break width), a recalculation of a relative
// float width may also be necessary.
isPerLength (vloat->getWidget()->getStyle()->width) ||
// Similar for "auto" widths of textblocks etc.
@@ -2106,33 +2106,33 @@ void OutOfFlowMgr::ensureFloatSize (Float *vloat)
// a narrow table column. To prevent this, the width of
// the *float* has to be limited (cf. also getExtremes).
- int availWidth, leftDiff, rightDiff;
+ int lineBreakWidth, leftDiff, rightDiff;
if (getFloatDiffToCB (vloat, &leftDiff, &rightDiff))
- availWidth = containingBlock->getAvailWidth()
+ lineBreakWidth = containingBlock->getLineBreakWidth()
- (vloat->getWidget()->getStyle()->vloat == FLOAT_LEFT ?
leftDiff : rightDiff);
else
// Not allocated: next allocation will take care.
- availWidth = containingBlock->getAvailWidth();
+ lineBreakWidth = containingBlock->getLineBreakWidth();
int width;
if (cssWidth == LENGTH_AUTO) {
- width = availWidth;
+ width = lineBreakWidth;
DBG_OBJ_MSGF ("resize.oofm", 1, "setting width 'auto': %d",
width);
} else {
- width = multiplyWithPerLength (availWidth, cssWidth);
+ width = multiplyWithPerLength (lineBreakWidth, cssWidth);
// Some more corrections (nonsense percentage values):
if (width < 1)
width = 1;
- if (width > availWidth)
- width = availWidth;
+ if (width > lineBreakWidth)
+ width = lineBreakWidth;
DBG_OBJ_MSGF ("resize.oofm", 1,
"about to set percentage width: %d * %g -> %d",
- availWidth, perLengthVal (cssWidth), width);
+ lineBreakWidth, perLengthVal (cssWidth), width);
width = adjustFloatWidth (width, &extremes);
}
@@ -2175,7 +2175,7 @@ void OutOfFlowMgr::ensureFloatSize (Float *vloat)
DBG_OBJ_MSGF ("resize.oofm", 1, "sizeRequest (2) => %d * (%d + %d)",
vloat->size.width, vloat->size.ascent, vloat->size.descent);
- vloat->cbAvailWidth = containingBlock->getAvailWidth ();
+ vloat->cbLineBreakWidth = containingBlock->getLineBreakWidth ();
vloat->dirty = false;
DBG_OBJ_MSGF ("resize.oofm", 1, "final size: %d * (%d + %d)",
@@ -2197,9 +2197,10 @@ void OutOfFlowMgr::ensureFloatSize (Float *vloat)
int OutOfFlowMgr::adjustFloatWidth (int width, Extremes *extremes)
{
DBG_OBJ_MSGF ("resize.oofm", 0,
- "<b>adjustFloatWidth</b> (%d, (%d, %d)) [CB->availWidth = %d]",
+ "<b>adjustFloatWidth</b> (%d, (%d, %d)) "
+ "[CB->lineBreakWidth = %d]",
width, extremes->minWidth, extremes->maxWidth,
- containingBlock->getAvailWidth());
+ containingBlock->getLineBreakWidth());
DBG_OBJ_MSG_START ();
// Consider extremes (as described above).
@@ -2211,14 +2212,15 @@ int OutOfFlowMgr::adjustFloatWidth (int width, Extremes *extremes)
width = extremes->maxWidth;
DBG_OBJ_MSGF ("resize.oofm", 1, "adjusted to maxWidth: %d", width);
}
- // Finally, consider the available width of the containing
- // block. Order is important: to prevent problems, the available
+ // Finally, consider the line break width of the containing
+ // block. Order is important: to prevent problems, the line break
// width of the float must never be larger than the one of the
// containing block. (Somewhat hackish, will be solved cleaner with
// GROWS.)
- if (width > containingBlock->getAvailWidth()) {
- width = containingBlock->getAvailWidth();
- DBG_OBJ_MSGF ("resize.oofm", 1, "adjusted to CB::availWidth: %d", width);
+ if (width > containingBlock->getLineBreakWidth()) {
+ width = containingBlock->getLineBreakWidth();
+ DBG_OBJ_MSGF ("resize.oofm", 1, "adjusted to CB::lineBreakWidth: %d",
+ width);
}
DBG_OBJ_MSGF ("resize.oofm", 1, "=> %d", width);
@@ -2245,69 +2247,8 @@ void OutOfFlowMgr::getAbsolutelyPositionedExtremes (Extremes *cbExtr,
void OutOfFlowMgr::ensureAbsolutelyPositionedSizeAndPosition
(AbsolutelyPositioned *abspos)
{
- // No work is done anymore on this, since widget sizes will be
- // redesigned before absolute positions are finished.
-
- if (abspos->dirty) {
- Style *style = abspos->widget->getStyle();
- int availWidth = containingBlock->getAvailWidth();
- int availHeight =
- containingBlock->getAvailAscent() + containingBlock->getAvailDescent();
-
- if (style->left == LENGTH_AUTO)
- abspos->xCB = 0;
- else
- abspos->xCB =
- calcValueForAbsolutelyPositioned (abspos, style->left, availWidth);
-
- if (style->top == LENGTH_AUTO)
- abspos->yCB = 0;
- else
- abspos->yCB =
- calcValueForAbsolutelyPositioned (abspos, style->top, availHeight);
-
- abspos->width = -1; // undefined
- if (style->width != LENGTH_AUTO)
- abspos->width = calcValueForAbsolutelyPositioned (abspos, style->width,
- availWidth);
- else if (style->right != LENGTH_AUTO) {
- int right = calcValueForAbsolutelyPositioned (abspos, style->right,
- availWidth);
- abspos->width = max (0, availWidth - (abspos->xCB + right));
- }
-
- abspos->height = -1; // undefined
- if (style->height != LENGTH_AUTO)
- abspos->height = calcValueForAbsolutelyPositioned (abspos,
- style->height,
- availHeight);
- else if (style->bottom != LENGTH_AUTO) {
- int bottom = calcValueForAbsolutelyPositioned (abspos, style->bottom,
- availHeight);
- abspos->height = max (0, availHeight - (abspos->yCB + bottom));
- }
-
- if (abspos->width != -1)
- abspos->widget->setWidth (abspos->width);
-
- if (abspos->height != -1) {
- abspos->widget->setAscent (abspos->height);
- abspos->widget->setDescent (0); // TODO
- }
-
- if (abspos->width == -1 || abspos->height == -1) {
- Requisition req;
- abspos->widget->sizeRequest (&req);
-
- if (abspos->width == -1)
- abspos->width = req.width;
-
- if (abspos->height == -1)
- abspos->height = req.ascent + req.descent;
- }
-
- abspos->dirty = false;
- }
+ // TODO
+ assertNotReached ();
}
int OutOfFlowMgr::calcValueForAbsolutelyPositioned
diff --git a/dw/outofflowmgr.hh b/dw/outofflowmgr.hh
index 429482fd..4d19a904 100644
--- a/dw/outofflowmgr.hh
+++ b/dw/outofflowmgr.hh
@@ -97,9 +97,9 @@ private:
respectively. -1 initially. */
int sideSpanningIndex, mark;
core::Requisition size;
- int cbAvailWidth; /* On which the calculation of relative sizes
- is based. Height not yet used, and probably
- not added before size redesign. */
+ int cbLineBreakWidth; /* On which the calculation of relative sizes
+ is based. Height not yet used, and probably
+ not added before size redesign. */
bool dirty, sizeChangedSinceLastAllocation;
Float (OutOfFlowMgr *oofm, core::Widget *widget,
@@ -172,7 +172,7 @@ private:
class TBInfo: public WidgetInfo
{
public:
- int availWidth;
+ int lineBreakWidth;
int index; // position within "tbInfos"
TBInfo *parent;
@@ -272,7 +272,7 @@ private:
void moveFromGBToCB (Side side);
void sizeAllocateFloats (Side side, int newLastAllocatedFloat);
int calcFloatX (Float *vloat, Side side, int gbX, int gbWidth,
- int gbAvailWidth);
+ int gbLineBreakWidth);
bool hasRelationChanged (TBInfo *tbInfo,int *minFloatPos,
core::Widget **minFloat);
diff --git a/dw/textblock.cc b/dw/textblock.cc
index 18abe9c8..c1308b0a 100644
--- a/dw/textblock.cc
+++ b/dw/textblock.cc
@@ -264,14 +264,10 @@ Textblock::Textblock (bool limitTextWidth)
hoverLink = -1;
- // random values
- availWidth = 100;
- availAscent = 100;
- availDescent = 0;
+ // random value
+ lineBreakWidth = 100;
- DBG_OBJ_SET_NUM ("availWidth", availWidth);
- DBG_OBJ_SET_NUM ("availAscent", availAscent);
- DBG_OBJ_SET_NUM ("availDescent", availDescent);
+ DBG_OBJ_SET_NUM ("lineBreakWidth", availWidth);
verticalOffset = 0;
DBG_OBJ_SET_NUM ("verticalOffset", verticalOffset);
@@ -396,8 +392,8 @@ void Textblock::sizeRequestImpl (core::Requisition *requisition)
availWidth, requisition->width, requisition->ascent,
requisition->descent);
- if (requisition->width < availWidth) {
- requisition->width = availWidth;
+ if (requisition->width < lineBreakWidth) {
+ requisition->width = lineBreakWidth;
DBG_OBJ_MSGF ("resize", 1, "adjusting to availWidth => %d",
requisition->width);
}
@@ -776,12 +772,12 @@ void Textblock::setWidth (int width)
{
/* If limitTextWidth is set to YES, a queueResize() may also be
* necessary. */
- if (availWidth != width || limitTextWidth) {
+ if (lineBreakWidth != width || limitTextWidth) {
DBG_OBJ_MSGF ("resize", 0, "<b>setWidth</b> (%d)", width);
DBG_OBJ_MSG_START ();
- availWidth = width;
- DBG_OBJ_SET_NUM ("availWidth", availWidth);
+ lineBreakWidth = width;
+ DBG_OBJ_SET_NUM ("lineBreakWidth", availWidth);
queueResize (OutOfFlowMgr::createRefNormalFlow (0), false);
mustQueueResize = false;
redrawY = 0;
@@ -791,36 +787,6 @@ void Textblock::setWidth (int width)
}
}
-void Textblock::setAscent (int ascent)
-{
- if (availAscent != ascent) {
- DBG_OBJ_MSGF ("resize", 0, "<b>setAscent</b> (%d)", ascent);
- DBG_OBJ_MSG_START ();
-
- availAscent = ascent;
- DBG_OBJ_SET_NUM ("availAscent", availAscent);
- queueResize (OutOfFlowMgr::createRefNormalFlow (0), false);
- mustQueueResize = false;
-
- DBG_OBJ_MSG_END ();
- }
-}
-
-void Textblock::setDescent (int descent)
-{
- if (availDescent != descent) {
- DBG_OBJ_MSGF ("resize", 0, "<b>setDescent</b> (%d)", descent);
- DBG_OBJ_MSG_START ();
-
- availDescent = descent;
- DBG_OBJ_SET_NUM ("availDescent", availDescent);
- queueResize (OutOfFlowMgr::createRefNormalFlow (0), false);
- mustQueueResize = false;
-
- DBG_OBJ_MSG_END ();
- }
-}
-
bool Textblock::isBlockLevel ()
{
return true;
@@ -1084,13 +1050,12 @@ void Textblock::calcWidgetSize (core::Widget *widget, core::Requisition *size)
DBG_OBJ_MSGF ("resize", 0, "<b>calcWidgetSize</b> (%p, ...)", widget);
core::Requisition requisition;
- int availWidth, availAscent, availDescent;
+ int availWidth;
core::style::Style *wstyle = widget->getStyle();
/* We ignore line1_offset[_eff]. */
- availWidth = this->availWidth - getStyle()->boxDiffWidth () - innerPadding;
- availAscent = this->availAscent - getStyle()->boxDiffHeight ();
- availDescent = this->availDescent;
+ availWidth =
+ this->lineBreakWidth - getStyle()->boxDiffWidth () - innerPadding;
if (widget->usesHints ()) {
// This is a simplified version of calcAvailWidth (see there for
@@ -1109,11 +1074,8 @@ void Textblock::calcWidgetSize (core::Widget *widget, core::Requisition *size)
misc::max (availWidth - (newLineLeftBorder + newLineRightBorder),
0);
- DBG_OBJ_MSGF ("resize", 1, "setting hints: %d, %d, %d",
- corrAvailWidth, availAscent, availDescent);
+ DBG_OBJ_MSGF ("resize", 1, "setting hint: %d", corrAvailWidth);
widget->setWidth (corrAvailWidth);
- widget->setAscent (availAscent);
- widget->setDescent (availDescent);
widget->sizeRequest (size);
DBG_OBJ_MSGF ("resize", 1, "sizeRequest => %d * (%d + %d)",
size->width, size->ascent, size->descent);
@@ -1147,10 +1109,12 @@ void Textblock::calcWidgetSize (core::Widget *widget, core::Requisition *size)
+ wstyle->boxDiffHeight ();
size->descent = 0;
} else {
- size->ascent =
+ // TODO Old code:
+ /*size->ascent =
core::style::multiplyWithPerLength (wstyle->height, availAscent);
size->descent =
core::style::multiplyWithPerLength (wstyle->height, availDescent);
+ */
}
}
diff --git a/dw/textblock.hh b/dw/textblock.hh
index 51d82f55..37786a1e 100644
--- a/dw/textblock.hh
+++ b/dw/textblock.hh
@@ -516,8 +516,8 @@ protected:
int redrawY;
int lastWordDrawn;
- /* These values are set by set_... */
- int availWidth, availAscent, availDescent;
+ /* This value is (currently) set by setAscent(). */
+ int lineBreakWidth;
// Additional vertical offset, used for the "clear" attribute.
int verticalOffset;
@@ -754,8 +754,6 @@ protected:
void notifySetAsTopLevel();
void notifySetParent();
void setWidth (int width);
- void setAscent (int ascent);
- void setDescent (int descent);
bool isBlockLevel ();
@@ -820,9 +818,7 @@ public:
queueResize (-1, extremesChanged);
DBG_OBJ_MSG_END ();
}
- inline int getAvailWidth () { return availWidth; }
- inline int getAvailAscent () { return availAscent; }
- inline int getAvailDescent () { return availDescent; }
+ inline int getLineBreakWidth () { return lineBreakWidth; }
};
#define DBG_SET_WORD_PENALTY(n, i, is) \
diff --git a/dw/textblock_linebreaking.cc b/dw/textblock_linebreaking.cc
index 6e9575e0..7b9110ee 100644
--- a/dw/textblock_linebreaking.cc
+++ b/dw/textblock_linebreaking.cc
@@ -1602,7 +1602,7 @@ int Textblock::calcAvailWidth (int lineIndex)
lineIndex, lines->size());
DBG_OBJ_MSG_START ();
- int availWidth = this->availWidth - innerPadding;
+ int availWidth = this->lineBreakWidth - innerPadding;
if (limitTextWidth &&
layout->getUsesViewport () &&
// margin/border/padding will be subtracted later, via OOFM.
@@ -1639,7 +1639,7 @@ void Textblock::initLine1Offset (int wordIndex)
/* Test whether line1Offset can be used. */
if (wordIndex == 0) {
if (ignoreLine1OffsetSometimes &&
- line1Offset + word->size.width > availWidth) {
+ line1Offset + word->size.width > lineBreakWidth) {
line1OffsetEff = 0;
} else {
int indent = 0;
@@ -1650,7 +1650,7 @@ void Textblock::initLine1Offset (int wordIndex)
} else {
if (core::style::isPerLength(getStyle()->textIndent)) {
indent = core::style::multiplyWithPerLengthRounded
- (this->availWidth, getStyle()->textIndent);
+ (lineBreakWidth, getStyle()->textIndent);
} else {
indent = core::style::absLengthVal (getStyle()->textIndent);
}