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 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
971 lineMidpointState.reset(); | 971 lineMidpointState.reset(); |
972 resolver.setPosition(endOfLine, numberOfIsolateAncestors(endOfLine)); | 972 resolver.setPosition(endOfLine, numberOfIsolateAncestors(endOfLine)); |
973 } | 973 } |
974 | 974 |
975 // The resolver runs should have been cleared, otherwise they're leaking. | 975 // The resolver runs should have been cleared, otherwise they're leaking. |
976 ASSERT(!resolver.runs().runCount()); | 976 ASSERT(!resolver.runs().runCount()); |
977 | 977 |
978 // In case we already adjusted the line positions during this layout to avoi
d widows | 978 // In case we already adjusted the line positions during this layout to avoi
d widows |
979 // then we need to ignore the possibility of having a new widows situation. | 979 // then we need to ignore the possibility of having a new widows situation. |
980 // Otherwise, we risk leaving empty containers which is against the block fr
agmentation principles. | 980 // Otherwise, we risk leaving empty containers which is against the block fr
agmentation principles. |
981 if (paginated && !style()->hasAutoWidows() && !didBreakAtLineToAvoidWidow())
{ | 981 if (paginated && style()->widows() > 1 && !didBreakAtLineToAvoidWidow()) { |
982 // Check the line boxes to make sure we didn't create unacceptable widow
s. | 982 // Check the line boxes to make sure we didn't create unacceptable widow
s. |
983 // However, we'll prioritize orphans - so nothing we do here should crea
te | 983 // However, we'll prioritize orphans - so nothing we do here should crea
te |
984 // a new orphan. | 984 // a new orphan. |
985 | 985 |
986 RootInlineBox* lineBox = lastRootBox(); | 986 RootInlineBox* lineBox = lastRootBox(); |
987 | 987 |
988 // Count from the end of the block backwards, to see how many hanging | 988 // Count from the end of the block backwards, to see how many hanging |
989 // lines we have. | 989 // lines we have. |
990 RootInlineBox* firstLineInBlock = firstRootBox(); | 990 RootInlineBox* firstLineInBlock = firstRootBox(); |
991 int numLinesHanging = 1; | 991 int numLinesHanging = 1; |
(...skipping 19 matching lines...) Expand all Loading... |
1011 while (lineBox && lineBox != firstLineInBlock && !lineBox->isFirstAf
terPageBreak()) { | 1011 while (lineBox && lineBox != firstLineInBlock && !lineBox->isFirstAf
terPageBreak()) { |
1012 ++numLinesInPreviousPage; | 1012 ++numLinesInPreviousPage; |
1013 lineBox = lineBox->prevRootBox(); | 1013 lineBox = lineBox->prevRootBox(); |
1014 } | 1014 } |
1015 | 1015 |
1016 // If there was an explicit value for orphans, respect that. If not,
we still | 1016 // If there was an explicit value for orphans, respect that. If not,
we still |
1017 // shouldn't create a situation where we make an orphan bigger than
the initial value. | 1017 // shouldn't create a situation where we make an orphan bigger than
the initial value. |
1018 // This means that setting widows implies we also care about orphans
, but given | 1018 // This means that setting widows implies we also care about orphans
, but given |
1019 // the specification says the initial orphan value is non-zero, this
is ok. The | 1019 // the specification says the initial orphan value is non-zero, this
is ok. The |
1020 // author is always free to set orphans explicitly as well. | 1020 // author is always free to set orphans explicitly as well. |
1021 int orphans = style()->hasAutoOrphans() ? style()->initialOrphans()
: style()->orphans(); | 1021 int orphans = style()->orphans(); |
1022 int numLinesAvailable = numLinesInPreviousPage - orphans; | 1022 int numLinesAvailable = numLinesInPreviousPage - orphans; |
1023 if (numLinesAvailable <= 0) | 1023 if (numLinesAvailable <= 0) |
1024 return; | 1024 return; |
1025 | 1025 |
1026 int numLinesToTake = std::min(numLinesAvailable, numLinesNeeded); | 1026 int numLinesToTake = std::min(numLinesAvailable, numLinesNeeded); |
1027 // Wind back from our first widowed line. | 1027 // Wind back from our first widowed line. |
1028 lineBox = currentFirstLineOfNewPage; | 1028 lineBox = currentFirstLineOfNewPage; |
1029 for (int i = 0; i < numLinesToTake; ++i) | 1029 for (int i = 0; i < numLinesToTake; ++i) |
1030 lineBox = lineBox->prevRootBox(); | 1030 lineBox = lineBox->prevRootBox(); |
1031 | 1031 |
(...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2078 if (!line || !line->isFirstLineStyle()) | 2078 if (!line || !line->isFirstLineStyle()) |
2079 return reason; | 2079 return reason; |
2080 // It's the RootInlineBox that paints the ::first-line background. Note that
since it may be | 2080 // It's the RootInlineBox that paints the ::first-line background. Note that
since it may be |
2081 // expensive to figure out if the first line is affected by any ::first-line
selectors at all, | 2081 // expensive to figure out if the first line is affected by any ::first-line
selectors at all, |
2082 // we just invalidate it unconditionally, since that's typically cheaper. | 2082 // we just invalidate it unconditionally, since that's typically cheaper. |
2083 invalidateDisplayItemClient(*line); | 2083 invalidateDisplayItemClient(*line); |
2084 return reason; | 2084 return reason; |
2085 } | 2085 } |
2086 | 2086 |
2087 } // namespace blink | 2087 } // namespace blink |
OLD | NEW |