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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 } | 186 } |
187 | 187 |
188 class LineInfo { | 188 class LineInfo { |
189 public: | 189 public: |
190 LineInfo() | 190 LineInfo() |
191 : m_isFirstLine(true) | 191 : m_isFirstLine(true) |
192 , m_isLastLine(false) | 192 , m_isLastLine(false) |
193 , m_isEmpty(true) | 193 , m_isEmpty(true) |
194 , m_previousLineBrokeCleanly(true) | 194 , m_previousLineBrokeCleanly(true) |
195 , m_floatPaginationStrut(0) | 195 , m_floatPaginationStrut(0) |
| 196 , m_runsFromLeadingWhitespace(0) |
196 { } | 197 { } |
197 | 198 |
198 bool isFirstLine() const { return m_isFirstLine; } | 199 bool isFirstLine() const { return m_isFirstLine; } |
199 bool isLastLine() const { return m_isLastLine; } | 200 bool isLastLine() const { return m_isLastLine; } |
200 bool isEmpty() const { return m_isEmpty; } | 201 bool isEmpty() const { return m_isEmpty; } |
201 bool previousLineBrokeCleanly() const { return m_previousLineBrokeCleanly; } | 202 bool previousLineBrokeCleanly() const { return m_previousLineBrokeCleanly; } |
202 LayoutUnit floatPaginationStrut() const { return m_floatPaginationStrut; } | 203 LayoutUnit floatPaginationStrut() const { return m_floatPaginationStrut; } |
| 204 unsigned runsFromLeadingWhitespace() const { return m_runsFromLeadingWhitesp
ace; } |
| 205 void resetRunsFromLeadingWhitespace() { m_runsFromLeadingWhitespace = 0; } |
| 206 void incrementRunsFromLeadingWhitespace() { m_runsFromLeadingWhitespace++; } |
203 | 207 |
204 void setFirstLine(bool firstLine) { m_isFirstLine = firstLine; } | 208 void setFirstLine(bool firstLine) { m_isFirstLine = firstLine; } |
205 void setLastLine(bool lastLine) { m_isLastLine = lastLine; } | 209 void setLastLine(bool lastLine) { m_isLastLine = lastLine; } |
206 void setEmpty(bool empty, RenderBlock* block = 0, LineWidth* lineWidth = 0) | 210 void setEmpty(bool empty, RenderBlock* block = 0, LineWidth* lineWidth = 0) |
207 { | 211 { |
208 if (m_isEmpty == empty) | 212 if (m_isEmpty == empty) |
209 return; | 213 return; |
210 m_isEmpty = empty; | 214 m_isEmpty = empty; |
211 if (!empty && block && floatPaginationStrut()) { | 215 if (!empty && block && floatPaginationStrut()) { |
212 block->setLogicalHeight(block->logicalHeight() + floatPaginationStru
t()); | 216 block->setLogicalHeight(block->logicalHeight() + floatPaginationStru
t()); |
213 setFloatPaginationStrut(0); | 217 setFloatPaginationStrut(0); |
214 lineWidth->updateAvailableWidth(); | 218 lineWidth->updateAvailableWidth(); |
215 } | 219 } |
216 } | 220 } |
217 | 221 |
218 void setPreviousLineBrokeCleanly(bool previousLineBrokeCleanly) { m_previous
LineBrokeCleanly = previousLineBrokeCleanly; } | 222 void setPreviousLineBrokeCleanly(bool previousLineBrokeCleanly) { m_previous
LineBrokeCleanly = previousLineBrokeCleanly; } |
219 void setFloatPaginationStrut(LayoutUnit strut) { m_floatPaginationStrut = st
rut; } | 223 void setFloatPaginationStrut(LayoutUnit strut) { m_floatPaginationStrut = st
rut; } |
220 | 224 |
221 private: | 225 private: |
222 bool m_isFirstLine; | 226 bool m_isFirstLine; |
223 bool m_isLastLine; | 227 bool m_isLastLine; |
224 bool m_isEmpty; | 228 bool m_isEmpty; |
225 bool m_previousLineBrokeCleanly; | 229 bool m_previousLineBrokeCleanly; |
226 LayoutUnit m_floatPaginationStrut; | 230 LayoutUnit m_floatPaginationStrut; |
| 231 unsigned m_runsFromLeadingWhitespace; |
227 }; | 232 }; |
228 | 233 |
229 static inline int borderPaddingMarginStart(RenderInline* child) | 234 static inline int borderPaddingMarginStart(RenderInline* child) |
230 { | 235 { |
231 return child->marginStart() + child->paddingStart() + child->borderStart(); | 236 return child->marginStart() + child->paddingStart() + child->borderStart(); |
232 } | 237 } |
233 | 238 |
234 static inline int borderPaddingMarginEnd(RenderInline* child) | 239 static inline int borderPaddingMarginEnd(RenderInline* child) |
235 { | 240 { |
236 return child->marginEnd() + child->paddingEnd() + child->borderEnd(); | 241 return child->marginEnd() + child->paddingEnd() + child->borderEnd(); |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 } | 477 } |
473 return false; | 478 return false; |
474 } | 479 } |
475 | 480 |
476 RootInlineBox* RenderBlock::constructLine(BidiRunList<BidiRun>& bidiRuns, const
LineInfo& lineInfo) | 481 RootInlineBox* RenderBlock::constructLine(BidiRunList<BidiRun>& bidiRuns, const
LineInfo& lineInfo) |
477 { | 482 { |
478 ASSERT(bidiRuns.firstRun()); | 483 ASSERT(bidiRuns.firstRun()); |
479 | 484 |
480 bool rootHasSelectedChildren = false; | 485 bool rootHasSelectedChildren = false; |
481 InlineFlowBox* parentBox = 0; | 486 InlineFlowBox* parentBox = 0; |
| 487 int runCount = bidiRuns.runCount() - lineInfo.runsFromLeadingWhitespace(); |
482 for (BidiRun* r = bidiRuns.firstRun(); r; r = r->next()) { | 488 for (BidiRun* r = bidiRuns.firstRun(); r; r = r->next()) { |
483 // Create a box for our object. | 489 // Create a box for our object. |
484 bool isOnlyRun = (bidiRuns.runCount() == 1); | 490 bool isOnlyRun = (runCount == 1); |
485 if (bidiRuns.runCount() == 2 && !r->m_object->isListMarker()) | 491 if (runCount == 2 && !r->m_object->isListMarker()) |
486 isOnlyRun = (!style()->isLeftToRightDirection() ? bidiRuns.lastRun()
: bidiRuns.firstRun())->m_object->isListMarker(); | 492 isOnlyRun = (!style()->isLeftToRightDirection() ? bidiRuns.lastRun()
: bidiRuns.firstRun())->m_object->isListMarker(); |
487 | 493 |
488 InlineBox* box = createInlineBoxForRenderer(r->m_object, false, isOnlyRu
n); | 494 InlineBox* box = createInlineBoxForRenderer(r->m_object, false, isOnlyRu
n); |
489 r->m_box = box; | 495 r->m_box = box; |
490 | 496 |
491 ASSERT(box); | 497 ASSERT(box); |
492 if (!box) | 498 if (!box) |
493 continue; | 499 continue; |
494 | 500 |
495 if (!rootHasSelectedChildren && box->renderer()->selectionState() != Ren
derObject::SelectionNone) | 501 if (!rootHasSelectedChildren && box->renderer()->selectionState() != Ren
derObject::SelectionNone) |
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1206 // FIXME: Is this check necessary before the first iteration or can it b
e moved to the end? | 1212 // FIXME: Is this check necessary before the first iteration or can it b
e moved to the end? |
1207 if (checkForEndLineMatch) { | 1213 if (checkForEndLineMatch) { |
1208 layoutState.setEndLineMatched(matchedEndLine(layoutState, resolver,
cleanLineStart, cleanLineBidiStatus)); | 1214 layoutState.setEndLineMatched(matchedEndLine(layoutState, resolver,
cleanLineStart, cleanLineBidiStatus)); |
1209 if (layoutState.endLineMatched()) | 1215 if (layoutState.endLineMatched()) |
1210 break; | 1216 break; |
1211 } | 1217 } |
1212 | 1218 |
1213 lineMidpointState.reset(); | 1219 lineMidpointState.reset(); |
1214 | 1220 |
1215 layoutState.lineInfo().setEmpty(true); | 1221 layoutState.lineInfo().setEmpty(true); |
| 1222 layoutState.lineInfo().resetRunsFromLeadingWhitespace(); |
1216 | 1223 |
1217 InlineIterator oldEnd = end; | 1224 InlineIterator oldEnd = end; |
1218 bool isNewUBAParagraph = layoutState.lineInfo().previousLineBrokeCleanly
(); | 1225 bool isNewUBAParagraph = layoutState.lineInfo().previousLineBrokeCleanly
(); |
1219 FloatingObject* lastFloatFromPreviousLine = (m_floatingObjects && !m_flo
atingObjects->set().isEmpty()) ? m_floatingObjects->set().last() : 0; | 1226 FloatingObject* lastFloatFromPreviousLine = (m_floatingObjects && !m_flo
atingObjects->set().isEmpty()) ? m_floatingObjects->set().last() : 0; |
1220 end = lineBreaker.nextLineBreak(resolver, layoutState.lineInfo(), lineBr
eakIteratorInfo, lastFloatFromPreviousLine, consecutiveHyphenatedLines); | 1227 end = lineBreaker.nextLineBreak(resolver, layoutState.lineInfo(), lineBr
eakIteratorInfo, lastFloatFromPreviousLine, consecutiveHyphenatedLines); |
1221 if (resolver.position().atEnd()) { | 1228 if (resolver.position().atEnd()) { |
1222 // FIXME: We shouldn't be creating any runs in findNextLineBreak to
begin with! | 1229 // FIXME: We shouldn't be creating any runs in findNextLineBreak to
begin with! |
1223 // Once BidiRunList is separated from BidiResolver this will not be
needed. | 1230 // Once BidiRunList is separated from BidiResolver this will not be
needed. |
1224 resolver.runs().deleteRuns(); | 1231 resolver.runs().deleteRuns(); |
1225 resolver.markCurrentRunEmpty(); // FIXME: This can probably be repla
ced by an ASSERT (or just removed). | 1232 resolver.markCurrentRunEmpty(); // FIXME: This can probably be repla
ced by an ASSERT (or just removed). |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1848 m_block->insertFloatingObject(toRenderBox(object)); | 1855 m_block->insertFloatingObject(toRenderBox(object)); |
1849 iterator.increment(); | 1856 iterator.increment(); |
1850 } | 1857 } |
1851 } | 1858 } |
1852 | 1859 |
1853 void RenderBlock::LineBreaker::skipLeadingWhitespace(InlineBidiResolver& resolve
r, LineInfo& lineInfo, | 1860 void RenderBlock::LineBreaker::skipLeadingWhitespace(InlineBidiResolver& resolve
r, LineInfo& lineInfo, |
1854 FloatingObject* lastFloatFr
omPreviousLine, LineWidth& width) | 1861 FloatingObject* lastFloatFr
omPreviousLine, LineWidth& width) |
1855 { | 1862 { |
1856 while (!resolver.position().atEnd() && !requiresLineBox(resolver.position(),
lineInfo, LeadingWhitespace)) { | 1863 while (!resolver.position().atEnd() && !requiresLineBox(resolver.position(),
lineInfo, LeadingWhitespace)) { |
1857 RenderObject* object = resolver.position().m_obj; | 1864 RenderObject* object = resolver.position().m_obj; |
1858 if (object->isPositioned()) | 1865 if (object->isPositioned()) { |
1859 setStaticPositions(m_block, toRenderBox(object)); | 1866 setStaticPositions(m_block, toRenderBox(object)); |
1860 else if (object->isFloating()) | 1867 if (object->style()->isOriginalDisplayInlineType()) { |
| 1868 resolver.runs().addRun(createRun(0, 1, object, resolver)); |
| 1869 lineInfo.incrementRunsFromLeadingWhitespace(); |
| 1870 } |
| 1871 } else if (object->isFloating()) |
1861 m_block->positionNewFloatOnLine(m_block->insertFloatingObject(toRend
erBox(object)), lastFloatFromPreviousLine, lineInfo, width); | 1872 m_block->positionNewFloatOnLine(m_block->insertFloatingObject(toRend
erBox(object)), lastFloatFromPreviousLine, lineInfo, width); |
1862 resolver.increment(); | 1873 resolver.increment(); |
1863 } | 1874 } |
1864 resolver.commitExplicitEmbedding(); | 1875 resolver.commitExplicitEmbedding(); |
1865 } | 1876 } |
1866 | 1877 |
1867 // This is currently just used for list markers and inline flows that have line
boxes. Neither should | 1878 // This is currently just used for list markers and inline flows that have line
boxes. Neither should |
1868 // have an effect on whitespace at the start of the line. | 1879 // have an effect on whitespace at the start of the line. |
1869 static bool shouldSkipWhitespaceAfterStartObject(RenderBlock* block, RenderObjec
t* o, LineMidpointState& lineMidpointState) | 1880 static bool shouldSkipWhitespaceAfterStartObject(RenderBlock* block, RenderObjec
t* o, LineMidpointState& lineMidpointState) |
1870 { | 1881 { |
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2712 availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), false) -
logicalLeft; | 2723 availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), false) -
logicalLeft; |
2713 float totalLogicalWidth = logicalWidthForChild(child); | 2724 float totalLogicalWidth = logicalWidthForChild(child); |
2714 updateLogicalWidthForAlignment(textAlign, 0l, logicalLeft, totalLogicalWidth
, availableLogicalWidth, 0); | 2725 updateLogicalWidthForAlignment(textAlign, 0l, logicalLeft, totalLogicalWidth
, availableLogicalWidth, 0); |
2715 | 2726 |
2716 if (!style()->isLeftToRightDirection()) | 2727 if (!style()->isLeftToRightDirection()) |
2717 return logicalWidth() - (logicalLeft + totalLogicalWidth); | 2728 return logicalWidth() - (logicalLeft + totalLogicalWidth); |
2718 return logicalLeft; | 2729 return logicalLeft; |
2719 } | 2730 } |
2720 | 2731 |
2721 } | 2732 } |
OLD | NEW |