| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
| 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) | 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv
ed. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv
ed. |
| 7 * Copyright (C) 2009 Google Inc. All rights reserved. | 7 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 void RenderObject::removeChild(RenderObject* oldChild) | 352 void RenderObject::removeChild(RenderObject* oldChild) |
| 353 { | 353 { |
| 354 RenderObjectChildList* children = virtualChildren(); | 354 RenderObjectChildList* children = virtualChildren(); |
| 355 ASSERT(children); | 355 ASSERT(children); |
| 356 if (!children) | 356 if (!children) |
| 357 return; | 357 return; |
| 358 | 358 |
| 359 children->removeChildNode(this, oldChild); | 359 children->removeChildNode(this, oldChild); |
| 360 } | 360 } |
| 361 | 361 |
| 362 // This is a non-recursive algorithm for visiting the tree in both pre and post |
| 363 // order as well as skipping children when necessary and staying within a given |
| 364 // root. Further, the algorithm takes into account nodes that still use recursi
ve |
| 365 // traversal and provides a clean way to switch between the two modes of travers
al. |
| 366 // This will allow us to incrementally change each class to non-recursive traver
sal |
| 367 // instead of having to change everything at once. I developed this algorithm |
| 368 // using a toy model of a tree like structure with methods similar to the render |
| 369 // tree and its layout methods. |
| 370 // |
| 371 // NOTE: Once we switch everything over to non-recursive this algorithm can be m
ade |
| 372 // much simpler :) |
| 373 RenderObject* RenderObject::nextForLayout(Order& order, const RenderObject* stay
Within, bool skippingChildren) const |
| 374 { |
| 375 RenderObject* node = const_cast<RenderObject*>(this); |
| 376 if (node == stayWithin && order == Post) |
| 377 return 0; |
| 378 |
| 379 if (!node->isNonRecursiveLayout()) { |
| 380 if (node->parent() && node->parent()->isNonRecursiveLayout()) { |
| 381 if (node->nextSibling()) { |
| 382 order = Pre; |
| 383 return node->nextSibling(); |
| 384 } |
| 385 order = Post; |
| 386 return node->parent(); |
| 387 } |
| 388 return 0; |
| 389 } |
| 390 |
| 391 if (order == Pre) { |
| 392 if (node->firstChild() && !skippingChildren) |
| 393 return node->firstChild(); |
| 394 order = Post; |
| 395 return node; |
| 396 } |
| 397 |
| 398 if (node->nextSibling()) { |
| 399 order = Pre; |
| 400 return node->nextSibling(); |
| 401 } |
| 402 |
| 403 for (RenderObject* parent = node->parent(); parent; parent = parent->parent(
)) { |
| 404 if (order == Post) { |
| 405 if (parent->isNonRecursiveLayout()) |
| 406 return parent; |
| 407 return 0; |
| 408 } |
| 409 |
| 410 if (parent->nextSibling()) |
| 411 return parent->nextSibling(); |
| 412 } |
| 413 return 0; |
| 414 } |
| 415 |
| 362 RenderObject* RenderObject::nextInPreOrder() const | 416 RenderObject* RenderObject::nextInPreOrder() const |
| 363 { | 417 { |
| 364 if (RenderObject* o = firstChild()) | 418 if (RenderObject* o = firstChild()) |
| 365 return o; | 419 return o; |
| 366 | 420 |
| 367 return nextInPreOrderAfterChildren(); | 421 return nextInPreOrderAfterChildren(); |
| 368 } | 422 } |
| 369 | 423 |
| 370 RenderObject* RenderObject::nextInPreOrderAfterChildren() const | 424 RenderObject* RenderObject::nextInPreOrderAfterChildren() const |
| 371 { | 425 { |
| (...skipping 3009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3381 { | 3435 { |
| 3382 if (object1) { | 3436 if (object1) { |
| 3383 const WebCore::RenderObject* root = object1; | 3437 const WebCore::RenderObject* root = object1; |
| 3384 while (root->parent()) | 3438 while (root->parent()) |
| 3385 root = root->parent(); | 3439 root = root->parent(); |
| 3386 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); | 3440 root->showRenderTreeAndMark(object1, "*", object2, "-", 0); |
| 3387 } | 3441 } |
| 3388 } | 3442 } |
| 3389 | 3443 |
| 3390 #endif | 3444 #endif |
| OLD | NEW |