summaryrefslogtreecommitdiff
path: root/dw
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2011-08-27 00:10:58 +0200
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2011-08-27 00:10:58 +0200
commit975c779bb16d0d36f9f7b8bb09d7bdfdff233a10 (patch)
treef16fc56305100fe6b3de625d94a3d6aa331c190e /dw
parentebef0b465431e79955a308242b717b66fc62bbb8 (diff)
collapse parent top margin with first child's top margin
Diffstat (limited to 'dw')
-rw-r--r--dw/textblock.cc14
1 files changed, 13 insertions, 1 deletions
diff --git a/dw/textblock.cc b/dw/textblock.cc
index 1fd188b0..23465d23 100644
--- a/dw/textblock.cc
+++ b/dw/textblock.cc
@@ -990,16 +990,28 @@ void Textblock::wordWrap(int wordIndex)
// lastLine->boxDescent);
if (word->content.type == core::Content::WIDGET) {
+ int collapseMarginTop = 0;
lastLine->marginDescent =
misc::max (lastLine->marginDescent,
word->size.descent +
word->content.widget->getStyle()->margin.bottom);
+ if (lines->size () == 1 &&
+ word->content.widget->blockLevel () &&
+ getStyle ()->borderWidth.top == 0 &&
+ getStyle ()->padding.top == 0) {
+ // collapse top margin of parent element with top margin of first child
+ // see: http://www.w3.org/TR/CSS21/box.html#collapsing-margins
+ collapseMarginTop = getStyle ()->margin.top;
+ }
+
lastLine->boxAscent =
misc::max (lastLine->boxAscent,
+ word->size.ascent,
word->size.ascent
- + word->content.widget->getStyle()->margin.top);
+ + word->content.widget->getStyle()->margin.top
+ - collapseMarginTop);
} else {
lastLine->marginDescent =