| 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 LayoutUnit borderPaddingMarginStart(RenderInline* child) | 234 static inline LayoutUnit 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 LayoutUnit borderPaddingMarginEnd(RenderInline* child) | 239 static inline LayoutUnit 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 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1219 layoutState.setEndLineMatched(matchedEndLine(layoutState, resolver,
cleanLineStart, cleanLineBidiStatus)); | 1225 layoutState.setEndLineMatched(matchedEndLine(layoutState, resolver,
cleanLineStart, cleanLineBidiStatus)); |
| 1220 if (layoutState.endLineMatched()) { | 1226 if (layoutState.endLineMatched()) { |
| 1221 resolver.setPosition(InlineIterator(resolver.position().root(),
0, 0), 0); | 1227 resolver.setPosition(InlineIterator(resolver.position().root(),
0, 0), 0); |
| 1222 break; | 1228 break; |
| 1223 } | 1229 } |
| 1224 } | 1230 } |
| 1225 | 1231 |
| 1226 lineMidpointState.reset(); | 1232 lineMidpointState.reset(); |
| 1227 | 1233 |
| 1228 layoutState.lineInfo().setEmpty(true); | 1234 layoutState.lineInfo().setEmpty(true); |
| 1235 layoutState.lineInfo().resetRunsFromLeadingWhitespace(); |
| 1229 | 1236 |
| 1230 const InlineIterator oldEnd = end; | 1237 const InlineIterator oldEnd = end; |
| 1231 bool isNewUBAParagraph = layoutState.lineInfo().previousLineBrokeCleanly
(); | 1238 bool isNewUBAParagraph = layoutState.lineInfo().previousLineBrokeCleanly
(); |
| 1232 FloatingObject* lastFloatFromPreviousLine = (m_floatingObjects && !m_flo
atingObjects->set().isEmpty()) ? m_floatingObjects->set().last() : 0; | 1239 FloatingObject* lastFloatFromPreviousLine = (m_floatingObjects && !m_flo
atingObjects->set().isEmpty()) ? m_floatingObjects->set().last() : 0; |
| 1233 end = lineBreaker.nextLineBreak(resolver, layoutState.lineInfo(), lineBr
eakIteratorInfo, lastFloatFromPreviousLine, consecutiveHyphenatedLines); | 1240 end = lineBreaker.nextLineBreak(resolver, layoutState.lineInfo(), lineBr
eakIteratorInfo, lastFloatFromPreviousLine, consecutiveHyphenatedLines); |
| 1234 if (resolver.position().atEnd()) { | 1241 if (resolver.position().atEnd()) { |
| 1235 // FIXME: We shouldn't be creating any runs in findNextLineBreak to
begin with! | 1242 // FIXME: We shouldn't be creating any runs in findNextLineBreak to
begin with! |
| 1236 // Once BidiRunList is separated from BidiResolver this will not be
needed. | 1243 // Once BidiRunList is separated from BidiResolver this will not be
needed. |
| 1237 resolver.runs().deleteRuns(); | 1244 resolver.runs().deleteRuns(); |
| 1238 resolver.markCurrentRunEmpty(); // FIXME: This can probably be repla
ced by an ASSERT (or just removed). | 1245 resolver.markCurrentRunEmpty(); // FIXME: This can probably be repla
ced by an ASSERT (or just removed). |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1867 m_block->insertFloatingObject(toRenderBox(object)); | 1874 m_block->insertFloatingObject(toRenderBox(object)); |
| 1868 iterator.increment(); | 1875 iterator.increment(); |
| 1869 } | 1876 } |
| 1870 } | 1877 } |
| 1871 | 1878 |
| 1872 void RenderBlock::LineBreaker::skipLeadingWhitespace(InlineBidiResolver& resolve
r, LineInfo& lineInfo, | 1879 void RenderBlock::LineBreaker::skipLeadingWhitespace(InlineBidiResolver& resolve
r, LineInfo& lineInfo, |
| 1873 FloatingObject* lastFloatFr
omPreviousLine, LineWidth& width) | 1880 FloatingObject* lastFloatFr
omPreviousLine, LineWidth& width) |
| 1874 { | 1881 { |
| 1875 while (!resolver.position().atEnd() && !requiresLineBox(resolver.position(),
lineInfo, LeadingWhitespace)) { | 1882 while (!resolver.position().atEnd() && !requiresLineBox(resolver.position(),
lineInfo, LeadingWhitespace)) { |
| 1876 RenderObject* object = resolver.position().m_obj; | 1883 RenderObject* object = resolver.position().m_obj; |
| 1877 if (object->isPositioned()) | 1884 if (object->isPositioned()) { |
| 1878 setStaticPositions(m_block, toRenderBox(object)); | 1885 setStaticPositions(m_block, toRenderBox(object)); |
| 1879 else if (object->isFloating()) | 1886 if (object->style()->isOriginalDisplayInlineType()) { |
| 1887 resolver.runs().addRun(createRun(0, 1, object, resolver)); |
| 1888 lineInfo.incrementRunsFromLeadingWhitespace(); |
| 1889 } |
| 1890 } else if (object->isFloating()) |
| 1880 m_block->positionNewFloatOnLine(m_block->insertFloatingObject(toRend
erBox(object)), lastFloatFromPreviousLine, lineInfo, width); | 1891 m_block->positionNewFloatOnLine(m_block->insertFloatingObject(toRend
erBox(object)), lastFloatFromPreviousLine, lineInfo, width); |
| 1881 resolver.increment(); | 1892 resolver.increment(); |
| 1882 } | 1893 } |
| 1883 resolver.commitExplicitEmbedding(); | 1894 resolver.commitExplicitEmbedding(); |
| 1884 } | 1895 } |
| 1885 | 1896 |
| 1886 // This is currently just used for list markers and inline flows that have line
boxes. Neither should | 1897 // This is currently just used for list markers and inline flows that have line
boxes. Neither should |
| 1887 // have an effect on whitespace at the start of the line. | 1898 // have an effect on whitespace at the start of the line. |
| 1888 static bool shouldSkipWhitespaceAfterStartObject(RenderBlock* block, RenderObjec
t* o, LineMidpointState& lineMidpointState) | 1899 static bool shouldSkipWhitespaceAfterStartObject(RenderBlock* block, RenderObjec
t* o, LineMidpointState& lineMidpointState) |
| 1889 { | 1900 { |
| (...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2731 availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), false) -
logicalLeft; | 2742 availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), false) -
logicalLeft; |
| 2732 float totalLogicalWidth = logicalWidthForChild(child); | 2743 float totalLogicalWidth = logicalWidthForChild(child); |
| 2733 updateLogicalWidthForAlignment(textAlign, 0l, logicalLeft, totalLogicalWidth
, availableLogicalWidth, 0); | 2744 updateLogicalWidthForAlignment(textAlign, 0l, logicalLeft, totalLogicalWidth
, availableLogicalWidth, 0); |
| 2734 | 2745 |
| 2735 if (!style()->isLeftToRightDirection()) | 2746 if (!style()->isLeftToRightDirection()) |
| 2736 return logicalWidth() - (logicalLeft + totalLogicalWidth); | 2747 return logicalWidth() - (logicalLeft + totalLogicalWidth); |
| 2737 return logicalLeft; | 2748 return logicalLeft; |
| 2738 } | 2749 } |
| 2739 | 2750 |
| 2740 } | 2751 } |
| OLD | NEW |