diff options
author | Sebastian Geerken <devnull@localhost> | 2014-11-15 01:39:27 +0100 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2014-11-15 01:39:27 +0100 |
commit | ca01dd7f3ba8fdd11e9f385d557877edd2aa956e (patch) | |
tree | b7c907999932840c038bb7db823f71429b8d63ec | |
parent | d6210add0244512b1dee53fd15b734a1ee980791 (diff) |
Fixed a CPU hogging bug.
-rw-r--r-- | dw/outofflowmgr.cc | 7 | ||||
-rw-r--r-- | dw/textblock.cc | 49 | ||||
-rw-r--r-- | dw/textblock_linebreaking.cc | 9 |
3 files changed, 48 insertions, 17 deletions
diff --git a/dw/outofflowmgr.cc b/dw/outofflowmgr.cc index 90f7172c..11b88ae0 100644 --- a/dw/outofflowmgr.cc +++ b/dw/outofflowmgr.cc @@ -1230,7 +1230,7 @@ int OutOfFlowMgr::calcFloatX (Float *vloat, Side side, int gbX, int gbWidth, // Left floats are always aligned on the left side of the // generator (content, not allocation) ... x = gbX + vloat->generatingBlock->getStyle()->boxOffsetX(); - DBG_OBJ_MSGF ("resize.oofm", 1, "left: x = %d + %d = %d", + DBG_OBJ_MSGF ("resize.common", 1, "left: x = %d + %d = %d", gbX, vloat->generatingBlock->getStyle()->boxOffsetX(), x); // ... but when the float exceeds the line break width of the // container, it is corrected (but not left of the container). @@ -1795,6 +1795,11 @@ void OutOfFlowMgr::getFloatsSize (Requisition *cbReq, Side side, int *width, for (int i = 0; i < list->size(); i++) { Float *vloat = list->get(i); + DBG_OBJ_MSGF ("resize.oofm", 1, + "float %p has generator %p (container is %p)", + vloat->getWidget (), vloat->generatingBlock, + containingBlock); + if (vloat->generatingBlock == containingBlock || wasAllocated (vloat->generatingBlock)) { ensureFloatSize (vloat); diff --git a/dw/textblock.cc b/dw/textblock.cc index 47ed7bdb..dd0aa100 100644 --- a/dw/textblock.cc +++ b/dw/textblock.cc @@ -626,6 +626,9 @@ void Textblock::sizeAllocateImpl (core::Allocation *allocation) DBG_OBJ_MSG_START (); for (lineIndex = 0; lineIndex < lines->size (); lineIndex++) { + DBG_OBJ_MSGF ("resize", 1, "line %d", lineIndex); + DBG_OBJ_MSG_START (); + // Especially for floats, allocation->width may be different // from the line break width, so that for centered and right // text, the offsets have to be recalculated again. However, if @@ -638,6 +641,8 @@ void Textblock::sizeAllocateImpl (core::Allocation *allocation) line = lines->getRef (lineIndex); xCursor = line->textOffset; + DBG_OBJ_MSGF ("resize", 1, "xCursor = %d (initially)", xCursor); + for (wordIndex = line->firstWord; wordIndex <= line->lastWord; wordIndex++) { word = words->getRef (wordIndex); @@ -732,7 +737,12 @@ void Textblock::sizeAllocateImpl (core::Allocation *allocation) } xCursor += (word->size.width + word->effSpace); + DBG_OBJ_MSGF ("resize", 1, "xCursor = %d (after word %d)", + xCursor, wordIndex); + DBG_MSG_WORD("resize", 1, "<i>that is:</i> ", wordIndex, ""); } + + DBG_OBJ_MSG_END (); } DBG_OBJ_MSG_END (); @@ -3117,31 +3127,40 @@ Textblock *Textblock::getTextblockForLine (int lineNo) Textblock *Textblock::getTextblockForLine (int firstWord, int lastWord) { + DBG_OBJ_ENTER ("resize", 0, "getTextblockForLine", "%d, %d", + firstWord, lastWord); + DBG_OBJ_MSGF ("resize", 1, "words.size = %d", words->size ()); + + Textblock *textblock = NULL; + if (firstWord < words->size ()) { - //printf ("[%p] GET_TEXTBLOCK_FOR_LINE (%d, %d)\n", - // this, firstWord, lastWord); + DBG_MSG_WORD ("resize", 1, "<i>first word:</i> ", firstWord, ""); // A textblock is always between two line breaks, and so the // first word of the line. Word *word = words->getRef (firstWord); - if (word->content.type == core::Content::WIDGET_IN_FLOW && - word->content.widget->instanceOf (Textblock::CLASS_ID) && - // Exclude inline blocks (see definition of float container). - (word->content.widget->getStyle()->display - == core::style::DISPLAY_BLOCK || - word->content.widget->getStyle()->display - == core::style::DISPLAY_LIST_ITEM)) { - //printf (" word %d: ", firstWord); - //printWordShort (word); - //printf ("\n"); + DBG_MSG_WORD ("resize", 1, "<i>first word:</i> ", firstWord, ""); - return (Textblock*)word->content.widget; + if (word->content.type == core::Content::WIDGET_IN_FLOW) { + Widget *widget = word->content.widget; + if (widget->instanceOf (Textblock::CLASS_ID) && + // Exclude some cases where a textblock constitutes a new + // container (see definition of float container in + // Textblock::isContainingBlock). + widget->getStyle()->display != core::style::DISPLAY_BLOCK && + widget->getStyle()->overflow == core::style::OVERFLOW_VISIBLE) + textblock = (Textblock*)widget; + + // (TODO: It would look nicer if there is one common place + // for such definitions. Will be fixed in "dillo_grows", not + // here.) } } - //printf (" nothing\n"); - return NULL; + DBG_OBJ_MSGF ("resize", 1, "=> %p", textblock); + DBG_OBJ_LEAVE (); + return textblock; } /** diff --git a/dw/textblock_linebreaking.cc b/dw/textblock_linebreaking.cc index 66391952..9a2a1a7c 100644 --- a/dw/textblock_linebreaking.cc +++ b/dw/textblock_linebreaking.cc @@ -389,7 +389,8 @@ Textblock::Line *Textblock::addLine (int firstWord, int lastWord, nonTemporaryLines = lines->size (); } - PRINTF ("nonTemporaryLines = %d\n", nonTemporaryLines); + DBG_OBJ_MSGF ("construct.line", 1, "nonTemporaryLines = %d", + nonTemporaryLines); int lineIndex = lines->size () - 1; Line *line = lines->getRef (lineIndex); @@ -413,6 +414,12 @@ Textblock::Line *Textblock::addLine (int firstWord, int lastWord, line->rightOffset = misc::max (regardBorder ? newLineRightBorder : 0, boxRestWidth ()); + DBG_OBJ_MSGF ("construct.line", 1, + "regardBorder = %s, newLineLeftBorder = %d, " + "newLineRightBorder = %d", + regardBorder ? "true" : "false", newLineLeftBorder, + newLineRightBorder); + DBG_OBJ_ARRATTRSET_NUM ("lines", lineIndex, "leftOffset", line->leftOffset); DBG_OBJ_ARRATTRSET_NUM ("lines", lineIndex, "rightOffset", line->rightOffset); |