diff options
-rw-r--r-- | dw/outofflowmgr.cc | 43 | ||||
-rw-r--r-- | dw/outofflowmgr.hh | 4 | ||||
-rw-r--r-- | dw/textblock.cc | 10 | ||||
-rw-r--r-- | dw/textblock.hh | 20 |
4 files changed, 69 insertions, 8 deletions
diff --git a/dw/outofflowmgr.cc b/dw/outofflowmgr.cc index cfc8ab39..1e3067d7 100644 --- a/dw/outofflowmgr.cc +++ b/dw/outofflowmgr.cc @@ -1364,6 +1364,49 @@ bool OutOfFlowMgr::hasFloat (Textblock *textblock, Side side, int y, int h, return list->findFirst (textblock, y, h, lastGB, lastExtIndex) != -1; } +int OutOfFlowMgr::getClearPosition (Textblock *tb, core::style::ClearType clear) +{ + bool left = false, right = false; + switch (clear) { + case core::style::CLEAR_NONE: break; + case core::style::CLEAR_LEFT: left = true; break; + case core::style::CLEAR_RIGHT: right = true; break; + case core::style::CLEAR_BOTH: left = right = true; break; + default: assertNotReached (); + } + + return max (left ? getClearPosition (tb, LEFT) : 0, + right ? getClearPosition (tb, RIGHT) : 0); +} + +int OutOfFlowMgr::getClearPosition (Textblock *tb, Side side) +{ + if (!wasAllocated (tb)) + // There is no relation yet to floats generated by other + // textblocks, and this textblocks floats are unimportant for + // the "clear" property. + return 0; + + SortedFloatsVector *list = side == LEFT ? leftFloatsCB : rightFloatsCB; + + int i = list->findFloatIndex (tb, 0); + if (i > 0) + return 0; + + Float *vloat = list->get(i); + // We pass this texblock and 0 (first word, or smallest external + // index, respectively), but search for the last float before this + // position. Therefore this check. + if (vloat->generatingBlock== tb) + i--; + if (i > 0) + return 0; + + vloat = list->get(i); + ensureFloatSize (vloat); + return vloat->yReal + vloat->size.ascent + vloat->size.descent; +} + void OutOfFlowMgr::ensureFloatSize (Float *vloat) { if (vloat->dirty || diff --git a/dw/outofflowmgr.hh b/dw/outofflowmgr.hh index 8bb6ed24..a97af4b9 100644 --- a/dw/outofflowmgr.hh +++ b/dw/outofflowmgr.hh @@ -235,6 +235,8 @@ private: bool hasFloat (Textblock *textblock, Side side, int y, int h, Textblock *lastGB, int lastExtIndex); + int getClearPosition (Textblock *tb, Side side); + void ensureFloatSize (Float *vloat); int getBorderDiff (Textblock *textblock, Float *vloat, Side side); @@ -340,6 +342,8 @@ public: bool hasFloatRight (Textblock *textblock, int y, int h, Textblock *lastGB, int lastExtIndex); + int getClearPosition (Textblock *tb, core::style::ClearType clear); + inline static bool isRefOutOfFlow (int ref) { return ref != -1 && (ref & 1) != 0; } inline static int createRefNormalFlow (int lineNo) { return lineNo << 1; } diff --git a/dw/textblock.cc b/dw/textblock.cc index c905091c..51591193 100644 --- a/dw/textblock.cc +++ b/dw/textblock.cc @@ -164,6 +164,8 @@ Textblock::Textblock (bool limitTextWidth) availAscent = 100; availDescent = 0; + verticalOffset = 0; + this->limitTextWidth = limitTextWidth; for (int layer = 0; layer < core::HIGHLIGHT_NUM_LAYERS; layer++) { @@ -258,7 +260,7 @@ void Textblock::sizeRequestImpl (core::Requisition *requisition) this, innerPadding, getStyle()->boxDiffWidth ()); requisition->width += innerPadding + getStyle()->boxDiffWidth (); - requisition->ascent += getStyle()->boxOffsetY (); + requisition->ascent += verticalOffset + getStyle()->boxOffsetY (); requisition->descent += getStyle()->boxRestHeight (); // Dealing with parts out of flow, which may overlap the borders of @@ -402,6 +404,7 @@ void Textblock::sizeAllocateImpl (core::Allocation *allocation) lineYOffsetCanvasAllocation (line, allocation) + (line->boxAscent - word->size.ascent) - word->content.widget->getStyle()->margin.top; + childAllocation.width = word->size.width; childAllocation.ascent = word->size.ascent + word->content.widget->getStyle()->margin.top; @@ -2513,10 +2516,11 @@ Textblock *Textblock::getTextblockForLine (int firstWord, int lastWord) int Textblock::topOfPossiblyMissingLine (int lineNo) { if (lineNo == 0) - return getStyle()->boxOffsetY(); + return verticalOffset + getStyle()->boxOffsetY(); else { Line *prevLine = lines->getRef (lineNo - 1); - return prevLine->top + prevLine->boxAscent + prevLine->boxDescent + + return verticalOffset + + prevLine->top + prevLine->boxAscent + prevLine->boxDescent + prevLine->breakSpace + getStyle()->boxOffsetY(); } } diff --git a/dw/textblock.hh b/dw/textblock.hh index 1989ecdb..b884587f 100644 --- a/dw/textblock.hh +++ b/dw/textblock.hh @@ -277,10 +277,17 @@ protected: int firstWord; /* first word's index in word vector */ int lastWord; /* last word's index in word vector */ - /* "top" is always relative to the top of the first line, i.e. - * page->lines[0].top is always 0. */ - int top, boxAscent, boxDescent, contentAscent, contentDescent, - breakSpace, leftOffset, offsetCompleteWidget; + + int top; /* "top" is always relative to the top + of the first line, i.e. + page->lines[0].top is always 0. */ + int boxAscent; /* ??? */ + int boxDescent; /* ??? */ + int contentAscent; /* ??? */ + int contentDescent; /* ??? */ + int breakSpace; /* ??? */ + int leftOffset; /* ??? */ + int offsetCompleteWidget; /* ??? */ /* This is similar to descent, but includes the bottom margins of the * widgets within this line. */ @@ -444,6 +451,9 @@ protected: /* These values are set by set_... */ int availWidth, availAscent, availDescent; + // Additional vertical offset, used for the "clear" attribute. + int verticalOffset; + int wrapRefLines, wrapRefParagraphs; /* 0-based. Important: Both are the line numbers, not the value stored in @@ -555,7 +565,7 @@ protected: inline int lineYOffsetCanvasAllocation (Line *line, core::Allocation *allocation) { - return allocation->y + lineYOffsetWidgetAllocation(line, allocation); + return allocation->y + lineYOffsetWidgetAllocation (line, allocation); } /** |