Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(685)

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutBlock.cpp

Issue 1977823002: Move makeChildrenNonInline() and childBecameNonInline() to LayoutBlockFlow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 LayoutBlock* newBox = createAnonymousBlock(); 367 LayoutBlock* newBox = createAnonymousBlock();
368 LayoutBox::addChild(newBox, beforeChild); 368 LayoutBox::addChild(newBox, beforeChild);
369 newBox->addChild(newChild); 369 newBox->addChild(newChild);
370 return; 370 return;
371 } 371 }
372 } 372 }
373 373
374 LayoutBox::addChild(newChild, beforeChild); 374 LayoutBox::addChild(newChild, beforeChild);
375 } 375 }
376 376
377 static void getInlineRun(LayoutObject* start, LayoutObject* boundary,
378 LayoutObject*& inlineRunStart,
379 LayoutObject*& inlineRunEnd)
380 {
381 // Beginning at |start| we find the largest contiguous run of inlines that
382 // we can. We denote the run with start and end points, |inlineRunStart|
383 // and |inlineRunEnd|. Note that these two values may be the same if
384 // we encounter only one inline.
385 //
386 // We skip any non-inlines we encounter as long as we haven't found any
387 // inlines yet.
388 //
389 // |boundary| indicates a non-inclusive boundary point. Regardless of wheth er |boundary|
390 // is inline or not, we will not include it in a run with inlines before it. It's as though we encountered
391 // a non-inline.
392
393 // Start by skipping as many non-inlines as we can.
394 LayoutObject * curr = start;
395 bool sawInline;
396 do {
397 while (curr && !(curr->isInline() || curr->isFloatingOrOutOfFlowPosition ed()))
398 curr = curr->nextSibling();
399
400 inlineRunStart = inlineRunEnd = curr;
401
402 if (!curr)
403 return; // No more inline children to be found.
404
405 sawInline = curr->isInline();
406
407 curr = curr->nextSibling();
408 while (curr && (curr->isInline() || curr->isFloatingOrOutOfFlowPositione d()) && (curr != boundary)) {
409 inlineRunEnd = curr;
410 if (curr->isInline())
411 sawInline = true;
412 curr = curr->nextSibling();
413 }
414 } while (!sawInline);
415 }
416
417 void LayoutBlock::deleteLineBoxTree() 377 void LayoutBlock::deleteLineBoxTree()
418 { 378 {
419 ASSERT(!m_lineBoxes.firstLineBox()); 379 ASSERT(!m_lineBoxes.firstLineBox());
420 } 380 }
421 381
422 void LayoutBlock::makeChildrenNonInline(LayoutObject *insertionPoint)
423 {
424 // makeChildrenNonInline takes a block whose children are *all* inline and i t
425 // makes sure that inline children are coalesced under anonymous
426 // blocks. If |insertionPoint| is defined, then it represents the insertion point for
427 // the new block child that is causing us to have to wrap all the inlines. This
428 // means that we cannot coalesce inlines before |insertionPoint| with inline s following
429 // |insertionPoint|, because the new child is going to be inserted in betwee n the inlines,
430 // splitting them.
431 ASSERT(isInlineBlockOrInlineTable() || !isInline());
432 ASSERT(!insertionPoint || insertionPoint->parent() == this);
433
434 setChildrenInline(false);
435
436 LayoutObject* child = firstChild();
437 if (!child)
438 return;
439
440 deleteLineBoxTree();
441
442 while (child) {
443 LayoutObject* inlineRunStart;
444 LayoutObject* inlineRunEnd;
445 getInlineRun(child, insertionPoint, inlineRunStart, inlineRunEnd);
446
447 if (!inlineRunStart)
448 break;
449
450 child = inlineRunEnd->nextSibling();
451
452 LayoutBlock* block = createAnonymousBlock();
453 children()->insertChildNode(this, block, inlineRunStart);
454 moveChildrenTo(block, inlineRunStart, child);
455 }
456
457 #if ENABLE(ASSERT)
458 for (LayoutObject *c = firstChild(); c; c = c->nextSibling())
459 ASSERT(!c->isInline());
460 #endif
461
462 setShouldDoFullPaintInvalidation();
463 }
464
465 void LayoutBlock::removeLeftoverAnonymousBlock(LayoutBlock* child) 382 void LayoutBlock::removeLeftoverAnonymousBlock(LayoutBlock* child)
466 { 383 {
467 ASSERT(child->isAnonymousBlock()); 384 ASSERT(child->isAnonymousBlock());
468 ASSERT(!child->childrenInline()); 385 ASSERT(!child->childrenInline());
469 ASSERT(child->parent() == this); 386 ASSERT(child->parent() == this);
470 387
471 if (child->continuation()) 388 if (child->continuation())
472 return; 389 return;
473 390
474 // Promote all the leftover anonymous block's children (to become children o f this block 391 // Promote all the leftover anonymous block's children (to become children o f this block
(...skipping 1300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1775 { 1692 {
1776 if (childrenInline()) 1693 if (childrenInline())
1777 return toLayoutBlockFlow(this); 1694 return toLayoutBlockFlow(this);
1778 for (LayoutObject* child = firstChild(); child && !child->isFloatingOrOutOfF lowPositioned() && child->isLayoutBlockFlow(); child = toLayoutBlock(child)->fir stChild()) { 1695 for (LayoutObject* child = firstChild(); child && !child->isFloatingOrOutOfF lowPositioned() && child->isLayoutBlockFlow(); child = toLayoutBlock(child)->fir stChild()) {
1779 if (child->childrenInline()) 1696 if (child->childrenInline())
1780 return toLayoutBlockFlow(child); 1697 return toLayoutBlockFlow(child);
1781 } 1698 }
1782 return nullptr; 1699 return nullptr;
1783 } 1700 }
1784 1701
1785 void LayoutBlock::childBecameNonInline(LayoutObject*)
1786 {
1787 makeChildrenNonInline();
1788 if (isAnonymousBlock() && parent() && parent()->isLayoutBlock())
1789 toLayoutBlock(parent())->removeLeftoverAnonymousBlock(this);
1790 // |this| may be dead here
1791 }
1792
1793 void LayoutBlock::updateHitTestResult(HitTestResult& result, const LayoutPoint& point) 1702 void LayoutBlock::updateHitTestResult(HitTestResult& result, const LayoutPoint& point)
1794 { 1703 {
1795 if (result.innerNode()) 1704 if (result.innerNode())
1796 return; 1705 return;
1797 1706
1798 if (Node* n = nodeForHitTest()) 1707 if (Node* n = nodeForHitTest())
1799 result.setNodeAndPosition(n, point); 1708 result.setNodeAndPosition(n, point);
1800 } 1709 }
1801 1710
1802 // An inline-block uses its inlineBox as the inlineBoxWrapper, 1711 // An inline-block uses its inlineBox as the inlineBoxWrapper,
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
2079 for (TrackedLayoutBoxListHashSet::const_iterator it = positionedDescenda ntSet->begin(); it != end; ++it) { 1988 for (TrackedLayoutBoxListHashSet::const_iterator it = positionedDescenda ntSet->begin(); it != end; ++it) {
2080 LayoutBox* currBox = *it; 1989 LayoutBox* currBox = *it;
2081 ASSERT(!currBox->needsLayout()); 1990 ASSERT(!currBox->needsLayout());
2082 } 1991 }
2083 } 1992 }
2084 } 1993 }
2085 1994
2086 #endif 1995 #endif
2087 1996
2088 } // namespace blink 1997 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBlock.h ('k') | third_party/WebKit/Source/core/layout/LayoutBlockFlow.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698