Summary: | [test case] Incorrect margin for tables | ||
---|---|---|---|
Product: | [Applications] konqueror | Reporter: | fleona |
Component: | khtml renderer | Assignee: | Konqueror Developers <konq-bugs> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: | |||
Attachments: |
test case
Corrected test case |
Description
fleona
2005-03-26 15:41:47 UTC
The alignment looks correct to me and the same as firefox. The right margin is too big though. Created attachment 10589 [details]
test case
A simple test case. It appears it doesn't happen if you replace the table with
a div.
Created attachment 10590 [details]
Corrected test case
Sorry, the first test case was buggy
SVN commit 595493 by carewolf: Don't subtract margin from available-width + fix various width bugs that revealed themselves up after fixing that. BUG: 102536 M +15 -9 render_table.cpp M +4 -0 render_table.h M +6 -2 table_layout.cpp --- branches/KDE/3.5/kdelibs/khtml/rendering/render_table.cpp #595492:595493 @@ -233,27 +233,33 @@ RenderBlock *cb = containingBlock(); int availableWidth = cb->contentWidth(); - // Subtract minimum margins - availableWidth -= style()->marginLeft().minWidth(cb->contentWidth()); - availableWidth -= style()->marginRight().minWidth(cb->contentWidth()); - LengthType widthType = style()->width().type(); if(widthType > Relative && style()->width().value() > 0) { // Percent or fixed table - m_width = style()->width().minWidth( availableWidth ); + m_width = calcBoxWidth(style()->width().minWidth( availableWidth )); if(m_minWidth > m_width) m_width = m_minWidth; } else { - m_width = KMIN(short( availableWidth ), short(m_maxWidth)); + // Subtract out any fixed margins from our available width for auto width tables. + int marginTotal = 0; + if (!style()->marginLeft().isVariable()) + marginTotal += style()->marginLeft().width(availableWidth); + if (!style()->marginRight().isVariable()) + marginTotal += style()->marginRight().width(availableWidth); + + // Subtract out our margins to get the available content width. + int availContentWidth = kMax(0, availableWidth - marginTotal); + + // Ensure we aren't bigger than our max width or smaller than our min width. + m_width = kMin(availContentWidth, m_maxWidth); } // restrict width to what we really have // EXCEPT percent tables, which are still calculated as above - availableWidth = cb->lineWidth( m_y ); if ( widthType != Percent ) - m_width = KMIN( short( availableWidth ), m_width ); + m_width = kMin( short( availableWidth ), m_width ); - m_width = KMAX (m_width, m_minWidth); + m_width = kMax (m_width, m_minWidth); // Finally, with our true width determined, compute our margins for real. m_marginRight=0; --- branches/KDE/3.5/kdelibs/khtml/rendering/render_table.h #595492:595493 @@ -73,6 +73,10 @@ int borderRight() const; int borderTop() const; int borderBottom() const; + int paddingLeft() const { return collapseBorders() ? 0 : RenderBlock::paddingLeft(); } + int paddingRight() const { return collapseBorders() ? 0 : RenderBlock::paddingRight(); } + int paddingTop() const { return collapseBorders() ? 0 : RenderBlock::paddingTop(); } + int paddingBottom() const { return collapseBorders() ? 0 : RenderBlock::paddingBottom(); } const QColor &bgColor() const { return style()->backgroundColor(); } --- branches/KDE/3.5/kdelibs/khtml/rendering/table_layout.cpp #595492:595493 @@ -233,7 +233,10 @@ // unlimited. int bs = table->bordersPaddingAndSpacing(); - int tableWidth = table->style()->width().isFixed() ? table->style()->width().value() - bs : 0; + int tableWidth = 0; + if (table->style()->width().isFixed()) { + tableWidth = table->calcBoxWidth(table->style()->width().value()); + } int mw = calcWidthArray() + bs; table->m_minWidth = kMin( kMax( mw, tableWidth ), 0x7fff ); @@ -599,7 +602,8 @@ Length tw = table->style()->width(); if ( tw.isFixed() && tw.value() > 0 ) { - minWidth = kMax( minWidth, int( tw.value() ) ); + int width = table->calcBoxWidth(tw.value()); + minWidth = kMax( minWidth, width ); maxWidth = minWidth; } |