Commit eb6ee89e authored by hyatt's avatar hyatt

Fixed for tables. Make the percentage height calculation

	more robust.  Also add a hack for replaced elements to
	subtract out their margins when computing percentage widths.
	This keeps them from spilling out of table cells.

        * khtml/rendering/render_box.cpp:
        (RenderBox::calcReplacedWidth):
        (RenderBox::calcReplacedHeight):
        * khtml/rendering/render_table.cpp:
        (RenderTable::layoutRows):
        * khtml/xml/dom_nodeimpl.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2812 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent cbea993b
2002-11-21 David Hyatt <hyatt@apple.com>
Fixed for tables. Make the percentage height calculation
more robust. Also add a hack for replaced elements to
subtract out their margins when computing percentage widths.
This keeps them from spilling out of table cells.
* khtml/rendering/render_box.cpp:
(RenderBox::calcReplacedWidth):
(RenderBox::calcReplacedHeight):
* khtml/rendering/render_table.cpp:
(RenderTable::layoutRows):
* khtml/xml/dom_nodeimpl.h:
=== Alexander-33 ===
2002-11-21 Richard Williamson <rjw@apple.com>
......
2002-11-21 David Hyatt <hyatt@apple.com>
Fixed for tables. Make the percentage height calculation
more robust. Also add a hack for replaced elements to
subtract out their margins when computing percentage widths.
This keeps them from spilling out of table cells.
* khtml/rendering/render_box.cpp:
(RenderBox::calcReplacedWidth):
(RenderBox::calcReplacedHeight):
* khtml/rendering/render_table.cpp:
(RenderTable::layoutRows):
* khtml/xml/dom_nodeimpl.h:
=== Alexander-33 ===
2002-11-21 Richard Williamson <rjw@apple.com>
......
2002-11-21 David Hyatt <hyatt@apple.com>
Fixed for tables. Make the percentage height calculation
more robust. Also add a hack for replaced elements to
subtract out their margins when computing percentage widths.
This keeps them from spilling out of table cells.
* khtml/rendering/render_box.cpp:
(RenderBox::calcReplacedWidth):
(RenderBox::calcReplacedHeight):
* khtml/rendering/render_table.cpp:
(RenderTable::layoutRows):
* khtml/xml/dom_nodeimpl.h:
=== Alexander-33 ===
2002-11-21 Richard Williamson <rjw@apple.com>
......
......@@ -644,8 +644,15 @@ short RenderBox::calcReplacedWidth(bool* ieHack) const
{
//RenderObject* p = parent();
int cw = containingBlockWidth();
if ( cw )
if ( cw ) {
width = w.minWidth( cw );
#if APPLE_CHANGES
// Aqua form controls have margins. In order to make this work out well,
// subtract our margins out.
if (isFormElement())
width -= (marginLeft() + marginRight());
#endif
}
else
width = intrinsicWidth();
break;
......@@ -688,7 +695,13 @@ int RenderBox::calcReplacedHeight() const
if (cb->isTableCell()) {
RenderTableCell* tableCell = static_cast<RenderTableCell*>(cb);
if (tableCell->style()->height().isPercent() && tableCell->getCellPercentageHeight()) {
height = h.minWidth(tableCell->getCellPercentageHeight());
height = h.minWidth(tableCell->getCellPercentageHeight());
#if APPLE_CHANGES
// Aqua form controls have margins. In order to make this work out well,
// subtract our margins out.
if (isFormElement())
height -= (marginTop() + marginBottom());
#endif
break;
}
}
......
......@@ -1424,7 +1424,6 @@ void RenderTable::layoutRows(int yoff)
calcRowHeight(r);
}
// html tables with percent height are relative to view
Length h = style()->height();
int th=0;
......@@ -1432,26 +1431,26 @@ void RenderTable::layoutRows(int yoff)
th = h.value;
else if (h.isPercent())
{
Length ch = containingBlock()->style()->height();
if (ch.isFixed())
th = h.width(ch.value);
else
{
// check we or not inside a table
RenderObject* ro = parent();
for (; ro && !ro->isTableCell(); ro=ro->parent());
if (!ro)
{
// we need to substract the bodys margins
// The cb is the <body>. Subtract out its margins. -dwh
th = h.width(viewRect().height()
- containingBlock()->marginBottom()
- containingBlock()->marginTop());
// not really, but this way the view height change
// gets propagated correctly
setOverhangingContents();
RenderObject* c = containingBlock();
for ( ;
!c->isBody() && !c->isTableCell() && !c->isPositioned() && !c->isFloating();
c = c->containingBlock()) {
Length ch = c->style()->height();
if (ch.isFixed()) {
th = h.width(ch.value);
break;
}
}
if (!c->isTableCell()) {
// we need to substract out the margins of this block. -dwh
th = h.width(viewRect().height()
- c->marginBottom()
- c->marginTop());
// not really, but this way the view height change
// gets propagated correctly
setOverhangingContents();
}
}
bool tableGrew = false;
......@@ -1462,11 +1461,11 @@ void RenderTable::layoutRows(int yoff)
if (dh>0)
{
// There is room to grow. Distribute the space among the rows
// by weighting according to their calculated heights,
// unless there are rows that have percentage
// by weighting according to their calculated heights,
// unless there are rows that have percentage
// heights. In that case, only the rows with percentage heights
// get the space, and the weight is distributed after computing
// a normalized flex. -dwh
// a normalized flex. -dwh
tableGrew = true;
int totalPercentage = 0;
for ( unsigned int r = 0; r < totalRows; r++ )
......@@ -1533,11 +1532,11 @@ void RenderTable::layoutRows(int yoff)
cell->layout();
}
}
if (cellChildrenFlex) {
// Alignment within a cell is based off the calculated
// height, which becomes irrelevant once the cell has
// been resized based off its percentage. -dwh
// Alignment within a cell is based off the calculated
// height, which becomes irrelevant once the cell has
// been resized based off its percentage. -dwh
cell->setCellTopExtra(0);
cell->setCellBottomExtra(0);
}
......
......@@ -105,7 +105,11 @@ public:
virtual bool isDocumentNode() const { return false; }
virtual bool isXMLElementNode() const { return false; }
// Used by <form> elements to indicate a malformed state of some kind, typically
// used to keep from applying the bottom margin of the form.
virtual bool isMalformed() { return false; }
virtual void setMalformed(bool malformed) {};
virtual bool containsOnlyWhitespace() const { return false; }
// helper functions not being part of the DOM
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment