setShouldPaintBackgroundOrBorder(true);
}
-bool RenderTableCell::requiresLayer() {
- return isPositioned() || style()->opacity() < 1.0f || hasOverflowClip();
+bool RenderTableCell::requiresLayer()
+{
+ return isPositioned() || isTransparent() || hasOverflowClip();
}
// The following rules apply for resolving conflicts and figuring out which border
return r;
}
-void RenderTableCell::paintBoxDecorations(PaintInfo& i, int _tx, int _ty)
+void RenderTableCell::paintBackgroundsBehindCell(PaintInfo& i, int _tx, int _ty, RenderObject* backgroundObject)
{
+ if (!backgroundObject)
+ return;
+
RenderTable* tableElt = table();
if (!tableElt->collapseBorders() && style()->emptyCells() == HIDE && !firstChild())
return;
-
- int w = width();
- int h = height() + borderTopExtra() + borderBottomExtra();
- _ty -= borderTopExtra();
-
- Color c = style()->backgroundColor();
- if (!c.isValid() && parent()) // take from row
- c = parent()->style()->backgroundColor();
- if (!c.isValid() && parent() && parent()->parent()) // take from rowgroup
- c = parent()->parent()->style()->backgroundColor();
- if (!c.isValid()) {
- // see if we have a col or colgroup for this
- RenderTableCol *col = table()->colElement(_col);
- if (col) {
- c = col->style()->backgroundColor();
- if (!c.isValid()) {
- // try column group
- RenderStyle *style = col->parent()->style();
- if (style->display() == TABLE_COLUMN_GROUP)
- c = style->backgroundColor();
- }
- }
- }
- // FIXME: This code is just plain wrong. Rows and columns should paint their backgrounds
- // independent from the cell.
- // ### get offsets right in case the bgimage is inherited.
- const BackgroundLayer* bgLayer = style()->backgroundLayers();
- if (!bgLayer->hasImage() && parent())
- bgLayer = parent()->style()->backgroundLayers();
- if (!bgLayer->hasImage() && parent() && parent()->parent())
- bgLayer = parent()->parent()->style()->backgroundLayers();
- if (!bgLayer->hasImage()) {
- // see if we have a col or colgroup for this
- RenderTableCol* col = table()->colElement(_col);
- if (col) {
- bgLayer = col->style()->backgroundLayers();
- if (!bgLayer->hasImage()) {
- // try column group
- RenderStyle *style = col->parent()->style();
- if (style->display() == TABLE_COLUMN_GROUP)
- bgLayer = style->backgroundLayers();
- }
- }
+ if (backgroundObject != this) {
+ _tx += m_x;
+ _ty += m_y + _topExtra;
}
+ int w = width();
+ int h = height() + borderTopExtra() + borderBottomExtra();
+ _ty -= borderTopExtra();
+
int my = kMax(_ty, i.r.y());
int end = kMin(i.r.bottom(), _ty + h);
int mh = end - my;
+
+ Color c = backgroundObject->style()->backgroundColor();
+ const BackgroundLayer* bgLayer = backgroundObject->style()->backgroundLayers();
if (bgLayer->hasImage() || c.isValid()) {
- // We have to clip here because the backround would paint
- // on top of the borders otherwise.
- if (m_layer && tableElt->collapseBorders()) {
+ // We have to clip here because the background would paint
+ // on top of the borders otherwise. This only matters for cells and rows.
+ bool hasLayer = backgroundObject->layer() && (backgroundObject == this || backgroundObject == parent());
+ if (hasLayer && tableElt->collapseBorders()) {
IntRect clipRect(_tx + borderLeft(), _ty + borderTop(),
w - borderLeft() - borderRight(), h - borderTop() - borderBottom());
i.p->save();
i.p->addClip(clipRect);
}
paintBackground(i.p, c, bgLayer, my, mh, _tx, _ty, w, h);
- if (m_layer && tableElt->collapseBorders())
+ if (hasLayer && tableElt->collapseBorders())
i.p->restore();
}
+}
+
+void RenderTableCell::paintBoxDecorations(PaintInfo& i, int _tx, int _ty)
+{
+ RenderTable* tableElt = table();
+ if (!tableElt->collapseBorders() && style()->emptyCells() == HIDE && !firstChild())
+ return;
+
+ // Paint our cell background.
+ paintBackgroundsBehindCell(i, _tx, _ty, this);
+
+ int w = width();
+ int h = height() + borderTopExtra() + borderBottomExtra();
+ _ty -= borderTopExtra();
if (style()->hasBorder() && !tableElt->collapseBorders())
paintBorder(i.p, _tx, _ty, w, h, style());