| 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, 2007, 2008, 2009 Apple Inc. All rights
reserved. | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
reserved. |
| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 , m_intrinsicPaddingBefore(0) | 59 , m_intrinsicPaddingBefore(0) |
| 60 , m_intrinsicPaddingAfter(0) | 60 , m_intrinsicPaddingAfter(0) |
| 61 { | 61 { |
| 62 // We only update the flags when notified of DOM changes in colSpanOrRowSpan
Changed() | 62 // We only update the flags when notified of DOM changes in colSpanOrRowSpan
Changed() |
| 63 // so we need to set their initial values here in case something asks for co
lSpan()/rowSpan() before then. | 63 // so we need to set their initial values here in case something asks for co
lSpan()/rowSpan() before then. |
| 64 updateColAndRowSpanFlags(); | 64 updateColAndRowSpanFlags(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void RenderTableCell::willBeRemovedFromTree() | 67 void RenderTableCell::willBeRemovedFromTree() |
| 68 { | 68 { |
| 69 RenderBlock::willBeRemovedFromTree(); | 69 RenderBlockFlow::willBeRemovedFromTree(); |
| 70 | 70 |
| 71 section()->setNeedsCellRecalc(); | 71 section()->setNeedsCellRecalc(); |
| 72 section()->removeCachedCollapsedBorders(this); | 72 section()->removeCachedCollapsedBorders(this); |
| 73 } | 73 } |
| 74 | 74 |
| 75 unsigned RenderTableCell::parseColSpanFromDOM() const | 75 unsigned RenderTableCell::parseColSpanFromDOM() const |
| 76 { | 76 { |
| 77 ASSERT(node()); | 77 ASSERT(node()); |
| 78 if (node()->hasTagName(tdTag) || node()->hasTagName(thTag)) | 78 if (node()->hasTagName(tdTag) || node()->hasTagName(thTag)) |
| 79 return min<unsigned>(toHTMLTableCellElement(node())->colSpan(), maxColum
nIndex); | 79 return min<unsigned>(toHTMLTableCellElement(node())->colSpan(), maxColum
nIndex); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 return Length(colWidthSum, Fixed); | 142 return Length(colWidthSum, Fixed); |
| 143 } | 143 } |
| 144 | 144 |
| 145 void RenderTableCell::computePreferredLogicalWidths() | 145 void RenderTableCell::computePreferredLogicalWidths() |
| 146 { | 146 { |
| 147 // The child cells rely on the grids up in the sections to do their computeP
referredLogicalWidths work. Normally the sections are set up early, as table | 147 // The child cells rely on the grids up in the sections to do their computeP
referredLogicalWidths work. Normally the sections are set up early, as table |
| 148 // cells are added, but relayout can cause the cells to be freed, leaving st
ale pointers in the sections' | 148 // cells are added, but relayout can cause the cells to be freed, leaving st
ale pointers in the sections' |
| 149 // grids. We must refresh those grids before the child cells try to use the
m. | 149 // grids. We must refresh those grids before the child cells try to use the
m. |
| 150 table()->recalcSectionsIfNeeded(); | 150 table()->recalcSectionsIfNeeded(); |
| 151 | 151 |
| 152 RenderBlock::computePreferredLogicalWidths(); | 152 RenderBlockFlow::computePreferredLogicalWidths(); |
| 153 if (node() && style()->autoWrap()) { | 153 if (node() && style()->autoWrap()) { |
| 154 // See if nowrap was set. | 154 // See if nowrap was set. |
| 155 Length w = styleOrColLogicalWidth(); | 155 Length w = styleOrColLogicalWidth(); |
| 156 const AtomicString& nowrap = toElement(node())->getAttribute(nowrapAttr)
; | 156 const AtomicString& nowrap = toElement(node())->getAttribute(nowrapAttr)
; |
| 157 if (!nowrap.isNull() && w.isFixed()) | 157 if (!nowrap.isNull() && w.isFixed()) |
| 158 // Nowrap is set, but we didn't actually use it because of the | 158 // Nowrap is set, but we didn't actually use it because of the |
| 159 // fixed width set on the cell. Even so, it is a WinIE/Moz trait | 159 // fixed width set on the cell. Even so, it is a WinIE/Moz trait |
| 160 // to make the minwidth of the cell into the fixed width. They do t
his | 160 // to make the minwidth of the cell into the fixed width. They do t
his |
| 161 // even in strict mode, so do not make this a quirk. Affected the t
op | 161 // even in strict mode, so do not make this a quirk. Affected the t
op |
| 162 // of hiptop.com. | 162 // of hiptop.com. |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 void RenderTableCell::setOverrideLogicalContentHeightFromRowHeight(LayoutUnit ro
wHeight) | 304 void RenderTableCell::setOverrideLogicalContentHeightFromRowHeight(LayoutUnit ro
wHeight) |
| 305 { | 305 { |
| 306 clearIntrinsicPadding(); | 306 clearIntrinsicPadding(); |
| 307 setOverrideLogicalContentHeight(max<LayoutUnit>(0, rowHeight - borderAndPadd
ingLogicalHeight())); | 307 setOverrideLogicalContentHeight(max<LayoutUnit>(0, rowHeight - borderAndPadd
ingLogicalHeight())); |
| 308 } | 308 } |
| 309 | 309 |
| 310 LayoutSize RenderTableCell::offsetFromContainer(RenderObject* o, const LayoutPoi
nt& point, bool* offsetDependsOnPoint) const | 310 LayoutSize RenderTableCell::offsetFromContainer(RenderObject* o, const LayoutPoi
nt& point, bool* offsetDependsOnPoint) const |
| 311 { | 311 { |
| 312 ASSERT(o == container()); | 312 ASSERT(o == container()); |
| 313 | 313 |
| 314 LayoutSize offset = RenderBlock::offsetFromContainer(o, point, offsetDepends
OnPoint); | 314 LayoutSize offset = RenderBlockFlow::offsetFromContainer(o, point, offsetDep
endsOnPoint); |
| 315 if (parent()) | 315 if (parent()) |
| 316 offset -= parentBox()->locationOffset(); | 316 offset -= parentBox()->locationOffset(); |
| 317 | 317 |
| 318 return offset; | 318 return offset; |
| 319 } | 319 } |
| 320 | 320 |
| 321 LayoutRect RenderTableCell::clippedOverflowRectForRepaint(const RenderLayerModel
Object* repaintContainer) const | 321 LayoutRect RenderTableCell::clippedOverflowRectForRepaint(const RenderLayerModel
Object* repaintContainer) const |
| 322 { | 322 { |
| 323 // If the table grid is dirty, we cannot get reliable information about adjo
ining cells, | 323 // If the table grid is dirty, we cannot get reliable information about adjo
ining cells, |
| 324 // so we ignore outside borders. This should not be a problem because it mea
ns that | 324 // so we ignore outside borders. This should not be a problem because it mea
ns that |
| 325 // the table is going to recalculate the grid, relayout and repaint its curr
ent rect, which | 325 // the table is going to recalculate the grid, relayout and repaint its curr
ent rect, which |
| 326 // includes any outside borders of this cell. | 326 // includes any outside borders of this cell. |
| 327 if (!table()->collapseBorders() || table()->needsSectionRecalc()) | 327 if (!table()->collapseBorders() || table()->needsSectionRecalc()) |
| 328 return RenderBlock::clippedOverflowRectForRepaint(repaintContainer); | 328 return RenderBlockFlow::clippedOverflowRectForRepaint(repaintContainer); |
| 329 | 329 |
| 330 bool rtl = !styleForCellFlow()->isLeftToRightDirection(); | 330 bool rtl = !styleForCellFlow()->isLeftToRightDirection(); |
| 331 int outlineSize = style()->outlineSize(); | 331 int outlineSize = style()->outlineSize(); |
| 332 int left = max(borderHalfLeft(true), outlineSize); | 332 int left = max(borderHalfLeft(true), outlineSize); |
| 333 int right = max(borderHalfRight(true), outlineSize); | 333 int right = max(borderHalfRight(true), outlineSize); |
| 334 int top = max(borderHalfTop(true), outlineSize); | 334 int top = max(borderHalfTop(true), outlineSize); |
| 335 int bottom = max(borderHalfBottom(true), outlineSize); | 335 int bottom = max(borderHalfBottom(true), outlineSize); |
| 336 if ((left && !rtl) || (right && rtl)) { | 336 if ((left && !rtl) || (right && rtl)) { |
| 337 if (RenderTableCell* before = table()->cellBefore(this)) { | 337 if (RenderTableCell* before = table()->cellBefore(this)) { |
| 338 top = max(top, before->borderHalfTop(true)); | 338 top = max(top, before->borderHalfTop(true)); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 } | 372 } |
| 373 | 373 |
| 374 void RenderTableCell::computeRectForRepaint(const RenderLayerModelObject* repain
tContainer, LayoutRect& r, bool fixed) const | 374 void RenderTableCell::computeRectForRepaint(const RenderLayerModelObject* repain
tContainer, LayoutRect& r, bool fixed) const |
| 375 { | 375 { |
| 376 if (repaintContainer == this) | 376 if (repaintContainer == this) |
| 377 return; | 377 return; |
| 378 r.setY(r.y()); | 378 r.setY(r.y()); |
| 379 RenderView* v = view(); | 379 RenderView* v = view(); |
| 380 if ((!v || !v->layoutStateEnabled() || repaintContainer) && parent()) | 380 if ((!v || !v->layoutStateEnabled() || repaintContainer) && parent()) |
| 381 r.moveBy(-parentBox()->location()); // Rows are in the same coordinate s
pace, so don't add their offset in. | 381 r.moveBy(-parentBox()->location()); // Rows are in the same coordinate s
pace, so don't add their offset in. |
| 382 RenderBlock::computeRectForRepaint(repaintContainer, r, fixed); | 382 RenderBlockFlow::computeRectForRepaint(repaintContainer, r, fixed); |
| 383 } | 383 } |
| 384 | 384 |
| 385 LayoutUnit RenderTableCell::cellBaselinePosition() const | 385 LayoutUnit RenderTableCell::cellBaselinePosition() const |
| 386 { | 386 { |
| 387 // <http://www.w3.org/TR/2007/CR-CSS21-20070719/tables.html#height-layout>:
The baseline of a cell is the baseline of | 387 // <http://www.w3.org/TR/2007/CR-CSS21-20070719/tables.html#height-layout>:
The baseline of a cell is the baseline of |
| 388 // the first in-flow line box in the cell, or the first in-flow table-row in
the cell, whichever comes first. If there | 388 // the first in-flow line box in the cell, or the first in-flow table-row in
the cell, whichever comes first. If there |
| 389 // is no such line box or table-row, the baseline is the bottom of content e
dge of the cell box. | 389 // is no such line box or table-row, the baseline is the bottom of content e
dge of the cell box. |
| 390 LayoutUnit firstLineBaseline = firstLineBoxBaseline(); | 390 LayoutUnit firstLineBaseline = firstLineBoxBaseline(); |
| 391 if (firstLineBaseline != -1) | 391 if (firstLineBaseline != -1) |
| 392 return firstLineBaseline; | 392 return firstLineBaseline; |
| 393 return paddingBefore() + borderBefore() + contentLogicalHeight(); | 393 return paddingBefore() + borderBefore() + contentLogicalHeight(); |
| 394 } | 394 } |
| 395 | 395 |
| 396 void RenderTableCell::styleDidChange(StyleDifference diff, const RenderStyle* ol
dStyle) | 396 void RenderTableCell::styleDidChange(StyleDifference diff, const RenderStyle* ol
dStyle) |
| 397 { | 397 { |
| 398 ASSERT(style()->display() == TABLE_CELL); | 398 ASSERT(style()->display() == TABLE_CELL); |
| 399 ASSERT(!row() || row()->rowIndexWasSet()); | 399 ASSERT(!row() || row()->rowIndexWasSet()); |
| 400 | 400 |
| 401 RenderBlock::styleDidChange(diff, oldStyle); | 401 RenderBlockFlow::styleDidChange(diff, oldStyle); |
| 402 setHasBoxDecorations(true); | 402 setHasBoxDecorations(true); |
| 403 | 403 |
| 404 if (parent() && section() && oldStyle && style()->height() != oldStyle->heig
ht()) | 404 if (parent() && section() && oldStyle && style()->height() != oldStyle->heig
ht()) |
| 405 section()->rowLogicalHeightChanged(rowIndex()); | 405 section()->rowLogicalHeightChanged(rowIndex()); |
| 406 | 406 |
| 407 // Our intrinsic padding pushes us down to align with the baseline of other
cells on the row. If our vertical-align | 407 // Our intrinsic padding pushes us down to align with the baseline of other
cells on the row. If our vertical-align |
| 408 // has changed then so will the padding needed to align with other cells - c
lear it so we can recalculate it from scratch. | 408 // has changed then so will the padding needed to align with other cells - c
lear it so we can recalculate it from scratch. |
| 409 if (oldStyle && style()->verticalAlign() != oldStyle->verticalAlign()) | 409 if (oldStyle && style()->verticalAlign() != oldStyle->verticalAlign()) |
| 410 clearIntrinsicPadding(); | 410 clearIntrinsicPadding(); |
| 411 | 411 |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 | 889 |
| 890 inline CollapsedBorderValue RenderTableCell::cachedCollapsedBottomBorder(const R
enderStyle* styleForCellFlow) const | 890 inline CollapsedBorderValue RenderTableCell::cachedCollapsedBottomBorder(const R
enderStyle* styleForCellFlow) const |
| 891 { | 891 { |
| 892 if (styleForCellFlow->isHorizontalWritingMode()) | 892 if (styleForCellFlow->isHorizontalWritingMode()) |
| 893 return styleForCellFlow->isFlippedBlocksWritingMode() ? section()->cache
dCollapsedBorder(this, CBSBefore) : section()->cachedCollapsedBorder(this, CBSAf
ter); | 893 return styleForCellFlow->isFlippedBlocksWritingMode() ? section()->cache
dCollapsedBorder(this, CBSBefore) : section()->cachedCollapsedBorder(this, CBSAf
ter); |
| 894 return styleForCellFlow->isLeftToRightDirection() ? section()->cachedCollaps
edBorder(this, CBSEnd) : section()->cachedCollapsedBorder(this, CBSStart); | 894 return styleForCellFlow->isLeftToRightDirection() ? section()->cachedCollaps
edBorder(this, CBSEnd) : section()->cachedCollapsedBorder(this, CBSStart); |
| 895 } | 895 } |
| 896 | 896 |
| 897 int RenderTableCell::borderLeft() const | 897 int RenderTableCell::borderLeft() const |
| 898 { | 898 { |
| 899 return table()->collapseBorders() ? borderHalfLeft(false) : RenderBlock::bor
derLeft(); | 899 return table()->collapseBorders() ? borderHalfLeft(false) : RenderBlockFlow:
:borderLeft(); |
| 900 } | 900 } |
| 901 | 901 |
| 902 int RenderTableCell::borderRight() const | 902 int RenderTableCell::borderRight() const |
| 903 { | 903 { |
| 904 return table()->collapseBorders() ? borderHalfRight(false) : RenderBlock::bo
rderRight(); | 904 return table()->collapseBorders() ? borderHalfRight(false) : RenderBlockFlow
::borderRight(); |
| 905 } | 905 } |
| 906 | 906 |
| 907 int RenderTableCell::borderTop() const | 907 int RenderTableCell::borderTop() const |
| 908 { | 908 { |
| 909 return table()->collapseBorders() ? borderHalfTop(false) : RenderBlock::bord
erTop(); | 909 return table()->collapseBorders() ? borderHalfTop(false) : RenderBlockFlow::
borderTop(); |
| 910 } | 910 } |
| 911 | 911 |
| 912 int RenderTableCell::borderBottom() const | 912 int RenderTableCell::borderBottom() const |
| 913 { | 913 { |
| 914 return table()->collapseBorders() ? borderHalfBottom(false) : RenderBlock::b
orderBottom(); | 914 return table()->collapseBorders() ? borderHalfBottom(false) : RenderBlockFlo
w::borderBottom(); |
| 915 } | 915 } |
| 916 | 916 |
| 917 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=46191, make the collapsed bord
er drawing | 917 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=46191, make the collapsed bord
er drawing |
| 918 // work with different block flow values instead of being hard-coded to top-to-b
ottom. | 918 // work with different block flow values instead of being hard-coded to top-to-b
ottom. |
| 919 int RenderTableCell::borderStart() const | 919 int RenderTableCell::borderStart() const |
| 920 { | 920 { |
| 921 return table()->collapseBorders() ? borderHalfStart(false) : RenderBlock::bo
rderStart(); | 921 return table()->collapseBorders() ? borderHalfStart(false) : RenderBlockFlow
::borderStart(); |
| 922 } | 922 } |
| 923 | 923 |
| 924 int RenderTableCell::borderEnd() const | 924 int RenderTableCell::borderEnd() const |
| 925 { | 925 { |
| 926 return table()->collapseBorders() ? borderHalfEnd(false) : RenderBlock::bord
erEnd(); | 926 return table()->collapseBorders() ? borderHalfEnd(false) : RenderBlockFlow::
borderEnd(); |
| 927 } | 927 } |
| 928 | 928 |
| 929 int RenderTableCell::borderBefore() const | 929 int RenderTableCell::borderBefore() const |
| 930 { | 930 { |
| 931 return table()->collapseBorders() ? borderHalfBefore(false) : RenderBlock::b
orderBefore(); | 931 return table()->collapseBorders() ? borderHalfBefore(false) : RenderBlockFlo
w::borderBefore(); |
| 932 } | 932 } |
| 933 | 933 |
| 934 int RenderTableCell::borderAfter() const | 934 int RenderTableCell::borderAfter() const |
| 935 { | 935 { |
| 936 return table()->collapseBorders() ? borderHalfAfter(false) : RenderBlock::bo
rderAfter(); | 936 return table()->collapseBorders() ? borderHalfAfter(false) : RenderBlockFlow
::borderAfter(); |
| 937 } | 937 } |
| 938 | 938 |
| 939 int RenderTableCell::borderHalfLeft(bool outer) const | 939 int RenderTableCell::borderHalfLeft(bool outer) const |
| 940 { | 940 { |
| 941 const RenderStyle* styleForCellFlow = this->styleForCellFlow(); | 941 const RenderStyle* styleForCellFlow = this->styleForCellFlow(); |
| 942 if (styleForCellFlow->isHorizontalWritingMode()) | 942 if (styleForCellFlow->isHorizontalWritingMode()) |
| 943 return styleForCellFlow->isLeftToRightDirection() ? borderHalfStart(oute
r) : borderHalfEnd(outer); | 943 return styleForCellFlow->isLeftToRightDirection() ? borderHalfStart(oute
r) : borderHalfEnd(outer); |
| 944 return styleForCellFlow->isFlippedBlocksWritingMode() ? borderHalfAfter(oute
r) : borderHalfBefore(outer); | 944 return styleForCellFlow->isFlippedBlocksWritingMode() ? borderHalfAfter(oute
r) : borderHalfBefore(outer); |
| 945 } | 945 } |
| 946 | 946 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 996 { | 996 { |
| 997 CollapsedBorderValue border = collapsedAfterBorder(DoNotIncludeBorderColor); | 997 CollapsedBorderValue border = collapsedAfterBorder(DoNotIncludeBorderColor); |
| 998 if (border.exists()) | 998 if (border.exists()) |
| 999 return (border.width() + ((styleForCellFlow()->isFlippedBlocksWritingMod
e() ^ outer) ? 1 : 0)) / 2; | 999 return (border.width() + ((styleForCellFlow()->isFlippedBlocksWritingMod
e() ^ outer) ? 1 : 0)) / 2; |
| 1000 return 0; | 1000 return 0; |
| 1001 } | 1001 } |
| 1002 | 1002 |
| 1003 void RenderTableCell::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset
) | 1003 void RenderTableCell::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset
) |
| 1004 { | 1004 { |
| 1005 ASSERT(paintInfo.phase != PaintPhaseCollapsedTableBorders); | 1005 ASSERT(paintInfo.phase != PaintPhaseCollapsedTableBorders); |
| 1006 RenderBlock::paint(paintInfo, paintOffset); | 1006 RenderBlockFlow::paint(paintInfo, paintOffset); |
| 1007 } | 1007 } |
| 1008 | 1008 |
| 1009 static EBorderStyle collapsedBorderStyle(EBorderStyle style) | 1009 static EBorderStyle collapsedBorderStyle(EBorderStyle style) |
| 1010 { | 1010 { |
| 1011 if (style == OUTSET) | 1011 if (style == OUTSET) |
| 1012 return GROOVE; | 1012 return GROOVE; |
| 1013 if (style == INSET) | 1013 if (style == INSET) |
| 1014 return RIDGE; | 1014 return RIDGE; |
| 1015 return style; | 1015 return style; |
| 1016 } | 1016 } |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1275 | 1275 |
| 1276 RenderTableCell* RenderTableCell::createAnonymousWithParentRenderer(const Render
Object* parent) | 1276 RenderTableCell* RenderTableCell::createAnonymousWithParentRenderer(const Render
Object* parent) |
| 1277 { | 1277 { |
| 1278 RenderTableCell* newCell = RenderTableCell::createAnonymous(&parent->documen
t()); | 1278 RenderTableCell* newCell = RenderTableCell::createAnonymous(&parent->documen
t()); |
| 1279 RefPtr<RenderStyle> newStyle = RenderStyle::createAnonymousStyleWithDisplay(
parent->style(), TABLE_CELL); | 1279 RefPtr<RenderStyle> newStyle = RenderStyle::createAnonymousStyleWithDisplay(
parent->style(), TABLE_CELL); |
| 1280 newCell->setStyle(newStyle.release()); | 1280 newCell->setStyle(newStyle.release()); |
| 1281 return newCell; | 1281 return newCell; |
| 1282 } | 1282 } |
| 1283 | 1283 |
| 1284 } // namespace WebCore | 1284 } // namespace WebCore |
| OLD | NEW |