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 * Copyright (C) 2013 Adobe Systems Incorporated. | 5 * Copyright (C) 2013 Adobe Systems Incorporated. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 85 |
86 LayoutObject* currentObject() { return m_current.object(); } | 86 LayoutObject* currentObject() { return m_current.object(); } |
87 InlineIterator lineBreak() { return m_lineBreak; } | 87 InlineIterator lineBreak() { return m_lineBreak; } |
88 bool atEnd() { return m_atEnd; } | 88 bool atEnd() { return m_atEnd; } |
89 | 89 |
90 void initializeForCurrentObject(); | 90 void initializeForCurrentObject(); |
91 | 91 |
92 void increment(); | 92 void increment(); |
93 | 93 |
94 void handleBR(EClear&); | 94 void handleBR(EClear&); |
95 void handleOutOfFlowPositioned(Vector<RenderBox*>& positionedObjects); | 95 void handleOutOfFlowPositioned(Vector<LayoutBox*>& positionedObjects); |
96 void handleFloat(); | 96 void handleFloat(); |
97 void handleEmptyInline(); | 97 void handleEmptyInline(); |
98 void handleReplaced(); | 98 void handleReplaced(); |
99 bool handleText(WordMeasurements&, bool& hyphenated); | 99 bool handleText(WordMeasurements&, bool& hyphenated); |
100 void commitAndUpdateLineBreakIfNeeded(); | 100 void commitAndUpdateLineBreakIfNeeded(); |
101 InlineIterator handleEndOfLine(); | 101 InlineIterator handleEndOfLine(); |
102 | 102 |
103 void clearLineBreakIfFitsOnLine() | 103 void clearLineBreakIfFitsOnLine() |
104 { | 104 { |
105 if (m_width.fitsOnLine() || m_lastWS == NOWRAP) | 105 if (m_width.fitsOnLine() || m_lastWS == NOWRAP) |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 return false; | 191 return false; |
192 | 192 |
193 if (!shouldCollapseWhiteSpace(it.object()->styleRef(), lineInfo, whitespaceP
osition) || it.object()->isBR()) | 193 if (!shouldCollapseWhiteSpace(it.object()->styleRef(), lineInfo, whitespaceP
osition) || it.object()->isBR()) |
194 return true; | 194 return true; |
195 | 195 |
196 UChar current = it.current(); | 196 UChar current = it.current(); |
197 bool notJustWhitespace = current != ' ' && current != '\t' && current != sof
tHyphen && (current != '\n' || it.object()->preservesNewline()); | 197 bool notJustWhitespace = current != ' ' && current != '\t' && current != sof
tHyphen && (current != '\n' || it.object()->preservesNewline()); |
198 return notJustWhitespace || isEmptyInline(it.object()); | 198 return notJustWhitespace || isEmptyInline(it.object()); |
199 } | 199 } |
200 | 200 |
201 inline void setStaticPositions(RenderBlockFlow* block, RenderBox* child) | 201 inline void setStaticPositions(RenderBlockFlow* block, LayoutBox* child) |
202 { | 202 { |
203 ASSERT(child->isOutOfFlowPositioned()); | 203 ASSERT(child->isOutOfFlowPositioned()); |
204 // FIXME: The math here is actually not really right. It's a best-guess appr
oximation that | 204 // FIXME: The math here is actually not really right. It's a best-guess appr
oximation that |
205 // will work for the common cases | 205 // will work for the common cases |
206 LayoutObject* containerBlock = child->container(); | 206 LayoutObject* containerBlock = child->container(); |
207 LayoutUnit blockHeight = block->logicalHeight(); | 207 LayoutUnit blockHeight = block->logicalHeight(); |
208 if (containerBlock->isRenderInline()) { | 208 if (containerBlock->isRenderInline()) { |
209 // A relative positioned inline encloses us. In this case, we also have
to determine our | 209 // A relative positioned inline encloses us. In this case, we also have
to determine our |
210 // position as though we were an inline. Set |staticInlinePosition| and
|staticBlockPosition| on the relative positioned | 210 // position as though we were an inline. Set |staticInlinePosition| and
|staticBlockPosition| on the relative positioned |
211 // inline so that we can obtain the value later. | 211 // inline so that we can obtain the value later. |
(...skipping 12 matching lines...) Expand all Loading... |
224 // line boxes even for containers that may ultimately collapse away. Otherwise w
e'll never get positioned | 224 // line boxes even for containers that may ultimately collapse away. Otherwise w
e'll never get positioned |
225 // elements quite right. In other words, we need to build this function's work i
nto the normal line | 225 // elements quite right. In other words, we need to build this function's work i
nto the normal line |
226 // object iteration process. | 226 // object iteration process. |
227 // NB. this function will insert any floating elements that would otherwise | 227 // NB. this function will insert any floating elements that would otherwise |
228 // be skipped but it will not position them. | 228 // be skipped but it will not position them. |
229 inline void BreakingContext::skipTrailingWhitespace(InlineIterator& iterator, co
nst LineInfo& lineInfo) | 229 inline void BreakingContext::skipTrailingWhitespace(InlineIterator& iterator, co
nst LineInfo& lineInfo) |
230 { | 230 { |
231 while (!iterator.atEnd() && !requiresLineBox(iterator, lineInfo, TrailingWhi
tespace)) { | 231 while (!iterator.atEnd() && !requiresLineBox(iterator, lineInfo, TrailingWhi
tespace)) { |
232 LayoutObject* object = iterator.object(); | 232 LayoutObject* object = iterator.object(); |
233 if (object->isOutOfFlowPositioned()) | 233 if (object->isOutOfFlowPositioned()) |
234 setStaticPositions(m_block, toRenderBox(object)); | 234 setStaticPositions(m_block, toLayoutBox(object)); |
235 else if (object->isFloating()) | 235 else if (object->isFloating()) |
236 m_block->insertFloatingObject(*toRenderBox(object)); | 236 m_block->insertFloatingObject(*toLayoutBox(object)); |
237 iterator.increment(); | 237 iterator.increment(); |
238 } | 238 } |
239 } | 239 } |
240 | 240 |
241 inline void BreakingContext::initializeForCurrentObject() | 241 inline void BreakingContext::initializeForCurrentObject() |
242 { | 242 { |
243 m_currentStyle = m_current.object()->style(); | 243 m_currentStyle = m_current.object()->style(); |
244 m_nextObject = bidiNextSkippingEmptyInlines(m_block, m_current.object()); | 244 m_nextObject = bidiNextSkippingEmptyInlines(m_block, m_current.object()); |
245 if (m_nextObject && m_nextObject->parent() && !m_nextObject->parent()->isDes
cendantOf(m_current.object()->parent())) | 245 if (m_nextObject && m_nextObject->parent() && !m_nextObject->parent()->isDes
cendantOf(m_current.object()->parent())) |
246 m_includeEndWidth = true; | 246 m_includeEndWidth = true; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 extraWidth += borderPaddingMarginEnd(parentAsRenderInline); | 328 extraWidth += borderPaddingMarginEnd(parentAsRenderInline); |
329 if (!start && !end) | 329 if (!start && !end) |
330 return extraWidth; | 330 return extraWidth; |
331 } | 331 } |
332 child = parent; | 332 child = parent; |
333 parent = child->parent(); | 333 parent = child->parent(); |
334 } | 334 } |
335 return extraWidth; | 335 return extraWidth; |
336 } | 336 } |
337 | 337 |
338 inline void BreakingContext::handleOutOfFlowPositioned(Vector<RenderBox*>& posit
ionedObjects) | 338 inline void BreakingContext::handleOutOfFlowPositioned(Vector<LayoutBox*>& posit
ionedObjects) |
339 { | 339 { |
340 // If our original display wasn't an inline type, then we can | 340 // If our original display wasn't an inline type, then we can |
341 // go ahead and determine our static inline position now. | 341 // go ahead and determine our static inline position now. |
342 RenderBox* box = toRenderBox(m_current.object()); | 342 LayoutBox* box = toLayoutBox(m_current.object()); |
343 bool isInlineType = box->style()->isOriginalDisplayInlineType(); | 343 bool isInlineType = box->style()->isOriginalDisplayInlineType(); |
344 if (!isInlineType) { | 344 if (!isInlineType) { |
345 m_block->setStaticInlinePositionForChild(*box, m_block->startOffsetForCo
ntent()); | 345 m_block->setStaticInlinePositionForChild(*box, m_block->startOffsetForCo
ntent()); |
346 } else { | 346 } else { |
347 // If our original display was an INLINE type, then we can go ahead | 347 // If our original display was an INLINE type, then we can go ahead |
348 // and determine our static y position now. | 348 // and determine our static y position now. |
349 box->layer()->setStaticBlockPosition(m_block->logicalHeight()); | 349 box->layer()->setStaticBlockPosition(m_block->logicalHeight()); |
350 } | 350 } |
351 | 351 |
352 // If we're ignoring spaces, we have to stop and include this object and | 352 // If we're ignoring spaces, we have to stop and include this object and |
353 // then start ignoring spaces again. | 353 // then start ignoring spaces again. |
354 if (isInlineType || box->container()->isRenderInline()) { | 354 if (isInlineType || box->container()->isRenderInline()) { |
355 if (m_ignoringSpaces) | 355 if (m_ignoringSpaces) |
356 m_lineMidpointState.ensureLineBoxInsideIgnoredSpaces(box); | 356 m_lineMidpointState.ensureLineBoxInsideIgnoredSpaces(box); |
357 m_trailingObjects.appendObjectIfNeeded(box); | 357 m_trailingObjects.appendObjectIfNeeded(box); |
358 } else { | 358 } else { |
359 positionedObjects.append(box); | 359 positionedObjects.append(box); |
360 } | 360 } |
361 m_width.addUncommittedWidth(inlineLogicalWidth(box).toFloat()); | 361 m_width.addUncommittedWidth(inlineLogicalWidth(box).toFloat()); |
362 // Reset prior line break context characters. | 362 // Reset prior line break context characters. |
363 m_renderTextInfo.m_lineBreakIterator.resetPriorContext(); | 363 m_renderTextInfo.m_lineBreakIterator.resetPriorContext(); |
364 } | 364 } |
365 | 365 |
366 inline void BreakingContext::handleFloat() | 366 inline void BreakingContext::handleFloat() |
367 { | 367 { |
368 RenderBox* floatBox = toRenderBox(m_current.object()); | 368 LayoutBox* floatBox = toLayoutBox(m_current.object()); |
369 FloatingObject* floatingObject = m_block->insertFloatingObject(*floatBox); | 369 FloatingObject* floatingObject = m_block->insertFloatingObject(*floatBox); |
370 // check if it fits in the current line. | 370 // check if it fits in the current line. |
371 // If it does, position it now, otherwise, position | 371 // If it does, position it now, otherwise, position |
372 // it after moving to next line (in newLine() func) | 372 // it after moving to next line (in newLine() func) |
373 // FIXME: Bug 110372: Properly position multiple stacked floats with non-rec
tangular shape outside. | 373 // FIXME: Bug 110372: Properly position multiple stacked floats with non-rec
tangular shape outside. |
374 if (m_floatsFitOnLine && m_width.fitsOnLine(m_block->logicalWidthForFloat(fl
oatingObject).toFloat(), ExcludeWhitespace)) { | 374 if (m_floatsFitOnLine && m_width.fitsOnLine(m_block->logicalWidthForFloat(fl
oatingObject).toFloat(), ExcludeWhitespace)) { |
375 m_block->positionNewFloatOnLine(floatingObject, m_lastFloatFromPreviousL
ine, m_lineInfo, m_width); | 375 m_block->positionNewFloatOnLine(floatingObject, m_lastFloatFromPreviousL
ine, m_lineInfo, m_width); |
376 if (m_lineBreak.object() == m_current.object()) { | 376 if (m_lineBreak.object() == m_current.object()) { |
377 ASSERT(!m_lineBreak.offset()); | 377 ASSERT(!m_lineBreak.offset()); |
378 m_lineBreak.increment(); | 378 m_lineBreak.increment(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 // if we encounter collapsible whitepace. | 433 // if we encounter collapsible whitepace. |
434 m_trailingObjects.appendObjectIfNeeded(m_current.object()); | 434 m_trailingObjects.appendObjectIfNeeded(m_current.object()); |
435 } | 435 } |
436 } | 436 } |
437 | 437 |
438 m_width.addUncommittedWidth((inlineLogicalWidth(m_current.object()) + border
PaddingMarginStart(flowBox) + borderPaddingMarginEnd(flowBox)).toFloat()); | 438 m_width.addUncommittedWidth((inlineLogicalWidth(m_current.object()) + border
PaddingMarginStart(flowBox) + borderPaddingMarginEnd(flowBox)).toFloat()); |
439 } | 439 } |
440 | 440 |
441 inline void BreakingContext::handleReplaced() | 441 inline void BreakingContext::handleReplaced() |
442 { | 442 { |
443 RenderBox* replacedBox = toRenderBox(m_current.object()); | 443 LayoutBox* replacedBox = toLayoutBox(m_current.object()); |
444 | 444 |
445 if (m_atStart) | 445 if (m_atStart) |
446 m_width.updateAvailableWidth(replacedBox->logicalHeight()); | 446 m_width.updateAvailableWidth(replacedBox->logicalHeight()); |
447 | 447 |
448 // Break on replaced elements if either has normal white-space. | 448 // Break on replaced elements if either has normal white-space. |
449 if ((m_autoWrap || LayoutStyle::autoWrap(m_lastWS)) && (!m_current.object()-
>isImage() || m_allowImagesToBreak)) { | 449 if ((m_autoWrap || LayoutStyle::autoWrap(m_lastWS)) && (!m_current.object()-
>isImage() || m_allowImagesToBreak)) { |
450 m_width.commit(); | 450 m_width.commit(); |
451 m_lineBreak.moveToStartOf(m_current.object()); | 451 m_lineBreak.moveToStartOf(m_current.object()); |
452 } | 452 } |
453 | 453 |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 | 891 |
892 if (style.textIndentType() == TextIndentHanging) | 892 if (style.textIndentType() == TextIndentHanging) |
893 shouldIndentText = shouldIndentText == IndentText ? DoNotIndentText : In
dentText; | 893 shouldIndentText = shouldIndentText == IndentText ? DoNotIndentText : In
dentText; |
894 | 894 |
895 return shouldIndentText; | 895 return shouldIndentText; |
896 } | 896 } |
897 | 897 |
898 } | 898 } |
899 | 899 |
900 #endif // BreakingContextInlineHeaders_h | 900 #endif // BreakingContextInlineHeaders_h |
OLD | NEW |