OLD | NEW |
---|---|
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 20 matching lines...) Expand all Loading... | |
31 #include "core/layout/LayoutRubyRun.h" | 31 #include "core/layout/LayoutRubyRun.h" |
32 #include "core/layout/LayoutView.h" | 32 #include "core/layout/LayoutView.h" |
33 #include "core/layout/TextRunConstructor.h" | 33 #include "core/layout/TextRunConstructor.h" |
34 #include "core/layout/VerticalPositionCache.h" | 34 #include "core/layout/VerticalPositionCache.h" |
35 #include "core/layout/api/LineLayoutItem.h" | 35 #include "core/layout/api/LineLayoutItem.h" |
36 #include "core/layout/line/BreakingContextInlineHeaders.h" | 36 #include "core/layout/line/BreakingContextInlineHeaders.h" |
37 #include "core/layout/line/GlyphOverflow.h" | 37 #include "core/layout/line/GlyphOverflow.h" |
38 #include "core/layout/line/LayoutTextInfo.h" | 38 #include "core/layout/line/LayoutTextInfo.h" |
39 #include "core/layout/line/LineLayoutState.h" | 39 #include "core/layout/line/LineLayoutState.h" |
40 #include "core/layout/line/LineWidth.h" | 40 #include "core/layout/line/LineWidth.h" |
41 #include "core/layout/line/TrailingFloatsRootInlineBox.h" | |
42 #include "core/layout/line/WordMeasurement.h" | 41 #include "core/layout/line/WordMeasurement.h" |
43 #include "core/layout/svg/line/SVGRootInlineBox.h" | 42 #include "core/layout/svg/line/SVGRootInlineBox.h" |
44 #include "platform/fonts/Character.h" | 43 #include "platform/fonts/Character.h" |
45 #include "platform/text/BidiResolver.h" | 44 #include "platform/text/BidiResolver.h" |
46 #include "wtf/RefCountedLeakCounter.h" | 45 #include "wtf/RefCountedLeakCounter.h" |
47 #include "wtf/StdLibExtras.h" | 46 #include "wtf/StdLibExtras.h" |
48 #include "wtf/Vector.h" | 47 #include "wtf/Vector.h" |
49 #include "wtf/text/CharacterNames.h" | 48 #include "wtf/text/CharacterNames.h" |
50 | 49 |
51 namespace blink { | 50 namespace blink { |
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
809 | 808 |
810 WordMeasurements wordMeasurements; | 809 WordMeasurements wordMeasurements; |
811 endOfLine = lineBreaker.nextLineBreak(resolver, layoutState.lineInfo(), layoutTextInfo, | 810 endOfLine = lineBreaker.nextLineBreak(resolver, layoutState.lineInfo(), layoutTextInfo, |
812 lastFloatFromPreviousLine, wordMeasurements); | 811 lastFloatFromPreviousLine, wordMeasurements); |
813 layoutTextInfo.m_lineBreakIterator.resetPriorContext(); | 812 layoutTextInfo.m_lineBreakIterator.resetPriorContext(); |
814 if (resolver.position().atEnd()) { | 813 if (resolver.position().atEnd()) { |
815 // FIXME: We shouldn't be creating any runs in nextLineBreak to begi n with! | 814 // FIXME: We shouldn't be creating any runs in nextLineBreak to begi n with! |
816 // Once BidiRunList is separated from BidiResolver this will not be needed. | 815 // Once BidiRunList is separated from BidiResolver this will not be needed. |
817 resolver.runs().deleteRuns(); | 816 resolver.runs().deleteRuns(); |
818 resolver.markCurrentRunEmpty(); // FIXME: This can probably be repla ced by an ASSERT (or just removed). | 817 resolver.markCurrentRunEmpty(); // FIXME: This can probably be repla ced by an ASSERT (or just removed). |
819 layoutState.setCheckForFloatsFromLastLine(true); | |
820 resolver.setPosition(InlineIterator(resolver.position().root(), 0, 0 ), 0); | 818 resolver.setPosition(InlineIterator(resolver.position().root(), 0, 0 ), 0); |
821 break; | 819 break; |
822 } | 820 } |
823 | 821 |
824 ASSERT(endOfLine != resolver.position()); | 822 ASSERT(endOfLine != resolver.position()); |
825 | 823 |
826 // This is a short-cut for empty lines. | 824 // This is a short-cut for empty lines. |
827 if (layoutState.lineInfo().isEmpty()) { | 825 if (layoutState.lineInfo().isEmpty()) { |
828 if (lastRootBox()) | 826 if (lastRootBox()) |
829 lastRootBox()->setLineBreakInfo(endOfLine.object(), endOfLine.of fset(), resolver.status()); | 827 lastRootBox()->setLineBreakInfo(endOfLine.object(), endOfLine.of fset(), resolver.status()); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1005 } | 1003 } |
1006 } | 1004 } |
1007 } | 1005 } |
1008 setLogicalHeight(lastRootBox()->lineBottomWithLeading()); | 1006 setLogicalHeight(lastRootBox()->lineBottomWithLeading()); |
1009 } else { | 1007 } else { |
1010 // Delete all the remaining lines. | 1008 // Delete all the remaining lines. |
1011 deleteLineRange(layoutState, layoutState.endLine()); | 1009 deleteLineRange(layoutState, layoutState.endLine()); |
1012 } | 1010 } |
1013 } | 1011 } |
1014 | 1012 |
1015 if (m_floatingObjects && (layoutState.checkForFloatsFromLastLine() || positi onNewFloats()) && lastRootBox()) { | 1013 if (positionNewFloats() && lastRootBox()) { |
1016 // In case we have a float on the last line, it might not be positioned up to now. | 1014 // In case we have a float on the last line, it might not be positioned up to now. |
1017 // This has to be done before adding in the bottom border/padding, or th e float will | 1015 // This has to be done before adding in the bottom border/padding, or th e float will |
1018 // include the padding incorrectly. -dwh | 1016 // include the padding incorrectly. -dwh |
1019 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 1017 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
1020 FloatingObjectSetIterator it = floatingObjectSet.begin(); | 1018 FloatingObjectSetIterator it = floatingObjectSet.begin(); |
1021 FloatingObjectSetIterator end = floatingObjectSet.end(); | 1019 FloatingObjectSetIterator end = floatingObjectSet.end(); |
1022 if (layoutState.lastFloat()) { | 1020 if (layoutState.lastFloat()) { |
1023 FloatingObjectSetIterator lastFloatIterator = floatingObjectSet.find (layoutState.lastFloat()); | 1021 FloatingObjectSetIterator lastFloatIterator = floatingObjectSet.find (layoutState.lastFloat()); |
1024 ASSERT(lastFloatIterator != end); | 1022 ASSERT(lastFloatIterator != end); |
1025 ++lastFloatIterator; | 1023 ++lastFloatIterator; |
1026 it = lastFloatIterator; | 1024 it = lastFloatIterator; |
1027 } | 1025 } |
1028 layoutState.setLastFloat(!floatingObjectSet.isEmpty() ? floatingObjectSe t.last().get() : 0); | 1026 layoutState.setLastFloat(!floatingObjectSet.isEmpty() ? floatingObjectSe t.last().get() : 0); |
1029 | 1027 |
1030 if (it == end) | 1028 if (it == end) |
1031 return; | 1029 return; |
1032 | 1030 |
1033 if (layoutState.checkForFloatsFromLastLine()) { | |
1034 LayoutUnit bottomVisualOverflow = lastRootBox()->logicalBottomVisual Overflow(); | |
1035 LayoutUnit bottomLayoutOverflow = lastRootBox()->logicalBottomLayout Overflow(); | |
1036 TrailingFloatsRootInlineBox* trailingFloatsLineBox = new TrailingFlo atsRootInlineBox(*this); | |
1037 m_lineBoxes.appendLineBox(trailingFloatsLineBox); | |
1038 trailingFloatsLineBox->setConstructed(); | |
1039 GlyphOverflowAndFallbackFontsMap textBoxDataMap; | |
1040 VerticalPositionCache verticalPositionCache; | |
1041 LayoutUnit blockLogicalHeight = logicalHeight(); | |
1042 trailingFloatsLineBox->alignBoxesInBlockDirection(blockLogicalHeight , textBoxDataMap, verticalPositionCache); | |
1043 trailingFloatsLineBox->setLineTopBottomPositions(blockLogicalHeight, blockLogicalHeight, blockLogicalHeight, blockLogicalHeight); | |
1044 LayoutRect logicalLayoutOverflow(0, blockLogicalHeight, 1, bottomLay outOverflow - blockLogicalHeight); | |
1045 LayoutRect logicalVisualOverflow(0, blockLogicalHeight, 1, bottomVis ualOverflow - blockLogicalHeight); | |
1046 trailingFloatsLineBox->setOverflowFromLogicalRects(logicalLayoutOver flow, logicalVisualOverflow, trailingFloatsLineBox->lineTop(), trailingFloatsLin eBox->lineBottom()); | |
1047 } | |
1048 | |
1049 for (; it != end; ++it) | 1031 for (; it != end; ++it) |
1050 appendFloatingObjectToLastLine(*it->get()); | 1032 appendFloatingObjectToLastLine(*it->get()); |
1051 } | 1033 } |
1052 } | 1034 } |
1053 | 1035 |
1054 void LayoutBlockFlow::markDirtyFloatsForPaintInvalidation(Vector<FloatWithRect>& floats) | 1036 void LayoutBlockFlow::markDirtyFloatsForPaintInvalidation(Vector<FloatWithRect>& floats) |
1055 { | 1037 { |
1056 size_t floatCount = floats.size(); | 1038 size_t floatCount = floats.size(); |
1057 // Floats that did not have layout did not paint invalidations when we laid them out. They would have | 1039 // Floats that did not have layout did not paint invalidations when we laid them out. They would have |
1058 // painted by now if they had moved, but if they stayed at (0, 0), they stil l need to be | 1040 // painted by now if they had moved, but if they stayed at (0, 0), they stil l need to be |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1539 if (hasTextOverflow) | 1521 if (hasTextOverflow) |
1540 deleteEllipsisLineBoxes(); | 1522 deleteEllipsisLineBoxes(); |
1541 | 1523 |
1542 if (firstChild()) { | 1524 if (firstChild()) { |
1543 // In full layout mode, clear the line boxes of children upfront. Otherw ise, | 1525 // In full layout mode, clear the line boxes of children upfront. Otherw ise, |
1544 // siblings can run into stale root lineboxes during layout. Then layout | 1526 // siblings can run into stale root lineboxes during layout. Then layout |
1545 // the replaced elements later. In partial layout mode, line boxes are n ot | 1527 // the replaced elements later. In partial layout mode, line boxes are n ot |
1546 // deleted and only dirtied. In that case, we can layout the replaced | 1528 // deleted and only dirtied. In that case, we can layout the replaced |
1547 // elements at the same time. | 1529 // elements at the same time. |
1548 Vector<LayoutBox*> replacedChildren; | 1530 Vector<LayoutBox*> replacedChildren; |
1531 LayoutObject* lastChild = nullptr; | |
1549 for (InlineWalker walker(this); !walker.atEnd(); walker.advance()) { | 1532 for (InlineWalker walker(this); !walker.atEnd(); walker.advance()) { |
1550 LayoutObject* o = walker.current(); | 1533 LayoutObject* o = walker.current(); |
1551 | 1534 |
1552 if (!layoutState.hasInlineChild() && o->isInline()) | 1535 if (!layoutState.hasInlineChild() && o->isInline()) |
1553 layoutState.setHasInlineChild(true); | 1536 layoutState.setHasInlineChild(true); |
1554 | 1537 |
1555 if (o->isReplaced() || o->isFloating() || o->isOutOfFlowPositioned() ) { | 1538 if (o->isReplaced() || o->isFloating() || o->isOutOfFlowPositioned() ) { |
1556 LayoutBox* box = toLayoutBox(o); | 1539 LayoutBox* box = toLayoutBox(o); |
1557 | 1540 |
1558 updateBlockChildDirtyBitsBeforeLayout(relayoutChildren, *box); | 1541 updateBlockChildDirtyBitsBeforeLayout(relayoutChildren, *box); |
(...skipping 14 matching lines...) Expand all Loading... | |
1573 else | 1556 else |
1574 o->layoutIfNeeded(); | 1557 o->layoutIfNeeded(); |
1575 } | 1558 } |
1576 } else if (o->isText() || (o->isLayoutInline() && !walker.atEndOfInl ine())) { | 1559 } else if (o->isText() || (o->isLayoutInline() && !walker.atEndOfInl ine())) { |
1577 if (!o->isText()) | 1560 if (!o->isText()) |
1578 toLayoutInline(o)->updateAlwaysCreateLineBoxes(layoutState.i sFullLayout()); | 1561 toLayoutInline(o)->updateAlwaysCreateLineBoxes(layoutState.i sFullLayout()); |
1579 if (layoutState.isFullLayout() || o->selfNeedsLayout()) | 1562 if (layoutState.isFullLayout() || o->selfNeedsLayout()) |
1580 dirtyLineBoxesForObject(o, layoutState.isFullLayout()); | 1563 dirtyLineBoxesForObject(o, layoutState.isFullLayout()); |
1581 o->clearNeedsLayout(); | 1564 o->clearNeedsLayout(); |
1582 } | 1565 } |
1566 if (!o->isText() || !toLayoutText(o)->isAllCollapsibleWhitespace()) | |
1567 lastChild = o; | |
1583 } | 1568 } |
1569 // If there is a trailing float on the line that will possibly occur aft er a natural line break | |
1570 // then dirty its adjacent lineboxes to ensure it gets placed. | |
leviw_travelin_and_unemployed
2015/07/28 18:25:38
If it's the last child and a float, will we ever b
rhogan
2015/07/28 19:10:37
The one it's on and possibly the one before it. Th
| |
1571 if (lastChild && lastChild->isFloating()) | |
1572 dirtyLinesFromChangedChild(lastChild); | |
leviw_travelin_and_unemployed
2015/07/28 18:25:38
Where did we dirty these lines before?
rhogan
2015/07/28 19:10:37
We didn't. Instead we added a new line box at the
| |
1584 | 1573 |
1585 for (size_t i = 0; i < replacedChildren.size(); i++) | 1574 for (size_t i = 0; i < replacedChildren.size(); i++) |
1586 replacedChildren[i]->layoutIfNeeded(); | 1575 replacedChildren[i]->layoutIfNeeded(); |
1587 | 1576 |
1588 layoutRunsAndFloats(layoutState); | 1577 layoutRunsAndFloats(layoutState); |
1589 } | 1578 } |
1590 | 1579 |
1591 // Expand the last line to accommodate Ruby and emphasis marks. | 1580 // Expand the last line to accommodate Ruby and emphasis marks. |
1592 int lastLineAnnotationsAdjustment = 0; | 1581 int lastLineAnnotationsAdjustment = 0; |
1593 if (lastRootBox()) { | 1582 if (lastRootBox()) { |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2033 LayoutUnit logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false); | 2022 LayoutUnit logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false); |
2034 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(logicalHeight() , false) - logicalLeft; | 2023 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(logicalHeight() , false) - logicalLeft; |
2035 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); | 2024 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); |
2036 | 2025 |
2037 if (!style()->isLeftToRightDirection()) | 2026 if (!style()->isLeftToRightDirection()) |
2038 return logicalWidth() - logicalLeft; | 2027 return logicalWidth() - logicalLeft; |
2039 return logicalLeft; | 2028 return logicalLeft; |
2040 } | 2029 } |
2041 | 2030 |
2042 } | 2031 } |
OLD | NEW |