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) 2007 David Smith (catfish.man@gmail.com) | 4 * (C) 2007 David Smith (catfish.man@gmail.com) |
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All r
ights reserved. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All r
ights reserved. |
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 o->setStyle(style()); | 393 o->setStyle(style()); |
394 o->setChildrenInline(childrenInline()); | 394 o->setChildrenInline(childrenInline()); |
395 return o; | 395 return o; |
396 } | 396 } |
397 | 397 |
398 void RenderBlock::splitBlocks(RenderBlock* fromBlock, RenderBlock* toBlock, | 398 void RenderBlock::splitBlocks(RenderBlock* fromBlock, RenderBlock* toBlock, |
399 RenderBlock* middleBlock, | 399 RenderBlock* middleBlock, |
400 RenderObject* beforeChild, RenderBoxModelObject* o
ldCont) | 400 RenderObject* beforeChild, RenderBoxModelObject* o
ldCont) |
401 { | 401 { |
402 // Create a clone of this inline. | 402 // Create a clone of this inline. |
403 RenderBlock* cloneBlock = clone(); | 403 RenderBlock* cloneBlock; |
404 cloneBlock->setContinuation(oldCont); | 404 if (isAnonymousBlock()) |
| 405 cloneBlock = createAnonymousBlock(); |
| 406 else { |
| 407 cloneBlock = clone(); |
| 408 cloneBlock->setContinuation(oldCont); |
| 409 } |
405 | 410 |
406 // Now take all of the children from beforeChild to the end and remove | 411 // Now take all of the children from beforeChild to the end and remove |
407 // them from |this| and place them in the clone. | 412 // them from |this| and place them in the clone. |
408 if (!beforeChild && isAfterContent(lastChild())) | 413 if (!beforeChild && isAfterContent(lastChild())) |
409 beforeChild = lastChild(); | 414 beforeChild = lastChild(); |
410 moveChildrenTo(cloneBlock, beforeChild, 0); | 415 moveChildrenTo(cloneBlock, beforeChild, 0); |
411 | 416 |
412 // Hook |clone| up as the continuation of the middle block. | 417 // Hook |clone| up as the continuation of the middle block. |
413 middleBlock->setContinuation(cloneBlock); | 418 if (!cloneBlock->isAnonymousBlock()) |
| 419 middleBlock->setContinuation(cloneBlock); |
414 | 420 |
415 // We have been reparented and are now under the fromBlock. We need | 421 // We have been reparented and are now under the fromBlock. We need |
416 // to walk up our block parent chain until we hit the containing anonymous c
olumns block. | 422 // to walk up our block parent chain until we hit the containing anonymous c
olumns block. |
417 // Once we hit the anonymous columns block we're done. | 423 // Once we hit the anonymous columns block we're done. |
418 RenderBoxModelObject* curr = toRenderBoxModelObject(parent()); | 424 RenderBoxModelObject* curr = toRenderBoxModelObject(parent()); |
419 RenderBoxModelObject* currChild = this; | 425 RenderBoxModelObject* currChild = this; |
420 | 426 |
421 while (curr && curr != fromBlock) { | 427 while (curr && curr != fromBlock) { |
422 ASSERT(curr->isRenderBlock() && !curr->isAnonymousBlock()); | 428 ASSERT(curr->isRenderBlock()); |
423 | 429 |
424 RenderBlock* blockCurr = toRenderBlock(curr); | 430 RenderBlock* blockCurr = toRenderBlock(curr); |
425 | 431 |
426 // Create a new clone. | 432 // Create a new clone. |
427 RenderBlock* cloneChild = cloneBlock; | 433 RenderBlock* cloneChild = cloneBlock; |
428 cloneBlock = blockCurr->clone(); | 434 cloneBlock = blockCurr->isAnonymousBlock() ? blockCurr->createAnonymousB
lock() : blockCurr->clone(); |
429 | 435 |
430 // Insert our child clone as the first child. | 436 // Insert our child clone as the first child. |
431 cloneBlock->children()->appendChildNode(cloneBlock, cloneChild); | 437 cloneBlock->children()->appendChildNode(cloneBlock, cloneChild); |
432 | 438 |
433 // Hook the clone up as a continuation of |curr|. Note we do encounter | 439 // Hook the clone up as a continuation of |curr|. Note we do encounter |
434 // anonymous blocks possibly as we walk up the block chain. When we spl
it an | 440 // anonymous blocks possibly as we walk up the block chain. When we spl
it an |
435 // anonymous block, there's no need to do any continuation hookup, since
we haven't | 441 // anonymous block, there's no need to do any continuation hookup, since
we haven't |
436 // actually split a real element. | 442 // actually split a real element. |
437 if (!blockCurr->isAnonymousBlock()) { | 443 if (!blockCurr->isAnonymousBlock()) { |
438 oldCont = blockCurr->continuation(); | 444 oldCont = blockCurr->continuation(); |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 { | 622 { |
617 // Make sure we don't append things after :after-generated content if we hav
e it. | 623 // Make sure we don't append things after :after-generated content if we hav
e it. |
618 if (!beforeChild) { | 624 if (!beforeChild) { |
619 RenderObject* lastRenderer = lastChild(); | 625 RenderObject* lastRenderer = lastChild(); |
620 if (isAfterContent(lastRenderer)) | 626 if (isAfterContent(lastRenderer)) |
621 beforeChild = lastRenderer; | 627 beforeChild = lastRenderer; |
622 else if (lastRenderer && lastRenderer->isAnonymousBlock() && isAfterCont
ent(lastRenderer->lastChild())) | 628 else if (lastRenderer && lastRenderer->isAnonymousBlock() && isAfterCont
ent(lastRenderer->lastChild())) |
623 beforeChild = lastRenderer->lastChild(); | 629 beforeChild = lastRenderer->lastChild(); |
624 } | 630 } |
625 | 631 |
| 632 // If the requested beforeChild is not one of our children, then this is bec
ause |
| 633 // there is an anonymous container within this object that contains the befo
reChild. |
| 634 if (beforeChild && beforeChild->parent() != this) { |
| 635 RenderObject* anonymousChild = beforeChild->parent(); |
| 636 ASSERT(anonymousChild); |
| 637 |
| 638 while (anonymousChild->parent() != this) |
| 639 anonymousChild = anonymousChild->parent(); |
| 640 |
| 641 ASSERT(anonymousChild->isAnonymous()); |
| 642 |
| 643 if (anonymousChild->isAnonymousBlock()) { |
| 644 // Insert the child into the anonymous block box instead of here. |
| 645 if (newChild->isInline() || beforeChild->parent()->firstChild() != b
eforeChild) |
| 646 beforeChild->parent()->addChild(newChild, beforeChild); |
| 647 else |
| 648 addChild(newChild, beforeChild->parent()); |
| 649 return; |
| 650 } |
| 651 |
| 652 ASSERT(anonymousChild->isTable()); |
| 653 if ((newChild->isTableCol() && newChild->style()->display() == TABLE_COL
UMN_GROUP) |
| 654 || (newChild->isRenderBlock() && newChild->style()->display() ==
TABLE_CAPTION) |
| 655 || newChild->isTableSection() |
| 656 || newChild->isTableRow() |
| 657 || newChild->isTableCell()) { |
| 658 // Insert into the anonymous table. |
| 659 anonymousChild->addChild(newChild, beforeChild); |
| 660 return; |
| 661 } |
| 662 |
| 663 // Go on to insert before the anonymous table. |
| 664 beforeChild = anonymousChild; |
| 665 } |
| 666 |
626 // Check for a spanning element in columns. | 667 // Check for a spanning element in columns. |
627 RenderBlock* columnsBlockAncestor = columnsBlockForSpanningElement(newChild)
; | 668 RenderBlock* columnsBlockAncestor = columnsBlockForSpanningElement(newChild)
; |
628 if (columnsBlockAncestor) { | 669 if (columnsBlockAncestor) { |
629 // We are placing a column-span element inside a block. | 670 // We are placing a column-span element inside a block. |
630 RenderBlock* newBox = createAnonymousColumnSpanBlock(); | 671 RenderBlock* newBox = createAnonymousColumnSpanBlock(); |
631 | 672 |
632 if (columnsBlockAncestor != this) { | 673 if (columnsBlockAncestor != this) { |
633 // We are nested inside a multi-column element and are being split b
y the span. We have to break up | 674 // We are nested inside a multi-column element and are being split b
y the span. We have to break up |
634 // our block into continuations. | 675 // our block into continuations. |
635 RenderBoxModelObject* oldContinuation = continuation(); | 676 RenderBoxModelObject* oldContinuation = continuation(); |
(...skipping 15 matching lines...) Expand all Loading... |
651 | 692 |
652 // We have to perform a split of this block's children. This involves c
reating an anonymous block box to hold | 693 // We have to perform a split of this block's children. This involves c
reating an anonymous block box to hold |
653 // the column-spanning |newChild|. We take all of the children from bef
ore |newChild| and put them into | 694 // the column-spanning |newChild|. We take all of the children from bef
ore |newChild| and put them into |
654 // one anonymous columns block, and all of the children after |newChild|
go into another anonymous block. | 695 // one anonymous columns block, and all of the children after |newChild|
go into another anonymous block. |
655 makeChildrenAnonymousColumnBlocks(beforeChild, newBox, newChild); | 696 makeChildrenAnonymousColumnBlocks(beforeChild, newBox, newChild); |
656 return; | 697 return; |
657 } | 698 } |
658 | 699 |
659 bool madeBoxesNonInline = false; | 700 bool madeBoxesNonInline = false; |
660 | 701 |
661 // If the requested beforeChild is not one of our children, then this is bec
ause | |
662 // there is an anonymous container within this object that contains the befo
reChild. | |
663 if (beforeChild && beforeChild->parent() != this) { | |
664 RenderObject* anonymousChild = beforeChild->parent(); | |
665 ASSERT(anonymousChild); | |
666 | |
667 while (anonymousChild->parent() != this) | |
668 anonymousChild = anonymousChild->parent(); | |
669 | |
670 ASSERT(anonymousChild->isAnonymous()); | |
671 | |
672 if (anonymousChild->isAnonymousBlock()) { | |
673 // Insert the child into the anonymous block box instead of here. | |
674 if (newChild->isInline() || beforeChild->parent()->firstChild() != b
eforeChild) | |
675 beforeChild->parent()->addChild(newChild, beforeChild); | |
676 else | |
677 addChild(newChild, beforeChild->parent()); | |
678 return; | |
679 } | |
680 | |
681 ASSERT(anonymousChild->isTable()); | |
682 if ((newChild->isTableCol() && newChild->style()->display() == TABLE_COL
UMN_GROUP) | |
683 || (newChild->isRenderBlock() && newChild->style()->display() ==
TABLE_CAPTION) | |
684 || newChild->isTableSection() | |
685 || newChild->isTableRow() | |
686 || newChild->isTableCell()) { | |
687 // Insert into the anonymous table. | |
688 anonymousChild->addChild(newChild, beforeChild); | |
689 return; | |
690 } | |
691 | |
692 // Go on to insert before the anonymous table. | |
693 beforeChild = anonymousChild; | |
694 } | |
695 | |
696 // A block has to either have all of its children inline, or all of its chil
dren as blocks. | 702 // A block has to either have all of its children inline, or all of its chil
dren as blocks. |
697 // So, if our children are currently inline and a block child has to be inse
rted, we move all our | 703 // So, if our children are currently inline and a block child has to be inse
rted, we move all our |
698 // inline children into anonymous block boxes. | 704 // inline children into anonymous block boxes. |
699 if (childrenInline() && !newChild->isInline() && !newChild->isFloatingOrPosi
tioned()) { | 705 if (childrenInline() && !newChild->isInline() && !newChild->isFloatingOrPosi
tioned()) { |
700 // This is a block with inline content. Wrap the inline content in anony
mous blocks. | 706 // This is a block with inline content. Wrap the inline content in anony
mous blocks. |
701 makeChildrenNonInline(beforeChild); | 707 makeChildrenNonInline(beforeChild); |
702 madeBoxesNonInline = true; | 708 madeBoxesNonInline = true; |
703 | 709 |
704 if (beforeChild && beforeChild->parent() != this) { | 710 if (beforeChild && beforeChild->parent() != this) { |
705 beforeChild = beforeChild->parent(); | 711 beforeChild = beforeChild->parent(); |
(...skipping 5683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6389 else if (isAnonymous()) | 6395 else if (isAnonymous()) |
6390 return "RenderBlock (generated)"; | 6396 return "RenderBlock (generated)"; |
6391 if (isRelPositioned()) | 6397 if (isRelPositioned()) |
6392 return "RenderBlock (relative positioned)"; | 6398 return "RenderBlock (relative positioned)"; |
6393 if (isRunIn()) | 6399 if (isRunIn()) |
6394 return "RenderBlock (run-in)"; | 6400 return "RenderBlock (run-in)"; |
6395 return "RenderBlock"; | 6401 return "RenderBlock"; |
6396 } | 6402 } |
6397 | 6403 |
6398 } // namespace WebCore | 6404 } // namespace WebCore |
OLD | NEW |