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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 #include "wtf/StdLibExtras.h" | 47 #include "wtf/StdLibExtras.h" |
48 #include "wtf/Vector.h" | 48 #include "wtf/Vector.h" |
49 #include "wtf/unicode/CharacterNames.h" | 49 #include "wtf/unicode/CharacterNames.h" |
50 | 50 |
51 namespace blink { | 51 namespace blink { |
52 | 52 |
53 using namespace WTF::Unicode; | 53 using namespace WTF::Unicode; |
54 | 54 |
55 static inline InlineBox* createInlineBoxForRenderer(RenderObject* obj, bool isRo
otLineBox, bool isOnlyRun = false) | 55 static inline InlineBox* createInlineBoxForRenderer(RenderObject* obj, bool isRo
otLineBox, bool isOnlyRun = false) |
56 { | 56 { |
| 57 // Callers should handle text themselves. |
| 58 ASSERT(!obj->isText()); |
| 59 |
57 if (isRootLineBox) | 60 if (isRootLineBox) |
58 return toRenderBlockFlow(obj)->createAndAppendRootInlineBox(); | 61 return toRenderBlockFlow(obj)->createAndAppendRootInlineBox(); |
59 | 62 |
60 if (obj->isText()) { | |
61 InlineTextBox* textBox = toRenderText(obj)->createInlineTextBox(); | |
62 // We only treat a box as text for a <br> if we are on a line by ourself
or in strict mode | |
63 // (Note the use of strict mode. In "almost strict" mode, we don't trea
t the box for <br> as text.) | |
64 if (obj->isBR()) | |
65 textBox->setIsText(isOnlyRun || obj->document().inNoQuirksMode()); | |
66 return textBox; | |
67 } | |
68 | |
69 if (obj->isBox()) | 63 if (obj->isBox()) |
70 return toRenderBox(obj)->createInlineBox(); | 64 return toRenderBox(obj)->createInlineBox(); |
71 | 65 |
72 return toRenderInline(obj)->createAndAppendInlineFlowBox(); | 66 return toRenderInline(obj)->createAndAppendInlineFlowBox(); |
73 } | 67 } |
74 | 68 |
| 69 static inline InlineTextBox* createInlineBoxForText(BidiRun& run, bool isOnlyRun
) |
| 70 { |
| 71 ASSERT(run.m_object->isText()); |
| 72 RenderText* text = toRenderText(run.m_object); |
| 73 InlineTextBox* textBox = text->createInlineTextBox(run.m_start, run.m_stop -
run.m_start); |
| 74 // We only treat a box as text for a <br> if we are on a line by ourself or
in strict mode |
| 75 // (Note the use of strict mode. In "almost strict" mode, we don't treat th
e box for <br> as text.) |
| 76 if (text->isBR()) |
| 77 textBox->setIsText(isOnlyRun || text->document().inNoQuirksMode()); |
| 78 textBox->setDirOverride(run.dirOverride(text->style()->rtlOrdering() == Visu
alOrder)); |
| 79 if (run.m_hasHyphen) |
| 80 textBox->setHasHyphen(true); |
| 81 return textBox; |
| 82 } |
| 83 |
75 static inline void dirtyLineBoxesForRenderer(RenderObject* o, bool fullLayout) | 84 static inline void dirtyLineBoxesForRenderer(RenderObject* o, bool fullLayout) |
76 { | 85 { |
77 if (o->isText()) { | 86 if (o->isText()) { |
78 RenderText* renderText = toRenderText(o); | 87 RenderText* renderText = toRenderText(o); |
79 renderText->dirtyLineBoxes(fullLayout); | 88 renderText->dirtyLineBoxes(fullLayout); |
80 } else | 89 } else |
81 toRenderInline(o)->dirtyLineBoxes(fullLayout); | 90 toRenderInline(o)->dirtyLineBoxes(fullLayout); |
82 } | 91 } |
83 | 92 |
84 static bool parentIsConstructedOrHaveNext(InlineFlowBox* parentBox) | 93 static bool parentIsConstructedOrHaveNext(InlineFlowBox* parentBox) |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 int runCount = bidiRuns.runCount() - lineInfo.runsFromLeadingWhitespace(); | 201 int runCount = bidiRuns.runCount() - lineInfo.runsFromLeadingWhitespace(); |
193 for (BidiRun* r = bidiRuns.firstRun(); r; r = r->next()) { | 202 for (BidiRun* r = bidiRuns.firstRun(); r; r = r->next()) { |
194 // Create a box for our object. | 203 // Create a box for our object. |
195 bool isOnlyRun = (runCount == 1); | 204 bool isOnlyRun = (runCount == 1); |
196 if (runCount == 2 && !r->m_object->isListMarker()) | 205 if (runCount == 2 && !r->m_object->isListMarker()) |
197 isOnlyRun = (!style()->isLeftToRightDirection() ? bidiRuns.lastRun()
: bidiRuns.firstRun())->m_object->isListMarker(); | 206 isOnlyRun = (!style()->isLeftToRightDirection() ? bidiRuns.lastRun()
: bidiRuns.firstRun())->m_object->isListMarker(); |
198 | 207 |
199 if (lineInfo.isEmpty()) | 208 if (lineInfo.isEmpty()) |
200 continue; | 209 continue; |
201 | 210 |
202 InlineBox* box = createInlineBoxForRenderer(r->m_object, false, isOnlyRu
n); | 211 InlineBox* box; |
| 212 if (r->m_object->isText()) |
| 213 box = createInlineBoxForText(*r, isOnlyRun); |
| 214 else |
| 215 box = createInlineBoxForRenderer(r->m_object, false, isOnlyRun); |
203 r->m_box = box; | 216 r->m_box = box; |
204 | 217 |
205 ASSERT(box); | 218 ASSERT(box); |
206 if (!box) | 219 if (!box) |
207 continue; | 220 continue; |
208 | 221 |
209 if (!rootHasSelectedChildren && box->renderer().selectionState() != Rend
erObject::SelectionNone) | 222 if (!rootHasSelectedChildren && box->renderer().selectionState() != Rend
erObject::SelectionNone) |
210 rootHasSelectedChildren = true; | 223 rootHasSelectedChildren = true; |
211 | 224 |
212 // If we have no parent box yet, or if the run is not simply a sibling, | 225 // If we have no parent box yet, or if the run is not simply a sibling, |
213 // then we need to construct inline boxes as necessary to properly enclo
se the | 226 // then we need to construct inline boxes as necessary to properly enclo
se the |
214 // run's inline box. Segments can only be siblings at the root level, as | 227 // run's inline box. Segments can only be siblings at the root level, as |
215 // they are positioned separately. | 228 // they are positioned separately. |
216 if (!parentBox || parentBox->renderer() != r->m_object->parent()) { | 229 if (!parentBox || parentBox->renderer() != r->m_object->parent()) { |
217 // Create new inline boxes all the way back to the appropriate inser
tion point. | 230 // Create new inline boxes all the way back to the appropriate inser
tion point. |
218 parentBox = createLineBoxes(r->m_object->parent(), lineInfo, box); | 231 parentBox = createLineBoxes(r->m_object->parent(), lineInfo, box); |
219 } else { | 232 } else { |
220 // Append the inline box to this line. | 233 // Append the inline box to this line. |
221 parentBox->addToLine(box); | 234 parentBox->addToLine(box); |
222 } | 235 } |
223 | 236 |
224 bool visuallyOrdered = r->m_object->style()->rtlOrdering() == VisualOrde
r; | |
225 box->setBidiLevel(r->level()); | 237 box->setBidiLevel(r->level()); |
226 | 238 |
227 if (box->isInlineTextBox()) { | 239 if (box->isInlineTextBox()) { |
228 InlineTextBox* text = toInlineTextBox(box); | |
229 text->setStart(r->m_start); | |
230 text->setLen(r->m_stop - r->m_start); | |
231 text->setDirOverride(r->dirOverride(visuallyOrdered)); | |
232 if (r->m_hasHyphen) | |
233 text->setHasHyphen(true); | |
234 | |
235 if (AXObjectCache* cache = document().existingAXObjectCache()) | 240 if (AXObjectCache* cache = document().existingAXObjectCache()) |
236 cache->inlineTextBoxesUpdated(r->m_object); | 241 cache->inlineTextBoxesUpdated(r->m_object); |
237 } | 242 } |
238 } | 243 } |
239 | 244 |
240 // We should have a root inline box. It should be unconstructed and | 245 // We should have a root inline box. It should be unconstructed and |
241 // be the last continuation of our line list. | 246 // be the last continuation of our line list. |
242 ASSERT(lastLineBox() && !lastLineBox()->isConstructed()); | 247 ASSERT(lastLineBox() && !lastLineBox()->isConstructed()); |
243 | 248 |
244 // Set the m_selectedChildren flag on the root inline box if one of the leaf
inline box | 249 // Set the m_selectedChildren flag on the root inline box if one of the leaf
inline box |
(...skipping 1792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2037 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat
(); | 2042 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat
(); |
2038 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal
se) - logicalLeft; | 2043 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal
se) - logicalLeft; |
2039 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid
th, availableLogicalWidth, 0); | 2044 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid
th, availableLogicalWidth, 0); |
2040 | 2045 |
2041 if (!style()->isLeftToRightDirection()) | 2046 if (!style()->isLeftToRightDirection()) |
2042 return logicalWidth() - logicalLeft; | 2047 return logicalWidth() - logicalLeft; |
2043 return logicalLeft; | 2048 return logicalLeft; |
2044 } | 2049 } |
2045 | 2050 |
2046 } | 2051 } |
OLD | NEW |