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

Side by Side Diff: Source/core/rendering/RenderBlockLineLayout.cpp

Issue 19865002: [CSS Shapes] Port shape-inside on regions and shape's content overflow from WebKit (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: [CSS Shapes] Port shape-inside on regions and shape's content overflow from WebKit Created 7 years, 5 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
« no previous file with comments | « Source/core/rendering/RenderBlock.h ('k') | Source/core/rendering/RenderBoxModelObject.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ight reserved. 3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ight reserved.
4 * Copyright (C) 2010 Google Inc. All rights reserved. 4 * Copyright (C) 2010 Google Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 if (!(block->style(isFirstLine)->lineBoxContain() & LineBoxContainBlock)) 63 if (!(block->style(isFirstLine)->lineBoxContain() & LineBoxContainBlock))
64 return 0; 64 return 0;
65 65
66 return max<LayoutUnit>(replacedHeight, block->lineHeight(isFirstLine, block- >isHorizontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLi neBoxes)); 66 return max<LayoutUnit>(replacedHeight, block->lineHeight(isFirstLine, block- >isHorizontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLi neBoxes));
67 } 67 }
68 68
69 ShapeInsideInfo* RenderBlock::layoutShapeInsideInfo() const 69 ShapeInsideInfo* RenderBlock::layoutShapeInsideInfo() const
70 { 70 {
71 ShapeInsideInfo* shapeInsideInfo = view()->layoutState()->shapeInsideInfo(); 71 ShapeInsideInfo* shapeInsideInfo = view()->layoutState()->shapeInsideInfo();
72
72 if (!shapeInsideInfo && flowThreadContainingBlock() && allowsShapeInsideInfo Sharing()) { 73 if (!shapeInsideInfo && flowThreadContainingBlock() && allowsShapeInsideInfo Sharing()) {
73 LayoutUnit offset = logicalHeight() + logicalHeightForLine(this, false); 74 // regionAtBlockOffset returns regions like an array first={0,N-1}, seco nd={N,M-1}, ...
75 LayoutUnit offset = logicalHeight() + logicalHeightForLine(this, false) - LayoutUnit(1);
74 RenderRegion* region = regionAtBlockOffset(offset); 76 RenderRegion* region = regionAtBlockOffset(offset);
75 return region ? region->shapeInsideInfo() : 0; 77 if (region)
78 shapeInsideInfo = region->shapeInsideInfo();
76 } 79 }
80
77 return shapeInsideInfo; 81 return shapeInsideInfo;
78 } 82 }
79 83
80 enum IndentTextOrNot { DoNotIndentText, IndentText }; 84 enum IndentTextOrNot { DoNotIndentText, IndentText };
81 85
82 class LineWidth { 86 class LineWidth {
83 public: 87 public:
84 LineWidth(RenderBlock* block, bool isFirstLine, IndentTextOrNot shouldIndent Text) 88 LineWidth(RenderBlock* block, bool isFirstLine, IndentTextOrNot shouldIndent Text)
85 : m_block(block) 89 : m_block(block)
86 , m_uncommittedWidth(0) 90 , m_uncommittedWidth(0)
(...skipping 1308 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 LineLayoutState(bool fullLayout, LayoutUnit& repaintLogicalTop, LayoutUnit& repaintLogicalBottom, RenderFlowThread* flowThread) 1399 LineLayoutState(bool fullLayout, LayoutUnit& repaintLogicalTop, LayoutUnit& repaintLogicalBottom, RenderFlowThread* flowThread)
1396 : m_lastFloat(0) 1400 : m_lastFloat(0)
1397 , m_endLine(0) 1401 , m_endLine(0)
1398 , m_floatIndex(0) 1402 , m_floatIndex(0)
1399 , m_endLineLogicalTop(0) 1403 , m_endLineLogicalTop(0)
1400 , m_endLineMatched(false) 1404 , m_endLineMatched(false)
1401 , m_checkForFloatsFromLastLine(false) 1405 , m_checkForFloatsFromLastLine(false)
1402 , m_isFullLayout(fullLayout) 1406 , m_isFullLayout(fullLayout)
1403 , m_repaintLogicalTop(repaintLogicalTop) 1407 , m_repaintLogicalTop(repaintLogicalTop)
1404 , m_repaintLogicalBottom(repaintLogicalBottom) 1408 , m_repaintLogicalBottom(repaintLogicalBottom)
1409 , m_adjustedLogicalLineTop(0)
1405 , m_usesRepaintBounds(false) 1410 , m_usesRepaintBounds(false)
1406 , m_flowThread(flowThread) 1411 , m_flowThread(flowThread)
1407 { } 1412 { }
1408 1413
1409 void markForFullLayout() { m_isFullLayout = true; } 1414 void markForFullLayout() { m_isFullLayout = true; }
1410 bool isFullLayout() const { return m_isFullLayout; } 1415 bool isFullLayout() const { return m_isFullLayout; }
1411 1416
1412 bool usesRepaintBounds() const { return m_usesRepaintBounds; } 1417 bool usesRepaintBounds() const { return m_usesRepaintBounds; }
1413 1418
1414 void setRepaintRange(LayoutUnit logicalHeight) 1419 void setRepaintRange(LayoutUnit logicalHeight)
(...skipping 25 matching lines...) Expand all
1440 void setEndLine(RootInlineBox* line) { m_endLine = line; } 1445 void setEndLine(RootInlineBox* line) { m_endLine = line; }
1441 1446
1442 RenderBlock::FloatingObject* lastFloat() const { return m_lastFloat; } 1447 RenderBlock::FloatingObject* lastFloat() const { return m_lastFloat; }
1443 void setLastFloat(RenderBlock::FloatingObject* lastFloat) { m_lastFloat = la stFloat; } 1448 void setLastFloat(RenderBlock::FloatingObject* lastFloat) { m_lastFloat = la stFloat; }
1444 1449
1445 Vector<RenderBlock::FloatWithRect>& floats() { return m_floats; } 1450 Vector<RenderBlock::FloatWithRect>& floats() { return m_floats; }
1446 1451
1447 unsigned floatIndex() const { return m_floatIndex; } 1452 unsigned floatIndex() const { return m_floatIndex; }
1448 void setFloatIndex(unsigned floatIndex) { m_floatIndex = floatIndex; } 1453 void setFloatIndex(unsigned floatIndex) { m_floatIndex = floatIndex; }
1449 1454
1455 LayoutUnit adjustedLogicalLineTop() const { return m_adjustedLogicalLineTop; }
1456 void setAdjustedLogicalLineTop(LayoutUnit value) { m_adjustedLogicalLineTop = value; }
1457
1450 RenderFlowThread* flowThread() const { return m_flowThread; } 1458 RenderFlowThread* flowThread() const { return m_flowThread; }
1451 void setFlowThread(RenderFlowThread* thread) { m_flowThread = thread; } 1459 void setFlowThread(RenderFlowThread* thread) { m_flowThread = thread; }
1452 1460
1453 private: 1461 private:
1454 Vector<RenderBlock::FloatWithRect> m_floats; 1462 Vector<RenderBlock::FloatWithRect> m_floats;
1455 RenderBlock::FloatingObject* m_lastFloat; 1463 RenderBlock::FloatingObject* m_lastFloat;
1456 RootInlineBox* m_endLine; 1464 RootInlineBox* m_endLine;
1457 LineInfo m_lineInfo; 1465 LineInfo m_lineInfo;
1458 unsigned m_floatIndex; 1466 unsigned m_floatIndex;
1459 LayoutUnit m_endLineLogicalTop; 1467 LayoutUnit m_endLineLogicalTop;
1460 bool m_endLineMatched; 1468 bool m_endLineMatched;
1461 bool m_checkForFloatsFromLastLine; 1469 bool m_checkForFloatsFromLastLine;
1462 1470
1463 bool m_isFullLayout; 1471 bool m_isFullLayout;
1464 1472
1465 // FIXME: Should this be a range object instead of two ints? 1473 // FIXME: Should this be a range object instead of two ints?
1466 LayoutUnit& m_repaintLogicalTop; 1474 LayoutUnit& m_repaintLogicalTop;
1467 LayoutUnit& m_repaintLogicalBottom; 1475 LayoutUnit& m_repaintLogicalBottom;
1468 1476
1477 LayoutUnit m_adjustedLogicalLineTop;
1478
1469 bool m_usesRepaintBounds; 1479 bool m_usesRepaintBounds;
1470 1480
1471 RenderFlowThread* m_flowThread; 1481 RenderFlowThread* m_flowThread;
1472 }; 1482 };
1473 1483
1474 static void deleteLineRange(LineLayoutState& layoutState, RenderArena* arena, Ro otInlineBox* startLine, RootInlineBox* stopLine = 0) 1484 static void deleteLineRange(LineLayoutState& layoutState, RenderArena* arena, Ro otInlineBox* startLine, RootInlineBox* stopLine = 0)
1475 { 1485 {
1476 RootInlineBox* boxToDelete = startLine; 1486 RootInlineBox* boxToDelete = startLine;
1477 while (boxToDelete && boxToDelete != stopLine) { 1487 while (boxToDelete && boxToDelete != stopLine) {
1478 layoutState.updateRepaintRangeFromBox(boxToDelete); 1488 layoutState.updateRepaintRangeFromBox(boxToDelete);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1569 1579
1570 static inline float firstPositiveWidth(const WordMeasurements& wordMeasurements) 1580 static inline float firstPositiveWidth(const WordMeasurements& wordMeasurements)
1571 { 1581 {
1572 for (size_t i = 0; i < wordMeasurements.size(); ++i) { 1582 for (size_t i = 0; i < wordMeasurements.size(); ++i) {
1573 if (wordMeasurements[i].width > 0) 1583 if (wordMeasurements[i].width > 0)
1574 return wordMeasurements[i].width; 1584 return wordMeasurements[i].width;
1575 } 1585 }
1576 return 0; 1586 return 0;
1577 } 1587 }
1578 1588
1579 static inline LayoutUnit adjustLogicalLineTop(ShapeInsideInfo* shapeInsideInfo, const InlineIterator& start, const InlineIterator& end, const WordMeasurements& wordMeasurements) 1589
1590 static inline LayoutUnit adjustLogicalLineTop(ShapeInsideInfo* shapeInsideInfo, InlineIterator start, InlineIterator end, const WordMeasurements& wordMeasuremen ts)
1580 { 1591 {
1581 if (!shapeInsideInfo || !segmentIsEmpty(start, end)) 1592 if (!shapeInsideInfo || end != start)
1582 return 0; 1593 return 0;
1583 1594
1584 float minWidth = firstPositiveWidth(wordMeasurements); 1595 float minWidth = firstPositiveWidth(wordMeasurements);
1585 ASSERT(minWidth || wordMeasurements.isEmpty()); 1596 ASSERT(minWidth || wordMeasurements.isEmpty());
1586 if (minWidth > 0 && shapeInsideInfo->adjustLogicalLineTop(minWidth)) 1597 if (minWidth > 0 && shapeInsideInfo->adjustLogicalLineTop(minWidth))
1587 return shapeInsideInfo->logicalLineTop(); 1598 return shapeInsideInfo->logicalLineTop();
1588 1599
1589 return shapeInsideInfo->shapeLogicalBottom(); 1600 return shapeInsideInfo->shapeLogicalBottom();
1590 } 1601 }
1591 1602
1603 static inline void pushShapeContentOverflowBelowTheContentBox(RenderBlock* block , ShapeInsideInfo* shapeInsideInfo, LayoutUnit lineTop, LayoutUnit lineHeight)
1604 {
1605 ASSERT(shapeInsideInfo);
1606
1607 LayoutUnit logicalLineBottom = lineTop + lineHeight;
1608 LayoutUnit shapeLogicalBottom = shapeInsideInfo->shapeLogicalBottom();
1609 LayoutUnit shapeContainingBlockHeight = shapeInsideInfo->shapeContainingBloc kHeight();
1610
1611 bool isOverflowPositionedAlready = (shapeContainingBlockHeight - shapeInside Info->owner()->borderAndPaddingAfter() + lineHeight) <= lineTop;
1612
1613 // If the last line overlaps with the shape, we don't need the segments anym ore
1614 if (lineTop < shapeLogicalBottom && shapeLogicalBottom < logicalLineBottom)
1615 shapeInsideInfo->clearSegments();
1616 if (logicalLineBottom <= shapeLogicalBottom || !shapeContainingBlockHeight | | isOverflowPositionedAlready)
1617 return;
1618
1619 LayoutUnit newLogicalHeight = block->logicalHeight() + (shapeContainingBlock Height - (lineTop + shapeInsideInfo->owner()->borderAndPaddingAfter()));
1620 block->setLogicalHeight(newLogicalHeight);
1621 }
1622
1623 void RenderBlock::updateShapeAndSegmentsForCurrentLine(ShapeInsideInfo*& shapeIn sideInfo, LayoutUnit& absoluteLogicalTop, LineLayoutState& layoutState)
1624 {
1625 if (layoutState.flowThread())
1626 return updateShapeAndSegmentsForCurrentLineInFlowThread(shapeInsideInfo, layoutState);
1627
1628 if (!shapeInsideInfo)
1629 return;
1630
1631 LayoutUnit lineTop = logicalHeight() + absoluteLogicalTop;
1632 LayoutUnit lineHeight = this->lineHeight(layoutState.lineInfo().isFirstLine( ), isHorizontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInterior LineBoxes);
1633
1634 // FIXME: Bug 95361: It is possible for a line to grow beyond lineHeight, in which case these segments may be incorrect.
1635 shapeInsideInfo->computeSegmentsForLine(lineTop, lineHeight);
1636
1637 pushShapeContentOverflowBelowTheContentBox(this, shapeInsideInfo, lineTop, l ineHeight);
1638 }
1639
1640 void RenderBlock::updateShapeAndSegmentsForCurrentLineInFlowThread(ShapeInsideIn fo*& shapeInsideInfo, LineLayoutState& layoutState)
1641 {
1642 ASSERT(layoutState.flowThread());
1643
1644 LayoutUnit lineHeight = this->lineHeight(layoutState.lineInfo().isFirstLine( ), isHorizontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInterior LineBoxes);
1645
1646 RenderRegion* currentRegion = regionAtBlockOffset(logicalHeight());
1647 if (!currentRegion)
1648 return;
1649
1650 shapeInsideInfo = currentRegion->shapeInsideInfo();
1651
1652 LayoutUnit logicalLineTopInFlowThread = logicalHeight() + offsetFromLogicalT opOfFirstPage();
1653 LayoutUnit logicalLineBottomInFlowThread = logicalLineTopInFlowThread + line Height;
1654 LayoutUnit logicalRegionTopInFlowThread = currentRegion->logicalTopForFlowTh readContent();
1655 LayoutUnit logicalRegionBottomInFlowThread = logicalRegionTopInFlowThread + currentRegion->logicalHeight() - currentRegion->borderAndPaddingBefore() - curre ntRegion->borderAndPaddingAfter();
1656
1657 // We only want to deal regions with shapes, so we look up for the next regi on whether it has a shape
1658 if (!shapeInsideInfo && !currentRegion->isLastRegion()) {
1659 LayoutUnit deltaToNextRegion = logicalHeight() + logicalRegionBottomInFl owThread - logicalLineTopInFlowThread;
1660 RenderRegion* lookupForNextRegion = regionAtBlockOffset(logicalHeight() + deltaToNextRegion);
1661 if (!lookupForNextRegion->shapeInsideInfo())
1662 return;
1663 }
1664
1665 LayoutUnit shapeBottomInFlowThread = LayoutUnit::max();
1666 if (shapeInsideInfo)
1667 shapeBottomInFlowThread = shapeInsideInfo->shapeLogicalBottom() + curren tRegion->logicalTopForFlowThreadContent();
1668
1669 // If the line is between two shapes/regions we position the line to the top of the next shape/region
1670 RenderRegion* nextRegion = regionAtBlockOffset(logicalHeight() + lineHeight) ;
1671 if ((currentRegion != nextRegion && (logicalLineBottomInFlowThread > logical RegionBottomInFlowThread)) || (!currentRegion->isLastRegion() && shapeBottomInFl owThread < logicalLineBottomInFlowThread)) {
1672 LayoutUnit deltaToNextRegion = logicalRegionBottomInFlowThread - logical LineTopInFlowThread;
1673 nextRegion = regionAtBlockOffset(logicalHeight() + deltaToNextRegion);
1674
1675 ASSERT(currentRegion != nextRegion);
1676
1677 shapeInsideInfo = nextRegion->shapeInsideInfo();
1678 setLogicalHeight(logicalHeight() + deltaToNextRegion);
1679
1680 currentRegion = nextRegion;
1681
1682 logicalLineTopInFlowThread = logicalHeight() + offsetFromLogicalTopOfFir stPage();
1683 logicalLineBottomInFlowThread = logicalLineTopInFlowThread + lineHeight;
1684 logicalRegionTopInFlowThread = currentRegion->logicalTopForFlowThreadCon tent();
1685 logicalRegionBottomInFlowThread = logicalRegionTopInFlowThread + current Region->logicalHeight() - currentRegion->borderAndPaddingBefore() - currentRegio n->borderAndPaddingAfter();
1686 }
1687
1688 if (!shapeInsideInfo)
1689 return;
1690
1691 // We position the first line to the top of the shape in the region or to th e previously adjusted position in the shape
1692 if (logicalLineBottomInFlowThread <= (logicalRegionTopInFlowThread + lineHei ght) || (logicalLineTopInFlowThread - logicalRegionTopInFlowThread) < (layoutSta te.adjustedLogicalLineTop() - currentRegion->borderAndPaddingBefore())) {
1693 LayoutUnit shapeTopOffset = layoutState.adjustedLogicalLineTop();
1694 if (!shapeTopOffset)
1695 shapeTopOffset = shapeInsideInfo->shapeLogicalTop();
1696
1697 LayoutUnit shapePositionInFlowThread = currentRegion->logicalTopForFlowT hreadContent() + shapeTopOffset;
1698 LayoutUnit shapeTopLineTopDelta = shapePositionInFlowThread - logicalLin eTopInFlowThread - currentRegion->borderAndPaddingBefore();
1699
1700 setLogicalHeight(logicalHeight() + shapeTopLineTopDelta);
1701 logicalLineTopInFlowThread += shapeTopLineTopDelta;
1702 layoutState.setAdjustedLogicalLineTop(0);
1703 }
1704
1705 LayoutUnit lineTop = logicalLineTopInFlowThread - currentRegion->logicalTopF orFlowThreadContent() + currentRegion->borderAndPaddingBefore();
1706 shapeInsideInfo->computeSegmentsForLine(lineTop, lineHeight);
1707
1708 if (currentRegion->isLastRegion())
1709 pushShapeContentOverflowBelowTheContentBox(this, shapeInsideInfo, lineTo p, lineHeight);
1710 }
1711
1712 bool RenderBlock::adjustLogicalLineTopAndLogicalHeightIfNeeded(ShapeInsideInfo* shapeInsideInfo, LayoutUnit absoluteLogicalTop, LineLayoutState& layoutState, In lineBidiResolver& resolver, FloatingObject* lastFloatFromPreviousLine, InlineIte rator& end, WordMeasurements& wordMeasurements)
1713 {
1714 LayoutUnit adjustedLogicalLineTop = adjustLogicalLineTop(shapeInsideInfo, re solver.position(), end, wordMeasurements);
1715 if (!adjustedLogicalLineTop)
1716 return false;
1717
1718 LayoutUnit newLogicalHeight = adjustedLogicalLineTop - absoluteLogicalTop;
1719
1720 if (layoutState.flowThread()) {
1721 layoutState.setAdjustedLogicalLineTop(adjustedLogicalLineTop);
1722 newLogicalHeight = logicalHeight();
1723 }
1724
1725
1726 end = restartLayoutRunsAndFloatsInRange(logicalHeight(), newLogicalHeight, l astFloatFromPreviousLine, resolver, end);
1727 return true;
1728 }
1729
1592 void RenderBlock::layoutRunsAndFloatsInRange(LineLayoutState& layoutState, Inlin eBidiResolver& resolver, const InlineIterator& cleanLineStart, const BidiStatus& cleanLineBidiStatus, unsigned consecutiveHyphenatedLines) 1730 void RenderBlock::layoutRunsAndFloatsInRange(LineLayoutState& layoutState, Inlin eBidiResolver& resolver, const InlineIterator& cleanLineStart, const BidiStatus& cleanLineBidiStatus, unsigned consecutiveHyphenatedLines)
1593 { 1731 {
1594 RenderStyle* styleToUse = style(); 1732 RenderStyle* styleToUse = style();
1595 bool paginated = view()->layoutState() && view()->layoutState()->isPaginated (); 1733 bool paginated = view()->layoutState() && view()->layoutState()->isPaginated ();
1596 LineMidpointState& lineMidpointState = resolver.midpointState(); 1734 LineMidpointState& lineMidpointState = resolver.midpointState();
1597 InlineIterator end = resolver.position(); 1735 InlineIterator end = resolver.position();
1598 bool checkForEndLineMatch = layoutState.endLine(); 1736 bool checkForEndLineMatch = layoutState.endLine();
1599 RenderTextInfo renderTextInfo; 1737 RenderTextInfo renderTextInfo;
1600 VerticalPositionCache verticalPositionCache; 1738 VerticalPositionCache verticalPositionCache;
1601 1739
1602 LineBreaker lineBreaker(this); 1740 LineBreaker lineBreaker(this);
1603 1741
1604 LayoutUnit absoluteLogicalTop; 1742 LayoutUnit absoluteLogicalTop;
1605 ShapeInsideInfo* shapeInsideInfo = layoutShapeInsideInfo(); 1743 ShapeInsideInfo* shapeInsideInfo = layoutShapeInsideInfo();
1606 if (shapeInsideInfo) { 1744 if (shapeInsideInfo) {
1607 ASSERT(shapeInsideInfo->owner() == this || allowsShapeInsideInfoSharing( )); 1745 ASSERT(shapeInsideInfo->owner() == this || allowsShapeInsideInfoSharing( ));
1608 if (shapeInsideInfo != this->shapeInsideInfo()) { 1746 if (shapeInsideInfo != this->shapeInsideInfo()) {
1609 // FIXME Bug 100284: If subsequent LayoutStates are pushed, we will have to add 1747 // FIXME Bug 100284: If subsequent LayoutStates are pushed, we will have to add
1610 // their offsets from the original shape-inside container. 1748 // their offsets from the original shape-inside container.
1611 absoluteLogicalTop = logicalTop(); 1749 absoluteLogicalTop = logicalTop();
1612 } 1750 }
1613 // Begin layout at the logical top of our shape inside. 1751 // Begin layout at the logical top of our shape inside.
1614 if (logicalHeight() + absoluteLogicalTop < shapeInsideInfo->shapeLogical Top()) 1752 if (logicalHeight() + absoluteLogicalTop < shapeInsideInfo->shapeLogical Top()) {
1615 setLogicalHeight(shapeInsideInfo->shapeLogicalTop() - absoluteLogica lTop); 1753 LayoutUnit logicalHeight = shapeInsideInfo->shapeLogicalTop() - abso luteLogicalTop;
1616 } 1754 if (layoutState.flowThread())
1617 1755 logicalHeight -= shapeInsideInfo->owner()->borderAndPaddingBefor e();
1618 if (layoutState.flowThread()) { 1756 setLogicalHeight(logicalHeight);
1619 // In a flow thread we need to update absoluteLogicalTop in every run to match to the current logical top increased by the height of the current line to calculate the right values for the 1757 }
1620 // actual shape when a line is beginning in a new region which has a sha pe on it. Usecase: shape-inside is applied not on the first, but on either of th e following regions in the region chain.
1621 absoluteLogicalTop = logicalTop() + lineHeight(layoutState.lineInfo().is FirstLine(), isHorizontalWritingMode() ? HorizontalLine : VerticalLine, Position OfInteriorLineBoxes);
1622 } 1758 }
1623 1759
1624 while (!end.atEnd()) { 1760 while (!end.atEnd()) {
1625 // FIXME: Is this check necessary before the first iteration or can it b e moved to the end? 1761 // FIXME: Is this check necessary before the first iteration or can it b e moved to the end?
1626 if (checkForEndLineMatch) { 1762 if (checkForEndLineMatch) {
1627 layoutState.setEndLineMatched(matchedEndLine(layoutState, resolver, cleanLineStart, cleanLineBidiStatus)); 1763 layoutState.setEndLineMatched(matchedEndLine(layoutState, resolver, cleanLineStart, cleanLineBidiStatus));
1628 if (layoutState.endLineMatched()) { 1764 if (layoutState.endLineMatched()) {
1629 resolver.setPosition(InlineIterator(resolver.position().root(), 0, 0), 0); 1765 resolver.setPosition(InlineIterator(resolver.position().root(), 0, 0), 0);
1630 break; 1766 break;
1631 } 1767 }
1632 } 1768 }
1633 1769
1634 lineMidpointState.reset(); 1770 lineMidpointState.reset();
1635 1771
1636 layoutState.lineInfo().setEmpty(true); 1772 layoutState.lineInfo().setEmpty(true);
1637 layoutState.lineInfo().resetRunsFromLeadingWhitespace(); 1773 layoutState.lineInfo().resetRunsFromLeadingWhitespace();
1638 1774
1639 const InlineIterator oldEnd = end; 1775 const InlineIterator oldEnd = end;
1640 bool isNewUBAParagraph = layoutState.lineInfo().previousLineBrokeCleanly (); 1776 bool isNewUBAParagraph = layoutState.lineInfo().previousLineBrokeCleanly ();
1641 FloatingObject* lastFloatFromPreviousLine = (containsFloats()) ? floatin gObjects()->set().last() : 0; 1777 FloatingObject* lastFloatFromPreviousLine = (containsFloats()) ? floatin gObjects()->set().last() : 0;
1642 // FIXME: Bug 95361: It is possible for a line to grow beyond lineHeight , in which 1778
1643 // case these segments may be incorrect. 1779 updateShapeAndSegmentsForCurrentLine(shapeInsideInfo, absoluteLogicalTop , layoutState);
1644 if (layoutState.flowThread()) 1780
1645 shapeInsideInfo = layoutShapeInsideInfo();
1646 if (shapeInsideInfo) {
1647 LayoutUnit lineTop = logicalHeight() + absoluteLogicalTop;
1648 shapeInsideInfo->computeSegmentsForLine(lineTop, lineHeight(layoutSt ate.lineInfo().isFirstLine(), isHorizontalWritingMode() ? HorizontalLine : Verti calLine, PositionOfInteriorLineBoxes));
1649 }
1650 WordMeasurements wordMeasurements; 1781 WordMeasurements wordMeasurements;
1651 end = lineBreaker.nextLineBreak(resolver, layoutState.lineInfo(), render TextInfo, lastFloatFromPreviousLine, consecutiveHyphenatedLines, wordMeasurement s); 1782 end = lineBreaker.nextLineBreak(resolver, layoutState.lineInfo(), render TextInfo, lastFloatFromPreviousLine, consecutiveHyphenatedLines, wordMeasurement s);
1652 renderTextInfo.m_lineBreakIterator.resetPriorContext(); 1783 renderTextInfo.m_lineBreakIterator.resetPriorContext();
1653 if (resolver.position().atEnd()) { 1784 if (resolver.position().atEnd()) {
1654 // FIXME: We shouldn't be creating any runs in nextLineBreak to begi n with! 1785 // FIXME: We shouldn't be creating any runs in nextLineBreak to begi n with!
1655 // Once BidiRunList is separated from BidiResolver this will not be needed. 1786 // Once BidiRunList is separated from BidiResolver this will not be needed.
1656 resolver.runs().deleteRuns(); 1787 resolver.runs().deleteRuns();
1657 resolver.markCurrentRunEmpty(); // FIXME: This can probably be repla ced by an ASSERT (or just removed). 1788 resolver.markCurrentRunEmpty(); // FIXME: This can probably be repla ced by an ASSERT (or just removed).
1658 layoutState.setCheckForFloatsFromLastLine(true); 1789 layoutState.setCheckForFloatsFromLastLine(true);
1659 resolver.setPosition(InlineIterator(resolver.position().root(), 0, 0 ), 0); 1790 resolver.setPosition(InlineIterator(resolver.position().root(), 0, 0 ), 0);
1660 break; 1791 break;
1661 } 1792 }
1662 1793
1663 if (LayoutUnit adjustedLogicalLineTop = adjustLogicalLineTop(shapeInside Info, resolver.position(), end, wordMeasurements)) { 1794 if (adjustLogicalLineTopAndLogicalHeightIfNeeded(shapeInsideInfo, absolu teLogicalTop, layoutState, resolver, lastFloatFromPreviousLine, end, wordMeasure ments))
1664 end = restartLayoutRunsAndFloatsInRange(logicalHeight(), adjustedLog icalLineTop - absoluteLogicalTop, lastFloatFromPreviousLine, resolver, oldEnd);
1665 continue; 1795 continue;
1666 }
1667 1796
1668 ASSERT(end != resolver.position()); 1797 ASSERT(end != resolver.position());
1669 1798
1670 // This is a short-cut for empty lines. 1799 // This is a short-cut for empty lines.
1671 if (layoutState.lineInfo().isEmpty()) { 1800 if (layoutState.lineInfo().isEmpty()) {
1672 if (lastRootBox()) 1801 if (lastRootBox())
1673 lastRootBox()->setLineBreakInfo(end.m_obj, end.m_pos, resolver.s tatus()); 1802 lastRootBox()->setLineBreakInfo(end.m_obj, end.m_pos, resolver.s tatus());
1674 } else { 1803 } else {
1675 VisualDirectionOverride override = (styleToUse->rtlOrdering() == Vis ualOrder ? (styleToUse->direction() == LTR ? VisualLeftToRightOverride : VisualR ightToLeftOverride) : NoVisualOverride); 1804 VisualDirectionOverride override = (styleToUse->rtlOrdering() == Vis ualOrder ? (styleToUse->direction() == LTR ? VisualLeftToRightOverride : VisualR ightToLeftOverride) : NoVisualOverride);
1676 1805
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after
2589 void RenderBlock::LineBreaker::reset() 2718 void RenderBlock::LineBreaker::reset()
2590 { 2719 {
2591 m_positionedObjects.clear(); 2720 m_positionedObjects.clear();
2592 m_hyphenated = false; 2721 m_hyphenated = false;
2593 m_clear = CNONE; 2722 m_clear = CNONE;
2594 } 2723 }
2595 2724
2596 InlineIterator RenderBlock::LineBreaker::nextLineBreak(InlineBidiResolver& resol ver, LineInfo& lineInfo, RenderTextInfo& renderTextInfo, FloatingObject* lastFlo atFromPreviousLine, unsigned consecutiveHyphenatedLines, WordMeasurements& wordM easurements) 2725 InlineIterator RenderBlock::LineBreaker::nextLineBreak(InlineBidiResolver& resol ver, LineInfo& lineInfo, RenderTextInfo& renderTextInfo, FloatingObject* lastFlo atFromPreviousLine, unsigned consecutiveHyphenatedLines, WordMeasurements& wordM easurements)
2597 { 2726 {
2598 ShapeInsideInfo* shapeInsideInfo = m_block->layoutShapeInsideInfo(); 2727 ShapeInsideInfo* shapeInsideInfo = m_block->layoutShapeInsideInfo();
2728
2599 if (!shapeInsideInfo || !shapeInsideInfo->lineOverlapsShapeBounds()) 2729 if (!shapeInsideInfo || !shapeInsideInfo->lineOverlapsShapeBounds())
2600 return nextSegmentBreak(resolver, lineInfo, renderTextInfo, lastFloatFro mPreviousLine, consecutiveHyphenatedLines, wordMeasurements); 2730 return nextSegmentBreak(resolver, lineInfo, renderTextInfo, lastFloatFro mPreviousLine, consecutiveHyphenatedLines, wordMeasurements);
2601 2731
2602 InlineIterator end = resolver.position(); 2732 InlineIterator end = resolver.position();
2603 InlineIterator oldEnd = end; 2733 InlineIterator oldEnd = end;
2604 2734
2605 if (!shapeInsideInfo->hasSegments()) { 2735 if (!shapeInsideInfo->hasSegments()) {
2606 end = nextSegmentBreak(resolver, lineInfo, renderTextInfo, lastFloatFrom PreviousLine, consecutiveHyphenatedLines, wordMeasurements); 2736 end = nextSegmentBreak(resolver, lineInfo, renderTextInfo, lastFloatFrom PreviousLine, consecutiveHyphenatedLines, wordMeasurements);
2607 resolver.setPositionIgnoringNestedIsolates(oldEnd); 2737 resolver.setPositionIgnoringNestedIsolates(oldEnd);
2608 return oldEnd; 2738 return oldEnd;
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
3430 lineGridBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, ver ticalPositionCache); 3560 lineGridBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, ver ticalPositionCache);
3431 3561
3432 setLineGridBox(lineGridBox); 3562 setLineGridBox(lineGridBox);
3433 3563
3434 // FIXME: If any of the characteristics of the box change compared to the ol d one, then we need to do a deep dirtying 3564 // FIXME: If any of the characteristics of the box change compared to the ol d one, then we need to do a deep dirtying
3435 // (similar to what happens when the page height changes). Ideally, though, we only do this if someone is actually snapping 3565 // (similar to what happens when the page height changes). Ideally, though, we only do this if someone is actually snapping
3436 // to this grid. 3566 // to this grid.
3437 } 3567 }
3438 3568
3439 } 3569 }
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBlock.h ('k') | Source/core/rendering/RenderBoxModelObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698