diff options
Diffstat (limited to 'dw')
-rw-r--r-- | dw/Makefile.am | 4 | ||||
-rw-r--r-- | dw/outofflowmgr.cc | 55 | ||||
-rw-r--r-- | dw/textblock.cc | 30 | ||||
-rw-r--r-- | dw/textblock_linebreaking.cc | 50 |
4 files changed, 108 insertions, 31 deletions
diff --git a/dw/Makefile.am b/dw/Makefile.am index 47ec5275..5306c5a5 100644 --- a/dw/Makefile.am +++ b/dw/Makefile.am @@ -1,7 +1,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir) \ - -DDILLO_LIBDIR='"$(pkglibdir)/"' - + -DDILLO_LIBDIR='"$(pkglibdir)/"' \ + -DCUR_WORKING_DIR='"@BASE_CUR_WORKING_DIR@/dw"' noinst_LIBRARIES = \ libDw-core.a \ diff --git a/dw/outofflowmgr.cc b/dw/outofflowmgr.cc index bb7f63da..634422c9 100644 --- a/dw/outofflowmgr.cc +++ b/dw/outofflowmgr.cc @@ -355,14 +355,14 @@ OutOfFlowMgr::~OutOfFlowMgr () void OutOfFlowMgr::sizeAllocateStart (Allocation *containingBlockAllocation) { - DBG_OBJ_MSG ("resize", 0, "<b>sizeAllocateStart</b>"); + DBG_OBJ_MSG ("resize.floats", 0, "<b>sizeAllocateStart</b>"); this->containingBlockAllocation = *containingBlockAllocation; containingBlockWasAllocated = true; } void OutOfFlowMgr::sizeAllocateEnd () { - DBG_OBJ_MSG ("resize", 0, "<b>sizeAllocateStart</b>"); + DBG_OBJ_MSG ("resize.floats", 0, "<b>sizeAllocateEnd</b>"); DBG_OBJ_MSG_START (); // 1. Move floats from GB lists to the one CB list. @@ -411,6 +411,9 @@ void OutOfFlowMgr::sizeAllocateEnd () int c2 = isTextblockCoveredByFloats (tb, tbAllocation->x, tbAllocation->y, width, height, &newPos, &newFloat); + DBG_OBJ_MSGF ("resize.floats", 0, "%p covered? then: %s, now: %s.", + tb, c1 ? "yes" : "no", c2 ? "yes" : "no"); + if (c1 || c2) { if (!c1) tb->borderChanged (newPos, newFloat); @@ -526,14 +529,20 @@ bool OutOfFlowMgr::isTextblockCoveredByFloat (Float *vloat, Textblock *tb, void OutOfFlowMgr::checkChangedFloatSizes () { + DBG_OBJ_MSG ("resize.floats", 0, "<b>checkChangedFloatSizes</b>"); + DBG_OBJ_MSG_START (); + checkChangedFloatSizes (leftFloatsCB); checkChangedFloatSizes (rightFloatsCB); + + DBG_OBJ_MSG_END (); } void OutOfFlowMgr::checkChangedFloatSizes (SortedFloatsVector *list) { - DBG_OBJ_MSG ("resize", 0, "<b>checkChangedFloatSizes</b>"); - DBG_OBJ_MSG_START (); + DBG_OBJ_MSG ("resize.floats", 0, + "<b>checkChangedFloatSizes</b> (<i>list</i>)"); + DBG_OBJ_MSG_START (); // TODO (i) Comment (ii) linear search? for (int i = 0; i < list->size(); i++) { @@ -542,7 +551,9 @@ void OutOfFlowMgr::checkChangedFloatSizes (SortedFloatsVector *list) if (vloat->sizeChangedSinceLastAllocation && wasAllocated (vloat->generatingBlock)) { - //printf ("=== start checking textblocks ===\n"); + DBG_OBJ_MSGF ("resize.floats", 1, "float %p: checking textblocks", + vloat->widget); + DBG_OBJ_MSG_START (); for (lout::container::typed::Iterator<TypedPointer <Textblock> > it = tbInfosByTextblock->iterator (); @@ -551,25 +562,22 @@ void OutOfFlowMgr::checkChangedFloatSizes (SortedFloatsVector *list) if (wasAllocated (tb)) { Allocation *tba = getAllocation (tb); int floatPos; - + if (isTextblockCoveredByFloat (vloat, tb, tba->x - containingBlockAllocation.x, tba->y - containingBlockAllocation.y, tba->width, tba->ascent + tba->descent, &floatPos)) { - //printf (" ---> yes: %p (parent: %p)\n", tb, - // tb->getParent()); + DBG_OBJ_MSGF ("resize.floats", 2, "%p: covereds", tb); tb->borderChanged (floatPos, vloat->widget); - } //else - // printf (" ---> not covered: %p (parent: %p)\n", tb, - // tb->getParent()); - } //else - // printf (" ---> not allocated: %p (parent: %p)\n", tb, - // tb->getParent()); + } else + DBG_OBJ_MSGF ("resize.floats", 2, "%p: not covered", tb); + } else + DBG_OBJ_MSGF ("resize.floats", 2, "%p: not allocated", tb); } - - //printf ("=== end checking textblocks ===\n"); vloat->sizeChangedSinceLastAllocation = false; + + DBG_OBJ_MSG_END (); } } @@ -942,7 +950,7 @@ void OutOfFlowMgr::tellPosition (Widget *widget, int yReq) void OutOfFlowMgr::tellFloatPosition (Widget *widget, int yReq) { - DBG_OBJ_MSGF ("resize", 0, "<b>tellFloatPosition</b> (%p, %d)", + DBG_OBJ_MSGF ("resize.floats", 0, "<b>tellFloatPosition</b> (%p, %d)", widget, yReq); DBG_OBJ_MSG_START (); @@ -1027,7 +1035,8 @@ void OutOfFlowMgr::tellFloatPosition (Widget *widget, int yReq) } } - DBG_OBJ_MSGF ("resize", 1, "oldY = %d, vloat->yReq = %d, vloat->yReal = %d", + DBG_OBJ_MSGF ("resize.floats", 1, + "oldY = %d, vloat->yReq = %d, vloat->yReal = %d", oldY, vloat->yReq, vloat->yReal); // No call neccessary when yReal has not changed. (Notice that @@ -1068,10 +1077,10 @@ bool OutOfFlowMgr::collides (Float *vloat, Float *other, int *yReal) void OutOfFlowMgr::checkCoveragePosChanged (Float *vloat, int oldY) { - DBG_OBJ_MSGF ("resize", 0, + DBG_OBJ_MSGF ("resize.floats", 0, "<b>checkCoveragePosChanged</b> (<widget: %p>, %d)", vloat->widget, oldY); - DBG_OBJ_MSG_START (); + DBG_OBJ_MSG_START (); // Only this float has been changed (see tellFloatPosition), so // only this float has to be tested against all textblocks. @@ -1096,6 +1105,12 @@ void OutOfFlowMgr::checkCoveragePosChanged (Float *vloat, int oldY) bool covered = (y2old > tby1 && y1old < tby2) || (y2new > tby1 && y1new < tby2); + DBG_OBJ_MSGF ("resize.floats", 0, + "%p covered: (%d > %d && %d < %d) || " + "(%d > %d && %d < %d? %s.\n", + textblock, y2old, tby1, y1old, tby2, y2new, tby1, + y1new,tby2, covered ? "Yes" : "No"); + if (covered) { int yTextblock = gba->y + min (oldY, vloat->yReal) - tba->y; textblock->borderChanged (yTextblock, vloat->widget); diff --git a/dw/textblock.cc b/dw/textblock.cc index fcbfe32b..468a7a44 100644 --- a/dw/textblock.cc +++ b/dw/textblock.cc @@ -256,6 +256,8 @@ Textblock::Textblock (bool limitTextWidth) wrapRefLines = wrapRefParagraphs = -1; + DBG_OBJ_SET_NUM ("lines.size", lines->size ()); + DBG_OBJ_SET_NUM ("words.size", words->size ()); DBG_OBJ_SET_NUM ("wrapRefLines", wrapRefLines); DBG_OBJ_SET_NUM ("wrapRefParagraphs", wrapRefParagraphs); @@ -1636,6 +1638,7 @@ Textblock::Word *Textblock::addWord (int width, int ascent, int descent, short flags, core::style::Style *style) { words->increase (); + DBG_OBJ_SET_NUM ("words.size", words->size ()); int wordNo = words->size () - 1; initWord (wordNo); fillWord (wordNo, width, ascent, descent, flags, style); @@ -2113,6 +2116,10 @@ void Textblock::addText0 (const char *text, size_t len, short flags, word->content.type = core::Content::TEXT; word->content.text = layout->textZone->strndup(text, len); + DBG_OBJ_ARRATTRSET_STR ("words", words->size () - 1, "type", "TEXT"); + DBG_OBJ_ARRATTRSET_STR ("words", words->size () - 1, + "text/widget/breakSpace", word->content.text); + // The following debug message may be useful to identify the // different textblocks. @@ -2154,6 +2161,11 @@ void Textblock::addWidget (core::Widget *widget, core::style::Style *style) word->content.type = core::Content::WIDGET_OOF_REF; word->content.widget = widget; word->style = style; + + DBG_OBJ_ARRATTRSET_STR ("words", words->size () - 1, "type", + "WIDGET_OOF_REF"); + DBG_OBJ_ARRATTRSET_PTR ("words", words->size () - 1, + "text/widget/breakSpace", word->content.widget); } else { PRINTF (" -> within flow.\n"); @@ -2166,10 +2178,14 @@ void Textblock::addWidget (core::Widget *widget, core::style::Style *style) core::Requisition size; calcWidgetSize (widget, &size); - Word *word = - addWord (size.width, size.ascent, size.descent, 0, style); + Word *word = addWord (size.width, size.ascent, size.descent, 0, style); word->content.type = core::Content::WIDGET_IN_FLOW; word->content.widget = widget; + + DBG_OBJ_ARRATTRSET_STR ("words", words->size () - 1, "type", + "WIDGET_IN_FLOW"); + DBG_OBJ_ARRATTRSET_PTR ("words", words->size () - 1, + "text/widget/breakSpace", word->content.widget); } processWord (words->size () - 1); @@ -2413,6 +2429,11 @@ void Textblock::addParbreak (int space, core::style::Style *style) word->content.type = core::Content::BREAK; word->badnessAndPenalty.setPenalty (PENALTY_FORCE_BREAK); word->content.breakSpace = space; + + DBG_OBJ_ARRATTRSET_STR ("words", words->size () - 1, "type", "BREAK"); + DBG_OBJ_ARRATTRSET_NUM ("words", words->size () - 1, + "text/widget/breakSpace", word->content.breakSpace); + processWord (words->size () - 1); } @@ -2436,6 +2457,11 @@ void Textblock::addLinebreak (core::style::Style *style) word->content.type = core::Content::BREAK; word->badnessAndPenalty.setPenalty (PENALTY_FORCE_BREAK); word->content.breakSpace = 0; + + DBG_OBJ_ARRATTRSET_STR ("words", words->size () - 1, "type", "BREAK"); + DBG_OBJ_ARRATTRSET_NUM ("words", words->size () - 1, + "text/widget/breakSpace", word->content.breakSpace); + processWord (words->size () - 1); } diff --git a/dw/textblock_linebreaking.cc b/dw/textblock_linebreaking.cc index 1fdd5159..e18b637a 100644 --- a/dw/textblock_linebreaking.cc +++ b/dw/textblock_linebreaking.cc @@ -325,9 +325,10 @@ void Textblock::justifyLine (Line *line, int diff) Textblock::Line *Textblock::addLine (int firstWord, int lastWord, bool temporary) { - PRINTF ("[%p] ADD_LINE (%d, %d) => %d\n", - this, firstWord, lastWord, lines->size ()); - + DBG_OBJ_MSGF ("construct.line", 0, "<b>addLine</b> (%d, %d) => %d", + firstWord, lastWord, lines->size ()); + DBG_OBJ_MSG_START (); + //for (int i = firstWord; i <= lastWord; i++) { // printf (" word %d: ", i); // printWord (words->getRef (i)); @@ -448,6 +449,7 @@ Textblock::Line *Textblock::addLine (int firstWord, int lastWord, initNewLine (); + DBG_OBJ_MSG_END (); return line; } @@ -524,8 +526,9 @@ void Textblock::processWord (int wordIndex) */ bool Textblock::wordWrap (int wordIndex, bool wrapAll) { - PRINTF ("[%p] WORD_WRAP (%d, %s)\n", - this, wordIndex, wrapAll ? "true" : "false"); + DBG_OBJ_MSGF ("construct.word", 0, "<b>wordWrap</b> (%d, %s)", + wordIndex, wrapAll ? "true" : "false"); + DBG_OBJ_MSG_START (); if (!wrapAll) removeTemporaryLines (); @@ -541,19 +544,28 @@ bool Textblock::wordWrap (int wordIndex, bool wrapAll) //printWord (word); //printf ("\n"); + bool b; switch (word->content.type) { case core::Content::WIDGET_OOF_REF: - return wrapWordOofRef (wordIndex, wrapAll); + b = wrapWordOofRef (wordIndex, wrapAll); break; default: - return wrapWordInFlow (wordIndex, wrapAll); + b = wrapWordInFlow (wordIndex, wrapAll); break; } + + DBG_OBJ_MSG_END (); + + return b; } bool Textblock::wrapWordInFlow (int wordIndex, bool wrapAll) { + DBG_OBJ_MSGF ("construct.word", 0, "<b>wrapWordInFlow</b> (%d, %s)", + wordIndex, wrapAll ? "true" : "false"); + DBG_OBJ_MSG_START (); + Word *word = words->getRef (wordIndex); bool wordListChanged = false; @@ -732,6 +744,8 @@ bool Textblock::wrapWordInFlow (int wordIndex, bool wrapAll) } } + DBG_OBJ_MSG_END (); + return wordListChanged; } @@ -759,6 +773,10 @@ void Textblock::checkPossibleLineHeightChange (int wordIndex) bool Textblock::wrapWordOofRef (int wordIndex, bool wrapAll) { + DBG_OBJ_MSGF ("construct.word", 0, "<b>wrapWordOofRef</b> (%d, %s)", + wordIndex, wrapAll ? "true" : "false"); + DBG_OBJ_MSG_START (); + assert (containingBlock->outOfFlowMgr); int y = yOffsetOfPossiblyMissingLine (lines->size ()); @@ -774,6 +792,9 @@ bool Textblock::wrapWordOofRef (int wordIndex, bool wrapAll) if (left || right) updateBorders (wordIndex, left, right); + + DBG_OBJ_MSG_END (); + return false; // Actually, the words list is never changed here. } @@ -1037,6 +1058,15 @@ int Textblock::hyphenateWord (int wordIndex) PRINTF ("[%p] %d words ...\n", this, words->size ()); words->insert (wordIndex, numBreaks); + +#ifdef DBG_RTFL + // TODO Must be corrected. + for (int i = wordIndex + numBreaks; i < words->size (); i++) { + DBG_OBJ_ARRATTRSET_STR ("words", i, "type", "???"); + DBG_OBJ_ARRATTRSET_STR ("words", i, "text/widget/breakSpace", "???"); + } +#endif + for (int i = 0; i < numBreaks; i++) initWord (wordIndex + i); PRINTF ("[%p] ... => %d words\n", this, words->size ()); @@ -1068,6 +1098,10 @@ int Textblock::hyphenateWord (int wordIndex) end - start); PRINTF (" [%d] -> '%s'\n", wordIndex + i, w->content.text); + DBG_OBJ_ARRATTRSET_STR ("words", wordIndex + i, "type", "TEXT"); + DBG_OBJ_ARRATTRSET_STR ("words", wordIndex + i, + "text/widget/breakSpace", w->content.text); + // Note: there are numBreaks + 1 word parts. if (i == 0) w->flags |= Word::WORD_START; @@ -1377,6 +1411,7 @@ void Textblock::rewrap () /* All lines up from wrapRef will be rebuild from the word list, * the line list up from this position is rebuild. */ lines->setSize (wrapRefLines); + DBG_OBJ_SET_NUM ("lines.size", lines->size ()); nonTemporaryLines = misc::min (nonTemporaryLines, wrapRefLines); initNewLine (); @@ -1518,6 +1553,7 @@ void Textblock::showMissingLines () void Textblock::removeTemporaryLines () { lines->setSize (nonTemporaryLines); + DBG_OBJ_SET_NUM ("lines.size", lines->size ()); } int Textblock::getSpaceShrinkability(struct Word *word) |