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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
279 if (beforeChild && beforeChild->parent() != this) { | 279 if (beforeChild && beforeChild->parent() != this) { |
280 RenderObject* beforeChildContainer = beforeChild->parent(); | 280 RenderObject* beforeChildContainer = beforeChild->parent(); |
281 ASSERT(beforeChildContainer->parent() == this); | 281 ASSERT(beforeChildContainer->parent() == this); |
282 ASSERT(beforeChildContainer->isAnonymousBlock()); | 282 ASSERT(beforeChildContainer->isAnonymousBlock()); |
283 addChild(newChild, beforeChildContainer); | 283 addChild(newChild, beforeChildContainer); |
284 return; | 284 return; |
285 } | 285 } |
286 | 286 |
287 // TODO(ojan): What should we do in this case? For now we insert an anonymou s paragraph. | 287 // TODO(ojan): What should we do in this case? For now we insert an anonymou s paragraph. |
288 // This only happens if we have a text node directly inside a non-paragraph. | 288 // This only happens if we have a text node directly inside a non-paragraph. |
289 if (!childrenInline() && newChild->isInline()) { | 289 if (!isRenderParagraph() && newChild->isInline()) { |
290 RenderBlock* newBox = createAnonymousBlock(); | 290 RenderBlock* newBox = createAnonymousBlock(); |
291 ASSERT(newBox->childrenInline()); | 291 ASSERT(newBox->isRenderParagraph()); |
292 RenderBox::addChild(newBox, beforeChild); | 292 RenderBox::addChild(newBox, beforeChild); |
293 newBox->addChild(newChild); | 293 newBox->addChild(newChild); |
294 return; | 294 return; |
295 } | 295 } |
296 | 296 |
297 RenderBox::addChild(newChild, beforeChild); | 297 RenderBox::addChild(newChild, beforeChild); |
298 } | 298 } |
299 | 299 |
300 void RenderBlock::addChild(RenderObject* newChild, RenderObject* beforeChild) | 300 void RenderBlock::addChild(RenderObject* newChild, RenderObject* beforeChild) |
301 { | 301 { |
302 addChildIgnoringAnonymousColumnBlocks(newChild, beforeChild); | 302 addChildIgnoringAnonymousColumnBlocks(newChild, beforeChild); |
303 } | 303 } |
304 | 304 |
305 void RenderBlock::deleteLineBoxTree() | 305 void RenderBlock::deleteLineBoxTree() |
306 { | 306 { |
307 ASSERT(!m_lineBoxes.firstLineBox()); | 307 ASSERT(!m_lineBoxes.firstLineBox()); |
308 } | 308 } |
309 | 309 |
310 void RenderBlock::removeChild(RenderObject* oldChild) | 310 void RenderBlock::removeChild(RenderObject* oldChild) |
311 { | 311 { |
312 RenderBox::removeChild(oldChild); | 312 RenderBox::removeChild(oldChild); |
313 | 313 |
314 // No need to waste time deleting the line box tree if we're getting destroy ed. | 314 // No need to waste time deleting the line box tree if we're getting destroy ed. |
315 if (documentBeingDestroyed()) | 315 if (documentBeingDestroyed()) |
316 return; | 316 return; |
317 | 317 |
318 // If this was our last child be sure to clear out our line boxes. | 318 // If this was our last child be sure to clear out our line boxes. |
319 if (!firstChild() && childrenInline()) | 319 if (!firstChild() && isRenderParagraph()) |
320 deleteLineBoxTree(); | 320 deleteLineBoxTree(); |
321 } | 321 } |
322 | 322 |
323 void RenderBlock::startDelayUpdateScrollInfo() | 323 void RenderBlock::startDelayUpdateScrollInfo() |
324 { | 324 { |
325 if (gDelayUpdateScrollInfo == 0) { | 325 if (gDelayUpdateScrollInfo == 0) { |
326 ASSERT(!gDelayedUpdateScrollInfoSet); | 326 ASSERT(!gDelayedUpdateScrollInfoSet); |
327 gDelayedUpdateScrollInfoSet = new DelayedUpdateScrollInfoSet; | 327 gDelayedUpdateScrollInfoSet = new DelayedUpdateScrollInfoSet; |
328 } | 328 } |
329 ASSERT(gDelayedUpdateScrollInfoSet); | 329 ASSERT(gDelayedUpdateScrollInfoSet); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
393 } | 393 } |
394 | 394 |
395 void RenderBlock::layoutBlock(bool) | 395 void RenderBlock::layoutBlock(bool) |
396 { | 396 { |
397 ASSERT_NOT_REACHED(); | 397 ASSERT_NOT_REACHED(); |
398 clearNeedsLayout(); | 398 clearNeedsLayout(); |
399 } | 399 } |
400 | 400 |
401 void RenderBlock::addOverflowFromChildren() | 401 void RenderBlock::addOverflowFromChildren() |
402 { | 402 { |
403 if (childrenInline()) | 403 if (isRenderParagraph()) |
404 toRenderBlockFlow(this)->addOverflowFromInlineChildren(); | 404 toRenderBlockFlow(this)->addOverflowFromInlineChildren(); |
405 else | 405 else |
406 addOverflowFromBlockChildren(); | 406 addOverflowFromBlockChildren(); |
407 } | 407 } |
408 | 408 |
409 void RenderBlock::computeOverflow(LayoutUnit oldClientAfterEdge, bool) | 409 void RenderBlock::computeOverflow(LayoutUnit oldClientAfterEdge, bool) |
410 { | 410 { |
411 m_overflow.clear(); | 411 m_overflow.clear(); |
412 | 412 |
413 // Add overflow from children. | 413 // Add overflow from children. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
465 if (relayoutChildren || (child->hasRelativeLogicalHeight() && !isRenderView( ))) | 465 if (relayoutChildren || (child->hasRelativeLogicalHeight() && !isRenderView( ))) |
466 child->setChildNeedsLayout(MarkOnlyThis); | 466 child->setChildNeedsLayout(MarkOnlyThis); |
467 | 467 |
468 // If relayoutChildren is set and the child has percentage padding or an emb edded content box, we also need to invalidate the childs pref widths. | 468 // If relayoutChildren is set and the child has percentage padding or an emb edded content box, we also need to invalidate the childs pref widths. |
469 if (relayoutChildren && child->needsPreferredWidthsRecalculation()) | 469 if (relayoutChildren && child->needsPreferredWidthsRecalculation()) |
470 child->setPreferredLogicalWidthsDirty(MarkOnlyThis); | 470 child->setPreferredLogicalWidthsDirty(MarkOnlyThis); |
471 } | 471 } |
472 | 472 |
473 void RenderBlock::simplifiedNormalFlowLayout() | 473 void RenderBlock::simplifiedNormalFlowLayout() |
474 { | 474 { |
475 if (childrenInline()) { | 475 if (isRenderParagraph()) { |
476 ListHashSet<RootInlineBox*> lineBoxes; | 476 ListHashSet<RootInlineBox*> lineBoxes; |
477 for (InlineWalker walker(this); !walker.atEnd(); walker.advance()) { | 477 for (InlineWalker walker(this); !walker.atEnd(); walker.advance()) { |
478 RenderObject* o = walker.current(); | 478 RenderObject* o = walker.current(); |
479 if (!o->isOutOfFlowPositioned() && o->isReplaced()) { | 479 if (!o->isOutOfFlowPositioned() && o->isReplaced()) { |
480 o->layoutIfNeeded(); | 480 o->layoutIfNeeded(); |
481 if (toRenderBox(o)->inlineBoxWrapper()) { | 481 if (toRenderBox(o)->inlineBoxWrapper()) { |
482 RootInlineBox& box = toRenderBox(o)->inlineBoxWrapper()->roo t(); | 482 RootInlineBox& box = toRenderBox(o)->inlineBoxWrapper()->roo t(); |
483 lineBoxes.add(&box); | 483 lineBoxes.add(&box); |
484 } | 484 } |
485 } else if (o->isText() || (o->isRenderInline() && !walker.atEndOfInl ine())) { | 485 } else if (o->isText() || (o->isRenderInline() && !walker.atEndOfInl ine())) { |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
650 } | 650 } |
651 | 651 |
652 void RenderBlock::paintContents(PaintInfo& paintInfo, const LayoutPoint& paintOf fset) | 652 void RenderBlock::paintContents(PaintInfo& paintInfo, const LayoutPoint& paintOf fset) |
653 { | 653 { |
654 // Avoid painting descendants of the root element when stylesheets haven't l oaded. This eliminates FOUC. | 654 // Avoid painting descendants of the root element when stylesheets haven't l oaded. This eliminates FOUC. |
655 // It's ok not to draw, because later on, when all the stylesheets do load, styleResolverChanged() on the Document | 655 // It's ok not to draw, because later on, when all the stylesheets do load, styleResolverChanged() on the Document |
656 // will do a full paint invalidation. | 656 // will do a full paint invalidation. |
657 if (document().didLayoutWithPendingStylesheets() && !isRenderView()) | 657 if (document().didLayoutWithPendingStylesheets() && !isRenderView()) |
658 return; | 658 return; |
659 | 659 |
660 if (childrenInline()) | 660 if (isRenderParagraph()) |
661 m_lineBoxes.paint(this, paintInfo, paintOffset); | 661 m_lineBoxes.paint(this, paintInfo, paintOffset); |
662 else { | 662 else { |
663 PaintPhase newPhase = (paintInfo.phase == PaintPhaseChildOutlines) ? Pai ntPhaseOutline : paintInfo.phase; | 663 PaintPhase newPhase = (paintInfo.phase == PaintPhaseChildOutlines) ? Pai ntPhaseOutline : paintInfo.phase; |
664 newPhase = (newPhase == PaintPhaseChildBlockBackgrounds) ? PaintPhaseChi ldBlockBackground : newPhase; | 664 newPhase = (newPhase == PaintPhaseChildBlockBackgrounds) ? PaintPhaseChi ldBlockBackground : newPhase; |
665 | 665 |
666 // We don't paint our own background, but we do let the kids paint their backgrounds. | 666 // We don't paint our own background, but we do let the kids paint their backgrounds. |
667 PaintInfo paintInfoForChild(paintInfo); | 667 PaintInfo paintInfoForChild(paintInfo); |
668 paintInfoForChild.phase = newPhase; | 668 paintInfoForChild.phase = newPhase; |
669 paintInfoForChild.updatePaintingRootForChildren(this); | 669 paintInfoForChild.updatePaintingRootForChildren(this); |
670 paintChildren(paintInfoForChild, paintOffset); | 670 paintChildren(paintInfoForChild, paintOffset); |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
913 return result; | 913 return result; |
914 | 914 |
915 if (hasTransform()) { | 915 if (hasTransform()) { |
916 // FIXME: We should learn how to gap fill multiple columns and transform s eventually. | 916 // FIXME: We should learn how to gap fill multiple columns and transform s eventually. |
917 lastLogicalTop = rootBlock->blockDirectionOffset(offsetFromRootBlock) + logicalHeight(); | 917 lastLogicalTop = rootBlock->blockDirectionOffset(offsetFromRootBlock) + logicalHeight(); |
918 lastLogicalLeft = logicalLeftSelectionOffset(rootBlock, logicalHeight()) ; | 918 lastLogicalLeft = logicalLeftSelectionOffset(rootBlock, logicalHeight()) ; |
919 lastLogicalRight = logicalRightSelectionOffset(rootBlock, logicalHeight( )); | 919 lastLogicalRight = logicalRightSelectionOffset(rootBlock, logicalHeight( )); |
920 return result; | 920 return result; |
921 } | 921 } |
922 | 922 |
923 if (childrenInline()) | 923 if (isRenderParagraph()) |
924 result = toRenderBlockFlow(this)->inlineSelectionGaps(rootBlock, rootBlo ckPhysicalPosition, offsetFromRootBlock, lastLogicalTop, lastLogicalLeft, lastLo gicalRight, paintInfo); | 924 result = toRenderBlockFlow(this)->inlineSelectionGaps(rootBlock, rootBlo ckPhysicalPosition, offsetFromRootBlock, lastLogicalTop, lastLogicalLeft, lastLo gicalRight, paintInfo); |
925 else | 925 else |
926 result = blockSelectionGaps(rootBlock, rootBlockPhysicalPosition, offset FromRootBlock, lastLogicalTop, lastLogicalLeft, lastLogicalRight, paintInfo); | 926 result = blockSelectionGaps(rootBlock, rootBlockPhysicalPosition, offset FromRootBlock, lastLogicalTop, lastLogicalLeft, lastLogicalRight, paintInfo); |
927 | 927 |
928 // Go ahead and fill the vertical gap all the way to the bottom of our block if the selection extends past our block. | 928 // Go ahead and fill the vertical gap all the way to the bottom of our block if the selection extends past our block. |
929 if (rootBlock == this && (selectionState() != SelectionBoth && selectionStat e() != SelectionEnd)) | 929 if (rootBlock == this && (selectionState() != SelectionBoth && selectionStat e() != SelectionEnd)) |
930 result.uniteCenter(blockSelectionGap(rootBlock, rootBlockPhysicalPositio n, offsetFromRootBlock, lastLogicalTop, lastLogicalLeft, lastLogicalRight, | 930 result.uniteCenter(blockSelectionGap(rootBlock, rootBlockPhysicalPositio n, offsetFromRootBlock, lastLogicalTop, lastLogicalLeft, lastLogicalRight, |
931 logicalHeight(), paintInfo)); | 931 logicalHeight(), paintInfo)); |
932 return result; | 932 return result; |
933 } | 933 } |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1412 if (!result.addNodeToRectBasedTestResult(node(), request, locationIn Container, boundsRect)) | 1412 if (!result.addNodeToRectBasedTestResult(node(), request, locationIn Container, boundsRect)) |
1413 return true; | 1413 return true; |
1414 } | 1414 } |
1415 } | 1415 } |
1416 | 1416 |
1417 return false; | 1417 return false; |
1418 } | 1418 } |
1419 | 1419 |
1420 bool RenderBlock::hitTestContents(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulat edOffset, HitTestAction hitTestAction) | 1420 bool RenderBlock::hitTestContents(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulat edOffset, HitTestAction hitTestAction) |
1421 { | 1421 { |
1422 if (childrenInline()) { | 1422 if (isRenderParagraph()) { |
1423 // We have to hit-test our line boxes. | 1423 // We have to hit-test our line boxes. |
1424 if (m_lineBoxes.hitTest(this, request, result, locationInContainer, accu mulatedOffset, hitTestAction)) | 1424 if (m_lineBoxes.hitTest(this, request, result, locationInContainer, accu mulatedOffset, hitTestAction)) |
1425 return true; | 1425 return true; |
1426 } else { | 1426 } else { |
1427 // Hit test our children. | 1427 // Hit test our children. |
1428 HitTestAction childHitTest = hitTestAction; | 1428 HitTestAction childHitTest = hitTestAction; |
1429 if (hitTestAction == HitTestChildBlockBackgrounds) | 1429 if (hitTestAction == HitTestChildBlockBackgrounds) |
1430 childHitTest = HitTestChildBlockBackground; | 1430 childHitTest = HitTestChildBlockBackground; |
1431 for (RenderBox* child = lastChildBox(); child; child = child->previousSi blingBox()) { | 1431 for (RenderBox* child = lastChildBox(); child; child = child->previousSi blingBox()) { |
1432 if (!child->hasSelfPaintingLayer() && child->nodeAtPoint(request, re sult, locationInContainer, accumulatedOffset, childHitTest)) | 1432 if (!child->hasSelfPaintingLayer() && child->nodeAtPoint(request, re sult, locationInContainer, accumulatedOffset, childHitTest)) |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1490 // Otherwise return before or after the child, depending on if the click was to the logical left or logical right of the child | 1490 // Otherwise return before or after the child, depending on if the click was to the logical left or logical right of the child |
1491 LayoutUnit childMiddle = parent->logicalWidthForChild(child) / 2; | 1491 LayoutUnit childMiddle = parent->logicalWidthForChild(child) / 2; |
1492 LayoutUnit logicalLeft = pointInChildCoordinates.x(); | 1492 LayoutUnit logicalLeft = pointInChildCoordinates.x(); |
1493 if (logicalLeft < childMiddle) | 1493 if (logicalLeft < childMiddle) |
1494 return ancestor->createPositionWithAffinity(childNode->nodeIndex(), DOWN STREAM); | 1494 return ancestor->createPositionWithAffinity(childNode->nodeIndex(), DOWN STREAM); |
1495 return ancestor->createPositionWithAffinity(childNode->nodeIndex() + 1, UPST REAM); | 1495 return ancestor->createPositionWithAffinity(childNode->nodeIndex() + 1, UPST REAM); |
1496 } | 1496 } |
1497 | 1497 |
1498 PositionWithAffinity RenderBlock::positionForPointWithInlineChildren(const Layou tPoint& pointInLogicalContents) | 1498 PositionWithAffinity RenderBlock::positionForPointWithInlineChildren(const Layou tPoint& pointInLogicalContents) |
1499 { | 1499 { |
1500 ASSERT(childrenInline()); | 1500 ASSERT(isRenderParagraph()); |
1501 | 1501 |
1502 if (!firstRootBox()) | 1502 if (!firstRootBox()) |
1503 return createPositionWithAffinity(0, DOWNSTREAM); | 1503 return createPositionWithAffinity(0, DOWNSTREAM); |
1504 | 1504 |
1505 // look for the closest line box in the root box which is at the passed-in y coordinate | 1505 // look for the closest line box in the root box which is at the passed-in y coordinate |
1506 InlineBox* closestBox = 0; | 1506 InlineBox* closestBox = 0; |
1507 RootInlineBox* firstRootBoxWithChildren = 0; | 1507 RootInlineBox* firstRootBoxWithChildren = 0; |
1508 RootInlineBox* lastRootBoxWithChildren = 0; | 1508 RootInlineBox* lastRootBoxWithChildren = 0; |
1509 for (RootInlineBox* root = firstRootBox(); root; root = root->nextRootBox()) { | 1509 for (RootInlineBox* root = firstRootBox(); root; root = root->nextRootBox()) { |
1510 if (!root->firstLeafChild()) | 1510 if (!root->firstLeafChild()) |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1586 if (pointLogicalTop < 0) | 1586 if (pointLogicalTop < 0) |
1587 return createPositionWithAffinity(caretMinOffset(), DOWNSTREAM); | 1587 return createPositionWithAffinity(caretMinOffset(), DOWNSTREAM); |
1588 if (pointLogicalTop >= logicalHeight()) | 1588 if (pointLogicalTop >= logicalHeight()) |
1589 return createPositionWithAffinity(caretMaxOffset(), DOWNSTREAM); | 1589 return createPositionWithAffinity(caretMaxOffset(), DOWNSTREAM); |
1590 } | 1590 } |
1591 | 1591 |
1592 LayoutPoint pointInContents = point; | 1592 LayoutPoint pointInContents = point; |
1593 offsetForContents(pointInContents); | 1593 offsetForContents(pointInContents); |
1594 LayoutPoint pointInLogicalContents(pointInContents); | 1594 LayoutPoint pointInLogicalContents(pointInContents); |
1595 | 1595 |
1596 if (childrenInline()) | 1596 if (isRenderParagraph()) |
1597 return positionForPointWithInlineChildren(pointInLogicalContents); | 1597 return positionForPointWithInlineChildren(pointInLogicalContents); |
1598 | 1598 |
1599 RenderBox* lastCandidateBox = lastChildBox(); | 1599 RenderBox* lastCandidateBox = lastChildBox(); |
1600 while (lastCandidateBox && !isChildHitTestCandidate(lastCandidateBox)) | 1600 while (lastCandidateBox && !isChildHitTestCandidate(lastCandidateBox)) |
1601 lastCandidateBox = lastCandidateBox->previousSiblingBox(); | 1601 lastCandidateBox = lastCandidateBox->previousSiblingBox(); |
1602 | 1602 |
1603 if (lastCandidateBox) { | 1603 if (lastCandidateBox) { |
1604 if (pointInLogicalContents.y() > logicalTopForChild(lastCandidateBox) | 1604 if (pointInLogicalContents.y() > logicalTopForChild(lastCandidateBox) |
1605 || (pointInLogicalContents.y() == logicalTopForChild(lastCandidateBo x))) | 1605 || (pointInLogicalContents.y() == logicalTopForChild(lastCandidateBo x))) |
1606 return positionForPointRespectingEditingBoundaries(this, lastCandida teBox, pointInContents); | 1606 return positionForPointRespectingEditingBoundaries(this, lastCandida teBox, pointInContents); |
(...skipping 18 matching lines...) Expand all Loading... | |
1625 offset += scrolledContentOffset(); | 1625 offset += scrolledContentOffset(); |
1626 } | 1626 } |
1627 | 1627 |
1628 LayoutUnit RenderBlock::availableLogicalWidth() const | 1628 LayoutUnit RenderBlock::availableLogicalWidth() const |
1629 { | 1629 { |
1630 return RenderBox::availableLogicalWidth(); | 1630 return RenderBox::availableLogicalWidth(); |
1631 } | 1631 } |
1632 | 1632 |
1633 void RenderBlock::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Lay outUnit& maxLogicalWidth) const | 1633 void RenderBlock::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Lay outUnit& maxLogicalWidth) const |
1634 { | 1634 { |
1635 if (childrenInline()) { | 1635 if (isRenderParagraph()) { |
1636 // FIXME: Remove this const_cast. | 1636 // FIXME: Remove this const_cast. |
1637 toRenderBlockFlow(const_cast<RenderBlock*>(this))->computeInlinePreferre dLogicalWidths(minLogicalWidth, maxLogicalWidth); | 1637 toRenderBlockFlow(const_cast<RenderBlock*>(this))->computeInlinePreferre dLogicalWidths(minLogicalWidth, maxLogicalWidth); |
1638 } else { | 1638 } else { |
1639 computeBlockPreferredLogicalWidths(minLogicalWidth, maxLogicalWidth); | 1639 computeBlockPreferredLogicalWidths(minLogicalWidth, maxLogicalWidth); |
1640 } | 1640 } |
1641 | 1641 |
1642 maxLogicalWidth = std::max(minLogicalWidth, maxLogicalWidth); | 1642 maxLogicalWidth = std::max(minLogicalWidth, maxLogicalWidth); |
1643 } | 1643 } |
1644 | 1644 |
1645 void RenderBlock::computePreferredLogicalWidths() | 1645 void RenderBlock::computePreferredLogicalWidths() |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1782 LayoutUnit RenderBlock::minLineHeightForReplacedRenderer(bool isFirstLine, Layou tUnit replacedHeight) const | 1782 LayoutUnit RenderBlock::minLineHeightForReplacedRenderer(bool isFirstLine, Layou tUnit replacedHeight) const |
1783 { | 1783 { |
1784 if (!(style(isFirstLine)->lineBoxContain() & LineBoxContainBlock)) | 1784 if (!(style(isFirstLine)->lineBoxContain() & LineBoxContainBlock)) |
1785 return 0; | 1785 return 0; |
1786 | 1786 |
1787 return std::max<LayoutUnit>(replacedHeight, lineHeight(isFirstLine, Horizont alLine, PositionOfInteriorLineBoxes)); | 1787 return std::max<LayoutUnit>(replacedHeight, lineHeight(isFirstLine, Horizont alLine, PositionOfInteriorLineBoxes)); |
1788 } | 1788 } |
1789 | 1789 |
1790 int RenderBlock::firstLineBoxBaseline() const | 1790 int RenderBlock::firstLineBoxBaseline() const |
1791 { | 1791 { |
1792 if (childrenInline()) { | 1792 if (isRenderParagraph()) { |
1793 if (firstLineBox()) | 1793 if (firstLineBox()) |
1794 return firstLineBox()->logicalTop() + style(true)->fontMetrics().asc ent(firstRootBox()->baselineType()); | 1794 return firstLineBox()->logicalTop() + style(true)->fontMetrics().asc ent(firstRootBox()->baselineType()); |
1795 else | 1795 else |
1796 return -1; | 1796 return -1; |
1797 } | 1797 } |
1798 else { | 1798 else { |
1799 for (RenderBox* curr = firstChildBox(); curr; curr = curr->nextSiblingBo x()) { | 1799 for (RenderBox* curr = firstChildBox(); curr; curr = curr->nextSiblingBo x()) { |
1800 if (!curr->isFloatingOrOutOfFlowPositioned()) { | 1800 if (!curr->isFloatingOrOutOfFlowPositioned()) { |
1801 int result = curr->firstLineBoxBaseline(); | 1801 int result = curr->firstLineBoxBaseline(); |
1802 if (result != -1) | 1802 if (result != -1) |
(...skipping 10 matching lines...) Expand all Loading... | |
1813 if (!style()->isOverflowVisible()) { | 1813 if (!style()->isOverflowVisible()) { |
1814 // We are not calling RenderBox::baselinePosition here because the calle r should add the margin-top/margin-right, not us. | 1814 // We are not calling RenderBox::baselinePosition here because the calle r should add the margin-top/margin-right, not us. |
1815 return direction == HorizontalLine ? height() + m_marginBox.bottom() : w idth() + m_marginBox.left(); | 1815 return direction == HorizontalLine ? height() + m_marginBox.bottom() : w idth() + m_marginBox.left(); |
1816 } | 1816 } |
1817 | 1817 |
1818 return lastLineBoxBaseline(direction); | 1818 return lastLineBoxBaseline(direction); |
1819 } | 1819 } |
1820 | 1820 |
1821 int RenderBlock::lastLineBoxBaseline(LineDirectionMode lineDirection) const | 1821 int RenderBlock::lastLineBoxBaseline(LineDirectionMode lineDirection) const |
1822 { | 1822 { |
1823 if (childrenInline()) { | 1823 if (isRenderParagraph()) { |
1824 if (!firstLineBox() && hasLineIfEmpty()) { | 1824 if (!firstLineBox() && hasLineIfEmpty()) { |
1825 const FontMetrics& fontMetrics = firstLineStyle()->fontMetrics(); | 1825 const FontMetrics& fontMetrics = firstLineStyle()->fontMetrics(); |
1826 return fontMetrics.ascent() | 1826 return fontMetrics.ascent() |
1827 + (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes) - fontMetrics.height()) / 2 | 1827 + (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes) - fontMetrics.height()) / 2 |
1828 + (lineDirection == HorizontalLine ? borderTop() + paddingTop() : borderRight() + paddingRight()); | 1828 + (lineDirection == HorizontalLine ? borderTop() + paddingTop() : borderRight() + paddingRight()); |
1829 } | 1829 } |
1830 if (lastLineBox()) | 1830 if (lastLineBox()) |
1831 return lastLineBox()->logicalTop() + style(lastLineBox() == firstLin eBox())->fontMetrics().ascent(lastRootBox()->baselineType()); | 1831 return lastLineBox()->logicalTop() + style(lastLineBox() == firstLin eBox())->fontMetrics().ascent(lastRootBox()->baselineType()); |
1832 return -1; | 1832 return -1; |
1833 } else { | 1833 } else { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1880 // Helper methods for obtaining the last line, computing line counts and heights for line counts | 1880 // Helper methods for obtaining the last line, computing line counts and heights for line counts |
1881 // (crawling into blocks). | 1881 // (crawling into blocks). |
1882 static bool shouldCheckLines(RenderObject* obj) | 1882 static bool shouldCheckLines(RenderObject* obj) |
1883 { | 1883 { |
1884 return !obj->isFloatingOrOutOfFlowPositioned() | 1884 return !obj->isFloatingOrOutOfFlowPositioned() |
1885 && obj->isRenderBlock() && obj->style()->height().isAuto(); | 1885 && obj->isRenderBlock() && obj->style()->height().isAuto(); |
1886 } | 1886 } |
1887 | 1887 |
1888 static int getHeightForLineCount(RenderBlock* block, int l, bool includeBottom, int& count) | 1888 static int getHeightForLineCount(RenderBlock* block, int l, bool includeBottom, int& count) |
1889 { | 1889 { |
1890 if (block->isRenderBlockFlow() && block->childrenInline()) { | 1890 if (block->isRenderBlockFlow() && block->isRenderParagraph()) { |
ojan
2014/11/21 22:55:10
Nit: this is redundant. RenderParagraphs are alway
rafaelw
2014/11/21 23:13:54
Done.
| |
1891 for (RootInlineBox* box = toRenderBlockFlow(block)->firstRootBox(); box; box = box->nextRootBox()) { | 1891 for (RootInlineBox* box = toRenderBlockFlow(block)->firstRootBox(); box; box = box->nextRootBox()) { |
1892 if (++count == l) | 1892 if (++count == l) |
1893 return box->lineBottom() + (includeBottom ? (block->borderBottom () + block->paddingBottom()) : LayoutUnit()); | 1893 return box->lineBottom() + (includeBottom ? (block->borderBottom () + block->paddingBottom()) : LayoutUnit()); |
1894 } | 1894 } |
1895 } else { | 1895 } else { |
1896 RenderBox* normalFlowChildWithoutLines = 0; | 1896 RenderBox* normalFlowChildWithoutLines = 0; |
1897 for (RenderBox* obj = block->firstChildBox(); obj; obj = obj->nextSiblin gBox()) { | 1897 for (RenderBox* obj = block->firstChildBox(); obj; obj = obj->nextSiblin gBox()) { |
1898 if (shouldCheckLines(obj)) { | 1898 if (shouldCheckLines(obj)) { |
1899 int result = getHeightForLineCount(toRenderBlock(obj), l, false, count); | 1899 int result = getHeightForLineCount(toRenderBlock(obj), l, false, count); |
1900 if (result != -1) | 1900 if (result != -1) |
1901 return result + obj->y() + (includeBottom ? (block->borderBo ttom() + block->paddingBottom()) : LayoutUnit()); | 1901 return result + obj->y() + (includeBottom ? (block->borderBo ttom() + block->paddingBottom()) : LayoutUnit()); |
1902 } else if (!obj->isFloatingOrOutOfFlowPositioned()) { | 1902 } else if (!obj->isFloatingOrOutOfFlowPositioned()) { |
1903 normalFlowChildWithoutLines = obj; | 1903 normalFlowChildWithoutLines = obj; |
1904 } | 1904 } |
1905 } | 1905 } |
1906 if (normalFlowChildWithoutLines && l == 0) | 1906 if (normalFlowChildWithoutLines && l == 0) |
1907 return normalFlowChildWithoutLines->y() + normalFlowChildWithoutLine s->height(); | 1907 return normalFlowChildWithoutLines->y() + normalFlowChildWithoutLine s->height(); |
1908 } | 1908 } |
1909 | 1909 |
1910 return -1; | 1910 return -1; |
1911 } | 1911 } |
1912 | 1912 |
1913 RootInlineBox* RenderBlock::lineAtIndex(int i) const | 1913 RootInlineBox* RenderBlock::lineAtIndex(int i) const |
1914 { | 1914 { |
1915 ASSERT(i >= 0); | 1915 ASSERT(i >= 0); |
1916 | 1916 |
1917 if (childrenInline()) { | 1917 if (isRenderParagraph()) { |
1918 for (RootInlineBox* box = firstRootBox(); box; box = box->nextRootBox()) | 1918 for (RootInlineBox* box = firstRootBox(); box; box = box->nextRootBox()) |
1919 if (!i--) | 1919 if (!i--) |
1920 return box; | 1920 return box; |
1921 } else { | 1921 } else { |
1922 for (RenderObject* child = firstChild(); child; child = child->nextSibli ng()) { | 1922 for (RenderObject* child = firstChild(); child; child = child->nextSibli ng()) { |
1923 if (!shouldCheckLines(child)) | 1923 if (!shouldCheckLines(child)) |
1924 continue; | 1924 continue; |
1925 if (RootInlineBox* box = toRenderBlock(child)->lineAtIndex(i)) | 1925 if (RootInlineBox* box = toRenderBlock(child)->lineAtIndex(i)) |
1926 return box; | 1926 return box; |
1927 } | 1927 } |
1928 } | 1928 } |
1929 | 1929 |
1930 return 0; | 1930 return 0; |
1931 } | 1931 } |
1932 | 1932 |
1933 int RenderBlock::lineCount(const RootInlineBox* stopRootInlineBox, bool* found) const | 1933 int RenderBlock::lineCount(const RootInlineBox* stopRootInlineBox, bool* found) const |
1934 { | 1934 { |
1935 int count = 0; | 1935 int count = 0; |
1936 if (childrenInline()) { | 1936 if (isRenderParagraph()) { |
1937 for (RootInlineBox* box = firstRootBox(); box; box = box->nextRootBox()) { | 1937 for (RootInlineBox* box = firstRootBox(); box; box = box->nextRootBox()) { |
1938 count++; | 1938 count++; |
1939 if (box == stopRootInlineBox) { | 1939 if (box == stopRootInlineBox) { |
1940 if (found) | 1940 if (found) |
1941 *found = true; | 1941 *found = true; |
1942 break; | 1942 break; |
1943 } | 1943 } |
1944 } | 1944 } |
1945 } else { | 1945 } else { |
1946 for (RenderObject* obj = firstChild(); obj; obj = obj->nextSibling()) | 1946 for (RenderObject* obj = firstChild(); obj; obj = obj->nextSibling()) |
(...skipping 11 matching lines...) Expand all Loading... | |
1958 } | 1958 } |
1959 | 1959 |
1960 int RenderBlock::heightForLineCount(int l) | 1960 int RenderBlock::heightForLineCount(int l) |
1961 { | 1961 { |
1962 int count = 0; | 1962 int count = 0; |
1963 return getHeightForLineCount(this, l, true, count); | 1963 return getHeightForLineCount(this, l, true, count); |
1964 } | 1964 } |
1965 | 1965 |
1966 void RenderBlock::clearTruncation() | 1966 void RenderBlock::clearTruncation() |
1967 { | 1967 { |
1968 if (childrenInline() && hasMarkupTruncation()) { | 1968 if (isRenderParagraph() && hasMarkupTruncation()) { |
1969 setHasMarkupTruncation(false); | 1969 setHasMarkupTruncation(false); |
1970 for (RootInlineBox* box = firstRootBox(); box; box = box->nextRootBox()) | 1970 for (RootInlineBox* box = firstRootBox(); box; box = box->nextRootBox()) |
1971 box->clearTruncation(); | 1971 box->clearTruncation(); |
1972 } else { | 1972 } else { |
1973 for (RenderObject* obj = firstChild(); obj; obj = obj->nextSibling()) { | 1973 for (RenderObject* obj = firstChild(); obj; obj = obj->nextSibling()) { |
1974 if (shouldCheckLines(obj)) | 1974 if (shouldCheckLines(obj)) |
1975 toRenderBlock(obj)->clearTruncation(); | 1975 toRenderBlock(obj)->clearTruncation(); |
1976 } | 1976 } |
1977 } | 1977 } |
1978 } | 1978 } |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2086 return toRenderBlock(renderer)->recalcOverflowAfterStyleChange(); | 2086 return toRenderBlock(renderer)->recalcOverflowAfterStyleChange(); |
2087 } | 2087 } |
2088 | 2088 |
2089 bool RenderBlock::recalcChildOverflowAfterStyleChange() | 2089 bool RenderBlock::recalcChildOverflowAfterStyleChange() |
2090 { | 2090 { |
2091 ASSERT(childNeedsOverflowRecalcAfterStyleChange()); | 2091 ASSERT(childNeedsOverflowRecalcAfterStyleChange()); |
2092 setChildNeedsOverflowRecalcAfterStyleChange(false); | 2092 setChildNeedsOverflowRecalcAfterStyleChange(false); |
2093 | 2093 |
2094 bool childrenOverflowChanged = false; | 2094 bool childrenOverflowChanged = false; |
2095 | 2095 |
2096 if (childrenInline()) { | 2096 if (isRenderParagraph()) { |
2097 ListHashSet<RootInlineBox*> lineBoxes; | 2097 ListHashSet<RootInlineBox*> lineBoxes; |
2098 for (InlineWalker walker(this); !walker.atEnd(); walker.advance()) { | 2098 for (InlineWalker walker(this); !walker.atEnd(); walker.advance()) { |
2099 RenderObject* renderer = walker.current(); | 2099 RenderObject* renderer = walker.current(); |
2100 if (recalcNormalFlowChildOverflowIfNeeded(renderer)) { | 2100 if (recalcNormalFlowChildOverflowIfNeeded(renderer)) { |
2101 childrenOverflowChanged = true; | 2101 childrenOverflowChanged = true; |
2102 if (InlineBox* inlineBoxWrapper = toRenderBlock(renderer)->inlin eBoxWrapper()) | 2102 if (InlineBox* inlineBoxWrapper = toRenderBlock(renderer)->inlin eBoxWrapper()) |
2103 lineBoxes.add(&inlineBoxWrapper->root()); | 2103 lineBoxes.add(&inlineBoxWrapper->root()); |
2104 } | 2104 } |
2105 } | 2105 } |
2106 | 2106 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2184 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const | 2184 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const |
2185 { | 2185 { |
2186 showRenderObject(); | 2186 showRenderObject(); |
2187 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) | 2187 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) |
2188 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); | 2188 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); |
2189 } | 2189 } |
2190 | 2190 |
2191 #endif | 2191 #endif |
2192 | 2192 |
2193 } // namespace blink | 2193 } // namespace blink |
OLD | NEW |