| 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 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 // Always just do a full layout in order to ensure that line boxes (especial
ly wrappers for images) | 586 // Always just do a full layout in order to ensure that line boxes (especial
ly wrappers for images) |
| 587 // get deleted properly. Because objects moves from the pre block into the
post block, we want to | 587 // get deleted properly. Because objects moves from the pre block into the
post block, we want to |
| 588 // make new line boxes instead of leaving the old line boxes around. | 588 // make new line boxes instead of leaving the old line boxes around. |
| 589 pre->setNeedsLayoutAndPrefWidthsRecalc(); | 589 pre->setNeedsLayoutAndPrefWidthsRecalc(); |
| 590 block->setNeedsLayoutAndPrefWidthsRecalc(); | 590 block->setNeedsLayoutAndPrefWidthsRecalc(); |
| 591 post->setNeedsLayoutAndPrefWidthsRecalc(); | 591 post->setNeedsLayoutAndPrefWidthsRecalc(); |
| 592 } | 592 } |
| 593 | 593 |
| 594 RenderObject* RenderBlock::splitAnonymousBlocksAroundChild(RenderObject* beforeC
hild) | 594 RenderObject* RenderBlock::splitAnonymousBlocksAroundChild(RenderObject* beforeC
hild) |
| 595 { | 595 { |
| 596 if (beforeChild->isTablePart()) |
| 597 beforeChild = splitTablePartsAroundChild(beforeChild); |
| 598 |
| 596 while (beforeChild->parent() != this) { | 599 while (beforeChild->parent() != this) { |
| 597 RenderBlock* blockToSplit = toRenderBlock(beforeChild->parent()); | 600 RenderBlock* blockToSplit = toRenderBlock(beforeChild->parent()); |
| 598 if (blockToSplit->firstChild() != beforeChild) { | 601 if (blockToSplit->firstChild() != beforeChild) { |
| 599 // We have to split the parentBlock into two blocks. | 602 // We have to split the parentBlock into two blocks. |
| 600 RenderBlock* post = createAnonymousBlockWithSameTypeAs(blockToSplit)
; | 603 RenderBlock* post = createAnonymousBlockWithSameTypeAs(blockToSplit)
; |
| 601 post->setChildrenInline(blockToSplit->childrenInline()); | 604 post->setChildrenInline(blockToSplit->childrenInline()); |
| 602 RenderBlock* parentBlock = toRenderBlock(blockToSplit->parent()); | 605 RenderBlock* parentBlock = toRenderBlock(blockToSplit->parent()); |
| 603 parentBlock->children()->insertChildNode(parentBlock, post, blockToS
plit->nextSibling()); | 606 parentBlock->children()->insertChildNode(parentBlock, post, blockToS
plit->nextSibling()); |
| 604 blockToSplit->moveChildrenTo(post, beforeChild, 0, blockToSplit->has
Layer()); | 607 blockToSplit->moveChildrenTo(post, beforeChild, 0, blockToSplit->has
Layer()); |
| 605 post->setNeedsLayoutAndPrefWidthsRecalc(); | 608 post->setNeedsLayoutAndPrefWidthsRecalc(); |
| 606 blockToSplit->setNeedsLayoutAndPrefWidthsRecalc(); | 609 blockToSplit->setNeedsLayoutAndPrefWidthsRecalc(); |
| 607 beforeChild = post; | 610 beforeChild = post; |
| 608 } else | 611 } else |
| 609 beforeChild = blockToSplit; | 612 beforeChild = blockToSplit; |
| 610 } | 613 } |
| 611 return beforeChild; | 614 return beforeChild; |
| 612 } | 615 } |
| 613 | 616 |
| 617 static void markTableForSectionAndCellRecalculation(RenderObject* child) |
| 618 { |
| 619 RenderObject* curr = child; |
| 620 while (!curr->isTable()) { |
| 621 if (curr->isTableSection()) |
| 622 toRenderTableSection(curr)->setNeedsCellRecalc(); |
| 623 curr = curr->parent(); |
| 624 } |
| 625 |
| 626 RenderTable* table = toRenderTable(curr); |
| 627 table->setNeedsSectionRecalc(); |
| 628 table->setNeedsLayoutAndPrefWidthsRecalc(); |
| 629 } |
| 630 |
| 631 static void moveAllTableChildrenTo(RenderObject* fromTablePart, RenderTable* toT
able, RenderObject* startChild) |
| 632 { |
| 633 for (RenderObject* curr = startChild; curr;) { |
| 634 // Need to store next sibling as we won't have access to it |
| 635 // after we are removed from table. |
| 636 RenderObject* next = curr->nextSibling(); |
| 637 fromTablePart->removeChild(curr); |
| 638 toTable->addChild(curr); |
| 639 if (curr->isTableSection()) |
| 640 toRenderTableSection(curr)->setNeedsCellRecalc(); |
| 641 curr->setNeedsLayoutAndPrefWidthsRecalc(); |
| 642 curr = next; |
| 643 } |
| 644 |
| 645 // This marks fromTable for section and cell recalculation. |
| 646 markTableForSectionAndCellRecalculation(fromTablePart); |
| 647 |
| 648 // startChild is now part of toTable. This marks toTable for section and cel
l recalculation. |
| 649 markTableForSectionAndCellRecalculation(startChild); |
| 650 } |
| 651 |
| 652 RenderObject* RenderBlock::splitTablePartsAroundChild(RenderObject* beforeChild) |
| 653 { |
| 654 ASSERT(beforeChild->isTablePart()); |
| 655 |
| 656 while (beforeChild->parent() != this && !beforeChild->isTable()) { |
| 657 RenderObject* tablePartToSplit = beforeChild->parent(); |
| 658 if (tablePartToSplit->firstChild() != beforeChild) { |
| 659 // Get our table container. |
| 660 RenderObject* curr = tablePartToSplit; |
| 661 while (!curr->isTable()) |
| 662 curr = curr->parent(); |
| 663 RenderTable* table = toRenderTable(curr); |
| 664 |
| 665 // Create an anonymous table container next to our table container. |
| 666 RenderBlock* parentBlock = toRenderBlock(table->parent()); |
| 667 RenderTable* postTable = parentBlock->createAnonymousTable(); |
| 668 parentBlock->children()->insertChildNode(parentBlock, postTable, tab
le->nextSibling()); |
| 669 |
| 670 // Move all the children from beforeChild to the newly created anony
mous table container. |
| 671 moveAllTableChildrenTo(tablePartToSplit, postTable, beforeChild); |
| 672 |
| 673 beforeChild = postTable; |
| 674 } else |
| 675 beforeChild = tablePartToSplit; |
| 676 } |
| 677 return beforeChild; |
| 678 } |
| 679 |
| 614 void RenderBlock::makeChildrenAnonymousColumnBlocks(RenderObject* beforeChild, R
enderBlock* newBlockBox, RenderObject* newChild) | 680 void RenderBlock::makeChildrenAnonymousColumnBlocks(RenderObject* beforeChild, R
enderBlock* newBlockBox, RenderObject* newChild) |
| 615 { | 681 { |
| 616 RenderBlock* pre = 0; | 682 RenderBlock* pre = 0; |
| 617 RenderBlock* post = 0; | 683 RenderBlock* post = 0; |
| 618 RenderBlock* block = this; // Eventually block will not just be |this|, but
will also be a block nested inside |this|. Assign to a variable | 684 RenderBlock* block = this; // Eventually block will not just be |this|, but
will also be a block nested inside |this|. Assign to a variable |
| 619 // so that we don't have to patch all of the rest
of the code later on. | 685 // so that we don't have to patch all of the rest
of the code later on. |
| 620 | 686 |
| 621 // Delete the block's line boxes before we do the split. | 687 // Delete the block's line boxes before we do the split. |
| 622 block->deleteLineBoxTree(); | 688 block->deleteLineBoxTree(); |
| 623 | 689 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 if ((newChild->isTableCol() && newChild->style()->display() == TABLE_COL
UMN_GROUP) | 786 if ((newChild->isTableCol() && newChild->style()->display() == TABLE_COL
UMN_GROUP) |
| 721 || (newChild->isTableCaption()) | 787 || (newChild->isTableCaption()) |
| 722 || newChild->isTableSection() | 788 || newChild->isTableSection() |
| 723 || newChild->isTableRow() | 789 || newChild->isTableRow() |
| 724 || newChild->isTableCell()) { | 790 || newChild->isTableCell()) { |
| 725 // Insert into the anonymous table. | 791 // Insert into the anonymous table. |
| 726 beforeChildAnonymousContainer->addChild(newChild, beforeChild); | 792 beforeChildAnonymousContainer->addChild(newChild, beforeChild); |
| 727 return; | 793 return; |
| 728 } | 794 } |
| 729 | 795 |
| 730 // Go on to insert before the anonymous table. | 796 beforeChild = splitTablePartsAroundChild(beforeChild); |
| 731 beforeChild = beforeChildAnonymousContainer; | |
| 732 } | 797 } |
| 733 | 798 |
| 734 // Check for a spanning element in columns. | 799 // Check for a spanning element in columns. |
| 735 RenderBlock* columnsBlockAncestor = columnsBlockForSpanningElement(newChild)
; | 800 RenderBlock* columnsBlockAncestor = columnsBlockForSpanningElement(newChild)
; |
| 736 if (columnsBlockAncestor) { | 801 if (columnsBlockAncestor) { |
| 737 // We are placing a column-span element inside a block. | 802 // We are placing a column-span element inside a block. |
| 738 RenderBlock* newBox = createAnonymousColumnSpanBlock(); | 803 RenderBlock* newBox = createAnonymousColumnSpanBlock(); |
| 739 | 804 |
| 740 if (columnsBlockAncestor != this) { | 805 if (columnsBlockAncestor != this) { |
| 741 // We are nested inside a multi-column element and are being split b
y the span. We have to break up | 806 // We are nested inside a multi-column element and are being split b
y the span. We have to break up |
| (...skipping 6340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7082 } | 7147 } |
| 7083 | 7148 |
| 7084 String ValueToString<RenderBlock::FloatingObject*>::string(const RenderBlock::Fl
oatingObject* floatingObject) | 7149 String ValueToString<RenderBlock::FloatingObject*>::string(const RenderBlock::Fl
oatingObject* floatingObject) |
| 7085 { | 7150 { |
| 7086 return String::format("%p (%dx%d %dx%d)", floatingObject, floatingObject->x(
), floatingObject->y(), floatingObject->maxX(), floatingObject->maxY()); | 7151 return String::format("%p (%dx%d %dx%d)", floatingObject, floatingObject->x(
), floatingObject->y(), floatingObject->maxX(), floatingObject->maxY()); |
| 7087 } | 7152 } |
| 7088 | 7153 |
| 7089 #endif | 7154 #endif |
| 7090 | 7155 |
| 7091 } // namespace WebCore | 7156 } // namespace WebCore |
| OLD | NEW |