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 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 return false; | 1012 return false; |
1013 | 1013 |
1014 if (!prev || !next) | 1014 if (!prev || !next) |
1015 return true; | 1015 return true; |
1016 | 1016 |
1017 // Make sure the types of the anonymous blocks match up. | 1017 // Make sure the types of the anonymous blocks match up. |
1018 return prev->isAnonymousColumnsBlock() == next->isAnonymousColumnsBlock() | 1018 return prev->isAnonymousColumnsBlock() == next->isAnonymousColumnsBlock() |
1019 && prev->isAnonymousColumnSpanBlock() == next->isAnonymousColumnSpanB
lock(); | 1019 && prev->isAnonymousColumnSpanBlock() == next->isAnonymousColumnSpanB
lock(); |
1020 } | 1020 } |
1021 | 1021 |
| 1022 void RenderBlock::collapseAnonymousBoxChild(RenderBlock* parent, RenderObject* c
hild) |
| 1023 { |
| 1024 parent->setNeedsLayoutAndPrefWidthsRecalc(); |
| 1025 parent->setChildrenInline(child->childrenInline()); |
| 1026 RenderBlock* anonBlock = toRenderBlock(parent->children()->removeChildNode(p
arent, child, child->hasLayer())); |
| 1027 anonBlock->moveAllChildrenTo(parent, child->hasLayer()); |
| 1028 // Delete the now-empty block's lines and nuke it. |
| 1029 if (!parent->documentBeingDestroyed()) |
| 1030 anonBlock->deleteLineBoxTree(); |
| 1031 anonBlock->destroy(); |
| 1032 } |
| 1033 |
1022 void RenderBlock::removeChild(RenderObject* oldChild) | 1034 void RenderBlock::removeChild(RenderObject* oldChild) |
1023 { | 1035 { |
1024 // If this child is a block, and if our previous and next siblings are | 1036 // If this child is a block, and if our previous and next siblings are |
1025 // both anonymous blocks with inline content, then we can go ahead and | 1037 // both anonymous blocks with inline content, then we can go ahead and |
1026 // fold the inline content back together. | 1038 // fold the inline content back together. |
1027 RenderObject* prev = oldChild->previousSibling(); | 1039 RenderObject* prev = oldChild->previousSibling(); |
1028 RenderObject* next = oldChild->nextSibling(); | 1040 RenderObject* next = oldChild->nextSibling(); |
1029 bool canMergeAnonymousBlocks = canMergeContiguousAnonymousBlocks(oldChild, p
rev, next); | 1041 bool canMergeAnonymousBlocks = canMergeContiguousAnonymousBlocks(oldChild, p
rev, next); |
1030 if (canMergeAnonymousBlocks && prev && next) { | 1042 if (canMergeAnonymousBlocks && prev && next) { |
1031 prev->setNeedsLayoutAndPrefWidthsRecalc(); | 1043 prev->setNeedsLayoutAndPrefWidthsRecalc(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1068 } | 1080 } |
1069 } | 1081 } |
1070 | 1082 |
1071 RenderBox::removeChild(oldChild); | 1083 RenderBox::removeChild(oldChild); |
1072 | 1084 |
1073 RenderObject* child = prev ? prev : next; | 1085 RenderObject* child = prev ? prev : next; |
1074 if (canMergeAnonymousBlocks && child && !child->previousSibling() && !child-
>nextSibling() && !isFlexibleBoxIncludingDeprecated()) { | 1086 if (canMergeAnonymousBlocks && child && !child->previousSibling() && !child-
>nextSibling() && !isFlexibleBoxIncludingDeprecated()) { |
1075 // The removal has knocked us down to containing only a single anonymous | 1087 // The removal has knocked us down to containing only a single anonymous |
1076 // box. We can go ahead and pull the content right back up into our | 1088 // box. We can go ahead and pull the content right back up into our |
1077 // box. | 1089 // box. |
1078 setNeedsLayoutAndPrefWidthsRecalc(); | 1090 collapseAnonymousBoxChild(this, child); |
1079 setChildrenInline(child->childrenInline()); | 1091 } else if ((prev && prev->isAnonymousBlock()) || (next && next->isAnonymousB
lock())) { |
1080 RenderBlock* anonBlock = toRenderBlock(children()->removeChildNode(this,
child, child->hasLayer())); | 1092 // It's possible that the removal has knocked us down to a single anonym
ous |
1081 anonBlock->moveAllChildrenTo(this, child->hasLayer()); | 1093 // block with pseudo-style element siblings (e.g. first-letter). If thes
e |
1082 // Delete the now-empty block's lines and nuke it. | 1094 // are floating, then we need to pull the content up also. |
1083 anonBlock->deleteLineBoxTree(); | 1095 RenderBlock* anonBlock = toRenderBlock((prev && prev->isAnonymousBlock()
) ? prev : next); |
1084 anonBlock->destroy(); | 1096 if ((anonBlock->previousSibling() || anonBlock->nextSibling()) |
| 1097 && (!anonBlock->previousSibling() || (anonBlock->previousSibling()->
style()->styleType() != NOPSEUDO && anonBlock->previousSibling()->isFloating())) |
| 1098 && (!anonBlock->nextSibling() || (anonBlock->nextSibling()->style()-
>styleType() != NOPSEUDO && anonBlock->nextSibling()->isFloating()))) { |
| 1099 collapseAnonymousBoxChild(this, anonBlock); |
| 1100 } |
1085 } | 1101 } |
1086 | 1102 |
1087 if (!firstChild() && !documentBeingDestroyed()) { | 1103 if (!firstChild() && !documentBeingDestroyed()) { |
1088 // If this was our last child be sure to clear out our line boxes. | 1104 // If this was our last child be sure to clear out our line boxes. |
1089 if (childrenInline()) | 1105 if (childrenInline()) |
1090 deleteLineBoxTree(); | 1106 deleteLineBoxTree(); |
1091 } | 1107 } |
1092 } | 1108 } |
1093 | 1109 |
1094 bool RenderBlock::isSelfCollapsingBlock() const | 1110 bool RenderBlock::isSelfCollapsingBlock() const |
(...skipping 5951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7046 } | 7062 } |
7047 | 7063 |
7048 String ValueToString<RenderBlock::FloatingObject*>::string(const RenderBlock::Fl
oatingObject* floatingObject) | 7064 String ValueToString<RenderBlock::FloatingObject*>::string(const RenderBlock::Fl
oatingObject* floatingObject) |
7049 { | 7065 { |
7050 return String::format("%p (%dx%d %dx%d)", floatingObject, floatingObject->x(
), floatingObject->y(), floatingObject->maxX(), floatingObject->maxY()); | 7066 return String::format("%p (%dx%d %dx%d)", floatingObject, floatingObject->x(
), floatingObject->y(), floatingObject->maxX(), floatingObject->maxY()); |
7051 } | 7067 } |
7052 | 7068 |
7053 #endif | 7069 #endif |
7054 | 7070 |
7055 } // namespace WebCore | 7071 } // namespace WebCore |
OLD | NEW |