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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 InlineBidiResolver& m_resolver; | 112 InlineBidiResolver& m_resolver; |
113 | 113 |
114 InlineIterator m_current; | 114 InlineIterator m_current; |
115 InlineIterator m_lineBreak; | 115 InlineIterator m_lineBreak; |
116 InlineIterator m_startOfIgnoredSpaces; | 116 InlineIterator m_startOfIgnoredSpaces; |
117 | 117 |
118 LayoutBlockFlow* m_block; | 118 LayoutBlockFlow* m_block; |
119 LayoutObject* m_lastObject; | 119 LayoutObject* m_lastObject; |
120 LayoutObject* m_nextObject; | 120 LayoutObject* m_nextObject; |
121 | 121 |
122 const LayoutStyle* m_currentStyle; | 122 const ComputedStyle* m_currentStyle; |
123 const LayoutStyle* m_blockStyle; | 123 const ComputedStyle* m_blockStyle; |
124 | 124 |
125 LineInfo& m_lineInfo; | 125 LineInfo& m_lineInfo; |
126 | 126 |
127 LayoutTextInfo& m_renderTextInfo; | 127 LayoutTextInfo& m_renderTextInfo; |
128 | 128 |
129 FloatingObject* m_lastFloatFromPreviousLine; | 129 FloatingObject* m_lastFloatFromPreviousLine; |
130 | 130 |
131 LineWidth m_width; | 131 LineWidth m_width; |
132 | 132 |
133 EWhiteSpace m_currWS; | 133 EWhiteSpace m_currWS; |
(...skipping 12 matching lines...) Expand all Loading... |
146 bool m_collapseWhiteSpace; | 146 bool m_collapseWhiteSpace; |
147 bool m_startingNewParagraph; | 147 bool m_startingNewParagraph; |
148 bool m_allowImagesToBreak; | 148 bool m_allowImagesToBreak; |
149 bool m_atEnd; | 149 bool m_atEnd; |
150 | 150 |
151 LineMidpointState& m_lineMidpointState; | 151 LineMidpointState& m_lineMidpointState; |
152 | 152 |
153 TrailingObjects m_trailingObjects; | 153 TrailingObjects m_trailingObjects; |
154 }; | 154 }; |
155 | 155 |
156 inline bool shouldCollapseWhiteSpace(const LayoutStyle& style, const LineInfo& l
ineInfo, WhitespacePosition whitespacePosition) | 156 inline bool shouldCollapseWhiteSpace(const ComputedStyle& style, const LineInfo&
lineInfo, WhitespacePosition whitespacePosition) |
157 { | 157 { |
158 // CSS2 16.6.1 | 158 // CSS2 16.6.1 |
159 // If a space (U+0020) at the beginning of a line has 'white-space' set to '
normal', 'nowrap', or 'pre-line', it is removed. | 159 // If a space (U+0020) at the beginning of a line has 'white-space' set to '
normal', 'nowrap', or 'pre-line', it is removed. |
160 // If a space (U+0020) at the end of a line has 'white-space' set to 'normal
', 'nowrap', or 'pre-line', it is also removed. | 160 // If a space (U+0020) at the end of a line has 'white-space' set to 'normal
', 'nowrap', or 'pre-line', it is also removed. |
161 // If spaces (U+0020) or tabs (U+0009) at the end of a line have 'white-spac
e' set to 'pre-wrap', UAs may visually collapse them. | 161 // If spaces (U+0020) or tabs (U+0009) at the end of a line have 'white-spac
e' set to 'pre-wrap', UAs may visually collapse them. |
162 return style.collapseWhiteSpace() | 162 return style.collapseWhiteSpace() |
163 || (whitespacePosition == TrailingWhitespace && style.whiteSpace() == PR
E_WRAP && (!lineInfo.isEmpty() || !lineInfo.previousLineBrokeCleanly())); | 163 || (whitespacePosition == TrailingWhitespace && style.whiteSpace() == PR
E_WRAP && (!lineInfo.isEmpty() || !lineInfo.previousLineBrokeCleanly())); |
164 } | 164 } |
165 | 165 |
166 inline bool requiresLineBoxForContent(LayoutInline* flow, const LineInfo& lineIn
fo) | 166 inline bool requiresLineBoxForContent(LayoutInline* flow, const LineInfo& lineIn
fo) |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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; |
247 | 247 |
248 m_currWS = m_current.object()->isReplaced() ? m_current.object()->parent()->
style()->whiteSpace() : m_currentStyle->whiteSpace(); | 248 m_currWS = m_current.object()->isReplaced() ? m_current.object()->parent()->
style()->whiteSpace() : m_currentStyle->whiteSpace(); |
249 m_lastWS = m_lastObject->isReplaced() ? m_lastObject->parent()->style()->whi
teSpace() : m_lastObject->style()->whiteSpace(); | 249 m_lastWS = m_lastObject->isReplaced() ? m_lastObject->parent()->style()->whi
teSpace() : m_lastObject->style()->whiteSpace(); |
250 | 250 |
251 m_autoWrap = LayoutStyle::autoWrap(m_currWS); | 251 m_autoWrap = ComputedStyle::autoWrap(m_currWS); |
252 m_autoWrapWasEverTrueOnLine = m_autoWrapWasEverTrueOnLine || m_autoWrap; | 252 m_autoWrapWasEverTrueOnLine = m_autoWrapWasEverTrueOnLine || m_autoWrap; |
253 | 253 |
254 m_preservesNewline = m_current.object()->isSVGInlineText() ? false : LayoutS
tyle::preserveNewline(m_currWS); | 254 m_preservesNewline = m_current.object()->isSVGInlineText() ? false : Compute
dStyle::preserveNewline(m_currWS); |
255 | 255 |
256 m_collapseWhiteSpace = LayoutStyle::collapseWhiteSpace(m_currWS); | 256 m_collapseWhiteSpace = ComputedStyle::collapseWhiteSpace(m_currWS); |
257 } | 257 } |
258 | 258 |
259 inline void BreakingContext::increment() | 259 inline void BreakingContext::increment() |
260 { | 260 { |
261 // Clear out our character space bool, since inline <pre>s don't collapse wh
itespace | 261 // Clear out our character space bool, since inline <pre>s don't collapse wh
itespace |
262 // with adjacent inline normal/nowrap spans. | 262 // with adjacent inline normal/nowrap spans. |
263 if (!m_collapseWhiteSpace) | 263 if (!m_collapseWhiteSpace) |
264 m_currentCharacterIsSpace = false; | 264 m_currentCharacterIsSpace = false; |
265 | 265 |
266 m_current.moveToStartOf(m_nextObject); | 266 m_current.moveToStartOf(m_nextObject); |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 } | 439 } |
440 | 440 |
441 inline void BreakingContext::handleReplaced() | 441 inline void BreakingContext::handleReplaced() |
442 { | 442 { |
443 LayoutBox* replacedBox = toLayoutBox(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 || ComputedStyle::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 |
454 if (m_ignoringSpaces) | 454 if (m_ignoringSpaces) |
455 m_lineMidpointState.stopIgnoringSpaces(InlineIterator(0, m_current.objec
t(), 0)); | 455 m_lineMidpointState.stopIgnoringSpaces(InlineIterator(0, m_current.objec
t(), 0)); |
456 | 456 |
457 m_lineInfo.setEmpty(false, m_block, &m_width); | 457 m_lineInfo.setEmpty(false, m_block, &m_width); |
458 m_ignoringSpaces = false; | 458 m_ignoringSpaces = false; |
459 m_currentCharacterShouldCollapseIfPreWap = m_currentCharacterIsSpace = false
; | 459 m_currentCharacterShouldCollapseIfPreWap = m_currentCharacterIsSpace = false
; |
(...skipping 30 matching lines...) Expand all Loading... |
490 { | 490 { |
491 for (size_t i = 0; i < wordMeasurements.size(); ++i) { | 491 for (size_t i = 0; i < wordMeasurements.size(); ++i) { |
492 if (wordMeasurements[i].width > 0) | 492 if (wordMeasurements[i].width > 0) |
493 return wordMeasurements[i].width; | 493 return wordMeasurements[i].width; |
494 } | 494 } |
495 return 0; | 495 return 0; |
496 } | 496 } |
497 | 497 |
498 inline float measureHyphenWidth(LayoutText* renderer, const Font& font, TextDire
ction textDirection) | 498 inline float measureHyphenWidth(LayoutText* renderer, const Font& font, TextDire
ction textDirection) |
499 { | 499 { |
500 const LayoutStyle& style = renderer->styleRef(); | 500 const ComputedStyle& style = renderer->styleRef(); |
501 return font.width(constructTextRun(renderer, font, | 501 return font.width(constructTextRun(renderer, font, |
502 style.hyphenString().string(), style, style.direction())); | 502 style.hyphenString().string(), style, style.direction())); |
503 } | 503 } |
504 | 504 |
505 ALWAYS_INLINE TextDirection textDirectionFromUnicode(WTF::Unicode::Direction dir
ection) | 505 ALWAYS_INLINE TextDirection textDirectionFromUnicode(WTF::Unicode::Direction dir
ection) |
506 { | 506 { |
507 return direction == WTF::Unicode::RightToLeft | 507 return direction == WTF::Unicode::RightToLeft |
508 || direction == WTF::Unicode::RightToLeftArabic ? RTL : LTR; | 508 || direction == WTF::Unicode::RightToLeftArabic ? RTL : LTR; |
509 } | 509 } |
510 | 510 |
(...skipping 14 matching lines...) Expand all Loading... |
525 { | 525 { |
526 if (!m_current.offset()) | 526 if (!m_current.offset()) |
527 m_appliedStartWidth = false; | 527 m_appliedStartWidth = false; |
528 | 528 |
529 LayoutText* renderText = toLayoutText(m_current.object()); | 529 LayoutText* renderText = toLayoutText(m_current.object()); |
530 | 530 |
531 bool isSVGText = renderText->isSVGInlineText(); | 531 bool isSVGText = renderText->isSVGInlineText(); |
532 | 532 |
533 // If we have left a no-wrap inline and entered an autowrap inline while ign
oring spaces | 533 // If we have left a no-wrap inline and entered an autowrap inline while ign
oring spaces |
534 // then we need to mark the start of the autowrap inline as a potential line
break now. | 534 // then we need to mark the start of the autowrap inline as a potential line
break now. |
535 if (m_autoWrap && !LayoutStyle::autoWrap(m_lastWS) && m_ignoringSpaces) { | 535 if (m_autoWrap && !ComputedStyle::autoWrap(m_lastWS) && m_ignoringSpaces) { |
536 m_width.commit(); | 536 m_width.commit(); |
537 m_lineBreak.moveToStartOf(m_current.object()); | 537 m_lineBreak.moveToStartOf(m_current.object()); |
538 } | 538 } |
539 | 539 |
540 const LayoutStyle& style = renderText->styleRef(m_lineInfo.isFirstLine()); | 540 const ComputedStyle& style = renderText->styleRef(m_lineInfo.isFirstLine()); |
541 const Font& font = style.font(); | 541 const Font& font = style.font(); |
542 bool isFixedPitch = font.isFixedPitch(); | 542 bool isFixedPitch = font.isFixedPitch(); |
543 | 543 |
544 unsigned lastSpace = m_current.offset(); | 544 unsigned lastSpace = m_current.offset(); |
545 float wordSpacing = m_currentStyle->wordSpacing(); | 545 float wordSpacing = m_currentStyle->wordSpacing(); |
546 float lastSpaceWordSpacing = 0; | 546 float lastSpaceWordSpacing = 0; |
547 float wordSpacingForWordMeasurement = 0; | 547 float wordSpacingForWordMeasurement = 0; |
548 | 548 |
549 float wrapW = m_width.uncommittedWidth() + inlineLogicalWidth(m_current.obje
ct(), !m_appliedStartWidth, true); | 549 float wrapW = m_width.uncommittedWidth() + inlineLogicalWidth(m_current.obje
ct(), !m_appliedStartWidth, true); |
550 float charWidth = 0; | 550 float charWidth = 0; |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 | 876 |
877 if (!m_current.object()->isFloatingOrOutOfFlowPositioned()) { | 877 if (!m_current.object()->isFloatingOrOutOfFlowPositioned()) { |
878 m_lastObject = m_current.object(); | 878 m_lastObject = m_current.object(); |
879 if (m_lastObject->isReplaced() && m_autoWrap && (!m_lastObject->isImage(
) || m_allowImagesToBreak) && (!m_lastObject->isListMarker() || toLayoutListMark
er(m_lastObject)->isInside())) { | 879 if (m_lastObject->isReplaced() && m_autoWrap && (!m_lastObject->isImage(
) || m_allowImagesToBreak) && (!m_lastObject->isListMarker() || toLayoutListMark
er(m_lastObject)->isInside())) { |
880 m_width.commit(); | 880 m_width.commit(); |
881 m_lineBreak.moveToStartOf(m_nextObject); | 881 m_lineBreak.moveToStartOf(m_nextObject); |
882 } | 882 } |
883 } | 883 } |
884 } | 884 } |
885 | 885 |
886 inline IndentTextOrNot requiresIndent(bool isFirstLine, bool isAfterHardLineBrea
k, const LayoutStyle& style) | 886 inline IndentTextOrNot requiresIndent(bool isFirstLine, bool isAfterHardLineBrea
k, const ComputedStyle& style) |
887 { | 887 { |
888 IndentTextOrNot shouldIndentText = DoNotIndentText; | 888 IndentTextOrNot shouldIndentText = DoNotIndentText; |
889 if (isFirstLine || (isAfterHardLineBreak && style.textIndentLine()) == TextI
ndentEachLine) | 889 if (isFirstLine || (isAfterHardLineBreak && style.textIndentLine()) == TextI
ndentEachLine) |
890 shouldIndentText = IndentText; | 890 shouldIndentText = IndentText; |
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 |