Chromium Code Reviews| 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 |
| 75 static inline void dirtyLineBoxesForRenderer(RenderObject* o, bool fullLayout) | 69 static inline void dirtyLineBoxesForRenderer(RenderObject* o, bool fullLayout) |
| 76 { | 70 { |
| 77 if (o->isText()) { | 71 if (o->isText()) { |
| 78 RenderText* renderText = toRenderText(o); | 72 RenderText* renderText = toRenderText(o); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 192 int runCount = bidiRuns.runCount() - lineInfo.runsFromLeadingWhitespace(); | 186 int runCount = bidiRuns.runCount() - lineInfo.runsFromLeadingWhitespace(); |
| 193 for (BidiRun* r = bidiRuns.firstRun(); r; r = r->next()) { | 187 for (BidiRun* r = bidiRuns.firstRun(); r; r = r->next()) { |
| 194 // Create a box for our object. | 188 // Create a box for our object. |
| 195 bool isOnlyRun = (runCount == 1); | 189 bool isOnlyRun = (runCount == 1); |
| 196 if (runCount == 2 && !r->m_object->isListMarker()) | 190 if (runCount == 2 && !r->m_object->isListMarker()) |
| 197 isOnlyRun = (!style()->isLeftToRightDirection() ? bidiRuns.lastRun() : bidiRuns.firstRun())->m_object->isListMarker(); | 191 isOnlyRun = (!style()->isLeftToRightDirection() ? bidiRuns.lastRun() : bidiRuns.firstRun())->m_object->isListMarker(); |
| 198 | 192 |
| 199 if (lineInfo.isEmpty()) | 193 if (lineInfo.isEmpty()) |
| 200 continue; | 194 continue; |
| 201 | 195 |
| 202 InlineBox* box = createInlineBoxForRenderer(r->m_object, false, isOnlyRu n); | 196 InlineBox* box; |
| 197 if (r->m_object->isText()) { | |
| 198 RenderText* text = toRenderText(r->m_object); | |
|
f(malita)
2014/10/06 15:18:23
Let's use a helper for this block too (createInlin
jbroman
2014/10/06 19:08:48
Done.
| |
| 199 InlineTextBox* textBox = text->createInlineTextBox(r->m_start, r->m_ stop - r->m_start); | |
| 200 // We only treat a box as text for a <br> if we are on a line by our self or in strict mode | |
| 201 // (Note the use of strict mode. In "almost strict" mode, we don't treat the box for <br> as text.) | |
| 202 if (r->m_object->isBR()) | |
| 203 textBox->setIsText(isOnlyRun || text->document().inNoQuirksMode( )); | |
| 204 textBox->setDirOverride(r->dirOverride(text->style()->rtlOrdering() == VisualOrder)); | |
| 205 if (r->m_hasHyphen) | |
| 206 textBox->setHasHyphen(true); | |
| 207 | |
| 208 box = textBox; | |
| 209 } else { | |
| 210 box = createInlineBoxForRenderer(r->m_object, false, isOnlyRun); | |
| 211 } | |
| 203 r->m_box = box; | 212 r->m_box = box; |
| 204 | 213 |
| 205 ASSERT(box); | 214 ASSERT(box); |
| 206 if (!box) | 215 if (!box) |
| 207 continue; | 216 continue; |
| 208 | 217 |
| 209 if (!rootHasSelectedChildren && box->renderer().selectionState() != Rend erObject::SelectionNone) | 218 if (!rootHasSelectedChildren && box->renderer().selectionState() != Rend erObject::SelectionNone) |
| 210 rootHasSelectedChildren = true; | 219 rootHasSelectedChildren = true; |
| 211 | 220 |
| 212 // If we have no parent box yet, or if the run is not simply a sibling, | 221 // 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 | 222 // 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 | 223 // run's inline box. Segments can only be siblings at the root level, as |
| 215 // they are positioned separately. | 224 // they are positioned separately. |
| 216 if (!parentBox || parentBox->renderer() != r->m_object->parent()) { | 225 if (!parentBox || parentBox->renderer() != r->m_object->parent()) { |
| 217 // Create new inline boxes all the way back to the appropriate inser tion point. | 226 // Create new inline boxes all the way back to the appropriate inser tion point. |
| 218 parentBox = createLineBoxes(r->m_object->parent(), lineInfo, box); | 227 parentBox = createLineBoxes(r->m_object->parent(), lineInfo, box); |
| 219 } else { | 228 } else { |
| 220 // Append the inline box to this line. | 229 // Append the inline box to this line. |
| 221 parentBox->addToLine(box); | 230 parentBox->addToLine(box); |
| 222 } | 231 } |
| 223 | 232 |
| 224 bool visuallyOrdered = r->m_object->style()->rtlOrdering() == VisualOrde r; | |
| 225 box->setBidiLevel(r->level()); | 233 box->setBidiLevel(r->level()); |
| 226 | 234 |
| 227 if (box->isInlineTextBox()) { | 235 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()) | 236 if (AXObjectCache* cache = document().existingAXObjectCache()) |
| 236 cache->inlineTextBoxesUpdated(r->m_object); | 237 cache->inlineTextBoxesUpdated(r->m_object); |
| 237 } | 238 } |
| 238 } | 239 } |
| 239 | 240 |
| 240 // We should have a root inline box. It should be unconstructed and | 241 // We should have a root inline box. It should be unconstructed and |
| 241 // be the last continuation of our line list. | 242 // be the last continuation of our line list. |
| 242 ASSERT(lastLineBox() && !lastLineBox()->isConstructed()); | 243 ASSERT(lastLineBox() && !lastLineBox()->isConstructed()); |
| 243 | 244 |
| 244 // Set the m_selectedChildren flag on the root inline box if one of the leaf inline box | 245 // 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 (); | 2038 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat (); |
| 2038 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal se) - logicalLeft; | 2039 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal se) - logicalLeft; |
| 2039 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); | 2040 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); |
| 2040 | 2041 |
| 2041 if (!style()->isLeftToRightDirection()) | 2042 if (!style()->isLeftToRightDirection()) |
| 2042 return logicalWidth() - logicalLeft; | 2043 return logicalWidth() - logicalLeft; |
| 2043 return logicalLeft; | 2044 return logicalLeft; |
| 2044 } | 2045 } |
| 2045 | 2046 |
| 2046 } | 2047 } |
| OLD | NEW |