| 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 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 895 | 895 |
| 896 if (!logicalWidthIsAvailable) { | 896 if (!logicalWidthIsAvailable) { |
| 897 for (size_t i = 0; i < lineBreaker.positionedObjects().size(); ++i) | 897 for (size_t i = 0; i < lineBreaker.positionedObjects().size(); ++i) |
| 898 setStaticPositions(this, lineBreaker.positionedObjects()[i]); | 898 setStaticPositions(this, lineBreaker.positionedObjects()[i]); |
| 899 | 899 |
| 900 if (!layoutState.lineInfo().isEmpty()) { | 900 if (!layoutState.lineInfo().isEmpty()) { |
| 901 layoutState.lineInfo().setFirstLine(false); | 901 layoutState.lineInfo().setFirstLine(false); |
| 902 clearFloats(lineBreaker.clear()); | 902 clearFloats(lineBreaker.clear()); |
| 903 } | 903 } |
| 904 | 904 |
| 905 if (appendFloatsToEndOfLine(layoutState, true)) | 905 if (m_floatingObjects && lastRootBox()) { |
| 906 checkForEndLineMatch = false; | 906 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->
set(); |
| 907 FloatingObjectSetIterator it = floatingObjectSet.begin(); |
| 908 FloatingObjectSetIterator end = floatingObjectSet.end(); |
| 909 if (layoutState.lastFloat()) { |
| 910 FloatingObjectSetIterator lastFloatIterator = floatingObject
Set.find(layoutState.lastFloat()); |
| 911 ASSERT(lastFloatIterator != end); |
| 912 ++lastFloatIterator; |
| 913 it = lastFloatIterator; |
| 914 } |
| 915 for (; it != end; ++it) { |
| 916 FloatingObject* f = it->get(); |
| 917 appendFloatingObjectToLastLine(f); |
| 918 ASSERT(f->layoutObject() == layoutState.floats()[layoutState
.floatIndex()].object); |
| 919 // If a float's geometry has changed, give up on syncing wit
h clean lines. |
| 920 if (layoutState.floats()[layoutState.floatIndex()].rect != f
->frameRect()) |
| 921 checkForEndLineMatch = false; |
| 922 layoutState.setFloatIndex(layoutState.floatIndex() + 1); |
| 923 } |
| 924 layoutState.setLastFloat(!floatingObjectSet.isEmpty() ? floating
ObjectSet.last().get() : 0); |
| 925 } |
| 907 } | 926 } |
| 908 | 927 |
| 909 lineMidpointState.reset(); | 928 lineMidpointState.reset(); |
| 910 resolver.setPosition(endOfLine, numberOfIsolateAncestors(endOfLine)); | 929 resolver.setPosition(endOfLine, numberOfIsolateAncestors(endOfLine)); |
| 911 } | 930 } |
| 912 | 931 |
| 913 // In case we already adjusted the line positions during this layout to avoi
d widows | 932 // 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. | 933 // 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. | 934 // Otherwise, we risk leaving empty containers which is against the block fr
agmentation principles. |
| 916 if (paginated && !style()->hasAutoWidows() && !didBreakAtLineToAvoidWidow())
{ | 935 if (paginated && !style()->hasAutoWidows() && !didBreakAtLineToAvoidWidow())
{ |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 966 | 985 |
| 967 // We now want to break at this line. Remember for next layout and t
rigger relayout. | 986 // We now want to break at this line. Remember for next layout and t
rigger relayout. |
| 968 setBreakAtLineToAvoidWidow(lineCount(lineBox)); | 987 setBreakAtLineToAvoidWidow(lineCount(lineBox)); |
| 969 markLinesDirtyInBlockRange(lastRootBox()->lineBottomWithLeading(), l
ineBox->lineBottomWithLeading(), lineBox); | 988 markLinesDirtyInBlockRange(lastRootBox()->lineBottomWithLeading(), l
ineBox->lineBottomWithLeading(), lineBox); |
| 970 } | 989 } |
| 971 } | 990 } |
| 972 | 991 |
| 973 clearDidBreakAtLineToAvoidWidow(); | 992 clearDidBreakAtLineToAvoidWidow(); |
| 974 } | 993 } |
| 975 | 994 |
| 976 bool LayoutBlockFlow::appendFloatsToEndOfLine(LineLayoutState& layoutState, bool
updateFloatIndex) | |
| 977 { | |
| 978 if (!m_floatingObjects || !lastRootBox()) | |
| 979 return false; | |
| 980 | |
| 981 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | |
| 982 FloatingObjectSetIterator it = floatingObjectSet.begin(); | |
| 983 FloatingObjectSetIterator end = floatingObjectSet.end(); | |
| 984 if (layoutState.lastFloat()) { | |
| 985 FloatingObjectSetIterator lastFloatIterator = floatingObjectSet.find(lay
outState.lastFloat()); | |
| 986 ASSERT(lastFloatIterator != end); | |
| 987 ++lastFloatIterator; | |
| 988 it = lastFloatIterator; | |
| 989 } | |
| 990 | |
| 991 bool floatChangedSize = false; | |
| 992 for (; it != end; ++it) { | |
| 993 FloatingObject* f = it->get(); | |
| 994 appendFloatingObjectToLastLine(f); | |
| 995 if (updateFloatIndex) { | |
| 996 ASSERT(f->layoutObject() == layoutState.floats()[layoutState.floatIn
dex()].object); | |
| 997 // If a float's geometry has changed, give up on syncing with clean
lines. | |
| 998 if (layoutState.floats()[layoutState.floatIndex()].rect != f->frameR
ect()) | |
| 999 floatChangedSize = true; | |
| 1000 layoutState.setFloatIndex(layoutState.floatIndex() + 1); | |
| 1001 } | |
| 1002 } | |
| 1003 layoutState.setLastFloat(!floatingObjectSet.isEmpty() ? floatingObjectSet.la
st().get() : 0); | |
| 1004 return floatChangedSize; | |
| 1005 } | |
| 1006 | |
| 1007 void LayoutBlockFlow::linkToEndLineIfNeeded(LineLayoutState& layoutState) | 995 void LayoutBlockFlow::linkToEndLineIfNeeded(LineLayoutState& layoutState) |
| 1008 { | 996 { |
| 1009 if (layoutState.endLine()) { | 997 if (layoutState.endLine()) { |
| 1010 if (layoutState.endLineMatched()) { | 998 if (layoutState.endLineMatched()) { |
| 1011 bool paginated = view()->layoutState() && view()->layoutState()->isP
aginated(); | 999 bool paginated = view()->layoutState() && view()->layoutState()->isP
aginated(); |
| 1012 // Attach all the remaining lines, and then adjust their y-positions
as needed. | 1000 // Attach all the remaining lines, and then adjust their y-positions
as needed. |
| 1013 LayoutUnit delta = logicalHeight() - layoutState.endLineLogicalTop()
; | 1001 LayoutUnit delta = logicalHeight() - layoutState.endLineLogicalTop()
; |
| 1014 for (RootInlineBox* line = layoutState.endLine(); line; line = line-
>nextRootBox()) { | 1002 for (RootInlineBox* line = layoutState.endLine(); line; line = line-
>nextRootBox()) { |
| 1015 line->attachLine(); | 1003 line->attachLine(); |
| 1016 if (paginated) { | 1004 if (paginated) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1031 } | 1019 } |
| 1032 } | 1020 } |
| 1033 } | 1021 } |
| 1034 setLogicalHeight(lastRootBox()->lineBottomWithLeading()); | 1022 setLogicalHeight(lastRootBox()->lineBottomWithLeading()); |
| 1035 } else { | 1023 } else { |
| 1036 // Delete all the remaining lines. | 1024 // Delete all the remaining lines. |
| 1037 deleteLineRange(layoutState, layoutState.endLine()); | 1025 deleteLineRange(layoutState, layoutState.endLine()); |
| 1038 } | 1026 } |
| 1039 } | 1027 } |
| 1040 | 1028 |
| 1041 if (positionNewFloats()) | 1029 if (positionNewFloats() && lastRootBox()) { |
| 1042 appendFloatsToEndOfLine(layoutState, false); | 1030 // In case we have a float on the last line, it might not be positioned
up to now. |
| 1031 // This has to be done before adding in the bottom border/padding, or th
e float will |
| 1032 // include the padding incorrectly. -dwh |
| 1033 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
| 1034 FloatingObjectSetIterator it = floatingObjectSet.begin(); |
| 1035 FloatingObjectSetIterator end = floatingObjectSet.end(); |
| 1036 if (layoutState.lastFloat()) { |
| 1037 FloatingObjectSetIterator lastFloatIterator = floatingObjectSet.find
(layoutState.lastFloat()); |
| 1038 ASSERT(lastFloatIterator != end); |
| 1039 ++lastFloatIterator; |
| 1040 it = lastFloatIterator; |
| 1041 } |
| 1042 layoutState.setLastFloat(!floatingObjectSet.isEmpty() ? floatingObjectSe
t.last().get() : 0); |
| 1043 |
| 1044 if (it == end) |
| 1045 return; |
| 1046 |
| 1047 for (; it != end; ++it) |
| 1048 appendFloatingObjectToLastLine(it->get()); |
| 1049 } |
| 1043 } | 1050 } |
| 1044 | 1051 |
| 1045 void LayoutBlockFlow::markDirtyFloatsForPaintInvalidation(Vector<FloatWithRect>&
floats) | 1052 void LayoutBlockFlow::markDirtyFloatsForPaintInvalidation(Vector<FloatWithRect>&
floats) |
| 1046 { | 1053 { |
| 1047 size_t floatCount = floats.size(); | 1054 size_t floatCount = floats.size(); |
| 1048 // Floats that did not have layout did not paint invalidations when we laid
them out. They would have | 1055 // Floats that did not have layout did not paint invalidations when we laid
them out. They would have |
| 1049 // painted by now if they had moved, but if they stayed at (0, 0), they stil
l need to be | 1056 // painted by now if they had moved, but if they stayed at (0, 0), they stil
l need to be |
| 1050 // painted. | 1057 // painted. |
| 1051 for (size_t i = 0; i < floatCount; ++i) { | 1058 for (size_t i = 0; i < floatCount; ++i) { |
| 1052 if (!floats[i].everHadLayout) { | 1059 if (!floats[i].everHadLayout) { |
| (...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2026 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat
(); | 2033 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat
(); |
| 2027 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal
se) - logicalLeft; | 2034 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal
se) - logicalLeft; |
| 2028 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid
th, availableLogicalWidth, 0); | 2035 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid
th, availableLogicalWidth, 0); |
| 2029 | 2036 |
| 2030 if (!style()->isLeftToRightDirection()) | 2037 if (!style()->isLeftToRightDirection()) |
| 2031 return logicalWidth() - logicalLeft; | 2038 return logicalWidth() - logicalLeft; |
| 2032 return logicalLeft; | 2039 return logicalLeft; |
| 2033 } | 2040 } |
| 2034 | 2041 |
| 2035 } | 2042 } |
| OLD | NEW |