Changeset 181105 in webkit
- Timestamp:
- Mar 5, 2015 3:34:56 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r181096 r181105 1 2015-03-05 Chris Dumez <cdumez@apple.com> 2 3 Regression(r173761): ASSERTION FAILED: !is8Bit() in StringImpl::characters16() 4 https://bugs.webkit.org/show_bug.cgi?id=142350 5 6 Reviewed by Michael Saboff and Benjamin Poulain. 7 8 Update String.startsWith() / endsWith() test to cover cases where the 9 input string is 8-bit and the pattern is 16-bit, and vice-versa. 10 11 * js/script-tests/string-includes.js: 12 * js/string-includes-expected.txt: 13 1 14 2015-03-05 Roger Fong <roger_fong@apple.com> 2 15 -
trunk/LayoutTests/js/script-tests/string-includes.js
r177856 r181105 55 55 shouldBe("'フーバー'.startsWith('フー')", "true"); 56 56 shouldBe("'フーバー'.startsWith('バー')", "false"); 57 shouldBe("'フーバー'.startsWith('abc')", "false"); 58 shouldBe("'フーバー'.startsWith('abc', 1)", "false"); 59 shouldBe("'foo bar'.startsWith('フー')", "false"); 60 shouldBe("'foo bar'.startsWith('フー', 1)", "false"); 57 61 58 62 // Test endsWith … … 83 87 shouldBe("'フーバー'.endsWith('バー')", "true"); 84 88 shouldBe("'フーバー'.endsWith('フー')", "false"); 89 shouldBe("'フーバー'.endsWith('abc')", "false"); 90 shouldBe("'フーバー'.endsWith('abc')", "false"); 91 shouldBe("'foo bar'.endsWith('フー')", "false"); 92 shouldBe("'foo bar'.endsWith('フー', 3)", "false"); 85 93 86 94 // Call functions with an environment record as 'this'. -
trunk/LayoutTests/js/string-includes-expected.txt
r177856 r181105 55 55 PASS 'フーバー'.startsWith('フー') is true 56 56 PASS 'フーバー'.startsWith('バー') is false 57 PASS 'フーバー'.startsWith('abc') is false 58 PASS 'フーバー'.startsWith('abc', 1) is false 59 PASS 'foo bar'.startsWith('フー') is false 60 PASS 'foo bar'.startsWith('フー', 1) is false 57 61 PASS 'foo bar'.endsWith('bar') is true 58 62 PASS 'foo bar'.endsWith('ba', 6) is true … … 81 85 PASS 'フーバー'.endsWith('バー') is true 82 86 PASS 'フーバー'.endsWith('フー') is false 87 PASS 'フーバー'.endsWith('abc') is false 88 PASS 'フーバー'.endsWith('abc') is false 89 PASS 'foo bar'.endsWith('フー') is false 90 PASS 'foo bar'.endsWith('フー', 3) is false 83 91 PASS (function() { var f = String.prototype.startsWith; (function() { f('a'); })(); })() threw exception TypeError: Type error. 84 92 PASS (function() { var f = String.prototype.endsWith; (function() { f('a'); })(); })() threw exception TypeError: Type error. -
trunk/Source/JavaScriptCore/ChangeLog
r181084 r181105 1 2015-03-05 Chris Dumez <cdumez@apple.com> 2 3 Regression(r173761): ASSERTION FAILED: !is8Bit() in StringImpl::characters16() 4 https://bugs.webkit.org/show_bug.cgi?id=142350 5 6 Reviewed by Michael Saboff and Benjamin Poulain. 7 8 Call WTFString::hasInfixStartingAt() / hasInfixEndingAt() now that these 9 methods have been renamed for clarity. 10 11 * runtime/StringPrototype.cpp: 12 (JSC::stringProtoFuncStartsWith): 13 (JSC::stringProtoFuncEndsWith): 14 1 15 2015-03-05 Yusuke Suzuki <utatane.tea@gmail.com> 2 16 -
trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp
r181084 r181105 1653 1653 return JSValue::encode(jsUndefined()); 1654 1654 1655 return JSValue::encode(jsBoolean(stringToSearchIn. startsWith(searchString, start, true)));1655 return JSValue::encode(jsBoolean(stringToSearchIn.hasInfixStartingAt(searchString, start))); 1656 1656 } 1657 1657 … … 1681 1681 unsigned end = std::min<unsigned>(std::max(pos, 0), length); 1682 1682 1683 return JSValue::encode(jsBoolean(stringToSearchIn. endsWith(searchString, end, true)));1683 return JSValue::encode(jsBoolean(stringToSearchIn.hasInfixEndingAt(searchString, end))); 1684 1684 } 1685 1685 -
trunk/Source/WTF/ChangeLog
r181086 r181105 1 2015-03-05 Chris Dumez <cdumez@apple.com> 2 3 Regression(r173761): ASSERTION FAILED: !is8Bit() in StringImpl::characters16() 4 https://bugs.webkit.org/show_bug.cgi?id=142350 5 6 Reviewed by Michael Saboff and Benjamin Poulain. 7 8 Fix ASSERTION FAILED: !is8Bit() in StringImpl::characters16() from 9 WTF::equalInner() after r173761. The code was incorrectly assuming that 10 if stringImpl is 16-bit, then matchString is 16-bit too, which is not 11 correct. 12 13 Also rename WTFString::startsWith() / endsWith() taking an offset to 14 hasInfixStartingAt() / hasInfixEndingAt() for clarity. It seems odd 15 to call it startsWith even though it won't technically *start* with 16 the pattern if the input offset is greater than zero. 17 18 Also drop the caseSensitive argument as it is never used (always true 19 at call sites. 20 21 * wtf/text/StringImpl.cpp: 22 (WTF::equalInner): 23 (WTF::StringImpl::hasInfixStartingAt): 24 (WTF::StringImpl::hasInfixEndingAt): 25 (WTF::StringImpl::startsWith): Deleted. 26 (WTF::StringImpl::endsWith): Deleted. 27 * wtf/text/StringImpl.h: 28 * wtf/text/WTFString.h: 29 (WTF::String::hasInfixStartingAt): 30 (WTF::String::hasInfixEndingAt): 31 (WTF::String::startsWith): Deleted. 32 (WTF::String::endsWith): Deleted. 33 1 34 2015-03-05 Chris Dumez <cdumez@apple.com> 2 35 -
trunk/Source/WTF/wtf/text/StringImpl.cpp
r179429 r181105 1358 1358 } 1359 1359 1360 ALWAYS_INLINE static bool equalInner( StringImpl& stringImpl, unsigned startOffset, StringImpl& matchString, bool caseSensitive)1360 ALWAYS_INLINE static bool equalInner(const StringImpl& stringImpl, unsigned startOffset, const StringImpl& matchString) 1361 1361 { 1362 1362 if (startOffset > stringImpl.length()) … … 1367 1367 return false; 1368 1368 1369 if ( caseSensitive) {1370 if ( stringImpl.is8Bit())1369 if (stringImpl.is8Bit()) { 1370 if (matchString.is8Bit()) 1371 1371 return equal(stringImpl.characters8() + startOffset, matchString.characters8(), matchString.length()); 1372 return equal(stringImpl.characters 16() + startOffset, matchString.characters16(), matchString.length());1373 } 1374 if ( stringImpl.is8Bit())1375 return equal IgnoringCase(stringImpl.characters8() + startOffset, matchString.characters8(), matchString.length());1376 return equal IgnoringCase(stringImpl.characters16() + startOffset, matchString.characters16(), matchString.length());1372 return equal(stringImpl.characters8() + startOffset, matchString.characters16(), matchString.length()); 1373 } 1374 if (matchString.is8Bit()) 1375 return equal(stringImpl.characters16() + startOffset, matchString.characters8(), matchString.length()); 1376 return equal(stringImpl.characters16() + startOffset, matchString.characters16(), matchString.length()); 1377 1377 } 1378 1378 … … 1408 1408 } 1409 1409 1410 bool StringImpl:: startsWith(StringImpl& matchString, unsigned startOffset, bool caseSensitive) const1411 { 1412 return equalInner( const_cast<StringImpl&>(*this), startOffset, matchString, caseSensitive);1410 bool StringImpl::hasInfixStartingAt(const StringImpl& matchString, unsigned startOffset) const 1411 { 1412 return equalInner(*this, startOffset, matchString); 1413 1413 } 1414 1414 … … 1437 1437 } 1438 1438 1439 bool StringImpl:: endsWith(StringImpl& matchString, unsigned endOffset, bool caseSensitive) const1439 bool StringImpl::hasInfixEndingAt(const StringImpl& matchString, unsigned endOffset) const 1440 1440 { 1441 1441 if (endOffset < matchString.length()) 1442 1442 return false; 1443 return equalInner( const_cast<StringImpl&>(*this), endOffset - matchString.length(), matchString, caseSensitive);1443 return equalInner(*this, endOffset - matchString.length(), matchString); 1444 1444 } 1445 1445 -
trunk/Source/WTF/wtf/text/StringImpl.h
r179644 r181105 675 675 template<unsigned matchLength> 676 676 bool startsWith(const char (&prefix)[matchLength], bool caseSensitive = true) const { return startsWith(prefix, matchLength - 1, caseSensitive); } 677 WTF_EXPORT_STRING_API bool startsWith(StringImpl&, unsigned startOffset, bool caseSensitive) const;677 WTF_EXPORT_STRING_API bool hasInfixStartingAt(const StringImpl&, unsigned startOffset) const; 678 678 679 679 WTF_EXPORT_STRING_API bool endsWith(StringImpl*, bool caseSensitive = true); … … 682 682 template<unsigned matchLength> 683 683 bool endsWith(const char (&prefix)[matchLength], bool caseSensitive = true) const { return endsWith(prefix, matchLength - 1, caseSensitive); } 684 WTF_EXPORT_STRING_API bool endsWith(StringImpl&, unsigned endOffset, bool caseSensitive) const;684 WTF_EXPORT_STRING_API bool hasInfixEndingAt(const StringImpl&, unsigned endOffset) const; 685 685 686 686 WTF_EXPORT_STRING_API Ref<StringImpl> replace(UChar, UChar); -
trunk/Source/WTF/wtf/text/WTFString.h
r181086 r181105 271 271 bool startsWith(const char (&prefix)[matchLength], bool caseSensitive = true) const 272 272 { return m_impl ? m_impl->startsWith<matchLength>(prefix, caseSensitive) : !matchLength; } 273 bool startsWith(String& prefix, unsigned startOffset, bool caseSensitive) const274 { return m_impl && prefix.impl() ? m_impl-> startsWith(*prefix.impl(), startOffset, caseSensitive) : false; }273 bool hasInfixStartingAt(const String& prefix, unsigned startOffset) const 274 { return m_impl && prefix.impl() ? m_impl->hasInfixStartingAt(*prefix.impl(), startOffset) : false; } 275 275 276 276 bool endsWith(const String& s, bool caseSensitive = true) const … … 282 282 bool endsWith(const char (&prefix)[matchLength], bool caseSensitive = true) const 283 283 { return m_impl ? m_impl->endsWith<matchLength>(prefix, caseSensitive) : !matchLength; } 284 bool endsWith(String& suffix, unsigned endOffset, bool caseSensitive) const285 { return m_impl && suffix.impl() ? m_impl-> endsWith(*suffix.impl(), endOffset, caseSensitive) : false; }284 bool hasInfixEndingAt(const String& suffix, unsigned endOffset) const 285 { return m_impl && suffix.impl() ? m_impl->hasInfixEndingAt(*suffix.impl(), endOffset) : false; } 286 286 287 287 WTF_EXPORT_STRING_API void append(const String&); -
trunk/Tools/ChangeLog
r181098 r181105 1 2015-03-05 Chris Dumez <cdumez@apple.com> 2 3 Regression(r173761): ASSERTION FAILED: !is8Bit() in StringImpl::characters16() 4 https://bugs.webkit.org/show_bug.cgi?id=142350 5 6 Reviewed by Michael Saboff and Benjamin Poulain. 7 8 Add API test for WTFString::hasInfixStartingAt() to make sure it doesn't 9 crash if the string is 8-bit but the pattern is 16-bit (and vice-versa). 10 11 * TestWebKitAPI/Tests/WTF/WTFString.cpp: 12 (TestWebKitAPI::TEST): 13 1 14 2015-03-05 Brent Fulgham <bfulgham@apple.com> 2 15 -
trunk/Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp
r174246 r181105 261 261 } 262 262 263 TEST(WTF, StringhasInfixStartingAt) 264 { 265 EXPECT_TRUE(String("Test").is8Bit()); 266 EXPECT_TRUE(String("Te").is8Bit()); 267 EXPECT_TRUE(String("st").is8Bit()); 268 EXPECT_TRUE(String("Test").hasInfixStartingAt(String("Te"), 0)); 269 EXPECT_FALSE(String("Test").hasInfixStartingAt(String("Te"), 2)); 270 EXPECT_TRUE(String("Test").hasInfixStartingAt(String("st"), 2)); 271 EXPECT_FALSE(String("Test").hasInfixStartingAt(String("ST"), 2)); 272 273 EXPECT_FALSE(String::fromUTF8("中国").is8Bit()); 274 EXPECT_FALSE(String::fromUTF8("中").is8Bit()); 275 EXPECT_FALSE(String::fromUTF8("国").is8Bit()); 276 EXPECT_TRUE(String::fromUTF8("中国").hasInfixStartingAt(String::fromUTF8("中"), 0)); 277 EXPECT_FALSE(String::fromUTF8("中国").hasInfixStartingAt(String::fromUTF8("中"), 1)); 278 EXPECT_TRUE(String::fromUTF8("中国").hasInfixStartingAt(String::fromUTF8("国"), 1)); 279 280 EXPECT_FALSE(String::fromUTF8("中国").hasInfixStartingAt(String("Te"), 0)); 281 EXPECT_FALSE(String("Test").hasInfixStartingAt(String::fromUTF8("中"), 2)); 282 } 283 263 284 } // namespace TestWebKitAPI
Note: See TracChangeset
for help on using the changeset viewer.