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 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 370 } | 370 } |
| 371 setHasOverflowClip(shouldClipOverflow); | 371 setHasOverflowClip(shouldClipOverflow); |
| 372 } | 372 } |
| 373 | 373 |
| 374 bool LayoutBlock::allowsOverflowClip() const | 374 bool LayoutBlock::allowsOverflowClip() const |
| 375 { | 375 { |
| 376 // If overflow has been propagated to the viewport, it has no effect here. | 376 // If overflow has been propagated to the viewport, it has no effect here. |
| 377 return node() != document().viewportDefiningElement(); | 377 return node() != document().viewportDefiningElement(); |
| 378 } | 378 } |
| 379 | 379 |
| 380 void LayoutBlock::addChildBeforeDescendant(LayoutObject* newChild, LayoutObject* beforeDescendant) | |
| 381 { | |
| 382 ASSERT(beforeDescendant->parent() != this); | |
| 383 LayoutObject* beforeDescendantContainer = beforeDescendant->parent(); | |
| 384 while (beforeDescendantContainer->parent() != this) | |
| 385 beforeDescendantContainer = beforeDescendantContainer->parent(); | |
| 386 ASSERT(beforeDescendantContainer); | |
| 387 | |
| 388 // We really can't go on if what we have found isn't anonymous. We're not su pposed to use some | |
| 389 // random non-anonymous object and put the child there. That's a recipe for security issues. | |
| 390 RELEASE_ASSERT(beforeDescendantContainer->isAnonymous()); | |
|
mstensho (USE GERRIT)
2016/05/11 21:06:00
Here's a difference. We previously allowed this si
eae
2016/05/11 21:10:11
Yay!
| |
| 391 | |
| 392 // If the requested insertion point is not one of our children, then this is because | |
| 393 // there is an anonymous container within this object that contains the befo reDescendant. | |
| 394 if (beforeDescendantContainer->isAnonymousBlock() | |
| 395 // Full screen layoutObjects and full screen placeholders act as anonymo us blocks, not tables: | |
| 396 || beforeDescendantContainer->isLayoutFullScreen() | |
| 397 || beforeDescendantContainer->isLayoutFullScreenPlaceholder()) { | |
| 398 // Insert the child into the anonymous block box instead of here. | |
| 399 if (newChild->isInline() || newChild->isFloatingOrOutOfFlowPositioned() || beforeDescendant->parent()->slowFirstChild() != beforeDescendant) | |
| 400 beforeDescendant->parent()->addChild(newChild, beforeDescendant); | |
| 401 else | |
| 402 addChild(newChild, beforeDescendant->parent()); | |
| 403 return; | |
| 404 } | |
| 405 | |
| 406 ASSERT(beforeDescendantContainer->isTable()); | |
| 407 if (newChild->isTablePart()) { | |
| 408 // Insert into the anonymous table. | |
| 409 beforeDescendantContainer->addChild(newChild, beforeDescendant); | |
| 410 return; | |
| 411 } | |
| 412 | |
| 413 LayoutObject* beforeChild = splitAnonymousBoxesAroundChild(beforeDescendant) ; | |
| 414 | |
| 415 ASSERT(beforeChild->parent() == this); | |
| 416 if (beforeChild->parent() != this) { | |
| 417 // We should never reach here. If we do, we need to use the | |
| 418 // safe fallback to use the topmost beforeChild container. | |
| 419 beforeChild = beforeDescendantContainer; | |
| 420 } | |
| 421 | |
| 422 addChild(newChild, beforeChild); | |
| 423 } | |
| 424 | |
| 380 void LayoutBlock::addChild(LayoutObject* newChild, LayoutObject* beforeChild) | 425 void LayoutBlock::addChild(LayoutObject* newChild, LayoutObject* beforeChild) |
| 381 { | 426 { |
| 382 if (beforeChild && beforeChild->parent() != this) { | 427 if (beforeChild && beforeChild->parent() != this) { |
| 383 LayoutObject* beforeChildContainer = beforeChild->parent(); | 428 addChildBeforeDescendant(newChild, beforeChild); |
| 384 while (beforeChildContainer->parent() != this) | 429 return; |
| 385 beforeChildContainer = beforeChildContainer->parent(); | |
| 386 ASSERT(beforeChildContainer); | |
| 387 | |
| 388 if (beforeChildContainer->isAnonymous()) { | |
| 389 // If the requested beforeChild is not one of our children, then thi s is because | |
| 390 // there is an anonymous container within this object that contains the beforeChild. | |
| 391 LayoutObject* beforeChildAnonymousContainer = beforeChildContainer; | |
| 392 if (beforeChildAnonymousContainer->isAnonymousBlock() | |
| 393 // Full screen layoutObjects and full screen placeholders act as anonymous blocks, not tables: | |
| 394 || beforeChildAnonymousContainer->isLayoutFullScreen() | |
| 395 || beforeChildAnonymousContainer->isLayoutFullScreenPlaceholder( ) | |
| 396 ) { | |
| 397 // Insert the child into the anonymous block box instead of here . | |
| 398 if (newChild->isInline() || newChild->isFloatingOrOutOfFlowPosit ioned() || beforeChild->parent()->slowFirstChild() != beforeChild) | |
| 399 beforeChild->parent()->addChild(newChild, beforeChild); | |
| 400 else | |
| 401 addChild(newChild, beforeChild->parent()); | |
| 402 return; | |
| 403 } | |
| 404 | |
| 405 ASSERT(beforeChildAnonymousContainer->isTable()); | |
| 406 if (newChild->isTablePart()) { | |
| 407 // Insert into the anonymous table. | |
| 408 beforeChildAnonymousContainer->addChild(newChild, beforeChild); | |
| 409 return; | |
| 410 } | |
| 411 | |
| 412 beforeChild = splitAnonymousBoxesAroundChild(beforeChild); | |
| 413 | |
| 414 ASSERT(beforeChild->parent() == this); | |
| 415 if (beforeChild->parent() != this) { | |
| 416 // We should never reach here. If we do, we need to use the | |
| 417 // safe fallback to use the topmost beforeChild container. | |
| 418 beforeChild = beforeChildContainer; | |
| 419 } | |
| 420 } | |
| 421 } | 430 } |
| 422 | 431 |
| 423 bool madeBoxesNonInline = false; | 432 bool madeBoxesNonInline = false; |
| 424 | 433 |
| 425 // A block has to either have all of its children inline, or all of its chil dren as blocks. | 434 // A block has to either have all of its children inline, or all of its chil dren as blocks. |
| 426 // So, if our children are currently inline and a block child has to be inse rted, we move all our | 435 // So, if our children are currently inline and a block child has to be inse rted, we move all our |
| 427 // inline children into anonymous block boxes. | 436 // inline children into anonymous block boxes. |
| 428 if (childrenInline() && !newChild->isInline() && !newChild->isFloatingOrOutO fFlowPositioned()) { | 437 if (childrenInline() && !newChild->isInline() && !newChild->isFloatingOrOutO fFlowPositioned()) { |
| 429 // This is a block with inline content. Wrap the inline content in anony mous blocks. | 438 // This is a block with inline content. Wrap the inline content in anony mous blocks. |
| 430 makeChildrenNonInline(beforeChild); | 439 makeChildrenNonInline(beforeChild); |
| (...skipping 1822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2253 for (TrackedLayoutBoxListHashSet::const_iterator it = positionedDescenda ntSet->begin(); it != end; ++it) { | 2262 for (TrackedLayoutBoxListHashSet::const_iterator it = positionedDescenda ntSet->begin(); it != end; ++it) { |
| 2254 LayoutBox* currBox = *it; | 2263 LayoutBox* currBox = *it; |
| 2255 ASSERT(!currBox->needsLayout()); | 2264 ASSERT(!currBox->needsLayout()); |
| 2256 } | 2265 } |
| 2257 } | 2266 } |
| 2258 } | 2267 } |
| 2259 | 2268 |
| 2260 #endif | 2269 #endif |
| 2261 | 2270 |
| 2262 } // namespace blink | 2271 } // namespace blink |
| OLD | NEW |