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 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
370 startOfContinuations->invalidateDisplayItemClient(*startOfContinuations) ; | 370 startOfContinuations->invalidateDisplayItemClient(*startOfContinuations) ; |
371 } | 371 } |
372 | 372 |
373 void LayoutBlock::invalidateDisplayItemClients(const LayoutBoxModelObject& paint InvalidationContainer) const | 373 void LayoutBlock::invalidateDisplayItemClients(const LayoutBoxModelObject& paint InvalidationContainer) const |
374 { | 374 { |
375 LayoutBox::invalidateDisplayItemClients(paintInvalidationContainer); | 375 LayoutBox::invalidateDisplayItemClients(paintInvalidationContainer); |
376 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); | 376 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); |
377 invalidateDisplayItemClientForStartOfContinuationsIfNeeded(*this); | 377 invalidateDisplayItemClientForStartOfContinuationsIfNeeded(*this); |
378 } | 378 } |
379 | 379 |
380 void LayoutBlock::addAdjacentSiblingsToAnonymousBox(AdjacentSiblings siblings, L ayoutBlock* anonymousBox) | |
381 { | |
382 bool previousSiblings = siblings == PreviousSiblings; | |
383 LayoutObject* child = previousSiblings ? anonymousBox->previousSibling() : a nonymousBox->nextSibling(); | |
384 while (child && (child->isFloatingOrOutOfFlowPositioned() || (child->isAnony mousBlock() && child->childrenInline()))) { | |
385 LayoutObject* sibling = previousSiblings ? child->previousSibling() : ch ild->nextSibling(); | |
386 if (child->isAnonymousBlock()) { | |
387 LayoutBlockFlow* block = toLayoutBlockFlow(child); | |
mstensho (USE GERRIT)
2015/09/03 08:44:30
I still think that if we find another anonymous bl
rhogan
2015/09/06 15:09:27
Yup - addressed this by parenting floating/out-of-
| |
388 block->moveAllChildrenTo(anonymousBox, previousSiblings ? anonymousB ox->firstChild() : 0, true); | |
389 block->destroy(); | |
390 } else { | |
391 moveChildTo(anonymousBox, child, previousSiblings ? anonymousBox->fi rstChild() : 0, false); | |
392 } | |
393 child = sibling; | |
394 } | |
395 } | |
396 | |
380 void LayoutBlock::addChildIgnoringContinuation(LayoutObject* newChild, LayoutObj ect* beforeChild) | 397 void LayoutBlock::addChildIgnoringContinuation(LayoutObject* newChild, LayoutObj ect* beforeChild) |
381 { | 398 { |
382 if (beforeChild && beforeChild->parent() != this) { | 399 if (beforeChild && beforeChild->parent() != this) { |
383 LayoutObject* beforeChildContainer = beforeChild->parent(); | 400 LayoutObject* beforeChildContainer = beforeChild->parent(); |
384 while (beforeChildContainer->parent() != this) | 401 while (beforeChildContainer->parent() != this) |
385 beforeChildContainer = beforeChildContainer->parent(); | 402 beforeChildContainer = beforeChildContainer->parent(); |
386 ASSERT(beforeChildContainer); | 403 ASSERT(beforeChildContainer); |
387 | 404 |
388 if (beforeChildContainer->isAnonymous()) { | 405 if (beforeChildContainer->isAnonymous()) { |
389 // If the requested beforeChild is not one of our children, then thi s is because | 406 // If the requested beforeChild is not one of our children, then thi s is because |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
439 // If we're inserting an inline child but all of our children are blocks , then we have to make sure | 456 // If we're inserting an inline child but all of our children are blocks , then we have to make sure |
440 // it is put into an anomyous block box. We try to use an existing anony mous box if possible, otherwise | 457 // it is put into an anomyous block box. We try to use an existing anony mous box if possible, otherwise |
441 // a new one is created and inserted into our list of children in the ap propriate position. | 458 // a new one is created and inserted into our list of children in the ap propriate position. |
442 LayoutObject* afterChild = beforeChild ? beforeChild->previousSibling() : lastChild(); | 459 LayoutObject* afterChild = beforeChild ? beforeChild->previousSibling() : lastChild(); |
443 | 460 |
444 if (afterChild && afterChild->isAnonymousBlock()) { | 461 if (afterChild && afterChild->isAnonymousBlock()) { |
445 afterChild->addChild(newChild); | 462 afterChild->addChild(newChild); |
446 return; | 463 return; |
447 } | 464 } |
448 | 465 |
466 LayoutObject* nextChild = firstChild(); | |
467 bool needsAnonymousBox = isFlexibleBoxIncludingDeprecated() || isLayoutG rid(); | |
mstensho (USE GERRIT)
2015/09/03 08:44:30
I cannot find this condition anywhere else in the
rhogan
2015/09/06 15:09:27
These seem to be the only two layout blocks that d
| |
468 while (nextChild && !needsAnonymousBox) { | |
mstensho (USE GERRIT)
2015/09/03 08:44:30
We're walking through all children to figure out i
rhogan
2015/09/06 15:09:27
Clarified what's happening in the comments - we ca
| |
469 if (!nextChild->isFloatingOrOutOfFlowPositioned()) { | |
470 needsAnonymousBox = true; | |
471 break; | |
472 } | |
473 nextChild = nextChild->nextSibling(); | |
474 } | |
475 if (!needsAnonymousBox) { | |
476 LayoutBox::addChild(newChild, beforeChild); | |
477 setChildrenInline(true); | |
478 return; | |
479 } | |
480 | |
449 if (newChild->isInline()) { | 481 if (newChild->isInline()) { |
450 // No suitable existing anonymous box - create a new one. | 482 // No suitable existing anonymous box - create a new one. |
451 LayoutBlock* newBox = createAnonymousBlock(); | 483 LayoutBlock* newBox = createAnonymousBlock(); |
452 LayoutBox::addChild(newBox, beforeChild); | 484 LayoutBox::addChild(newBox, beforeChild); |
485 // Reparent adjacent inline siblings to the new box. | |
486 addAdjacentSiblingsToAnonymousBox(PreviousSiblings, newBox); | |
453 newBox->addChild(newChild); | 487 newBox->addChild(newChild); |
488 addAdjacentSiblingsToAnonymousBox(NextSiblings, newBox); | |
454 return; | 489 return; |
455 } | 490 } |
456 } | 491 } |
457 | 492 |
458 LayoutBox::addChild(newChild, beforeChild); | 493 LayoutBox::addChild(newChild, beforeChild); |
459 | 494 |
460 if (madeBoxesNonInline && parent() && isAnonymousBlock() && parent()->isLayo utBlock()) | 495 if (madeBoxesNonInline && parent() && isAnonymousBlock() && parent()->isLayo utBlock()) |
461 toLayoutBlock(parent())->removeLeftoverAnonymousBlock(this); | 496 toLayoutBlock(parent())->removeLeftoverAnonymousBlock(this); |
462 // this object may be dead here | 497 // this object may be dead here |
463 } | 498 } |
(...skipping 2442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2906 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const | 2941 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const |
2907 { | 2942 { |
2908 showLayoutObject(); | 2943 showLayoutObject(); |
2909 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) | 2944 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) |
2910 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); | 2945 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); |
2911 } | 2946 } |
2912 | 2947 |
2913 #endif | 2948 #endif |
2914 | 2949 |
2915 } // namespace blink | 2950 } // namespace blink |
OLD | NEW |