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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 void commitAndUpdateLineBreakIfNeeded(); | 92 void commitAndUpdateLineBreakIfNeeded(); |
93 InlineIterator handleEndOfLine(); | 93 InlineIterator handleEndOfLine(); |
94 | 94 |
95 void clearLineBreakIfFitsOnLine() | 95 void clearLineBreakIfFitsOnLine() |
96 { | 96 { |
97 if (m_width.fitsOnLine() || m_lastWS == NOWRAP) | 97 if (m_width.fitsOnLine() || m_lastWS == NOWRAP) |
98 m_lineBreak.clear(); | 98 m_lineBreak.clear(); |
99 } | 99 } |
100 | 100 |
101 private: | 101 private: |
102 void skipTrailingWhitespace(InlineIterator&, const LineInfo&); | |
103 | |
104 InlineBidiResolver& m_resolver; | 102 InlineBidiResolver& m_resolver; |
105 | 103 |
106 InlineIterator m_current; | 104 InlineIterator m_current; |
107 InlineIterator m_lineBreak; | 105 InlineIterator m_lineBreak; |
108 InlineIterator m_startOfIgnoredSpaces; | 106 InlineIterator m_startOfIgnoredSpaces; |
109 | 107 |
110 RenderBlockFlow* m_block; | 108 RenderBlockFlow* m_block; |
111 RenderObject* m_lastObject; | 109 RenderObject* m_lastObject; |
112 RenderObject* m_nextObject; | 110 RenderObject* m_nextObject; |
113 | 111 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 return false; | 176 return false; |
179 | 177 |
180 if (!shouldCollapseWhiteSpace(it.object()->style(), lineInfo, whitespacePosi
tion)) | 178 if (!shouldCollapseWhiteSpace(it.object()->style(), lineInfo, whitespacePosi
tion)) |
181 return true; | 179 return true; |
182 | 180 |
183 UChar current = it.current(); | 181 UChar current = it.current(); |
184 bool notJustWhitespace = current != ' ' && current != '\t' && current != sof
tHyphen && (current != '\n' || it.object()->preservesNewline()); | 182 bool notJustWhitespace = current != ' ' && current != '\t' && current != sof
tHyphen && (current != '\n' || it.object()->preservesNewline()); |
185 return notJustWhitespace || isEmptyInline(it.object()); | 183 return notJustWhitespace || isEmptyInline(it.object()); |
186 } | 184 } |
187 | 185 |
188 inline void setStaticPositions(RenderBlockFlow* block, RenderBox* child) | |
189 { | |
190 ASSERT(child->isOutOfFlowPositioned()); | |
191 // FIXME: The math here is actually not really right. It's a best-guess appr
oximation that | |
192 // will work for the common cases | |
193 RenderObject* containerBlock = child->container(); | |
194 LayoutUnit blockHeight = block->logicalHeight(); | |
195 if (containerBlock->isRenderInline()) { | |
196 // A relative positioned inline encloses us. In this case, we also have
to determine our | |
197 // position as though we were an inline. Set |staticInlinePosition| and
|staticBlockPosition| on the relative positioned | |
198 // inline so that we can obtain the value later. | |
199 toRenderInline(containerBlock)->layer()->setStaticInlinePosition(block->
startAlignedOffsetForLine(false)); | |
200 toRenderInline(containerBlock)->layer()->setStaticBlockPosition(blockHei
ght); | |
201 } | |
202 block->updateStaticInlinePositionForChild(child); | |
203 child->layer()->setStaticBlockPosition(blockHeight); | |
204 } | |
205 | |
206 // FIXME: The entire concept of the skipTrailingWhitespace function is flawed, s
ince we really need to be building | |
207 // line boxes even for containers that may ultimately collapse away. Otherwise w
e'll never get positioned | |
208 // elements quite right. In other words, we need to build this function's work i
nto the normal line | |
209 // object iteration process. | |
210 // NB. this function will insert any floating elements that would otherwise | |
211 // be skipped but it will not position them. | |
212 inline void BreakingContext::skipTrailingWhitespace(InlineIterator& iterator, co
nst LineInfo& lineInfo) | |
213 { | |
214 while (!iterator.atEnd() && !requiresLineBox(iterator, lineInfo, TrailingWhi
tespace)) { | |
215 RenderObject* object = iterator.object(); | |
216 if (object->isOutOfFlowPositioned()) | |
217 setStaticPositions(m_block, toRenderBox(object)); | |
218 iterator.increment(); | |
219 } | |
220 } | |
221 | |
222 inline void BreakingContext::initializeForCurrentObject() | 186 inline void BreakingContext::initializeForCurrentObject() |
223 { | 187 { |
224 m_currentStyle = m_current.object()->style(); | 188 m_currentStyle = m_current.object()->style(); |
225 m_nextObject = bidiNextSkippingEmptyInlines(m_block, m_current.object()); | 189 m_nextObject = bidiNextSkippingEmptyInlines(m_block, m_current.object()); |
226 if (m_nextObject && m_nextObject->parent() && !m_nextObject->parent()->isDes
cendantOf(m_current.object()->parent())) | 190 if (m_nextObject && m_nextObject->parent() && !m_nextObject->parent()->isDes
cendantOf(m_current.object()->parent())) |
227 m_includeEndWidth = true; | 191 m_includeEndWidth = true; |
228 | 192 |
229 m_currWS = m_current.object()->isReplaced() ? m_current.object()->parent()->
style()->whiteSpace() : m_currentStyle->whiteSpace(); | 193 m_currWS = m_current.object()->isReplaced() ? m_current.object()->parent()->
style()->whiteSpace() : m_currentStyle->whiteSpace(); |
230 m_lastWS = m_lastObject->isReplaced() ? m_lastObject->parent()->style()->whi
teSpace() : m_lastObject->style()->whiteSpace(); | 194 m_lastWS = m_lastObject->isReplaced() ? m_lastObject->parent()->style()->whi
teSpace() : m_lastObject->style()->whiteSpace(); |
231 | 195 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 parent = child->parent(); | 268 parent = child->parent(); |
305 } | 269 } |
306 return extraWidth; | 270 return extraWidth; |
307 } | 271 } |
308 | 272 |
309 inline void BreakingContext::handleOutOfFlowPositioned(Vector<RenderBox*>& posit
ionedObjects) | 273 inline void BreakingContext::handleOutOfFlowPositioned(Vector<RenderBox*>& posit
ionedObjects) |
310 { | 274 { |
311 // If our original display wasn't an inline type, then we can | 275 // If our original display wasn't an inline type, then we can |
312 // go ahead and determine our static inline position now. | 276 // go ahead and determine our static inline position now. |
313 RenderBox* box = toRenderBox(m_current.object()); | 277 RenderBox* box = toRenderBox(m_current.object()); |
314 bool isInlineType = box->style()->isOriginalDisplayInlineType(); | |
315 if (!isInlineType) { | |
316 m_block->setStaticInlinePositionForChild(box, m_block->startOffsetForCon
tent()); | |
317 } else { | |
318 // If our original display was an INLINE type, then we can go ahead | |
319 // and determine our static y position now. | |
320 box->layer()->setStaticBlockPosition(m_block->logicalHeight()); | |
321 } | |
322 | 278 |
323 // If we're ignoring spaces, we have to stop and include this object and | 279 // If we're ignoring spaces, we have to stop and include this object and |
324 // then start ignoring spaces again. | 280 // then start ignoring spaces again. |
325 if (isInlineType || box->container()->isRenderInline()) { | 281 if (box->style()->isOriginalDisplayInlineType() || box->container()->isRende
rInline()) { |
326 if (m_ignoringSpaces) | 282 if (m_ignoringSpaces) |
327 m_lineMidpointState.ensureLineBoxInsideIgnoredSpaces(box); | 283 m_lineMidpointState.ensureLineBoxInsideIgnoredSpaces(box); |
328 m_trailingObjects.appendObjectIfNeeded(box); | 284 m_trailingObjects.appendObjectIfNeeded(box); |
329 } else { | 285 } else { |
330 positionedObjects.append(box); | 286 positionedObjects.append(box); |
331 } | 287 } |
332 m_width.addUncommittedWidth(inlineLogicalWidth(box).toFloat()); | 288 m_width.addUncommittedWidth(inlineLogicalWidth(box).toFloat()); |
333 // Reset prior line break context characters. | 289 // Reset prior line break context characters. |
334 m_renderTextInfo.m_lineBreakIterator.resetPriorContext(); | 290 m_renderTextInfo.m_lineBreakIterator.resetPriorContext(); |
335 } | 291 } |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 | 540 |
585 if (m_autoWrap || breakWords) { | 541 if (m_autoWrap || breakWords) { |
586 // If we break only after white-space, consider the current char
acter | 542 // If we break only after white-space, consider the current char
acter |
587 // as candidate width for this line. | 543 // as candidate width for this line. |
588 bool lineWasTooWide = false; | 544 bool lineWasTooWide = false; |
589 if (m_width.fitsOnLine() && m_currentCharacterIsSpace && m_curre
ntStyle->breakOnlyAfterWhiteSpace() && !midWordBreak) { | 545 if (m_width.fitsOnLine() && m_currentCharacterIsSpace && m_curre
ntStyle->breakOnlyAfterWhiteSpace() && !midWordBreak) { |
590 float charWidth = textWidth(renderText, m_current.offset(),
1, font, m_width.currentWidth(), isFixedPitch, m_collapseWhiteSpace, &wordMeasur
ement.fallbackFonts) + (applyWordSpacing ? wordSpacing : 0); | 546 float charWidth = textWidth(renderText, m_current.offset(),
1, font, m_width.currentWidth(), isFixedPitch, m_collapseWhiteSpace, &wordMeasur
ement.fallbackFonts) + (applyWordSpacing ? wordSpacing : 0); |
591 // Check if line is too big even without the extra space | 547 // Check if line is too big even without the extra space |
592 // at the end of the line. If it is not, do nothing. | 548 // at the end of the line. If it is not, do nothing. |
593 // If the line needs the extra whitespace to be too long, | 549 // If the line needs the extra whitespace to be too long, |
594 // then move the line break to the space and skip all | 550 // then move the line break to the space. |
595 // additional whitespace. | |
596 if (!m_width.fitsOnLine(charWidth)) { | 551 if (!m_width.fitsOnLine(charWidth)) { |
597 lineWasTooWide = true; | 552 lineWasTooWide = true; |
598 m_lineBreak.moveTo(m_current.object(), m_current.offset(
), m_current.nextBreakablePosition()); | 553 m_lineBreak.moveTo(m_current.object(), m_current.offset(
), m_current.nextBreakablePosition()); |
599 skipTrailingWhitespace(m_lineBreak, m_lineInfo); | |
600 } | 554 } |
601 } | 555 } |
602 if (lineWasTooWide || !m_width.fitsOnLine()) { | 556 if (lineWasTooWide || !m_width.fitsOnLine()) { |
603 if (m_lineBreak.atTextParagraphSeparator()) { | 557 if (m_lineBreak.atTextParagraphSeparator()) { |
604 if (!stoppedIgnoringSpaces && m_current.offset() > 0) | 558 if (!stoppedIgnoringSpaces && m_current.offset() > 0) |
605 m_lineMidpointState.ensureCharacterGetsLineBox(m_cur
rent); | 559 m_lineMidpointState.ensureCharacterGetsLineBox(m_cur
rent); |
606 m_lineBreak.increment(); | 560 m_lineBreak.increment(); |
607 m_lineInfo.setPreviousLineBrokeCleanly(true); | 561 m_lineInfo.setPreviousLineBrokeCleanly(true); |
608 wordMeasurement.endOffset = m_lineBreak.offset(); | 562 wordMeasurement.endOffset = m_lineBreak.offset(); |
609 } | 563 } |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
807 | 761 |
808 if (style->textIndentType() == TextIndentHanging) | 762 if (style->textIndentType() == TextIndentHanging) |
809 shouldIndentText = shouldIndentText == IndentText ? DoNotIndentText : In
dentText; | 763 shouldIndentText = shouldIndentText == IndentText ? DoNotIndentText : In
dentText; |
810 | 764 |
811 return shouldIndentText; | 765 return shouldIndentText; |
812 } | 766 } |
813 | 767 |
814 } | 768 } |
815 | 769 |
816 #endif // SKY_ENGINE_CORE_RENDERING_LINE_BREAKINGCONTEXTINLINEHEADERS_H_ | 770 #endif // SKY_ENGINE_CORE_RENDERING_LINE_BREAKINGCONTEXTINLINEHEADERS_H_ |
OLD | NEW |