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 2893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2904 wordMeasurement.endOffset = lBreak.m_pos; | 2904 wordMeasurement.endOffset = lBreak.m_pos; |
2905 } | 2905 } |
2906 if (lBreak.m_obj && lBreak.m_pos && lBreak.m_obj->is
Text() && toRenderText(lBreak.m_obj)->textLength() && toRenderText(lBreak.m_obj)
->characterAt(lBreak.m_pos - 1) == softHyphen && style->hyphens() != HyphensNone
) | 2906 if (lBreak.m_obj && lBreak.m_pos && lBreak.m_obj->is
Text() && toRenderText(lBreak.m_obj)->textLength() && toRenderText(lBreak.m_obj)
->characterAt(lBreak.m_pos - 1) == softHyphen && style->hyphens() != HyphensNone
) |
2907 m_hyphenated = true; | 2907 m_hyphenated = true; |
2908 if (lBreak.m_pos && lBreak.m_pos != (unsigned)wordMe
asurement.endOffset && !wordMeasurement.width) { | 2908 if (lBreak.m_pos && lBreak.m_pos != (unsigned)wordMe
asurement.endOffset && !wordMeasurement.width) { |
2909 if (charWidth) { | 2909 if (charWidth) { |
2910 wordMeasurement.endOffset = lBreak.m_pos; | 2910 wordMeasurement.endOffset = lBreak.m_pos; |
2911 wordMeasurement.width = charWidth; | 2911 wordMeasurement.width = charWidth; |
2912 } | 2912 } |
2913 } | 2913 } |
2914 goto end; // Didn't fit. Jump to the end. | 2914 // Didn't fit. Jump to the end unless there's still
an opportunity to collapse whitespace. |
| 2915 if (ignoringSpaces || !currentStyle->collapseWhiteSp
ace() || !currentCharacterIsSpace || !previousCharacterIsSpace) |
| 2916 goto end; |
2915 } else { | 2917 } else { |
2916 if (!betweenWords || (midWordBreak && !autoWrap)) | 2918 if (!betweenWords || (midWordBreak && !autoWrap)) |
2917 width.addUncommittedWidth(-additionalTmpW); | 2919 width.addUncommittedWidth(-additionalTmpW); |
2918 if (hyphenWidth) { | 2920 if (hyphenWidth) { |
2919 // Subtract the width of the soft hyphen out sin
ce we fit on a line. | 2921 // Subtract the width of the soft hyphen out sin
ce we fit on a line. |
2920 width.addUncommittedWidth(-hyphenWidth); | 2922 width.addUncommittedWidth(-hyphenWidth); |
2921 hyphenWidth = 0; | 2923 hyphenWidth = 0; |
2922 } | 2924 } |
2923 } | 2925 } |
2924 } | 2926 } |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3031 | 3033 |
3032 if (m_hyphenated) | 3034 if (m_hyphenated) |
3033 goto end; | 3035 goto end; |
3034 } | 3036 } |
3035 } else | 3037 } else |
3036 ASSERT_NOT_REACHED(); | 3038 ASSERT_NOT_REACHED(); |
3037 | 3039 |
3038 bool checkForBreak = autoWrap || blockStyle->autoWrap(); | 3040 bool checkForBreak = autoWrap || blockStyle->autoWrap(); |
3039 if (width.committedWidth() && !width.fitsOnLine() && lBreak.m_obj && cur
rWS == NOWRAP) | 3041 if (width.committedWidth() && !width.fitsOnLine() && lBreak.m_obj && cur
rWS == NOWRAP) |
3040 checkForBreak = true; | 3042 checkForBreak = true; |
3041 else if (next && current.m_obj->isText() && next->isText() && !next->isB
R() && (autoWrap || (next->style()->autoWrap()))) { | 3043 else if (next && current.m_obj->isText() && next->isText() && !next->isB
R() && (autoWrap || next->style()->autoWrap())) { |
3042 if (currentCharacterIsSpace) | 3044 if (autoWrap && currentCharacterIsSpace) |
3043 checkForBreak = true; | 3045 checkForBreak = true; |
3044 else { | 3046 else { |
3045 RenderText* nextText = toRenderText(next); | 3047 RenderText* nextText = toRenderText(next); |
3046 if (nextText->textLength()) { | 3048 if (nextText->textLength()) { |
3047 UChar c = nextText->characterAt(0); | 3049 UChar c = nextText->characterAt(0); |
3048 checkForBreak = (c == ' ' || c == '\t' || (c == '\n' && !nex
t->preservesNewline())); | |
3049 // If the next item on the line is text, and if we did not e
nd with | 3050 // If the next item on the line is text, and if we did not e
nd with |
3050 // a space, then the next text run continues our word (and s
o it needs to | 3051 // a space, then the next text run continues our word (and s
o it needs to |
3051 // keep adding to |tmpW|. Just update and continue. | 3052 // keep adding to the uncommitted width. Just update and con
tinue. |
| 3053 checkForBreak = !currentCharacterIsSpace && (c == ' ' || c =
= '\t' || (c == '\n' && !next->preservesNewline())); |
3052 } else if (nextText->isWordBreak()) | 3054 } else if (nextText->isWordBreak()) |
3053 checkForBreak = true; | 3055 checkForBreak = true; |
3054 | 3056 |
3055 if (!width.fitsOnLine() && !width.committedWidth()) | 3057 if (!width.fitsOnLine() && !width.committedWidth()) |
3056 width.fitBelowFloats(); | 3058 width.fitBelowFloats(); |
3057 | 3059 |
3058 bool canPlaceOnLine = width.fitsOnLine() || !autoWrapWasEverTrue
OnLine; | 3060 bool canPlaceOnLine = width.fitsOnLine() || !autoWrapWasEverTrue
OnLine; |
3059 if (canPlaceOnLine && checkForBreak) { | 3061 if (canPlaceOnLine && checkForBreak) { |
3060 width.commit(); | 3062 width.commit(); |
3061 lBreak.moveToStartOf(next); | 3063 lBreak.moveToStartOf(next); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3096 current.moveToStartOf(next); | 3098 current.moveToStartOf(next); |
3097 atStart = false; | 3099 atStart = false; |
3098 } | 3100 } |
3099 | 3101 |
3100 if (width.fitsOnLine() || lastWS == NOWRAP) | 3102 if (width.fitsOnLine() || lastWS == NOWRAP) |
3101 lBreak.clear(); | 3103 lBreak.clear(); |
3102 | 3104 |
3103 end: | 3105 end: |
3104 if (lBreak == resolver.position() && (!lBreak.m_obj || !lBreak.m_obj->isBR()
)) { | 3106 if (lBreak == resolver.position() && (!lBreak.m_obj || !lBreak.m_obj->isBR()
)) { |
3105 // we just add as much as possible | 3107 // we just add as much as possible |
3106 if (blockStyle->whiteSpace() == PRE) { | 3108 if (blockStyle->whiteSpace() == PRE && !current.m_pos) { |
3107 // FIXME: Don't really understand this case. | 3109 lBreak.moveTo(last, last->isText() ? last->length() : 0); |
3108 if (current.m_pos) { | |
3109 // FIXME: This should call moveTo which would clear m_nextBreaka
blePosition | |
3110 // this code as-is is likely wrong. | |
3111 lBreak.m_obj = current.m_obj; | |
3112 lBreak.m_pos = current.m_pos - 1; | |
3113 } else | |
3114 lBreak.moveTo(last, last->isText() ? last->length() : 0); | |
3115 } else if (lBreak.m_obj) { | 3110 } else if (lBreak.m_obj) { |
3116 // Don't ever break in the middle of a word if we can help it. | 3111 // Don't ever break in the middle of a word if we can help it. |
3117 // There's no room at all. We just have to be on this line, | 3112 // There's no room at all. We just have to be on this line, |
3118 // even though we'll spill out. | 3113 // even though we'll spill out. |
3119 lBreak.moveTo(current.m_obj, current.m_pos); | 3114 lBreak.moveTo(current.m_obj, current.m_pos); |
3120 } | 3115 } |
3121 } | 3116 } |
3122 | 3117 |
3123 // FIXME Bug 100049: We do not need to consume input in a multi-segment line | 3118 // FIXME Bug 100049: We do not need to consume input in a multi-segment line |
3124 // unless no segment will. | 3119 // unless no segment will. |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3313 lineGridBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, ver
ticalPositionCache); | 3308 lineGridBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, ver
ticalPositionCache); |
3314 | 3309 |
3315 setLineGridBox(lineGridBox); | 3310 setLineGridBox(lineGridBox); |
3316 | 3311 |
3317 // FIXME: If any of the characteristics of the box change compared to the ol
d one, then we need to do a deep dirtying | 3312 // FIXME: If any of the characteristics of the box change compared to the ol
d one, then we need to do a deep dirtying |
3318 // (similar to what happens when the page height changes). Ideally, though,
we only do this if someone is actually snapping | 3313 // (similar to what happens when the page height changes). Ideally, though,
we only do this if someone is actually snapping |
3319 // to this grid. | 3314 // to this grid. |
3320 } | 3315 } |
3321 | 3316 |
3322 } | 3317 } |
OLD | NEW |