This source file includes following definitions.
- m_rowIndex
- willBeRemovedFromTree
- borderWidthChanged
- styleDidChange
- borderAdjoiningStartCell
- borderAdjoiningEndCell
- addChild
- layout
- nodeAtPoint
- paintOutlineForRowIfNeeded
- paint
- imageChanged
- createAnonymous
- createAnonymousWithParentRenderer
#include "config.h"
#include "core/rendering/RenderTableRow.h"
#include "HTMLNames.h"
#include "core/dom/Document.h"
#include "core/fetch/ImageResource.h"
#include "core/rendering/GraphicsContextAnnotator.h"
#include "core/rendering/HitTestResult.h"
#include "core/rendering/LayoutRectRecorder.h"
#include "core/rendering/PaintInfo.h"
#include "core/rendering/RenderTableCell.h"
#include "core/rendering/RenderView.h"
#include "core/rendering/SubtreeLayoutScope.h"
#include "core/rendering/style/StyleInheritedData.h"
namespace WebCore {
using namespace HTMLNames;
RenderTableRow::RenderTableRow(Element* element)
: RenderBox(element)
, m_rowIndex(unsetRowIndex)
{
setInline(false);
}
void RenderTableRow::willBeRemovedFromTree()
{
RenderBox::willBeRemovedFromTree();
section()->setNeedsCellRecalc();
}
static bool borderWidthChanged(const RenderStyle* oldStyle, const RenderStyle* newStyle)
{
return oldStyle->borderLeftWidth() != newStyle->borderLeftWidth()
|| oldStyle->borderTopWidth() != newStyle->borderTopWidth()
|| oldStyle->borderRightWidth() != newStyle->borderRightWidth()
|| oldStyle->borderBottomWidth() != newStyle->borderBottomWidth();
}
void RenderTableRow::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
{
ASSERT(style()->display() == TABLE_ROW);
RenderBox::styleDidChange(diff, oldStyle);
propagateStyleToAnonymousChildren();
if (section() && oldStyle && style()->logicalHeight() != oldStyle->logicalHeight())
section()->rowLogicalHeightChanged(rowIndex());
if (parent()) {
RenderTable* table = this->table();
if (table && !table->selfNeedsLayout() && !table->normalChildNeedsLayout() && oldStyle && oldStyle->border() != style()->border())
table->invalidateCollapsedBorders();
if (table && oldStyle && diff == StyleDifferenceLayout && needsLayout() && table->collapseBorders() && borderWidthChanged(oldStyle, style())) {
for (RenderBox* childBox = firstChildBox(); childBox; childBox = childBox->nextSiblingBox()) {
if (!childBox->isTableCell())
continue;
childBox->setChildNeedsLayout();
}
}
}
}
const BorderValue& RenderTableRow::borderAdjoiningStartCell(const RenderTableCell* cell) const
{
ASSERT_UNUSED(cell, cell->isFirstOrLastCellInRow());
return style()->borderStart();
}
const BorderValue& RenderTableRow::borderAdjoiningEndCell(const RenderTableCell* cell) const
{
ASSERT_UNUSED(cell, cell->isFirstOrLastCellInRow());
return style()->borderEnd();
}
void RenderTableRow::addChild(RenderObject* child, RenderObject* beforeChild)
{
if (!child->isTableCell()) {
RenderObject* last = beforeChild;
if (!last)
last = lastChild();
if (last && last->isAnonymous() && last->isTableCell() && !last->isBeforeOrAfterContent()) {
if (beforeChild == last)
beforeChild = last->firstChild();
last->addChild(child, beforeChild);
return;
}
if (beforeChild && !beforeChild->isAnonymous() && beforeChild->parent() == this) {
RenderObject* cell = beforeChild->previousSibling();
if (cell && cell->isTableCell() && cell->isAnonymous()) {
cell->addChild(child);
return;
}
}
if (last && !last->isTableCell() && last->parent() && last->parent()->isAnonymous() && !last->parent()->isBeforeOrAfterContent()) {
last->parent()->addChild(child, beforeChild);
return;
}
RenderTableCell* cell = RenderTableCell::createAnonymousWithParentRenderer(this);
addChild(cell, beforeChild);
cell->addChild(child);
return;
}
if (beforeChild && beforeChild->parent() != this)
beforeChild = splitAnonymousBoxesAroundChild(beforeChild);
RenderTableCell* cell = toRenderTableCell(child);
if (parent())
section()->addCell(cell, this);
ASSERT(!beforeChild || beforeChild->isTableCell());
RenderBox::addChild(cell, beforeChild);
if (beforeChild || nextSibling())
section()->setNeedsCellRecalc();
}
void RenderTableRow::layout()
{
ASSERT(needsLayout());
LayoutRectRecorder recorder(*this);
LayoutStateMaintainer statePusher(*this, LayoutSize());
for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
if (child->isTableCell()) {
SubtreeLayoutScope layouter(child);
RenderTableCell* cell = toRenderTableCell(child);
if (!cell->needsLayout())
cell->markForPaginationRelayoutIfNeeded(layouter);
if (cell->needsLayout()) {
cell->computeAndSetBlockDirectionMargins(table());
cell->layout();
}
}
}
m_overflow.clear();
addVisualEffectOverflow();
if (selfNeedsLayout() && checkForRepaint()) {
for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
if (child->isTableCell()) {
if (RuntimeEnabledFeatures::repaintAfterLayoutEnabled()) {
child->setShouldDoFullRepaintAfterLayout(true);
} else {
child->repaint();
}
}
}
}
clearNeedsLayout();
}
bool RenderTableRow::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction action)
{
for (RenderObject* child = lastChild(); child; child = child->previousSibling()) {
if (child->isTableCell() && !toRenderBox(child)->hasSelfPaintingLayer()) {
LayoutPoint cellPoint = flipForWritingModeForChild(toRenderTableCell(child), accumulatedOffset);
if (child->nodeAtPoint(request, result, locationInContainer, cellPoint, action)) {
updateHitTestResult(result, locationInContainer.point() - toLayoutSize(cellPoint));
return true;
}
}
}
return false;
}
void RenderTableRow::paintOutlineForRowIfNeeded(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
LayoutPoint adjustedPaintOffset = paintOffset + location();
PaintPhase paintPhase = paintInfo.phase;
if ((paintPhase == PaintPhaseOutline || paintPhase == PaintPhaseSelfOutline) && style()->visibility() == VISIBLE)
paintOutline(paintInfo, LayoutRect(adjustedPaintOffset, size()));
}
void RenderTableRow::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
ASSERT(hasSelfPaintingLayer());
ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this);
paintOutlineForRowIfNeeded(paintInfo, paintOffset);
for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
if (child->isTableCell()) {
if (paintInfo.phase == PaintPhaseBlockBackground || paintInfo.phase == PaintPhaseChildBlockBackground) {
RenderTableCell* cell = toRenderTableCell(child);
cell->paintBackgroundsBehindCell(paintInfo, paintOffset, this);
}
if (!toRenderBox(child)->hasSelfPaintingLayer())
child->paint(paintInfo, paintOffset);
}
}
}
void RenderTableRow::imageChanged(WrappedImagePtr, const IntRect*)
{
repaint();
}
RenderTableRow* RenderTableRow::createAnonymous(Document* document)
{
RenderTableRow* renderer = new RenderTableRow(0);
renderer->setDocumentForAnonymous(document);
return renderer;
}
RenderTableRow* RenderTableRow::createAnonymousWithParentRenderer(const RenderObject* parent)
{
RenderTableRow* newRow = RenderTableRow::createAnonymous(&parent->document());
RefPtr<RenderStyle> newStyle = RenderStyle::createAnonymousStyleWithDisplay(parent->style(), TABLE_ROW);
newRow->setStyle(newStyle.release());
return newRow;
}
}