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

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: Created 7 years, 3 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 1521 matching lines...) Expand 10 before | Expand all | Expand 10 after
1656 int RenderText::previousOffset(int current) const 1656 int RenderText::previousOffset(int current) const
1657 { 1657 {
1658 if (isAllASCII() || m_text.is8Bit()) 1658 if (isAllASCII() || m_text.is8Bit())
1659 return current - 1; 1659 return current - 1;
1660 1660
1661 StringImpl* textImpl = m_text.impl(); 1661 StringImpl* textImpl = m_text.impl();
1662 TextBreakIterator* iterator = cursorMovementIterator(textImpl->characters16( ), textImpl->length()); 1662 TextBreakIterator* iterator = cursorMovementIterator(textImpl->characters16( ), textImpl->length());
1663 if (!iterator) 1663 if (!iterator)
1664 return current - 1; 1664 return current - 1;
1665 1665
1666 long result = textBreakPreceding(iterator, current); 1666 long result = iterator->preceding(current);
1667 if (result == TextBreakDone) 1667 if (result == TextBreakDone)
1668 result = current - 1; 1668 result = current - 1;
1669 1669
1670 1670
1671 return result; 1671 return result;
1672 } 1672 }
1673 1673
1674 #if OS(MACOSX) 1674 #if OS(MACOSX)
1675 1675
1676 #define HANGUL_CHOSEONG_START (0x1100) 1676 #define HANGUL_CHOSEONG_START (0x1100)
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1812 int RenderText::nextOffset(int current) const 1812 int RenderText::nextOffset(int current) const
1813 { 1813 {
1814 if (isAllASCII() || m_text.is8Bit()) 1814 if (isAllASCII() || m_text.is8Bit())
1815 return current + 1; 1815 return current + 1;
1816 1816
1817 StringImpl* textImpl = m_text.impl(); 1817 StringImpl* textImpl = m_text.impl();
1818 TextBreakIterator* iterator = cursorMovementIterator(textImpl->characters16( ), textImpl->length()); 1818 TextBreakIterator* iterator = cursorMovementIterator(textImpl->characters16( ), textImpl->length());
1819 if (!iterator) 1819 if (!iterator)
1820 return current + 1; 1820 return current + 1;
1821 1821
1822 long result = textBreakFollowing(iterator, current); 1822 long result = iterator->following(current);
1823 if (result == TextBreakDone) 1823 if (result == TextBreakDone)
1824 result = current + 1; 1824 result = current + 1;
1825 1825
1826 return result; 1826 return result;
1827 } 1827 }
1828 1828
1829 bool RenderText::computeCanUseSimpleFontCodePath() const 1829 bool RenderText::computeCanUseSimpleFontCodePath() const
1830 { 1830 {
1831 if (isAllASCII() || m_text.is8Bit()) 1831 if (isAllASCII() || m_text.is8Bit())
1832 return true; 1832 return true;
(...skipping 24 matching lines...) Expand all
1857 1857
1858 SecureTextTimer* secureTextTimer = gSecureTextTimers->get(this); 1858 SecureTextTimer* secureTextTimer = gSecureTextTimers->get(this);
1859 if (!secureTextTimer) { 1859 if (!secureTextTimer) {
1860 secureTextTimer = new SecureTextTimer(this); 1860 secureTextTimer = new SecureTextTimer(this);
1861 gSecureTextTimers->add(this, secureTextTimer); 1861 gSecureTextTimers->add(this, secureTextTimer);
1862 } 1862 }
1863 secureTextTimer->restartWithNewText(lastTypedCharacterOffset); 1863 secureTextTimer->restartWithNewText(lastTypedCharacterOffset);
1864 } 1864 }
1865 1865
1866 } // namespace WebCore 1866 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698