| OLD | NEW |
| 1 /* | 1 /* |
| 2 * (C) 1999 Lars Knoll (knoll@kde.org) | 2 * (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 2000 Dirk Mueller (mueller@kde.org) | 3 * (C) 2000 Dirk Mueller (mueller@kde.org) |
| 4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. |
| 5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) | 5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) |
| 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) | 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 #include "platform/text/TextRunIterator.h" | 49 #include "platform/text/TextRunIterator.h" |
| 50 #include "wtf/text/StringBuffer.h" | 50 #include "wtf/text/StringBuffer.h" |
| 51 #include "wtf/text/StringBuilder.h" | 51 #include "wtf/text/StringBuilder.h" |
| 52 #include "wtf/unicode/CharacterNames.h" | 52 #include "wtf/unicode/CharacterNames.h" |
| 53 | 53 |
| 54 using namespace WTF; | 54 using namespace WTF; |
| 55 using namespace Unicode; | 55 using namespace Unicode; |
| 56 | 56 |
| 57 namespace blink { | 57 namespace blink { |
| 58 | 58 |
| 59 struct SameSizeAsRenderText : public RenderObject { | 59 struct SameSizeAsRenderText : public LayoutObject { |
| 60 uint32_t bitfields : 16; | 60 uint32_t bitfields : 16; |
| 61 float widths[4]; | 61 float widths[4]; |
| 62 String text; | 62 String text; |
| 63 void* pointers[2]; | 63 void* pointers[2]; |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 static_assert(sizeof(RenderText) == sizeof(SameSizeAsRenderText), "RenderText sh
ould stay small"); | 66 static_assert(sizeof(RenderText) == sizeof(SameSizeAsRenderText), "RenderText sh
ould stay small"); |
| 67 | 67 |
| 68 class SecureTextTimer; | 68 class SecureTextTimer; |
| 69 typedef HashMap<RenderText*, SecureTextTimer*> SecureTextTimerMap; | 69 typedef HashMap<RenderText*, SecureTextTimer*> SecureTextTimerMap; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 if (startOfWord) // Ignore first char of previous string | 131 if (startOfWord) // Ignore first char of previous string |
| 132 result.append(input[startOfWord - 1] == noBreakSpace ? noBreakSpace
: toTitleCase(stringWithPrevious[startOfWord])); | 132 result.append(input[startOfWord - 1] == noBreakSpace ? noBreakSpace
: toTitleCase(stringWithPrevious[startOfWord])); |
| 133 for (int i = startOfWord + 1; i < endOfWord; i++) | 133 for (int i = startOfWord + 1; i < endOfWord; i++) |
| 134 result.append(input[i - 1]); | 134 result.append(input[i - 1]); |
| 135 } | 135 } |
| 136 | 136 |
| 137 *string = result.toString(); | 137 *string = result.toString(); |
| 138 } | 138 } |
| 139 | 139 |
| 140 RenderText::RenderText(Node* node, PassRefPtr<StringImpl> str) | 140 RenderText::RenderText(Node* node, PassRefPtr<StringImpl> str) |
| 141 : RenderObject(!node || node->isDocumentNode() ? 0 : node) | 141 : LayoutObject(!node || node->isDocumentNode() ? 0 : node) |
| 142 , m_hasTab(false) | 142 , m_hasTab(false) |
| 143 , m_linesDirty(false) | 143 , m_linesDirty(false) |
| 144 , m_containsReversedText(false) | 144 , m_containsReversedText(false) |
| 145 , m_knownToHaveNoOverflowAndNoFallbackFonts(false) | 145 , m_knownToHaveNoOverflowAndNoFallbackFonts(false) |
| 146 , m_minWidth(-1) | 146 , m_minWidth(-1) |
| 147 , m_maxWidth(-1) | 147 , m_maxWidth(-1) |
| 148 , m_firstLineMinWidth(0) | 148 , m_firstLineMinWidth(0) |
| 149 , m_lastLineLineMinWidth(0) | 149 , m_lastLineLineMinWidth(0) |
| 150 , m_text(str) | 150 , m_text(str) |
| 151 , m_firstTextBox(0) | 151 , m_firstTextBox(0) |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 } | 229 } |
| 230 deleteTextBoxes(); | 230 deleteTextBoxes(); |
| 231 } | 231 } |
| 232 | 232 |
| 233 void RenderText::willBeDestroyed() | 233 void RenderText::willBeDestroyed() |
| 234 { | 234 { |
| 235 if (SecureTextTimer* secureTextTimer = gSecureTextTimers ? gSecureTextTimers
->take(this) : 0) | 235 if (SecureTextTimer* secureTextTimer = gSecureTextTimers ? gSecureTextTimers
->take(this) : 0) |
| 236 delete secureTextTimer; | 236 delete secureTextTimer; |
| 237 | 237 |
| 238 removeAndDestroyTextBoxes(); | 238 removeAndDestroyTextBoxes(); |
| 239 RenderObject::willBeDestroyed(); | 239 LayoutObject::willBeDestroyed(); |
| 240 } | 240 } |
| 241 | 241 |
| 242 void RenderText::extractTextBox(InlineTextBox* box) | 242 void RenderText::extractTextBox(InlineTextBox* box) |
| 243 { | 243 { |
| 244 checkConsistency(); | 244 checkConsistency(); |
| 245 | 245 |
| 246 m_lastTextBox = box->prevTextBox(); | 246 m_lastTextBox = box->prevTextBox(); |
| 247 if (box == m_firstTextBox) | 247 if (box == m_firstTextBox) |
| 248 m_firstTextBox = 0; | 248 m_firstTextBox = 0; |
| 249 if (box->prevTextBox()) | 249 if (box->prevTextBox()) |
| (...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1191 return m_firstTextBox ? m_firstTextBox->x().toFloat() : 0; | 1191 return m_firstTextBox ? m_firstTextBox->x().toFloat() : 0; |
| 1192 } | 1192 } |
| 1193 | 1193 |
| 1194 float RenderText::firstRunY() const | 1194 float RenderText::firstRunY() const |
| 1195 { | 1195 { |
| 1196 return m_firstTextBox ? m_firstTextBox->y().toFloat() : 0; | 1196 return m_firstTextBox ? m_firstTextBox->y().toFloat() : 0; |
| 1197 } | 1197 } |
| 1198 | 1198 |
| 1199 void RenderText::setSelectionState(SelectionState state) | 1199 void RenderText::setSelectionState(SelectionState state) |
| 1200 { | 1200 { |
| 1201 RenderObject::setSelectionState(state); | 1201 LayoutObject::setSelectionState(state); |
| 1202 | 1202 |
| 1203 if (canUpdateSelectionOnRootLineBoxes()) { | 1203 if (canUpdateSelectionOnRootLineBoxes()) { |
| 1204 if (state == SelectionStart || state == SelectionEnd || state == Selecti
onBoth) { | 1204 if (state == SelectionStart || state == SelectionEnd || state == Selecti
onBoth) { |
| 1205 int startPos, endPos; | 1205 int startPos, endPos; |
| 1206 selectionStartEnd(startPos, endPos); | 1206 selectionStartEnd(startPos, endPos); |
| 1207 if (selectionState() == SelectionStart) { | 1207 if (selectionState() == SelectionStart) { |
| 1208 endPos = textLength(); | 1208 endPos = textLength(); |
| 1209 | 1209 |
| 1210 // to handle selection from end of text to end of line | 1210 // to handle selection from end of text to end of line |
| 1211 if (startPos && startPos == endPos) | 1211 if (startPos && startPos == endPos) |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1308 m_linesDirty = dirtiedLines; | 1308 m_linesDirty = dirtiedLines; |
| 1309 setText(text, force || dirtiedLines); | 1309 setText(text, force || dirtiedLines); |
| 1310 } | 1310 } |
| 1311 | 1311 |
| 1312 void RenderText::transformText() | 1312 void RenderText::transformText() |
| 1313 { | 1313 { |
| 1314 if (RefPtr<StringImpl> textToTransform = originalText()) | 1314 if (RefPtr<StringImpl> textToTransform = originalText()) |
| 1315 setText(textToTransform.release(), true); | 1315 setText(textToTransform.release(), true); |
| 1316 } | 1316 } |
| 1317 | 1317 |
| 1318 static inline bool isInlineFlowOrEmptyText(const RenderObject* o) | 1318 static inline bool isInlineFlowOrEmptyText(const LayoutObject* o) |
| 1319 { | 1319 { |
| 1320 if (o->isRenderInline()) | 1320 if (o->isRenderInline()) |
| 1321 return true; | 1321 return true; |
| 1322 if (!o->isText()) | 1322 if (!o->isText()) |
| 1323 return false; | 1323 return false; |
| 1324 return toRenderText(o)->text().isEmpty(); | 1324 return toRenderText(o)->text().isEmpty(); |
| 1325 } | 1325 } |
| 1326 | 1326 |
| 1327 UChar RenderText::previousCharacter() const | 1327 UChar RenderText::previousCharacter() const |
| 1328 { | 1328 { |
| 1329 // find previous text renderer if one exists | 1329 // find previous text renderer if one exists |
| 1330 const RenderObject* previousText = previousInPreOrder(); | 1330 const LayoutObject* previousText = previousInPreOrder(); |
| 1331 for (; previousText; previousText = previousText->previousInPreOrder()) | 1331 for (; previousText; previousText = previousText->previousInPreOrder()) |
| 1332 if (!isInlineFlowOrEmptyText(previousText)) | 1332 if (!isInlineFlowOrEmptyText(previousText)) |
| 1333 break; | 1333 break; |
| 1334 UChar prev = space; | 1334 UChar prev = space; |
| 1335 if (previousText && previousText->isText()) | 1335 if (previousText && previousText->isText()) |
| 1336 if (StringImpl* previousString = toRenderText(previousText)->text().impl
()) | 1336 if (StringImpl* previousString = toRenderText(previousText)->text().impl
()) |
| 1337 prev = (*previousString)[previousString->length() - 1]; | 1337 prev = (*previousString)[previousString->length() - 1]; |
| 1338 return prev; | 1338 return prev; |
| 1339 } | 1339 } |
| 1340 | 1340 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1417 } | 1417 } |
| 1418 | 1418 |
| 1419 void RenderText::setText(PassRefPtr<StringImpl> text, bool force) | 1419 void RenderText::setText(PassRefPtr<StringImpl> text, bool force) |
| 1420 { | 1420 { |
| 1421 ASSERT(text); | 1421 ASSERT(text); |
| 1422 | 1422 |
| 1423 if (!force && equal(m_text.impl(), text.get())) | 1423 if (!force && equal(m_text.impl(), text.get())) |
| 1424 return; | 1424 return; |
| 1425 | 1425 |
| 1426 setTextInternal(text); | 1426 setTextInternal(text); |
| 1427 // If preferredLogicalWidthsDirty() of an orphan child is true, RenderObject
ChildList:: | 1427 // If preferredLogicalWidthsDirty() of an orphan child is true, LayoutObject
ChildList:: |
| 1428 // insertChildNode() fails to set true to owner. To avoid that, we call | 1428 // insertChildNode() fails to set true to owner. To avoid that, we call |
| 1429 // setNeedsLayoutAndPrefWidthsRecalc() only if this RenderText has parent. | 1429 // setNeedsLayoutAndPrefWidthsRecalc() only if this RenderText has parent. |
| 1430 if (parent()) | 1430 if (parent()) |
| 1431 setNeedsLayoutAndPrefWidthsRecalc(); | 1431 setNeedsLayoutAndPrefWidthsRecalc(); |
| 1432 m_knownToHaveNoOverflowAndNoFallbackFonts = false; | 1432 m_knownToHaveNoOverflowAndNoFallbackFonts = false; |
| 1433 | 1433 |
| 1434 if (AXObjectCache* cache = document().existingAXObjectCache()) | 1434 if (AXObjectCache* cache = document().existingAXObjectCache()) |
| 1435 cache->textChanged(this); | 1435 cache->textChanged(this); |
| 1436 } | 1436 } |
| 1437 | 1437 |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1883 secureTextTimer->restartWithNewText(lastTypedCharacterOffset); | 1883 secureTextTimer->restartWithNewText(lastTypedCharacterOffset); |
| 1884 } | 1884 } |
| 1885 | 1885 |
| 1886 PassRefPtr<AbstractInlineTextBox> RenderText::firstAbstractInlineTextBox() | 1886 PassRefPtr<AbstractInlineTextBox> RenderText::firstAbstractInlineTextBox() |
| 1887 { | 1887 { |
| 1888 return AbstractInlineTextBox::getOrCreate(this, m_firstTextBox); | 1888 return AbstractInlineTextBox::getOrCreate(this, m_firstTextBox); |
| 1889 } | 1889 } |
| 1890 | 1890 |
| 1891 void RenderText::invalidateDisplayItemClients(DisplayItemList* displayItemList)
const | 1891 void RenderText::invalidateDisplayItemClients(DisplayItemList* displayItemList)
const |
| 1892 { | 1892 { |
| 1893 RenderObject::invalidateDisplayItemClients(displayItemList); | 1893 LayoutObject::invalidateDisplayItemClients(displayItemList); |
| 1894 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) | 1894 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) |
| 1895 displayItemList->invalidate(box->displayItemClient()); | 1895 displayItemList->invalidate(box->displayItemClient()); |
| 1896 } | 1896 } |
| 1897 | 1897 |
| 1898 } // namespace blink | 1898 } // namespace blink |
| OLD | NEW |