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 * |
11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 * Library General Public License for more details. | 14 * Library General Public License for more details. |
15 * | 15 * |
16 * You should have received a copy of the GNU Library General Public License | 16 * You should have received a copy of the GNU Library General Public License |
17 * along with this library; see the file COPYING.LIB. If not, write to | 17 * along with this library; see the file COPYING.LIB. If not, write to |
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
20 * | 20 * |
21 */ | 21 */ |
22 | 22 |
23 #include "core/layout/line/LineBreaker.h" | 23 #include "core/layout/line/LineBreaker.h" |
24 | 24 |
25 #include "core/layout/line/BreakingContextInlineHeaders.h" | 25 #include "core/layout/line/BreakingContextInlineHeaders.h" |
26 | 26 |
27 namespace blink { | 27 namespace blink { |
28 | 28 |
29 void LineBreaker::skipLeadingWhitespace(InlineBidiResolver& resolver, LineInfo&
lineInfo, | 29 void LineBreaker::skipLeadingWhitespace(InlineBidiResolver& resolver, LineInfo&
lineInfo, LineWidth& width) |
30 FloatingObject* lastFloatFromPreviousLine, LineWidth& width) | |
31 { | 30 { |
32 while (!resolver.position().atEnd() && !requiresLineBox(resolver.position(),
lineInfo, LeadingWhitespace)) { | 31 while (!resolver.position().atEnd() && !requiresLineBox(resolver.position(),
lineInfo, LeadingWhitespace)) { |
33 LineLayoutItem lineLayoutItem = resolver.position().getLineLayoutItem(); | 32 LineLayoutItem lineLayoutItem = resolver.position().getLineLayoutItem(); |
34 if (lineLayoutItem.isOutOfFlowPositioned()) { | 33 if (lineLayoutItem.isOutOfFlowPositioned()) { |
35 setStaticPositions(m_block, LineLayoutBox(lineLayoutItem), width.ind
entText()); | 34 setStaticPositions(m_block, LineLayoutBox(lineLayoutItem), width.ind
entText()); |
36 if (lineLayoutItem.style()->isOriginalDisplayInlineType()) { | 35 if (lineLayoutItem.style()->isOriginalDisplayInlineType()) { |
37 resolver.runs().addRun(createRun(0, 1, LineLayoutItem(lineLayout
Item), resolver)); | 36 resolver.runs().addRun(createRun(0, 1, LineLayoutItem(lineLayout
Item), resolver)); |
38 lineInfo.incrementRunsFromLeadingWhitespace(); | 37 lineInfo.incrementRunsFromLeadingWhitespace(); |
39 } | 38 } |
40 } else if (lineLayoutItem.isFloating()) { | 39 } else if (lineLayoutItem.isFloating()) { |
41 m_block.positionNewFloatOnLine(*m_block.insertFloatingObject(LineLay
outBox(lineLayoutItem)), lastFloatFromPreviousLine, lineInfo, width); | 40 m_block.insertFloatingObject(LineLayoutBox(lineLayoutItem)); |
| 41 m_block.positionNewFloats(&width); |
42 } | 42 } |
43 resolver.position().increment(&resolver); | 43 resolver.position().increment(&resolver); |
44 } | 44 } |
45 resolver.commitExplicitEmbedding(resolver.runs()); | 45 resolver.commitExplicitEmbedding(resolver.runs()); |
46 } | 46 } |
47 | 47 |
48 void LineBreaker::reset() | 48 void LineBreaker::reset() |
49 { | 49 { |
50 m_positionedObjects.clear(); | 50 m_positionedObjects.clear(); |
51 m_hyphenated = false; | 51 m_hyphenated = false; |
52 m_clear = ClearNone; | 52 m_clear = ClearNone; |
53 } | 53 } |
54 | 54 |
55 InlineIterator LineBreaker::nextLineBreak(InlineBidiResolver& resolver, LineInfo
& lineInfo, | 55 InlineIterator LineBreaker::nextLineBreak(InlineBidiResolver& resolver, LineInfo
& lineInfo, |
56 LayoutTextInfo& layoutTextInfo, FloatingObject* lastFloatFromPreviousLine, | 56 LayoutTextInfo& layoutTextInfo, WordMeasurements& wordMeasurements) |
57 WordMeasurements& wordMeasurements) | |
58 { | 57 { |
59 reset(); | 58 reset(); |
60 | 59 |
61 ASSERT(resolver.position().root() == m_block); | 60 ASSERT(resolver.position().root() == m_block); |
62 | 61 |
63 bool appliedStartWidth = resolver.position().offset() > 0; | 62 bool appliedStartWidth = resolver.position().offset() > 0; |
64 | 63 |
65 LineWidth width(m_block, lineInfo.isFirstLine(), requiresIndent(lineInfo.isF
irstLine(), lineInfo.previousLineBrokeCleanly(), m_block.styleRef())); | 64 LineWidth width(m_block, lineInfo.isFirstLine(), requiresIndent(lineInfo.isF
irstLine(), lineInfo.previousLineBrokeCleanly(), m_block.styleRef())); |
66 | 65 |
67 skipLeadingWhitespace(resolver, lineInfo, lastFloatFromPreviousLine, width); | 66 skipLeadingWhitespace(resolver, lineInfo, width); |
68 | 67 |
69 if (resolver.position().atEnd()) | 68 if (resolver.position().atEnd()) |
70 return resolver.position(); | 69 return resolver.position(); |
71 | 70 |
72 BreakingContext context(resolver, lineInfo, width, layoutTextInfo, lastFloat
FromPreviousLine, appliedStartWidth, m_block); | 71 BreakingContext context(resolver, lineInfo, width, layoutTextInfo, appliedSt
artWidth, m_block); |
73 | 72 |
74 while (context.currentItem()) { | 73 while (context.currentItem()) { |
75 context.initializeForCurrentObject(); | 74 context.initializeForCurrentObject(); |
76 if (context.currentItem().isBR()) { | 75 if (context.currentItem().isBR()) { |
77 context.handleBR(m_clear); | 76 context.handleBR(m_clear); |
78 } else if (context.currentItem().isOutOfFlowPositioned()) { | 77 } else if (context.currentItem().isOutOfFlowPositioned()) { |
79 context.handleOutOfFlowPositioned(m_positionedObjects); | 78 context.handleOutOfFlowPositioned(m_positionedObjects); |
80 } else if (context.currentItem().isFloating()) { | 79 } else if (context.currentItem().isFloating()) { |
81 context.handleFloat(); | 80 context.handleFloat(); |
82 } else if (context.currentItem().isLayoutInline()) { | 81 } else if (context.currentItem().isLayoutInline()) { |
(...skipping 19 matching lines...) Expand all Loading... |
102 | 101 |
103 context.increment(); | 102 context.increment(); |
104 } | 103 } |
105 | 104 |
106 context.clearLineBreakIfFitsOnLine(); | 105 context.clearLineBreakIfFitsOnLine(); |
107 | 106 |
108 return context.handleEndOfLine(); | 107 return context.handleEndOfLine(); |
109 } | 108 } |
110 | 109 |
111 } // namespace blink | 110 } // namespace blink |
OLD | NEW |