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 { | 109 { |
110 if (!before || !ptr) | 110 if (!before || !ptr) |
111 return; | 111 return; |
112 RenderObject* o = before->previousSibling(); | 112 RenderObject* o = before->previousSibling(); |
113 while (o && o != ptr) | 113 while (o && o != ptr) |
114 o = o->previousSibling(); | 114 o = o->previousSibling(); |
115 if (!o) | 115 if (!o) |
116 ptr = 0; | 116 ptr = 0; |
117 } | 117 } |
118 | 118 |
| 119 static inline bool needsTableSection(RenderObject* object) |
| 120 { |
| 121 // Return true if 'object' can't exist in an anonymous table without being |
| 122 // wrapped in a table section box. |
| 123 EDisplay display = object->style()->display(); |
| 124 return display != TABLE_CAPTION && display != TABLE_COLUMN_GROUP && display
!= TABLE_COLUMN; |
| 125 } |
| 126 |
119 void RenderTable::addChild(RenderObject* child, RenderObject* beforeChild) | 127 void RenderTable::addChild(RenderObject* child, RenderObject* beforeChild) |
120 { | 128 { |
121 bool wrapInAnonymousSection = !child->isOutOfFlowPositioned(); | 129 bool wrapInAnonymousSection = !child->isOutOfFlowPositioned(); |
122 | 130 |
123 if (child->isTableCaption()) | 131 if (child->isTableCaption()) |
124 wrapInAnonymousSection = false; | 132 wrapInAnonymousSection = false; |
125 else if (child->isRenderTableCol()) { | 133 else if (child->isRenderTableCol()) { |
126 m_hasColElements = true; | 134 m_hasColElements = true; |
127 wrapInAnonymousSection = false; | 135 wrapInAnonymousSection = false; |
128 } else if (child->isTableSection()) { | 136 } else if (child->isTableSection()) { |
(...skipping 19 matching lines...) Expand all Loading... |
148 // Fall through. | 156 // Fall through. |
149 case TABLE_ROW_GROUP: | 157 case TABLE_ROW_GROUP: |
150 resetSectionPointerIfNotBefore(m_firstBody, beforeChild); | 158 resetSectionPointerIfNotBefore(m_firstBody, beforeChild); |
151 if (!m_firstBody) | 159 if (!m_firstBody) |
152 m_firstBody = toRenderTableSection(child); | 160 m_firstBody = toRenderTableSection(child); |
153 wrapInAnonymousSection = false; | 161 wrapInAnonymousSection = false; |
154 break; | 162 break; |
155 default: | 163 default: |
156 ASSERT_NOT_REACHED(); | 164 ASSERT_NOT_REACHED(); |
157 } | 165 } |
158 } else if (child->isTableCell() || child->isTableRow()) | 166 } else |
159 wrapInAnonymousSection = true; | |
160 else | |
161 wrapInAnonymousSection = true; | 167 wrapInAnonymousSection = true; |
162 | 168 |
163 if (child->isTableSection()) | 169 if (child->isTableSection()) |
164 setNeedsSectionRecalc(); | 170 setNeedsSectionRecalc(); |
165 | 171 |
166 if (!wrapInAnonymousSection) { | 172 if (!wrapInAnonymousSection) { |
167 if (beforeChild && beforeChild->parent() != this) | 173 if (beforeChild && beforeChild->parent() != this) |
168 beforeChild = splitAnonymousBoxesAroundChild(beforeChild); | 174 beforeChild = splitAnonymousBoxesAroundChild(beforeChild); |
169 | 175 |
170 RenderBox::addChild(child, beforeChild); | 176 RenderBox::addChild(child, beforeChild); |
171 return; | 177 return; |
172 } | 178 } |
173 | 179 |
174 if (!beforeChild && lastChild() && lastChild()->isTableSection() && lastChil
d()->isAnonymous() && !lastChild()->isBeforeContent()) { | 180 if (!beforeChild && lastChild() && lastChild()->isTableSection() && lastChil
d()->isAnonymous() && !lastChild()->isBeforeContent()) { |
175 lastChild()->addChild(child); | 181 lastChild()->addChild(child); |
176 return; | 182 return; |
177 } | 183 } |
178 | 184 |
179 if (beforeChild && !beforeChild->isAnonymous() && beforeChild->parent() == t
his) { | 185 if (beforeChild && !beforeChild->isAnonymous() && beforeChild->parent() == t
his) { |
180 RenderObject* section = beforeChild->previousSibling(); | 186 RenderObject* section = beforeChild->previousSibling(); |
181 if (section && section->isTableSection() && section->isAnonymous()) { | 187 if (section && section->isTableSection() && section->isAnonymous()) { |
182 section->addChild(child); | 188 section->addChild(child); |
183 return; | 189 return; |
184 } | 190 } |
185 } | 191 } |
186 | 192 |
187 RenderObject* lastBox = beforeChild; | 193 RenderObject* lastBox = beforeChild; |
188 while (lastBox && lastBox->parent()->isAnonymous() && !lastBox->isTableSecti
on() && lastBox->style()->display() != TABLE_CAPTION && lastBox->style()->displa
y() != TABLE_COLUMN_GROUP) | 194 while (lastBox && lastBox->parent()->isAnonymous() && !lastBox->isTableSecti
on() && needsTableSection(lastBox)) |
189 lastBox = lastBox->parent(); | 195 lastBox = lastBox->parent(); |
190 if (lastBox && lastBox->isAnonymous() && !isAfterContent(lastBox)) { | 196 if (lastBox && lastBox->isAnonymous() && !isAfterContent(lastBox)) { |
191 if (beforeChild == lastBox) | 197 if (beforeChild == lastBox) |
192 beforeChild = lastBox->firstChild(); | 198 beforeChild = lastBox->firstChild(); |
193 lastBox->addChild(child, beforeChild); | 199 lastBox->addChild(child, beforeChild); |
194 return; | 200 return; |
195 } | 201 } |
196 | 202 |
197 if (beforeChild && !beforeChild->isTableSection() && beforeChild->style()->d
isplay() != TABLE_CAPTION && beforeChild->style()->display() != TABLE_COLUMN_GRO
UP) | 203 if (beforeChild && !beforeChild->isTableSection() && needsTableSection(befor
eChild)) |
198 beforeChild = 0; | 204 beforeChild = 0; |
199 | 205 |
200 RenderTableSection* section = RenderTableSection::createAnonymousWithParentR
enderer(this); | 206 RenderTableSection* section = RenderTableSection::createAnonymousWithParentR
enderer(this); |
201 addChild(section, beforeChild); | 207 addChild(section, beforeChild); |
202 section->addChild(child); | 208 section->addChild(child); |
203 } | 209 } |
204 | 210 |
205 void RenderTable::addCaption(const RenderTableCaption* caption) | 211 void RenderTable::addCaption(const RenderTableCaption* caption) |
206 { | 212 { |
207 ASSERT(m_captions.find(caption) == kNotFound); | 213 ASSERT(m_captions.find(caption) == kNotFound); |
(...skipping 1228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1436 const BorderValue& RenderTable::tableEndBorderAdjoiningCell(const RenderTableCel
l* cell) const | 1442 const BorderValue& RenderTable::tableEndBorderAdjoiningCell(const RenderTableCel
l* cell) const |
1437 { | 1443 { |
1438 ASSERT(cell->isFirstOrLastCellInRow()); | 1444 ASSERT(cell->isFirstOrLastCellInRow()); |
1439 if (hasSameDirectionAs(cell->row())) | 1445 if (hasSameDirectionAs(cell->row())) |
1440 return style()->borderEnd(); | 1446 return style()->borderEnd(); |
1441 | 1447 |
1442 return style()->borderStart(); | 1448 return style()->borderStart(); |
1443 } | 1449 } |
1444 | 1450 |
1445 } | 1451 } |
OLD | NEW |