margin-bottom counted twice
Johannes Hofmann <[email protected]>
| Newsgroups | gmane.comp.web.dillo.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, I found that current dillo uses twice the given margin-bottom: value. See attached margin_bottom.html. It is related to commented out code in textblock.cc. Attached patch tries to fix it while not breaking the test cases in http://www.dillo.org/test/img/ I'm not 100% sure about removing the "if" in Textblock::wordWrap(), but why shouldn't a widget's top margin count in the first line of a paragraph? Cheers, Johannes _______________________________________________ Dillo-dev mailing list [email protected] http://lists.auriga.wearlab.de/cgi-bin/mailman/listinfo/dillo-dev
margin_bottom.html
(text/html, 124 B)
<div style="border: 1px solid black; margin-bottom: 100px">foo bar</div> <div style="border: 1px solid black">foo bar</div>
margin-bottom-fix.diff
(text/plain, 2.9 KB)
diff -r 64a13e326578 dw/textblock.cc
--- a/dw/textblock.cc Fri Aug 26 00:06:38 2011 +0000
+++ b/dw/textblock.cc Fri Aug 26 10:19:30 2011 +0200
@@ -376,13 +376,13 @@
* http://www.dillo.org/test/img/ */
childAllocation.y =
lineYOffsetCanvasAllocation (line, allocation)
- + (line->boxAscent - word->size.ascent);
- // - word->content.widget->getStyle()->margin.top;
+ + (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;
- childAllocation.descent = word->size.descent;
- // + word->content.widget->getStyle()->margin.bottom;
+ childAllocation.ascent = word->size.ascent
+ + word->content.widget->getStyle()->margin.top;
+ childAllocation.descent = word->size.descent
+ + word->content.widget->getStyle()->margin.bottom;
oldChildAllocation = word->content.widget->getAllocation();
@@ -995,24 +995,11 @@
word->size.descent +
word->content.widget->getStyle()->margin.bottom);
- //DBG_OBJ_ARRSET_NUM (page, "lines.%d.descent", page->num_lines - 1,
- // lastLine->descent);
-
- /* If the widget is not in the first line of the paragraph, its top
- * margin may make the line higher.
- */
- if (lines->size () > 1) {
- /* Here, we know already what the break and the bottom margin
- * contributed to the space before this line.
- */
- lastLine->boxAscent =
+ lastLine->boxAscent =
misc::max (lastLine->boxAscent,
word->size.ascent
+ word->content.widget->getStyle()->margin.top);
- //DBG_OBJ_ARRSET_NUM (page, "lines.%d.ascent", page->num_lines - 1,
- // lastLine->boxAscent);
- }
} else {
lastLine->marginDescent =
misc::max (lastLine->marginDescent, lastLine->boxDescent);
@@ -1123,11 +1110,7 @@
widget->setAscent (availAscent);
widget->setDescent (availDescent);
widget->sizeRequest (size);
-// size->ascent -= wstyle->margin.top;
-// size->descent -= wstyle->margin.bottom;
} else {
- /* TODO: Use margin.{top|bottom} here, like above.
- * (No harm for the next future.) */
if (wstyle->width == core::style::LENGTH_AUTO ||
wstyle->height == core::style::LENGTH_AUTO)
widget->sizeRequest (&requisition);
@@ -1158,6 +1141,10 @@
size->descent = (int) (len * availDescent);
}
}
+
+ /* ascent and descent in words do not contain margins. */
+ size->ascent -= wstyle->margin.top;
+ size->descent -= wstyle->margin.bottom;
}
/**