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, 2010 Apple Inc. All r
ights reserved. | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All r
ights reserved. |
8 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 8 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 beforeChild = lastChild(); | 109 beforeChild = lastChild(); |
110 | 110 |
111 bool wrapInAnonymousSection = !child->isPositioned(); | 111 bool wrapInAnonymousSection = !child->isPositioned(); |
112 | 112 |
113 if (child->isRenderBlock() && child->style()->display() == TABLE_CAPTION) { | 113 if (child->isRenderBlock() && child->style()->display() == TABLE_CAPTION) { |
114 // First caption wins. | 114 // First caption wins. |
115 if (beforeChild && m_caption) { | 115 if (beforeChild && m_caption) { |
116 RenderObject* o = beforeChild->previousSibling(); | 116 RenderObject* o = beforeChild->previousSibling(); |
117 while (o && o != m_caption) | 117 while (o && o != m_caption) |
118 o = o->previousSibling(); | 118 o = o->previousSibling(); |
119 if (!o) | 119 if (!o) { |
120 m_caption = 0; | 120 m_caption = 0; |
| 121 setNeedsSectionRecalc(); |
| 122 } |
121 } | 123 } |
122 if (!m_caption) | 124 if (!m_caption) |
123 m_caption = toRenderBlock(child); | 125 m_caption = toRenderBlock(child); |
| 126 else |
| 127 setNeedsSectionRecalc(); |
124 wrapInAnonymousSection = false; | 128 wrapInAnonymousSection = false; |
125 } else if (child->isTableCol()) { | 129 } else if (child->isTableCol()) { |
126 m_hasColElements = true; | 130 m_hasColElements = true; |
127 wrapInAnonymousSection = false; | 131 wrapInAnonymousSection = false; |
128 } else if (child->isTableSection()) { | 132 } else if (child->isTableSection()) { |
129 switch (child->style()->display()) { | 133 switch (child->style()->display()) { |
130 case TABLE_HEADER_GROUP: | 134 case TABLE_HEADER_GROUP: |
131 resetSectionPointerIfNotBefore(m_head, beforeChild); | 135 resetSectionPointerIfNotBefore(m_head, beforeChild); |
132 if (!m_head) { | 136 if (!m_head) { |
133 m_head = toRenderTableSection(child); | 137 m_head = toRenderTableSection(child); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 newStyle->inheritFrom(style()); | 195 newStyle->inheritFrom(style()); |
192 newStyle->setDisplay(TABLE_ROW_GROUP); | 196 newStyle->setDisplay(TABLE_ROW_GROUP); |
193 section->setStyle(newStyle.release()); | 197 section->setStyle(newStyle.release()); |
194 addChild(section, beforeChild); | 198 addChild(section, beforeChild); |
195 section->addChild(child); | 199 section->addChild(child); |
196 } | 200 } |
197 | 201 |
198 void RenderTable::removeChild(RenderObject* oldChild) | 202 void RenderTable::removeChild(RenderObject* oldChild) |
199 { | 203 { |
200 RenderBox::removeChild(oldChild); | 204 RenderBox::removeChild(oldChild); |
| 205 |
| 206 if (m_caption && oldChild == m_caption && node()) |
| 207 node()->setNeedsStyleRecalc(); |
201 setNeedsSectionRecalc(); | 208 setNeedsSectionRecalc(); |
202 } | 209 } |
203 | 210 |
204 void RenderTable::computeLogicalWidth() | 211 void RenderTable::computeLogicalWidth() |
205 { | 212 { |
206 if (isPositioned()) | 213 if (isPositioned()) |
207 computePositionedLogicalWidth(); | 214 computePositionedLogicalWidth(); |
208 | 215 |
209 RenderBlock* cb = containingBlock(); | 216 RenderBlock* cb = containingBlock(); |
210 | 217 |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 *endEdge = endCol == col; | 688 *endEdge = endCol == col; |
682 return colElem; | 689 return colElem; |
683 } | 690 } |
684 } | 691 } |
685 colElem = nextColElement(colElem); | 692 colElem = nextColElement(colElem); |
686 } | 693 } |
687 | 694 |
688 return 0; | 695 return 0; |
689 } | 696 } |
690 | 697 |
| 698 void RenderTable::recalcCaption(RenderBlock* caption) const |
| 699 { |
| 700 if (!m_caption) { |
| 701 m_caption = caption; |
| 702 m_caption->setNeedsLayout(true); |
| 703 } else { |
| 704 // Detach the child from the table. |
| 705 const RenderBlock* block = static_cast<const RenderBlock*>(this); |
| 706 const_cast<RenderBlock*>(block)->removeChild(caption); |
| 707 |
| 708 // Make sure to null out the child's renderer. |
| 709 if (Node* node = caption->node()) |
| 710 node->setRenderer(0); |
| 711 |
| 712 // Destroy the child now. |
| 713 caption->destroy(); |
| 714 } |
| 715 } |
| 716 |
691 void RenderTable::recalcSections() const | 717 void RenderTable::recalcSections() const |
692 { | 718 { |
693 m_caption = 0; | 719 m_caption = 0; |
694 m_head = 0; | 720 m_head = 0; |
695 m_foot = 0; | 721 m_foot = 0; |
696 m_firstBody = 0; | 722 m_firstBody = 0; |
697 m_hasColElements = false; | 723 m_hasColElements = false; |
698 | 724 |
699 // We need to get valid pointers to caption, head, foot and first body again | 725 // We need to get valid pointers to caption, head, foot and first body again |
700 for (RenderObject* child = firstChild(); child; child = child->nextSibling()
) { | 726 RenderObject* nextSibling; |
| 727 for (RenderObject* child = firstChild(); child; child = nextSibling) { |
| 728 nextSibling = child->nextSibling(); |
701 switch (child->style()->display()) { | 729 switch (child->style()->display()) { |
702 case TABLE_CAPTION: | 730 case TABLE_CAPTION: |
703 if (!m_caption && child->isRenderBlock()) { | 731 if (child->isRenderBlock()) |
704 m_caption = toRenderBlock(child); | 732 recalcCaption(toRenderBlock(child)); |
705 m_caption->setNeedsLayout(true); | |
706 } | |
707 break; | 733 break; |
708 case TABLE_COLUMN: | 734 case TABLE_COLUMN: |
709 case TABLE_COLUMN_GROUP: | 735 case TABLE_COLUMN_GROUP: |
710 m_hasColElements = true; | 736 m_hasColElements = true; |
711 break; | 737 break; |
712 case TABLE_HEADER_GROUP: | 738 case TABLE_HEADER_GROUP: |
713 if (child->isTableSection()) { | 739 if (child->isTableSection()) { |
714 RenderTableSection* section = toRenderTableSection(child); | 740 RenderTableSection* section = toRenderTableSection(child); |
715 if (!m_head) | 741 if (!m_head) |
716 m_head = section; | 742 m_head = section; |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1195 if (visibleToHitTesting() && (action == HitTestBlockBackground || action ==
HitTestChildBlockBackground) && boundsRect.intersects(result.rectForPoint(xPos,
yPos))) { | 1221 if (visibleToHitTesting() && (action == HitTestBlockBackground || action ==
HitTestChildBlockBackground) && boundsRect.intersects(result.rectForPoint(xPos,
yPos))) { |
1196 updateHitTestResult(result, flipForWritingMode(IntPoint(xPos - tx, yPos
- ty))); | 1222 updateHitTestResult(result, flipForWritingMode(IntPoint(xPos - tx, yPos
- ty))); |
1197 if (!result.addNodeToRectBasedTestResult(node(), xPos, yPos, boundsRect)
) | 1223 if (!result.addNodeToRectBasedTestResult(node(), xPos, yPos, boundsRect)
) |
1198 return true; | 1224 return true; |
1199 } | 1225 } |
1200 | 1226 |
1201 return false; | 1227 return false; |
1202 } | 1228 } |
1203 | 1229 |
1204 } | 1230 } |
OLD | NEW |