Changeset 225618 in webkit for trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
- Timestamp:
- Dec 6, 2017, 8:06:53 PM (8 years ago)
- Author:
- Darin Adler
- Message:
-
Modernize some aspects of text codecs, eliminate WebKit use of strcasecmp
https://bugs.webkit.org/show_bug.cgi?id=180009
Reviewed by Alex Christensen.
Source/JavaScriptCore:
- bytecode/ArrayProfile.cpp: Removed include of StringExtras.h.
- bytecode/CodeBlock.cpp: Ditto.
- bytecode/ExecutionCounter.cpp: Ditto.
- runtime/ConfigFile.cpp: Ditto.
- runtime/DatePrototype.cpp: Ditto.
- runtime/IndexingType.cpp: Ditto.
- runtime/JSCJSValue.cpp: Ditto.
- runtime/JSDateMath.cpp: Ditto.
- runtime/JSGlobalObjectFunctions.cpp: Ditto.
- runtime/Options.cpp: Ditto.
(JSC::parse): Use equalLettersIgnoringASCIICase instead of strcasecmp.
Source/WebCore:
- Modules/fetch/FetchBody.cpp:
(WebCore::FetchBody::consumeAsStream): Update to use size since the result of
encode is now Vector rather than CString. And for the new UnencodableHandling.
(WebCore::FetchBody::consumeText): Removed now-unneeded type cast. Ditto.
(WebCore::FetchBody::bodyAsFormData const): Ditto.
(WebCore::FetchBody::take): Pass result of encode directly to SharedBuffer::create.
- Modules/websockets/WebSocketDeflater.cpp: Removed include of StringExtras.h.
- bridge/IdentifierRep.h: Ditto.
- bridge/c/c_instance.cpp: Ditto.
- fileapi/BlobBuilder.cpp:
(WebCore::BlobBuilder::append): Updated for CString to Vector change and
for UnencodableHandling.
- html/parser/HTMLMetaCharsetParser.cpp:
(WebCore::HTMLMetaCharsetParser::checkForMetaCharset): Call the decode function
with all the arguments since there is only one decode function now.
- inspector/agents/InspectorDOMAgent.cpp:
(WebCore::computeContentSecurityPolicySHA256Hash): Updated for CString to Vector
change and for UnencodableHandling.
- loader/ResourceCryptographicDigest.cpp:
(WebCore::cryptographicDigestForBytes): Changed argument type to const void*.
- loader/ResourceCryptographicDigest.h: Ditto.
- loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::TextResourceDecoder): Moved initialization of data
members to class definition.
(WebCore::TextResourceDecoder::create): Moved function body here from the header.
(WebCore::TextResourceDecoder::setEncoding): Use equalLettersIgnoringASCIICase.
(WebCore::TextResourceDecoder::shouldAutoDetect const): Updated for name change
to m_parentFrameAutoDetectedEncoding, which obviates a comment.
(WebCore::TextResourceDecoder::flush): Ditto.
- loader/TextResourceDecoder.h: Moved initialization here from constructor.
Moved function bodies out of the class. Renamed m_hintEncoding to
m_parentFrameAutoDetectedEncoding since that is a more accurate description.
- loader/appcache/ApplicationCacheStorage.cpp: Removed include of StringExtras.h.
- page/FrameTree.cpp: Ditto.
- page/PageSerializer.cpp: Ditto.
(WebCore::PageSerializer::serializeFrame): Pass result of encode directly to
StringBuffer::create and update for UnencodableHandling.
(WebCore::PageSerializer::serializeCSSStyleSheet): Ditto.
- page/csp/ContentSecurityPolicy.cpp:
(WebCore::ContentSecurityPolicy::findHashOfContentInPolicies const): Ditto.
- platform/FileHandle.cpp: Removed include of StringExtras.h.
- platform/SharedBuffer.cpp:
(WebCore::SharedBuffer::create): Added an overload that takes Vector<uint8_t>.
- platform/SharedBuffer.h: Ditto.
- platform/URLParser.cpp:
(WebCore::URLParser::encodeQuery): Updated since encode returns a Vector instead
of a CString now and for UnencodableHandling.
- platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::shouldWaitForLoadingOfResource): Ditto.
- platform/graphics/ca/PlatformCALayer.cpp: Removed include of StringExtras.h.
- platform/network/curl/ResourceHandleCurlDelegate.cpp:
(WebCore::ResourceHandleCurlDelegate::handleDataURL): Updated for Vector instead
of CString.
- platform/network/FormData.cpp:
(WebCore::FormData::create): Added new overload, and simplified some existing ones.
(WebCore::normalizeStringData): Changed return type to Vector<uint8_t> and updated
for UnencodableHandling.
(WebCore::FormData::appendMultiPartStringValue): Updated for change in type of
result of normalizeStringData.
- platform/network/FormData.h: Updated for the above and updated comments.
- platform/network/FormDataBuilder.cpp: Made this a namespace instead of a class.
(WebCore::FormDataBuilder::append): Added an overload for Vector<uint8_t>.
(WebCore::FormDataBuilder::appendQuoted): Renamed from appendQuotedString and
changed the argument type.
(WebCore::FormDataBuilder::appendFormURLEncoded): Moved logic up from the
encodeStringAsFormData function into a new separate helper.
(WebCore::FormDataBuilder::addFilenameToMultiPartHeader): Updated for change to
UnencodableHandling.
(WebCore::FormDataBuilder::beginMultiPartHeader): Changed argument type.
(WebCore::FormDataBuilder::addKeyValuePairAsFormData): Ditto.
(WebCore::FormDataBuilder::encodeStringAsFormData): Updated to call helper.
- platform/network/FormDataBuilder.h: Updated for the above.
- platform/text/DecodeEscapeSequences.h: Use Vector<uint8_t> instead of
Vector<char>, also updated the code that calls encode for the new return type
and updated for change to UnencodableHandler.
- platform/text/TextCodec.cpp:
(WebCore::TextCodec::getUnencodableReplacement): Updated since we are using
std::array now, so the out argument is easier to understand, also updated for
change to UnencodablaHandler.
- platform/text/TextCodec.h: Use std::array for the UnencodableReplacementArray
type, removed the overload of decode so there is only one decode function.
- platform/text/TextCodecICU.cpp:
(WebCore::ICUConverterWrapper::~ICUConverterWrapper): Deleted.
Not needed any more since we use ICUConverterPtr instead now.
(WebCore::cachedConverterICU): Deleted.
(WebCore::TextCodecICU::create): Deleted. Callers just use make_unique
directly now.
(WebCore::TextCodecICU::registerCodecs): Rewrote to use lambdas instead
of functions with void* pointers.
(WebCore::TextCodecICU::TextCodecICU): Moved initializers into the header.
(WebCore::TextCodecICU::~TextCodecICU): Moved the body of releaseICUConverter
in here. Also greatly simplified it now that ICUConverterPtr handles closing
it as needed.
(WebCore::TextCodecICU::releaseICUConverter const): Deleted.
(WebCore::TextCodecICU::createICUConverter const): Rewrote to simplfy now that
we can use ICUConverterPtr.
(WebCore::ErrorCallbackSetter::ErrorCallbackSetter): Take a reference instead
of a pointer.
(WebCore::ErrorCallbackSetter::~ErrorCallbackSetter): Ditto.
(WebCore::TextCodecICU::decode): Use equalLettersIgnoringASCIICase instead of
strcasecmp.
(WebCore::TextCodecICU::encode): Return a Vector instead of a CString.
Take a StringView instead of a pointer and length. Simplified
the backslash-as-currency-symbol code by using String::replace.
- platform/text/TextCodecICU.h: Updated for above. Fixed indentation.
Added a new ICUConverterPtr typedef that uses std::unique_ptr to close the
converter; combined with move semantics it simplifies things so we don't have
to be so careful about calling ucnv_close.
- platform/text/TextCodecLatin1.cpp: Renamed the Latin-1 to Unicode table from
"table" to latin1ConversionTable.
(WebCore::TextCodecLatin1::registerCodecs): Use a lambda.
(WebCore::encodeComplexWindowsLatin1): Return a Vector instad of CString.
Also use StringView::codePoints instead of our own U16_NEXT.
(WebCore::TextCodecLatin1::encode): More of the same.
- platform/text/TextCodecLatin1.h: Updated for the above.
- platform/text/TextCodecReplacement.cpp:
(WebCore::TextCodecReplacement::create): Deleted.
(WebCore::TextCodecReplacement::TextCodecReplacement): Deleted.
(WebCore::TextCodecReplacement::registerCodecs): Use a lambda.
- platform/text/TextCodecReplacement.h: Updated for the above.
- platform/text/TextCodecUTF16.cpp:
(WebCore::newStreamingTextDecoderUTF16LE): Deleted.
(WebCore::newStreamingTextDecoderUTF16BE): Deleted.
(WebCore::TextCodecUTF16::registerCodecs): Use lambdas.
(WebCore::TextCodecUTF16::encode): Return a Vector.
- platform/text/TextCodecUTF16.h: Updated for the above.
- platform/text/TextCodecUTF8.cpp:
(WebCore::TextCodecUTF8::registerCodecs): Use a lambda.
(WebCore::TextCodecUTF8::encode): Return a Vector.
- platform/text/TextCodecUTF8.h: Updated for the above.
- platform/text/TextCodecUserDefined.cpp:
(WebCore::newStreamingTextDecoderUserDefined): Deleted.
(WebCore::TextCodecUserDefined::registerCodecs): Use a lambda.
(WebCore::encodeComplexUserDefined): Return a Vector.
(WebCore::TextCodecUserDefined::encode): Ditto.
- platform/text/TextCodecUserDefined.h: Updated for the above.
- platform/text/TextEncoding.cpp: Changed TextCodecMap to just hold a
WTF::Function instead of holding a function and an additional data pointer.
(WebCore::TextEncoding::TextEncoding): Use equalLettersIgnoringASCIICase
instead of a special isReplacementEncoding function.
(WebCore::TextEncoding::encode const): Return a Vector instead of a CString.
Pass StringView instead of a pointer and length.
- platform/text/TextEncoding.h: Updated for the above.
- platform/text/TextEncodingRegistry.cpp:
(WebCore::addToTextCodecMap): Removed the additionalData pointer and used
WTFMove since NewTextCodecFunction is now a WTF::Function rather than a C
function pointer.
(WebCore::isReplacementEncoding): Deleted.
(WebCore::newTextCodec): Use find instead of get now that the fucntions in
the map are WTF::Function and can't be copied.
(WebCore::dumpTextEncodingNameMap): Deleted.
- platform/text/TextEncodingRegistry.h: Updated for the above.
- platform/text/win/TextCodecWin.cpp:
(WebCore::TextCodecWin::encode): Updated comment.
- xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::send): Updated for change to UnencodableHandling.
- xml/XSLTUnicodeSort.cpp: Removed include of StringExtras.h.
- xml/parser/XMLDocumentParser.cpp: Ditto.
- xml/parser/XMLDocumentParserLibxml2.cpp: Ditto.
Source/WebCore/PAL:
- PAL.xcodeproj/project.pbxproj: Added UnencodableHandling.h.
- pal/text/UnencodableHandling.h: Moved the UnencodableHandling enumeration
here from TextCodec.h and changed it to an enum class.
Source/WebKit:
- WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
(WebKit::initializeProtectionSpace): Use equalLettersIgnoringASCIICase instead
of strcasecmp.
Source/WebKitLegacy/mac:
- History/HistoryPropertyList.mm: Removed include of StringExtras.h.
- Plugins/WebBaseNetscapePluginView.mm:
(WebKit::getAuthenticationInfo): Use equalLettersIgnoringASCIICase instead
of strcasecmp.
- WebView/WebPreferences.mm:
(contains): Ditto. Also made this a template so it's easier to call on an array.
(cacheModelForMainBundle): Take advantage of the above to make it cleaner.
Source/WTF:
- wtf/Assertions.cpp: Removed include of StringExtras.h.
(WTFLogChannelByName): Use equalIgnoringASCIICase instead of strcasecmp.
- wtf/DateMath.cpp: Removed include of StringExtras.h.
- wtf/MD5.cpp: Ditto. Also removed include of CString.h.
- wtf/SHA1.cpp: Ditto.
- wtf/StringExtras.h:
(strncasecmp): Deleted.
(strcasecmp): Deleted.
- wtf/StringPrintStream.cpp: Removed include of StringExtras.h.
- wtf/text/Base64.cpp: Ditto.
- wtf/text/LineEnding.cpp:
(WTF::normalizeLineEndingsToLF): Replaced old more general purpose function with
this. Changed argument type to vector and used an rvalue reference and return value.
Also fixed some small logic errors.
(WTF::normalizeLineEndingsToCRLF): Ditto.
(WTF::normalizeLineEndingsToNative): Updated for above changes.
- wtf/text/LineEnding.h: Updated for above changes.
- wtf/text/StringCommon.h:
(WTF::equalIgnoringASCIICase): Added overload for const char*.
(WTF::equalLettersIgnoringASCIICase): Ditto.
- wtf/text/TextStream.cpp: Removed include of StringExtras.h.
- wtf/text/WTFString.cpp: Ditto.
- wtf/unicode/icu/CollatorICU.cpp: Ditto.
Tools:
- DumpRenderTree/cg/PixelDumpSupportCG.cpp: Removed include of StringExtras.h.
- TestWebKitAPI/CMakeLists.txt: Added LineEnding.cpp.
- TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Ditto.
- TestWebKitAPI/Tests/WTF/LineEnding.cpp: Added. Has tests for the LineEnding
functions rewritten in this patch.
- TestWebKitAPI/Tests/WebCore/TextCodec.cpp: Updated test now that the decode
function doesn't have defaults for as many arguments any more. Also changed so
that the tests log the fact that the decode function returns an error and updated
expected results to expect all the errors.
- WebKitTestRunner/cg/TestInvocationCG.cpp: Ditto.
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
r225150 r225618 54 54 #include <wtf/HexNumber.h> 55 55 #include <wtf/MathExtras.h> 56 #include <wtf/StringExtras.h>57 56 #include <wtf/dtoa.h> 58 57 #include <wtf/text/StringBuilder.h>