aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Geerken <devnull@localhost>2014-08-29 18:10:42 +0200
committerSebastian Geerken <devnull@localhost>2014-08-29 18:10:42 +0200
commit16607bb593346401334d0988b2b25a3df3b5ce0d (patch)
tree375d681115c78860b86be9888b433fcaf12c90bc
parente144d5f0fec68f7f9cba7e5944872b910c759a48 (diff)
Applied 'childBaseAllocation' also to other textblock contents.
-rw-r--r--dw/textblock.cc39
-rw-r--r--dw/textblock.hh22
2 files changed, 29 insertions, 32 deletions
diff --git a/dw/textblock.cc b/dw/textblock.cc
index 9a82456c..dd9260d6 100644
--- a/dw/textblock.cc
+++ b/dw/textblock.cc
@@ -560,7 +560,6 @@ void Textblock::sizeAllocateImpl (core::Allocation *allocation)
// avoid this case; in the example above, the height will be 50px =
// 100px (ascent) - 50px (descent: negative).
- core::Allocation childBaseAllocation;
childBaseAllocation.x = allocation->x;
childBaseAllocation.y = allocation->y;
childBaseAllocation.width = allocation->width;
@@ -573,6 +572,12 @@ void Textblock::sizeAllocateImpl (core::Allocation *allocation)
childBaseAllocation.descent =
allocation->ascent + allocation->descent - childBaseAllocation.ascent;
+ DBG_OBJ_SET_NUM ("childBaseAllocation.x", childBaseAllocation.x);
+ DBG_OBJ_SET_NUM ("childBaseAllocation.y", childBaseAllocation.y);
+ DBG_OBJ_SET_NUM ("childBaseAllocation.width", childBaseAllocation.width);
+ DBG_OBJ_SET_NUM ("childBaseAllocation.ascent", childBaseAllocation.ascent);
+ DBG_OBJ_SET_NUM ("childBaseAllocation.descent", childBaseAllocation.descent);
+
if (containingBlock->outOfFlowMgr)
containingBlock->outOfFlowMgr->sizeAllocateStart (this, allocation);
@@ -627,31 +632,13 @@ void Textblock::sizeAllocateImpl (core::Allocation *allocation)
/* align=bottom (base line) */
/* Commented lines break the n2 and n3 test cases at
* http://www.dillo.org/test/img/ */
- childAllocation.y =
- lineYOffsetCanvasAllocation (line, &childBaseAllocation)
+ childAllocation.y = lineYOffsetCanvas (line)
+ (line->boxAscent - word->size.ascent)
- word->content.widget->getStyle()->margin.top;
- DBG_OBJ_MSG_START ();
- DBG_OBJ_MSGF ("resize", 1,
- "lineYOffsetWidgetAllocation (...) = %d + (%d - %d) "
- "= %d",
- line->top, childBaseAllocation.ascent,
- lines->getRef(0)->boxAscent,
- lineYOffsetWidgetAllocation (line,
- &childBaseAllocation));
- DBG_OBJ_MSGF ("resize", 1,
- "lineYOffsetCanvasAllocation (...) = %d + %d = %d",
- childBaseAllocation.y,
- lineYOffsetWidgetAllocation (line,
- &childBaseAllocation),
- lineYOffsetCanvasAllocation (line,
- &childBaseAllocation));
- DBG_OBJ_MSG_END ();
DBG_OBJ_MSGF ("resize", 1,
"childAllocation.y = %d + (%d - %d) - %d = %d",
- lineYOffsetCanvasAllocation (line,
- &childBaseAllocation),
+ lineYOffsetCanvas (line),
line->boxAscent, word->size.ascent,
word->content.widget->getStyle()->margin.top,
childAllocation.y);
@@ -734,7 +721,7 @@ void Textblock::sizeAllocateImpl (core::Allocation *allocation)
y = allocation->y + allocation->ascent + allocation->descent;
} else {
Line *line = lines->getRef(findLineOfWord (anchor->wordIndex));
- y = lineYOffsetCanvasAllocation (line, allocation);
+ y = lineYOffsetCanvas (line);
}
changeAnchor (anchor->name, y);
}
@@ -1599,11 +1586,13 @@ int Textblock::findLineIndexWhenNotAllocated (int y)
int Textblock::findLineIndexWhenAllocated (int y)
{
assert (wasAllocated ());
- return findLineIndex (y, allocation.ascent);
+ return findLineIndex (y, childBaseAllocation.ascent);
}
int Textblock::findLineIndex (int y, int ascent)
{
+ DBG_OBJ_ENTER ("events", 0, "findLineIndex", "%d, %d", y, ascent);
+
core::Allocation alloc;
alloc.ascent = ascent; // More is not needed.
@@ -1632,6 +1621,10 @@ int Textblock::findLineIndex (int y, int ascent)
* Dw_page_find_link() --EG
* That function has now been inlined into Dw_page_motion_notify() --JV
*/
+
+ DBG_OBJ_MSGF ("events", 1, "=> %d", low);
+ DBG_OBJ_LEAVE ();
+
return low;
}
diff --git a/dw/textblock.hh b/dw/textblock.hh
index 69fcd3da..980a34c1 100644
--- a/dw/textblock.hh
+++ b/dw/textblock.hh
@@ -475,6 +475,9 @@ protected:
friend class TextblockIterator;
+ // See sizeAllocateImpl for details. It is also used elsewhere.
+ core::Allocation childBaseAllocation;
+
/* These fields provide some ad-hoc-functionality, used by sub-classes. */
bool hasListitemValue; /* If true, the first word of the page is treated
specially (search in source). */
@@ -637,24 +640,25 @@ protected:
return getTextblockForLine (lineNo) == NULL;
}
- inline int lineYOffsetWidgetAllocation (Line *line,
- core::Allocation *allocation)
+ inline int _lineYOffsetWidgetAllocation (Line *line,
+ core::Allocation *allocation)
{
return line->top + (allocation->ascent - lines->getRef(0)->boxAscent);
}
inline int lineYOffsetWidget (Line *line)
{
- return lineYOffsetWidgetAllocation (line, &allocation);
+ return _lineYOffsetWidgetAllocation (line, &childBaseAllocation);
}
/**
- * Like lineYOffsetCanvas, but with the allocation as parameter.
+ * Like lineYOffsetCanvas, but with the allocation as parameter. Rarely used
+ * outside of lineYOffsetCanvas.
*/
- inline int lineYOffsetCanvasAllocation (Line *line,
+ inline int _lineYOffsetCanvasAllocation (Line *line,
core::Allocation *allocation)
{
- return allocation->y + lineYOffsetWidgetAllocation (line, allocation);
+ return allocation->y + _lineYOffsetWidgetAllocation (line, allocation);
}
/**
@@ -662,7 +666,7 @@ protected:
*/
inline int lineYOffsetCanvas (Line *line)
{
- return lineYOffsetCanvasAllocation(line, &allocation);
+ return _lineYOffsetCanvasAllocation(line, &childBaseAllocation);
}
inline int lineYOffsetWidgetI (int lineIndex)
@@ -673,8 +677,8 @@ protected:
inline int lineYOffsetWidgetIAllocation (int lineIndex,
core::Allocation *allocation)
{
- return lineYOffsetWidgetAllocation (lines->getRef (lineIndex),
- allocation);
+ return _lineYOffsetWidgetAllocation (lines->getRef (lineIndex),
+ allocation);
}
inline int lineYOffsetCanvasI (int lineIndex)