| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 2 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
| 3 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. | 3 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 node->resetThisAndDescendantsRenderers(); | 231 node->resetThisAndDescendantsRenderers(); |
| 232 } | 232 } |
| 233 } | 233 } |
| 234 | 234 |
| 235 void CounterNode::insertAfter(CounterNode* newChild, CounterNode* refChild, cons
t AtomicString& identifier) | 235 void CounterNode::insertAfter(CounterNode* newChild, CounterNode* refChild, cons
t AtomicString& identifier) |
| 236 { | 236 { |
| 237 ASSERT(newChild); | 237 ASSERT(newChild); |
| 238 ASSERT(!newChild->m_parent); | 238 ASSERT(!newChild->m_parent); |
| 239 ASSERT(!newChild->m_previousSibling); | 239 ASSERT(!newChild->m_previousSibling); |
| 240 ASSERT(!newChild->m_nextSibling); | 240 ASSERT(!newChild->m_nextSibling); |
| 241 ASSERT(!refChild || refChild->m_parent == this); | 241 // If the refChild is not our child we can not complete the request. This ha
rdens against bugs in RenderCounter. |
| 242 // When renderers are reparented it may request that we insert counter nodes
improperly. |
| 243 if (refChild && refChild->m_parent != this) |
| 244 return; |
| 242 | 245 |
| 243 if (newChild->m_hasResetType) { | 246 if (newChild->m_hasResetType) { |
| 244 while (m_lastChild != refChild) | 247 while (m_lastChild != refChild) |
| 245 RenderCounter::destroyCounterNode(m_lastChild->owner(), identifier); | 248 RenderCounter::destroyCounterNode(m_lastChild->owner(), identifier); |
| 246 } | 249 } |
| 247 | 250 |
| 248 CounterNode* next; | 251 CounterNode* next; |
| 249 | 252 |
| 250 if (refChild) { | 253 if (refChild) { |
| 251 next = refChild->m_nextSibling; | 254 next = refChild->m_nextSibling; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 267 ASSERT(m_lastChild == refChild); | 270 ASSERT(m_lastChild == refChild); |
| 268 m_lastChild = newChild; | 271 m_lastChild = newChild; |
| 269 } | 272 } |
| 270 | 273 |
| 271 newChild->m_countInParent = newChild->computeCountInParent(); | 274 newChild->m_countInParent = newChild->computeCountInParent(); |
| 272 newChild->resetThisAndDescendantsRenderers(); | 275 newChild->resetThisAndDescendantsRenderers(); |
| 273 if (next) | 276 if (next) |
| 274 next->recount(); | 277 next->recount(); |
| 275 return; | 278 return; |
| 276 } | 279 } |
| 280 // If the new child is the last in the sibling list we must set the parent's
lastChild. |
| 281 if (!newChild->m_nextSibling) |
| 282 m_lastChild = newChild; |
| 277 | 283 |
| 278 // The code below handles the case when a formerly root increment counter is
loosing its root position | 284 // The code below handles the case when a formerly root increment counter is
loosing its root position |
| 279 // and therefore its children become next siblings. | 285 // and therefore its children become next siblings. |
| 280 CounterNode* last = newChild->m_lastChild; | 286 CounterNode* last = newChild->m_lastChild; |
| 281 CounterNode* first = newChild->m_firstChild; | 287 CounterNode* first = newChild->m_firstChild; |
| 282 | 288 |
| 283 newChild->m_nextSibling = first; | 289 if (first) { |
| 284 first->m_previousSibling = newChild; | 290 ASSERT(last); |
| 285 // The case when the original next sibling of the inserted node becomes a ch
ild of | 291 newChild->m_nextSibling = first; |
| 286 // one of the former children of the inserted node is not handled as it is b
elieved | 292 if (m_lastChild == newChild) |
| 287 // to be impossible since: | 293 m_lastChild = last; |
| 288 // 1. if the increment counter node lost it's root position as a result of a
nother | 294 |
| 289 // counter node being created, it will be inserted as the last child so n
ext is null. | 295 first->m_previousSibling = newChild; |
| 290 // 2. if the increment counter node lost it's root position as a result of a
renderer being | 296 |
| 291 // inserted into the document's render tree, all its former children coun
ters are attached | 297 // The case when the original next sibling of the inserted node becomes
a child of |
| 292 // to children of the inserted renderer and hence cannot be in scope for
counter nodes | 298 // one of the former children of the inserted node is not handled as it
is believed |
| 293 // attached to renderers that were already in the document's render tree. | 299 // to be impossible since: |
| 294 last->m_nextSibling = next; | 300 // 1. if the increment counter node lost it's root position as a result
of another |
| 295 if (next) | 301 // counter node being created, it will be inserted as the last child
so next is null. |
| 296 next->m_previousSibling = last; | 302 // 2. if the increment counter node lost it's root position as a result
of a renderer being |
| 297 else | 303 // inserted into the document's render tree, all its former children
counters are attached |
| 298 m_lastChild = last; | 304 // to children of the inserted renderer and hence cannot be in scope
for counter nodes |
| 299 for (next = first; ; next = next->m_nextSibling) { | 305 // attached to renderers that were already in the document's render t
ree. |
| 300 next->m_parent = this; | 306 last->m_nextSibling = next; |
| 301 if (last == next) | 307 if (next) { |
| 302 break; | 308 ASSERT(next->m_previousSibling == newChild); |
| 309 next->m_previousSibling = last; |
| 310 } else |
| 311 m_lastChild = last; |
| 312 for (next = first; ; next = next->m_nextSibling) { |
| 313 next->m_parent = this; |
| 314 if (last == next) |
| 315 break; |
| 316 } |
| 303 } | 317 } |
| 304 newChild->m_firstChild = 0; | 318 newChild->m_firstChild = 0; |
| 305 newChild->m_lastChild = 0; | 319 newChild->m_lastChild = 0; |
| 306 newChild->m_countInParent = newChild->computeCountInParent(); | 320 newChild->m_countInParent = newChild->computeCountInParent(); |
| 307 newChild->resetRenderers(); | 321 newChild->resetRenderers(); |
| 308 first->recount(); | 322 first->recount(); |
| 309 } | 323 } |
| 310 | 324 |
| 311 void CounterNode::removeChild(CounterNode* oldChild) | 325 void CounterNode::removeChild(CounterNode* oldChild) |
| 312 { | 326 { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 | 379 |
| 366 #ifndef NDEBUG | 380 #ifndef NDEBUG |
| 367 | 381 |
| 368 void showCounterTree(const WebCore::CounterNode* counter) | 382 void showCounterTree(const WebCore::CounterNode* counter) |
| 369 { | 383 { |
| 370 if (counter) | 384 if (counter) |
| 371 showTreeAndMark(counter); | 385 showTreeAndMark(counter); |
| 372 } | 386 } |
| 373 | 387 |
| 374 #endif | 388 #endif |
| OLD | NEW |