Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: Source/core/rendering/RenderText.cpp

Issue 23618052: TextBreakIterator should use the C++ icu API instead of the C one (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Downcast to icu::RuleBasedBreakIterator Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 113 }
114 114
115 TextBreakIterator* boundary = wordBreakIterator(stringWithPrevious.character s(), length + 1); 115 TextBreakIterator* boundary = wordBreakIterator(stringWithPrevious.character s(), length + 1);
116 if (!boundary) 116 if (!boundary)
117 return; 117 return;
118 118
119 StringBuilder result; 119 StringBuilder result;
120 result.reserveCapacity(length); 120 result.reserveCapacity(length);
121 121
122 int32_t endOfWord; 122 int32_t endOfWord;
123 int32_t startOfWord = textBreakFirst(boundary); 123 int32_t startOfWord = boundary->first();
124 for (endOfWord = textBreakNext(boundary); endOfWord != TextBreakDone; startO fWord = endOfWord, endOfWord = textBreakNext(boundary)) { 124 for (endOfWord = boundary->next(); endOfWord != TextBreakDone; startOfWord = endOfWord, endOfWord = boundary->next()) {
125 if (startOfWord) // Ignore first char of previous string 125 if (startOfWord) // Ignore first char of previous string
126 result.append(input[startOfWord - 1] == noBreakSpace ? noBreakSpace : toTitleCase(stringWithPrevious[startOfWord])); 126 result.append(input[startOfWord - 1] == noBreakSpace ? noBreakSpace : toTitleCase(stringWithPrevious[startOfWord]));
127 for (int i = startOfWord + 1; i < endOfWord; i++) 127 for (int i = startOfWord + 1; i < endOfWord; i++)
128 result.append(input[i - 1]); 128 result.append(input[i - 1]);
129 } 129 }
130 130
131 *string = result.toString(); 131 *string = result.toString();
132 } 132 }
133 133
134 RenderText::RenderText(Node* node, PassRefPtr<StringImpl> str) 134 RenderText::RenderText(Node* node, PassRefPtr<StringImpl> str)
(...skipping 1522 matching lines...) Expand 10 before | Expand all | Expand 10 after
1657 int RenderText::previousOffset(int current) const 1657 int RenderText::previousOffset(int current) const
1658 { 1658 {
1659 if (isAllASCII() || m_text.is8Bit()) 1659 if (isAllASCII() || m_text.is8Bit())
1660 return current - 1; 1660 return current - 1;
1661 1661
1662 StringImpl* textImpl = m_text.impl(); 1662 StringImpl* textImpl = m_text.impl();
1663 TextBreakIterator* iterator = cursorMovementIterator(textImpl->characters16( ), textImpl->length()); 1663 TextBreakIterator* iterator = cursorMovementIterator(textImpl->characters16( ), textImpl->length());
1664 if (!iterator) 1664 if (!iterator)
1665 return current - 1; 1665 return current - 1;
1666 1666
1667 long result = textBreakPreceding(iterator, current); 1667 long result = iterator->preceding(current);
1668 if (result == TextBreakDone) 1668 if (result == TextBreakDone)
1669 result = current - 1; 1669 result = current - 1;
1670 1670
1671 1671
1672 return result; 1672 return result;
1673 } 1673 }
1674 1674
1675 #if OS(MACOSX) 1675 #if OS(MACOSX)
1676 1676
1677 #define HANGUL_CHOSEONG_START (0x1100) 1677 #define HANGUL_CHOSEONG_START (0x1100)
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1813 int RenderText::nextOffset(int current) const 1813 int RenderText::nextOffset(int current) const
1814 { 1814 {
1815 if (isAllASCII() || m_text.is8Bit()) 1815 if (isAllASCII() || m_text.is8Bit())
1816 return current + 1; 1816 return current + 1;
1817 1817
1818 StringImpl* textImpl = m_text.impl(); 1818 StringImpl* textImpl = m_text.impl();
1819 TextBreakIterator* iterator = cursorMovementIterator(textImpl->characters16( ), textImpl->length()); 1819 TextBreakIterator* iterator = cursorMovementIterator(textImpl->characters16( ), textImpl->length());
1820 if (!iterator) 1820 if (!iterator)
1821 return current + 1; 1821 return current + 1;
1822 1822
1823 long result = textBreakFollowing(iterator, current); 1823 long result = iterator->following(current);
1824 if (result == TextBreakDone) 1824 if (result == TextBreakDone)
1825 result = current + 1; 1825 result = current + 1;
1826 1826
1827 return result; 1827 return result;
1828 } 1828 }
1829 1829
1830 bool RenderText::computeCanUseSimpleFontCodePath() const 1830 bool RenderText::computeCanUseSimpleFontCodePath() const
1831 { 1831 {
1832 if (isAllASCII() || m_text.is8Bit()) 1832 if (isAllASCII() || m_text.is8Bit())
1833 return true; 1833 return true;
(...skipping 24 matching lines...) Expand all
1858 1858
1859 SecureTextTimer* secureTextTimer = gSecureTextTimers->get(this); 1859 SecureTextTimer* secureTextTimer = gSecureTextTimers->get(this);
1860 if (!secureTextTimer) { 1860 if (!secureTextTimer) {
1861 secureTextTimer = new SecureTextTimer(this); 1861 secureTextTimer = new SecureTextTimer(this);
1862 gSecureTextTimers->add(this, secureTextTimer); 1862 gSecureTextTimers->add(this, secureTextTimer);
1863 } 1863 }
1864 secureTextTimer->restartWithNewText(lastTypedCharacterOffset); 1864 secureTextTimer->restartWithNewText(lastTypedCharacterOffset);
1865 } 1865 }
1866 1866
1867 } // namespace WebCore 1867 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/platform/graphics/mac/ComplexTextController.cpp ('k') | Source/core/rendering/break_lines.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698