| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1997 Martin Jones (mjones@kde.org) | 2 * Copyright (C) 1997 Martin Jones (mjones@kde.org) |
| 3 * (C) 1997 Torben Weis (weis@kde.org) | 3 * (C) 1997 Torben Weis (weis@kde.org) |
| 4 * (C) 1998 Waldo Bastian (bastian@kde.org) | 4 * (C) 1998 Waldo Bastian (bastian@kde.org) |
| 5 * (C) 1999 Lars Knoll (knoll@kde.org) | 5 * (C) 1999 Lars Knoll (knoll@kde.org) |
| 6 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 6 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 7 * Copyright (C) 2003, 2004, 2005, 2006, 2009, 2010 Apple Inc. All rights reserv
ed. | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2009, 2010 Apple Inc. All rights reserv
ed. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 class LayoutTableCaption; | 37 class LayoutTableCaption; |
| 38 class LayoutTableCell; | 38 class LayoutTableCell; |
| 39 class LayoutTableSection; | 39 class LayoutTableSection; |
| 40 class TableLayoutAlgorithm; | 40 class TableLayoutAlgorithm; |
| 41 | 41 |
| 42 enum SkipEmptySectionsValue { DoNotSkipEmptySections, SkipEmptySections }; | 42 enum SkipEmptySectionsValue { DoNotSkipEmptySections, SkipEmptySections }; |
| 43 | 43 |
| 44 class CORE_EXPORT LayoutTable final : public LayoutBlock { | 44 class CORE_EXPORT LayoutTable final : public LayoutBlock { |
| 45 public: | 45 public: |
| 46 explicit LayoutTable(Element*); | 46 explicit LayoutTable(Element*); |
| 47 virtual ~LayoutTable(); | 47 ~LayoutTable() override; |
| 48 | 48 |
| 49 // Per CSS 3 writing-mode: "The first and second values of the 'border-spaci
ng' property represent spacing between columns | 49 // Per CSS 3 writing-mode: "The first and second values of the 'border-spaci
ng' property represent spacing between columns |
| 50 // and rows respectively, not necessarily the horizontal and vertical spacin
g respectively". | 50 // and rows respectively, not necessarily the horizontal and vertical spacin
g respectively". |
| 51 int hBorderSpacing() const { return m_hSpacing; } | 51 int hBorderSpacing() const { return m_hSpacing; } |
| 52 int vBorderSpacing() const { return m_vSpacing; } | 52 int vBorderSpacing() const { return m_vSpacing; } |
| 53 | 53 |
| 54 bool collapseBorders() const { return style()->borderCollapse(); } | 54 bool collapseBorders() const { return style()->borderCollapse(); } |
| 55 | 55 |
| 56 virtual int borderStart() const override { return m_borderStart; } | 56 int borderStart() const override { return m_borderStart; } |
| 57 virtual int borderEnd() const override { return m_borderEnd; } | 57 int borderEnd() const override { return m_borderEnd; } |
| 58 virtual int borderBefore() const override; | 58 int borderBefore() const override; |
| 59 virtual int borderAfter() const override; | 59 int borderAfter() const override; |
| 60 | 60 |
| 61 virtual int borderLeft() const override | 61 int borderLeft() const override |
| 62 { | 62 { |
| 63 if (style()->isHorizontalWritingMode()) | 63 if (style()->isHorizontalWritingMode()) |
| 64 return style()->isLeftToRightDirection() ? borderStart() : borderEnd
(); | 64 return style()->isLeftToRightDirection() ? borderStart() : borderEnd
(); |
| 65 return style()->isFlippedBlocksWritingMode() ? borderAfter() : borderBef
ore(); | 65 return style()->isFlippedBlocksWritingMode() ? borderAfter() : borderBef
ore(); |
| 66 } | 66 } |
| 67 | 67 |
| 68 virtual int borderRight() const override | 68 int borderRight() const override |
| 69 { | 69 { |
| 70 if (style()->isHorizontalWritingMode()) | 70 if (style()->isHorizontalWritingMode()) |
| 71 return style()->isLeftToRightDirection() ? borderEnd() : borderStart
(); | 71 return style()->isLeftToRightDirection() ? borderEnd() : borderStart
(); |
| 72 return style()->isFlippedBlocksWritingMode() ? borderBefore() : borderAf
ter(); | 72 return style()->isFlippedBlocksWritingMode() ? borderBefore() : borderAf
ter(); |
| 73 } | 73 } |
| 74 | 74 |
| 75 virtual int borderTop() const override | 75 int borderTop() const override |
| 76 { | 76 { |
| 77 if (style()->isHorizontalWritingMode()) | 77 if (style()->isHorizontalWritingMode()) |
| 78 return style()->isFlippedBlocksWritingMode() ? borderAfter() : borde
rBefore(); | 78 return style()->isFlippedBlocksWritingMode() ? borderAfter() : borde
rBefore(); |
| 79 return style()->isLeftToRightDirection() ? borderStart() : borderEnd(); | 79 return style()->isLeftToRightDirection() ? borderStart() : borderEnd(); |
| 80 } | 80 } |
| 81 | 81 |
| 82 virtual int borderBottom() const override | 82 int borderBottom() const override |
| 83 { | 83 { |
| 84 if (style()->isHorizontalWritingMode()) | 84 if (style()->isHorizontalWritingMode()) |
| 85 return style()->isFlippedBlocksWritingMode() ? borderBefore() : bord
erAfter(); | 85 return style()->isFlippedBlocksWritingMode() ? borderBefore() : bord
erAfter(); |
| 86 return style()->isLeftToRightDirection() ? borderEnd() : borderStart(); | 86 return style()->isLeftToRightDirection() ? borderEnd() : borderStart(); |
| 87 } | 87 } |
| 88 | 88 |
| 89 int outerBorderBefore() const; | 89 int outerBorderBefore() const; |
| 90 int outerBorderAfter() const; | 90 int outerBorderAfter() const; |
| 91 int outerBorderStart() const; | 91 int outerBorderStart() const; |
| 92 int outerBorderEnd() const; | 92 int outerBorderEnd() const; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 116 { | 116 { |
| 117 if (style()->isHorizontalWritingMode()) | 117 if (style()->isHorizontalWritingMode()) |
| 118 return style()->isFlippedBlocksWritingMode() ? outerBorderBefore() :
outerBorderAfter(); | 118 return style()->isFlippedBlocksWritingMode() ? outerBorderBefore() :
outerBorderAfter(); |
| 119 return style()->isLeftToRightDirection() ? outerBorderEnd() : outerBorde
rStart(); | 119 return style()->isLeftToRightDirection() ? outerBorderEnd() : outerBorde
rStart(); |
| 120 } | 120 } |
| 121 | 121 |
| 122 int calcBorderStart() const; | 122 int calcBorderStart() const; |
| 123 int calcBorderEnd() const; | 123 int calcBorderEnd() const; |
| 124 void recalcBordersInRowDirection(); | 124 void recalcBordersInRowDirection(); |
| 125 | 125 |
| 126 virtual void addChild(LayoutObject* child, LayoutObject* beforeChild = nullp
tr) override; | 126 void addChild(LayoutObject* child, LayoutObject* beforeChild = nullptr) over
ride; |
| 127 virtual void addChildIgnoringContinuation(LayoutObject* newChild, LayoutObje
ct* beforeChild = nullptr) override; | 127 void addChildIgnoringContinuation(LayoutObject* newChild, LayoutObject* befo
reChild = nullptr) override; |
| 128 | 128 |
| 129 struct ColumnStruct { | 129 struct ColumnStruct { |
| 130 explicit ColumnStruct(unsigned initialSpan = 1) | 130 explicit ColumnStruct(unsigned initialSpan = 1) |
| 131 : span(initialSpan) | 131 : span(initialSpan) |
| 132 { | 132 { |
| 133 } | 133 } |
| 134 | 134 |
| 135 unsigned span; | 135 unsigned span; |
| 136 }; | 136 }; |
| 137 | 137 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 | 194 |
| 195 LayoutUnit borderSpacingInRowDirection() const | 195 LayoutUnit borderSpacingInRowDirection() const |
| 196 { | 196 { |
| 197 if (unsigned effectiveColumnCount = numEffCols()) | 197 if (unsigned effectiveColumnCount = numEffCols()) |
| 198 return static_cast<LayoutUnit>(effectiveColumnCount + 1) * hBorderSp
acing(); | 198 return static_cast<LayoutUnit>(effectiveColumnCount + 1) * hBorderSp
acing(); |
| 199 | 199 |
| 200 return 0; | 200 return 0; |
| 201 } | 201 } |
| 202 | 202 |
| 203 // Override paddingStart/End to return pixel values to match behavor of Layo
utTableCell. | 203 // Override paddingStart/End to return pixel values to match behavor of Layo
utTableCell. |
| 204 virtual LayoutUnit paddingEnd() const override { return static_cast<int>(Lay
outBlock::paddingEnd()); } | 204 LayoutUnit paddingEnd() const override { return static_cast<int>(LayoutBlock
::paddingEnd()); } |
| 205 virtual LayoutUnit paddingStart() const override { return static_cast<int>(L
ayoutBlock::paddingStart()); } | 205 LayoutUnit paddingStart() const override { return static_cast<int>(LayoutBlo
ck::paddingStart()); } |
| 206 | 206 |
| 207 LayoutUnit bordersPaddingAndSpacingInRowDirection() const | 207 LayoutUnit bordersPaddingAndSpacingInRowDirection() const |
| 208 { | 208 { |
| 209 // 'border-spacing' only applies to separate borders (see 17.6.1 The sep
arated borders model). | 209 // 'border-spacing' only applies to separate borders (see 17.6.1 The sep
arated borders model). |
| 210 return borderStart() + borderEnd() + (collapseBorders() ? LayoutUnit() :
(paddingStart() + paddingEnd() + borderSpacingInRowDirection())); | 210 return borderStart() + borderEnd() + (collapseBorders() ? LayoutUnit() :
(paddingStart() + paddingEnd() + borderSpacingInRowDirection())); |
| 211 } | 211 } |
| 212 | 212 |
| 213 // Return the first column or column-group. | 213 // Return the first column or column-group. |
| 214 LayoutTableCol* firstColumn() const; | 214 LayoutTableCol* firstColumn() const; |
| 215 | 215 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 | 247 |
| 248 bool hasSections() const { return m_head || m_foot || m_firstBody; } | 248 bool hasSections() const { return m_head || m_foot || m_firstBody; } |
| 249 | 249 |
| 250 void recalcSectionsIfNeeded() const | 250 void recalcSectionsIfNeeded() const |
| 251 { | 251 { |
| 252 if (m_needsSectionRecalc) | 252 if (m_needsSectionRecalc) |
| 253 recalcSections(); | 253 recalcSections(); |
| 254 } | 254 } |
| 255 | 255 |
| 256 static LayoutTable* createAnonymousWithParent(const LayoutObject*); | 256 static LayoutTable* createAnonymousWithParent(const LayoutObject*); |
| 257 virtual LayoutBox* createAnonymousBoxWithSameTypeAs(const LayoutObject* pare
nt) const override | 257 LayoutBox* createAnonymousBoxWithSameTypeAs(const LayoutObject* parent) cons
t override |
| 258 { | 258 { |
| 259 return createAnonymousWithParent(parent); | 259 return createAnonymousWithParent(parent); |
| 260 } | 260 } |
| 261 | 261 |
| 262 const BorderValue& tableStartBorderAdjoiningCell(const LayoutTableCell*) con
st; | 262 const BorderValue& tableStartBorderAdjoiningCell(const LayoutTableCell*) con
st; |
| 263 const BorderValue& tableEndBorderAdjoiningCell(const LayoutTableCell*) const
; | 263 const BorderValue& tableEndBorderAdjoiningCell(const LayoutTableCell*) const
; |
| 264 | 264 |
| 265 void addCaption(const LayoutTableCaption*); | 265 void addCaption(const LayoutTableCaption*); |
| 266 void removeCaption(const LayoutTableCaption*); | 266 void removeCaption(const LayoutTableCaption*); |
| 267 void addColumn(const LayoutTableCol*); | 267 void addColumn(const LayoutTableCol*); |
| 268 void removeColumn(const LayoutTableCol*); | 268 void removeColumn(const LayoutTableCol*); |
| 269 | 269 |
| 270 virtual void paintBoxDecorationBackground(const PaintInfo&, const LayoutPoin
t&) override final; | 270 void paintBoxDecorationBackground(const PaintInfo&, const LayoutPoint&) fina
l; |
| 271 | 271 |
| 272 virtual void paintMask(const PaintInfo&, const LayoutPoint&) override final; | 272 void paintMask(const PaintInfo&, const LayoutPoint&) final; |
| 273 | 273 |
| 274 const CollapsedBorderValues& collapsedBorders() | 274 const CollapsedBorderValues& collapsedBorders() |
| 275 { | 275 { |
| 276 ASSERT(m_collapsedBordersValid); | 276 ASSERT(m_collapsedBordersValid); |
| 277 return m_collapsedBorders; | 277 return m_collapsedBorders; |
| 278 } | 278 } |
| 279 | 279 |
| 280 void subtractCaptionRect(LayoutRect&) const; | 280 void subtractCaptionRect(LayoutRect&) const; |
| 281 | 281 |
| 282 virtual const char* name() const override { return "LayoutTable"; } | 282 const char* name() const override { return "LayoutTable"; } |
| 283 | 283 |
| 284 protected: | 284 protected: |
| 285 virtual void styleDidChange(StyleDifference, const ComputedStyle* oldStyle)
override; | 285 void styleDidChange(StyleDifference, const ComputedStyle* oldStyle) override
; |
| 286 virtual void simplifiedNormalFlowLayout() override; | 286 void simplifiedNormalFlowLayout() override; |
| 287 virtual PaintInvalidationReason invalidatePaintIfNeeded(PaintInvalidationSta
te&, const LayoutBoxModelObject& paintInvalidationContainer) override; | 287 PaintInvalidationReason invalidatePaintIfNeeded(PaintInvalidationState&, con
st LayoutBoxModelObject& paintInvalidationContainer) override; |
| 288 virtual void invalidatePaintOfSubtreesIfNeeded(PaintInvalidationState&) over
ride; | 288 void invalidatePaintOfSubtreesIfNeeded(PaintInvalidationState&) override; |
| 289 | 289 |
| 290 private: | 290 private: |
| 291 virtual bool isOfType(LayoutObjectType type) const override { return type ==
LayoutObjectTable || LayoutBlock::isOfType(type); } | 291 bool isOfType(LayoutObjectType type) const override { return type == LayoutO
bjectTable || LayoutBlock::isOfType(type); } |
| 292 | 292 |
| 293 virtual void paintObject(const PaintInfo&, const LayoutPoint&) override; | 293 void paintObject(const PaintInfo&, const LayoutPoint&) override; |
| 294 virtual void layout() override; | 294 void layout() override; |
| 295 virtual void computeIntrinsicLogicalWidths(LayoutUnit& minWidth, LayoutUnit&
maxWidth) const override; | 295 void computeIntrinsicLogicalWidths(LayoutUnit& minWidth, LayoutUnit& maxWidt
h) const override; |
| 296 virtual void computePreferredLogicalWidths() override; | 296 void computePreferredLogicalWidths() override; |
| 297 virtual bool nodeAtPoint(HitTestResult&, const HitTestLocation& locationInCo
ntainer, const LayoutPoint& accumulatedOffset, HitTestAction) override; | 297 bool nodeAtPoint(HitTestResult&, const HitTestLocation& locationInContainer,
const LayoutPoint& accumulatedOffset, HitTestAction) override; |
| 298 | 298 |
| 299 virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode
, LinePositionMode = PositionOnContainingLine) const override; | 299 int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePo
sitionMode = PositionOnContainingLine) const override; |
| 300 virtual int firstLineBoxBaseline() const override; | 300 int firstLineBoxBaseline() const override; |
| 301 virtual int inlineBlockBaseline(LineDirectionMode) const override; | 301 int inlineBlockBaseline(LineDirectionMode) const override; |
| 302 | 302 |
| 303 LayoutTableCol* slowColElement(unsigned col, bool* startEdge, bool* endEdge)
const; | 303 LayoutTableCol* slowColElement(unsigned col, bool* startEdge, bool* endEdge)
const; |
| 304 | 304 |
| 305 void updateColumnCache() const; | 305 void updateColumnCache() const; |
| 306 void invalidateCachedColumns(); | 306 void invalidateCachedColumns(); |
| 307 | 307 |
| 308 virtual void updateLogicalWidth() override; | 308 void updateLogicalWidth() override; |
| 309 | 309 |
| 310 LayoutUnit convertStyleLogicalWidthToComputedWidth(const Length& styleLogica
lWidth, LayoutUnit availableWidth); | 310 LayoutUnit convertStyleLogicalWidthToComputedWidth(const Length& styleLogica
lWidth, LayoutUnit availableWidth); |
| 311 LayoutUnit convertStyleLogicalHeightToComputedHeight(const Length& styleLogi
calHeight); | 311 LayoutUnit convertStyleLogicalHeightToComputedHeight(const Length& styleLogi
calHeight); |
| 312 | 312 |
| 313 virtual LayoutRect overflowClipRect(const LayoutPoint& location, OverlayScro
llbarSizeRelevancy = IgnoreOverlayScrollbarSize) const override; | 313 LayoutRect overflowClipRect(const LayoutPoint& location, OverlayScrollbarSiz
eRelevancy = IgnoreOverlayScrollbarSize) const override; |
| 314 | 314 |
| 315 virtual void addOverflowFromChildren() override; | 315 void addOverflowFromChildren() override; |
| 316 | 316 |
| 317 void recalcSections() const; | 317 void recalcSections() const; |
| 318 void layoutCaption(LayoutTableCaption&); | 318 void layoutCaption(LayoutTableCaption&); |
| 319 | 319 |
| 320 void distributeExtraLogicalHeight(int extraLogicalHeight); | 320 void distributeExtraLogicalHeight(int extraLogicalHeight); |
| 321 | 321 |
| 322 void recalcCollapsedBordersIfNeeded(); | 322 void recalcCollapsedBordersIfNeeded(); |
| 323 | 323 |
| 324 mutable Vector<int> m_columnPos; | 324 mutable Vector<int> m_columnPos; |
| 325 mutable Vector<ColumnStruct> m_columns; | 325 mutable Vector<ColumnStruct> m_columns; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 if (m_firstBody) | 366 if (m_firstBody) |
| 367 return m_firstBody; | 367 return m_firstBody; |
| 368 return m_foot; | 368 return m_foot; |
| 369 } | 369 } |
| 370 | 370 |
| 371 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutTable, isTable()); | 371 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutTable, isTable()); |
| 372 | 372 |
| 373 } // namespace blink | 373 } // namespace blink |
| 374 | 374 |
| 375 #endif // LayoutTable_h | 375 #endif // LayoutTable_h |
| OLD | NEW |