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 12 matching lines...) Expand all Loading... |
23 */ | 23 */ |
24 | 24 |
25 #include "config.h" | 25 #include "config.h" |
26 #include "core/rendering/RenderText.h" | 26 #include "core/rendering/RenderText.h" |
27 | 27 |
28 #include "core/accessibility/AXObjectCache.h" | 28 #include "core/accessibility/AXObjectCache.h" |
29 #include "core/dom/Text.h" | 29 #include "core/dom/Text.h" |
30 #include "core/fetch/TextResourceDecoder.h" | 30 #include "core/fetch/TextResourceDecoder.h" |
31 #include "core/frame/FrameView.h" | 31 #include "core/frame/FrameView.h" |
32 #include "core/page/Settings.h" | 32 #include "core/page/Settings.h" |
33 #include "core/platform/text/transcoder/FontTranscoder.h" | |
34 #include "core/rendering/EllipsisBox.h" | 33 #include "core/rendering/EllipsisBox.h" |
35 #include "core/rendering/InlineTextBox.h" | 34 #include "core/rendering/InlineTextBox.h" |
36 #include "core/rendering/RenderBlock.h" | 35 #include "core/rendering/RenderBlock.h" |
37 #include "core/rendering/RenderCombineText.h" | 36 #include "core/rendering/RenderCombineText.h" |
38 #include "core/rendering/RenderLayer.h" | 37 #include "core/rendering/RenderLayer.h" |
39 #include "core/rendering/RenderView.h" | 38 #include "core/rendering/RenderView.h" |
40 #include "core/rendering/break_lines.h" | 39 #include "core/rendering/break_lines.h" |
41 #include "platform/geometry/FloatQuad.h" | 40 #include "platform/geometry/FloatQuad.h" |
42 #include "platform/text/TextBreakIterator.h" | 41 #include "platform/text/TextBreakIterator.h" |
43 #include "wtf/text/StringBuffer.h" | 42 #include "wtf/text/StringBuffer.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 129 |
131 *string = result.toString(); | 130 *string = result.toString(); |
132 } | 131 } |
133 | 132 |
134 RenderText::RenderText(Node* node, PassRefPtr<StringImpl> str) | 133 RenderText::RenderText(Node* node, PassRefPtr<StringImpl> str) |
135 : RenderObject(!node || node->isDocumentNode() ? 0 : node) | 134 : RenderObject(!node || node->isDocumentNode() ? 0 : node) |
136 , m_hasTab(false) | 135 , m_hasTab(false) |
137 , m_linesDirty(false) | 136 , m_linesDirty(false) |
138 , m_containsReversedText(false) | 137 , m_containsReversedText(false) |
139 , m_knownToHaveNoOverflowAndNoFallbackFonts(false) | 138 , m_knownToHaveNoOverflowAndNoFallbackFonts(false) |
140 , m_needsTranscoding(false) | |
141 , m_minWidth(-1) | 139 , m_minWidth(-1) |
142 , m_maxWidth(-1) | 140 , m_maxWidth(-1) |
143 , m_firstLineMinWidth(0) | 141 , m_firstLineMinWidth(0) |
144 , m_lastLineLineMinWidth(0) | 142 , m_lastLineLineMinWidth(0) |
145 , m_text(str) | 143 , m_text(str) |
146 , m_firstTextBox(0) | 144 , m_firstTextBox(0) |
147 , m_lastTextBox(0) | 145 , m_lastTextBox(0) |
148 { | 146 { |
149 ASSERT(m_text); | 147 ASSERT(m_text); |
150 // FIXME: Some clients of RenderText (and subclasses) pass Document as node
to create anonymous renderer. | 148 // FIXME: Some clients of RenderText (and subclasses) pass Document as node
to create anonymous renderer. |
(...skipping 26 matching lines...) Expand all Loading... |
177 bool RenderText::isTextFragment() const | 175 bool RenderText::isTextFragment() const |
178 { | 176 { |
179 return false; | 177 return false; |
180 } | 178 } |
181 | 179 |
182 bool RenderText::isWordBreak() const | 180 bool RenderText::isWordBreak() const |
183 { | 181 { |
184 return false; | 182 return false; |
185 } | 183 } |
186 | 184 |
187 void RenderText::updateNeedsTranscoding() | |
188 { | |
189 const WTF::TextEncoding* encoding = document().decoder() ? &document().decod
er()->encoding() : 0; | |
190 m_needsTranscoding = fontTranscoder().needsTranscoding(style()->font().fontD
escription(), encoding); | |
191 } | |
192 | |
193 void RenderText::styleDidChange(StyleDifference diff, const RenderStyle* oldStyl
e) | 185 void RenderText::styleDidChange(StyleDifference diff, const RenderStyle* oldStyl
e) |
194 { | 186 { |
195 // There is no need to ever schedule repaints from a style change of a text
run, since | 187 // There is no need to ever schedule repaints from a style change of a text
run, since |
196 // we already did this for the parent of the text run. | 188 // we already did this for the parent of the text run. |
197 // We do have to schedule layouts, though, since a style change can force us
to | 189 // We do have to schedule layouts, though, since a style change can force us
to |
198 // need to relayout. | 190 // need to relayout. |
199 if (diff == StyleDifferenceLayout) { | 191 if (diff == StyleDifferenceLayout) { |
200 setNeedsLayoutAndPrefWidthsRecalc(); | 192 setNeedsLayoutAndPrefWidthsRecalc(); |
201 m_knownToHaveNoOverflowAndNoFallbackFonts = false; | 193 m_knownToHaveNoOverflowAndNoFallbackFonts = false; |
202 } | 194 } |
203 | 195 |
204 RenderStyle* newStyle = style(); | 196 RenderStyle* newStyle = style(); |
205 bool needsResetText = false; | |
206 if (!oldStyle) { | |
207 updateNeedsTranscoding(); | |
208 needsResetText = m_needsTranscoding; | |
209 } else if (oldStyle->font().needsTranscoding() != newStyle->font().needsTran
scoding() || (newStyle->font().needsTranscoding() && oldStyle->font().family().f
amily() != newStyle->font().family().family())) { | |
210 updateNeedsTranscoding(); | |
211 needsResetText = true; | |
212 } | |
213 | |
214 ETextTransform oldTransform = oldStyle ? oldStyle->textTransform() : TTNONE; | 197 ETextTransform oldTransform = oldStyle ? oldStyle->textTransform() : TTNONE; |
215 ETextSecurity oldSecurity = oldStyle ? oldStyle->textSecurity() : TSNONE; | 198 ETextSecurity oldSecurity = oldStyle ? oldStyle->textSecurity() : TSNONE; |
216 if (needsResetText || oldTransform != newStyle->textTransform() || oldSecuri
ty != newStyle->textSecurity()) | 199 if (oldTransform != newStyle->textTransform() || oldSecurity != newStyle->te
xtSecurity()) |
217 transformText(); | 200 transformText(); |
218 | 201 |
219 if (!text().containsOnlyWhitespace()) | 202 if (!text().containsOnlyWhitespace()) |
220 newStyle->font().willUseFontData(); | 203 newStyle->font().willUseFontData(); |
221 } | 204 } |
222 | 205 |
223 void RenderText::removeAndDestroyTextBoxes() | 206 void RenderText::removeAndDestroyTextBoxes() |
224 { | 207 { |
225 if (!documentBeingDestroyed()) { | 208 if (!documentBeingDestroyed()) { |
226 if (firstTextBox()) { | 209 if (firstTextBox()) { |
(...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1322 case LOWERCASE: | 1305 case LOWERCASE: |
1323 text = text.lower(style->locale()); | 1306 text = text.lower(style->locale()); |
1324 break; | 1307 break; |
1325 } | 1308 } |
1326 } | 1309 } |
1327 | 1310 |
1328 void RenderText::setTextInternal(PassRefPtr<StringImpl> text) | 1311 void RenderText::setTextInternal(PassRefPtr<StringImpl> text) |
1329 { | 1312 { |
1330 ASSERT(text); | 1313 ASSERT(text); |
1331 m_text = text; | 1314 m_text = text; |
1332 if (m_needsTranscoding) { | |
1333 const WTF::TextEncoding* encoding = document().decoder() ? &document().d
ecoder()->encoding() : 0; | |
1334 fontTranscoder().convert(m_text, style()->font().fontDescription(), enco
ding); | |
1335 } | |
1336 ASSERT(m_text); | |
1337 | 1315 |
1338 if (style()) { | 1316 if (style()) { |
1339 applyTextTransform(style(), m_text, previousCharacter()); | 1317 applyTextTransform(style(), m_text, previousCharacter()); |
1340 | 1318 |
1341 // We use the same characters here as for list markers. | 1319 // We use the same characters here as for list markers. |
1342 // See the listMarkerText function in RenderListMarker.cpp. | 1320 // See the listMarkerText function in RenderListMarker.cpp. |
1343 switch (style()->textSecurity()) { | 1321 switch (style()->textSecurity()) { |
1344 case TSNONE: | 1322 case TSNONE: |
1345 break; | 1323 break; |
1346 case TSCIRCLE: | 1324 case TSCIRCLE: |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1391 return; | 1369 return; |
1392 | 1370 |
1393 setTextInternal(text); | 1371 setTextInternal(text); |
1394 setNeedsLayoutAndPrefWidthsRecalc(); | 1372 setNeedsLayoutAndPrefWidthsRecalc(); |
1395 m_knownToHaveNoOverflowAndNoFallbackFonts = false; | 1373 m_knownToHaveNoOverflowAndNoFallbackFonts = false; |
1396 | 1374 |
1397 if (AXObjectCache* cache = document().existingAXObjectCache()) | 1375 if (AXObjectCache* cache = document().existingAXObjectCache()) |
1398 cache->textChanged(this); | 1376 cache->textChanged(this); |
1399 } | 1377 } |
1400 | 1378 |
1401 String RenderText::textWithoutTranscoding() const | |
1402 { | |
1403 // If m_text isn't transcoded or is secure, we can just return the modified
text. | |
1404 if (!m_needsTranscoding || style()->textSecurity() != TSNONE) | |
1405 return text(); | |
1406 | |
1407 // Otherwise, we should use original text. If text-transform is | |
1408 // specified, we should transform the text on the fly. | |
1409 String text = originalText(); | |
1410 applyTextTransform(style(), text, previousCharacter()); | |
1411 return text; | |
1412 } | |
1413 | |
1414 void RenderText::dirtyLineBoxes(bool fullLayout) | 1379 void RenderText::dirtyLineBoxes(bool fullLayout) |
1415 { | 1380 { |
1416 if (fullLayout) | 1381 if (fullLayout) |
1417 deleteTextBoxes(); | 1382 deleteTextBoxes(); |
1418 else if (!m_linesDirty) { | 1383 else if (!m_linesDirty) { |
1419 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) | 1384 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) |
1420 box->dirtyLineBoxes(); | 1385 box->dirtyLineBoxes(); |
1421 } | 1386 } |
1422 m_linesDirty = false; | 1387 m_linesDirty = false; |
1423 } | 1388 } |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1858 | 1823 |
1859 SecureTextTimer* secureTextTimer = gSecureTextTimers->get(this); | 1824 SecureTextTimer* secureTextTimer = gSecureTextTimers->get(this); |
1860 if (!secureTextTimer) { | 1825 if (!secureTextTimer) { |
1861 secureTextTimer = new SecureTextTimer(this); | 1826 secureTextTimer = new SecureTextTimer(this); |
1862 gSecureTextTimers->add(this, secureTextTimer); | 1827 gSecureTextTimers->add(this, secureTextTimer); |
1863 } | 1828 } |
1864 secureTextTimer->restartWithNewText(lastTypedCharacterOffset); | 1829 secureTextTimer->restartWithNewText(lastTypedCharacterOffset); |
1865 } | 1830 } |
1866 | 1831 |
1867 } // namespace WebCore | 1832 } // namespace WebCore |
OLD | NEW |