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

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

Issue 16501003: text-transform: capitalize shouldn't upconvert (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 RenderText* m_renderText; 91 RenderText* m_renderText;
92 int m_lastTypedCharacterOffset; 92 int m_lastTypedCharacterOffset;
93 }; 93 };
94 94
95 static void makeCapitalized(String* string, UChar previous) 95 static void makeCapitalized(String* string, UChar previous)
96 { 96 {
97 if (string->isNull()) 97 if (string->isNull())
98 return; 98 return;
99 99
100 unsigned length = string->length(); 100 unsigned length = string->length();
101 const UChar* characters = string->characters(); 101 const StringImpl& input = *string->impl();
102 102
103 if (length >= numeric_limits<unsigned>::max()) 103 if (length >= numeric_limits<unsigned>::max())
104 CRASH(); 104 CRASH();
105 105
106 StringBuffer<UChar> stringWithPrevious(length + 1); 106 StringBuffer<UChar> stringWithPrevious(length + 1);
107 stringWithPrevious[0] = previous == noBreakSpace ? ' ' : previous; 107 stringWithPrevious[0] = previous == noBreakSpace ? ' ' : previous;
108 for (unsigned i = 1; i < length + 1; i++) { 108 for (unsigned i = 1; i < length + 1; i++) {
109 // Replace &nbsp with a real space since ICU no longer treats &nbsp as a word separator. 109 // Replace &nbsp with a real space since ICU no longer treats &nbsp as a word separator.
110 if (characters[i - 1] == noBreakSpace) 110 if (input[i - 1] == noBreakSpace)
111 stringWithPrevious[i] = ' '; 111 stringWithPrevious[i] = ' ';
112 else 112 else
113 stringWithPrevious[i] = characters[i - 1]; 113 stringWithPrevious[i] = input[i - 1];
114 } 114 }
115 115
116 TextBreakIterator* boundary = wordBreakIterator(stringWithPrevious.character s(), length + 1); 116 TextBreakIterator* boundary = wordBreakIterator(stringWithPrevious.character s(), length + 1);
117 if (!boundary) 117 if (!boundary)
118 return; 118 return;
119 119
120 StringBuffer<UChar> data(length); 120 StringBuilder result;
121 result.reserveCapacity(length);
121 122
122 int32_t endOfWord; 123 int32_t endOfWord;
123 int32_t startOfWord = textBreakFirst(boundary); 124 int32_t startOfWord = textBreakFirst(boundary);
124 for (endOfWord = textBreakNext(boundary); endOfWord != TextBreakDone; startO fWord = endOfWord, endOfWord = textBreakNext(boundary)) { 125 for (endOfWord = textBreakNext(boundary); endOfWord != TextBreakDone; startO fWord = endOfWord, endOfWord = textBreakNext(boundary)) {
125 if (startOfWord) // Ignore first char of previous string 126 if (startOfWord) // Ignore first char of previous string
126 data[startOfWord - 1] = characters[startOfWord - 1] == noBreakSpace ? noBreakSpace : toTitleCase(stringWithPrevious[startOfWord]); 127 result.append(input[startOfWord - 1] == noBreakSpace ? noBreakSpace : toTitleCase(stringWithPrevious[startOfWord]));
127 for (int i = startOfWord + 1; i < endOfWord; i++) 128 for (int i = startOfWord + 1; i < endOfWord; i++)
128 data[i - 1] = characters[i - 1]; 129 result.append(input[i - 1]);
129 } 130 }
130 131
131 *string = String::adopt(data); 132 *string = result.toString();
132 } 133 }
133 134
134 RenderText::RenderText(Node* node, PassRefPtr<StringImpl> str) 135 RenderText::RenderText(Node* node, PassRefPtr<StringImpl> str)
135 : RenderObject(!node || node->isDocumentNode() ? 0 : node) 136 : RenderObject(!node || node->isDocumentNode() ? 0 : node)
136 , m_hasTab(false) 137 , m_hasTab(false)
137 , m_linesDirty(false) 138 , m_linesDirty(false)
138 , m_containsReversedText(false) 139 , m_containsReversedText(false)
139 , m_knownToHaveNoOverflowAndNoFallbackFonts(false) 140 , m_knownToHaveNoOverflowAndNoFallbackFonts(false)
140 , m_needsTranscoding(false) 141 , m_needsTranscoding(false)
141 , m_minWidth(-1) 142 , m_minWidth(-1)
(...skipping 1784 matching lines...) Expand 10 before | Expand all | Expand 10 after
1926 void RenderText::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const 1927 void RenderText::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
1927 { 1928 {
1928 MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Rendering) ; 1929 MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Rendering) ;
1929 RenderObject::reportMemoryUsage(memoryObjectInfo); 1930 RenderObject::reportMemoryUsage(memoryObjectInfo);
1930 info.addMember(m_text, "text"); 1931 info.addMember(m_text, "text");
1931 info.addMember(m_firstTextBox, "firstTextBox"); 1932 info.addMember(m_firstTextBox, "firstTextBox");
1932 info.addMember(m_lastTextBox, "lastTextBox"); 1933 info.addMember(m_lastTextBox, "lastTextBox");
1933 } 1934 }
1934 1935
1935 } // namespace WebCore 1936 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698