Unreviewed, rolling out r161840.

http://trac.webkit.org/changeset/161840
https://bugs.webkit.org/show_bug.cgi?id=126870

Caused jsscore and layout test failures (Requested by smfr on
#webkit).

Source/JavaScriptCore:

* API/JSValueRef.cpp:
(JSValueMakeFromJSONString):
* bindings/ScriptValue.cpp:
(Deprecated::jsToInspectorValue):
* inspector/InspectorValues.cpp:
* runtime/DatePrototype.cpp:
(JSC::formatLocaleDate):
* runtime/Identifier.h:
(JSC::Identifier::characters):
* runtime/JSStringBuilder.h:
(JSC::JSStringBuilder::append):

Source/WebCore:

* bindings/objc/WebScriptObject.mm:
(+[WebScriptObject _convertValueToObjcValue:JSC::originRootObject:rootObject:]):
* editing/CompositeEditCommand.cpp:
(WebCore::containsOnlyWhitespace):
* editing/TypingCommand.cpp:
(WebCore::TypingCommand::insertText):
* editing/VisibleUnits.cpp:
(WebCore::startOfParagraph):
(WebCore::endOfParagraph):
* html/parser/HTMLParserIdioms.cpp:
(WebCore::stripLeadingAndTrailingHTMLSpaces):
(WebCore::parseHTMLNonNegativeInteger):
* inspector/ContentSearchUtils.cpp:
(WebCore::ContentSearchUtils::createSearchRegexSource):
* inspector/InspectorStyleSheet.cpp:
(WebCore::InspectorStyle::newLineAndWhitespaceDelimiters):
* inspector/InspectorStyleTextEditor.cpp:
(WebCore::InspectorStyleTextEditor::insertProperty):
(WebCore::InspectorStyleTextEditor::internalReplaceProperty):
* platform/Length.cpp:
(WebCore::newCoordsArray):
* platform/LinkHash.cpp:
(WebCore::visitedLinkHash):
* platform/graphics/Color.cpp:
(WebCore::Color::parseHexColor):
(WebCore::Color::Color):
* platform/graphics/TextRun.h:
(WebCore::TextRun::TextRun):
* platform/text/TextEncodingRegistry.cpp:
(WebCore::atomicCanonicalTextEncodingName):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::constructTextRun):
* rendering/RenderCombineText.cpp:
(WebCore::RenderCombineText::width):
* svg/SVGFontElement.cpp:
(WebCore::SVGFontElement::registerLigaturesInGlyphCache):
* xml/XPathFunctions.cpp:
(WebCore::XPath::FunId::evaluate):
* xml/XPathNodeSet.h:

Source/WTF:

