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 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
969 | 969 |
970 const SegmentRangeList& segmentRanges = shapeInsideInfo->segmentRanges(); | 970 const SegmentRangeList& segmentRanges = shapeInsideInfo->segmentRanges(); |
971 ASSERT(segmentRanges.size()); | 971 ASSERT(segmentRanges.size()); |
972 | 972 |
973 for (size_t i = 0; i < segmentRanges.size(); i++) { | 973 for (size_t i = 0; i < segmentRanges.size(); i++) { |
974 LineSegmentIterator iterator = segmentRanges[i].start; | 974 LineSegmentIterator iterator = segmentRanges[i].start; |
975 InlineIterator segmentStart(iterator.root, iterator.object, iterator.off
set); | 975 InlineIterator segmentStart(iterator.root, iterator.object, iterator.off
set); |
976 iterator = segmentRanges[i].end; | 976 iterator = segmentRanges[i].end; |
977 InlineIterator segmentEnd(iterator.root, iterator.object, iterator.offse
t); | 977 InlineIterator segmentEnd(iterator.root, iterator.object, iterator.offse
t); |
978 if (i) { | 978 if (i) { |
979 ASSERT(segmentStart.m_obj); | 979 ASSERT(segmentStart.object()); |
980 BidiRun* segmentMarker = createRun(segmentStart.m_pos, segmentStart.
m_pos, segmentStart.m_obj, topResolver); | 980 BidiRun* segmentMarker = createRun(segmentStart.m_pos, segmentStart.
m_pos, segmentStart.object(), topResolver); |
981 segmentMarker->m_startsSegment = true; | 981 segmentMarker->m_startsSegment = true; |
982 bidiRuns.addRun(segmentMarker); | 982 bidiRuns.addRun(segmentMarker); |
983 // Do not collapse midpoints between segments | 983 // Do not collapse midpoints between segments |
984 topResolver.midpointState().betweenMidpoints = false; | 984 topResolver.midpointState().betweenMidpoints = false; |
985 } | 985 } |
986 if (!segmentIsEmpty(segmentStart, segmentEnd)) { | 986 if (!segmentIsEmpty(segmentStart, segmentEnd)) { |
987 topResolver.setPosition(segmentStart, numberOfIsolateAncestors(segme
ntStart)); | 987 topResolver.setPosition(segmentStart, numberOfIsolateAncestors(segme
ntStart)); |
988 constructBidiRunsForSegment(topResolver, bidiRuns, segmentEnd, overr
ide, previousLineBrokeCleanly, isNewUBAParagraph); | 988 constructBidiRunsForSegment(topResolver, bidiRuns, segmentEnd, overr
ide, previousLineBrokeCleanly, isNewUBAParagraph); |
989 } | 989 } |
990 } | 990 } |
991 } | 991 } |
992 | 992 |
993 // This function constructs line boxes for all of the text runs in the resolver
and computes their position. | 993 // This function constructs line boxes for all of the text runs in the resolver
and computes their position. |
994 RootInlineBox* RenderBlockFlow::createLineBoxesFromBidiRuns(unsigned bidiLevel,
BidiRunList<BidiRun>& bidiRuns, const InlineIterator& end, LineInfo& lineInfo, V
erticalPositionCache& verticalPositionCache, BidiRun* trailingSpaceRun, WordMeas
urements& wordMeasurements) | 994 RootInlineBox* RenderBlockFlow::createLineBoxesFromBidiRuns(unsigned bidiLevel,
BidiRunList<BidiRun>& bidiRuns, const InlineIterator& end, LineInfo& lineInfo, V
erticalPositionCache& verticalPositionCache, BidiRun* trailingSpaceRun, WordMeas
urements& wordMeasurements) |
995 { | 995 { |
996 if (!bidiRuns.runCount()) | 996 if (!bidiRuns.runCount()) |
997 return 0; | 997 return 0; |
998 | 998 |
999 // FIXME: Why is this only done when we had runs? | 999 // FIXME: Why is this only done when we had runs? |
1000 lineInfo.setLastLine(!end.m_obj); | 1000 lineInfo.setLastLine(!end.object()); |
1001 | 1001 |
1002 RootInlineBox* lineBox = constructLine(bidiRuns, lineInfo); | 1002 RootInlineBox* lineBox = constructLine(bidiRuns, lineInfo); |
1003 if (!lineBox) | 1003 if (!lineBox) |
1004 return 0; | 1004 return 0; |
1005 | 1005 |
1006 lineBox->setBidiLevel(bidiLevel); | 1006 lineBox->setBidiLevel(bidiLevel); |
1007 lineBox->setEndsWithBreak(lineInfo.previousLineBrokeCleanly()); | 1007 lineBox->setEndsWithBreak(lineInfo.previousLineBrokeCleanly()); |
1008 | 1008 |
1009 bool isSVGRootInlineBox = lineBox->isSVGRootInlineBox(); | 1009 bool isSVGRootInlineBox = lineBox->isSVGRootInlineBox(); |
1010 | 1010 |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1438 } | 1438 } |
1439 | 1439 |
1440 if (adjustLogicalLineTopAndLogicalHeightIfNeeded(shapeInsideInfo, logica
lOffsetFromShapeContainer.height(), layoutState, resolver, lastFloatFromPrevious
Line, endOfLine, wordMeasurements)) | 1440 if (adjustLogicalLineTopAndLogicalHeightIfNeeded(shapeInsideInfo, logica
lOffsetFromShapeContainer.height(), layoutState, resolver, lastFloatFromPrevious
Line, endOfLine, wordMeasurements)) |
1441 continue; | 1441 continue; |
1442 | 1442 |
1443 ASSERT(endOfLine != resolver.position()); | 1443 ASSERT(endOfLine != resolver.position()); |
1444 | 1444 |
1445 // This is a short-cut for empty lines. | 1445 // This is a short-cut for empty lines. |
1446 if (layoutState.lineInfo().isEmpty()) { | 1446 if (layoutState.lineInfo().isEmpty()) { |
1447 if (lastRootBox()) | 1447 if (lastRootBox()) |
1448 lastRootBox()->setLineBreakInfo(endOfLine.m_obj, endOfLine.m_pos
, resolver.status()); | 1448 lastRootBox()->setLineBreakInfo(endOfLine.object(), endOfLine.m_
pos, resolver.status()); |
1449 } else { | 1449 } else { |
1450 VisualDirectionOverride override = (styleToUse->rtlOrdering() == Vis
ualOrder ? (styleToUse->direction() == LTR ? VisualLeftToRightOverride : VisualR
ightToLeftOverride) : NoVisualOverride); | 1450 VisualDirectionOverride override = (styleToUse->rtlOrdering() == Vis
ualOrder ? (styleToUse->direction() == LTR ? VisualLeftToRightOverride : VisualR
ightToLeftOverride) : NoVisualOverride); |
1451 | 1451 |
1452 if (isNewUBAParagraph && styleToUse->unicodeBidi() == Plaintext && !
resolver.context()->parent()) { | 1452 if (isNewUBAParagraph && styleToUse->unicodeBidi() == Plaintext && !
resolver.context()->parent()) { |
1453 TextDirection direction = determinePlaintextDirectionality(resol
ver.position().root(), resolver.position().object(), resolver.position().offset(
)); | 1453 TextDirection direction = determinePlaintextDirectionality(resol
ver.position().root(), resolver.position().object(), resolver.position().offset(
)); |
1454 resolver.setStatus(BidiStatus(direction, isOverride(styleToUse->
unicodeBidi()))); | 1454 resolver.setStatus(BidiStatus(direction, isOverride(styleToUse->
unicodeBidi()))); |
1455 } | 1455 } |
1456 // FIXME: This ownership is reversed. We should own the BidiRunList
and pass it to createBidiRunsForLine. | 1456 // FIXME: This ownership is reversed. We should own the BidiRunList
and pass it to createBidiRunsForLine. |
1457 BidiRunList<BidiRun>& bidiRuns = resolver.runs(); | 1457 BidiRunList<BidiRun>& bidiRuns = resolver.runs(); |
1458 constructBidiRunsForLine(this, resolver, bidiRuns, endOfLine, overri
de, layoutState.lineInfo().previousLineBrokeCleanly(), isNewUBAParagraph); | 1458 constructBidiRunsForLine(this, resolver, bidiRuns, endOfLine, overri
de, layoutState.lineInfo().previousLineBrokeCleanly(), isNewUBAParagraph); |
(...skipping 11 matching lines...) Expand all Loading... |
1470 // At the same time we figure out where border/padding/margin should
be applied for | 1470 // At the same time we figure out where border/padding/margin should
be applied for |
1471 // inline flow boxes. | 1471 // inline flow boxes. |
1472 | 1472 |
1473 LayoutUnit oldLogicalHeight = logicalHeight(); | 1473 LayoutUnit oldLogicalHeight = logicalHeight(); |
1474 RootInlineBox* lineBox = createLineBoxesFromBidiRuns(resolver.status
().context->level(), bidiRuns, endOfLine, layoutState.lineInfo(), verticalPositi
onCache, trailingSpaceRun, wordMeasurements); | 1474 RootInlineBox* lineBox = createLineBoxesFromBidiRuns(resolver.status
().context->level(), bidiRuns, endOfLine, layoutState.lineInfo(), verticalPositi
onCache, trailingSpaceRun, wordMeasurements); |
1475 | 1475 |
1476 bidiRuns.deleteRuns(); | 1476 bidiRuns.deleteRuns(); |
1477 resolver.markCurrentRunEmpty(); // FIXME: This can probably be repla
ced by an ASSERT (or just removed). | 1477 resolver.markCurrentRunEmpty(); // FIXME: This can probably be repla
ced by an ASSERT (or just removed). |
1478 | 1478 |
1479 if (lineBox) { | 1479 if (lineBox) { |
1480 lineBox->setLineBreakInfo(endOfLine.m_obj, endOfLine.m_pos, reso
lver.status()); | 1480 lineBox->setLineBreakInfo(endOfLine.object(), endOfLine.m_pos, r
esolver.status()); |
1481 if (layoutState.usesRepaintBounds()) | 1481 if (layoutState.usesRepaintBounds()) |
1482 layoutState.updateRepaintRangeFromBox(lineBox); | 1482 layoutState.updateRepaintRangeFromBox(lineBox); |
1483 | 1483 |
1484 if (paginated) { | 1484 if (paginated) { |
1485 LayoutUnit adjustment = 0; | 1485 LayoutUnit adjustment = 0; |
1486 adjustLinePositionForPagination(lineBox, adjustment, layoutS
tate.flowThread()); | 1486 adjustLinePositionForPagination(lineBox, adjustment, layoutS
tate.flowThread()); |
1487 if (adjustment) { | 1487 if (adjustment) { |
1488 LayoutUnit oldLineWidth = availableLogicalWidthForLine(o
ldLogicalHeight, layoutState.lineInfo().isFirstLine()); | 1488 LayoutUnit oldLineWidth = availableLogicalWidthForLine(o
ldLogicalHeight, layoutState.lineInfo().isFirstLine()); |
1489 lineBox->adjustBlockDirectionPosition(adjustment); | 1489 lineBox->adjustBlockDirectionPosition(adjustment); |
1490 if (layoutState.usesRepaintBounds()) | 1490 if (layoutState.usesRepaintBounds()) |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2045 return false; | 2045 return false; |
2046 return checkPaginationAndFloatsAtEndLine(layoutState); | 2046 return checkPaginationAndFloatsAtEndLine(layoutState); |
2047 } | 2047 } |
2048 | 2048 |
2049 // The first clean line doesn't match, but we can check a handful of followi
ng lines to try | 2049 // The first clean line doesn't match, but we can check a handful of followi
ng lines to try |
2050 // to match back up. | 2050 // to match back up. |
2051 static int numLines = 8; // The # of lines we're willing to match against. | 2051 static int numLines = 8; // The # of lines we're willing to match against. |
2052 RootInlineBox* originalEndLine = layoutState.endLine(); | 2052 RootInlineBox* originalEndLine = layoutState.endLine(); |
2053 RootInlineBox* line = originalEndLine; | 2053 RootInlineBox* line = originalEndLine; |
2054 for (int i = 0; i < numLines && line; i++, line = line->nextRootBox()) { | 2054 for (int i = 0; i < numLines && line; i++, line = line->nextRootBox()) { |
2055 if (line->lineBreakObj() == resolver.position().m_obj && line->lineBreak
Pos() == resolver.position().m_pos) { | 2055 if (line->lineBreakObj() == resolver.position().object() && line->lineBr
eakPos() == resolver.position().m_pos) { |
2056 // We have a match. | 2056 // We have a match. |
2057 if (line->lineBreakBidiStatus() != resolver.status()) | 2057 if (line->lineBreakBidiStatus() != resolver.status()) |
2058 return false; // ...but the bidi state doesn't match. | 2058 return false; // ...but the bidi state doesn't match. |
2059 | 2059 |
2060 bool matched = false; | 2060 bool matched = false; |
2061 RootInlineBox* result = line->nextRootBox(); | 2061 RootInlineBox* result = line->nextRootBox(); |
2062 layoutState.setEndLine(result); | 2062 layoutState.setEndLine(result); |
2063 if (result) { | 2063 if (result) { |
2064 layoutState.setEndLineLogicalTop(line->lineBottomWithLeading()); | 2064 layoutState.setEndLineLogicalTop(line->lineBottomWithLeading()); |
2065 matched = checkPaginationAndFloatsAtEndLine(layoutState); | 2065 matched = checkPaginationAndFloatsAtEndLine(layoutState); |
(...skipping 18 matching lines...) Expand all Loading... |
2084 while (!it.atEnd() && !requiresLineBox(it)) | 2084 while (!it.atEnd() && !requiresLineBox(it)) |
2085 it.increment(); | 2085 it.increment(); |
2086 | 2086 |
2087 return !it.atEnd(); | 2087 return !it.atEnd(); |
2088 } | 2088 } |
2089 | 2089 |
2090 void LineBreaker::skipLeadingWhitespace(InlineBidiResolver& resolver, LineInfo&
lineInfo, | 2090 void LineBreaker::skipLeadingWhitespace(InlineBidiResolver& resolver, LineInfo&
lineInfo, |
2091 FloatingObject* lastFloatFr
omPreviousLine, LineWidth& width) | 2091 FloatingObject* lastFloatFr
omPreviousLine, LineWidth& width) |
2092 { | 2092 { |
2093 while (!resolver.position().atEnd() && !requiresLineBox(resolver.position(),
lineInfo, LeadingWhitespace)) { | 2093 while (!resolver.position().atEnd() && !requiresLineBox(resolver.position(),
lineInfo, LeadingWhitespace)) { |
2094 RenderObject* object = resolver.position().m_obj; | 2094 RenderObject* object = resolver.position().object(); |
2095 if (object->isOutOfFlowPositioned()) { | 2095 if (object->isOutOfFlowPositioned()) { |
2096 setStaticPositions(m_block, toRenderBox(object)); | 2096 setStaticPositions(m_block, toRenderBox(object)); |
2097 if (object->style()->isOriginalDisplayInlineType()) { | 2097 if (object->style()->isOriginalDisplayInlineType()) { |
2098 resolver.runs().addRun(createRun(0, 1, object, resolver)); | 2098 resolver.runs().addRun(createRun(0, 1, object, resolver)); |
2099 lineInfo.incrementRunsFromLeadingWhitespace(); | 2099 lineInfo.incrementRunsFromLeadingWhitespace(); |
2100 } | 2100 } |
2101 } else if (object->isFloating()) { | 2101 } else if (object->isFloating()) { |
2102 // The top margin edge of a self-collapsing block that clears a floa
t intrudes up into it by the height of the margin, | 2102 // The top margin edge of a self-collapsing block that clears a floa
t intrudes up into it by the height of the margin, |
2103 // so in order to place this first child float at the top content ed
ge of the self-collapsing block add the margin back in before placement. | 2103 // so in order to place this first child float at the top content ed
ge of the self-collapsing block add the margin back in before placement. |
2104 LayoutUnit marginOffset = (!object->previousSibling() && m_block->is
SelfCollapsingBlock() && m_block->style()->clear() && m_block->getClearDelta(m_b
lock, LayoutUnit())) ? m_block->collapsedMarginBeforeForChild(m_block) : LayoutU
nit(); | 2104 LayoutUnit marginOffset = (!object->previousSibling() && m_block->is
SelfCollapsingBlock() && m_block->style()->clear() && m_block->getClearDelta(m_b
lock, LayoutUnit())) ? m_block->collapsedMarginBeforeForChild(m_block) : LayoutU
nit(); |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2399 lineGridBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, ver
ticalPositionCache); | 2399 lineGridBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, ver
ticalPositionCache); |
2400 | 2400 |
2401 setLineGridBox(lineGridBox); | 2401 setLineGridBox(lineGridBox); |
2402 | 2402 |
2403 // FIXME: If any of the characteristics of the box change compared to the ol
d one, then we need to do a deep dirtying | 2403 // FIXME: If any of the characteristics of the box change compared to the ol
d one, then we need to do a deep dirtying |
2404 // (similar to what happens when the page height changes). Ideally, though,
we only do this if someone is actually snapping | 2404 // (similar to what happens when the page height changes). Ideally, though,
we only do this if someone is actually snapping |
2405 // to this grid. | 2405 // to this grid. |
2406 } | 2406 } |
2407 | 2407 |
2408 } | 2408 } |
OLD | NEW |