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 1843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1854 // FIXME: The entire concept of the skipTrailingWhitespace function is flawed, s
ince we really need to be building | 1854 // FIXME: The entire concept of the skipTrailingWhitespace function is flawed, s
ince we really need to be building |
1855 // line boxes even for containers that may ultimately collapse away. Otherwise w
e'll never get positioned | 1855 // line boxes even for containers that may ultimately collapse away. Otherwise w
e'll never get positioned |
1856 // elements quite right. In other words, we need to build this function's work i
nto the normal line | 1856 // elements quite right. In other words, we need to build this function's work i
nto the normal line |
1857 // object iteration process. | 1857 // object iteration process. |
1858 // NB. this function will insert any floating elements that would otherwise | 1858 // NB. this function will insert any floating elements that would otherwise |
1859 // be skipped but it will not position them. | 1859 // be skipped but it will not position them. |
1860 void RenderBlock::LineBreaker::skipTrailingWhitespace(InlineIterator& iterator,
const LineInfo& lineInfo) | 1860 void RenderBlock::LineBreaker::skipTrailingWhitespace(InlineIterator& iterator,
const LineInfo& lineInfo) |
1861 { | 1861 { |
1862 while (!iterator.atEnd() && !requiresLineBox(iterator, lineInfo, TrailingWhi
tespace)) { | 1862 while (!iterator.atEnd() && !requiresLineBox(iterator, lineInfo, TrailingWhi
tespace)) { |
1863 RenderObject* object = iterator.m_obj; | 1863 RenderObject* object = iterator.m_obj; |
1864 if (object->isFloating()) { | 1864 if (object->isPositioned()) |
| 1865 setStaticPositions(m_block, toRenderBox(object)); |
| 1866 else if (object->isFloating()) |
1865 m_block->insertFloatingObject(toRenderBox(object)); | 1867 m_block->insertFloatingObject(toRenderBox(object)); |
1866 } else if (object->isPositioned()) | |
1867 setStaticPositions(m_block, toRenderBox(object)); | |
1868 iterator.increment(); | 1868 iterator.increment(); |
1869 } | 1869 } |
1870 } | 1870 } |
1871 | 1871 |
1872 void RenderBlock::LineBreaker::skipLeadingWhitespace(InlineBidiResolver& resolve
r, LineInfo& lineInfo, | 1872 void RenderBlock::LineBreaker::skipLeadingWhitespace(InlineBidiResolver& resolve
r, LineInfo& lineInfo, |
1873 FloatingObject* lastFloatFr
omPreviousLine, LineWidth& width) | 1873 FloatingObject* lastFloatFr
omPreviousLine, LineWidth& width) |
1874 { | 1874 { |
1875 while (!resolver.position().atEnd() && !requiresLineBox(resolver.position(),
lineInfo, LeadingWhitespace)) { | 1875 while (!resolver.position().atEnd() && !requiresLineBox(resolver.position(),
lineInfo, LeadingWhitespace)) { |
1876 RenderObject* object = resolver.position().m_obj; | 1876 RenderObject* object = resolver.position().m_obj; |
1877 if (object->isFloating()) | 1877 if (object->isPositioned()) |
| 1878 setStaticPositions(m_block, toRenderBox(object)); |
| 1879 else if (object->isFloating()) |
1878 m_block->positionNewFloatOnLine(m_block->insertFloatingObject(toRend
erBox(object)), lastFloatFromPreviousLine, lineInfo, width); | 1880 m_block->positionNewFloatOnLine(m_block->insertFloatingObject(toRend
erBox(object)), lastFloatFromPreviousLine, lineInfo, width); |
1879 else if (object->isPositioned()) | |
1880 setStaticPositions(m_block, toRenderBox(object)); | |
1881 resolver.increment(); | 1881 resolver.increment(); |
1882 } | 1882 } |
1883 resolver.commitExplicitEmbedding(); | 1883 resolver.commitExplicitEmbedding(); |
1884 } | 1884 } |
1885 | 1885 |
1886 // This is currently just used for list markers and inline flows that have line
boxes. Neither should | 1886 // 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. | 1887 // have an effect on whitespace at the start of the line. |
1888 static bool shouldSkipWhitespaceAfterStartObject(RenderBlock* block, RenderObjec
t* o, LineMidpointState& lineMidpointState) | 1888 static bool shouldSkipWhitespaceAfterStartObject(RenderBlock* block, RenderObjec
t* o, LineMidpointState& lineMidpointState) |
1889 { | 1889 { |
1890 RenderObject* next = bidiNextSkippingEmptyInlines(block, o); | 1890 RenderObject* next = bidiNextSkippingEmptyInlines(block, o); |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2144 lineInfo.setEmpty(false, m_block, &width); | 2144 lineInfo.setEmpty(false, m_block, &width); |
2145 trailingObjects.clear(); | 2145 trailingObjects.clear(); |
2146 lineInfo.setPreviousLineBrokeCleanly(true); | 2146 lineInfo.setPreviousLineBrokeCleanly(true); |
2147 | 2147 |
2148 if (!lineInfo.isEmpty()) | 2148 if (!lineInfo.isEmpty()) |
2149 m_clear = current.m_obj->style()->clear(); | 2149 m_clear = current.m_obj->style()->clear(); |
2150 } | 2150 } |
2151 goto end; | 2151 goto end; |
2152 } | 2152 } |
2153 | 2153 |
2154 if (current.m_obj->isFloating()) { | 2154 if (current.m_obj->isPositioned()) { |
2155 RenderBox* floatBox = toRenderBox(current.m_obj); | |
2156 FloatingObject* f = m_block->insertFloatingObject(floatBox); | |
2157 // check if it fits in the current line. | |
2158 // If it does, position it now, otherwise, position | |
2159 // it after moving to next line (in newLine() func) | |
2160 if (floatsFitOnLine && width.fitsOnLine(m_block->logicalWidthForFloa
t(f))) { | |
2161 m_block->positionNewFloatOnLine(f, lastFloatFromPreviousLine, li
neInfo, width); | |
2162 if (lBreak.m_obj == current.m_obj) { | |
2163 ASSERT(!lBreak.m_pos); | |
2164 lBreak.increment(); | |
2165 } | |
2166 } else | |
2167 floatsFitOnLine = false; | |
2168 } else if (current.m_obj->isPositioned()) { | |
2169 // If our original display wasn't an inline type, then we can | 2155 // If our original display wasn't an inline type, then we can |
2170 // go ahead and determine our static inline position now. | 2156 // go ahead and determine our static inline position now. |
2171 RenderBox* box = toRenderBox(current.m_obj); | 2157 RenderBox* box = toRenderBox(current.m_obj); |
2172 bool isInlineType = box->style()->isOriginalDisplayInlineType(); | 2158 bool isInlineType = box->style()->isOriginalDisplayInlineType(); |
2173 if (!isInlineType) | 2159 if (!isInlineType) |
2174 m_block->setStaticInlinePositionForChild(box, m_block->logicalHe
ight(), m_block->startOffsetForContent(m_block->logicalHeight())); | 2160 m_block->setStaticInlinePositionForChild(box, m_block->logicalHe
ight(), m_block->startOffsetForContent(m_block->logicalHeight())); |
2175 else { | 2161 else { |
2176 // If our original display was an INLINE type, then we can go ah
ead | 2162 // If our original display was an INLINE type, then we can go ah
ead |
2177 // and determine our static y position now. | 2163 // and determine our static y position now. |
2178 box->layer()->setStaticBlockPosition(m_block->logicalHeight()); | 2164 box->layer()->setStaticBlockPosition(m_block->logicalHeight()); |
2179 } | 2165 } |
2180 | 2166 |
2181 // If we're ignoring spaces, we have to stop and include this object
and | 2167 // If we're ignoring spaces, we have to stop and include this object
and |
2182 // then start ignoring spaces again. | 2168 // then start ignoring spaces again. |
2183 if (isInlineType || current.m_obj->container()->isRenderInline()) { | 2169 if (isInlineType || current.m_obj->container()->isRenderInline()) { |
2184 if (ignoringSpaces) { | 2170 if (ignoringSpaces) { |
2185 ignoreStart.m_obj = current.m_obj; | 2171 ignoreStart.m_obj = current.m_obj; |
2186 ignoreStart.m_pos = 0; | 2172 ignoreStart.m_pos = 0; |
2187 addMidpoint(lineMidpointState, ignoreStart); // Stop ignorin
g spaces. | 2173 addMidpoint(lineMidpointState, ignoreStart); // Stop ignorin
g spaces. |
2188 addMidpoint(lineMidpointState, ignoreStart); // Start ignori
ng again. | 2174 addMidpoint(lineMidpointState, ignoreStart); // Start ignori
ng again. |
2189 } | 2175 } |
2190 trailingObjects.appendBoxIfNeeded(box); | 2176 trailingObjects.appendBoxIfNeeded(box); |
2191 } else | 2177 } else |
2192 m_positionedObjects.append(box); | 2178 m_positionedObjects.append(box); |
| 2179 } else if (current.m_obj->isFloating()) { |
| 2180 RenderBox* floatBox = toRenderBox(current.m_obj); |
| 2181 FloatingObject* f = m_block->insertFloatingObject(floatBox); |
| 2182 // check if it fits in the current line. |
| 2183 // If it does, position it now, otherwise, position |
| 2184 // it after moving to next line (in newLine() func) |
| 2185 if (floatsFitOnLine && width.fitsOnLine(m_block->logicalWidthForFloa
t(f))) { |
| 2186 m_block->positionNewFloatOnLine(f, lastFloatFromPreviousLine, li
neInfo, width); |
| 2187 if (lBreak.m_obj == current.m_obj) { |
| 2188 ASSERT(!lBreak.m_pos); |
| 2189 lBreak.increment(); |
| 2190 } |
| 2191 } else |
| 2192 floatsFitOnLine = false; |
2193 } else if (current.m_obj->isRenderInline()) { | 2193 } else if (current.m_obj->isRenderInline()) { |
2194 // Right now, we should only encounter empty inlines here. | 2194 // Right now, we should only encounter empty inlines here. |
2195 ASSERT(!current.m_obj->firstChild()); | 2195 ASSERT(!current.m_obj->firstChild()); |
2196 | 2196 |
2197 RenderInline* flowBox = toRenderInline(current.m_obj); | 2197 RenderInline* flowBox = toRenderInline(current.m_obj); |
2198 | 2198 |
2199 // Now that some inline flows have line boxes, if we are already ign
oring spaces, we need | 2199 // Now that some inline flows have line boxes, if we are already ign
oring spaces, we need |
2200 // to make sure that we stop to include this object and then start i
gnoring spaces again. | 2200 // to make sure that we stop to include this object and then start i
gnoring spaces again. |
2201 // If this object is at the start of the line, we need to behave lik
e list markers and | 2201 // If this object is at the start of the line, we need to behave lik
e list markers and |
2202 // start ignoring spaces. | 2202 // start ignoring spaces. |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2731 availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), false) -
logicalLeft; | 2731 availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), false) -
logicalLeft; |
2732 float totalLogicalWidth = logicalWidthForChild(child); | 2732 float totalLogicalWidth = logicalWidthForChild(child); |
2733 updateLogicalWidthForAlignment(textAlign, 0l, logicalLeft, totalLogicalWidth
, availableLogicalWidth, 0); | 2733 updateLogicalWidthForAlignment(textAlign, 0l, logicalLeft, totalLogicalWidth
, availableLogicalWidth, 0); |
2734 | 2734 |
2735 if (!style()->isLeftToRightDirection()) | 2735 if (!style()->isLeftToRightDirection()) |
2736 return logicalWidth() - (logicalLeft + totalLogicalWidth); | 2736 return logicalWidth() - (logicalLeft + totalLogicalWidth); |
2737 return logicalLeft; | 2737 return logicalLeft; |
2738 } | 2738 } |
2739 | 2739 |
2740 } | 2740 } |
OLD | NEW |