| 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 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
reserved. | 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
reserved. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 static_assert(sizeof(LayoutInline) == sizeof(SameSizeAsLayoutInline), "LayoutInl
ine should stay small"); | 53 static_assert(sizeof(LayoutInline) == sizeof(SameSizeAsLayoutInline), "LayoutInl
ine should stay small"); |
| 54 | 54 |
| 55 LayoutInline::LayoutInline(Element* element) | 55 LayoutInline::LayoutInline(Element* element) |
| 56 : LayoutBoxModelObject(element) | 56 : LayoutBoxModelObject(element) |
| 57 { | 57 { |
| 58 setChildrenInline(true); | 58 setChildrenInline(true); |
| 59 } | 59 } |
| 60 | 60 |
| 61 LayoutInline* LayoutInline::createAnonymous(Document* document) | 61 LayoutInline* LayoutInline::createAnonymous(Document* document) |
| 62 { | 62 { |
| 63 LayoutInline* layoutObject = new LayoutInline(0); | 63 LayoutInline* layoutObject = new LayoutInline(nullptr); |
| 64 layoutObject->setDocumentForAnonymous(document); | 64 layoutObject->setDocumentForAnonymous(document); |
| 65 return layoutObject; | 65 return layoutObject; |
| 66 } | 66 } |
| 67 | 67 |
| 68 void LayoutInline::willBeDestroyed() | 68 void LayoutInline::willBeDestroyed() |
| 69 { | 69 { |
| 70 #if ENABLE(ASSERT) | 70 #if ENABLE(ASSERT) |
| 71 // Make sure we do not retain "this" in the continuation outline table map o
f our containing blocks. | 71 // Make sure we do not retain "this" in the continuation outline table map o
f our containing blocks. |
| 72 if (parent() && style()->visibility() == VISIBLE && style()->hasOutline()) { | 72 if (parent() && style()->visibility() == VISIBLE && style()->hasOutline()) { |
| 73 bool containingBlockPaintsContinuationOutline = continuation() || isInli
neElementContinuation(); | 73 bool containingBlockPaintsContinuationOutline = continuation() || isInli
neElementContinuation(); |
| 74 if (containingBlockPaintsContinuationOutline) { | 74 if (containingBlockPaintsContinuationOutline) { |
| 75 if (LayoutBlock* cb = containingBlock()) { | 75 if (LayoutBlock* cb = containingBlock()) { |
| 76 if (LayoutBlock* cbCb = cb->containingBlock()) | 76 if (LayoutBlock* cbCb = cb->containingBlock()) |
| 77 ASSERT(!cbCb->paintsContinuationOutline(this)); | 77 ASSERT(!cbCb->paintsContinuationOutline(this)); |
| 78 } | 78 } |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 #endif | 81 #endif |
| 82 | 82 |
| 83 // Make sure to destroy anonymous children first while they are still connec
ted to the rest of the tree, so that they will | 83 // Make sure to destroy anonymous children first while they are still connec
ted to the rest of the tree, so that they will |
| 84 // properly dirty line boxes that they are removed from. Effects that do :b
efore/:after only on hover could crash otherwise. | 84 // properly dirty line boxes that they are removed from. Effects that do :b
efore/:after only on hover could crash otherwise. |
| 85 children()->destroyLeftoverChildren(); | 85 children()->destroyLeftoverChildren(); |
| 86 | 86 |
| 87 // Destroy our continuation before anything other than anonymous children. | 87 // Destroy our continuation before anything other than anonymous children. |
| 88 // The reason we don't destroy it before anonymous children is that they may | 88 // The reason we don't destroy it before anonymous children is that they may |
| 89 // have continuations of their own that are anonymous children of our contin
uation. | 89 // have continuations of their own that are anonymous children of our contin
uation. |
| 90 LayoutBoxModelObject* continuation = this->continuation(); | 90 LayoutBoxModelObject* continuation = this->continuation(); |
| 91 if (continuation) { | 91 if (continuation) { |
| 92 continuation->destroy(); | 92 continuation->destroy(); |
| 93 setContinuation(0); | 93 setContinuation(nullptr); |
| 94 } | 94 } |
| 95 | 95 |
| 96 if (!documentBeingDestroyed()) { | 96 if (!documentBeingDestroyed()) { |
| 97 if (firstLineBox()) { | 97 if (firstLineBox()) { |
| 98 // We can't wait for LayoutBoxModelObject::destroy to clear the sele
ction, | 98 // We can't wait for LayoutBoxModelObject::destroy to clear the sele
ction, |
| 99 // because by then we will have nuked the line boxes. | 99 // because by then we will have nuked the line boxes. |
| 100 // FIXME: The FrameSelection should be responsible for this when it | 100 // FIXME: The FrameSelection should be responsible for this when it |
| 101 // is notified of DOM mutations. | 101 // is notified of DOM mutations. |
| 102 if (isSelectionBorder()) | 102 if (isSelectionBorder()) |
| 103 view()->clearSelection(); | 103 view()->clearSelection(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 setHasReflection(false); | 141 setHasReflection(false); |
| 142 } | 142 } |
| 143 | 143 |
| 144 static LayoutObject* inFlowPositionedInlineAncestor(LayoutObject* p) | 144 static LayoutObject* inFlowPositionedInlineAncestor(LayoutObject* p) |
| 145 { | 145 { |
| 146 while (p && p->isLayoutInline()) { | 146 while (p && p->isLayoutInline()) { |
| 147 if (p->isRelPositioned()) | 147 if (p->isRelPositioned()) |
| 148 return p; | 148 return p; |
| 149 p = p->parent(); | 149 p = p->parent(); |
| 150 } | 150 } |
| 151 return 0; | 151 return nullptr; |
| 152 } | 152 } |
| 153 | 153 |
| 154 static void updateStyleOfAnonymousBlockContinuations(LayoutObject* block, const
ComputedStyle& newStyle, const ComputedStyle& oldStyle) | 154 static void updateStyleOfAnonymousBlockContinuations(LayoutObject* block, const
ComputedStyle& newStyle, const ComputedStyle& oldStyle) |
| 155 { | 155 { |
| 156 for (;block && block->isAnonymousBlock(); block = block->nextSibling()) { | 156 for (;block && block->isAnonymousBlock(); block = block->nextSibling()) { |
| 157 if (!toLayoutBlock(block)->isAnonymousBlockContinuation()) | 157 if (!toLayoutBlock(block)->isAnonymousBlockContinuation()) |
| 158 continue; | 158 continue; |
| 159 | 159 |
| 160 RefPtr<ComputedStyle> newBlockStyle; | 160 RefPtr<ComputedStyle> newBlockStyle; |
| 161 | 161 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 187 // Ensure that all of the split inlines pick up the new style. We | 187 // Ensure that all of the split inlines pick up the new style. We |
| 188 // only do this if we're an inline, since we don't want to propagate | 188 // only do this if we're an inline, since we don't want to propagate |
| 189 // a block's style to the other inlines. | 189 // a block's style to the other inlines. |
| 190 // e.g., <font>foo <h4>goo</h4> moo</font>. The <font> inlines before | 190 // e.g., <font>foo <h4>goo</h4> moo</font>. The <font> inlines before |
| 191 // and after the block share the same style, but the block doesn't | 191 // and after the block share the same style, but the block doesn't |
| 192 // need to pass its style on to anyone else. | 192 // need to pass its style on to anyone else. |
| 193 const ComputedStyle& newStyle = styleRef(); | 193 const ComputedStyle& newStyle = styleRef(); |
| 194 LayoutInline* continuation = inlineElementContinuation(); | 194 LayoutInline* continuation = inlineElementContinuation(); |
| 195 for (LayoutInline* currCont = continuation; currCont; currCont = currCont->i
nlineElementContinuation()) { | 195 for (LayoutInline* currCont = continuation; currCont; currCont = currCont->i
nlineElementContinuation()) { |
| 196 LayoutBoxModelObject* nextCont = currCont->continuation(); | 196 LayoutBoxModelObject* nextCont = currCont->continuation(); |
| 197 currCont->setContinuation(0); | 197 currCont->setContinuation(nullptr); |
| 198 currCont->setStyle(mutableStyle()); | 198 currCont->setStyle(mutableStyle()); |
| 199 currCont->setContinuation(nextCont); | 199 currCont->setContinuation(nextCont); |
| 200 } | 200 } |
| 201 | 201 |
| 202 // If an inline's outline or in-flow positioning has changed then any descen
dant blocks will need to change their styles accordingly. | 202 // If an inline's outline or in-flow positioning has changed then any descen
dant blocks will need to change their styles accordingly. |
| 203 // Do this by updating the styles of the descendant blocks' containing anony
mous blocks - there may be more than one. | 203 // Do this by updating the styles of the descendant blocks' containing anony
mous blocks - there may be more than one. |
| 204 if (continuation && oldStyle | 204 if (continuation && oldStyle |
| 205 && (!newStyle.isOutlineEquivalent(oldStyle) | 205 && (!newStyle.isOutlineEquivalent(oldStyle) |
| 206 || (newStyle.position() != oldStyle->position() && (newStyle.hasInFl
owPosition() || oldStyle->hasInFlowPosition())))) { | 206 || (newStyle.position() != oldStyle->position() && (newStyle.hasInFl
owPosition() || oldStyle->hasInFlowPosition())))) { |
| 207 // If any descendant blocks exist then they will be in the next anonymou
s block and its siblings. | 207 // If any descendant blocks exist then they will be in the next anonymou
s block and its siblings. |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 middleBlock->setContinuation(cloneInline); | 450 middleBlock->setContinuation(cloneInline); |
| 451 | 451 |
| 452 // Now take all of the children from |beforeChild| to the end and remove | 452 // Now take all of the children from |beforeChild| to the end and remove |
| 453 // them from |this| and place them in the clone. | 453 // them from |this| and place them in the clone. |
| 454 moveChildrenToIgnoringContinuation(cloneInline, beforeChild); | 454 moveChildrenToIgnoringContinuation(cloneInline, beforeChild); |
| 455 } | 455 } |
| 456 | 456 |
| 457 void LayoutInline::splitFlow(LayoutObject* beforeChild, LayoutBlock* newBlockBox
, | 457 void LayoutInline::splitFlow(LayoutObject* beforeChild, LayoutBlock* newBlockBox
, |
| 458 LayoutObject* newChild, LayoutBoxModelObject* oldCont) | 458 LayoutObject* newChild, LayoutBoxModelObject* oldCont) |
| 459 { | 459 { |
| 460 LayoutBlock* pre = 0; | 460 LayoutBlock* pre = nullptr; |
| 461 LayoutBlock* block = containingBlock(); | 461 LayoutBlock* block = containingBlock(); |
| 462 | 462 |
| 463 // Delete our line boxes before we do the inline split into continuations. | 463 // Delete our line boxes before we do the inline split into continuations. |
| 464 block->deleteLineBoxTree(); | 464 block->deleteLineBoxTree(); |
| 465 | 465 |
| 466 bool madeNewBeforeBlock = false; | 466 bool madeNewBeforeBlock = false; |
| 467 if (block->isAnonymousBlock() && (!block->parent() || !block->parent()->crea
tesAnonymousWrapper())) { | 467 if (block->isAnonymousBlock() && (!block->parent() || !block->parent()->crea
tesAnonymousWrapper())) { |
| 468 // We can reuse this block and make it the preBlock of the next continua
tion. | 468 // We can reuse this block and make it the preBlock of the next continua
tion. |
| 469 pre = block; | 469 pre = block; |
| 470 pre->removePositionedObjects(0); | 470 pre->removePositionedObjects(nullptr); |
| 471 if (pre->isLayoutBlockFlow()) | 471 if (pre->isLayoutBlockFlow()) |
| 472 toLayoutBlockFlow(pre)->removeFloatingObjects(); | 472 toLayoutBlockFlow(pre)->removeFloatingObjects(); |
| 473 block = block->containingBlock(); | 473 block = block->containingBlock(); |
| 474 } else { | 474 } else { |
| 475 // No anonymous block available for use. Make one. | 475 // No anonymous block available for use. Make one. |
| 476 pre = block->createAnonymousBlock(); | 476 pre = block->createAnonymousBlock(); |
| 477 madeNewBeforeBlock = true; | 477 madeNewBeforeBlock = true; |
| 478 } | 478 } |
| 479 | 479 |
| 480 LayoutBlock* post = toLayoutBlock(pre->createAnonymousBoxWithSameTypeAs(bloc
k)); | 480 LayoutBlock* post = toLayoutBlock(pre->createAnonymousBoxWithSameTypeAs(bloc
k)); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 509 // make new line boxes instead of leaving the old line boxes around. | 509 // make new line boxes instead of leaving the old line boxes around. |
| 510 pre->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInvalid
ationReason::AnonymousBlockChange); | 510 pre->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInvalid
ationReason::AnonymousBlockChange); |
| 511 block->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInval
idationReason::AnonymousBlockChange); | 511 block->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInval
idationReason::AnonymousBlockChange); |
| 512 post->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInvali
dationReason::AnonymousBlockChange); | 512 post->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInvali
dationReason::AnonymousBlockChange); |
| 513 } | 513 } |
| 514 | 514 |
| 515 void LayoutInline::addChildToContinuation(LayoutObject* newChild, LayoutObject*
beforeChild) | 515 void LayoutInline::addChildToContinuation(LayoutObject* newChild, LayoutObject*
beforeChild) |
| 516 { | 516 { |
| 517 LayoutBoxModelObject* flow = continuationBefore(beforeChild); | 517 LayoutBoxModelObject* flow = continuationBefore(beforeChild); |
| 518 ASSERT(!beforeChild || beforeChild->parent()->isLayoutBlock() || beforeChild
->parent()->isLayoutInline()); | 518 ASSERT(!beforeChild || beforeChild->parent()->isLayoutBlock() || beforeChild
->parent()->isLayoutInline()); |
| 519 LayoutBoxModelObject* beforeChildParent = 0; | 519 LayoutBoxModelObject* beforeChildParent = nullptr; |
| 520 if (beforeChild) { | 520 if (beforeChild) { |
| 521 beforeChildParent = toLayoutBoxModelObject(beforeChild->parent()); | 521 beforeChildParent = toLayoutBoxModelObject(beforeChild->parent()); |
| 522 } else { | 522 } else { |
| 523 LayoutBoxModelObject* cont = nextContinuation(flow); | 523 LayoutBoxModelObject* cont = nextContinuation(flow); |
| 524 if (cont) | 524 if (cont) |
| 525 beforeChildParent = cont; | 525 beforeChildParent = cont; |
| 526 else | 526 else |
| 527 beforeChildParent = flow; | 527 beforeChildParent = flow; |
| 528 } | 528 } |
| 529 | 529 |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 LayoutInline* currInline = toLayoutInline(curr); | 909 LayoutInline* currInline = toLayoutInline(curr); |
| 910 InlineBox* result = currInline->firstLineBoxIncludingCulling(); | 910 InlineBox* result = currInline->firstLineBoxIncludingCulling(); |
| 911 if (result) | 911 if (result) |
| 912 return result; | 912 return result; |
| 913 } else if (curr->isText()) { | 913 } else if (curr->isText()) { |
| 914 LayoutText* currText = toLayoutText(curr); | 914 LayoutText* currText = toLayoutText(curr); |
| 915 if (currText->firstTextBox()) | 915 if (currText->firstTextBox()) |
| 916 return currText->firstTextBox(); | 916 return currText->firstTextBox(); |
| 917 } | 917 } |
| 918 } | 918 } |
| 919 return 0; | 919 return nullptr; |
| 920 } | 920 } |
| 921 | 921 |
| 922 InlineBox* LayoutInline::culledInlineLastLineBox() const | 922 InlineBox* LayoutInline::culledInlineLastLineBox() const |
| 923 { | 923 { |
| 924 for (LayoutObject* curr = lastChild(); curr; curr = curr->previousSibling())
{ | 924 for (LayoutObject* curr = lastChild(); curr; curr = curr->previousSibling())
{ |
| 925 if (curr->isFloatingOrOutOfFlowPositioned()) | 925 if (curr->isFloatingOrOutOfFlowPositioned()) |
| 926 continue; | 926 continue; |
| 927 | 927 |
| 928 // We want to get the margin box in the inline direction, and then use o
ur font ascent/descent in the block | 928 // We want to get the margin box in the inline direction, and then use o
ur font ascent/descent in the block |
| 929 // direction (aligned to the root box's baseline). | 929 // direction (aligned to the root box's baseline). |
| 930 if (curr->isBox()) | 930 if (curr->isBox()) |
| 931 return toLayoutBox(curr)->inlineBoxWrapper(); | 931 return toLayoutBox(curr)->inlineBoxWrapper(); |
| 932 if (curr->isLayoutInline()) { | 932 if (curr->isLayoutInline()) { |
| 933 LayoutInline* currInline = toLayoutInline(curr); | 933 LayoutInline* currInline = toLayoutInline(curr); |
| 934 InlineBox* result = currInline->lastLineBoxIncludingCulling(); | 934 InlineBox* result = currInline->lastLineBoxIncludingCulling(); |
| 935 if (result) | 935 if (result) |
| 936 return result; | 936 return result; |
| 937 } else if (curr->isText()) { | 937 } else if (curr->isText()) { |
| 938 LayoutText* currText = toLayoutText(curr); | 938 LayoutText* currText = toLayoutText(curr); |
| 939 if (currText->lastTextBox()) | 939 if (currText->lastTextBox()) |
| 940 return currText->lastTextBox(); | 940 return currText->lastTextBox(); |
| 941 } | 941 } |
| 942 } | 942 } |
| 943 return 0; | 943 return nullptr; |
| 944 } | 944 } |
| 945 | 945 |
| 946 LayoutRect LayoutInline::culledInlineVisualOverflowBoundingBox() const | 946 LayoutRect LayoutInline::culledInlineVisualOverflowBoundingBox() const |
| 947 { | 947 { |
| 948 FloatRect floatResult; | 948 FloatRect floatResult; |
| 949 LinesBoundingBoxGeneratorContext context(floatResult); | 949 LinesBoundingBoxGeneratorContext context(floatResult); |
| 950 generateCulledLineBoxRects(context, this); | 950 generateCulledLineBoxRects(context, this); |
| 951 LayoutRect result(enclosingLayoutRect(floatResult)); | 951 LayoutRect result(enclosingLayoutRect(floatResult)); |
| 952 bool isHorizontal = style()->isHorizontalWritingMode(); | 952 bool isHorizontal = style()->isHorizontalWritingMode(); |
| 953 for (LayoutObject* curr = firstChild(); curr; curr = curr->nextSibling()) { | 953 for (LayoutObject* curr = firstChild(); curr; curr = curr->nextSibling()) { |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1431 } | 1431 } |
| 1432 | 1432 |
| 1433 void LayoutInline::invalidateDisplayItemClients(const LayoutBoxModelObject& pain
tInvalidationContainer) const | 1433 void LayoutInline::invalidateDisplayItemClients(const LayoutBoxModelObject& pain
tInvalidationContainer) const |
| 1434 { | 1434 { |
| 1435 LayoutBoxModelObject::invalidateDisplayItemClients(paintInvalidationContaine
r); | 1435 LayoutBoxModelObject::invalidateDisplayItemClients(paintInvalidationContaine
r); |
| 1436 for (InlineFlowBox* box = firstLineBox(); box; box = box->nextLineBox()) | 1436 for (InlineFlowBox* box = firstLineBox(); box; box = box->nextLineBox()) |
| 1437 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*box); | 1437 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*box); |
| 1438 } | 1438 } |
| 1439 | 1439 |
| 1440 } // namespace blink | 1440 } // namespace blink |
| OLD | NEW |