diff options
author | Sebastian Geerken <devnull@localhost> | 2015-06-08 22:18:41 +0200 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2015-06-08 22:18:41 +0200 |
commit | 7c8f69de8bc95c6078ee5fc0b63d263a80f31b44 (patch) | |
tree | b495c1320496cd5ff67c56b6a07d5a79c218455b /dw/textblock_linebreaking.cc | |
parent | 826577556fa8b8eedcf1620b4104115d83dbce0b (diff) |
SRDOP: Positions relative to multiple references; design now considers handling conflicts.
Diffstat (limited to 'dw/textblock_linebreaking.cc')
-rw-r--r-- | dw/textblock_linebreaking.cc | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/dw/textblock_linebreaking.cc b/dw/textblock_linebreaking.cc index 31fcb833..03933830 100644 --- a/dw/textblock_linebreaking.cc +++ b/dw/textblock_linebreaking.cc @@ -463,16 +463,19 @@ Textblock::Line *Textblock::addLine (int firstWord, int lastWord, if (word->content.type == core::Content::WIDGET_OOF_REF) { Widget *widget = word->content.widget; - oof::OutOfFlowMgr *oofm = - searchOutOfFlowMgr (getWidgetOOFIndex (widget)); + int oofmIndex = getWidgetOOFIndex (widget); + oof::OutOfFlowMgr *oofm = searchOutOfFlowMgr (oofmIndex); // See also Textblock::sizeAllocate, and notes there about // vertical alignment. Calculating the vertical position // should probably be centralized. if (oofm) { - assert (sizeRequestPosDefined); - oofm->tellPosition2 (widget, sizeRequestX + xWidget, - sizeRequestY + yLine + (line->borderAscent - - word->size.ascent)); + int xRel = xWidget; + int yRel = yLine + (line->borderAscent - word->size.ascent); + int xRef, yRef; + if (findSizeRequestReference (oofmIndex, &xRef, &yRef)) + oofm->tellPosition2 (widget, xRef + xRel, yRef + yRel); + else + oofm->tellIncompletePosition2 (widget, this, xRel, yRel); } } @@ -757,12 +760,14 @@ int Textblock::wrapWordInFlow (int wordIndex, bool wrapAll) lastFloatPos = newFloatPos; Widget *widget = words->getRef(lastFloatPos)->content.widget; - oof::OutOfFlowMgr *oofm = - searchOutOfFlowMgr (getWidgetOOFIndex (widget)); + int oofmIndex = getWidgetOOFIndex (widget); + oof::OutOfFlowMgr *oofm = searchOutOfFlowMgr (oofmIndex); if (oofm && oofm->mayAffectBordersAtAll ()) { - assert (sizeRequestPosDefined); - oofm->tellPosition1 (widget, sizeRequestX + boxOffsetX (), - sizeRequestY + yNewLine); + int xRel = boxOffsetX (), yRel = yNewLine, xRef, yRef; + if (findSizeRequestReference (oofmIndex, &xRef, &yRef)) + oofm->tellPosition1 (widget, xRef + xRel, yRef + yRel); + else + oofm->tellIncompletePosition1 (widget, this, xRel, yRel); } balanceBreakPosAndHeight (wordIndex, firstIndex, &searchUntil, @@ -852,16 +857,19 @@ int Textblock::wrapWordOofRef (int wordIndex, bool wrapAll) // Floats, which affect either border, are handled in wrapWordInFlow; this // is rather for positioned elements (but only for completeness: // tellPosition1 is not implemented for positioned elements). - oof::OutOfFlowMgr *oofm = searchOutOfFlowMgr (getWidgetOOFIndex (widget)); + int oofmIndex = getWidgetOOFIndex (widget); + oof::OutOfFlowMgr *oofm = searchOutOfFlowMgr (oofmIndex); DBG_OBJ_MSGF ("construct.word", 1, "parentRef = %d, oofm = %p", widget->parentRef, oofm); if (oofm && !oofm->mayAffectBordersAtAll ()) { // TODO Again, "x" is not correct (see above). - assert (sizeRequestPosDefined); - oofm->tellPosition1 (widget, sizeRequestX + boxOffsetX (), - sizeRequestY + yNewLine); + int xRel = boxOffsetX (), yRel = yNewLine, xRef, yRef; + if (findSizeRequestReference (oofmIndex, &xRef, &yRef)) + oofm->tellPosition1 (widget, xRef + xRel, yRef + yRel); + else + oofm->tellIncompletePosition1 (widget, this, xRel, yRel); } - + DBG_OBJ_LEAVE (); return 0; // Words list not changed. @@ -2014,19 +2022,19 @@ void Textblock::calcBorders (int lastOofRef, int height) bool oofmDefined = false; for (int i = 0; i < NUM_OOFM && !oofmDefined; i++) - if (searchOutOfFlowMgr(i)) + if (findSizeRequestReference (i)) oofmDefined = true; if (oofmDefined) { int firstWordOfLine = lines->size() > 0 ? lines->getLastRef()->lastWord + 1 : 0; int effOofRef = misc::max (lastOofRef, firstWordOfLine - 1); - assert (sizeRequestPosDefined); - int y = sizeRequestY + yOffsetOfLineToBeCreated (); + int yRel = yOffsetOfLineToBeCreated (), yRef; for (int i = 0; i < NUM_OOFM; i++) { - oof::OutOfFlowMgr *oofm = searchOutOfFlowMgr(i); - if (oofm) { + oof::OutOfFlowMgr *oofm; + if ((oofm = searchOutOfFlowMgr (i)) && + findSizeRequestReference (i, NULL, &yRef)) { // Consider the example: // // <div> @@ -2059,6 +2067,7 @@ void Textblock::calcBorders (int lastOofRef, int height) // than the first word of the new line, so a solution is to use // the maximum of both. + int y = yRef + yRel; bool thisHasLeft, thisHasRight; thisHasLeft = oofm->hasFloatLeft (this, y, height, this, effOofRef); |