| 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 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 | 757 |
| 758 // Before restarting the layout loop with a new logicalHeight, remove all floats
that were added and reset the resolver. | 758 // Before restarting the layout loop with a new logicalHeight, remove all floats
that were added and reset the resolver. |
| 759 inline const InlineIterator& LayoutBlockFlow::restartLayoutRunsAndFloatsInRange(
LayoutUnit oldLogicalHeight, LayoutUnit newLogicalHeight, FloatingObject* lastF
loatFromPreviousLine, InlineBidiResolver& resolver, const InlineIterator& oldEn
d) | 759 inline const InlineIterator& LayoutBlockFlow::restartLayoutRunsAndFloatsInRange(
LayoutUnit oldLogicalHeight, LayoutUnit newLogicalHeight, FloatingObject* lastF
loatFromPreviousLine, InlineBidiResolver& resolver, const InlineIterator& oldEn
d) |
| 760 { | 760 { |
| 761 removeFloatingObjectsBelow(lastFloatFromPreviousLine, oldLogicalHeight); | 761 removeFloatingObjectsBelow(lastFloatFromPreviousLine, oldLogicalHeight); |
| 762 setLogicalHeight(newLogicalHeight); | 762 setLogicalHeight(newLogicalHeight); |
| 763 resolver.setPositionIgnoringNestedIsolates(oldEnd); | 763 resolver.setPositionIgnoringNestedIsolates(oldEnd); |
| 764 return oldEnd; | 764 return oldEnd; |
| 765 } | 765 } |
| 766 | 766 |
| 767 void LayoutBlockFlow::appendFloatsToLastLine(LineLayoutState& layoutState, const
InlineIterator& cleanLineStart) |
| 768 { |
| 769 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
| 770 FloatingObjectSetIterator it = floatingObjectSet.begin(); |
| 771 FloatingObjectSetIterator end = floatingObjectSet.end(); |
| 772 if (layoutState.lastFloat()) { |
| 773 FloatingObjectSetIterator lastFloatIterator = floatingObjectSet.find(lay
outState.lastFloat()); |
| 774 ASSERT(lastFloatIterator != end); |
| 775 ++lastFloatIterator; |
| 776 it = lastFloatIterator; |
| 777 } |
| 778 for (; it != end; ++it) { |
| 779 FloatingObject& floatingObject = *it->get(); |
| 780 // If we've reached the start of clean lines any remaining floating chil
dren belong to them. |
| 781 if (floatingObject.layoutObject() == cleanLineStart.object() && layoutSt
ate.endLine()) { |
| 782 layoutState.setLastFloat(&floatingObject); |
| 783 return; |
| 784 } |
| 785 appendFloatingObjectToLastLine(floatingObject); |
| 786 ASSERT(floatingObject.layoutObject() == layoutState.floats()[layoutState
.floatIndex()].object); |
| 787 // If a float's geometry has changed, give up on syncing with clean line
s. |
| 788 if (layoutState.floats()[layoutState.floatIndex()].rect != floatingObjec
t.frameRect()) { |
| 789 // Delete all the remaining lines. |
| 790 deleteLineRange(layoutState, layoutState.endLine()); |
| 791 layoutState.setEndLine(nullptr); |
| 792 } |
| 793 layoutState.setFloatIndex(layoutState.floatIndex() + 1); |
| 794 } |
| 795 layoutState.setLastFloat(!floatingObjectSet.isEmpty() ? floatingObjectSet.la
st().get() : 0); |
| 796 } |
| 797 |
| 767 void LayoutBlockFlow::layoutRunsAndFloatsInRange(LineLayoutState& layoutState, | 798 void LayoutBlockFlow::layoutRunsAndFloatsInRange(LineLayoutState& layoutState, |
| 768 InlineBidiResolver& resolver, const InlineIterator& cleanLineStart, | 799 InlineBidiResolver& resolver, const InlineIterator& cleanLineStart, |
| 769 const BidiStatus& cleanLineBidiStatus) | 800 const BidiStatus& cleanLineBidiStatus) |
| 770 { | 801 { |
| 771 const ComputedStyle& styleToUse = styleRef(); | 802 const ComputedStyle& styleToUse = styleRef(); |
| 772 bool paginated = view()->layoutState() && view()->layoutState()->isPaginated
(); | 803 bool paginated = view()->layoutState() && view()->layoutState()->isPaginated
(); |
| 773 LineMidpointState& lineMidpointState = resolver.midpointState(); | 804 LineMidpointState& lineMidpointState = resolver.midpointState(); |
| 774 InlineIterator endOfLine = resolver.position(); | 805 InlineIterator endOfLine = resolver.position(); |
| 775 bool checkForEndLineMatch = layoutState.endLine(); | |
| 776 LayoutTextInfo layoutTextInfo; | 806 LayoutTextInfo layoutTextInfo; |
| 777 VerticalPositionCache verticalPositionCache; | 807 VerticalPositionCache verticalPositionCache; |
| 778 | 808 |
| 779 LineBreaker lineBreaker(LineLayoutBlockFlow(this)); | 809 LineBreaker lineBreaker(LineLayoutBlockFlow(this)); |
| 780 | 810 |
| 781 while (!endOfLine.atEnd()) { | 811 while (!endOfLine.atEnd()) { |
| 782 bool logicalWidthIsAvailable = false; | 812 bool logicalWidthIsAvailable = false; |
| 783 | 813 |
| 784 // FIXME: Is this check necessary before the first iteration or can it b
e moved to the end? | 814 // FIXME: Is this check necessary before the first iteration or can it b
e moved to the end? |
| 785 if (checkForEndLineMatch) { | 815 if (layoutState.endLine()) { |
| 786 layoutState.setEndLineMatched(matchedEndLine(layoutState, resolver,
cleanLineStart, cleanLineBidiStatus)); | 816 layoutState.setEndLineMatched(matchedEndLine(layoutState, resolver,
cleanLineStart, cleanLineBidiStatus)); |
| 787 if (layoutState.endLineMatched()) { | 817 if (layoutState.endLineMatched()) { |
| 788 resolver.setPosition(InlineIterator(resolver.position().root(),
0, 0), 0); | 818 resolver.setPosition(InlineIterator(resolver.position().root(),
0, 0), 0); |
| 789 break; | 819 break; |
| 790 } | 820 } |
| 791 } | 821 } |
| 792 | 822 |
| 793 lineMidpointState.reset(); | 823 lineMidpointState.reset(); |
| 794 | 824 |
| 795 layoutState.lineInfo().setEmpty(true); | 825 layoutState.lineInfo().setEmpty(true); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 } | 902 } |
| 873 | 903 |
| 874 if (!logicalWidthIsAvailable) { | 904 if (!logicalWidthIsAvailable) { |
| 875 for (size_t i = 0; i < lineBreaker.positionedObjects().size(); ++i) | 905 for (size_t i = 0; i < lineBreaker.positionedObjects().size(); ++i) |
| 876 setStaticPositions(LineLayoutBlockFlow(this), LineLayoutBox(line
Breaker.positionedObjects()[i])); | 906 setStaticPositions(LineLayoutBlockFlow(this), LineLayoutBox(line
Breaker.positionedObjects()[i])); |
| 877 | 907 |
| 878 if (!layoutState.lineInfo().isEmpty()) | 908 if (!layoutState.lineInfo().isEmpty()) |
| 879 layoutState.lineInfo().setFirstLine(false); | 909 layoutState.lineInfo().setFirstLine(false); |
| 880 clearFloats(lineBreaker.clear()); | 910 clearFloats(lineBreaker.clear()); |
| 881 | 911 |
| 882 if (m_floatingObjects && lastRootBox()) { | 912 if (m_floatingObjects && lastRootBox()) |
| 883 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->
set(); | 913 appendFloatsToLastLine(layoutState, cleanLineStart); |
| 884 FloatingObjectSetIterator it = floatingObjectSet.begin(); | |
| 885 FloatingObjectSetIterator end = floatingObjectSet.end(); | |
| 886 if (layoutState.lastFloat()) { | |
| 887 FloatingObjectSetIterator lastFloatIterator = floatingObject
Set.find(layoutState.lastFloat()); | |
| 888 ASSERT(lastFloatIterator != end); | |
| 889 ++lastFloatIterator; | |
| 890 it = lastFloatIterator; | |
| 891 } | |
| 892 for (; it != end; ++it) { | |
| 893 FloatingObject& floatingObject = *it->get(); | |
| 894 // If we've reached the start of clean lines any remaining f
loating children belong to them. | |
| 895 // We don't care about the 'last float' mechanism once we're
in clean lines so it's ok to let it get set below. | |
| 896 if (floatingObject.layoutObject() == cleanLineStart.object()
) | |
| 897 break; | |
| 898 appendFloatingObjectToLastLine(floatingObject); | |
| 899 ASSERT(floatingObject.layoutObject() == layoutState.floats()
[layoutState.floatIndex()].object); | |
| 900 // If a float's geometry has changed, give up on syncing wit
h clean lines. | |
| 901 if (layoutState.floats()[layoutState.floatIndex()].rect != f
loatingObject.frameRect()) | |
| 902 checkForEndLineMatch = false; | |
| 903 layoutState.setFloatIndex(layoutState.floatIndex() + 1); | |
| 904 } | |
| 905 layoutState.setLastFloat(!floatingObjectSet.isEmpty() ? floating
ObjectSet.last().get() : 0); | |
| 906 } | |
| 907 } | 914 } |
| 908 | 915 |
| 909 lineMidpointState.reset(); | 916 lineMidpointState.reset(); |
| 910 resolver.setPosition(endOfLine, numberOfIsolateAncestors(endOfLine)); | 917 resolver.setPosition(endOfLine, numberOfIsolateAncestors(endOfLine)); |
| 911 } | 918 } |
| 912 | 919 |
| 913 // In case we already adjusted the line positions during this layout to avoi
d widows | 920 // In case we already adjusted the line positions during this layout to avoi
d widows |
| 914 // then we need to ignore the possibility of having a new widows situation. | 921 // then we need to ignore the possibility of having a new widows situation. |
| 915 // Otherwise, we risk leaving empty containers which is against the block fr
agmentation principles. | 922 // Otherwise, we risk leaving empty containers which is against the block fr
agmentation principles. |
| 916 if (paginated && !style()->hasAutoWidows() && !didBreakAtLineToAvoidWidow())
{ | 923 if (paginated && !style()->hasAutoWidows() && !didBreakAtLineToAvoidWidow())
{ |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1000 } | 1007 } |
| 1001 } | 1008 } |
| 1002 } | 1009 } |
| 1003 setLogicalHeight(lastRootBox()->lineBottomWithLeading()); | 1010 setLogicalHeight(lastRootBox()->lineBottomWithLeading()); |
| 1004 } else { | 1011 } else { |
| 1005 // Delete all the remaining lines. | 1012 // Delete all the remaining lines. |
| 1006 deleteLineRange(layoutState, layoutState.endLine()); | 1013 deleteLineRange(layoutState, layoutState.endLine()); |
| 1007 } | 1014 } |
| 1008 } | 1015 } |
| 1009 | 1016 |
| 1010 if (positionNewFloats() && lastRootBox()) { | 1017 // In case we have a float on the last line, it might not be positioned up t
o now. |
| 1011 // In case we have a float on the last line, it might not be positioned
up to now. | 1018 // This has to be done before adding in the bottom border/padding, or the fl
oat will |
| 1012 // This has to be done before adding in the bottom border/padding, or th
e float will | 1019 // include the padding incorrectly. -dwh |
| 1013 // include the padding incorrectly. -dwh | 1020 if (positionNewFloats() && lastRootBox()) |
| 1014 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 1021 appendFloatsToLastLine(layoutState, InlineIterator()); |
| 1015 FloatingObjectSetIterator it = floatingObjectSet.begin(); | |
| 1016 FloatingObjectSetIterator end = floatingObjectSet.end(); | |
| 1017 if (layoutState.lastFloat()) { | |
| 1018 FloatingObjectSetIterator lastFloatIterator = floatingObjectSet.find
(layoutState.lastFloat()); | |
| 1019 ASSERT(lastFloatIterator != end); | |
| 1020 ++lastFloatIterator; | |
| 1021 it = lastFloatIterator; | |
| 1022 } | |
| 1023 layoutState.setLastFloat(!floatingObjectSet.isEmpty() ? floatingObjectSe
t.last().get() : 0); | |
| 1024 | |
| 1025 if (it == end) | |
| 1026 return; | |
| 1027 | |
| 1028 for (; it != end; ++it) | |
| 1029 appendFloatingObjectToLastLine(*it->get()); | |
| 1030 } | |
| 1031 } | 1022 } |
| 1032 | 1023 |
| 1033 void LayoutBlockFlow::markDirtyFloatsForPaintInvalidation(Vector<FloatWithRect>&
floats) | 1024 void LayoutBlockFlow::markDirtyFloatsForPaintInvalidation(Vector<FloatWithRect>&
floats) |
| 1034 { | 1025 { |
| 1035 size_t floatCount = floats.size(); | 1026 size_t floatCount = floats.size(); |
| 1036 // Floats that did not have layout did not paint invalidations when we laid
them out. They would have | 1027 // Floats that did not have layout did not paint invalidations when we laid
them out. They would have |
| 1037 // painted by now if they had moved, but if they stayed at (0, 0), they stil
l need to be | 1028 // painted by now if they had moved, but if they stayed at (0, 0), they stil
l need to be |
| 1038 // painted. | 1029 // painted. |
| 1039 for (size_t i = 0; i < floatCount; ++i) { | 1030 for (size_t i = 0; i < floatCount; ++i) { |
| 1040 LayoutBox* f = floats[i].object; | 1031 LayoutBox* f = floats[i].object; |
| (...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2036 LayoutUnit logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false); | 2027 LayoutUnit logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false); |
| 2037 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(logicalHeight()
, false) - logicalLeft; | 2028 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(logicalHeight()
, false) - logicalLeft; |
| 2038 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid
th, availableLogicalWidth, 0); | 2029 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid
th, availableLogicalWidth, 0); |
| 2039 | 2030 |
| 2040 if (!style()->isLeftToRightDirection()) | 2031 if (!style()->isLeftToRightDirection()) |
| 2041 return logicalWidth() - logicalLeft; | 2032 return logicalWidth() - logicalLeft; |
| 2042 return logicalLeft; | 2033 return logicalLeft; |
| 2043 } | 2034 } |
| 2044 | 2035 |
| 2045 } | 2036 } |
| OLD | NEW |