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 1824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1835 // FIXME: The entire concept of the skipTrailingWhitespace function is flawed, s
ince we really need to be building | 1835 // FIXME: The entire concept of the skipTrailingWhitespace function is flawed, s
ince we really need to be building |
1836 // line boxes even for containers that may ultimately collapse away. Otherwise w
e'll never get positioned | 1836 // line boxes even for containers that may ultimately collapse away. Otherwise w
e'll never get positioned |
1837 // elements quite right. In other words, we need to build this function's work i
nto the normal line | 1837 // elements quite right. In other words, we need to build this function's work i
nto the normal line |
1838 // object iteration process. | 1838 // object iteration process. |
1839 // NB. this function will insert any floating elements that would otherwise | 1839 // NB. this function will insert any floating elements that would otherwise |
1840 // be skipped but it will not position them. | 1840 // be skipped but it will not position them. |
1841 void RenderBlock::LineBreaker::skipTrailingWhitespace(InlineIterator& iterator,
const LineInfo& lineInfo) | 1841 void RenderBlock::LineBreaker::skipTrailingWhitespace(InlineIterator& iterator,
const LineInfo& lineInfo) |
1842 { | 1842 { |
1843 while (!iterator.atEnd() && !requiresLineBox(iterator, lineInfo, TrailingWhi
tespace)) { | 1843 while (!iterator.atEnd() && !requiresLineBox(iterator, lineInfo, TrailingWhi
tespace)) { |
1844 RenderObject* object = iterator.m_obj; | 1844 RenderObject* object = iterator.m_obj; |
1845 if (object->isFloating()) { | 1845 if (object->isPositioned()) |
| 1846 setStaticPositions(m_block, toRenderBox(object)); |
| 1847 else if (object->isFloating()) |
1846 m_block->insertFloatingObject(toRenderBox(object)); | 1848 m_block->insertFloatingObject(toRenderBox(object)); |
1847 } else if (object->isPositioned()) | |
1848 setStaticPositions(m_block, toRenderBox(object)); | |
1849 iterator.increment(); | 1849 iterator.increment(); |
1850 } | 1850 } |
1851 } | 1851 } |
1852 | 1852 |
1853 void RenderBlock::LineBreaker::skipLeadingWhitespace(InlineBidiResolver& resolve
r, LineInfo& lineInfo, | 1853 void RenderBlock::LineBreaker::skipLeadingWhitespace(InlineBidiResolver& resolve
r, LineInfo& lineInfo, |
1854 FloatingObject* lastFloatFr
omPreviousLine, LineWidth& width) | 1854 FloatingObject* lastFloatFr
omPreviousLine, LineWidth& width) |
1855 { | 1855 { |
1856 while (!resolver.position().atEnd() && !requiresLineBox(resolver.position(),
lineInfo, LeadingWhitespace)) { | 1856 while (!resolver.position().atEnd() && !requiresLineBox(resolver.position(),
lineInfo, LeadingWhitespace)) { |
1857 RenderObject* object = resolver.position().m_obj; | 1857 RenderObject* object = resolver.position().m_obj; |
1858 if (object->isFloating()) | 1858 if (object->isPositioned()) |
| 1859 setStaticPositions(m_block, toRenderBox(object)); |
| 1860 else if (object->isFloating()) |
1859 m_block->positionNewFloatOnLine(m_block->insertFloatingObject(toRend
erBox(object)), lastFloatFromPreviousLine, lineInfo, width); | 1861 m_block->positionNewFloatOnLine(m_block->insertFloatingObject(toRend
erBox(object)), lastFloatFromPreviousLine, lineInfo, width); |
1860 else if (object->isPositioned()) | |
1861 setStaticPositions(m_block, toRenderBox(object)); | |
1862 resolver.increment(); | 1862 resolver.increment(); |
1863 } | 1863 } |
1864 resolver.commitExplicitEmbedding(); | 1864 resolver.commitExplicitEmbedding(); |
1865 } | 1865 } |
1866 | 1866 |
1867 // This is currently just used for list markers and inline flows that have line
boxes. Neither should | 1867 // 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. | 1868 // have an effect on whitespace at the start of the line. |
1869 static bool shouldSkipWhitespaceAfterStartObject(RenderBlock* block, RenderObjec
t* o, LineMidpointState& lineMidpointState) | 1869 static bool shouldSkipWhitespaceAfterStartObject(RenderBlock* block, RenderObjec
t* o, LineMidpointState& lineMidpointState) |
1870 { | 1870 { |
1871 RenderObject* next = bidiNextSkippingEmptyInlines(block, o); | 1871 RenderObject* next = bidiNextSkippingEmptyInlines(block, o); |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2125 lineInfo.setEmpty(false, m_block, &width); | 2125 lineInfo.setEmpty(false, m_block, &width); |
2126 trailingObjects.clear(); | 2126 trailingObjects.clear(); |
2127 lineInfo.setPreviousLineBrokeCleanly(true); | 2127 lineInfo.setPreviousLineBrokeCleanly(true); |
2128 | 2128 |
2129 if (!lineInfo.isEmpty()) | 2129 if (!lineInfo.isEmpty()) |
2130 m_clear = current.m_obj->style()->clear(); | 2130 m_clear = current.m_obj->style()->clear(); |
2131 } | 2131 } |
2132 goto end; | 2132 goto end; |
2133 } | 2133 } |
2134 | 2134 |
2135 if (current.m_obj->isFloating()) { | 2135 if (current.m_obj->isPositioned()) { |
2136 RenderBox* floatBox = toRenderBox(current.m_obj); | |
2137 FloatingObject* f = m_block->insertFloatingObject(floatBox); | |
2138 // check if it fits in the current line. | |
2139 // If it does, position it now, otherwise, position | |
2140 // it after moving to next line (in newLine() func) | |
2141 if (floatsFitOnLine && width.fitsOnLine(m_block->logicalWidthForFloa
t(f))) { | |
2142 m_block->positionNewFloatOnLine(f, lastFloatFromPreviousLine, li
neInfo, width); | |
2143 if (lBreak.m_obj == current.m_obj) { | |
2144 ASSERT(!lBreak.m_pos); | |
2145 lBreak.increment(); | |
2146 } | |
2147 } else | |
2148 floatsFitOnLine = false; | |
2149 } else if (current.m_obj->isPositioned()) { | |
2150 // If our original display wasn't an inline type, then we can | 2136 // If our original display wasn't an inline type, then we can |
2151 // go ahead and determine our static inline position now. | 2137 // go ahead and determine our static inline position now. |
2152 RenderBox* box = toRenderBox(current.m_obj); | 2138 RenderBox* box = toRenderBox(current.m_obj); |
2153 bool isInlineType = box->style()->isOriginalDisplayInlineType(); | 2139 bool isInlineType = box->style()->isOriginalDisplayInlineType(); |
2154 if (!isInlineType) | 2140 if (!isInlineType) |
2155 m_block->setStaticInlinePositionForChild(box, m_block->logicalHe
ight(), m_block->startOffsetForContent(m_block->logicalHeight())); | 2141 m_block->setStaticInlinePositionForChild(box, m_block->logicalHe
ight(), m_block->startOffsetForContent(m_block->logicalHeight())); |
2156 else { | 2142 else { |
2157 // If our original display was an INLINE type, then we can go ah
ead | 2143 // If our original display was an INLINE type, then we can go ah
ead |
2158 // and determine our static y position now. | 2144 // and determine our static y position now. |
2159 box->layer()->setStaticBlockPosition(m_block->logicalHeight()); | 2145 box->layer()->setStaticBlockPosition(m_block->logicalHeight()); |
2160 } | 2146 } |
2161 | 2147 |
2162 // If we're ignoring spaces, we have to stop and include this object
and | 2148 // If we're ignoring spaces, we have to stop and include this object
and |
2163 // then start ignoring spaces again. | 2149 // then start ignoring spaces again. |
2164 if (isInlineType || current.m_obj->container()->isRenderInline()) { | 2150 if (isInlineType || current.m_obj->container()->isRenderInline()) { |
2165 if (ignoringSpaces) { | 2151 if (ignoringSpaces) { |
2166 ignoreStart.m_obj = current.m_obj; | 2152 ignoreStart.m_obj = current.m_obj; |
2167 ignoreStart.m_pos = 0; | 2153 ignoreStart.m_pos = 0; |
2168 addMidpoint(lineMidpointState, ignoreStart); // Stop ignorin
g spaces. | 2154 addMidpoint(lineMidpointState, ignoreStart); // Stop ignorin
g spaces. |
2169 addMidpoint(lineMidpointState, ignoreStart); // Start ignori
ng again. | 2155 addMidpoint(lineMidpointState, ignoreStart); // Start ignori
ng again. |
2170 } | 2156 } |
2171 trailingObjects.appendBoxIfNeeded(box); | 2157 trailingObjects.appendBoxIfNeeded(box); |
2172 } else | 2158 } else |
2173 m_positionedObjects.append(box); | 2159 m_positionedObjects.append(box); |
| 2160 } else if (current.m_obj->isFloating()) { |
| 2161 RenderBox* floatBox = toRenderBox(current.m_obj); |
| 2162 FloatingObject* f = m_block->insertFloatingObject(floatBox); |
| 2163 // check if it fits in the current line. |
| 2164 // If it does, position it now, otherwise, position |
| 2165 // it after moving to next line (in newLine() func) |
| 2166 if (floatsFitOnLine && width.fitsOnLine(m_block->logicalWidthForFloa
t(f))) { |
| 2167 m_block->positionNewFloatOnLine(f, lastFloatFromPreviousLine, li
neInfo, width); |
| 2168 if (lBreak.m_obj == current.m_obj) { |
| 2169 ASSERT(!lBreak.m_pos); |
| 2170 lBreak.increment(); |
| 2171 } |
| 2172 } else |
| 2173 floatsFitOnLine = false; |
2174 } else if (current.m_obj->isRenderInline()) { | 2174 } else if (current.m_obj->isRenderInline()) { |
2175 // Right now, we should only encounter empty inlines here. | 2175 // Right now, we should only encounter empty inlines here. |
2176 ASSERT(!current.m_obj->firstChild()); | 2176 ASSERT(!current.m_obj->firstChild()); |
2177 | 2177 |
2178 RenderInline* flowBox = toRenderInline(current.m_obj); | 2178 RenderInline* flowBox = toRenderInline(current.m_obj); |
2179 | 2179 |
2180 // Now that some inline flows have line boxes, if we are already ign
oring spaces, we need | 2180 // Now that some inline flows have line boxes, if we are already ign
oring spaces, we need |
2181 // to make sure that we stop to include this object and then start i
gnoring spaces again. | 2181 // to make sure that we stop to include this object and then start i
gnoring spaces again. |
2182 // If this object is at the start of the line, we need to behave lik
e list markers and | 2182 // If this object is at the start of the line, we need to behave lik
e list markers and |
2183 // start ignoring spaces. | 2183 // start ignoring spaces. |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2712 availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), false) -
logicalLeft; | 2712 availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), false) -
logicalLeft; |
2713 float totalLogicalWidth = logicalWidthForChild(child); | 2713 float totalLogicalWidth = logicalWidthForChild(child); |
2714 updateLogicalWidthForAlignment(textAlign, 0l, logicalLeft, totalLogicalWidth
, availableLogicalWidth, 0); | 2714 updateLogicalWidthForAlignment(textAlign, 0l, logicalLeft, totalLogicalWidth
, availableLogicalWidth, 0); |
2715 | 2715 |
2716 if (!style()->isLeftToRightDirection()) | 2716 if (!style()->isLeftToRightDirection()) |
2717 return logicalWidth() - (logicalLeft + totalLogicalWidth); | 2717 return logicalWidth() - (logicalLeft + totalLogicalWidth); |
2718 return logicalLeft; | 2718 return logicalLeft; |
2719 } | 2719 } |
2720 | 2720 |
2721 } | 2721 } |
OLD | NEW |