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, 2011 Apple Inc.
All rights reserved. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights 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 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 // Always just do a full layout in order to ensure that line boxes (especial
ly wrappers for images) | 592 // Always just do a full layout in order to ensure that line boxes (especial
ly wrappers for images) |
593 // get deleted properly. Because objects moves from the pre block into the
post block, we want to | 593 // get deleted properly. Because objects moves from the pre block into the
post block, we want to |
594 // make new line boxes instead of leaving the old line boxes around. | 594 // make new line boxes instead of leaving the old line boxes around. |
595 pre->setNeedsLayoutAndPrefWidthsRecalc(); | 595 pre->setNeedsLayoutAndPrefWidthsRecalc(); |
596 block->setNeedsLayoutAndPrefWidthsRecalc(); | 596 block->setNeedsLayoutAndPrefWidthsRecalc(); |
597 post->setNeedsLayoutAndPrefWidthsRecalc(); | 597 post->setNeedsLayoutAndPrefWidthsRecalc(); |
598 } | 598 } |
599 | 599 |
600 RenderObject* RenderBlock::splitAnonymousBlocksAroundChild(RenderObject* beforeC
hild) | 600 RenderObject* RenderBlock::splitAnonymousBlocksAroundChild(RenderObject* beforeC
hild) |
601 { | 601 { |
| 602 if (beforeChild->isTablePart()) |
| 603 beforeChild = splitTablePartsAroundChild(beforeChild); |
| 604 |
602 while (beforeChild->parent() != this) { | 605 while (beforeChild->parent() != this) { |
603 RenderBlock* blockToSplit = toRenderBlock(beforeChild->parent()); | 606 RenderBlock* blockToSplit = toRenderBlock(beforeChild->parent()); |
604 if (blockToSplit->firstChild() != beforeChild) { | 607 if (blockToSplit->firstChild() != beforeChild) { |
605 // We have to split the parentBlock into two blocks. | 608 // We have to split the parentBlock into two blocks. |
606 RenderBlock* post = createAnonymousBlockWithSameTypeAs(blockToSplit)
; | 609 RenderBlock* post = createAnonymousBlockWithSameTypeAs(blockToSplit)
; |
607 post->setChildrenInline(blockToSplit->childrenInline()); | 610 post->setChildrenInline(blockToSplit->childrenInline()); |
608 RenderBlock* parentBlock = toRenderBlock(blockToSplit->parent()); | 611 RenderBlock* parentBlock = toRenderBlock(blockToSplit->parent()); |
609 parentBlock->children()->insertChildNode(parentBlock, post, blockToS
plit->nextSibling()); | 612 parentBlock->children()->insertChildNode(parentBlock, post, blockToS
plit->nextSibling()); |
610 blockToSplit->moveChildrenTo(post, beforeChild, 0, blockToSplit->has
Layer()); | 613 blockToSplit->moveChildrenTo(post, beforeChild, 0, blockToSplit->has
Layer()); |
611 post->setNeedsLayoutAndPrefWidthsRecalc(); | 614 post->setNeedsLayoutAndPrefWidthsRecalc(); |
612 blockToSplit->setNeedsLayoutAndPrefWidthsRecalc(); | 615 blockToSplit->setNeedsLayoutAndPrefWidthsRecalc(); |
613 beforeChild = post; | 616 beforeChild = post; |
614 } else | 617 } else |
615 beforeChild = blockToSplit; | 618 beforeChild = blockToSplit; |
616 } | 619 } |
617 return beforeChild; | 620 return beforeChild; |
618 } | 621 } |
619 | 622 |
| 623 static void markTableForSectionAndCellRecalculation(RenderObject* child) |
| 624 { |
| 625 RenderObject* curr = child; |
| 626 while (!curr->isTable()) { |
| 627 if (curr->isTableSection()) |
| 628 toRenderTableSection(curr)->setNeedsCellRecalc(); |
| 629 curr = curr->parent(); |
| 630 } |
| 631 |
| 632 RenderTable* table = toRenderTable(curr); |
| 633 table->setNeedsSectionRecalc(); |
| 634 table->setNeedsLayoutAndPrefWidthsRecalc(); |
| 635 } |
| 636 |
| 637 static void moveAllTableChildrenTo(RenderObject* fromTablePart, RenderTable* toT
able, RenderObject* startChild) |
| 638 { |
| 639 for (RenderObject* curr = startChild; curr;) { |
| 640 // Need to store next sibling as we won't have access to it |
| 641 // after we are removed from table. |
| 642 RenderObject* next = curr->nextSibling(); |
| 643 fromTablePart->removeChild(curr); |
| 644 toTable->addChild(curr); |
| 645 if (curr->isTableSection()) |
| 646 toRenderTableSection(curr)->setNeedsCellRecalc(); |
| 647 curr->setNeedsLayoutAndPrefWidthsRecalc(); |
| 648 curr = next; |
| 649 } |
| 650 |
| 651 // This marks fromTable for section and cell recalculation. |
| 652 markTableForSectionAndCellRecalculation(fromTablePart); |
| 653 |
| 654 // startChild is now part of toTable. This marks toTable for section and cel
l recalculation. |
| 655 markTableForSectionAndCellRecalculation(startChild); |
| 656 } |
| 657 |
| 658 RenderObject* RenderBlock::splitTablePartsAroundChild(RenderObject* beforeChild) |
| 659 { |
| 660 ASSERT(beforeChild->isTablePart()); |
| 661 |
| 662 while (beforeChild->parent() != this && !beforeChild->isTable()) { |
| 663 RenderObject* tablePartToSplit = beforeChild->parent(); |
| 664 if (tablePartToSplit->firstChild() != beforeChild) { |
| 665 // Get our table container. |
| 666 RenderObject* curr = tablePartToSplit; |
| 667 while (!curr->isTable()) |
| 668 curr = curr->parent(); |
| 669 RenderTable* table = toRenderTable(curr); |
| 670 |
| 671 // Create an anonymous table container next to our table container. |
| 672 RenderBlock* parentBlock = toRenderBlock(table->parent()); |
| 673 RenderTable* postTable = parentBlock->createAnonymousTable(); |
| 674 parentBlock->children()->insertChildNode(parentBlock, postTable, tab
le->nextSibling()); |
| 675 |
| 676 // Move all the children from beforeChild to the newly created anony
mous table container. |
| 677 moveAllTableChildrenTo(tablePartToSplit, postTable, beforeChild); |
| 678 |
| 679 beforeChild = postTable; |
| 680 } else |
| 681 beforeChild = tablePartToSplit; |
| 682 } |
| 683 return beforeChild; |
| 684 } |
| 685 |
620 void RenderBlock::makeChildrenAnonymousColumnBlocks(RenderObject* beforeChild, R
enderBlock* newBlockBox, RenderObject* newChild) | 686 void RenderBlock::makeChildrenAnonymousColumnBlocks(RenderObject* beforeChild, R
enderBlock* newBlockBox, RenderObject* newChild) |
621 { | 687 { |
622 RenderBlock* pre = 0; | 688 RenderBlock* pre = 0; |
623 RenderBlock* post = 0; | 689 RenderBlock* post = 0; |
624 RenderBlock* block = this; // Eventually block will not just be |this|, but
will also be a block nested inside |this|. Assign to a variable | 690 RenderBlock* block = this; // Eventually block will not just be |this|, but
will also be a block nested inside |this|. Assign to a variable |
625 // so that we don't have to patch all of the rest
of the code later on. | 691 // so that we don't have to patch all of the rest
of the code later on. |
626 | 692 |
627 // Delete the block's line boxes before we do the split. | 693 // Delete the block's line boxes before we do the split. |
628 block->deleteLineBoxTree(); | 694 block->deleteLineBoxTree(); |
629 | 695 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 if ((newChild->isTableCol() && newChild->style()->display() == TABLE_COL
UMN_GROUP) | 792 if ((newChild->isTableCol() && newChild->style()->display() == TABLE_COL
UMN_GROUP) |
727 || (newChild->isTableCaption()) | 793 || (newChild->isTableCaption()) |
728 || newChild->isTableSection() | 794 || newChild->isTableSection() |
729 || newChild->isTableRow() | 795 || newChild->isTableRow() |
730 || newChild->isTableCell()) { | 796 || newChild->isTableCell()) { |
731 // Insert into the anonymous table. | 797 // Insert into the anonymous table. |
732 beforeChildAnonymousContainer->addChild(newChild, beforeChild); | 798 beforeChildAnonymousContainer->addChild(newChild, beforeChild); |
733 return; | 799 return; |
734 } | 800 } |
735 | 801 |
736 // Go on to insert before the anonymous table. | 802 beforeChild = splitTablePartsAroundChild(beforeChild); |
737 beforeChild = beforeChildAnonymousContainer; | |
738 } | 803 } |
739 | 804 |
740 // Check for a spanning element in columns. | 805 // Check for a spanning element in columns. |
741 RenderBlock* columnsBlockAncestor = columnsBlockForSpanningElement(newChild)
; | 806 RenderBlock* columnsBlockAncestor = columnsBlockForSpanningElement(newChild)
; |
742 if (columnsBlockAncestor) { | 807 if (columnsBlockAncestor) { |
743 // We are placing a column-span element inside a block. | 808 // We are placing a column-span element inside a block. |
744 RenderBlock* newBox = createAnonymousColumnSpanBlock(); | 809 RenderBlock* newBox = createAnonymousColumnSpanBlock(); |
745 | 810 |
746 if (columnsBlockAncestor != this) { | 811 if (columnsBlockAncestor != this) { |
747 // We are nested inside a multi-column element and are being split b
y the span. We have to break up | 812 // We are nested inside a multi-column element and are being split b
y the span. We have to break up |
(...skipping 6365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7113 } | 7178 } |
7114 | 7179 |
7115 String ValueToString<RenderBlock::FloatingObject*>::string(const RenderBlock::Fl
oatingObject* floatingObject) | 7180 String ValueToString<RenderBlock::FloatingObject*>::string(const RenderBlock::Fl
oatingObject* floatingObject) |
7116 { | 7181 { |
7117 return String::format("%p (%dx%d %dx%d)", floatingObject, floatingObject->x(
), floatingObject->y(), floatingObject->maxX(), floatingObject->maxY()); | 7182 return String::format("%p (%dx%d %dx%d)", floatingObject, floatingObject->x(
), floatingObject->y(), floatingObject->maxX(), floatingObject->maxY()); |
7118 } | 7183 } |
7119 | 7184 |
7120 #endif | 7185 #endif |
7121 | 7186 |
7122 } // namespace WebCore | 7187 } // namespace WebCore |
OLD | NEW |