Chromium Code Reviews| 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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 return oldStyle.borderTopWidth() != newStyle.borderTopWidth() | 264 return oldStyle.borderTopWidth() != newStyle.borderTopWidth() |
| 265 || oldStyle.borderBottomWidth() != newStyle.borderBottomWidth() | 265 || oldStyle.borderBottomWidth() != newStyle.borderBottomWidth() |
| 266 || oldStyle.paddingTop() != newStyle.paddingTop() | 266 || oldStyle.paddingTop() != newStyle.paddingTop() |
| 267 || oldStyle.paddingBottom() != newStyle.paddingBottom(); | 267 || oldStyle.paddingBottom() != newStyle.paddingBottom(); |
| 268 } | 268 } |
| 269 | 269 |
| 270 void LayoutBlock::styleDidChange(StyleDifference diff, const ComputedStyle* oldS tyle) | 270 void LayoutBlock::styleDidChange(StyleDifference diff, const ComputedStyle* oldS tyle) |
| 271 { | 271 { |
| 272 LayoutBox::styleDidChange(diff, oldStyle); | 272 LayoutBox::styleDidChange(diff, oldStyle); |
| 273 | 273 |
| 274 if (isFloatingOrOutOfFlowPositioned() && oldStyle && !oldStyle->isFloating() && !oldStyle->hasOutOfFlowPosition() && parent() && parent()->isLayoutBlockFlow ()) | 274 if (isFloatingOrOutOfFlowPositioned() && oldStyle && !oldStyle->isFloating() && !oldStyle->hasOutOfFlowPosition() && parent() && parent()->isLayoutBlockFlow ()) { |
| 275 toLayoutBlock(parent())->removeAnonymousWrappersIfRequired(); | 275 toLayoutBlock(parent())->removeAnonymousWrappersIfRequired(); |
| 276 // Reparent to an adjacent anonymous block if one is available. | |
| 277 if (previousSibling() && previousSibling()->isAnonymousBlock()) | |
| 278 toLayoutBlock(parent())->moveChildTo(toLayoutBlock(previousSibling() ), this, 0, false); | |
| 279 if (nextSibling() && nextSibling()->isAnonymousBlock()) | |
| 280 toLayoutBlock(parent())->moveChildTo(toLayoutBlock(nextSibling()), t his, nextSibling()->slowFirstChild(), false); | |
| 281 } | |
| 276 | 282 |
| 277 const ComputedStyle& newStyle = styleRef(); | 283 const ComputedStyle& newStyle = styleRef(); |
| 278 | 284 |
| 279 if (oldStyle && parent()) { | 285 if (oldStyle && parent()) { |
| 280 if (oldStyle->position() != newStyle.position() && newStyle.position() ! = StaticPosition) { | 286 if (oldStyle->position() != newStyle.position() && newStyle.position() ! = StaticPosition) { |
| 281 // Remove our absolutely positioned descendants from their new conta ining block, | 287 // Remove our absolutely positioned descendants from their new conta ining block, |
| 282 // in case containingBlock() changes by the change to the position p roperty. | 288 // in case containingBlock() changes by the change to the position p roperty. |
| 283 // See styleWillChange() for other cases. | 289 // See styleWillChange() for other cases. |
| 284 if (LayoutBlock* cb = containingBlock()) | 290 if (LayoutBlock* cb = containingBlock()) |
| 285 cb->removePositionedObjects(this, NewContainingBlock); | 291 cb->removePositionedObjects(this, NewContainingBlock); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 369 startOfContinuations->invalidateDisplayItemClient(*startOfContinuations) ; | 375 startOfContinuations->invalidateDisplayItemClient(*startOfContinuations) ; |
| 370 } | 376 } |
| 371 | 377 |
| 372 void LayoutBlock::invalidateDisplayItemClients(const LayoutBoxModelObject& paint InvalidationContainer) const | 378 void LayoutBlock::invalidateDisplayItemClients(const LayoutBoxModelObject& paint InvalidationContainer) const |
| 373 { | 379 { |
| 374 LayoutBox::invalidateDisplayItemClients(paintInvalidationContainer); | 380 LayoutBox::invalidateDisplayItemClients(paintInvalidationContainer); |
| 375 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); | 381 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); |
| 376 invalidateDisplayItemClientForStartOfContinuationsIfNeeded(*this); | 382 invalidateDisplayItemClientForStartOfContinuationsIfNeeded(*this); |
| 377 } | 383 } |
| 378 | 384 |
| 385 void LayoutBlock::addAdjacentSiblingsToAnonymousBox(AdjacentSiblings siblings, L ayoutBlock* anonymousBox) | |
| 386 { | |
| 387 bool previousSiblings = siblings == PreviousSiblings; | |
| 388 LayoutObject* child = previousSiblings ? anonymousBox->previousSibling() : a nonymousBox->nextSibling(); | |
| 389 while (child && child->isFloatingOrOutOfFlowPositioned()) { | |
| 390 LayoutObject* sibling = previousSiblings ? child->previousSibling() : ch ild->nextSibling(); | |
| 391 moveChildTo(anonymousBox, child, previousSiblings ? anonymousBox->firstC hild() : 0, false); | |
| 392 child = sibling; | |
| 393 } | |
| 394 } | |
| 395 | |
| 379 void LayoutBlock::addChildIgnoringContinuation(LayoutObject* newChild, LayoutObj ect* beforeChild) | 396 void LayoutBlock::addChildIgnoringContinuation(LayoutObject* newChild, LayoutObj ect* beforeChild) |
| 380 { | 397 { |
| 381 if (beforeChild && beforeChild->parent() != this) { | 398 if (beforeChild && beforeChild->parent() != this) { |
| 382 LayoutObject* beforeChildContainer = beforeChild->parent(); | 399 LayoutObject* beforeChildContainer = beforeChild->parent(); |
| 383 while (beforeChildContainer->parent() != this) | 400 while (beforeChildContainer->parent() != this) |
| 384 beforeChildContainer = beforeChildContainer->parent(); | 401 beforeChildContainer = beforeChildContainer->parent(); |
| 385 ASSERT(beforeChildContainer); | 402 ASSERT(beforeChildContainer); |
| 386 | 403 |
| 387 if (beforeChildContainer->isAnonymous()) { | 404 if (beforeChildContainer->isAnonymous()) { |
| 388 // If the requested beforeChild is not one of our children, then thi s is because | 405 // If the requested beforeChild is not one of our children, then thi s is because |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 432 if (beforeChild && beforeChild->parent() != this) { | 449 if (beforeChild && beforeChild->parent() != this) { |
| 433 beforeChild = beforeChild->parent(); | 450 beforeChild = beforeChild->parent(); |
| 434 ASSERT(beforeChild->isAnonymousBlock()); | 451 ASSERT(beforeChild->isAnonymousBlock()); |
| 435 ASSERT(beforeChild->parent() == this); | 452 ASSERT(beforeChild->parent() == this); |
| 436 } | 453 } |
| 437 } else if (!childrenInline() && (newChild->isFloatingOrOutOfFlowPositioned() || newChild->isInline())) { | 454 } else if (!childrenInline() && (newChild->isFloatingOrOutOfFlowPositioned() || newChild->isInline())) { |
| 438 // If we're inserting an inline child but all of our children are blocks , then we have to make sure | 455 // If we're inserting an inline child but all of our children are blocks , then we have to make sure |
| 439 // it is put into an anomyous block box. We try to use an existing anony mous box if possible, otherwise | 456 // it is put into an anomyous block box. We try to use an existing anony mous box if possible, otherwise |
| 440 // a new one is created and inserted into our list of children in the ap propriate position. | 457 // a new one is created and inserted into our list of children in the ap propriate position. |
| 441 LayoutObject* afterChild = beforeChild ? beforeChild->previousSibling() : lastChild(); | 458 LayoutObject* afterChild = beforeChild ? beforeChild->previousSibling() : lastChild(); |
| 442 | |
| 443 if (afterChild && afterChild->isAnonymousBlock()) { | 459 if (afterChild && afterChild->isAnonymousBlock()) { |
| 444 afterChild->addChild(newChild); | 460 afterChild->addChild(newChild); |
| 445 return; | 461 return; |
| 446 } | 462 } |
| 447 | 463 |
| 464 // If we are a block that allows inline children and the child we're add ing means that | |
|
mstensho (USE GERRIT)
2015/09/07 14:01:47
But we are not a block that allows inline children
| |
| 465 // we can now treat all children as inline without the need for anonymou s blocks, then do that. | |
| 466 LayoutObject* nextChild = firstChild(); | |
| 467 bool childrenAllInline = !isFlexibleBoxIncludingDeprecated() && !isLayou tGrid(); | |
| 468 while (nextChild && childrenAllInline) { | |
| 469 if (!nextChild->isFloatingOrOutOfFlowPositioned()) { | |
| 470 childrenAllInline = false; | |
| 471 break; | |
| 472 } | |
| 473 nextChild = nextChild->nextSibling(); | |
| 474 } | |
| 475 if (childrenAllInline) { | |
| 476 LayoutBox::addChild(newChild, beforeChild); | |
| 477 setChildrenInline(true); | |
| 478 return; | |
| 479 } | |
| 480 | |
| 448 if (newChild->isInline()) { | 481 if (newChild->isInline()) { |
| 449 // No suitable existing anonymous box - create a new one. | 482 // No suitable existing anonymous box - create a new one. |
| 450 LayoutBlock* newBox = createAnonymousBlock(); | 483 LayoutBlock* newBox = createAnonymousBlock(); |
| 451 LayoutBox::addChild(newBox, beforeChild); | 484 LayoutBox::addChild(newBox, beforeChild); |
| 485 // Reparent adjacent inline siblings to the new box. | |
| 486 addAdjacentSiblingsToAnonymousBox(PreviousSiblings, newBox); | |
| 452 newBox->addChild(newChild); | 487 newBox->addChild(newChild); |
| 488 addAdjacentSiblingsToAnonymousBox(NextSiblings, newBox); | |
| 453 return; | 489 return; |
| 454 } | 490 } |
| 455 } | 491 } |
| 456 | 492 |
| 457 LayoutBox::addChild(newChild, beforeChild); | 493 LayoutBox::addChild(newChild, beforeChild); |
| 458 | 494 |
| 459 if (madeBoxesNonInline && parent() && isAnonymousBlock() && parent()->isLayo utBlock()) | 495 if (madeBoxesNonInline && parent() && isAnonymousBlock() && parent()->isLayo utBlock()) |
| 460 toLayoutBlock(parent())->removeLeftoverAnonymousBlock(this); | 496 toLayoutBlock(parent())->removeLeftoverAnonymousBlock(this); |
| 461 // this object may be dead here | 497 // this object may be dead here |
| 462 } | 498 } |
| (...skipping 2462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2925 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const | 2961 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const |
| 2926 { | 2962 { |
| 2927 showLayoutObject(); | 2963 showLayoutObject(); |
| 2928 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) | 2964 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) |
| 2929 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); | 2965 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); |
| 2930 } | 2966 } |
| 2931 | 2967 |
| 2932 #endif | 2968 #endif |
| 2933 | 2969 |
| 2934 } // namespace blink | 2970 } // namespace blink |
| OLD | NEW |