Changeset 140731 in webkit
- Timestamp:
- Jan 24, 2013 3:01:06 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r140695 r140731 1 2013-01-24 Martin Robinson <mrobinson@igalia.com> 2 3 Abstract the logic for appending a UChar32 onto StringBuilder 4 https://bugs.webkit.org/show_bug.cgi?id=107505 5 6 Reviewed by Darin Adler. 7 8 * wtf/text/StringBuilder.h: 9 (WTF::StringBuilder::append): Added a method for appending a UChar32 to a StringBuilder. 10 1 11 2013-01-24 Brent Fulgham <bfulgham@webkit.org> 2 12 -
trunk/Source/WTF/wtf/text/StringBuilder.h
r133726 r140731 142 142 } 143 143 144 void append(UChar32 c) 145 { 146 if (U_IS_BMP(c)) { 147 append(static_cast<UChar>(c)); 148 return; 149 } 150 append(U16_LEAD(c)); 151 append(U16_TRAIL(c)); 152 } 153 144 154 template<unsigned charactersCount> 145 155 ALWAYS_INLINE void appendLiteral(const char (&characters)[charactersCount]) { append(characters, charactersCount - 1); } -
trunk/Source/WebCore/ChangeLog
r140729 r140731 1 2013-01-24 Martin Robinson <mrobinson@igalia.com> 2 3 Abstract the logic for appending a UChar32 onto StringBuilder 4 https://bugs.webkit.org/show_bug.cgi?id=107505 5 6 Reviewed by Darin Adler. 7 8 * css/CSSOMUtils.cpp: 9 (WebCore::serializeCharacter): Use the new StringBuilder append. 10 (WebCore::serializeIdentifier): Ditto. 11 (WebCore::serializeString): Ditto. 12 * html/parser/HTMLEntityParser.cpp: 13 (WebCore::HTMLEntityParser::consumeNamedEntity): Ditto. 14 * svg/SVGFontData.cpp: 15 (WebCore::SVGFontData::createStringWithMirroredCharacters): Ditto. 16 * xml/parser/CharacterReferenceParserInlines.h: 17 (WebCore::consumeCharacterReference): Ditto. 18 * xml/parser/XMLCharacterReferenceParser.cpp: Remove an older helper 19 superseded by StringBuilder::append. 20 1 21 2013-01-24 Kentaro Hara <haraken@chromium.org> 2 22 -
trunk/Source/WebCore/css/CSSOMUtils.cpp
r95901 r140731 37 37 namespace WebCore { 38 38 39 static void appendCharacter(UChar32 c, StringBuilder& appendTo)40 {41 if (U16_LENGTH(c) == 1)42 appendTo.append(static_cast<UChar>(c));43 else {44 appendTo.append(U16_LEAD(c));45 appendTo.append(U16_TRAIL(c));46 }47 }48 49 39 void serializeCharacter(UChar32 c, StringBuilder& appendTo) 50 40 { 51 41 appendTo.append('\\'); 52 append Character(c, appendTo);42 appendTo.append(c); 53 43 } 54 44 … … 82 72 serializeCharacter(c, appendTo); 83 73 else if (0x80 <= c || c == 0x2d || c == 0x5f || (0x30 <= c && c <= 0x39) || (0x41 <= c && c <= 0x5a) || (0x61 <= c && c <= 0x7a)) 84 append Character(c, appendTo);74 appendTo.append(c); 85 75 else 86 76 serializeCharacter(c, appendTo); … … 116 106 serializeCharacter(c, appendTo); 117 107 else 118 append Character(c, appendTo);108 appendTo.append(c); 119 109 } 120 110 -
trunk/Source/WebCore/html/parser/HTMLEntityParser.cpp
r140610 r140731 69 69 } 70 70 71 inline static void convertToUTF16(UChar32 value, StringBuilder& decodedEntity)72 {73 if (U_IS_BMP(value)) {74 UChar character = static_cast<UChar>(value);75 ASSERT(character == value);76 decodedEntity.append(character);77 return;78 }79 decodedEntity.append(U16_LEAD(value));80 decodedEntity.append(U16_TRAIL(value));81 }82 83 71 inline static bool acceptMalformed() { return true; } 84 72 … … 126 114 || !additionalAllowedCharacter 127 115 || !(isAlphaNumeric(cc) || cc == '=')) { 128 convertToUTF16(entitySearch.mostRecentMatch()->firstValue, decodedEntity);116 decodedEntity.append(entitySearch.mostRecentMatch()->firstValue); 129 117 if (entitySearch.mostRecentMatch()->secondValue) 130 convertToUTF16(entitySearch.mostRecentMatch()->secondValue, decodedEntity);118 decodedEntity.append(entitySearch.mostRecentMatch()->secondValue); 131 119 return true; 132 120 } -
trunk/Source/WebCore/svg/SVGFontData.cpp
r138316 r140731 292 292 mirroredCharacters.reserveCapacity(length); 293 293 294 UChar32 character;295 294 unsigned i = 0; 296 295 while (i < length) { 296 UChar32 character; 297 297 U16_NEXT(characters, i, length, character); 298 character = mirroredChar(character); 299 300 if (U16_LENGTH(character) == 1) 301 mirroredCharacters.append(static_cast<UChar>(character)); 302 else { 303 mirroredCharacters.append(U16_LEAD(character)); 304 mirroredCharacters.append(U16_TRAIL(character)); 305 } 298 mirroredCharacters.append(mirroredChar(character)); 306 299 } 307 300 -
trunk/Source/WebCore/xml/parser/CharacterReferenceParserInlines.h
r135802 r140731 129 129 else if (cc == ';') { 130 130 source.advanceAndASSERT(cc); 131 ParserFunctions::convertToUTF16(ParserFunctions::legalEntityFor(result), decodedCharacter);131 decodedCharacter.append(ParserFunctions::legalEntityFor(result)); 132 132 return true; 133 133 } else if (ParserFunctions::acceptMalformed()) { 134 ParserFunctions::convertToUTF16(ParserFunctions::legalEntityFor(result), decodedCharacter);134 decodedCharacter.append(ParserFunctions::legalEntityFor(result)); 135 135 return true; 136 136 } else { … … 145 145 else if (cc == ';') { 146 146 source.advanceAndASSERT(cc); 147 ParserFunctions::convertToUTF16(ParserFunctions::legalEntityFor(result), decodedCharacter);147 decodedCharacter.append(ParserFunctions::legalEntityFor(result)); 148 148 return true; 149 149 } else if (ParserFunctions::acceptMalformed()) { 150 ParserFunctions::convertToUTF16(ParserFunctions::legalEntityFor(result), decodedCharacter);150 decodedCharacter.append(ParserFunctions::legalEntityFor(result)); 151 151 return true; 152 152 } else { -
trunk/Tools/ChangeLog
r140717 r140731 1 2013-01-24 Martin Robinson <mrobinson@igalia.com> 2 3 Abstract the logic for appending a UChar32 onto StringBuilder 4 https://bugs.webkit.org/show_bug.cgi?id=107505 5 6 Reviewed by Darin Adler. 7 8 * TestWebKitAPI/Tests/WTF/StringBuilder.cpp: 9 (TestWebKitAPI::TEST): Added a simple test for appending UChar32. 10 1 11 2013-01-24 Erik Arvidsson <arv@chromium.org> 2 12 -
trunk/Tools/TestWebKitAPI/Tests/WTF/StringBuilder.cpp
r105639 r140731 34 34 namespace TestWebKitAPI { 35 35 36 void expectBuilderContent(const char*expected, const StringBuilder& builder)36 static void expectBuilderContent(const String& expected, const StringBuilder& builder) 37 37 { 38 38 // Not using builder.toString() or builder.toStringPreserveCapacity() because they all 39 39 // change internal state of builder. 40 EXPECT_EQ( String(expected), String(builder.characters(), builder.length()));40 EXPECT_EQ(expected, String(builder.characters(), builder.length())); 41 41 } 42 42 … … 86 86 builder2.append("abcd"); 87 87 ASSERT_EQ(characters, builder2.characters()); 88 89 // Test appending UChar32 characters to StringBuilder. 90 StringBuilder builderForUChar32Append; 91 UChar32 frakturAChar = 0x1D504; 92 builderForUChar32Append.append(frakturAChar); // The fraktur A is not in the BMP, so it's two UTF-16 code units long. 93 ASSERT_EQ(2U, builderForUChar32Append.length()); 94 builderForUChar32Append.append(static_cast<UChar32>('A')); 95 ASSERT_EQ(3U, builderForUChar32Append.length()); 96 const UChar resultArray[] = { U16_LEAD(frakturAChar), U16_TRAIL(frakturAChar), 'A' }; 97 expectBuilderContent(String(resultArray, WTF_ARRAY_LENGTH(resultArray)), builderForUChar32Append); 88 98 } 89 99
Note: See TracChangeset
for help on using the changeset viewer.