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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 uint32_t bitfields : 16; | 59 uint32_t bitfields : 16; |
60 float widths[4]; | 60 float widths[4]; |
61 String text; | 61 String text; |
62 void* pointers[2]; | 62 void* pointers[2]; |
63 }; | 63 }; |
64 | 64 |
65 static_assert(sizeof(LayoutText) == sizeof(SameSizeAsLayoutText), "LayoutText sh
ould stay small"); | 65 static_assert(sizeof(LayoutText) == sizeof(SameSizeAsLayoutText), "LayoutText sh
ould stay small"); |
66 | 66 |
67 class SecureTextTimer; | 67 class SecureTextTimer; |
68 typedef HashMap<LayoutText*, SecureTextTimer*> SecureTextTimerMap; | 68 typedef HashMap<LayoutText*, SecureTextTimer*> SecureTextTimerMap; |
69 static SecureTextTimerMap* gSecureTextTimers = 0; | 69 static SecureTextTimerMap* gSecureTextTimers = nullptr; |
70 | 70 |
71 class SecureTextTimer final : public TimerBase { | 71 class SecureTextTimer final : public TimerBase { |
72 public: | 72 public: |
73 SecureTextTimer(LayoutText* layoutText) | 73 SecureTextTimer(LayoutText* layoutText) |
74 : m_layoutText(layoutText) | 74 : m_layoutText(layoutText) |
75 , m_lastTypedCharacterOffset(-1) | 75 , m_lastTypedCharacterOffset(-1) |
76 { | 76 { |
77 } | 77 } |
78 | 78 |
79 void restartWithNewText(unsigned lastTypedCharacterOffset) | 79 void restartWithNewText(unsigned lastTypedCharacterOffset) |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 : LayoutObject(!node || node->isDocumentNode() ? 0 : node) | 140 : LayoutObject(!node || node->isDocumentNode() ? 0 : node) |
141 , m_hasTab(false) | 141 , m_hasTab(false) |
142 , m_linesDirty(false) | 142 , m_linesDirty(false) |
143 , m_containsReversedText(false) | 143 , m_containsReversedText(false) |
144 , m_knownToHaveNoOverflowAndNoFallbackFonts(false) | 144 , m_knownToHaveNoOverflowAndNoFallbackFonts(false) |
145 , m_minWidth(-1) | 145 , m_minWidth(-1) |
146 , m_maxWidth(-1) | 146 , m_maxWidth(-1) |
147 , m_firstLineMinWidth(0) | 147 , m_firstLineMinWidth(0) |
148 , m_lastLineLineMinWidth(0) | 148 , m_lastLineLineMinWidth(0) |
149 , m_text(str) | 149 , m_text(str) |
150 , m_firstTextBox(0) | 150 , m_firstTextBox(nullptr) |
151 , m_lastTextBox(0) | 151 , m_lastTextBox(nullptr) |
152 { | 152 { |
153 ASSERT(m_text); | 153 ASSERT(m_text); |
154 // FIXME: Some clients of LayoutText (and subclasses) pass Document as node
to create anonymous layoutObject. | 154 // FIXME: Some clients of LayoutText (and subclasses) pass Document as node
to create anonymous layoutObject. |
155 // They should be switched to passing null and using setDocumentForAnonymous
. | 155 // They should be switched to passing null and using setDocumentForAnonymous
. |
156 if (node && node->isDocumentNode()) | 156 if (node && node->isDocumentNode()) |
157 setDocumentForAnonymous(toDocument(node)); | 157 setDocumentForAnonymous(toDocument(node)); |
158 | 158 |
159 m_canUseSimpleFontCodePath = computeCanUseSimpleFontCodePath(); | 159 m_canUseSimpleFontCodePath = computeCanUseSimpleFontCodePath(); |
160 setIsText(); | 160 setIsText(); |
161 | 161 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 removeAndDestroyTextBoxes(); | 232 removeAndDestroyTextBoxes(); |
233 LayoutObject::willBeDestroyed(); | 233 LayoutObject::willBeDestroyed(); |
234 } | 234 } |
235 | 235 |
236 void LayoutText::extractTextBox(InlineTextBox* box) | 236 void LayoutText::extractTextBox(InlineTextBox* box) |
237 { | 237 { |
238 checkConsistency(); | 238 checkConsistency(); |
239 | 239 |
240 m_lastTextBox = box->prevTextBox(); | 240 m_lastTextBox = box->prevTextBox(); |
241 if (box == m_firstTextBox) | 241 if (box == m_firstTextBox) |
242 m_firstTextBox = 0; | 242 m_firstTextBox = nullptr; |
243 if (box->prevTextBox()) | 243 if (box->prevTextBox()) |
244 box->prevTextBox()->setNextTextBox(0); | 244 box->prevTextBox()->setNextTextBox(nullptr); |
245 box->setPreviousTextBox(0); | 245 box->setPreviousTextBox(nullptr); |
246 for (InlineTextBox* curr = box; curr; curr = curr->nextTextBox()) | 246 for (InlineTextBox* curr = box; curr; curr = curr->nextTextBox()) |
247 curr->setExtracted(); | 247 curr->setExtracted(); |
248 | 248 |
249 checkConsistency(); | 249 checkConsistency(); |
250 } | 250 } |
251 | 251 |
252 void LayoutText::attachTextBox(InlineTextBox* box) | 252 void LayoutText::attachTextBox(InlineTextBox* box) |
253 { | 253 { |
254 checkConsistency(); | 254 checkConsistency(); |
255 | 255 |
(...skipping 30 matching lines...) Expand all Loading... |
286 } | 286 } |
287 | 287 |
288 void LayoutText::deleteTextBoxes() | 288 void LayoutText::deleteTextBoxes() |
289 { | 289 { |
290 if (firstTextBox()) { | 290 if (firstTextBox()) { |
291 InlineTextBox* next; | 291 InlineTextBox* next; |
292 for (InlineTextBox* curr = firstTextBox(); curr; curr = next) { | 292 for (InlineTextBox* curr = firstTextBox(); curr; curr = next) { |
293 next = curr->nextTextBox(); | 293 next = curr->nextTextBox(); |
294 curr->destroy(); | 294 curr->destroy(); |
295 } | 295 } |
296 m_firstTextBox = m_lastTextBox = 0; | 296 m_firstTextBox = m_lastTextBox = nullptr; |
297 } | 297 } |
298 } | 298 } |
299 | 299 |
300 PassRefPtr<StringImpl> LayoutText::originalText() const | 300 PassRefPtr<StringImpl> LayoutText::originalText() const |
301 { | 301 { |
302 Node* e = node(); | 302 Node* e = node(); |
303 return (e && e->isTextNode()) ? toText(e)->dataImpl() : 0; | 303 return (e && e->isTextNode()) ? toText(e)->dataImpl() : 0; |
304 } | 304 } |
305 | 305 |
306 String LayoutText::plainText() const | 306 String LayoutText::plainText() const |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 | 594 |
595 PositionWithAffinity LayoutText::positionForPoint(const LayoutPoint& point) | 595 PositionWithAffinity LayoutText::positionForPoint(const LayoutPoint& point) |
596 { | 596 { |
597 if (!firstTextBox() || textLength() == 0) | 597 if (!firstTextBox() || textLength() == 0) |
598 return createPositionWithAffinity(0, DOWNSTREAM); | 598 return createPositionWithAffinity(0, DOWNSTREAM); |
599 | 599 |
600 LayoutUnit pointLineDirection = firstTextBox()->isHorizontal() ? point.x() :
point.y(); | 600 LayoutUnit pointLineDirection = firstTextBox()->isHorizontal() ? point.x() :
point.y(); |
601 LayoutUnit pointBlockDirection = firstTextBox()->isHorizontal() ? point.y()
: point.x(); | 601 LayoutUnit pointBlockDirection = firstTextBox()->isHorizontal() ? point.y()
: point.x(); |
602 bool blocksAreFlipped = style()->isFlippedBlocksWritingMode(); | 602 bool blocksAreFlipped = style()->isFlippedBlocksWritingMode(); |
603 | 603 |
604 InlineTextBox* lastBox = 0; | 604 InlineTextBox* lastBox = nullptr; |
605 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) { | 605 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) { |
606 if (box->isLineBreak() && !box->prevLeafChild() && box->nextLeafChild()
&& !box->nextLeafChild()->isLineBreak()) | 606 if (box->isLineBreak() && !box->prevLeafChild() && box->nextLeafChild()
&& !box->nextLeafChild()->isLineBreak()) |
607 box = box->nextTextBox(); | 607 box = box->nextTextBox(); |
608 | 608 |
609 RootInlineBox& rootBox = box->root(); | 609 RootInlineBox& rootBox = box->root(); |
610 LayoutUnit top = std::min(rootBox.selectionTop(), rootBox.lineTop()); | 610 LayoutUnit top = std::min(rootBox.selectionTop(), rootBox.lineTop()); |
611 if (pointBlockDirection > top || (!blocksAreFlipped && pointBlockDirecti
on == top)) { | 611 if (pointBlockDirection > top || (!blocksAreFlipped && pointBlockDirecti
on == top)) { |
612 LayoutUnit bottom = rootBox.selectionBottom(); | 612 LayoutUnit bottom = rootBox.selectionBottom(); |
613 if (rootBox.nextRootBox()) | 613 if (rootBox.nextRootBox()) |
614 bottom = std::min(bottom, rootBox.nextRootBox()->lineTop()); | 614 bottom = std::min(bottom, rootBox.nextRootBox()->lineTop()); |
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1201 void LayoutText::setTextWithOffset(PassRefPtr<StringImpl> text, unsigned offset,
unsigned len, bool force) | 1201 void LayoutText::setTextWithOffset(PassRefPtr<StringImpl> text, unsigned offset,
unsigned len, bool force) |
1202 { | 1202 { |
1203 if (!force && equal(m_text.impl(), text.get())) | 1203 if (!force && equal(m_text.impl(), text.get())) |
1204 return; | 1204 return; |
1205 | 1205 |
1206 unsigned oldLen = textLength(); | 1206 unsigned oldLen = textLength(); |
1207 unsigned newLen = text->length(); | 1207 unsigned newLen = text->length(); |
1208 int delta = newLen - oldLen; | 1208 int delta = newLen - oldLen; |
1209 unsigned end = len ? offset + len - 1 : offset; | 1209 unsigned end = len ? offset + len - 1 : offset; |
1210 | 1210 |
1211 RootInlineBox* firstRootBox = 0; | 1211 RootInlineBox* firstRootBox = nullptr; |
1212 RootInlineBox* lastRootBox = 0; | 1212 RootInlineBox* lastRootBox = nullptr; |
1213 | 1213 |
1214 bool dirtiedLines = false; | 1214 bool dirtiedLines = false; |
1215 | 1215 |
1216 // Dirty all text boxes that include characters in between offset and offset
+len. | 1216 // Dirty all text boxes that include characters in between offset and offset
+len. |
1217 for (InlineTextBox* curr = firstTextBox(); curr; curr = curr->nextTextBox())
{ | 1217 for (InlineTextBox* curr = firstTextBox(); curr; curr = curr->nextTextBox())
{ |
1218 // FIXME: This shouldn't rely on the end of a dirty line box. See https:
//bugs.webkit.org/show_bug.cgi?id=97264 | 1218 // FIXME: This shouldn't rely on the end of a dirty line box. See https:
//bugs.webkit.org/show_bug.cgi?id=97264 |
1219 // Text run is entirely before the affected range. | 1219 // Text run is entirely before the affected range. |
1220 if (curr->end() < offset) | 1220 if (curr->end() < offset) |
1221 continue; | 1221 continue; |
1222 | 1222 |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1820 if (m_text.is8Bit()) | 1820 if (m_text.is8Bit()) |
1821 return true; | 1821 return true; |
1822 return Character::characterRangeCodePath(characters16(), length()) == Simple
Path; | 1822 return Character::characterRangeCodePath(characters16(), length()) == Simple
Path; |
1823 } | 1823 } |
1824 | 1824 |
1825 #if ENABLE(ASSERT) | 1825 #if ENABLE(ASSERT) |
1826 | 1826 |
1827 void LayoutText::checkConsistency() const | 1827 void LayoutText::checkConsistency() const |
1828 { | 1828 { |
1829 #ifdef CHECK_CONSISTENCY | 1829 #ifdef CHECK_CONSISTENCY |
1830 const InlineTextBox* prev = 0; | 1830 const InlineTextBox* prev = nullptr; |
1831 for (const InlineTextBox* child = m_firstTextBox; child != 0; child = child-
>nextTextBox()) { | 1831 for (const InlineTextBox* child = m_firstTextBox; child; child = child->next
TextBox()) { |
1832 ASSERT(child->layoutObject() == this); | 1832 ASSERT(child->layoutObject() == this); |
1833 ASSERT(child->prevTextBox() == prev); | 1833 ASSERT(child->prevTextBox() == prev); |
1834 prev = child; | 1834 prev = child; |
1835 } | 1835 } |
1836 ASSERT(prev == m_lastTextBox); | 1836 ASSERT(prev == m_lastTextBox); |
1837 #endif | 1837 #endif |
1838 } | 1838 } |
1839 | 1839 |
1840 #endif | 1840 #endif |
1841 | 1841 |
(...skipping 16 matching lines...) Expand all Loading... |
1858 } | 1858 } |
1859 | 1859 |
1860 void LayoutText::invalidateDisplayItemClients(const LayoutBoxModelObject& paintI
nvalidationContainer) const | 1860 void LayoutText::invalidateDisplayItemClients(const LayoutBoxModelObject& paintI
nvalidationContainer) const |
1861 { | 1861 { |
1862 LayoutObject::invalidateDisplayItemClients(paintInvalidationContainer); | 1862 LayoutObject::invalidateDisplayItemClients(paintInvalidationContainer); |
1863 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) | 1863 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) |
1864 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*box); | 1864 paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*box); |
1865 } | 1865 } |
1866 | 1866 |
1867 } // namespace blink | 1867 } // namespace blink |
OLD | NEW |