summaryrefslogtreecommitdiff
path: root/Source/WebCore/rendering/RenderTable.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/rendering/RenderTable.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/rendering/RenderTable.h')
-rw-r--r--Source/WebCore/rendering/RenderTable.h189
1 files changed, 111 insertions, 78 deletions
diff --git a/Source/WebCore/rendering/RenderTable.h b/Source/WebCore/rendering/RenderTable.h
index 166c7cb8b..d7b493db0 100644
--- a/Source/WebCore/rendering/RenderTable.h
+++ b/Source/WebCore/rendering/RenderTable.h
@@ -4,7 +4,7 @@
* (C) 1998 Waldo Bastian (bastian@kde.org)
* (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
- * Copyright (C) 2003, 2004, 2005, 2006, 2009, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2003, 2004, 2005, 2006, 2009, 2010, 2014 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -22,12 +22,13 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef RenderTable_h
-#define RenderTable_h
+#pragma once
#include "CSSPropertyNames.h"
#include "CollapsedBorderValue.h"
#include "RenderBlock.h"
+#include <memory>
+#include <wtf/HashMap.h>
#include <wtf/Vector.h>
namespace WebCore {
@@ -42,44 +43,44 @@ enum SkipEmptySectionsValue { DoNotSkipEmptySections, SkipEmptySections };
class RenderTable : public RenderBlock {
public:
- RenderTable(Element&, PassRef<RenderStyle>);
- RenderTable(Document&, PassRef<RenderStyle>);
+ RenderTable(Element&, RenderStyle&&);
+ RenderTable(Document&, RenderStyle&&);
virtual ~RenderTable();
// Per CSS 3 writing-mode: "The first and second values of the 'border-spacing' property represent spacing between columns
// and rows respectively, not necessarily the horizontal and vertical spacing respectively".
- int hBorderSpacing() const { return m_hSpacing; }
- int vBorderSpacing() const { return m_vSpacing; }
+ LayoutUnit hBorderSpacing() const { return m_hSpacing; }
+ LayoutUnit vBorderSpacing() const { return m_vSpacing; }
bool collapseBorders() const { return style().borderCollapse(); }
- virtual int borderStart() const override { return m_borderStart; }
- virtual int borderEnd() const override { return m_borderEnd; }
- virtual int borderBefore() const override;
- virtual int borderAfter() const override;
+ LayoutUnit borderStart() const override { return m_borderStart; }
+ LayoutUnit borderEnd() const override { return m_borderEnd; }
+ LayoutUnit borderBefore() const override;
+ LayoutUnit borderAfter() const override;
- virtual int borderLeft() const override
+ LayoutUnit borderLeft() const override
{
if (style().isHorizontalWritingMode())
return style().isLeftToRightDirection() ? borderStart() : borderEnd();
return style().isFlippedBlocksWritingMode() ? borderAfter() : borderBefore();
}
- virtual int borderRight() const override
+ LayoutUnit borderRight() const override
{
if (style().isHorizontalWritingMode())
return style().isLeftToRightDirection() ? borderEnd() : borderStart();
return style().isFlippedBlocksWritingMode() ? borderBefore() : borderAfter();
}
- virtual int borderTop() const override
+ LayoutUnit borderTop() const override
{
if (style().isHorizontalWritingMode())
return style().isFlippedBlocksWritingMode() ? borderAfter() : borderBefore();
return style().isLeftToRightDirection() ? borderStart() : borderEnd();
}
- virtual int borderBottom() const override
+ LayoutUnit borderBottom() const override
{
if (style().isHorizontalWritingMode())
return style().isFlippedBlocksWritingMode() ? borderBefore() : borderAfter();
@@ -88,44 +89,44 @@ public:
Color bgColor() const { return style().visitedDependentColor(CSSPropertyBackgroundColor); }
- int outerBorderBefore() const;
- int outerBorderAfter() const;
- int outerBorderStart() const;
- int outerBorderEnd() const;
+ LayoutUnit outerBorderBefore() const;
+ LayoutUnit outerBorderAfter() const;
+ LayoutUnit outerBorderStart() const;
+ LayoutUnit outerBorderEnd() const;
- int outerBorderLeft() const
+ LayoutUnit outerBorderLeft() const
{
if (style().isHorizontalWritingMode())
return style().isLeftToRightDirection() ? outerBorderStart() : outerBorderEnd();
return style().isFlippedBlocksWritingMode() ? outerBorderAfter() : outerBorderBefore();
}
- int outerBorderRight() const
+ LayoutUnit outerBorderRight() const
{
if (style().isHorizontalWritingMode())
return style().isLeftToRightDirection() ? outerBorderEnd() : outerBorderStart();
return style().isFlippedBlocksWritingMode() ? outerBorderBefore() : outerBorderAfter();
}
- int outerBorderTop() const
+ LayoutUnit outerBorderTop() const
{
if (style().isHorizontalWritingMode())
return style().isFlippedBlocksWritingMode() ? outerBorderAfter() : outerBorderBefore();
return style().isLeftToRightDirection() ? outerBorderStart() : outerBorderEnd();
}
- int outerBorderBottom() const
+ LayoutUnit outerBorderBottom() const
{
if (style().isHorizontalWritingMode())
return style().isFlippedBlocksWritingMode() ? outerBorderBefore() : outerBorderAfter();
return style().isLeftToRightDirection() ? outerBorderEnd() : outerBorderStart();
}
- int calcBorderStart() const;
- int calcBorderEnd() const;
+ LayoutUnit calcBorderStart() const;
+ LayoutUnit calcBorderEnd() const;
void recalcBordersInRowDirection();
- virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0) override final;
+ void addChild(RenderObject* child, RenderObject* beforeChild = 0) final;
struct ColumnStruct {
explicit ColumnStruct(unsigned initialSpan = 1)
@@ -143,8 +144,8 @@ public:
}
const Vector<ColumnStruct>& columns() const { return m_columns; }
- const Vector<int>& columnPositions() const { return m_columnPos; }
- void setColumnPosition(unsigned index, int position)
+ const Vector<LayoutUnit>& columnPositions() const { return m_columnPos; }
+ void setColumnPosition(unsigned index, LayoutUnit position)
{
// Note that if our horizontal border-spacing changed, our position will change but not
// our column's width. In practice, horizontal border-spacing won't change often.
@@ -172,6 +173,9 @@ public:
unsigned colToEffCol(unsigned column) const
{
+ if (!m_hasCellColspanThatDeterminesTableWidth)
+ return column;
+
unsigned effColumn = 0;
unsigned numColumns = numEffCols();
for (unsigned c = 0; effColumn < numColumns && c + m_columns[effColumn].span - 1 < column; ++effColumn)
@@ -181,6 +185,9 @@ public:
unsigned effColToCol(unsigned effCol) const
{
+ if (!m_hasCellColspanThatDeterminesTableWidth)
+ return effCol;
+
unsigned c = 0;
for (unsigned i = 0; i < effCol; i++)
c += m_columns[i].span;
@@ -190,15 +197,11 @@ public:
LayoutUnit borderSpacingInRowDirection() const
{
if (unsigned effectiveColumnCount = numEffCols())
- return static_cast<LayoutUnit>(effectiveColumnCount + 1) * hBorderSpacing();
+ return (effectiveColumnCount + 1) * hBorderSpacing();
return 0;
}
- // Override paddingStart/End to return pixel values to match behavor of RenderTableCell.
- virtual LayoutUnit paddingEnd() const override final { return static_cast<int>(RenderBlock::paddingEnd()); }
- virtual LayoutUnit paddingStart() const override final { return static_cast<int>(RenderBlock::paddingStart()); }
-
LayoutUnit bordersPaddingAndSpacingInRowDirection() const
{
// 'border-spacing' only applies to separate borders (see 17.6.1 The separated borders model).
@@ -219,7 +222,7 @@ public:
bool needsSectionRecalc() const { return m_needsSectionRecalc; }
void setNeedsSectionRecalc()
{
- if (documentBeingDestroyed())
+ if (renderTreeBeingDestroyed())
return;
m_needsSectionRecalc = true;
setNeedsLayout();
@@ -234,11 +237,9 @@ public:
RenderTableCell* cellAfter(const RenderTableCell*) const;
typedef Vector<CollapsedBorderValue> CollapsedBorderValues;
- void invalidateCollapsedBorders()
- {
- m_collapsedBordersValid = false;
- m_collapsedBorders.clear();
- }
+ bool collapsedBordersAreValid() const { return m_collapsedBordersValid; }
+ void invalidateCollapsedBorders(RenderTableCell* cellWithStyleChange = nullptr);
+ void collapsedEmptyBorderIsPresent() { m_collapsedEmptyBorderIsPresent = true; }
const CollapsedBorderValue* currentBorderValue() const { return m_currentBorder; }
bool hasSections() const { return m_head || m_foot || m_firstBody; }
@@ -249,95 +250,122 @@ public:
recalcSections();
}
- static RenderTable* createAnonymousWithParentRenderer(const RenderObject*);
- virtual RenderBox* createAnonymousBoxWithSameTypeAs(const RenderObject* parent) const override
- {
- return createAnonymousWithParentRenderer(parent);
- }
+ static std::unique_ptr<RenderTable> createAnonymousWithParentRenderer(const RenderElement&);
+ std::unique_ptr<RenderBox> createAnonymousBoxWithSameTypeAs(const RenderBox& renderer) const override;
- const BorderValue& tableStartBorderAdjoiningCell(const RenderTableCell*) const;
- const BorderValue& tableEndBorderAdjoiningCell(const RenderTableCell*) const;
+ const BorderValue& tableStartBorderAdjoiningCell(const RenderTableCell&) const;
+ const BorderValue& tableEndBorderAdjoiningCell(const RenderTableCell&) const;
void addCaption(const RenderTableCaption*);
void removeCaption(const RenderTableCaption*);
void addColumn(const RenderTableCol*);
void removeColumn(const RenderTableCol*);
+ LayoutUnit offsetTopForColumn(const RenderTableCol&) const;
+ LayoutUnit offsetLeftForColumn(const RenderTableCol&) const;
+ LayoutUnit offsetWidthForColumn(const RenderTableCol&) const;
+ LayoutUnit offsetHeightForColumn(const RenderTableCol&) const;
+
+ void markForPaginationRelayoutIfNeeded() final;
+
protected:
- virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override final;
- virtual void simplifiedNormalFlowLayout() override final;
+ void styleDidChange(StyleDifference, const RenderStyle* oldStyle) final;
+ void simplifiedNormalFlowLayout() final;
private:
- virtual const char* renderName() const override { return "RenderTable"; }
+ static std::unique_ptr<RenderTable> createTableWithStyle(Document&, const RenderStyle&);
+
+ const char* renderName() const override { return "RenderTable"; }
- virtual bool isTable() const override final { return true; }
+ bool isTable() const final { return true; }
- virtual bool avoidsFloats() const override final { return true; }
+ bool avoidsFloats() const final { return true; }
- virtual void paint(PaintInfo&, const LayoutPoint&) override final;
- virtual void paintObject(PaintInfo&, const LayoutPoint&) override final;
- virtual void paintBoxDecorations(PaintInfo&, const LayoutPoint&) override final;
- virtual void paintMask(PaintInfo&, const LayoutPoint&) override final;
- virtual void layout() override final;
- virtual void computeIntrinsicLogicalWidths(LayoutUnit& minWidth, LayoutUnit& maxWidth) const override final;
- virtual void computePreferredLogicalWidths() override;
- virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) override;
+ void paint(PaintInfo&, const LayoutPoint&) final;
+ void paintObject(PaintInfo&, const LayoutPoint&) final;
+ void paintBoxDecorations(PaintInfo&, const LayoutPoint&) final;
+ void paintMask(PaintInfo&, const LayoutPoint&) final;
+ void layout() final;
+ void computeIntrinsicLogicalWidths(LayoutUnit& minWidth, LayoutUnit& maxWidth) const final;
+ void computePreferredLogicalWidths() override;
+ bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) override;
- virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const override final;
- virtual int firstLineBaseline() const override;
- virtual int inlineBlockBaseline(LineDirectionMode) const override final;
+ int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const final;
+ std::optional<int> firstLineBaseline() const override;
+ std::optional<int> inlineBlockBaseline(LineDirectionMode) const final;
RenderTableCol* slowColElement(unsigned col, bool* startEdge, bool* endEdge) const;
void updateColumnCache() const;
void invalidateCachedColumns();
- virtual RenderBlock* firstLineBlock() const override final;
- virtual void updateFirstLetter() override final;
+ void invalidateCachedColumnOffsets();
+
+ RenderBlock* firstLineBlock() const final;
+ void updateFirstLetter(RenderTreeMutationIsAllowed = RenderTreeMutationIsAllowed::Yes) final;
- virtual void updateLogicalWidth() override final;
+ void updateLogicalWidth() final;
LayoutUnit convertStyleLogicalWidthToComputedWidth(const Length& styleLogicalWidth, LayoutUnit availableWidth);
LayoutUnit convertStyleLogicalHeightToComputedHeight(const Length& styleLogicalHeight);
- virtual LayoutRect overflowClipRect(const LayoutPoint& location, RenderRegion*, OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize, PaintPhase = PaintPhaseBlockBackground) override final;
- virtual LayoutRect overflowClipRectForChildLayers(const LayoutPoint& location, RenderRegion* region, OverlayScrollbarSizeRelevancy relevancy) override { return RenderBox::overflowClipRect(location, region, relevancy); }
+ LayoutRect overflowClipRect(const LayoutPoint& location, RenderRegion*, OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize, PaintPhase = PaintPhaseBlockBackground) final;
+ LayoutRect overflowClipRectForChildLayers(const LayoutPoint& location, RenderRegion* region, OverlayScrollbarSizeRelevancy relevancy) override { return RenderBox::overflowClipRect(location, region, relevancy); }
- virtual void addOverflowFromChildren() override final;
+ void addOverflowFromChildren() final;
void subtractCaptionRect(LayoutRect&) const;
void recalcCollapsedBorders();
void recalcSections() const;
- void layoutCaption(RenderTableCaption*);
+ enum class BottomCaptionLayoutPhase { Yes, No };
+ void layoutCaptions(BottomCaptionLayoutPhase = BottomCaptionLayoutPhase::No);
+ void layoutCaption(RenderTableCaption&);
- void distributeExtraLogicalHeight(int extraLogicalHeight);
+ void distributeExtraLogicalHeight(LayoutUnit extraLogicalHeight);
- mutable Vector<int> m_columnPos;
+ mutable Vector<LayoutUnit> m_columnPos;
mutable Vector<ColumnStruct> m_columns;
mutable Vector<RenderTableCaption*> m_captions;
mutable Vector<RenderTableCol*> m_columnRenderers;
+ unsigned effectiveIndexOfColumn(const RenderTableCol&) const;
+ typedef HashMap<const RenderTableCol*, unsigned> EffectiveColumnIndexMap;
+ mutable EffectiveColumnIndexMap m_effectiveColumnIndexMap;
+
mutable RenderTableSection* m_head;
mutable RenderTableSection* m_foot;
mutable RenderTableSection* m_firstBody;
- OwnPtr<TableLayout> m_tableLayout;
+ std::unique_ptr<TableLayout> m_tableLayout;
CollapsedBorderValues m_collapsedBorders;
const CollapsedBorderValue* m_currentBorder;
bool m_collapsedBordersValid : 1;
+ bool m_collapsedEmptyBorderIsPresent : 1;
mutable bool m_hasColElements : 1;
mutable bool m_needsSectionRecalc : 1;
bool m_columnLogicalWidthChanged : 1;
mutable bool m_columnRenderersValid: 1;
+ mutable bool m_hasCellColspanThatDeterminesTableWidth : 1;
- short m_hSpacing;
- short m_vSpacing;
- int m_borderStart;
- int m_borderEnd;
+ bool hasCellColspanThatDeterminesTableWidth() const
+ {
+ for (unsigned c = 0; c < numEffCols(); c++) {
+ if (m_columns[c].span > 1)
+ return true;
+ }
+ return false;
+ }
+
+ LayoutUnit m_hSpacing;
+ LayoutUnit m_vSpacing;
+ LayoutUnit m_borderStart;
+ LayoutUnit m_borderEnd;
+ mutable LayoutUnit m_columnOffsetTop;
+ mutable LayoutUnit m_columnOffsetHeight;
};
inline RenderTableSection* RenderTable::topSection() const
@@ -350,8 +378,13 @@ inline RenderTableSection* RenderTable::topSection() const
return m_foot;
}
-RENDER_OBJECT_TYPE_CASTS(RenderTable, isTable())
+inline bool isDirectionSame(const RenderBox* tableItem, const RenderBox* otherTableItem) { return tableItem && otherTableItem ? tableItem->style().direction() == otherTableItem->style().direction() : true; }
+
+inline std::unique_ptr<RenderBox> RenderTable::createAnonymousBoxWithSameTypeAs(const RenderBox& renderer) const
+{
+ return RenderTable::createTableWithStyle(renderer.document(), renderer.style());
+}
} // namespace WebCore
-#endif // RenderTable_h
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderTable, isTable())