* wtf/text/StringImpl.cpp:
(WTF::StringImpl::replace):
* wtf/text/WTFString.h:
(WTF::String::isAllSpecialCharacters):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@161861 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 518579c2
......@@ -323,11 +323,11 @@ JSValueRef JSValueMakeFromJSONString(JSContextRef ctx, JSStringRef string)
APIEntryShim entryShim(exec);
String str = string->string();
unsigned length = str.length();
if (str.is8Bit()) {
if (length && str.is8Bit()) {
LiteralParser<LChar> parser(exec, str.characters8(), length, StrictJSON);
return toRef(exec, parser.tryLiteralParse());
}
LiteralParser<UChar> parser(exec, str.characters16(), length, StrictJSON);
LiteralParser<UChar> parser(exec, str.characters(), length, StrictJSON);
return toRef(exec, parser.tryLiteralParse());
}
......
2014-01-12 Commit Queue <commit-queue@webkit.org>
Unreviewed, rolling out r161840.
http://trac.webkit.org/changeset/161840
https://bugs.webkit.org/show_bug.cgi?id=126870
Caused jsscore and layout test failures (Requested by smfr on
#webkit).
* API/JSValueRef.cpp:
(JSValueMakeFromJSONString):
* bindings/ScriptValue.cpp:
(Deprecated::jsToInspectorValue):
* inspector/InspectorValues.cpp:
* runtime/DatePrototype.cpp:
(JSC::formatLocaleDate):
* runtime/Identifier.h:
(JSC::Identifier::characters):
* runtime/JSStringBuilder.h:
(JSC::JSStringBuilder::append):
2014-01-12 Darin Adler <darin@apple.com>
Add deprecatedCharacters as a synonym for characters and convert most call sites
......
......@@ -115,8 +115,10 @@ static PassRefPtr<InspectorValue> jsToInspectorValue(ExecState* scriptState, JSV
return InspectorBasicValue::create(value.asBoolean());
if (value.isNumber())
return InspectorBasicValue::create(value.asNumber());
if (value.isString())
return InspectorString::create(value.getString(scriptState));
if (value.isString()) {
String s = value.getString(scriptState);
return InspectorString::create(String(s.characters(), s.length()));
}
if (value.isObject()) {
if (isJSArray(value)) {
......@@ -136,11 +138,13 @@ static PassRefPtr<InspectorValue> jsToInspectorValue(ExecState* scriptState, JSV
JSObject* object = value.getObject();
PropertyNameArray propertyNames(scriptState);
object->methodTable()->getOwnPropertyNames(object, scriptState, propertyNames, ExcludeDontEnumProperties);
for (auto& name : propertyNames) {
RefPtr<InspectorValue> inspectorValue = jsToInspectorValue(scriptState, object->get(scriptState, name), maxDepth);
for (size_t i = 0; i < propertyNames.size(); i++) {
const Identifier& name = propertyNames[i];
JSValue propertyValue = object->get(scriptState, name);
RefPtr<InspectorValue> inspectorValue = jsToInspectorValue(scriptState, propertyValue, maxDepth);
if (!inspectorValue)
return nullptr;
inspectorObject->setValue(name.string(), inspectorValue);
inspectorObject->setValue(String(name.characters(), name.length()), inspectorValue);
}
return inspectorObject;
}
......
......@@ -446,17 +446,14 @@ PassRefPtr<InspectorValue> buildValue(const UChar* start, const UChar* end, cons
inline bool escapeChar(UChar c, StringBuilder* dst)
{
// Must escape < and > to prevent script execution.
switch (c) {
case '\b': dst->appendLiteral("\\b"); break;
case '\f': dst->appendLiteral("\\f"); break;
case '\n': dst->appendLiteral("\\n"); break;
case '\r': dst->appendLiteral("\\r"); break;
case '\t': dst->appendLiteral("\\t"); break;
case '\\': dst->appendLiteral("\\\\"); break;
case '"': dst->appendLiteral("\\\""); break;
case '<': dst->appendLiteral("\\u003C"); break;
case '>': dst->appendLiteral("\\u003E"); break;
case '\b': dst->append("\\b", 2); break;
case '\f': dst->append("\\f", 2); break;
case '\n': dst->append("\\n", 2); break;
case '\r': dst->append("\\r", 2); break;
case '\t': dst->append("\\t", 2); break;
case '\\': dst->append("\\\\", 2); break;
case '"': dst->append("\\\"", 2); break;
default:
return false;
}
......@@ -469,13 +466,15 @@ inline void doubleQuoteString(const String& str, StringBuilder* dst)
for (unsigned i = 0; i < str.length(); ++i) {
UChar c = str[i];
if (!escapeChar(c, dst)) {
// We could format c > 126 as UTF-8 instead of escaping them.
if (c >= 32 || c <= 126)
if (c < 32 || c > 126 || c == '<' || c == '>') {
// 1. Escaping <, > to prevent script execution.
// 2. Technically, we could also pass through c > 126 as UTF8, but this
// is also optional. It would also be a pain to implement here.
unsigned int symbol = static_cast<unsigned int>(c);
String symbolCode = String::format("\\u%04X", symbol);
dst->append(symbolCode.characters(), symbolCode.length());
} else
dst->append(c);
else {
// FIXME: Way too slow to do this by creating and destroying a string each time.
dst->append(String::format("\\u%04X", static_cast<unsigned>(c)));
}
}
}
dst->append('"');
......
......@@ -162,14 +162,33 @@ static JSCell* formatLocaleDate(ExecState* exec, DateInstance*, double timeInMil
else if (format != LocaleDate && !exec->argument(0).isUndefined())
timeStyle = styleFromArgString(arg0String, timeStyle);
RetainPtr<CFDateFormatterRef> formatter = adoptCF(CFDateFormatterCreate(kCFAllocatorDefault, adoptCF(CFLocaleCopyCurrent()).get(), dateStyle, timeStyle));
CFLocaleRef locale = CFLocaleCopyCurrent();
CFDateFormatterRef formatter = CFDateFormatterCreate(0, locale, dateStyle, timeStyle);
CFRelease(locale);
if (useCustomFormat) {
CFStringRef customFormatCFString = CFStringCreateWithCharacters(0, customFormatString.characters(), customFormatString.length());
CFDateFormatterSetFormat(formatter, customFormatCFString);
CFRelease(customFormatCFString);
}
CFStringRef string = CFDateFormatterCreateStringWithAbsoluteTime(0, formatter, floor(timeInMilliseconds / msPerSecond) - kCFAbsoluteTimeIntervalSince1970);
if (useCustomFormat)
CFDateFormatterSetFormat(formatter.get(), customFormatString.createCFString().get());
CFRelease(formatter);
RetainPtr<CFStringRef> string = adoptCF(CFDateFormatterCreateStringWithAbsoluteTime(kCFAllocatorDefault, formatter.get(), floor(timeInMilliseconds / msPerSecond) - kCFAbsoluteTimeIntervalSince1970));
// We truncate the string returned from CFDateFormatter if it's absurdly long (> 200 characters).
// That's not great error handling, but it just won't happen so it doesn't matter.
UChar buffer[200];
const size_t bufferLength = WTF_ARRAY_LENGTH(buffer);
size_t length = CFStringGetLength(string);
ASSERT(length <= bufferLength);
if (length > bufferLength)
length = bufferLength;
CFStringGetCharacters(string, CFRangeMake(0, length), buffer);
return jsNontrivialString(exec, string.get());
CFRelease(string);
return jsNontrivialString(exec, String(buffer, length));
}
#elif USE(ICU_UNICODE) && !UCONFIG_NO_FORMATTING
......
......@@ -55,6 +55,7 @@ namespace JSC {
const String& string() const { return m_string; }
StringImpl* impl() const { return m_string.impl(); }
const UChar* characters() const { return m_string.characters(); }
int length() const { return m_string.length(); }
CString ascii() const { return m_string.ascii(); }
......
......@@ -105,7 +105,7 @@ public:
}
upConvert();
}
m_okay &= buffer16.tryAppend(str.characters16(), length);
m_okay &= buffer16.tryAppend(str.characters(), length);
}
void upConvert()
......
2014-01-12 Commit Queue <commit-queue@webkit.org>
Unreviewed, rolling out r161840.
http://trac.webkit.org/changeset/161840
https://bugs.webkit.org/show_bug.cgi?id=126870
Caused jsscore and layout test failures (Requested by smfr on
#webkit).
* wtf/text/StringImpl.cpp:
(WTF::StringImpl::replace):
* wtf/text/WTFString.h:
(WTF::String::isAllSpecialCharacters):
2014-01-12 Dan Bernstein <mitz@apple.com>
Fix an assertion failure in initializeDates() when launching Safari, which was introduced in r161852.
......
......@@ -1489,7 +1489,7 @@ PassRef<StringImpl> StringImpl::replace(unsigned position, unsigned lengthToRepl
for (unsigned i = 0; i < length() - position - lengthToReplace; ++i)
data[i + position + lengthToInsert] = m_data8[i + position + lengthToReplace];
} else {
memcpy(data + position + lengthToInsert, characters16() + position + lengthToReplace,
memcpy(data + position + lengthToInsert, characters() + position + lengthToReplace,
(length() - position - lengthToReplace) * sizeof(UChar));
}
return newImpl;
......
......@@ -625,14 +625,14 @@ inline bool isAllSpecialCharacters(const CharacterType* characters, size_t lengt
template<bool isSpecialCharacter(UChar)>
inline bool String::isAllSpecialCharacters() const
{
size_t length = this->length();
size_t len = length();
if (!length)
if (!len)
return true;
if (is8Bit())
return WTF::isAllSpecialCharacters<isSpecialCharacter>(characters8(), length);
return WTF::isAllSpecialCharacters<isSpecialCharacter>(characters16(), length);
return WTF::isAllSpecialCharacters<isSpecialCharacter, LChar>(characters8(), len);
return WTF::isAllSpecialCharacters<isSpecialCharacter, UChar>(characters(), len);
}
// StringHash is the default hash for String
......
2014-01-12 Commit Queue <commit-queue@webkit.org>
Unreviewed, rolling out r161840.
http://trac.webkit.org/changeset/161840
https://bugs.webkit.org/show_bug.cgi?id=126870
Caused jsscore and layout test failures (Requested by smfr on
#webkit).
* bindings/objc/WebScriptObject.mm:
(+[WebScriptObject _convertValueToObjcValue:JSC::originRootObject:rootObject:]):
* editing/CompositeEditCommand.cpp:
(WebCore::containsOnlyWhitespace):
* editing/TypingCommand.cpp:
(WebCore::TypingCommand::insertText):
* editing/VisibleUnits.cpp:
(WebCore::startOfParagraph):
(WebCore::endOfParagraph):
* html/parser/HTMLParserIdioms.cpp:
(WebCore::stripLeadingAndTrailingHTMLSpaces):
(WebCore::parseHTMLNonNegativeInteger):
* inspector/ContentSearchUtils.cpp:
(WebCore::ContentSearchUtils::createSearchRegexSource):
* inspector/InspectorStyleSheet.cpp:
(WebCore::InspectorStyle::newLineAndWhitespaceDelimiters):
* inspector/InspectorStyleTextEditor.cpp:
(WebCore::InspectorStyleTextEditor::insertProperty):
(WebCore::InspectorStyleTextEditor::internalReplaceProperty):
* platform/Length.cpp:
(WebCore::newCoordsArray):
* platform/LinkHash.cpp:
(WebCore::visitedLinkHash):
* platform/graphics/Color.cpp:
(WebCore::Color::parseHexColor):
(WebCore::Color::Color):
* platform/graphics/TextRun.h:
(WebCore::TextRun::TextRun):
* platform/text/TextEncodingRegistry.cpp:
(WebCore::atomicCanonicalTextEncodingName):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::constructTextRun):
* rendering/RenderCombineText.cpp:
(WebCore::RenderCombineText::width):
* svg/SVGFontElement.cpp:
(WebCore::SVGFontElement::registerLigaturesInGlyphCache):
* xml/XPathFunctions.cpp:
(WebCore::XPath::FunId::evaluate):
* xml/XPathNodeSet.h:
2014-01-12 Jinwoo Song <jinwoo7.song@samsung.com>
Fix build warnings by unused parameter
......@@ -548,8 +548,11 @@ static void getListFromNSArray(ExecState *exec, NSArray *array, RootObject* root
return [WebScriptObject scriptObjectForJSObject:toRef(object) originRootObject:originRootObject rootObject:rootObject];
}
if (value.isString())
return asString(value)->value(rootObject->globalObject()->globalExec());
if (value.isString()) {
ExecState* exec = rootObject->globalObject()->globalExec();
const String& u = asString(value)->value(exec);
return [NSString stringWithCharacters:u.characters() length:u.length()];
}
if (value.isNumber())
return [NSNumber numberWithDouble:value.asNumber()];
......
......@@ -667,9 +667,10 @@ void CompositeEditCommand::setNodeAttribute(PassRefPtr<Element> element, const Q
static inline bool containsOnlyWhitespace(const String& text)
{
for (unsigned i = 0; i < text.length(); ++i) {
if (!isWhitespace(text[i]))
if (!isWhitespace(text.characters()[i]))
return false;
}
return true;
}
......
......@@ -152,7 +152,7 @@ void TypingCommand::insertText(Document& document, const String& text, Options o
ASSERT(frame);
if (!text.isEmpty())
frame->editor().updateMarkersForWordsAffectedByEditing(isSpaceOrNewline(text[0]));
frame->editor().updateMarkersForWordsAffectedByEditing(isSpaceOrNewline(text.characters()[0]));
insertText(document, text, frame->selection().selection(), options, composition);
}
......
......@@ -1146,10 +1146,15 @@ VisiblePosition startOfParagraph(const VisiblePosition& c, EditingBoundaryCrossi
ASSERT_WITH_SECURITY_IMPLICATION(n->isTextNode());
type = Position::PositionIsOffsetInAnchor;
if (style.preserveNewline()) {
unsigned startOffset = n == startNode ? std::max(0, offset) : std::numeric_limits<unsigned>::max();
size_t newlineOffset = toRenderText(r)->text()->reverseFind('\n', startOffset);
if (newlineOffset != notFound)
return VisiblePosition(Position(toText(n), newlineOffset + 1), DOWNSTREAM);
const UChar* chars = toRenderText(r)->characters();
int i = toRenderText(r)->textLength();
int o = offset;
if (n == startNode && o < i)
i = std::max(0, o);
while (--i >= 0) {
if (chars[i] == '\n')
return VisiblePosition(Position(toText(n), i + 1), DOWNSTREAM);
}
}
node = n;
offset = 0;
......@@ -1221,11 +1226,15 @@ VisiblePosition endOfParagraph(const VisiblePosition &c, EditingBoundaryCrossing
// FIXME: We avoid returning a position where the renderer can't accept the caret.
if (r->isText() && toRenderText(r)->hasRenderedText()) {
ASSERT_WITH_SECURITY_IMPLICATION(n->isTextNode());
int length = toRenderText(r)->textLength();
type = Position::PositionIsOffsetInAnchor;
if (style.preserveNewline()) {
size_t newlineOffset = toRenderText(r)->text()->find('\n', n == startNode ? offset : 0);
if (newlineOffset != notFound)
return VisiblePosition(Position(toText(n), newlineOffset), DOWNSTREAM);
const UChar* chars = toRenderText(r)->characters();
int o = n == startNode ? offset : 0;
for (int i = o; i < length; ++i) {
if (chars[i] == '\n')
return VisiblePosition(Position(toText(n), i), DOWNSTREAM);
}
}
node = n;
offset = r->caretMaxOffset();
......
......@@ -71,7 +71,7 @@ String stripLeadingAndTrailingHTMLSpaces(const String& string)
if (string.is8Bit())
return stripLeadingAndTrailingHTMLSpaces(string, string.characters8(), length);
return stripLeadingAndTrailingHTMLSpaces(string, string.characters16(), length);
return stripLeadingAndTrailingHTMLSpaces(string, string.characters(), length);
}
String serializeForNumberType(const Decimal& number)
......@@ -267,12 +267,12 @@ bool parseHTMLNonNegativeInteger(const String& input, unsigned& value)
// Step 1
// Step 2
unsigned length = input.length();
if (input.isNull() || input.is8Bit()) {
if (length && input.is8Bit()) {
const LChar* start = input.characters8();
return parseHTMLNonNegativeIntegerInternal(start, start + length, value);
}
const UChar* start = input.characters16();
const UChar* start = input.characters();
return parseHTMLNonNegativeIntegerInternal(start, start + length, value);
}
......
......@@ -36,7 +36,6 @@
#include <inspector/InspectorValues.h>
#include <wtf/BumpPointerAllocator.h>
#include <wtf/StdLibExtras.h>
#include <wtf/text/StringBuilder.h>
#include <yarr/Yarr.h>
using namespace Inspector;
......@@ -51,13 +50,17 @@ static const char regexSpecialCharacters[] = "[](){}+-*.,?\\^$|";
static String createSearchRegexSource(const String& text)
{
StringBuilder result;
String result;
const UChar* characters = text.characters();
String specials(regexSpecialCharacters);
for (unsigned i = 0; i < text.length(); i++) {
if (isASCII(text[i]) && strchr(regexSpecialCharacters, text[i]))
result.append('\\');
result.append(text[i]);
if (specials.find(characters[i]) != notFound)
result.append("\\");
result.append(characters[i]);
}
return result.toString();
return result;
}
static inline size_t sizetExtractor(const size_t* value)
......
......@@ -723,13 +723,14 @@ NewLineAndWhitespace& InspectorStyle::newLineAndWhitespaceDelimiters() const
int propertyIndex = 0;
bool isFullPrefixScanned = false;
bool lineFeedTerminated = false;
const UChar* characters = text.characters();
while (propertyIndex < propertyCount) {
const WebCore::CSSPropertySourceData& currentProperty = sourcePropertyData->at(propertyIndex++);
bool processNextProperty = false;
int scanEnd = currentProperty.range.start;
for (int i = scanStart; i < scanEnd; ++i) {
UChar ch = text[i];
UChar ch = characters[i];
bool isLineFeed = isHTMLLineBreak(ch);
if (isLineFeed) {
if (!lineFeedTerminated)
......
......@@ -82,10 +82,12 @@ void InspectorStyleTextEditor::insertProperty(unsigned index, const String& prop
if (insertLast && !insertFirstInSource) {
propertyStart = styleBodyLength;
if (propertyStart && textToSet.length()) {
const UChar* characters = m_styleText.characters();
long curPos = propertyStart - 1; // The last position of style declaration, since propertyStart points past one.
while (curPos && isHTMLSpace(m_styleText[curPos]))
while (curPos && isHTMLSpace(characters[curPos]))
--curPos;
if (curPos && m_styleText[curPos] != ';') {
if (curPos && characters[curPos] != ';') {
// Prepend a ";" to the property text if appending to a style declaration where
// the last property has no trailing ";".
textToSet.insert(";", 0);
......@@ -228,6 +230,7 @@ void InspectorStyleTextEditor::internalReplaceProperty(const InspectorStylePrope
const SourceRange& range = property.sourceData.range;
long replaceRangeStart = range.start;
long replaceRangeEnd = range.end;
const UChar* characters = m_styleText.characters();
long newTextLength = newText.length();
String finalNewText = newText;
......@@ -238,14 +241,14 @@ void InspectorStyleTextEditor::internalReplaceProperty(const InspectorStylePrope
if (replaceRangeStart >= fullPrefixLength && m_styleText.substring(replaceRangeStart - fullPrefixLength, fullPrefixLength) == fullPrefix)
replaceRangeStart -= fullPrefixLength;
} else if (newTextLength) {
if (isHTMLLineBreak(newText[newTextLength - 1])) {
if (isHTMLLineBreak(newText.characters()[newTextLength - 1])) {
// Coalesce newlines of the original and new property values (to avoid a lot of blank lines while incrementally applying property values).
bool foundNewline = false;
bool isLastNewline = false;
int i;
int textLength = m_styleText.length();
for (i = replaceRangeEnd; i < textLength && isSpaceOrNewline(m_styleText[i]); ++i) {
isLastNewline = isHTMLLineBreak(m_styleText[i]);
for (i = replaceRangeEnd; i < textLength && isSpaceOrNewline(characters[i]); ++i) {
isLastNewline = isHTMLLineBreak(characters[i]);
if (isLastNewline)
foundNewline = true;
else if (foundNewline && !isLastNewline) {
......
......@@ -88,9 +88,10 @@ static int countCharacter(const UChar* data, unsigned length, UChar character)
std::unique_ptr<Length[]> newCoordsArray(const String& string, int& len)
{
unsigned length = string.length();
const UChar* data = string.characters();
StringBuffer<UChar> spacified(length);
for (unsigned i = 0; i < length; i++) {
UChar cc = string[i];
UChar cc = data[i];
if (cc > '9' || (cc < '0' && cc != '-' && cc != '*' && cc != '.'))
spacified[i] = ' ';
else
......
......@@ -214,9 +214,10 @@ static ALWAYS_INLINE LinkHash visitedLinkHashInline(const CharacterType* url, un
LinkHash visitedLinkHash(const String& url)
{
unsigned length = url.length();
if (url.isNull() || url.is8Bit())
if (length && url.is8Bit())
return visitedLinkHashInline(url.characters8(), length);
return visitedLinkHashInline(url.characters16(), length);
return visitedLinkHashInline(url.characters(), length);
}
LinkHash visitedLinkHash(const UChar* url, unsigned length)
......
......@@ -165,7 +165,7 @@ bool Color::parseHexColor(const String& name, RGBA32& rgb)
return false;
if (name.is8Bit())
return parseHexColor(name.characters8(), name.length(), rgb);
return parseHexColor(name.characters16(), name.length(), rgb);
return parseHexColor(name.characters(), name.length(), rgb);
}
int differenceSquared(const Color& c1, const Color& c2)
......@@ -182,7 +182,7 @@ Color::Color(const String& name)
if (name.is8Bit())
m_valid = parseHexColor(name.characters8() + 1, name.length() - 1, m_color);
else
m_valid = parseHexColor(name.characters16() + 1, name.length() - 1, m_color);
m_valid = parseHexColor(name.characters() + 1, name.length() - 1, m_color);
} else
setNamedColor(name);
}
......
......@@ -124,11 +124,11 @@ public:
, m_tabSize(0)
{
#if ENABLE(8BIT_TEXTRUN)
if (s.isNull() || s.is8Bit()) {
if (m_charactersLength && s.is8Bit()) {
m_data.characters8 = s.characters8();
m_is8Bit = true;
} else {
m_data.characters16 = s.characters16();
m_data.characters16 = s.characters();
m_is8Bit = false;
}
#else
......
......@@ -347,13 +347,13 @@ const char* atomicCanonicalTextEncodingName(const CharacterType* characters, siz
const char* atomicCanonicalTextEncodingName(const String& alias)
{
if (alias.isEmpty())
return nullptr;
if (!alias.length())
return 0;
if (alias.is8Bit())
return atomicCanonicalTextEncodingName<LChar>(alias.characters8(), alias.length());
return atomicCanonicalTextEncodingName<UChar>(alias.characters16(), alias.length());
return atomicCanonicalTextEncodingName<UChar>(alias.characters(), alias.length());
}
bool noExtendedTextEncodingNameUsed()
......
......@@ -5479,10 +5479,11 @@ TextRun RenderBlock::constructTextRun(RenderObject* context, const Font& font, c
TextRun RenderBlock::constructTextRun(RenderObject* context, const Font& font, const String& string, const RenderStyle& style, TextRun::ExpansionBehavior expansion, TextRunFlags flags)
{
unsigned length = string.length();
#if ENABLE(8BIT_TEXTRUN)
if (string.isNull() || string.is8Bit())
if (length && string.is8Bit())
return constructTextRunInternal(context, font, string.characters8(), length, style, expansion, flags);
return constructTextRunInternal(context, font, string.characters16(), length, style, expansion, flags);
return constructTextRunInternal(context, font, string.characters(), length, style, expansion, flags);
#else
return constructTextRunInternal(context, font, string.deprecatedCharacters(), length, style, expansion, flags);
#endif
......
......@@ -60,7 +60,7 @@ void RenderCombineText::setTextInternal(const String& text)
float RenderCombineText::width(unsigned from, unsigned length, const Font& font, float xPosition, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
{
if (!textLength())
if (!characters())
return 0;
if (m_isCombined)
......
......@@ -87,13 +87,16 @@ void SVGFontElement::registerLigaturesInGlyphCache(Vector<String>& ligatures)
// will not be able to find a glyph for "f", but handles the fallback
// character substitution properly through glyphDataForCharacter().
Vector<SVGGlyph> glyphs;
for (auto& ligature : ligatures) {
unsigned ligatureLength = ligature.length();
ASSERT(ligatureLength > 1);
size_t ligaturesSize = ligatures.size();
for (size_t i = 0; i < ligaturesSize; ++i) {
const String& unicode = ligatures[i];
for (unsigned i = 0; i < ligatureLength; ++i) {
// FIXME: Is there a faster way to do this without allocating/deallocating a string for every character in every ligature?
String lookupString(ligature.substring(i, 1));
unsigned unicodeLength = unicode.length();
ASSERT(unicodeLength > 1);
const UChar* characters = unicode.characters();
for (unsigned i = 0; i < unicodeLength; ++i) {
String lookupString(characters + i, 1);
m_glyphMap.collectGlyphsForString(lookupString, glyphs);
if (!glyphs.isEmpty()) {
glyphs.clear();
......
......@@ -307,17 +307,18 @@ Value FunPosition::evaluate() const
Value FunId::evaluate() const
{
Value a = argument(0).evaluate();
StringBuilder idList; // A whitespace-separated list of IDs
String idList; // A whitespace-separated list of IDs
if (a.isNodeSet()) {
StringBuilder spaceSeparatedList;
for (auto& node : a.toNodeSet()) {
spaceSeparatedList.append(stringValue(node.get()));
spaceSeparatedList.append(' ');
const NodeSet& nodes = a.toNodeSet();
for (size_t i = 0; i < nodes.size(); ++i) {
String str = stringValue(nodes[i]);
idList.append(str);
idList.append(' ');
}
idList = spaceSeparatedList.toString();
} else {
idList = a.toString();
String str = a.toString();
idList.append(str);
}
TreeScope& contextScope = evaluationContext().node->treeScope();
......@@ -339,7 +340,7 @@ Value FunId::evaluate() const
// If there are several nodes with the same id, id() should return the first one.
// In WebKit, getElementById behaves so, too, although its behavior in this case is formally undefined.
Node* node = contextScope.getElementById(idList.substring(startPos, endPos - startPos));
Node* node = contextScope.getElementById(String(idList.characters() + startPos, endPos - startPos));
if (node && resultSet.add(node).isNewEntry)
result.append(node);
......
......@@ -44,9 +44,6 @@ namespace WebCore {
void reserveCapacity(size_t newCapacity) { m_nodes.reserveCapacity(newCapacity); }
void clear() { m_nodes.clear(); }
Vector<RefPtr<Node>>::const_iterator begin() const { return m_nodes.begin(); }
Vector<RefPtr<Node>>::const_iterator end() const { return m_nodes.end(); }
// NodeSet itself does not verify that nodes in it are unique.
void append(PassRefPtr<Node> node) { m_nodes.append(node); }
void append(const NodeSet& nodeSet) { m_nodes.appendVector(nodeSet.m_nodes); }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment