Commit Graph

835 Commits

Author SHA1 Message Date
Adrien Destugues 0195b40b77 Merge commit 'e4390067fab9a407b0c303e04f03c77381cb2ddb' into Haiku 2021-08-30 17:59:07 +02:00
Adrien Destugues 9cabb795d1 Merge commit '788086b3b8ba5a5894f8cfe1094ed237351b2dea' into Haiku 2021-08-19 20:21:07 +02:00
David Kilzer 371a901118 ThreadSanitizer: ignore uninteresting data races for reference counting of static WTF::StringImpl objects
<https://webkit.org/b/229113>

Reviewed by Chris Dumez.

* wtf/text/StringImpl.h:
(WTF::StringImpl::isStatic const):
- Add SUPPRESS_TSAN attribute since the 0x1 bit is set at
  construction and refcounting occurs in increments of 0x2, so
  the static bit never changes.
(WTF::StringImpl::ref):
(WTF::StringImpl::deref):
- Return early for static WTF::StringImpl objects to prevent
  TSan from reporting data races for m_refCount.


Canonical link: https://commits.webkit.org/240551@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281091 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-16 16:49:55 +00:00
Myles C. Maxfield f512d3569c [Cocoa] Tweak the formatting for passing NSArrays to TextStreams
https://bugs.webkit.org/show_bug.cgi?id=228766

Reviewed by Simon Fraser.

Source/WTF:

Instead of using -[NSArray description], which puts its output on multiple lines,
instead use the same formatting as WTF::Vector, which puts its output on a single line.

We can also use this opportunity to tweak the implementation of operator<<(id) to
allow it to be called with Core Foundation types in raw C++ code.

* wtf/text/TextStream.h:
* wtf/text/cocoa/TextStreamCocoa.mm:
(WTF::TextStream::operator<<):

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/cocoa/TextStreamCocoa.cpp: Added.
(TEST):
* TestWebKitAPI/Tests/WTF/cocoa/TextStreamCocoa.mm: Added.
(TEST):

Canonical link: https://commits.webkit.org/240262@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280651 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-04 19:37:35 +00:00
Adrien Destugues 3c03b69045 Merge commit 'e09283eaa2c87b3bb00c5380c76ccc1292a165c2' into Haiku branch 2021-08-01 10:58:52 +02:00
Yusuke Suzuki 8c35105dc6 Unreviewed, speculative revert of r280193
https://bugs.webkit.org/show_bug.cgi?id=228142

Source/WebCore:

* html/parser/HTMLConstructionSite.cpp:
(WebCore::HTMLConstructionSite::insertTextNode):
* html/parser/HTMLConstructionSite.h:
* html/parser/HTMLDocumentParser.cpp:
(WebCore::HTMLDocumentParser::pumpTokenizerLoop):
* html/parser/HTMLMetaCharsetParser.cpp:
(WebCore::HTMLMetaCharsetParser::checkForMetaCharset):
* html/parser/HTMLPreloadScanner.cpp:
(WebCore::HTMLPreloadScanner::scan):
* html/parser/HTMLToken.h:
(WebCore::HTMLToken::clear):
(WebCore::HTMLToken::beginStartTag):
(WebCore::HTMLToken::beginEndTag):
(WebCore::HTMLToken::shrinkToBestFit): Deleted.
* html/parser/HTMLTokenizer.h:
(WebCore::HTMLTokenizer::shrinkToBestFit): Deleted.
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::ExternalCharacterTokenBuffer::characterPredicate):
(WebCore::HTMLTreeBuilder::processFakeCharacters):
(WebCore::HTMLTreeBuilder::insertPhoneNumberLink):
(WebCore::HTMLTreeBuilder::linkifyPhoneNumbers):
(WebCore::HTMLTreeBuilder::processCharacterBuffer):
(WebCore::HTMLTreeBuilder::processCharacterBufferForInBody):
(WebCore::HTMLTreeBuilder::defaultForInTableText):
(WebCore::HTMLTreeBuilder::processTokenInForeignContent):
* html/parser/HTMLTreeBuilder.h:

Source/WTF:

* wtf/Vector.h:
(WTF::Malloc>::shrinkCapacity):
(WTF::Malloc>::shrinkToBestFit): Deleted.
* wtf/text/AtomStringImpl.cpp:
(WTF::UCharBufferTranslator::equal):
(WTF::LCharBufferTranslator::equal):
(WTF::BufferFromStaticDataTranslator::equal):
* wtf/text/StringView.h:
(WTF::StringView::stripLeadingMatchedCharacters): Deleted.

Tools:

* TestWebKitAPI/Tests/WTF/StringView.cpp:
* TestWebKitAPI/Tests/WTF/Vector.cpp:

Canonical link: https://commits.webkit.org/239982@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280335 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-27 01:43:33 +00:00
Yusuke Suzuki 31236257c5 Unreviewed, follow-up after r280193
https://bugs.webkit.org/show_bug.cgi?id=228142

I accidentally reverted auto change when switching branches.

* wtf/text/AtomStringImpl.cpp:
(WTF::UCharBufferTranslator::equal):
(WTF::LCharBufferTranslator::equal):
(WTF::BufferFromStaticDataTranslator::equal):

Canonical link: https://commits.webkit.org/239882@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280194 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-22 20:04:10 +00:00
Yusuke Suzuki 609bede062 Micro-optimize innerHTML
https://bugs.webkit.org/show_bug.cgi?id=228142

Reviewed by Simon Fraser.

Source/WebCore:

No behavior change.

This patch does some micro optimizations revealed by the profiler when running some of Speedometer2 tests which intensively use innerHTML.
This offers improvement in jQuery-TodoMVC and Vanilla-ES2015-Babel-Webpack-TodoMVC since both are super innerHTML heavy benchmarks.

----------------------------------------------------------------------------------------------------------------------------------
|               subtest                |     ms      |     ms      |  b / a   | pValue (significance using False Discovery Rate) |
----------------------------------------------------------------------------------------------------------------------------------
| Elm-TodoMVC                          |126.862500   |126.687500   |0.998621  | 0.673462                                         |
| VueJS-TodoMVC                        |27.775000    |27.645833    |0.995350  | 0.741588                                         |
| EmberJS-TodoMVC                      |129.350000   |129.129167   |0.998293  | 0.624196                                         |
| BackboneJS-TodoMVC                   |51.129167    |51.204167    |1.001467  | 0.716622                                         |
| Preact-TodoMVC                       |21.870833    |21.337500    |0.975614  | 0.217771                                         |
| AngularJS-TodoMVC                    |139.854167   |140.266667   |1.002950  | 0.489838                                         |
| Vanilla-ES2015-TodoMVC               |69.229167    |68.895833    |0.995185  | 0.238772                                         |
| Inferno-TodoMVC                      |68.391667    |68.266667    |0.998172  | 0.762281                                         |
| Flight-TodoMVC                       |77.979167    |78.166667    |1.002404  | 0.710324                                         |
| Angular2-TypeScript-TodoMVC          |39.741667    |39.966667    |1.005662  | 0.524123                                         |
| VanillaJS-TodoMVC                    |55.416667    |55.512500    |1.001729  | 0.781447                                         |
| jQuery-TodoMVC                       |268.812500   |266.966667   |0.993133  | 0.003384 (significant)                           |
| EmberJS-Debug-TodoMVC                |345.383333   |345.662500   |1.000808  | 0.695259                                         |
| React-TodoMVC                        |90.679167    |90.179167    |0.994486  | 0.067477                                         |
| React-Redux-TodoMVC                  |152.691667   |152.687500   |0.999973  | 0.991207                                         |
| Vanilla-ES2015-Babel-Webpack-TodoMVC |66.487500    |65.729167    |0.988594  | 0.000118 (significant)                           |
----------------------------------------------------------------------------------------------------------------------------------

a mean = 242.12319
b mean = 242.80485
pValue = 0.1992654128
(Bigger means are better.)
1.003 times better
Results ARE NOT significant

* html/parser/HTMLConstructionSite.cpp:
(WebCore::HTMLConstructionSite::insertTextNode):
* html/parser/HTMLConstructionSite.h:
* html/parser/HTMLDocumentParser.cpp:
(WebCore::HTMLDocumentParser::pumpTokenizerLoop): We do not need to call `shrinkToBestFit` in fragment parsing case since
we will discard HTMLToken soon.
* html/parser/HTMLMetaCharsetParser.cpp:
(WebCore::HTMLMetaCharsetParser::checkForMetaCharset):
* html/parser/HTMLPreloadScanner.cpp:
(WebCore::HTMLPreloadScanner::scan):
* html/parser/HTMLToken.h:
(WebCore::HTMLToken::clear): We found that these `clear` calls cause performance problem according to the Instruments: we
repeatedly use this Vector, and we repeatedly allocate and deallocate this Vector unnecessarily. We use `resize(0)` instead
to avoid this allocation and deallocation.
(WebCore::HTMLToken::shrinkToBestFit): But HTMLToken is kept so long, so at some point, we would like to make backing storage
small. So, we add shrinkToBestFit and we call it only after finishing batching of HTMLToken processing.
(WebCore::HTMLToken::beginStartTag):
(WebCore::HTMLToken::beginEndTag):
* html/parser/HTMLTokenizer.h:
(WebCore::HTMLTokenizer::shrinkToBestFit):
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::ExternalCharacterTokenBuffer::characterPredicate):
(WebCore::HTMLTreeBuilder::insertPhoneNumberLink):
(WebCore::HTMLTreeBuilder::linkifyPhoneNumbers):
(WebCore::HTMLTreeBuilder::processCharacterBuffer):
(WebCore::HTMLTreeBuilder::processCharacterBufferForInBody):
(WebCore::HTMLTreeBuilder::defaultForInTableText):
(WebCore::HTMLTreeBuilder::processTokenInForeignContent):
(WebCore::HTMLTreeBuilder::processFakeCharacters): Deleted. It is dead code before this patch.
* html/parser/HTMLTreeBuilder.h:

Source/WTF:

* wtf/Vector.h:
(WTF::Malloc>::shrinkToBestFit): This shrinks the backing storage to "appropriate for the living Vector".
* wtf/text/AtomStringImpl.cpp:
(WTF::UCharBufferTranslator::equal): WTF::equal for String does not check hash. This is because computing hash is expensive
and we would like to avoid that if it is not necessary. But when inserting string into AtomStringTable, we can use hash value
since they must be already computed because of HashMap's requirement. So let's use it before calling WTF::equal.
(WTF::LCharBufferTranslator::equal):
(WTF::BufferFromStaticDataTranslator::equal):
* wtf/text/StringView.h:
(WTF::StringView::stripLeadingMatchedCharacters): Add this and use it in HTMLTreeBuilder.

Tools:

* TestWebKitAPI/Tests/WTF/StringView.cpp:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WTF/Vector.cpp:
(TestWebKitAPI::TEST):

Canonical link: https://commits.webkit.org/239881@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280193 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-22 19:18:45 +00:00
Alex Christensen 19d82880c2 XHR.send(Document) should replace mismatched surrogates with replacement character before sending
https://bugs.webkit.org/show_bug.cgi?id=228170

Patch by Alex Christensen <achristensen@webkit.org> on 2021-07-22
Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

* web-platform-tests/xhr/send-entity-body-document-bogus-expected.txt:

Source/WebCore:

This matches the behavior of Chrome and Firefox.
Covered by a newly passing WPT test.

* bindings/js/JSDOMConvertStrings.cpp:
(WebCore::identifierToUSVString):
(WebCore::valueToUSVString):
(WebCore::stringToUSVString): Deleted.
* bindings/js/JSDOMConvertStrings.h:
* css/parser/CSSTokenizer.cpp:
(WebCore::preprocessString):
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::send):

Source/WTF:

* wtf/text/WTFString.cpp:
(WTF::replaceUnpairedSurrogatesWithReplacementCharacter):
* wtf/text/WTFString.h:
Move from WebCore, rename as suggested, update spec link to one that works.

Canonical link: https://commits.webkit.org/239875@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280181 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-22 17:44:34 +00:00
Adrien Destugues 6fa86ddd8b Merge commit '533b089dc9634a2d7afcd133d96f9f46d347f1a7' into Haiku 2021-07-20 21:31:28 +02:00
Simon Fraser 5097cefb44 Add a StyleSheets log channel and some logging
https://bugs.webkit.org/show_bug.cgi?id=227880

Reviewed by Alan Bujtas.

Source/WebCore:

Add some logging to help debug issues when pages dynamically build style sheets.

Also make Document loggable.

* css/CSSStyleSheet.cpp:
(WebCore::CSSStyleSheet::insertRule):
(WebCore::CSSStyleSheet::deleteRule):
(WebCore::CSSStyleSheet::addRule):
(WebCore::CSSStyleSheet::debugDescription const):
* css/CSSStyleSheet.h:
* css/StyleSheet.cpp:
(WebCore::operator<<):
* css/StyleSheet.h:
* dom/Document.cpp:
(WebCore::Document::debugDescription const):
(WebCore::operator<<):
* dom/Document.h:
* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::process):
(WebCore::HTMLLinkElement::debugDescription const):
* html/HTMLLinkElement.h:
* platform/Logging.h:
* platform/graphics/GraphicsLayer.cpp:
(WebCore::GraphicsLayer::dumpProperties const):
* platform/graphics/filters/FilterEffect.cpp:
(WebCore::FilterEffect::imageBufferResult):
* style/StyleScope.cpp:
(WebCore::Style::Scope::addPendingSheet):
(WebCore::Style::Scope::addStyleSheetCandidateNode):
(WebCore::Style::Scope::collectActiveStyleSheets):
(WebCore::Style::Scope::updateActiveStyleSheets):
* xml/XSLStyleSheet.h:
* xml/XSLStyleSheetLibxslt.cpp:
(WebCore::XSLStyleSheet::debugDescription const):

Source/WTF:

Make it possible to feed Ref<> and RefPtr<> into TextStream.

* wtf/text/TextStream.h:
(WTF::operator<<):


Canonical link: https://commits.webkit.org/239602@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279847 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-12 20:45:20 +00:00
Adrien Destugues 89494020d1 Merge commit '6fbe35566296ef4716d35074d3ebb6ff71abb226' into HEAD 2021-06-29 18:42:07 +02:00
Adrien Destugues 333916fbb0 Merge commit 'bd708bb50d9feb3c098035e778f1f0b91d9b8112' into haiku branch 2021-06-20 18:56:20 +02:00
Sam Weinig e6c9e42905 Adopt Span in Base64.h
https://bugs.webkit.org/show_bug.cgi?id=227132

Reviewed by Chris Dumez.

Replaces overloads taking Vectors with ones taking Spans
and add overloads for Span<const std::byte> which all the
others are now implemented in terms of. This is useful since
any Span can be turned into one of type Span<const std::byte>
just by calling asBytes(existingSpan).

This leaves most of the existing overloads in place (though
simplifies them by implementing them as Span contructions)
though we should consider removing some in a separate pass.

* wtf/Vector.h:
Add value_type typedef so that Vector<T> can be automatically
deduced as Span<T>.

* wtf/text/CString.h:
Add bytes() and bytesInludingNullTerminator() (only the former
is used in this patch, but the later will be needed shortly)
which return Span<const uint8_t> of the CString. I chose to use
an explicit function, rather than making it converible to Span
like Vector, because some callers will want the null terminator
and some will not.

* wtf/text/Base64.cpp:
* wtf/text/Base64.h:
Canonicalize all input buffers either as a Span<const std::byte> or
a StringView, making all the other overloads just forward to one of
those two (String -> StringView, everything else -> Span<const std::byte>).

Clean up the header a bit by putting all the declarations at the top of
the file.


Canonical link: https://commits.webkit.org/238971@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279051 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-20 02:05:08 +00:00
Adrien Destugues c6e4bb5d32 Merge commit '20307a3cb5047e4a3a5d1133a37d2db95a84164c' into HEAD 2021-06-12 20:52:37 +02:00
Chris Dumez 698c990225 Avoid some calls to StringView::toString() / StringView::toStringWithoutCopying()
https://bugs.webkit.org/show_bug.cgi?id=226803

Reviewed by Darin Adler.

Source/WebCore:

* css/parser/CSSPropertyParser.cpp:
(WebCore::consumeFontVariationTag):
* page/FrameView.cpp:
(WebCore::FrameView::scrollToFragmentInternal):
* platform/text/hyphen/HyphenationLibHyphen.cpp:
(WebCore::lastHyphenLocation):
* rendering/RenderTreeAsText.cpp:
(WebCore::writeDebugInfo):

Source/WTF:

Add support to TextStream for printing a StringView directly, without having to convert
it to a String first.

* wtf/text/TextStream.cpp:
(WTF::TextStream::operator<<):
* wtf/text/TextStream.h:


Canonical link: https://commits.webkit.org/238651@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278669 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-09 20:46:24 +00:00
Chris Dumez e2db8292be Reduce use of reinterpret_cast<> in the codebase
https://bugs.webkit.org/show_bug.cgi?id=226743

Reviewed by Darin Adler.

Source/WebCore:

* Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp:
(WebCore::CDMSessionClearKey::generateKeyRequest):
* Modules/fetch/FetchBody.cpp:
(WebCore::FetchBody::take):
* Modules/fetch/FetchBodyConsumer.cpp:
(WebCore::FetchBodyConsumer::resolve):
(WebCore::FetchBodyConsumer::takeAsBlob):
(WebCore::FetchBodyConsumer::takeAsText):
* Modules/mediastream/RTCDataChannelRemoteHandler.cpp:
(WebCore::RTCDataChannelRemoteHandler::readyToSend):
(WebCore::RTCDataChannelRemoteHandler::sendStringData):
(WebCore::RTCDataChannelRemoteHandler::sendRawData):
* Modules/webaudio/MediaStreamAudioSourceGStreamer.cpp:
(WebCore::copyBusData):
* Modules/webauthn/AuthenticatorResponseData.h:
(WebCore::encodeArrayBuffer):
(WebCore::decodeArrayBuffer):
* Modules/websockets/WebSocketChannel.cpp:
(WebCore::WebSocketChannel::startClosingHandshake):
(WebCore::WebSocketChannel::processOutgoingFrameQueue):
* Modules/websockets/WebSocketHandshake.cpp:
(WebCore::WebSocketHandshake::getExpectedWebSocketAccept):
(WebCore::headerHasValidHTTPVersion):
* bindings/js/ScriptBufferSourceProvider.h:
* bindings/js/SerializedScriptValue.cpp:
(WebCore::CloneDeserializer::readString):
* contentextensions/SerializedNFA.cpp:
(WebCore::ContentExtensions::SerializedNFA::pointerAtOffsetInFile const):
* dom/Node.cpp:
(WebCore::hashPointer):
* dom/TextEncoder.cpp:
(WebCore::TextEncoder::encode const):
* dom/TextEncoderStreamEncoder.cpp:
(WebCore::TextEncoderStreamEncoder::flush):
* editing/cocoa/WebContentReaderCocoa.mm:
(WebCore::sanitizeMarkupWithArchive):
* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::texImageArrayBufferViewHelper):
* inspector/DOMPatchSupport.cpp:
(WebCore::addStringToSHA1):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::textFromUTF8):
* loader/cache/CachedScript.cpp:
(WebCore::CachedScript::script):
* page/cocoa/ResourceUsageOverlayCocoa.mm:
(WebCore::showText):
* platform/SharedBufferChunkReader.cpp:
(WebCore::SharedBufferChunkReader::nextChunk):
* platform/cf/SharedBufferCF.cpp:
(WebCore::SharedBuffer::createCFData const):
* platform/generic/KeyedEncoderGeneric.cpp:
(WebCore::KeyedEncoderGeneric::encodeString):
* platform/graphics/GraphicsContextGL.cpp:
(WebCore::GraphicsContextGL::packImageData):
* platform/graphics/ImageBufferBackend.cpp:
(WebCore::ImageBufferBackend::getPixelBuffer const):
(WebCore::ImageBufferBackend::putPixelBuffer):
* platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp:
(WebCore::InbandTextTrackPrivateAVF::processNativeSamples):
* platform/graphics/avfoundation/cf/CDMSessionAVFoundationCF.cpp:
(WebCore::CDMSessionAVFoundationCF::generateKeyRequest):
(WebCore::CDMSessionAVFoundationCF::update):
* platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.cpp:
(WebCore::InbandTextTrackPrivateAVCF::readNativeSampleBuffer):
* platform/graphics/displaylists/DisplayListItemBuffer.cpp:
(WebCore::DisplayList::ItemBuffer::createItemBuffer):
* platform/graphics/displaylists/DisplayListIterator.cpp:
(WebCore::DisplayList::DisplayList::Iterator::updateCurrentItem):
* platform/image-decoders/gif/GIFImageReader.h:
(GIFImageReader::data const):
* platform/mac/SSLKeyGeneratorMac.mm:
(WebCore::signedPublicKeyAndChallengeString):
* platform/mediastream/RealtimeMediaSourceCenter.cpp:
(WebCore::addStringToSHA1):
* platform/network/FormDataBuilder.cpp:
(WebCore::FormDataBuilder::encodeStringAsFormData):
* platform/network/SocketStreamHandle.cpp:
(WebCore::SocketStreamHandle::sendHandshake):
* platform/network/cf/ResourceRequestCFNet.cpp:
(WebCore::ResourceRequest::doUpdatePlatformRequest):
* platform/network/cf/ResourceRequestCFNet.h:
(WebCore::httpHeaderValueUsingSuitableEncoding):
* platform/network/cf/SocketStreamHandleImplCFNet.cpp:
(WebCore::SocketStreamHandleImpl::platformSendInternal):
* platform/network/curl/CurlCacheEntry.cpp:
(WebCore::CurlCacheEntry::generateBaseFilename):
* platform/sql/SQLiteStatement.cpp:
(WebCore::SQLiteStatement::columnBlobView):
* testing/MockCDMFactory.cpp:
(WebCore::MockCDM::sanitizeResponse const):

Source/WebDriver:

* socket/HTTPParser.cpp:
(WebDriver::HTTPParser::readLine):
* socket/SessionHostSocket.cpp:
(WebDriver::SessionHost::sendWebInspectorEvent):

Source/WebKit:

* GPUProcess/media/RemoteMediaPlayerProxy.cpp:
(WebKit::RemoteMediaPlayerProxy::mediaPlayerInitializationDataEncountered):
* GPUProcess/media/RemoteTextTrackProxy.cpp:
(WebKit::RemoteTextTrackProxy::addDataCue):
* GPUProcess/webrtc/RemoteMediaRecorder.cpp:
(WebKit::RemoteMediaRecorder::fetchData):
* NetworkProcess/cache/NetworkCacheDataCurl.cpp:
(WebKit::NetworkCache::Data::apply const):
* NetworkProcess/cache/NetworkCacheKey.cpp:
(WebKit::NetworkCache::hashString):
* NetworkProcess/soup/WebKitDirectoryInputStream.cpp:
(webkitDirectoryInputStreamRead):
* Platform/IPC/ArgumentCoders.cpp:
(IPC::ArgumentCoder<CString>::encode):
(IPC::ArgumentCoder<String>::encode):
* Shared/API/c/cf/WKStringCF.mm:
(WKStringCopyCFString):
* Shared/API/c/cf/WKURLCF.mm:
(WKURLCopyCFURL):
* Shared/ShareableResource.cpp:
(WebKit::ShareableResource::wrapInSharedBuffer):
* Shared/SharedDisplayListHandle.h:
(WebKit::SharedDisplayListHandle::data const):
* Shared/WebCompiledContentRuleList.cpp:
(WebKit::WebCompiledContentRuleList::conditionsApplyOnlyToDomain const):
* UIProcess/API/APIWebAuthenticationAssertionResponse.cpp:
(API::WebAuthenticationAssertionResponse::userHandle const):
* UIProcess/API/C/WKPage.cpp:
(dataFrom):
* UIProcess/Cocoa/SOAuthorization/RedirectSOAuthorizationSession.mm:
(WebKit::RedirectSOAuthorizationSession::completeInternal):
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::sendWebInspectorEvent):
* WebProcess/Network/WebSocketChannel.cpp:
(WebKit::WebSocketChannel::createMessageQueue):
(WebKit::WebSocketChannel::didReceiveText):
* WebProcess/Network/webrtc/RTCDataChannelRemoteManager.cpp:
(WebKit::RTCDataChannelRemoteManager::sendData):
(WebKit::RTCDataChannelRemoteManager::RemoteSourceConnection::didReceiveStringData):
* WebProcess/Plugins/Netscape/NetscapePluginStream.cpp:
(WebKit::NetscapePluginStream::sendJavaScriptStream):

Source/WTF:

* wtf/CryptographicallyRandomNumber.cpp:
* wtf/FastMalloc.h:
(WTF::FastAllocator::allocate):
* wtf/SHA1.h:
(WTF::SHA1::addBytes):
* wtf/StackCheck.h:
(WTF::StackCheck::Scope::Scope):
(WTF::StackCheck::StackCheck):
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::userVisibleURL):
* wtf/URLParser.cpp:
(WTF::URLParser::formURLDecode):
* wtf/cf/URLCF.cpp:
(WTF::URL::createCFURL const):
* wtf/cocoa/URLCocoa.mm:
(WTF::URL::createCFURL const):
* wtf/persistence/PersistentCoders.cpp:
(WTF::Persistence::Coder<CString>::encode):
(WTF::Persistence::Coder<String>::encode):
* wtf/text/CString.h:
* wtf/text/WTFString.cpp:
(WTF::String::latin1 const):
* wtf/text/cf/StringImplCF.cpp:
(WTF::StringImpl::createCFString):


Canonical link: https://commits.webkit.org/238604@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278619 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-08 17:35:15 +00:00
Michael Catanzaro db03ea7de8 REGRESSION(r277744): Broke build on s390x mainframes
https://bugs.webkit.org/show_bug.cgi?id=226497

Patch by Michael Catanzaro <mcatanzaro@gnome.org> on 2021-06-03
Reviewed by Darin Adler.

The problem is we have a template defined in a C++ source file, used by multiple source
files. This is not valid C++, so let's split the templates defined in StringBuilder.cpp out
into a new StringBuilderInternals.h that we can #include in both StringBuilder.cpp and
StringBuilderJSON.cpp.

Ideally we would move the template defined in StringBuilderJSON.cpp as well, and then
eliminate StringBuilderJSON.cpp since there would only be one function left. But that file
has an MPL license. It's easier to leave it be to keep the license situation simpler.

* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/text/StringBuilder.cpp:
(WTF::StringBuilder::expandedCapacity):
(WTF::expandedCapacity): Deleted.
(WTF::StringBuilder::allocateBuffer): Deleted.
(WTF::StringBuilder::extendBufferForAppending): Deleted.
(WTF::StringBuilder::extendBufferForAppendingSlowCase): Deleted.
* wtf/text/StringBuilder.h:
* wtf/text/StringBuilderInternals.h: Added.
(WTF::StringBuilder::allocateBuffer):
(WTF::StringBuilder::reallocateBuffer):
(WTF::StringBuilder::extendBufferForAppending):
(WTF::StringBuilder::extendBufferForAppendingSlowCase):
* wtf/text/StringBuilderJSON.cpp:

Canonical link: https://commits.webkit.org/238429@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278404 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-03 13:10:38 +00:00
Darin Adler 786e7036ff Remove <wtf/Optional.h>
https://bugs.webkit.org/show_bug.cgi?id=226437

Reviewed by Chris Dumez.

Source/JavaScriptCore:

* <many files>: Remove include of <wtf/Optional.h>.

* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes): Don't generate
an include of wtf/Optional.h; including WTFString.h takes care of this anyway.
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes): Ditto.
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes): Ditto.

* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator.generate_output): Generate an include of <optional>
instead of <wtf/Optional.h>.

* inspector/scripts/tests/expected/*: Regenerate.

Source/WebCore:

* <many files>: Removed include of <wtf/Optional.h>.

* platform/graphics/Font.h: Tweaked style a bit.

* Modules/geolocation/GeolocationClient.h: Added include of <optional>.
* Modules/mediastream/DoubleRange.h: Ditto.
* Modules/mediastream/LongRange.h: Ditto.
* Modules/webauthn/AuthenticationExtensionsClientOutputs.h: Ditto.
* css/CSSToLengthConversionData.h: Ditto.
* css/DOMMatrix2DInit.h: Ditto.
* dom/AddEventListenerOptions.h: Ditto.
* dom/DeviceMotionData.h: Ditto.
* dom/DeviceOrientationData.h: Ditto.
* dom/SuccessOr.h: Ditto.
* html/DateTimeFieldsState.h: Ditto.
* html/ImageBitmapOptions.h: Ditto.
* html/canvas/PredefinedColorSpace.h: Ditto.
* layout/LayoutPhase.h: Ditto.
* layout/MarginTypes.h: Ditto.
* loader/ResourceLoadNotifier.h: Ditto.
* page/RuntimeEnabledFeatures.h: Ditto.
* page/ScrollOptions.h: Ditto.
* platform/MediaCapabilitiesInfo.h: Ditto.
* platform/cocoa/SystemBattery.h: Ditto.
* platform/graphics/DecodingOptions.h: Ditto.
* platform/graphics/DestinationColorSpace.h: Ditto.
* platform/graphics/DisplayRefreshMonitorClient.h: Ditto.
* platform/graphics/FloatLine.h: Ditto.
* platform/graphics/gpu/GPURequestAdapterOptions.h: Ditto.
* platform/graphics/x11/PlatformDisplayX11.h: Ditto.
* platform/ios/SelectionGeometry.h: Ditto.
* platform/mac/NSScrollerImpDetails.h: Ditto.
* platform/network/DNS.h: Ditto.
* platform/text/EncodingTables.h: Ditto.
* platform/text/TextCodecCJK.h: Ditto.
* platform/text/TextCodecUTF16.h: Ditto.
* platform/text/TextFlags.h: Ditto.

Source/WebCore/PAL:

* pal/SessionID.h: Include <optional>.
* pal/crypto/gcrypt/Utilities.h: Ditto.
* pal/crypto/tasn1/Utilities.cpp: Removed include of <wtf/Optional.h>.

Source/WebDriver:

* SessionHost.h: Removed include of <wtf/Optional.h>.

Source/WebKit:

* <many files>: Removed include of <wtf/Optional.h>.

Source/WebKitLegacy/mac:

* DOM/DOMRangeInternal.h: Added import of <optional>.
* WebView/WebGeolocationPosition.mm: Removed import of <wtf/Optional.h>.
* WebView/WebGeolocationPositionInternal.h: Added import of <optional>.

Source/WTF:

* <many files>: Removed include of <wtf/Optional.h>.

* WTF.xcodeproj/project.pbxproj: Removed Optional.h.

* wtf/Markable.h: Added include of <optional>.
* wtf/OptionSet.h: Ditto.

* wtf/Optional.h: Emptied this file. On the Windows build system, we can't
seem to build successfully without an empty file here. The copied forwarding
header seems to linger even if we remove the original. Until we fix the
Windows build system, if we want to support incremental builds, we need
to keep this empty file around.

* wtf/PrintStream.h: Added include of <optional>.
* wtf/Seconds.h: Ditto.
* wtf/StackTrace.h: Ditto.

* wtf/StdLibExtras.h: Moved the valueOrCompute function here from Optional.h.
Re-sorted the "using" at the bottom of the file.

* wtf/URLHelpers.h: Added include of <optional>.
* wtf/Vector.h: Ditto.

Tools:

* <many files>: Removed include of <wtf/Optional.h>.


Canonical link: https://commits.webkit.org/238372@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278340 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-02 06:45:51 +00:00
Chris Dumez 22838249ce Rename Checked::unsafeGet() to Checked::value()
https://bugs.webkit.org/show_bug.cgi?id=226514

Reviewed by Darin Adler.

Rename Checked::unsafeGet() to Checked::value(). The "unsafeGet" naming is confusing as this
function isn't really unsafe since it will crash if the value has overflowed. Also add an
`operator T()` to implicitly convert a Checked to its underlying type without needing to
call value().

Source/JavaScriptCore:

* b3/B3Const32Value.cpp:
(JSC::B3::Const32Value::checkAddConstant const):
(JSC::B3::Const32Value::checkSubConstant const):
(JSC::B3::Const32Value::checkMulConstant const):
* b3/B3Const64Value.cpp:
(JSC::B3::Const64Value::checkAddConstant const):
(JSC::B3::Const64Value::checkSubConstant const):
(JSC::B3::Const64Value::checkMulConstant const):
* bytecompiler/BytecodeGenerator.h:
(JSC::FinallyContext::numberOfBreaksOrContinues const):
* dfg/DFGConstantFoldingPhase.cpp:
(JSC::DFG::ConstantFoldingPhase::foldConstants):
* dfg/DFGOperations.cpp:
(JSC::DFG::JSC_DEFINE_JIT_OPERATION):
* ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::compileNewArrayWithSpread):
(JSC::FTL::DFG::LowerDFGToB3::compileSpread):
(JSC::FTL::DFG::LowerDFGToB3::compileCallOrConstructVarargsSpread):
(JSC::FTL::DFG::LowerDFGToB3::compileForwardVarargsWithSpread):
* ftl/FTLOperations.cpp:
(JSC::FTL::JSC_DEFINE_JIT_OPERATION):
* heap/Heap.cpp:
(JSC::Heap::deprecatedReportExtraMemorySlowCase):
(JSC::Heap::extraMemorySize):
(JSC::Heap::updateAllocationLimits):
(JSC::Heap::reportExtraMemoryVisited):
* heap/SlotVisitor.cpp:
(JSC::SlotVisitor::propagateExternalMemoryVisitedIfNecessary):
* runtime/ArgList.cpp:
(JSC::MarkedArgumentBuffer::slowEnsureCapacity):
(JSC::MarkedArgumentBuffer::expandCapacity):
* runtime/ArrayPrototype.cpp:
(JSC::concatAppendOne):
(JSC::JSC_DEFINE_HOST_FUNCTION):
* runtime/CommonSlowPaths.cpp:
(JSC::JSC_DEFINE_COMMON_SLOW_PATH):
* runtime/DirectArguments.h:
* runtime/HashMapImpl.h:
(JSC::HashMapBuffer::allocationSize):
(JSC::HashMapImpl::HashMapImpl):
* runtime/HashMapImplInlines.h:
(JSC::nextCapacity):
(JSC::HashMapImpl<HashMapBucketType>::finishCreation):
* runtime/JSBigInt.cpp:
(JSC::JSBigInt::parseInt):
* runtime/JSImmutableButterfly.h:
(JSC::JSImmutableButterfly::tryCreate):
* runtime/JSLexicalEnvironment.h:
(JSC::JSLexicalEnvironment::offsetOfVariable):
(JSC::JSLexicalEnvironment::allocationSizeForScopeSize):
* runtime/JSObject.h:
* runtime/JSPropertyNameEnumerator.cpp:
(JSC::JSPropertyNameEnumerator::create):
* runtime/JSString.h:
* runtime/ScopedArguments.cpp:
(JSC::ScopedArguments::createUninitialized):
* runtime/StringPrototype.cpp:
(JSC::jsSpliceSubstrings):
(JSC::jsSpliceSubstringsWithSeparators):
* runtime/StructureChain.cpp:
(JSC::StructureChain::create):
* runtime/VM.h:
(JSC::ScratchBuffer::allocationSize):
* runtime/WeakMapImpl.h:
(JSC::WeakMapBuffer::allocationSize):
* wasm/WasmAirIRGenerator.cpp:
(JSC::Wasm::AirIRGenerator::AirIRGenerator):
(JSC::Wasm::AirIRGenerator::emitCallPatchpoint):
* wasm/WasmB3IRGenerator.cpp:
(JSC::Wasm::B3IRGenerator::B3IRGenerator):
* wasm/WasmInstance.cpp:
* wasm/WasmInstance.h:
(JSC::Wasm::Instance::allocationSize):
* wasm/WasmLLIntGenerator.cpp:
(JSC::Wasm::LLIntGenerator::push):
(JSC::Wasm::LLIntGenerator::getDropKeepCount):
(JSC::Wasm::LLIntGenerator::walkExpressionStack):
(JSC::Wasm::LLIntGenerator::finalize):
(JSC::Wasm::LLIntGenerator::callInformationForCaller):
(JSC::Wasm::LLIntGenerator::addLoop):
(JSC::Wasm::LLIntGenerator::addTopLevel):
(JSC::Wasm::LLIntGenerator::addBlock):
(JSC::Wasm::LLIntGenerator::addIf):
(JSC::Wasm::LLIntGenerator::addElseToUnreachable):
* wasm/WasmSignature.h:
(JSC::Wasm::Signature::allocatedSize):
* wasm/WasmStreamingParser.cpp:
(JSC::Wasm::StreamingParser::addBytes):
* wasm/WasmTable.cpp:
(JSC::Wasm::Table::Table):
(JSC::Wasm::Table::grow):
(JSC::Wasm::FuncRefTable::FuncRefTable):
* yarr/YarrInterpreter.cpp:
(JSC::Yarr::Interpreter::DisjunctionContext::allocationSize):
(JSC::Yarr::Interpreter::ParenthesesDisjunctionContext::allocationSize):
(JSC::Yarr::Interpreter::allocParenthesesDisjunctionContext):
(JSC::Yarr::ByteCompiler::atomCharacterClass):
(JSC::Yarr::ByteCompiler::atomBackReference):
(JSC::Yarr::ByteCompiler::atomParentheticalAssertionEnd):
(JSC::Yarr::ByteCompiler::atomParenthesesSubpatternEnd):
(JSC::Yarr::ByteCompiler::atomParenthesesOnceEnd):
(JSC::Yarr::ByteCompiler::atomParenthesesTerminalEnd):
(JSC::Yarr::ByteCompiler::emitDisjunction):
* yarr/YarrInterpreter.h:
(JSC::Yarr::ByteTerm::ByteTerm):
(JSC::Yarr::ByteTerm::CheckInput):
(JSC::Yarr::ByteTerm::UncheckInput):
* yarr/YarrJIT.cpp:
* yarr/YarrParser.h:
(JSC::Yarr::Parser::consumeNumber):
* yarr/YarrPattern.cpp:
(JSC::Yarr::PatternTerm::dumpQuantifier):

Source/WebCore:

* bindings/js/SerializedScriptValue.cpp:
(WebCore::CloneDeserializer::readTerminal):
* dom/TextEncoderStreamEncoder.cpp:
(WebCore::TextEncoderStreamEncoder::encode):
* editing/markup.cpp:
(WebCore::StyledMarkupAccumulator::takeResults):
* html/FileInputType.cpp:
(WebCore::FileInputType::saveFormControlState const):
* html/ImageData.cpp:
(WebCore::ImageData::create):
(WebCore::ImageData::createUninitialized):
* html/MediaElementSession.cpp:
(WebCore::isElementRectMostlyInMainFrame):
* html/canvas/WebGL2RenderingContext.cpp:
(WebCore::WebGL2RenderingContext::sliceArrayBufferView):
(WebCore::WebGL2RenderingContext::copyBufferSubData):
(WebCore::WebGL2RenderingContext::getBufferSubData):
(WebCore::WebGL2RenderingContext::validateClearBuffer):
* html/canvas/WebGLBuffer.cpp:
(WebCore::WebGLBuffer::associateBufferSubDataImpl):
(WebCore::WebGLBuffer::associateCopyBufferSubData):
* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::clip2D):
(WebCore::WebGLRenderingContextBase::validateDrawArrays):
(WebCore::WebGLRenderingContextBase::validateDrawElements):
(WebCore::WebGLRenderingContextBase::validateTexFuncData):
(WebCore::WebGLRenderingContextBase::validateCompressedTexFuncData):
(WebCore::WebGLRenderingContextBase::validateSimulatedVertexAttrib0):
* html/canvas/WebGLRenderingContextBase.h:
(WebCore::WebGLRenderingContextBase::validateTexImageSubRectangle):
(WebCore::WebGLRenderingContextBase::checkedAddAndMultiply):
* page/FrameView.h:
(WebCore::FrameView::incrementVisuallyNonEmptyPixelCount):
* page/History.cpp:
(WebCore::History::stateObjectAdded):
* platform/audio/AudioArray.h:
(WebCore::AudioArray::resize):
* platform/audio/cocoa/AudioFileReaderCocoa.cpp:
(WebCore::tryCreateAudioBufferList):
* platform/audio/cocoa/CARingBuffer.cpp:
(WebCore::CARingBuffer::adoptStorage):
(WebCore::CARingBuffer::initializeAfterAllocation):
(WebCore::CARingBuffer::allocate):
* platform/audio/cocoa/WebAudioBufferList.cpp:
(WebCore::WebAudioBufferList::WebAudioBufferList):
* platform/graphics/FormatConverter.h:
(WebCore::FormatConverter::FormatConverter):
* platform/graphics/GraphicsContextGL.cpp:
(WebCore::GraphicsContextGL::computeImageSizeInBytes):
* platform/graphics/ImageBackingStore.h:
(WebCore::ImageBackingStore::setSize):
(WebCore::ImageBackingStore::clear):
* platform/graphics/ImageBufferBackend.cpp:
(WebCore::ImageBufferBackend::calculateMemoryCost):
* platform/graphics/ImageFrame.h:
(WebCore::ImageFrame::frameBytes const):
* platform/graphics/ImageSource.cpp:
(WebCore::ImageSource::maximumSubsamplingLevel):
* platform/graphics/PixelBuffer.cpp:
(WebCore::PixelBuffer::tryCreateForDecoding):
(WebCore::PixelBuffer::tryCreate):
* platform/graphics/PixelBuffer.h:
(WebCore::PixelBuffer::encode const):
(WebCore::PixelBuffer::decode):
* platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm:
(WebCore::ImageDecoderAVFObjC::frameBytesAtIndex const):
* platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm:
(WebCore::MediaSampleAVFObjC::setByteRangeOffset):
(WebCore::MediaSampleAVFObjC::byteRangeForAttachment const):
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::updateBackdropFilters):
* platform/graphics/ca/LayerPool.cpp:
(WebCore::LayerPool::backingStoreBytesForSize):
* platform/graphics/cg/GraphicsContextGLCG.cpp:
(WebCore::GraphicsContextGLImageExtractor::extractImage):
* platform/graphics/cg/ImageBufferCGBackend.cpp:
(WebCore::ImageBufferCGBackend::calculateBytesPerRow):
* platform/graphics/cg/ImageDecoderCG.cpp:
(WebCore::ImageDecoderCG::frameBytesAtIndex const):
* platform/graphics/cocoa/SourceBufferParser.cpp:
(WebCore::SourceBufferParser::Segment::read const):
* platform/graphics/filters/FEColorMatrix.cpp:
(WebCore::effectApplyAccelerated):
* platform/graphics/filters/FEGaussianBlur.cpp:
(WebCore::FEGaussianBlur::platformApplySoftware):
* platform/graphics/filters/FETurbulence.cpp:
(WebCore::FETurbulence::platformApplySoftware):
* platform/graphics/filters/FilterEffect.cpp:
(WebCore::FilterEffect::unmultipliedResult):
(WebCore::FilterEffect::premultipliedResult):
(WebCore::copyPremultiplyingAlpha):
(WebCore::copyUnpremultiplyingAlpha):
* platform/graphics/gpu/cocoa/GPUBindGroupAllocatorMetal.mm:
(WebCore::GPUBindGroupAllocator::allocateAndSetEncoders):
(WebCore::GPUBindGroupAllocator::reallocate):
* platform/graphics/gpu/cocoa/GPUCommandBufferMetal.mm:
(WebCore::GPUCommandBuffer::copyBufferToBuffer):
* platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm:
(WebCore::GPURenderPassEncoder::drawIndexed):
* platform/graphics/gstreamer/ImageDecoderGStreamer.cpp:
(WebCore::ImageDecoderGStreamer::frameBytesAtIndex const):
* platform/graphics/nicosia/NicosiaBuffer.cpp:
(Nicosia::Buffer::Buffer):
* platform/graphics/win/Direct2DUtilities.cpp:
(WebCore::Direct2D::createDirect2DImageSurfaceWithData):
* platform/graphics/win/ImageBufferDirect2DBackend.cpp:
(WebCore::ImageBufferDirect2DBackend::compatibleBitmap):
* platform/graphics/win/ImageDecoderDirect2D.cpp:
(WebCore::ImageDecoderDirect2D::frameBytesAtIndex const):
* platform/image-decoders/ScalableImageDecoder.cpp:
(WebCore::ScalableImageDecoder::frameBytesAtIndex const):
* platform/image-decoders/jpeg2000/JPEG2000ImageDecoder.cpp:
(WebCore::sycc444ToRGB):
(WebCore::sycc422ToRGB):
(WebCore::sycc420ToRGB):
* platform/ios/LegacyTileLayerPool.mm:
(WebCore::LegacyTileLayerPool::bytesBackingLayerWithPixelSize):
* platform/text/TextCodecUTF16.cpp:
(WebCore::TextCodecUTF16::encode const):
* platform/text/TextCodecUTF8.cpp:
(WebCore::TextCodecUTF8::encodeUTF8):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::requiresCompositingForCanvas const):
* rendering/shapes/Shape.cpp:
(WebCore::Shape::createRasterShape):
* storage/StorageMap.cpp:
(WebCore::StorageMap::setItem):
* xml/XSLStyleSheetLibxslt.cpp:
(WebCore::XSLStyleSheet::parseString):
* xml/XSLTProcessorLibxslt.cpp:
(WebCore::xsltParamArrayFromParameterMap):
* xml/parser/CharacterReferenceParserInlines.h:
(WebCore::consumeCharacterReference):

Source/WebKit:

* GPUProcess/graphics/RemoteRenderingBackend.cpp:
(WebKit::RemoteRenderingBackend::nextDestinationImageBufferAfterApplyingDisplayLists):
* NetworkProcess/WebStorage/LocalStorageDatabase.cpp:
(WebKit::LocalStorageDatabase::setItem):
* NetworkProcess/cache/CacheStorageEngineCache.cpp:
(WebKit::CacheStorage::Cache::put):
* Platform/IPC/ArgumentCoders.h:
* Platform/IPC/cocoa/ConnectionCocoa.mm:
(IPC::Connection::sendOutgoingMessage):
(IPC::createMessageDecoder):
* Platform/IPC/cocoa/MachMessage.cpp:
(IPC::MachMessage::create):
* Shared/ShareableBitmap.cpp:
(WebKit::ShareableBitmap::Handle::encode const):
(WebKit::ShareableBitmap::create):
(WebKit::ShareableBitmap::createShareable):
* Shared/ShareableBitmap.h:
(WebKit::ShareableBitmap::bytesPerRow const):
(WebKit::ShareableBitmap::sizeInBytes const):
* Shared/ShareableResource.cpp:
(WebKit::ShareableResource::create):
* Shared/cg/ShareableBitmapCG.cpp:
(WebKit::ShareableBitmap::calculateBytesPerRow):
(WebKit::ShareableBitmap::createGraphicsContext):
(WebKit::ShareableBitmap::createCGImage const):
* Shared/mac/MediaFormatReader/MediaFormatReader.cpp:
(WebKit::MediaFormatReader::copyTrackArray):
* Shared/mac/MediaFormatReader/MediaSampleCursor.cpp:
(WebKit::MediaSampleCursor::copySampleLocation const):
* WebProcess/GPU/graphics/DisplayListWriterHandle.cpp:
(WebKit::DisplayListWriterHandle::advance):
* WebProcess/GPU/graphics/ImageBufferShareableBitmapBackend.cpp:
(WebKit::ImageBufferShareableBitmapBackend::calculateBytesPerRow):
* WebProcess/GPU/media/RemoteImageDecoderAVF.cpp:
(WebKit::RemoteImageDecoderAVF::frameBytesAtIndex const):
* WebProcess/Network/WebSocketChannel.cpp:
(WebKit::WebSocketChannel::increaseBufferedAmount):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::requestEvasionRectsAboveSelection):
(WebKit::WebPage::updateSelectionWithDelta):

Source/WTF:

* wtf/CheckedArithmetic.h:
(WTF::Checked::operator! const):
(WTF::Checked::operator bool const):
(WTF::Checked::operator T const):
(WTF::Checked::value const):
(WTF::Checked::operator==):
(WTF::Checked::operator< const):
(WTF::Checked::operator<= const):
(WTF::Checked::operator> const):
(WTF::Checked::operator>= const):
* wtf/ConcurrentBuffer.h:
* wtf/FastMalloc.cpp:
(WTF::fastCalloc):
(WTF::tryFastCalloc):
* wtf/Gigacage.cpp:
(Gigacage::tryMallocArray):
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::userVisibleURL):
* wtf/URLParser.cpp:
(WTF::URLParser::parseIPv4Piece):
* wtf/UniqueArray.h:
* wtf/cocoa/NSURLExtras.mm:
(WTF::dataWithUserTypedString):
* wtf/glib/SocketConnection.cpp:
(WTF::SocketConnection::readMessage):
(WTF::SocketConnection::sendMessage):
* wtf/text/CString.cpp:
(WTF::CStringBuffer::createUninitialized):
* wtf/text/StringBuffer.h:
(WTF::StringBuffer::StringBuffer):
* wtf/text/StringBuilderJSON.cpp:
(WTF::StringBuilder::appendQuotedJSONString):
* wtf/text/StringConcatenate.h:
(WTF::tryMakeStringFromAdapters):
* wtf/text/StringImpl.h:
(WTF::StringImpl::allocationSize):
* wtf/text/StringToIntegerConversion.h:
(WTF::parseInteger):

Tools:

* TestWebKitAPI/Tests/WTF/CheckedArithmeticOperations.cpp:
(TestWebKitAPI::CheckedArithmeticTester::run):
(TestWebKitAPI::AllowMixedSignednessTest::run):
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebCore/IntRectTests.cpp:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebCore/IntSizeTests.cpp:
(TestWebKitAPI::TEST):


Canonical link: https://commits.webkit.org/238371@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278338 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-02 05:21:13 +00:00
Darin Adler e98ff129bc Remove WTF::Optional synonym for std::optional, using that class template directly instead
https://bugs.webkit.org/show_bug.cgi?id=226433

Reviewed by Chris Dumez.

Source/JavaScriptCore:

* <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>.

* inspector/scripts/codegen/generate_objc_protocol_types_implementation.py:
(ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead
of Optional<>. Also use * instead of value() and nest the definition of the local inside an if
statement in the case where it's an optional.

* inspector/scripts/tests/expected/*: Regenerated these results.

Source/WebCore:

* <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>.

Source/WebCore/PAL:

* <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>.

Source/WebDriver:

* <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>.

Source/WebKit:

* <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>.

* Scripts/webkit/tests: Regenerated expected results, by running the command "python
Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?)

Source/WebKitLegacy/ios:

* WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename
Optional<> to std::optional<>.

Source/WebKitLegacy/mac:

* <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>.

Source/WebKitLegacy/win:

* <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>.

Source/WTF:

* <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>.

* wtf/Optional.h: Remove WTF::Optional.

Tools:

* <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>.


Canonical link: https://commits.webkit.org/238290@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
Darin Adler 695e0888fe Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280

Reviewed by Chris Dumez.

Source/JavaScriptCore:

* <many files>: Accept the renaming done by do-webcore-rename.

* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.

Source/WebCore:

* <many files>: Accept the renaming done by do-webcore-rename.

* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.

* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.

Source/WebCore/PAL:

* <many files>: Accept the renaming done by do-webcore-rename.

Source/WebDriver:

* <many files>: Accept the renaming done by do-webcore-rename.

Source/WebKit:

* <many files>: Accept the renaming done by do-webcore-rename.

Source/WebKitLegacy:

* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.

Source/WebKitLegacy/mac:

* <many files>: Accept the renaming done by do-webcore-rename.

Source/WebKitLegacy/win:

* <many files>: Accept the renaming done by do-webcore-rename.

Source/WTF:

* <many files>: Accept the renaming done by do-webcore-rename.

* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.

* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.

Tools:

* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.

* <many files>: Accept the renaming done by do-webcore-rename.

Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
Chris Dumez d3e3088169 Leverage the new Vector(const T*, size_t) constructor
https://bugs.webkit.org/show_bug.cgi?id=226304

Reviewed by Darin Adler.

Leverage the new Vector(const T*, size_t) constructor in existing code.

Source/JavaScriptCore:

* wasm/WasmStreamingParser.cpp:
(JSC::Wasm::StreamingParser::consume):

Source/WebCore:

* Modules/fetch/FetchBodyConsumer.cpp:
(WebCore::blobFromData):
* Modules/indexeddb/IDBGetResult.cpp:
(WebCore::IDBGetResult::dataFromBuffer):
* Modules/webauthn/WebAuthenticationUtils.cpp:
(WebCore::convertBytesToVector):
* Modules/webauthn/fido/DeviceResponseConverter.cpp:
(fido::decodeResponseMap):
* Modules/webauthn/fido/FidoHidPacket.cpp:
(fido::FidoHidInitPacket::createFromSerializedData):
(fido::FidoHidContinuationPacket::createFromSerializedData):
* Modules/webauthn/fido/Pin.cpp:
(fido::pin::encodeCOSEPublicKey):
* Modules/webauthn/fido/U2fResponseConverter.cpp:
(fido::WebCore::extractECPublicKeyFromU2fRegistrationResponse):
(fido::WebCore::extractCredentialIdFromU2fRegistrationResponse):
(fido::WebCore::createFidoAttestationStatementFromU2fRegisterResponse):
(fido::readU2fSignResponse):
* Modules/websockets/WebSocketChannel.cpp:
(WebCore::WebSocketChannel::enqueueRawFrame):
* crypto/SubtleCrypto.cpp:
(WebCore::toKeyData):
(WebCore::copyToVector):
* crypto/gcrypt/CryptoKeyECGCrypt.cpp:
(WebCore::CryptoKeyEC::platformAddFieldElements const):
* crypto/mac/CryptoKeyECMac.cpp:
(WebCore::CryptoKeyEC::platformImportPkcs8):
* crypto/mac/SerializedCryptoKeyWrapMac.mm:
(WebCore::vectorFromNSData):
* crypto/openssl/CryptoAlgorithmAES_GCMOpenSSL.cpp:
(WebCore::cryptDecrypt):
* fileapi/Blob.cpp:
(WebCore::Blob::Blob):
* platform/graphics/ImageBackingStore.h:
(WebCore::ImageBackingStore::ImageBackingStore):
* platform/graphics/cairo/ImageBufferUtilitiesCairo.cpp:
(WebCore::data):
* platform/graphics/gstreamer/GStreamerCommon.cpp:
(WebCore::GstMappedBuffer::createVector const):
* platform/graphics/gstreamer/eme/CDMProxyClearKey.cpp:
(WebCore::CDMProxyClearKey::cencSetDecryptionKey):
* platform/mediarecorder/MediaRecorderPrivateMock.cpp:
(WebCore::MediaRecorderPrivateMock::fetchData):
* platform/network/FormData.cpp:
(WebCore::FormDataElement::isolatedCopy const):
(WebCore::FormData::appendData):
* platform/network/curl/OpenSSLHelper.cpp:
(OpenSSL::BIO::getDataAsVector const):
* testing/Internals.cpp:
(WebCore::Internals::deserializeBuffer const):
* xml/parser/XMLDocumentParserLibxml2.cpp:
(WebCore::openFunc):

Source/WebCore/PAL:

* pal/crypto/gcrypt/CryptoDigestGCrypt.cpp:
(PAL::CryptoDigest::computeHash):

Source/WebKit:

* Platform/IPC/ArrayReference.h:
(IPC::ArrayReference::vector const):
* UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm:
(vectorFromNSData):
* UIProcess/API/glib/IconDatabase.cpp:
(WebKit::IconDatabase::setIconForPageURL):
* UIProcess/Cocoa/SOAuthorization/SubFrameSOAuthorizationSession.mm:
(WebKit::WebCore::convertBytesToVector):
* UIProcess/Inspector/WebInspectorUIExtensionControllerProxy.cpp:
(WebKit::WebInspectorUIExtensionControllerProxy::evaluateScriptForExtension):
* UIProcess/WebAuthentication/Cocoa/HidConnection.mm:
(WebKit::reportReceived):
* UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm:
(WebKit::LocalAuthenticatorInternal::toVector):
(WebKit::LocalAuthenticatorInternal::aaguidVector):
* UIProcess/WebAuthentication/Cocoa/NfcConnection.mm:
(WebKit::NfcConnection::transact const):
* UIProcess/WebURLSchemeTask.cpp:
(WebKit::WebURLSchemeTask::didComplete):
* WebProcess/WebPage/WebURLSchemeTaskProxy.cpp:
(WebKit::WebURLSchemeTaskProxy::didReceiveData):

Source/WTF:

* wtf/text/WTFString.cpp:
(asciiDebug):


Canonical link: https://commits.webkit.org/238190@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278146 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-27 03:17:27 +00:00
Adrien Destugues 8fe7de1f76 Merge commit '17e4ef947b901efe5b83003cb46fb9b6b67227c3' into Haiku branch 2021-05-25 20:01:40 +02:00
Darin Adler 4d78e56eb5 Remove StringBuilder::appendLiteral
https://bugs.webkit.org/show_bug.cgi?id=226137

Reviewed by Chris Dumez.

Source/JavaScriptCore:

* API/tests/PingPongStackOverflowTest.cpp:
(PingPongStackOverflowObject_hasInstance): Use append instead of appendLiteral.

* bindings/ScriptFunctionCall.cpp:
(Deprecated::ScriptCallArgumentHandler::appendArgument): Remove unnecessary cast
from const char* to String, which defeats optimization and has no benefit.

* bytecompiler/NodesCodegen.cpp:
(JSC::ArrayPatternNode::toString const): Use append instead of appendLiteral.
(JSC::RestParameterNode::toString const): Ditto.

* heap/HeapSnapshotBuilder.cpp:
(JSC::HeapSnapshotBuilder::json): Use append instead of appendLiteral.
Removed unnecesary use of appendQuotedJSONString to append the result of
snapshotTypeToString and edgeTypeToString, which return a const char* that
never contains characters that require special quoting consideration, so
can be appended efficiently with the normal append function.

* inspector/agents/InspectorAuditAgent.cpp:
(Inspector::InspectorAuditAgent::run): Use makeString instead of StringBuilder.

* inspector/agents/InspectorConsoleAgent.cpp: Use auto for the result of makeString.

* jsc.cpp: Use appned instead of appendLiteral.

* parser/ParserArena.cpp:
(JSC::IdentifierArena::makePrivateIdentifier): Use auto for the result of makeString.

* runtime/ConsoleClient.cpp:
(JSC::ConsoleClient::printConsoleMessage): Use append instead of appendLiteral.
Also use variadic append when practical for better efficiency.
(JSC::ConsoleClient::printConsoleMessageWithArguments): Ditto.
* runtime/DateConversion.cpp:
(JSC::formatDateTime): Ditto.

* runtime/ErrorInstance.cpp:
(JSC::ErrorInstance::sanitizedToString): Use makeString instead of StringBuilder.

* runtime/ExceptionHelpers.cpp:
(JSC::notAFunctionSourceAppender): Use append instead of appendLiteral.
* runtime/IntlDateTimeFormat.cpp:
(JSC::IntlDateTimeFormat::initializeDateTimeFormat): Ditto.
* runtime/IntlNumberFormat.cpp:
(JSC::IntlNumberFormat::initializeNumberFormat): Ditto.

* runtime/JSCustomGetterFunction.cpp:
(JSC::JSCustomGetterFunction::create): Use auto and cut down on reference count
churn by using passing the StringImpl to makeString.
* runtime/JSCustomSetterFunction.cpp:
(JSC::JSCustomSetterFunction::create): Ditto.

* runtime/JSGlobalObjectFunctions.cpp: Use more const and use variadic
append for better efficiency.

* runtime/JSONObject.cpp:
(JSC::Stringifier::appendStringifiedValue): Use append instead of appendLiteral.
(JSC::Stringifier::Holder::appendNextProperty): Ditto.

* runtime/JSStringJoiner.h: Deleted unused appendLiteral function.
Unrelated to StringBuilder::appendLiteral, but dead code.

* runtime/Options.cpp:
(JSC::Options::dumpOption): Use append instead of appendLiteral.
* runtime/RegExpPrototype.cpp:
(JSC::appendLineTerminatorEscape<UChar>): Ditto.

* runtime/SamplingProfiler.cpp:
(JSC::SamplingProfiler::reportTopFunctions): Use auto for the result of makeString.
(JSC::SamplingProfiler::reportTopBytecodes): Ditto.

* runtime/TypeProfiler.cpp:
(JSC::TypeProfiler::typeInformationForExpressionAtOffset): Use append instead of
appendLiteral.

* runtime/TypeSet.cpp:
(JSC::TypeSet::dumpTypes const): Use append instead of appendLiteral.
(JSC::TypeSet::toJSONString const): Ditto.
(JSC::StructureShape::propertyHash): Ditto.
(JSC::StructureShape::toJSONString const): Ditto.

Source/WebCore:

* Modules/fetch/FetchBodyConsumer.cpp:
(WebCore::packageFormData): Use auto for the result of makeString.

* Modules/indexeddb/IDBKeyData.cpp:
(WebCore::IDBKeyData::loggingString const): Use append instead
of appendLiteral.

* Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
(WebCore::IDBServer::SQLiteIDBBackingStore::addRecord): Use auto
for the result of makeString.

* Modules/indexeddb/server/SQLiteIDBCursor.cpp:
(WebCore::IDBServer::buildPreIndexStatement): Use makeString
instead of StringBuilder.
(WebCore::IDBServer::buildIndexStatement): Ditto.
(WebCore::IDBServer::buildObjectStoreStatement): Ditto.

* Modules/websockets/WebSocket.cpp:
(WebCore::encodeProtocolString): Use append instead of appendLiteral.
* Modules/websockets/WebSocketExtensionDispatcher.cpp:
(WebCore::WebSocketExtensionDispatcher::appendAcceptedExtension): Ditto.

* Modules/websockets/WebSocketHandshake.cpp:
(WebCore::WebSocketHandshake::clientHandshakeMessage const): Use
makeString instead of StringBuilder.
(WebCore::WebSocketHandshake::clientHandshakeRequest const): Tweak
to match the function above more closely, and use ASCIILiteral.

* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(formatForDebugger): Use makeString instead of StringBuilder.

* contentextensions/CombinedURLFilters.cpp:
(WebCore::ContentExtensions::prefixTreeVertexToString): Use
append instead of appendLiteral.
* css/CSSBasicShapes.cpp:
(WebCore::buildCircleString): Ditto.
(WebCore::buildEllipseString): Ditto.
(WebCore::buildPathString): Ditto.
(WebCore::buildPolygonString): Ditto.
(WebCore::buildInsetString): Ditto.
* css/CSSGradientValue.cpp:
(WebCore::CSSLinearGradientValue::customCSSText const): Ditto.
(WebCore::CSSRadialGradientValue::customCSSText const): Ditto.
(WebCore::CSSConicGradientValue::customCSSText const): Ditto.

* css/CSSGridIntegerRepeatValue.cpp:
(WebCore::CSSGridIntegerRepeatValue::customCSSText const):
Use makeString instead of StringBuilder.

* css/CSSImageSetValue.cpp:
(WebCore::CSSImageSetValue::customCSSText const): Use append
instead of appendLiteral.

* css/CSSImportRule.cpp:
(WebCore::CSSImportRule::cssText const): Use makeString instead
of StringBuilder.
* css/CSSKeyframeRule.cpp:
(WebCore::StyleRuleKeyframe::cssText const): Ditto.

* css/CSSKeyframesRule.cpp:
(WebCore::CSSKeyframesRule::cssText const): Use variadic append.

* css/CSSLineBoxContainValue.cpp:
(WebCore::CSSLineBoxContainValue::customCSSText const): Use
append instead of appendLiteral.
* css/CSSNamespaceRule.cpp:
(WebCore::CSSNamespaceRule::cssText const): Ditto.

* css/CSSPageRule.cpp:
(WebCore::CSSPageRule::cssText const): Use makeString instead of
StringBuilder.
* css/CSSPaintImageValue.cpp:
(WebCore::CSSPaintImageValue::customCSSText const): Ditto.

* css/CSSPrimitiveValue.cpp:
(WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText const):
Use append instead of appendLiteral.

* css/CSSSelector.cpp:
(WebCore::appendLangArgumentList): Use variadic append.
(WebCore::CSSSelector::selectorText const): Ditto. Also use
append instead of appendLiteral and make some improvements to
cut down on allocations a little.

* css/CSSSelectorList.cpp:
(WebCore::CSSSelectorList::buildSelectorsText const): Use
append instead of appendLiteral.

* css/CSSStyleSheet.cpp:
(WebCore::CSSStyleSheet::CSSStyleSheet): Moved more of the
data member initialization to the class definition.
(WebCore::CSSStyleSheet::addRule): Use makeString instead of
StringBuilder.
* css/CSSStyleSheet.h: Moved initialization here.

* css/CSSTimingFunctionValue.cpp:
(WebCore::CSSStepsTimingFunctionValue::customCSSText const):
Use makeString instead of StringBuilder.
(WebCore::CSSSpringTimingFunctionValue::customCSSText const):
Ditto.

* css/MediaList.cpp:
(WebCore::MediaQuerySet::mediaText const): Use append instead
of appendLiteral.
* css/MediaQuery.cpp:
(WebCore::MediaQuery::serialize const): Ditto.

* css/MediaQueryExpression.cpp:
(WebCore::MediaQueryExpression::serialize const): Use makeString
instead of StringBuilder.

* css/StyleProperties.cpp:
(WebCore::StyleProperties::getLayeredShorthandValue const):
Use append instead of appendLiteral.

* css/parser/CSSParserToken.cpp:
(WebCore::CSSParserToken::serialize const): Removed a lot of
unnecessary braces. Use variadic append and append instead of appendLiteral.

* dom/Document.cpp:
(WebCore::Document::initSecurityContext): Use auto for the result
of makeString.

* dom/Element.cpp:
(WebCore::appendAttributes): Use variadic append and append
instead of appendLiteral.
* dom/SecurityContext.cpp:
(WebCore::SecurityContext::parseSandboxPolicy): Ditto.
* editing/HTMLInterchange.cpp:
(WebCore::convertHTMLTextToInterchangeFormat): Ditto.

* editing/TextIterator.cpp:
(WebCore::createSearcher): Use auto for the result of makeString.

* editing/markup.cpp:
(WebCore::StyledMarkupAccumulator::appendStyleNodeOpenTag):
Use append instead of appendLiteral.
(WebCore::StyledMarkupAccumulator::appendStartTag): Ditto.
(WebCore::urlToMarkup): Ditto.
* html/FormController.cpp:
(WebCore::recordFormStructure): Ditto.

* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::reportValidity): Use auto for
the result of makeString.
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::validateInteractively): Ditto.

* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::completeURLsInAttributeValue const):
Use append insteaed of appendLiteral.

* html/MediaElementSession.cpp:
(WebCore::restrictionNames): Use auto for the result of makeString.
* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::getUniformLocation): Ditto.
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::ExternalCharacterTokenBuffer::takeRemaining): Ditto.

* html/parser/XSSAuditorDelegate.cpp:
(WebCore::buildConsoleError): Use makeString instead of StringBuilder.
* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::rebuildDisplayTree): Ditto.

* inspector/InspectorFrontendAPIDispatcher.cpp:
(WebCore::expressionForEvaluatingCommand): Use append instead of appendLiteral.

* inspector/InspectorOverlay.cpp:
(WebCore::InspectorOverlay::drawElementTitle): Use auto for the result of makeString.

* inspector/InspectorStyleSheet.cpp:
(WebCore::InspectorStyleSheet::addRule): Use append instead of appendLiteral.

* inspector/agents/InspectorApplicationCacheAgent.cpp:
(WebCore::InspectorApplicationCacheAgent::buildObjectForApplicationCacheResource):
Use makeString instead of StringBuilder.

* inspector/agents/WebConsoleAgent.cpp:
(WebCore::WebConsoleAgent::didReceiveResponse): Use auto for the result of makeString.
(WebCore::WebConsoleAgent::didFailLoading): Ditto.
* loader/MixedContentChecker.cpp:
(WebCore::logWarning): Ditto
(WebCore::MixedContentChecker::checkFormForMixedContent): Ditto

* loader/PrivateClickMeasurement.cpp:
(WebCore::makeValidURL): Added. Used for various cases below that all construct
URLs in the same way with the same kinds of checks. Use makeString here instead
of StringBuilder.
(WebCore::attributionReportURL): Call makeValidURL.
(WebCore::PrivateClickMeasurement::tokenSignatureURL const): Ditto.
(WebCore::PrivateClickMeasurement::tokenPublicKeyURL const): Ditto.

* loader/ResourceLoadStatistics.cpp:
(WebCore::appendBoolean): Use append instead of appendLiteral.
(WebCore::appendHashSet): Ditto.
(WebCore::appendNavigatorAPIOptionSet): Ditto.
(WebCore::appendScreenAPIOptionSet): Ditto.
(WebCore::ResourceLoadStatistics::toString const): Ditto.

* loader/WorkerThreadableLoader.cpp:
(WebCore::WorkerThreadableLoader::loadResourceSynchronously): Use auto for
the result of makeString.
* page/DOMWindow.cpp:
(WebCore::DOMWindow::postMessage): Ditto.

* page/Frame.cpp:
(WebCore::createRegExpForLabels): Use append instead of appendLiteral.
Also tweak coding style a bit.

* page/FrameView.cpp:
(WebCore::FrameView::logMockScrollAnimatorMessage const): Use makeString
instead of StringBuilder.

* page/PageSerializer.cpp:
(WebCore::PageSerializer::SerializerMarkupAccumulator::appendStartTag):
Use append instead of appendLiteral.
(WebCore::PageSerializer::serializeCSSStyleSheet): Ditto.
(WebCore::PageSerializer::urlForBlankFrame): Use auto for the result of
makeString.

* page/PerformanceLoggingClient.cpp:
(WebCore::PerformanceLoggingClient::synchronousScrollingReasonsAsString):
Use makeString instead of StringBuilder.

* page/cocoa/ResourceUsageOverlayCocoa.mm:
(WebCore::ResourceUsageOverlay::platformDraw): Use auto for the result of
makeString.

* page/csp/ContentSecurityPolicy.cpp:
(WebCore::consoleMessageForViolation): Use makeString instsead of StringBuilder.
(WebCore::ContentSecurityPolicy::allowRunningOrDisplayingInsecureContent): Ditto.
(WebCore::ContentSecurityPolicy::reportInvalidDirectiveValueCharacter const):
Get rid of local variable for result of makeString.
(WebCore::ContentSecurityPolicy::reportInvalidPathCharacter const): Ditto.
(WebCore::ContentSecurityPolicy::reportInvalidSourceExpression const): Ditto.

* page/csp/ContentSecurityPolicyDirectiveList.cpp:
(WebCore::ContentSecurityPolicyDirectiveList::create): Get rid of local
variable for result of makeString.

* page/scrolling/ScrollingCoordinator.cpp:
(WebCore::ScrollingCoordinator::synchronousScrollingReasonsAsText):
Use makeString instead of StringBulder.

* platform/Decimal.cpp:
(WebCore::Decimal::toString const): Use append instead of appendLiteral.

* platform/animation/TimingFunction.cpp:
(WebCore::TimingFunction::createFromCSSText): Use makeString instead
of StringBuilder.

* platform/audio/HRTFElevation.cpp:
(WebCore::HRTFElevation::calculateKernelsForAzimuthElevation): Use auto
for the result of makeString.

* platform/glib/UserAgentGLib.cpp:
(WebCore::buildUserAgentString): Use append instead of appendLiteral.

* platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp:
(WebCore::InbandTextTrackPrivateAVF::processCueAttributes): Use
append instead of appendLiteral.

* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::recursiveCommitChanges): Got rid of local
variable for result of makeString.
(WebCore::GraphicsLayerCA::appendToUncommittedAnimations): Use auto
for result of makeString.

* platform/graphics/ca/TileController.cpp:
(WebCore::TileController::tileRevalidationTimerFired): Update to
use OptionSet.

* platform/graphics/ca/TileGrid.cpp:
(WebCore::validationPolicyAsString): Use OptionSet.
(WebCore::TileGrid::setNeedsDisplayInRect): Use auto for iterator
and range-based for loop.
(WebCore::TileGrid::updateTileLayerProperties): Ditto.
(WebCore::TileGrid::blankPixelCount const): Ditto.
(WebCore::TileGrid::removeTiles): Use HashCountedSet.
(WebCore::TileGrid::revalidateTiles): Use OptionSet.
(WebCore::TileGrid::retainedTileBackingStoreMemory const): Use
ranged-based for loop.
(WebCore::TileGrid::drawTileMapContents const): Use range-based
for loop and use writeIntegerToBuffer instead of String::number.
(WebCore::TileGrid::platformCALayerRepaintCount const): Use
HashCountedSet.
(WebCore::TileGrid::platformCALayerIncrementRepaintCount): Ditto.
This cuts us down from 3 hash table lookups to 1.
(WebCore::TileGrid::removeUnparentedTilesNow): Removed local
variable to make code a little tighter.
* platform/graphics/ca/TileGrid.h: Use OptionSet and HashCountedSet.
Removed some type names.

* platform/graphics/ca/cocoa/PlatformCAFiltersCocoa.mm:
(WebCore::PlatformCAFilters::setFiltersOnLayer): Use auto for
reuslt of makeString.
* platform/mock/MockRealtimeVideoSource.cpp:
(WebCore::MockRealtimeVideoSource::drawText): Ditto.

* platform/mock/ScrollAnimatorMock.cpp:
(WebCore::ScrollAnimatorMock::scrollbarPrefix const): Added
helper function for use below.
(WebCore::ScrollAnimatorMock::mouseEnteredScrollbar const): Use
makeString instead of StringBuilder.
(WebCore::ScrollAnimatorMock::mouseExitedScrollbar const): Ditto.
(WebCore::ScrollAnimatorMock::mouseIsDownInScrollbar const): Ditto.
* platform/mock/ScrollAnimatorMock.h: Ditto.

* platform/network/ProxyServer.cpp:
(WebCore::appendProxyServerString): Use append instead of appendLiteral.
(WebCore::toString): Ditto.

* platform/network/ResourceResponseBase.cpp:
(WebCore::ResourceResponseBase::sanitizeSuggestedFilename): Get rid
of local variable with result of maekString in it.

* platform/playstation/UserAgentPlayStation.cpp:
(WebCore::platformForUAString): Deleted. No need for a global variable
to hold the result of something called only once.
(WebCore::platformVersionForUAString): Ditto.
(WebCore::buildUserAgentString): Deleted.
(WebCore::standardUserAgentStatic): Moved the logic from buildUserAgentString
here, using makeString instead of StringBuilder.

* platform/sql/SQLiteDatabase.cpp:
(WebCore::SQLiteDatabase::open): Use auto for result of makeString.
* platform/sql/SQLiteFileSystem.cpp:
(WebCore::SQLiteFileSystem::deleteDatabaseFile): Ditto.

* platform/text/DateTimeFormat.cpp:
(WebCore::DateTimeFormat::quoteAndAppendLiteral): Use append instead
of appendLiteral and StringView::substring instead of String::substring.

* platform/win/ClipboardUtilitiesWin.cpp:
(WebCore::replaceNewlinesWithWindowsStyleNewlines): Use append
instead of appendLiteral.

* platform/win/UserAgentWin.cpp:
(WebCore::standardUserAgent): Use makeString instead of StringBuildeer.
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::name const): Ditto.
(WebCore::RenderLayer::debugDescription const): Ditto.

* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::logLayerInfo): Use append instead of
appendLiteral.
* rendering/RenderTreeAsText.cpp:
(WebCore::quoteAndEscapeNonPrintables): Ditto.
(WebCore::nodePosition): Ditto.
* svg/SVGPathStringBuilder.cpp:
(WebCore::SVGPathStringBuilder::moveTo): Ditto.
(WebCore::SVGPathStringBuilder::lineTo): Ditto.
(WebCore::SVGPathStringBuilder::lineToHorizontal): Ditto.
(WebCore::SVGPathStringBuilder::lineToVertical): Ditto.
(WebCore::SVGPathStringBuilder::curveToCubic): Ditto.
(WebCore::SVGPathStringBuilder::curveToCubicSmooth): Ditto.
(WebCore::SVGPathStringBuilder::curveToQuadratic): Ditto.
(WebCore::SVGPathStringBuilder::curveToQuadraticSmooth): Ditto.
(WebCore::SVGPathStringBuilder::arcTo): Ditto.
(WebCore::SVGPathStringBuilder::closePath): Ditto.
* testing/Internals.cpp:
(WebCore::Internals::dumpMarkerRects): Ditto.
(WebCore::appendOffsets):
(WebCore::Internals::scrollSnapOffsets): Ditto.

* workers/WorkerScriptLoader.cpp:
(WebCore::WorkerScriptLoader::validateWorkerResponse): Use auto
for reuslt of makeString.

Source/WebKit:

* NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
(WebKit::ResourceLoadStatisticsDatabaseStore::ensureAndMakeDomainList): Use append
instead of appendLiteral.
(WebKit::domainsToString): Ditto.
(WebKit::buildList): Ditto.
(WebKit::ResourceLoadStatisticsDatabaseStore::findNotVeryPrevalentResources): Ditto.
(WebKit::ResourceLoadStatisticsDatabaseStore::dumpResourceLoadStatistics): Ditto.
(WebKit::appendBoolean): Ditto.
(WebKit::appendNextEntry): Ditto.
(WebKit::ResourceLoadStatisticsDatabaseStore::appendSubStatisticList const): Ditto.
(WebKit::ResourceLoadStatisticsDatabaseStore::resourceToString const): Ditto.
(WebKit::ResourceLoadStatisticsDatabaseStore::attributionToString): Ditto.
(WebKit::ResourceLoadStatisticsDatabaseStore::privateClickMeasurementToString): Ditto.
* NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
(WebKit::ResourceLoadStatisticsMemoryStore::dumpResourceLoadStatistics): Ditto.
* NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp: Ditto.
(WebKit::domainsToString): Ditto.

* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::create): Moved this here from the header.
(WebKit::WebResourceLoadStatisticsStore::ThirdPartyDataForSpecificFirstParty::toString const): Ditto.
(WebKit::WebResourceLoadStatisticsStore::ThirdPartyDataForSpecificFirstParty::encode const): Ditto.
(WebKit::WebResourceLoadStatisticsStore::ThirdPartyDataForSpecificFirstParty::decode): Ditto.
(WebKit::WebResourceLoadStatisticsStore::ThirdPartyDataForSpecificFirstParty::operator== const): Ditto.
(WebKit::WebResourceLoadStatisticsStore::ThirdPartyData::toString const): Ditto.
(WebKit::WebResourceLoadStatisticsStore::ThirdPartyData::encode const): Ditto.
(WebKit::WebResourceLoadStatisticsStore::ThirdPartyData::decode): Ditto.
(WebKit::WebResourceLoadStatisticsStore::ThirdPartyData::operator< const): Ditto.
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h: Moved member
functions of the nested structures into the implementation file and fixed
the indentation of the structures to indicate the nesting.

* NetworkProcess/NetworkLoadChecker.cpp:
(WebKit::NetworkLoadChecker::continueCheckingRequest): Do not use a local
variable for the reuslt of makeString.
* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::newTestingSession): Ditto.

* NetworkProcess/cache/NetworkCache.cpp:
(WebKit::NetworkCache::Cache::dumpContentsToFile): Use append instead of appendLiteral
* NetworkProcess/cache/NetworkCacheEntry.cpp:
(WebKit::NetworkCache::Entry::asJSON const): Ditto.

* NetworkProcess/cache/NetworkCacheStorage.cpp:
(WebKit::NetworkCache::makeVersionedDirectoryPath): Do not use a local variable for
the result of makeString.

* NetworkProcess/soup/NetworkProcessSoup.cpp:
(WebKit::buildAcceptLanguages): Use append instead of appendLiteral.
* NetworkProcess/soup/WebSocketTaskSoup.cpp:
(WebKit::WebSocketTask::acceptedExtensions const): Ditto.

* NetworkProcess/webrtc/NetworkMDNSRegister.cpp:
(WebKit::NetworkMDNSRegister::registerMDNSName): Use auto for the result of makeString.
* Shared/WebMemorySampler.cpp:
(WebKit::WebMemorySampler::writeHeaders): Ditto.

* Shared/mac/AuxiliaryProcessMac.mm:
(WebKit::initializeSandboxParameters): Do not use a local variable for the result of
makeString. Also, take advantage of the support for concatenating an NSString instead
of converting it to a WTF::String.

* Shared/mac/WebMemorySampler.mac.mm:
(WebKit::WebMemorySampler::sampleWebKit const): Use ASCIILiteral and remove explicit
conversion to String.

* UIProcess/API/glib/WebKitWebView.cpp:
(webkitWebViewRunJavaScriptCallback): Use append instead of appendLiteral.

* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::fileCanBeAcceptedForUpload): Use auto for result of makeString.

* WebProcess/InjectedBundle/API/glib/WebKitWebPage.cpp: Use makeString instead of
StringBuilder.

* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::requestStorageSpace): Use auto for result of makeString.

* UIProcess/WebBackForwardList.cpp:
(WebKit::WebBackForwardList::loggingString): Use append instead of appendLiteral.

* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::processDidFinishLaunching): Use auto for result of makeString.
(WebKit::WebProcessPool::startMemorySampler): Ditto.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::dumpHistoryItem): Use append instead of appendLiteral.
(WebKit::WebPage::getContentsAsString): Ditto.

Source/WebKitLegacy:

* WebCoreSupport/NetworkStorageSessionMap.cpp:
(NetworkStorageSessionMap::switchToNewTestingSession): Do not use local
for return value of makeString.

Source/WebKitLegacy/mac:

* WebView/WebHTMLRepresentation.mm:
(regExpForLabels): Use append instead of appendLiteral.
Also imrpove local variable names a bit.

Source/WebKitLegacy/win:

* AccessibleBase.cpp:
(AccessibleBase::get_accKeyboardShortcut): Use append instead of appnedLiteral.
* WebView.cpp: Ditto.

Source/WTF:

The optimization done by appendLiteral has minimal value and is something we
can do without. It does not cut down the number of allocations, which is the
main cost of the StringBuilder class. Getting rid of the differently named
appendLiteral improves the design of the StringBuilder class for callers.
Our goal is to get as close as possible to a single append function.

If we decide we need an optimization for literals, we can come up with a
different way that is compatible with append. For example, we could assume
that any char array is a literal and check that at compile time in
StringConcatenate; that optimization would work for both makeString and
StringBuilder. Or we could use a strategy like ASCIILiteral.

* wtf/FileSystem.cpp:
(WTF::FileSystemImpl::encodeForFileName): Streamline logic,
and use variadic append to make this more efficient.

* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::escapeString): Use append instead
of appendLiteral.
(WTF::JSONImpl::Value::writeJSON const): Ditto.

* wtf/Logger.h:
(WTF::Logger::log): Use auto for result of makeString.
(WTF::Logger::logVerbose): Ditto.

* wtf/MediaTime.cpp:
(WTF::MediaTime::toString const): Use makeString instead of StringBuilder.

* wtf/text/IntegerToStringConversion.h:
Made lengthOfIntegerAsString a constexpr function so we can use it to
compute the required size of arrays for conversion. Added using for both
lengthOfIntegerAsString and writeIntegerToBuffer so we can use them without
the WTF prefix as is customary for functions in WTF.

* wtf/text/StringBuilder.h:
(WTF::StringBuilder::appendLiteral): Deleted.

* wtf/text/StringConcatenate.h: Added support for appending StringImpl&,
StringImpl*, AtomStringImpl&, and AtomStringImpl*.

Tools:

* TestWebKitAPI/Tests/WTF/StringBuilder.cpp:
Use append instead of appendLiteral.
* TestWebKitAPI/Tests/WebCore/FileMonitor.cpp:
(TestWebKitAPI::createCommand): Use makeString instead of StringBuilder.
* TestWebKitAPI/Tests/WebCore/Logging.cpp:
(TestWebKitAPI::TEST_F): Made lots of fixes to code inside #if TEST_OUTPUT,
which hasn't compiled in a long time. Still not 100% there, but closer.
* TestWebKitAPI/Tests/WebCore/TextCodec.cpp:
(TestWebKitAPI::testDecode): Use append instead of appendLiteral.
* WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp:
(WTR::AccessibilityUIElement::helpText const): Ditto.


Canonical link: https://commits.webkit.org/238091@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277967 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-24 21:51:47 +00:00
Chris Dumez 42ae9aaebc Drop CheckedLock / CheckedCondition aliases
https://bugs.webkit.org/show_bug.cgi?id=226176

Reviewed by Kate Cheney.

Drop CheckedLock / CheckedCondition aliases now that they are the default.

Source/JavaScriptCore:

* API/JSVirtualMachine.mm:
* API/glib/JSCVirtualMachine.cpp:
* assembler/PerfLog.h:
* assembler/testmasm.cpp:
* bytecode/StructureStubInfo.h:
* bytecode/SuperSampler.cpp:
* dfg/DFGCommon.cpp:
* dfg/DFGCommonData.cpp:
* dfg/DFGPlan.h:
* dfg/DFGThreadData.h:
* dfg/DFGWorklist.cpp:
(JSC::DFG::Worklist::Worklist):
* dfg/DFGWorklist.h:
* disassembler/Disassembler.cpp:
* dynbench.cpp:
* heap/BlockDirectory.cpp:
(JSC::BlockDirectory::parallelNotEmptyBlockSource):
* heap/BlockDirectory.h:
(JSC::BlockDirectory::bitvectorLock):
* heap/CodeBlockSet.h:
(JSC::CodeBlockSet::getLock):
* heap/Heap.cpp:
(JSC::Heap::Heap):
* heap/Heap.h:
* heap/IsoSubspacePerVM.h:
* heap/MarkedSpace.h:
(JSC::MarkedSpace::directoryLock):
* heap/MarkingConstraintSolver.h:
* heap/SlotVisitor.cpp:
(JSC::SlotVisitor::donateKnownParallel):
* heap/SlotVisitor.h:
* inspector/remote/socket/RemoteInspectorConnectionClient.h:
* inspector/remote/socket/RemoteInspectorSocketEndpoint.h:
* jit/ExecutableAllocator.cpp:
(JSC::ExecutableAllocator::getLock const):
(JSC::dumpJITMemory):
* jit/ExecutableAllocator.h:
(JSC::ExecutableAllocatorBase::getLock const):
* jit/JITWorklist.cpp:
(JSC::JITWorklist::JITWorklist):
* jit/JITWorklist.h:
* jsc.cpp:
* profiler/ProfilerDatabase.h:
* runtime/ConcurrentJSLock.h:
* runtime/DeferredWorkTimer.h:
* runtime/JSLock.h:
* runtime/SamplingProfiler.cpp:
(JSC::FrameWalker::FrameWalker):
(JSC::CFrameWalker::CFrameWalker):
(JSC::SamplingProfiler::takeSample):
* runtime/SamplingProfiler.h:
(JSC::SamplingProfiler::getLock):
* runtime/VM.h:
* runtime/VMTraps.cpp:
(JSC::VMTraps::invalidateCodeBlocksOnStack):
(JSC::VMTraps::VMTraps):
* runtime/VMTraps.h:
* tools/FunctionOverrides.h:
* tools/VMInspector.cpp:
(JSC::ensureIsSafeToLock):
* tools/VMInspector.h:
(JSC::VMInspector::getLock):
* wasm/WasmCalleeRegistry.h:
(JSC::Wasm::CalleeRegistry::getLock):
* wasm/WasmPlan.h:
* wasm/WasmStreamingCompiler.h:
* wasm/WasmThunks.h:
* wasm/WasmWorklist.cpp:
(JSC::Wasm::Worklist::Worklist):
* wasm/WasmWorklist.h:

Source/WebCore:

* Modules/indexeddb/IDBObjectStore.h:
* Modules/indexeddb/IDBTransaction.h:
* Modules/indexeddb/client/IDBConnectionProxy.h:
* Modules/indexeddb/server/IDBSerializationContext.cpp:
* Modules/indexeddb/server/IDBServer.cpp:
* Modules/mediastream/RTCDataChannel.cpp:
* Modules/mediastream/RTCRtpSFrameTransformer.h:
* Modules/mediastream/RTCRtpScriptTransform.h:
* Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.h:
* Modules/mediastream/libwebrtc/LibWebRTCRtpTransformBackend.h:
* Modules/speech/SpeechRecognitionCaptureSourceImpl.h:
* Modules/webaudio/AudioParamTimeline.h:
* Modules/webaudio/MediaElementAudioSourceNode.h:
* Modules/webdatabase/Database.cpp:
* Modules/webdatabase/Database.h:
* Modules/webdatabase/DatabaseManager.h:
* Modules/webdatabase/DatabaseTask.h:
* Modules/webdatabase/DatabaseThread.h:
* Modules/webdatabase/DatabaseTracker.cpp:
(WebCore::DatabaseTracker::openDatabaseMutex):
* Modules/webdatabase/DatabaseTracker.h:
* Modules/webdatabase/OriginLock.cpp:
* Modules/webdatabase/SQLCallbackWrapper.h:
* Modules/webdatabase/SQLTransaction.h:
* Modules/webgpu/WebGPUDevice.cpp:
(WebCore::WebGPUDevice::instancesLock):
* Modules/webgpu/WebGPUDevice.h:
* Modules/webgpu/WebGPUPipeline.cpp:
(WebCore::WebGPUPipeline::instancesLock):
* Modules/webgpu/WebGPUPipeline.h:
* Modules/websockets/WebSocket.cpp:
(WebCore::WebSocket::allActiveWebSocketsLock):
* Modules/websockets/WebSocket.h:
* accessibility/isolatedtree/AXIsolatedTree.cpp:
* accessibility/isolatedtree/AXIsolatedTree.h:
* bindings/js/JSDOMGlobalObject.h:
* bridge/objc/WebScriptObject.mm:
* crypto/CryptoAlgorithmRegistry.h:
* dom/MessagePort.cpp:
* dom/Node.cpp:
* dom/ScriptExecutionContext.cpp:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::createMediaPlayer):
* html/canvas/CanvasRenderingContext.cpp:
(WebCore::CanvasRenderingContext::instancesLock):
* html/canvas/CanvasRenderingContext.h:
* html/canvas/WebGLContextGroup.cpp:
(WebCore::WebGLContextGroup::objectGraphLockForAContext):
* html/canvas/WebGLContextGroup.h:
* html/canvas/WebGLContextObject.cpp:
(WebCore::WebGLContextObject::objectGraphLockForContext):
* html/canvas/WebGLContextObject.h:
* html/canvas/WebGLObject.h:
* html/canvas/WebGLProgram.cpp:
(WebCore::WebGLProgram::instancesLock):
* html/canvas/WebGLProgram.h:
* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::objectGraphLock):
* html/canvas/WebGLRenderingContextBase.h:
* html/canvas/WebGLSharedObject.cpp:
(WebCore::WebGLSharedObject::objectGraphLockForContext):
* html/canvas/WebGLSharedObject.h:
* inspector/agents/WebHeapAgent.cpp:
* page/ResourceUsageThread.h:
* page/SecurityPolicy.cpp:
* page/WheelEventTestMonitor.h:
* page/scrolling/ScrollingTree.h:
(WebCore::ScrollingTree::WTF_RETURNS_LOCK):
* page/scrolling/ScrollingTreeLatchingController.h:
* page/scrolling/ThreadedScrollingTree.h:
(WebCore::ThreadedScrollingTree::WTF_RETURNS_LOCK):
* page/scrolling/mac/ScrollingTreeMac.h:
* platform/AbortableTaskQueue.h:
* platform/GenericTaskQueue.cpp:
* platform/GenericTaskQueue.h:
* platform/LegacySchemeRegistry.cpp:
* platform/audio/AudioDestination.h:
* platform/audio/HRTFDatabaseLoader.h:
* platform/audio/ReverbConvolver.cpp:
(WebCore::ReverbConvolver::backgroundThreadEntry):
* platform/audio/cocoa/AudioDestinationCocoa.h:
* platform/audio/gstreamer/AudioSourceProviderGStreamer.h:
* platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp:
* platform/audio/mac/FFTFrameMac.cpp:
* platform/encryptedmedia/CDMProxy.h:
* platform/graphics/MediaPlayer.cpp:
* platform/graphics/ShadowBlur.cpp:
(WebCore::ScratchBuffer::lock):
(WebCore::ShadowBlur::drawRectShadowWithTiling):
(WebCore::ShadowBlur::drawInsetShadowWithTiling):
* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
* platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
* platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:
* platform/graphics/cg/IOSurfacePool.h:
* platform/graphics/cg/SubimageCacheWithTimer.h:
* platform/graphics/cocoa/FontCacheCoreText.cpp:
* platform/graphics/gstreamer/ImageDecoderGStreamer.h:
* platform/graphics/gstreamer/MainThreadNotifier.h:
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
* platform/graphics/gstreamer/VideoSinkGStreamer.cpp:
* platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
* platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp:
* platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamer.cpp:
* platform/graphics/texmap/TextureMapperPlatformLayerProxy.h:
(WebCore::TextureMapperPlatformLayerProxy::WTF_RETURNS_LOCK):
* platform/image-decoders/ScalableImageDecoder.h:
* platform/ios/QuickLook.mm:
* platform/ios/WebSQLiteDatabaseTrackerClient.mm:
* platform/ios/wak/WebCoreThreadRun.cpp:
* platform/mediarecorder/MediaRecorderPrivateMock.h:
* platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h:
* platform/mediastream/RealtimeMediaSource.h:
* platform/mediastream/RealtimeOutgoingAudioSource.h:
* platform/mediastream/RealtimeOutgoingVideoSource.h:
* platform/mediastream/cocoa/AudioMediaStreamTrackRendererUnit.h:
* platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceLibWebRTC.h:
* platform/network/cf/LoaderRunLoopCF.cpp:
(WebCore::loaderRunLoop):
* platform/network/cocoa/WebCoreNSURLSession.mm:
* platform/network/mac/UTIUtilities.mm:
* platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.h:
* platform/sql/SQLiteDatabase.cpp:
* platform/sql/SQLiteDatabase.h:
* platform/sql/SQLiteDatabaseTracker.cpp:
* platform/text/TextEncodingRegistry.cpp:
* storage/StorageQuotaManager.h:
* workers/WorkerGlobalScope.cpp:
* workers/WorkerOrWorkletScriptController.h:
* workers/WorkerOrWorkletThread.cpp:
(WebCore::WorkerOrWorkletThread::workerOrWorkletThreadsLock):
* workers/WorkerOrWorkletThread.h:
* worklets/PaintWorkletGlobalScope.h:

Source/WebKit:

* GPUProcess/graphics/RemoteGraphicsContextGL.cpp:
(WebKit::RemoteGraphicsContextGL::paintPixelBufferToImageBuffer):
* GPUProcess/webrtc/LibWebRTCCodecsProxy.h:
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
* NetworkProcess/CustomProtocols/LegacyCustomProtocolManager.h:
* NetworkProcess/IndexedDB/WebIDBServer.cpp:
* NetworkProcess/NetworkProcess.h:
* NetworkProcess/WebStorage/StorageManagerSet.h:
* NetworkProcess/cache/NetworkCacheStorage.cpp:
* NetworkProcess/cocoa/LaunchServicesDatabaseObserver.h:
* NetworkProcess/glib/DNSCache.h:
* Platform/IPC/Connection.cpp:
* Platform/IPC/Connection.h:
* Platform/IPC/StreamConnectionWorkQueue.h:
* Platform/IPC/StreamServerConnection.h:
* Shared/BlockingResponseMap.h:
* Shared/Cocoa/XPCEndpointClient.h:
* Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h:
* Shared/mac/MediaFormatReader/MediaFormatReader.h:
* Shared/mac/MediaFormatReader/MediaSampleCursor.h:
* Shared/mac/MediaFormatReader/MediaTrackReader.h:
* UIProcess/API/glib/IconDatabase.h:
* UIProcess/WebURLSchemeTask.h:
* UIProcess/mac/DisplayLink.h:
* UIProcess/mac/WKPrintingView.mm:
(-[WKPrintingView knowsPageRange:]):
* WebProcess/GPU/graphics/RemoteImageBufferProxy.h:
* WebProcess/GPU/webrtc/LibWebRTCCodecs.h:
* WebProcess/Network/WebSocketStream.cpp:
* WebProcess/Plugins/PluginProcessConnectionManager.h:
* WebProcess/WebPage/EventDispatcher.h:
* WebProcess/WebPage/ViewUpdateDispatcher.h:

Source/WebKitLegacy:

* Storage/StorageAreaSync.h:

Source/WebKitLegacy/mac:

* DOM/DOMInternal.mm:

Source/WTF:

* WTF.xcodeproj/project.pbxproj:
* wtf/Assertions.cpp:
* wtf/AutomaticThread.cpp:
(WTF::AutomaticThreadCondition::wait):
(WTF::AutomaticThreadCondition::waitFor):
(WTF::AutomaticThread::AutomaticThread):
* wtf/AutomaticThread.h:
* wtf/CMakeLists.txt:
* wtf/CheckedCondition.h: Removed.
* wtf/CheckedLock.h: Removed.
* wtf/Condition.h:
* wtf/CrossThreadQueue.h:
* wtf/CrossThreadTaskHandler.h:
* wtf/CryptographicallyRandomNumber.cpp:
* wtf/FastMalloc.cpp:
* wtf/Forward.h:
* wtf/Language.cpp:
* wtf/Lock.cpp:
(WTF::UncheckedLock::lockSlow):
(WTF::UncheckedLock::unlockSlow):
(WTF::UncheckedLock::unlockFairlySlow):
(WTF::UncheckedLock::safepointSlow):
* wtf/Lock.h:
(WTF::WTF_ASSERTS_ACQUIRED_LOCK):
* wtf/Logger.cpp:
* wtf/Logger.h:
(WTF::Logger::WTF_RETURNS_LOCK):
* wtf/MessageQueue.h:
* wtf/MetaAllocator.cpp:
(WTF::MetaAllocator::release):
(WTF::MetaAllocator::MetaAllocator):
(WTF::MetaAllocator::allocate):
(WTF::MetaAllocator::currentStatistics):
* wtf/MetaAllocator.h:
* wtf/OSLogPrintStream.h:
* wtf/ParallelHelperPool.cpp:
(WTF::ParallelHelperPool::ParallelHelperPool):
* wtf/ParallelHelperPool.h:
* wtf/ParallelJobsGeneric.h:
* wtf/ParallelVectorIterator.h:
* wtf/ReadWriteLock.h:
* wtf/RecursiveLockAdapter.h:
* wtf/RunLoop.h:
* wtf/SynchronizedFixedQueue.h:
* wtf/Threading.cpp:
(WTF::Thread::allThreadsLock):
* wtf/Threading.h:
* wtf/TimingScope.cpp:
* wtf/URL.cpp:
* wtf/WTFSemaphore.h:
* wtf/WorkQueue.cpp:
(WTF::WorkQueue::concurrentApply):
* wtf/WorkerPool.cpp:
(WTF::WorkerPool::WorkerPool):
* wtf/WorkerPool.h:
* wtf/cf/LanguageCF.cpp:
* wtf/text/AtomStringImpl.cpp:
(WTF::AtomStringTableLocker::AtomStringTableLocker):
* wtf/text/StringView.cpp:
* wtf/threads/BinarySemaphore.h:
* wtf/unicode/icu/CollatorICU.cpp:

Tools:

* TestWebKitAPI/CMakeLists.txt:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/CheckedConditionTest.cpp: Removed.
* TestWebKitAPI/Tests/WTF/CheckedLockTest.cpp: Removed.
* TestWebKitAPI/Tests/WTF/Condition.cpp:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WTF/Lock.cpp:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WTF/MetaAllocator.cpp:
* WebKitTestRunner/InjectedBundle/AccessibilityController.cpp:
(WTR::AXThread::createThreadIfNeeded):

Canonical link: https://commits.webkit.org/238085@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277958 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-24 18:29:01 +00:00
Chris Dumez e801aaaa0b Make CheckedLock the default Lock
https://bugs.webkit.org/show_bug.cgi?id=226157

Reviewed by Darin Adler.

Make CheckedLock the default Lock so that we get more benefits from Clang
Thread Safety Analysis. Note that CheckedLock 100% relies on the existing
Source/JavaScriptCore:

Lock implementation and merely adds the clang anotations for thread
safety.

That this patch does is:
1. Rename the Lock class to UncheckedLock
2. Rename the CheckedLock class to Lock
3. Rename the Condition class to UncheckedCondition
4. Rename the CheckedCondition class to Condition
5. Update the types of certain variables from Lock / Condition to
   UncheckedLock / UncheckedCondition if I got a build failure. Build
   failures are usually caused by the following facts:
   - Locker<CheckedLock> doesn't subclass AbstractLocker which a lot of
     JSC code passes as argument
   - Locker<CheckedLock> has no move constructor
   - Locker<CheckedLock> cannot be constructed from a lock pointer, only
     a reference

For now, CheckedLock and CheckedCondition remain as aliases to Lock and
Condition, in their respective CheckedLock.h / CheckedCondition.h headers.
I will drop them in a follow-up to reduce patch size.

I will also follow-up to try and get rid of as much usage of UncheckedLock
and UncheckedCondition as possible. I did not try very hard in this patch
to reduce patch size.

* assembler/testmasm.cpp:
* dfg/DFGCommon.cpp:
* dfg/DFGThreadData.h:
* dfg/DFGWorklist.cpp:
(JSC::DFG::Worklist::Worklist):
* dfg/DFGWorklist.h:
* dynbench.cpp:
* heap/BlockDirectory.h:
(JSC::BlockDirectory::bitvectorLock):
* heap/CodeBlockSet.h:
(JSC::CodeBlockSet::getLock):
* heap/Heap.cpp:
(JSC::Heap::Heap):
* heap/Heap.h:
* heap/MarkedSpace.h:
(JSC::MarkedSpace::directoryLock):
* heap/MarkingConstraintSolver.h:
* heap/SlotVisitor.cpp:
(JSC::SlotVisitor::donateKnownParallel):
* heap/SlotVisitor.h:
* jit/ExecutableAllocator.cpp:
(JSC::ExecutableAllocator::getLock const):
(JSC::dumpJITMemory):
* jit/ExecutableAllocator.h:
(JSC::ExecutableAllocatorBase::getLock const):
* jit/JITWorklist.cpp:
(JSC::JITWorklist::JITWorklist):
* jit/JITWorklist.h:
* jsc.cpp:
* profiler/ProfilerDatabase.h:
* runtime/ConcurrentJSLock.h:
* runtime/DeferredWorkTimer.h:
* runtime/JSLock.h:
* runtime/SamplingProfiler.cpp:
(JSC::FrameWalker::FrameWalker):
(JSC::CFrameWalker::CFrameWalker):
(JSC::SamplingProfiler::takeSample):
* runtime/SamplingProfiler.h:
(JSC::SamplingProfiler::getLock):
* runtime/VM.h:
* runtime/VMTraps.cpp:
(JSC::VMTraps::invalidateCodeBlocksOnStack):
(JSC::VMTraps::VMTraps):
* runtime/VMTraps.h:
* tools/FunctionOverrides.h:
* tools/VMInspector.cpp:
(JSC::ensureIsSafeToLock):
* tools/VMInspector.h:
(JSC::VMInspector::getLock):
* wasm/WasmCalleeRegistry.h:
(JSC::Wasm::CalleeRegistry::getLock):
* wasm/WasmPlan.h:
* wasm/WasmStreamingCompiler.h:
* wasm/WasmThunks.h:
* wasm/WasmWorklist.cpp:
(JSC::Wasm::Worklist::Worklist):
* wasm/WasmWorklist.h:

Source/WebCore:

Lock implementation and merely adds the clang anotations for thread
safety.

That this patch does is:
1. Rename the Lock class to UncheckedLock
2. Rename the CheckedLock class to Lock
3. Rename the Condition class to UncheckedCondition
4. Rename the CheckedCondition class to Condition
5. Update the types of certain variables from Lock / Condition to
   UncheckedLock / UncheckedCondition if I got a build failure. Build
   failures are usually caused by the following facts:
   - Locker<CheckedLock> doesn't subclass AbstractLocker which a lot of
     JSC code passes as argument
   - Locker<CheckedLock> has no move constructor
   - Locker<CheckedLock> cannot be constructed from a lock pointer, only
     a reference

For now, CheckedLock and CheckedCondition remain as aliases to Lock and
Condition, in their respective CheckedLock.h / CheckedCondition.h headers.
I will drop them in a follow-up to reduce patch size.

I will also follow-up to try and get rid of as much usage of UncheckedLock
and UncheckedCondition as possible. I did not try very hard in this patch
to reduce patch size.

* Modules/indexeddb/server/IDBServer.cpp:
* Modules/webaudio/MediaElementAudioSourceNode.h:
* Modules/webdatabase/OriginLock.cpp:
* bindings/js/JSDOMGlobalObject.h:
* dom/Node.cpp:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::createMediaPlayer):
* html/canvas/WebGLContextGroup.cpp:
(WebCore::WebGLContextGroup::objectGraphLockForAContext):
* html/canvas/WebGLContextGroup.h:
* html/canvas/WebGLContextObject.cpp:
(WebCore::WebGLContextObject::objectGraphLockForContext):
* html/canvas/WebGLContextObject.h:
* html/canvas/WebGLObject.h:
* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::objectGraphLock):
* html/canvas/WebGLRenderingContextBase.h:
* html/canvas/WebGLSharedObject.cpp:
(WebCore::WebGLSharedObject::objectGraphLockForContext):
* html/canvas/WebGLSharedObject.h:
* page/scrolling/mac/ScrollingTreeMac.h:
* platform/audio/ReverbConvolver.cpp:
(WebCore::ReverbConvolver::backgroundThreadEntry):
* platform/graphics/ShadowBlur.cpp:
(WebCore::ScratchBuffer::lock):
(WebCore::ShadowBlur::drawRectShadowWithTiling):
(WebCore::ShadowBlur::drawInsetShadowWithTiling):
* platform/graphics/gstreamer/VideoSinkGStreamer.cpp:
* platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp:

Source/WebKit:

Lock implementation and merely adds the clang anotations for thread
safety.

That this patch does is:
1. Rename the Lock class to UncheckedLock
2. Rename the CheckedLock class to Lock
3. Rename the Condition class to UncheckedCondition
4. Rename the CheckedCondition class to Condition
5. Update the types of certain variables from Lock / Condition to
   UncheckedLock / UncheckedCondition if I got a build failure. Build
   failures are usually caused by the following facts:
   - Locker<CheckedLock> doesn't subclass AbstractLocker which a lot of
     JSC code passes as argument
   - Locker<CheckedLock> has no move constructor
   - Locker<CheckedLock> cannot be constructed from a lock pointer, only
     a reference

For now, CheckedLock and CheckedCondition remain as aliases to Lock and
Condition, in their respective CheckedLock.h / CheckedCondition.h headers.
I will drop them in a follow-up to reduce patch size.

I will also follow-up to try and get rid of as much usage of UncheckedLock
and UncheckedCondition as possible. I did not try very hard in this patch
to reduce patch size.

* GPUProcess/graphics/RemoteGraphicsContextGL.cpp:
(WebKit::RemoteGraphicsContextGL::paintPixelBufferToImageBuffer):
* NetworkProcess/IndexedDB/WebIDBServer.cpp:
* UIProcess/API/glib/IconDatabase.h:
* UIProcess/mac/WKPrintingView.mm:
(-[WKPrintingView knowsPageRange:]):

Source/WTF:

Lock implementation and merely adds the clang anotations for thread
safety.

That this patch does is:
1. Rename the Lock class to UncheckedLock
2. Rename the CheckedLock class to Lock
3. Rename the Condition class to UncheckedCondition
4. Rename the CheckedCondition class to Condition
5. Update the types of certain variables from Lock / Condition to
   UncheckedLock / UncheckedCondition if I got a build failure. Build
   failures are usually caused by the following facts:
   - Locker<CheckedLock> doesn't subclass AbstractLocker which a lot of
     JSC code passes as argument
   - Locker<CheckedLock> has no move constructor
   - Locker<CheckedLock> cannot be constructed from a lock pointer, only
     a reference

For now, CheckedLock and CheckedCondition remain as aliases to Lock and
Condition, in their respective CheckedLock.h / CheckedCondition.h headers.
I will drop them in a follow-up to reduce patch size.

I will also follow-up to try and get rid of as much usage of UncheckedLock
and UncheckedCondition as possible. I did not try very hard in this patch
to reduce patch size.

* wtf/AutomaticThread.cpp:
(WTF::AutomaticThreadCondition::wait):
(WTF::AutomaticThreadCondition::waitFor):
(WTF::AutomaticThread::AutomaticThread):
* wtf/AutomaticThread.h:
* wtf/CheckedCondition.h:
* wtf/CheckedLock.h:
* wtf/Condition.h:
* wtf/Lock.cpp:
(WTF::UncheckedLock::lockSlow):
(WTF::UncheckedLock::unlockSlow):
(WTF::UncheckedLock::unlockFairlySlow):
(WTF::UncheckedLock::safepointSlow):
* wtf/Lock.h:
(WTF::WTF_ASSERTS_ACQUIRED_LOCK):
* wtf/MetaAllocator.cpp:
(WTF::MetaAllocator::release):
(WTF::MetaAllocator::MetaAllocator):
(WTF::MetaAllocator::allocate):
(WTF::MetaAllocator::currentStatistics):
* wtf/MetaAllocator.h:
* wtf/ParallelHelperPool.cpp:
(WTF::ParallelHelperPool::ParallelHelperPool):
* wtf/ParallelHelperPool.h:
* wtf/RecursiveLockAdapter.h:
* wtf/WorkerPool.cpp:
(WTF::WorkerPool::WorkerPool):
* wtf/WorkerPool.h:

Tools:

Lock implementation and merely adds the clang anotations for thread
safety.

That this patch does is:
1. Rename the Lock class to UncheckedLock
2. Rename the CheckedLock class to Lock
3. Rename the Condition class to UncheckedCondition
4. Rename the CheckedCondition class to Condition
5. Update the types of certain variables from Lock / Condition to
   UncheckedLock / UncheckedCondition if I got a build failure. Build
   failures are usually caused by the following facts:
   - Locker<CheckedLock> doesn't subclass AbstractLocker which a lot of
     JSC code passes as argument
   - Locker<CheckedLock> has no move constructor
   - Locker<CheckedLock> cannot be constructed from a lock pointer, only
     a reference

For now, CheckedLock and CheckedCondition remain as aliases to Lock and
Condition, in their respective CheckedLock.h / CheckedCondition.h headers.
I will drop them in a follow-up to reduce patch size.

I will also follow-up to try and get rid of as much usage of UncheckedLock
and UncheckedCondition as possible. I did not try very hard in this patch
to reduce patch size.

* TestWebKitAPI/Tests/WTF/CheckedConditionTest.cpp:
* TestWebKitAPI/Tests/WTF/Condition.cpp:
* TestWebKitAPI/Tests/WTF/MetaAllocator.cpp:
* WebKitTestRunner/InjectedBundle/AccessibilityController.cpp:
(WTR::AXThread::createThreadIfNeeded):


Canonical link: https://commits.webkit.org/238070@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-24 05:37:41 +00:00
Adrien Destugues 2739e4d5c4 Merge commit 'a9ad6be2f57e2093525317ffb3d1284b45b87d10' into HEAD 2021-05-22 17:30:30 +02:00
Chris Dumez 3559a772ec Replace more static Locks with CheckedLocks in WTF / WebCore
https://bugs.webkit.org/show_bug.cgi?id=226040

Reviewed by Darin Adler.

Replace more static Locks with CheckedLocks so that we can benefit from Clang Thread Safety Analysis.

Source/WebCore:

* Modules/indexeddb/server/IDBSerializationContext.cpp:
(WebCore::IDBServer::IDBSerializationContext::getOrCreateForCurrentThread):
(WebCore::IDBServer::IDBSerializationContext::~IDBSerializationContext):
* Modules/mediastream/RTCDataChannel.cpp:
(WebCore::WTF_REQUIRES_LOCK):
(WebCore::RTCDataChannel::detach):
(WebCore::RTCDataChannel::removeFromDataChannelLocalMapIfNeeded):
(WebCore::RTCDataChannel::handlerFromIdentifier):
* Modules/webdatabase/Database.cpp:
(WebCore::WTF_REQUIRES_LOCK):
(WebCore::Database::Database):
(WebCore::Database::performOpenAndVerify):
(WebCore::Database::closeDatabase):
(WebCore::Database::getCachedVersion const):
(WebCore::Database::setCachedVersion):
* Modules/webgpu/WebGPUDevice.cpp:
(WebCore::WebGPUDevice::instancesLock):
(WebCore::WebGPUDevice::~WebGPUDevice):
* Modules/webgpu/WebGPUDevice.h:
* Modules/webgpu/WebGPUPipeline.cpp:
(WebCore::WebGPUPipeline::instancesLock):
(WebCore::WebGPUPipeline::WebGPUPipeline):
(WebCore::WebGPUPipeline::~WebGPUPipeline):
* Modules/webgpu/WebGPUPipeline.h:
* Modules/websockets/WebSocket.cpp:
(WebCore::WebSocket::WebSocket):
(WebCore::WebSocket::~WebSocket):
(WebCore::WebSocket::allActiveWebSocketsLock):
* Modules/websockets/WebSocket.h:
* bridge/objc/WebScriptObject.mm:
(WebCore::getJSWrapper):
(WebCore::addJSWrapper):
(WebCore::removeJSWrapper):
(WebCore::removeJSWrapperIfRetainCountOne):
* crypto/CryptoAlgorithmRegistry.cpp:
(WebCore::CryptoAlgorithmRegistry::singleton):
(WebCore::CryptoAlgorithmRegistry::identifier):
(WebCore::CryptoAlgorithmRegistry::name):
(WebCore::CryptoAlgorithmRegistry::create):
(WebCore::CryptoAlgorithmRegistry::registerAlgorithm):
* crypto/CryptoAlgorithmRegistry.h:
* dom/MessagePort.cpp:
(WebCore::MessagePort::deref const):
(WebCore::MessagePort::isExistingMessagePortLocallyReachable):
(WebCore::MessagePort::notifyMessageAvailable):
(WebCore::MessagePort::MessagePort):
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::contextIdentifier const):
(WebCore::ScriptExecutionContext::removeFromContextsMap):
(WebCore::ScriptExecutionContext::~ScriptExecutionContext):
(WebCore::ScriptExecutionContext::postTaskTo):
* html/canvas/CanvasRenderingContext.cpp:
(WebCore::CanvasRenderingContext::instancesLock):
(WebCore::CanvasRenderingContext::CanvasRenderingContext):
(WebCore::CanvasRenderingContext::~CanvasRenderingContext):
* html/canvas/CanvasRenderingContext.h:
* html/canvas/WebGLProgram.cpp:
(WebCore::WebGLProgram::instancesLock):
(WebCore::WebGLProgram::WebGLProgram):
(WebCore::WebGLProgram::~WebGLProgram):
* html/canvas/WebGLProgram.h:
* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::~WebGLRenderingContextBase):
* inspector/InspectorCanvas.cpp:
(WebCore::InspectorCanvas::canvasElement const):
(WebCore:: const):
* inspector/agents/InspectorCanvasAgent.cpp:
(WebCore::InspectorCanvasAgent::enable):
* inspector/agents/InspectorNetworkAgent.cpp:
(WebCore::InspectorNetworkAgent::enable):
(WebCore::InspectorNetworkAgent::webSocketForRequestId):
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* page/SecurityPolicy.cpp:
(WebCore::WTF_REQUIRES_LOCK):
(WebCore::SecurityPolicy::isAccessAllowed):
(WebCore::SecurityPolicy::addOriginAccessAllowlistEntry):
(WebCore::SecurityPolicy::removeOriginAccessAllowlistEntry):
(WebCore::SecurityPolicy::resetOriginAccessAllowlists):
(WebCore::SecurityPolicy::allowAccessTo):
* page/cocoa/ResourceUsageThreadCocoa.mm:
(WebCore::ResourceUsageThread::platformCollectCPUData):
* page/linux/ResourceUsageThreadLinux.cpp:
(WebCore::ResourceUsageThread::platformCollectCPUData):
* platform/GenericTaskQueue.cpp:
(WebCore::TaskDispatcher<Timer>::postTask):
(WebCore::TaskDispatcher<Timer>::sharedTimerFired):
(WebCore::TaskDispatcher<Timer>::pendingDispatchers):
(WebCore::TaskDispatcher<Timer>::dispatchOneTask):
* platform/GenericTaskQueue.h:
* platform/LegacySchemeRegistry.cpp:
(WebCore::allBuiltinSchemes):
(WebCore::WTF_REQUIRES_LOCK):
(WebCore::LegacySchemeRegistry::registerURLSchemeAsLocal):
(WebCore::LegacySchemeRegistry::removeURLSchemeRegisteredAsLocal):
(WebCore::LegacySchemeRegistry::registerURLSchemeAsHandledBySchemeHandler):
(WebCore::LegacySchemeRegistry::schemeIsHandledBySchemeHandler):
(WebCore::LegacySchemeRegistry::shouldTreatURLSchemeAsLocal):
(WebCore::LegacySchemeRegistry::registerURLSchemeAsNoAccess):
(WebCore::LegacySchemeRegistry::shouldTreatURLSchemeAsNoAccess):
(WebCore::LegacySchemeRegistry::registerURLSchemeAsDisplayIsolated):
(WebCore::LegacySchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated):
(WebCore::LegacySchemeRegistry::registerURLSchemeAsSecure):
(WebCore::LegacySchemeRegistry::shouldTreatURLSchemeAsSecure):
(WebCore::LegacySchemeRegistry::canDisplayOnlyIfCanRequest):
(WebCore::LegacySchemeRegistry::registerAsCanDisplayOnlyIfCanRequest):
(WebCore::LegacySchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy):
(WebCore::LegacySchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy):
(WebCore::LegacySchemeRegistry::schemeShouldBypassContentSecurityPolicy):
(WebCore::LegacySchemeRegistry::registerURLSchemeAsCachePartitioned):
(WebCore::LegacySchemeRegistry::shouldPartitionCacheForURLScheme):
* platform/audio/mac/FFTFrameMac.cpp:
(WebCore::WTF_REQUIRES_LOCK):
(WebCore::FFTFrame::fftSetupForSize):
* platform/graphics/MediaPlayer.cpp:
(WebCore::WTF_REQUIRES_LOCK):
(WebCore::installedMediaEngines):
(WebCore::MediaPlayer::resetMediaEngines):
* platform/ios/QuickLook.mm:
(WebCore::WTF_REQUIRES_LOCK):
(WebCore::removeQLPreviewConverterForURL):
(WebCore::addQLPreviewConverterWithFileForURL):
* platform/ios/WebSQLiteDatabaseTrackerClient.mm:
(WTF_REQUIRES_LOCK):
(+[WebDatabaseTransactionBackgroundTaskController startBackgroundTask]):
(+[WebDatabaseTransactionBackgroundTaskController endBackgroundTask]):
* platform/network/mac/UTIUtilities.mm:
(WebCore::WTF_REQUIRES_LOCK):
(WebCore::UTIFromMIMEType):
* platform/sql/SQLiteDatabase.cpp:
(WebCore::WTF_GUARDED_BY_LOCK):
(WebCore::SQLiteDatabase::setIsDatabaseOpeningForbidden):
(WebCore::SQLiteDatabase::open):
* platform/sql/SQLiteDatabaseTracker.cpp:
(WebCore::SQLiteDatabaseTracker::WTF_GUARDED_BY_LOCK):
(WebCore::SQLiteDatabaseTracker::setClient):
(WebCore::SQLiteDatabaseTracker::incrementTransactionInProgressCount):
(WebCore::SQLiteDatabaseTracker::decrementTransactionInProgressCount):
(WebCore::SQLiteDatabaseTracker::hasTransactionInProgress):
* platform/text/TextEncodingRegistry.cpp:
(WebCore::WTF_REQUIRES_LOCK):
(WebCore::newTextCodec):
(WebCore::atomCanonicalTextEncodingName):
* workers/WorkerGlobalScope.cpp:
(WebCore::WTF_REQUIRES_LOCK):
(WebCore::WorkerGlobalScope::WorkerGlobalScope):
(WebCore::WorkerGlobalScope::~WorkerGlobalScope):
(WebCore::WorkerGlobalScope::releaseMemoryInWorkers):
* workers/WorkerOrWorkletThread.cpp:
(WebCore::WorkerOrWorkletThread::workerOrWorkletThreadsLock):
(WebCore::WorkerOrWorkletThread::WorkerOrWorkletThread):
(WebCore::WorkerOrWorkletThread::~WorkerOrWorkletThread):
(WebCore::WorkerOrWorkletThread::releaseFastMallocFreeMemoryInAllThreads):
* workers/WorkerOrWorkletThread.h:

Source/WTF:

* wtf/Threading.cpp:
(WTF::Thread::allThreadsLock):
(WTF::Thread::create):
(WTF::Thread::didExit):
* wtf/Threading.h:
* wtf/URL.cpp:
(WTF::WTF_REQUIRES_LOCK):
(WTF::registerDefaultPortForProtocolForTesting):
(WTF::clearDefaultPortForProtocolMapForTesting):
(WTF::defaultPortForProtocol):
* wtf/cf/LanguageCF.cpp:
(WTF::WTF_REQUIRES_LOCK):
(WTF::platformLanguageDidChange):
(WTF::platformUserPreferredLanguages):
* wtf/text/StringView.cpp:
(WTF::StringView::invalidate):
(WTF::StringView::adoptUnderlyingString):
(WTF::StringView::setUnderlyingString):
* wtf/unicode/icu/CollatorICU.cpp:
(WTF::Collator::Collator):
(WTF::Collator::~Collator):


Canonical link: https://commits.webkit.org/238018@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277880 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-21 20:19:46 +00:00
Darin Adler c8156cc287 Move CFStringRef and NSString support from StringBuilder into StringConcatenateCF
https://bugs.webkit.org/show_bug.cgi?id=225839

Reviewed by Sam Weinig.

Source/JavaScriptCore:

* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::ConsoleMessage): Use StringBuilder::clear instead of
StringBuilder::resize; no advantage to the latter after calling StringBuilder::toString.

* runtime/JSONObject.cpp:
(JSC::Stringifier::Holder::appendNextProperty): Update for name change of
StringBuilder::resize to StringBuilder::shrink.
* runtime/TypeSet.cpp:
(JSC::StructureShape::stringRepresentation): Ditto.

Source/WebCore:

* Modules/airplay/WebMediaSessionManager.cpp:
(WebCore::mediaProducerStateString): Use StringBuilder exclusively instead of
mixing it with makeString. Also updated for StringBuilder::shrink name.
* html/HTMLTextFormControlElement.cpp:
(WebCore::stripTrailingNewline): Updated for StringBuilder::shrink name.

* page/CaptionUserPreferencesMediaAF.cpp:
(WebCore::CaptionUserPreferencesMediaAF::captionsTextColor const): Tweaked
coding style a bit.
(WebCore::appendCSS): Use variadic StringBuilder::append instead of many
separate calls.
(WebCore::CaptionUserPreferencesMediaAF::captionsDefaultFontCSS const):
Tweaked coding style a bit, and use variadic StrinBuilder::append calls
to reduce the number of calls and streamline the code.
(WebCore::CaptionUserPreferencesMediaAF::captionsStyleSheetOverride const):
Ditto. Also removed unnecessary checks that strings are empty before appending.

* page/scrolling/ScrollingCoordinator.cpp:
(WebCore::ScrollingCoordinator::synchronousScrollingReasonsAsText):
Updated for StringBuilder::shrink name.

* platform/LayoutUnit.h: Updated for saturatedSum/Difference names.

* platform/network/cocoa/NetworkStorageSessionCocoa.mm:
(WebCore::NetworkStorageSession::cookiesForSession const): Tweaked codin
style a bit, and use variadic StrinBuilder::append calls to reduce the
number of calls and streamline the code.

* rendering/RenderCounter.cpp:
(WebCore::planCounter): Updated for saturatedSum name.
* style/StyleBuilderCustom.h:
(WebCore::Style::BuilderCustom::applyValueCounter): Ditto.

* svg/SVGPathStringBuilder.cpp:
(WebCore::SVGPathStringBuilder::result): Updated for StringBuilder::shrink name.
* testing/Internals.cpp:
(WebCore::Internals::pageMediaState): Ditto.
* xml/XSLTProcessorLibxslt.cpp:
(WebCore::saveResultToString): Ditto.

Source/WebKit:

* UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
(WebKit::WebsiteDataStore::platformSetNetworkParameters): Use makeString instead
of StringBuilder.

Source/WTF:

The new header makes CFStringRef and NSString work with string concatenation,
which means it now works with the variadic StringBuilder::append and makeString,
and still works with the single-argument StringBuilder::append. More efficient
that the old version because it does not allocate a temporary WTF::String for
the 16-bit character path.

Also made many other small improvements to the StringBuilder implementation.

* WTF.xcodeproj/project.pbxproj: Added StringConcatenateCF.h.

* wtf/CheckedArithmetic.h: Removed ConditionalCrashOnOverflow, which was only
here for use by StringBuilder, which does not use CheckedArithmetic any more.

* wtf/PlatformFTW.cmake: Added StringConcatenateCF.h..
* wtf/PlatformMac.cmake: Ditto.
* wtf/PlatformWin.cmake: Ditto.

* wtf/SaturatedArithmetic.h: Moved the contents of this file inside the
WTF namespace.
(WTF::signedAddInt32Overflows): Renamed this function. The type here is
important, and we are not doing anything to prevent type conversion or
create ambiguity, so it's good to be explicit in the function name.
(WTF::saturatedSum<int32_t>): Renamed this from saturatedAddition for
clarity. The function returns a sum, so that's a better name than calling
it "addition". Also, it's clearer to be explicit about the return type.
(WTF::signedSubtractInt32Overflows): Renamed. Same reason as above.
(WTF::saturatedDifference<int32_t>): Ditto.
(WTF::saturatedSum): Added. Does unsigned integer saturated addition.
This one can be written in a portable manner and still get really
efficient code on at least Intel and ARM64.
(WTF::saturatedSum): Added a function template that lets callers pass
larger number of arguments to saturatedSum, rather than exactly two.

* wtf/text/StringBuilder.cpp:
(WTF::expandedCapacity): Renamed to use the term capacity rather than
length for the new required capacity.
(WTF::StringBuilder::didOverflow): Implement the new approach to
overflow, meaning we need to write the CRASH() here explicitly and
in the non-crashing mode, set m_length.
(WTF::StringBuilder::reifyString const): Changed the overflow check
into a RELEASE_ASSERT. This is now responsible for doing the check that
callers were doing earlier, so we want it in production builds. Also
simplified this since our m_length member is a simple integer now,
and removed the unused m_isReified.
(WTF::StringBuilder::shrink): Renamed this to shrink to match the
Vector::shrink function, since this has never supported making the
builder larger. Removed unnecessary overflow checks, since shrinking
cannot cause overflow.
(WTF::StringBuilder::allocateBuffer): Replaced two separate functions
with a single simpler function template. Removed extra overflow checks
because the StringImpl::tryCreateUninitialized function already does
the only overflow check we need. Also move to StringImpl::copyCharacters
for copying characters rather than using std::memcpy directly.
Removed code to set m_is8Bit and m_bufferCharacters.
(WTF::StringBuilder::reallocateBuffer): Replaced two separate
functions with a function template and a cover that calls the
appropriate instance of the template for places where we aren't
already in character-type-specific code paths. This version now
supports allocating a buffer for the first time in cases where
we have m_string and not m_buffer, which used to be handled at
the higher level. Removed code to set m_bufferCharacters.
(WTF::StringBuilder::reserveCapacity): Rewrote for simplicity.
By relying on the overflow checking inside reallocateBuffer and
allocateBuffer we no longer need checking of the passed-in value
at this level.
(WTF::StringBuilder::extendBufferForAppending): Removed the
version of this that takes additionalLength since it's
potentially confusing to have a family of functions that have the
same name and take the same type of argument, but interpret it
subtly differently. Streamlined the code using std::exchange.
This function now also includes the logic from the function named
extendBufferForAppendingWithoutOverflowCheck, which was subtly
misnamed since that was not the only semantic difference. Also
removed the ALWAYS_INLINE because the compiler will do the right
thing without such heavy handed advice.
(WTF::StringBuilder::extendBufferForAppendingSlowCase): Streamlined
this by using std::exchange and removed additional overflow checks
at this level since reallocateBuffer already does them. Also added
a check for the case where the new total length is 0, which would
not be handled correctly and efficiently by reallocateBuffer.
(WTF::StringBuilder::extendBufferForAppendingLChar): Renamed this
from extendBufferForAppending8, since it's now identical to calling
extendBufferForAppending<LChar>, except for inlining and linkage.
(WTF::StringBuilder::extendBufferForAppendingWithUpconvert):
Renamed this from extendBufferForAppending16. It is different from
the other extendBuffer functions because is supports upconverting
from LChar to UChar. Like the others it relies on allocateBuffer
for the overflow checking.
(WTF::StringBuilder::appendCharacters): Removed an unnecessary
assertion that the characters pointer is non-null; that will fail
in an obvious way without an assertion. Simplified the logic and
removed some invariant assertions that don't help us much. Changed
overflow checking by using saturatedSum to compute the new length.
In overflow cases, the new sum will be larger than the maximum
string length, but will fit in an unsigned, so we can pass it
down to lower levels and let functions like reallocateBuffer do
the actual overflow checking. Also use StringImpl::copyCharacters.
(WTF::StringBuilder::append): Removed the CFStringRef overload.
(WTF::StringBuilder::shouldShrinkToFit const): Rename this from
canShrink. Simplify the function a bit and remove the vague FIXME
that says "this should be tuned". That may be so, but the FIXME
is not really driving us to action.
(WTF::StringBuilder::shrinkToFit): Simplify by using the new
reallocateBuffer and std::exchange. Removed unneeded assertion
about overflow that doesn't help us maintain the invariant.
(WTF::StringBuilder::isAllASCII const): Was tempted to remove
this function, but for now just made it use the StringView
version for brevity.

* wtf/text/StringBuilder.h: Removed many unneeded includes, and
notably included SaturatedArithmetic.h instead of
CheckedArithmetic.h because we now use the former instead of the
latter. Changed the overflow checking implementation to work
more simply based on saturated addition rather than Checked.
This allowed us to get rid of dependency on our own unique mode
for Checked, called ConditionalCrashOnOverflow. Removed a
comment about making a templatized version of StringBuilder.
We can do it if we like, but does not seem urgent. Moved
fucntion bodies out of the class definition so it's easier to
see what's going on in the class. Since m_length is now an
ordinary integer, the check for overflowed simply checks to see
if the length is larger than the maximum string length. When we
encounter overflow that is not about length computation, we set
the length to the maximum integer to indicate the failure.
Deleted the append overloads for CFStringRef and NSString.
Removed m_bufferCharacters, m_is8Bit, and m_isReified.
(WTF::StringBuilder::StringBuilder): Simplified the constructor
since we only have to initialize the m_shouldCrashOnOverflow member.
(WTF::StringBuilder::clear): Fixed a mistake where this was not
resetting the m_isReified flag.
(WTF::StringBuilder::swap): Updated for changes in the data members.
(WTF::StringBuilder::operator StringView const): Moved out of line.
Made sure to call the length() function so we crash if this is
called after overflow.
(WTF::StringBuilder::append): Remove some of the unnecessary checks
and special cases in the various versions of append. Most of the
checking is done inside appendCharacters, with only a few exceptions.
(WTF::StringBuilder::appendSubstring): Moved out of the class
definition without making significant changes.
(WTF::StringBuilder::appendCharacter): Ditto.
(WTF::StringBuilder::toString): Greatly simplified this function
by relying on overflow checking in the reifyString function instead
of doing it here and removing unneeded invariant assertions.
(WTF::StringBuilder::toStringPreserveCapacity const): Ditto.
(WTF::StringBuilder::toAtomString const): Rewrote this to streamline,
removing explicit overflow checks.
(WTF::StringBuilder::length const): Moved out of the class
definition without making significant changes.
(WTF::StringBuilder::capacity const): Ditto.
(WTF::StringBuilder::operator[] const): Ditto.
(WTF::StringBuilder::characters const): Implemented this operation
in the function template. Now rather than having this call the
characters8 and characters16 functions, they can call it.
(WTF::StringBuilder::getBufferCharacters<LChar>): Deleted.
(WTF::StringBuilder::getBufferCharacters<UChar>): Deleted.
(WTF::StringBuilder::appendFromAdapters): Use saturatedSum to
compute the required length, which allows the extendBuffer
functions to do overflow checking without having to take special
checked integer types for arguments.
(WTF::StringBuilder::equal): Implement using StringView.

* wtf/text/StringBuilderJSON.cpp:
(WTF::StringBuilder::appendQuotedJSONString): Simplified the checked
arithmetic for computing the required capacity. Updated since we
removed m_bufferCharacters and changed the type of m_length.

* wtf/text/cf/StringConcatenateCF.h: Added. Specializes StringTypeAdapter for
both CFStringRef and NSString *. If CFStringGetCStringPtr works for Latin-1, then
does the 8-bit code path, otherwise the 16-bit.

* wtf/text/cocoa/TextStreamCocoa.mm: Include StringConcatenateCF.h, since it's
now needed to use CFStringRef with StringBuilder.

Tools:

* TestWebKitAPI/Tests/WTF/SaturatedArithmeticOperations.cpp: Updated
tests for changes to SaturatedArithmetic.h.

* TestWebKitAPI/Tests/WTF/StringBuilder.cpp: Updated tests for changes
to StringBuilder.
* TestWebKitAPI/Tests/WebKit/GetUserMedia.mm:
(TestWebKitAPI::wkMediaCaptureStateString): Ditto.

* WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
Added include of StringConcatenateCF.h.
Added StringTypeAdapter for WKStringRef.
(WTR::styleDecToStr): Use ASCIILiteral instead of StringBuilder.
(WTR::string): Removed unneeded toWTFString since the WKStringRef
StringTypeAdapter takes care of it.
(WTR::string): Renamed from frameToStr. Use makeString.
(WTR::dumpResourceURL): Use append instead of appendLiteral.
(WTR::dumpFrameDescriptionSuitableForTestResult): Deleted.
(WTR::dumpLoadEvent): Use makeString.
(WTR::string): Renamed from a longer name. Return a String
instead of building in a StringBuilder. Use makeString.
(WTR::string): Ditto.
(WTR::dumpErrorDescriptionSuitableForTestResult): Removed
unneeded toWTFString.
(WTR::dumpFrameScrollPosition): Ditto.
(WTR::dumpDescendantFramesText): Ditto.
(WTR::InjectedBundlePage::dumpDOMAsWebArchive): Removed an
unneeded local variable.
(WTR::InjectedBundlePage::dump): Removed unneeded toWTFString.
(WTR::InjectedBundlePage::didReceiveTitleForFrame): Ditto.
(WTR::InjectedBundlePage::didFinishDocumentLoadForFrame):
Updated for functon name change.
(WTR::InjectedBundlePage::willSendRequestForFrame): Ditto.
Also use variadic append. Also use makeString.
(WTR::InjectedBundlePage::didReceiveResponseForResource): Ditto.
(WTR::InjectedBundlePage::didFinishLoadForResource): Ditto.
(WTR::InjectedBundlePage::didFailLoadForResource): Ditto.
(WTR::InjectedBundlePage::decidePolicyForNavigationAction): Ditto.
(WTR::InjectedBundlePage::decidePolicyForResponse): Ditto.
(WTR::InjectedBundlePage::willAddMessageToConsole): Ditto.
(WTR::InjectedBundlePage::willSetStatusbarText): Ditto.
(WTR::InjectedBundlePage::willRunJavaScriptPrompt): Ditto.
(WTR::InjectedBundlePage::didExceedDatabaseQuota): Ditto.
(WTR::InjectedBundlePage::shouldInsertNode): Ditto.
(WTR::InjectedBundlePage::shouldInsertText): Ditto.
(WTR::InjectedBundlePage::shouldDeleteRange): Ditto.
(WTR::InjectedBundlePage::shouldChangeSelectedRange): Ditto.
(WTR::InjectedBundlePage::shouldApplyStyle): Ditto.
(WTR::InjectedBundlePage::didBeginEditing): Ditto.
(WTR::InjectedBundlePage::didEndEditing): Ditto.
(WTR::InjectedBundlePage::didChange): Ditto.
(WTR::InjectedBundlePage::didChangeSelection): Ditto.
(WTR::InjectedBundlePage::dumpHistory): Ditto.

Canonical link: https://commits.webkit.org/237916@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277744 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-19 19:37:21 +00:00
Sam Weinig e3e9cf6d20 Update Base64 encoding/decoding to match more modern WebKit conventions
https://bugs.webkit.org/show_bug.cgi?id=225920

Reviewed by Chris Dumez.

Source/WebCore:

- Updates to use new signatures for base64 encoding/decoding including
  utilizing the string type adaptor and makeString.
- Replace out parameter based getDefaultWebCryptoMasterKey() with
  Optional<Vector<uint8_t>> defaultWebCryptoMasterKey().
- Update synchronous loading code path to use uint8_t* consistently for
  data buffer representation.
- Replace out parameters in quotedPrintableEncode/quotedPrintableDecode
  with Optional.

* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
Update to use new base64URLDecode.

(WebCore::sanitizeKeyids):
Update to use new base64URLEncodeToString()

* Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp:
(WebCore::CDMSessionClearKey::update):
Update to use new base64Decode().

* Modules/plugins/QuickTimePluginReplacement.mm:
(WebCore::jsValueWithDataInContext):
(WebCore::jsValueWithAVMetadataItemInContext):
Update to use new base64EncodeToString(). Replace string concatentation
using operator+ with makeString().

* Modules/webauthn/AuthenticatorCoordinator.cpp:
(WebCore::AuthenticatorCoordinatorInternal::produceClientDataJson):
Update to use new base64URLEncodeToString().

* Modules/webauthn/PublicKeyCredential.cpp:
(WebCore::PublicKeyCredential::PublicKeyCredential):
Update to use new base64URLEncodeToString().

* Modules/websockets/WebSocketHandshake.cpp:
(WebCore::generateSecWebSocketKey):
(WebCore::WebSocketHandshake::getExpectedWebSocketAccept):
Update to use new base64URLEncodeToString().

* crypto/SerializedCryptoKeyWrap.h:
Change from outparameter based getDefaultWebCryptoMasterKey() to new
Optional<Vector<uint8_t>> defaultWebCryptoMasterKey().

* crypto/gcrypt/CryptoKeyECGCrypt.cpp:
(WebCore::CryptoKeyEC::platformAddFieldElements const):
Update to use new base64URLEncodeToString().

* crypto/gcrypt/SerializedCryptoKeyWrapGCrypt.cpp:
(WebCore::defaultWebCryptoMasterKey):
(WebCore::getDefaultWebCryptoMasterKey): Deleted.
Update for new defaultWebCryptoMasterKey() signature.

* crypto/keys/CryptoKeyAES.cpp:
(WebCore::CryptoKeyAES::importJwk):
(WebCore::CryptoKeyAES::exportJwk const):
Update to use new base64URLDecode / base64URLEncodeToString().

* crypto/keys/CryptoKeyEC.cpp:
(WebCore::CryptoKeyEC::importJwk):
Update to use new base64URLDecode.

* crypto/keys/CryptoKeyHMAC.cpp:
(WebCore::CryptoKeyHMAC::importJwk):
(WebCore::CryptoKeyHMAC::exportJwk const):
Update to use new base64URLDecode / base64URLEncodeToString().

* crypto/keys/CryptoKeyRSA.cpp:
(WebCore::CryptoKeyRSA::importJwk):
(WebCore::CryptoKeyRSA::exportJwk const):
Update to use new base64URLDecode / base64URLEncodeToString().

* crypto/mac/CryptoKeyECMac.cpp:
(WebCore::CryptoKeyEC::platformAddFieldElements const):
Update to use new base64URLEncodeToString().

* crypto/mac/SerializedCryptoKeyWrapMac.mm:
(WebCore::createAndStoreMasterKey):
(WebCore::findMasterKey):
(WebCore::defaultWebCryptoMasterKey):
(WebCore::getDefaultWebCryptoMasterKey): Deleted.
Update for new defaultWebCryptoMasterKey() signature.

* crypto/openssl/SerializedCryptoKeyWrapOpenSSL.cpp:
(WebCore::defaultWebCryptoMasterKey):
(WebCore::getDefaultWebCryptoMasterKey): Deleted.
Update for new defaultWebCryptoMasterKey() signature.

* fileapi/FileReaderLoader.cpp:
(WebCore::FileReaderLoader::convertToDataURL):
Update to use new base64EncodeToString().

* inspector/DOMPatchSupport.cpp:
(WebCore::DOMPatchSupport::createDigest):
Update to use new base64EncodeToString().

* inspector/InspectorFrontendHost.cpp:
(WebCore::InspectorFrontendHost::showCertificate):
Update to use new base64URLDecode / base64URLEncodeToString().

* inspector/NetworkResourcesData.cpp:
(WebCore::NetworkResourcesData::ResourceData::decodeDataToContent):
Update to use new base64EncodeToString().

* inspector/agents/InspectorDOMAgent.cpp:
(WebCore::computeContentSecurityPolicySHA256Hash):
Update to use new base64Decode / base64EncodeToString().

* inspector/agents/InspectorNetworkAgent.cpp:
(WebCore::Inspector::buildWebSocketMessage):
(WebCore::InspectorNetworkAgent::didReceiveData):
(WebCore::InspectorNetworkAgent::getSerializedCertificate):
(WebCore::InspectorNetworkAgent::interceptWithRequest):
(WebCore::InspectorNetworkAgent::interceptWithResponse):
(WebCore::InspectorNetworkAgent::interceptRequestWithResponse):
(WebCore::InspectorNetworkAgent::cachedResourceContent):
Update to use new base64Decode / base64EncodeToString().

* inspector/agents/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::dataContent):
(WebCore::InspectorPageAgent::archive):
Update to use new base64EncodeToString().

* loader/FrameLoader.cpp:
(WebCore::FrameLoader::loadResourceSynchronously):
Switch to using Vector<uint8_t> buffer to match new loadResourceSynchronously
signature.

* loader/LoaderStrategy.h:
Switch to using Vector<uint8_t> for the data buffer.

* loader/PrivateClickMeasurement.cpp:
(WebCore::PrivateClickMeasurement::EphemeralSourceNonce::isValid const):
Update to use new base64URLDecode.

* loader/ResourceCryptographicDigest.cpp:
(WebCore::parseCryptographicDigestImpl):
(WebCore::decodeEncodedResourceCryptographicDigest):
Update to use new base64Decode.

* loader/archive/mhtml/MHTMLArchive.cpp:
(WebCore::MHTMLArchive::generateMHTMLData):
Switch to using new base64Encode and new quotedPrintableEncode.

* loader/archive/mhtml/MHTMLParser.cpp:
(WebCore::MHTMLParser::parseNextPart):
Switch to using new base64Decode and new quotedPrintableDecode.

* loader/cocoa/PrivateClickMeasurementCocoa.mm:
(WebCore::PrivateClickMeasurement::calculateAndUpdateSourceUnlinkableToken):
(WebCore::PrivateClickMeasurement::calculateAndUpdateSourceSecretToken):
Update to use new base64URLDecode / base64URLEncodeToString().

* page/Base64Utilities.cpp:
(WebCore::Base64Utilities::btoa):
(WebCore::Base64Utilities::atob):
Update to use new base64Decode / base64EncodeToString().

* page/Page.cpp:
(WebCore::Page::userStyleSheetLocationChanged):
Update to use new base64Decode.

* platform/SharedBuffer.cpp:
(WebCore::SharedBuffer::append):
* platform/SharedBuffer.h:
Add overload for append which allows passing in a uint8_t*.

* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::extractKeyidsFromCencInitData):
(WebCore::extractKeyIdFromWebMInitData):
(WebCore::CDMInstanceSessionClearKey::removeSessionData):
Update to use new base64URLDecode / base64URLEncodeToString().

* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
Update to use new base64Decode.

* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::requestLicense):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::didProvideRequests):
Update to use new base64Decode / base64EncodeToString().

* platform/graphics/cairo/ImageBufferCairoBackend.cpp:
(WebCore::ImageBufferCairoBackend::toDataURL const):
Update to use new base64EncodeToString().

* platform/graphics/cg/ImageBufferUtilitiesCG.cpp:
(WebCore::dataURL):
Update to use new base64EncodeToString().

* platform/graphics/win/FontCustomPlatformData.cpp:
(WebCore::createUniqueFontName):
Update to use new base64EncodeToString().

* platform/graphics/win/FontCustomPlatformDataCairo.cpp:
(WebCore::createUniqueFontName):
Update to use new base64EncodeToString().

* platform/mac/SSLKeyGeneratorMac.mm:
(WebCore::signedPublicKeyAndChallengeString):
Update to use new base64EncodeToString().

* platform/network/BlobRegistryImpl.cpp:
(WebCore::loadBlobResourceSynchronously):
Switch to using Vector<uint8_t> buffer to match new loadResourceSynchronously
signature.

* platform/network/BlobResourceHandle.cpp:
* platform/network/BlobResourceHandle.h:
(WebCore::BlobResourceHandle::loadResourceSynchronously):
Switch to using Vector<uint8_t> buffer to match new loadResourceSynchronously
signature.

* platform/network/CredentialBase.cpp:
* platform/network/CredentialBase.h:
(WebCore::CredentialBase::serializationForBasicAuthorizationHeader const):
Add helper to construct Basic auth header to replace duplicated logic in
call sites.

* platform/network/DataURLDecoder.cpp:
(WebCore::DataURLDecoder::decodeBase64):
(WebCore::DataURLDecoder::decodeEscaped):
(WebCore::DataURLDecoder::decodeSynchronously):
* platform/network/DataURLDecoder.h:
Update to use new base64Decode.

* platform/network/ResourceHandle.cpp:
* platform/network/ResourceHandle.h:
Switch to using Vector<uint8_t> for the data buffer in the synchronous load.

* platform/network/SynchronousLoaderClient.cpp:
(WebCore::SynchronousLoaderClient::didReceiveData):
* platform/network/SynchronousLoaderClient.h:
Switch to using Vector<uint8_t> buffer to match new loadResourceSynchronously
signature.

* platform/network/cf/ResourceHandleCFNet.cpp:
(WebCore::applyBasicAuthorizationHeader):
Use new serializationForBasicAuthorizationHeader() helper.

(WebCore::ResourceHandle::platformLoadResourceSynchronously):
Switch to using Vector<uint8_t> for the data buffer in the synchronous load.

* platform/network/curl/ResourceHandleCurl.cpp:
(WebCore::ResourceHandle::platformLoadResourceSynchronously):
(WebCore::ResourceHandle::handleDataURL):
Switch to using Vector<uint8_t> for the data buffer in the synchronous load.

* platform/network/mac/ResourceHandleMac.mm:
(WebCore::applyBasicAuthorizationHeader):
Use new serializationForBasicAuthorizationHeader() helper.

(WebCore::ResourceHandle::platformLoadResourceSynchronously):
Switch to using Vector<uint8_t> for the data buffer in the synchronous load.

* platform/network/soup/ResourceHandleSoup.cpp:
(WebCore::ResourceHandle::platformLoadResourceSynchronously):
Switch to using Vector<uint8_t> for the data buffer in the synchronous load.

* platform/network/soup/SoupNetworkSession.cpp:
(WebCore::HostTLSCertificateSet::computeCertificateHash):
Update to use new base64EncodeToString().

* platform/text/DecodeEscapeSequences.h:
(WebCore::decodeURLEscapeSequencesAsData):
Switch to returning Vector<uint8_t>.

* platform/text/QuotedPrintable.cpp:
* platform/text/QuotedPrintable.h:
(WebCore::lengthOfLineEndingAtIndex):
(WebCore::quotedPrintableEncode):
(WebCore::quotedPrintableDecode):
Replace uses of Vector<char> with Vector<uint8_t> and the out parameters
with Optional return values.

* platform/win/SSLKeyGeneratorWin.cpp:
(WebCore::signedPublicKeyAndChallengeString):
Update to use new base64EncodeToString().

* workers/service/server/SWScriptStorage.cpp:
(WebCore::SWScriptStorage::sha2Hash const):
Update to use new base64URLEncodeToString().

Source/WebKit:

* NetworkProcess/NetworkConnectionToWebProcess.messages.in:
* UIProcess/API/C/WKPage.cpp:
(WKPageSetPageNavigationClient):
* UIProcess/WebPageProxy.messages.in:
* UIProcess/WebURLSchemeHandler.h:
* UIProcess/WebURLSchemeTask.cpp:
(WebKit::WebURLSchemeTask::didComplete):
* UIProcess/WebURLSchemeTask.h:
* WebProcess/Network/WebLoaderStrategy.cpp:
(WebKit::WebLoaderStrategy::loadResourceSynchronously):
* WebProcess/Network/WebLoaderStrategy.h:
* WebProcess/WebPage/WebURLSchemeHandlerProxy.cpp:
(WebKit::WebURLSchemeHandlerProxy::loadSynchronously):
* WebProcess/WebPage/WebURLSchemeHandlerProxy.h:
Update to use uint8_t* data buffers more consistently for synchronous loads.

* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::sendReplyToSynchronousRequest):
Update to use uint8_t* data buffers more consistently for synchronous loads.

* NetworkProcess/PrivateClickMeasurementManager.cpp:
(WebKit::PrivateClickMeasurementManager::fireConversionRequest):
Update to use new base64URLDecode / base64URLEncodeToString().

* NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
(WebKit::applyBasicAuthorizationHeader):
Use new serializationForBasicAuthorizationHeader() helper.

* Shared/API/APIData.h:
(API::Data::create):
(API::Data::fastFreeBytes): Deleted.
Add new create function that takes ownership of a Vector's buffer rather
than copying it. Replace use of static functions with inline lambdas for
free-functions.

* Shared/mac/AuxiliaryProcessMac.mm:
(WebKit::sandboxFilePath):
Use makeString and new base64URLEncoded().

* UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm:
(produceClientDataJson):
Use new base64URLEncodeToString().

* UIProcess/Automation/cairo/WebAutomationSessionCairo.cpp:
(WebKit::base64EncodedPNGData):
Use new base64EncodeToString().

* UIProcess/Cocoa/NavigationState.mm:
(WebKit::NavigationState::NavigationClient::webCryptoMasterKey):
Use new defaultWebCryptoMasterKey() and new adopting API::Data::create function.

* UIProcess/Inspector/glib/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setBackendCommands):
Use new base64EncodeToString().

* UIProcess/Inspector/gtk/RemoteWebInspectorUIProxyGtk.cpp:
(WebKit::RemoteWebInspectorUIProxy::platformSave):
Use new base64Decode().

* UIProcess/Inspector/gtk/WebInspectorUIProxyGtk.cpp:
(WebKit::WebInspectorUIProxy::platformSave):
Use new base64Decode().

* UIProcess/Inspector/mac/RemoteWebInspectorUIProxyMac.mm:
(WebKit::RemoteWebInspectorUIProxy::platformSave):
Use new base64Decode().

* UIProcess/Inspector/mac/WebInspectorUIProxyMac.mm:
(WebKit::WebInspectorUIProxy::platformSave):
Use new base64Decode().

* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setBackendCommands):
Use new base64EncodeToString().

* UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm:
(WebKit::LocalAuthenticatorInternal::produceHashSet):
(WebKit::LocalAuthenticator::makeCredential):
(WebKit::LocalAuthenticator::getAssertion):
Use new base64EncodeToString().

* UIProcess/WebAuthentication/Mock/MockHidConnection.cpp:
(WebKit::MockHidConnection::feedReports):
Use new base64Decode().

* UIProcess/WebAuthentication/Mock/MockLocalConnection.mm:
(WebKit::MockLocalConnection::filterResponses const):
Use new base64EncodeToString().

Source/WebKitLegacy:

* WebCoreSupport/WebResourceLoadScheduler.cpp:
(WebResourceLoadScheduler::loadResourceSynchronously):
* WebCoreSupport/WebResourceLoadScheduler.h:
Update to match new signature. char -> uint8_t.

Source/WebKitLegacy/mac:

* WebCoreSupport/WebChromeClient.mm:
(WebChromeClient::wrapCryptoKey const):
(WebChromeClient::unwrapCryptoKey const):
Update to use new Optional returning defaultWebCryptoMasterKey().

* WebCoreSupport/WebInspectorClient.mm:
(WebInspectorFrontendClient::save):
Update to use new Optional returning base64Decode().

Source/WTF:

Bring base64 encoding/decoding up to more modern WebKit conventions by:
- Replace use of "out parameter + bool" with Optional return values.
- Using enum class for enumerations.
- Replacing SignedOrUnsignedCharVectorAdapter/ConstSignedOrUnsignedCharVectorAdapter
  with appropriate function overloads.

Also adds a new StringTypeAdapter for inline base64 encoding data in either makeString()
or StringBuilder. To make this work, a few modifications were need to the base64Encode()
functions to support the fixed size writeTo() function.

First, the length of the encoded data is now computed up front depending on the policy.
This has been extracted into a new calculateBase64EncodedSize() function used by both
the adaptor and by base64Encode when passed a Vector. Previously, when encoding using
some policies, the size was an overestimate and the resulting Vector would be resized
down after encoding.

Second, base64EncodeInternal was made into a template function to allow for two new
base64Encode functions, one of which has a UChar* destination. These are used by the
adaptor to write the encoded data.

One additional small change is that now a optional map type parameter has been added
to all the encoders to allow using either the default map or the URL one as defined
in RFC 4648. This simplifies the implementation of the StringTypeAdapter and makes the
base64URLEncode/base64URLDecode functions into simple convenience functions that use
the right defaults for the generic encode/decode functions.

* wtf/text/Base64.cpp:
(WTF::base64EncodeInternal):
(WTF::base64Encode):
(WTF::base64DecodeInternal):
(WTF::base64Decode):
(WTF::base64URLDecode):
(WTF::base64URLEncode): Deleted.
* wtf/text/Base64.h:
(WTF::base64Decode):
(WTF::base64Encode):
(WTF::base64URLEncode):
(WTF::isBase64OrBase64URLCharacter):
(WTF::calculateBase64EncodedSize):
(WTF::base64Encoded):
(WTF::base64URLEncoded):
(WTF::StringTypeAdapter<Base64Specification>::StringTypeAdapter):
(WTF::StringTypeAdapter<Base64Specification>::length const):
(WTF::StringTypeAdapter<Base64Specification>::is8Bit const):
(WTF::StringTypeAdapter<Base64Specification>::writeTo const):

Tools:

Update to use updated base64 and defaultWebCryptoMasterKey() related
functions.

* TestWebKitAPI/TCPServer.cpp:
(TestWebKitAPI::TCPServer::startSecureConnection):
(TestWebKitAPI::TCPServer::testCertificate):
(TestWebKitAPI::TCPServer::testPrivateKey):
* TestWebKitAPI/Tests/WebCore/ISOBox.cpp:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebCore/cocoa/PrivateClickMeasurementCocoa.mm:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebCore/cocoa/SerializedCryptoKeyWrap.mm:
(TestWebKitAPI::TEST_F):
* TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm:
(testIdentity2):
* TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/mac/SSLKeyGenerator.mm:
(TestWebKitAPI::TEST_F):
* TestWebKitAPI/cocoa/HTTPServer.mm:
(TestWebKitAPI::Connection::webSocketHandshake):


Canonical link: https://commits.webkit.org/237912@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277740 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-19 18:43:29 +00:00
Darin Adler e12a212a53 Remove StringBuilder::appendNumber
https://bugs.webkit.org/show_bug.cgi?id=225732

Reviewed by Sam Weinig.

Source/JavaScriptCore:

* API/JSContextRef.cpp:
(BacktraceFunctor::operator() const): Use append instead of appendNumber.
* API/tests/PingPongStackOverflowTest.cpp:
(PingPongStackOverflowObject_hasInstance): Ditto.
* heap/HeapSnapshotBuilder.cpp:
(JSC::HeapSnapshotBuilder::json): Ditto.

* interpreter/StackVisitor.cpp:
(JSC::StackVisitor::Frame::toString const): Use makeString instead of StringBuilder.

* runtime/ConsoleClient.cpp:
(JSC::appendURLAndPosition): Ditto.
(JSC::ConsoleClient::printConsoleMessageWithArguments): Use append instead of appendNumber.
* runtime/JSONObject.cpp:
(JSC::Stringifier::appendStringifiedValue): Ditto.
* runtime/Options.cpp:
(JSC::OptionReader::Option::dump const): Ditto.

* runtime/StackFrame.cpp:
(JSC::StackFrame::toString const): Use makeString instead of StringBuilder.

Source/WebCore:

* Modules/indexeddb/server/IndexValueStore.cpp:
(WebCore::IDBServer::IndexValueStore::loggingString const):
Use append instead of appendNumber.

* Modules/websockets/WebSocketHandshake.cpp:
(WebCore::hostName): Use makeString instead of StringBuilder.

* contentextensions/CombinedURLFilters.cpp:
(WebCore::ContentExtensions::prefixTreeVertexToString):
Use append instead of appendNumber.
* contentextensions/Term.h:
(WebCore::ContentExtensions::Term::toString const): Ditto.
* css/CSSFontFeatureValue.cpp:
(WebCore::CSSFontFeatureValue::customCSSText const): Ditto.
* css/CSSTimingFunctionValue.cpp:
(WebCore::CSSStepsTimingFunctionValue::customCSSText const): Ditto.

* dom/Document.cpp:
(WebCore::Document::downgradeReferrerToRegistrableDomain): Use
makeString instead of StringBuilder.
* editing/MarkupAccumulator.cpp:
(WebCore::MarkupAccumulator::generateUniquePrefix): Ditto.

* editing/cocoa/DataDetection.mm:
(WebCore::dataDetectorStringForPath): Use append instead of appendNumber.
* html/HTMLAnchorElement.cpp:
(WebCore::appendServerMapMousePosition): Ditto.

* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::createContext2d): Use makeString
instead of StringBuilder.
(WebCore::HTMLCanvasElement::createImageBuffer const): Ditto.

* loader/ResourceLoadStatistics.cpp:
(WebCore::ResourceLoadStatistics::toString const): Use append instead
of appendNumber.

* loader/SubresourceIntegrity.cpp:
(WebCore::integrityMismatchDescription): Use makeString instead of
StringBuilder.

* page/IntersectionObserver.cpp:
(WebCore::IntersectionObserver::rootMargin const): Use append instead
of appendNumber.

* page/SecurityOriginData.cpp:
(WebCore::SecurityOriginData::databaseIdentifier const): Use makeString
instead of StringBuilder.

* platform/Decimal.cpp:
(WebCore::Decimal::toString const): Use append instead of appendNumber.

* platform/graphics/GraphicsLayer.cpp:
(WebCore::GraphicsLayer::animationNameForTransition): Use makeString
instead of StringBuilder.
* platform/graphics/ca/TileController.cpp:
(WebCore::TileController::createTileLayer): Ditto.

* platform/graphics/ca/win/PlatformCALayerWin.cpp:
(printTransform): Use single append instead of a run of them.
(printLayer): Ditto, and use append instead of apppendNumber.
(PlatformCALayerWin::layerTreeAsString const): Ditto.

* platform/mediarecorder/MediaRecorderPrivateMock.cpp:
(WebCore::MediaRecorderPrivateMock::generateMockCounterString):
Use append instead of appendNumber.
* platform/network/ProxyServer.cpp:
(WebCore::appendProxyServerString): Ditto.
* rendering/RenderTreeAsText.cpp:
(WebCore::nodePosition): Ditto.
* svg/SVGPathUtilities.cpp:
(WebCore::buildStringFromPath): Ditto.

* testing/Internals.cpp:
(WebCore::Internals::parserMetaData): Use makeString instead of
StringBuilder.
(WebCore::appendOffsets): Use append instead of appendNumber.

* testing/MockPageOverlayClient.cpp:
(WebCore::MockPageOverlayClient::drawRect): Use makeString instead
of StringBuilder.
(WebCore::MockPageOverlayClient::mouseEvent): Ditto.

* xml/XMLErrors.cpp:
(WebCore::XMLErrors::appendErrorMessage): Use append instead of
appendNumber.

Source/WebDriver:

* SessionHost.cpp:
(WebDriver::SessionHost::sendCommandToBackend): Use append instead
of appendNumber.
* socket/HTTPServerSocket.cpp:
(WebDriver::HTTPRequestHandler::packHTTPMessage const): Ditto.

Source/WebKit:

* NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
(WebKit::buildList): Use append instead of appendNumber.
(WebKit::ResourceLoadStatisticsDatabaseStore::findNotVeryPrevalentResources): Ditto.
(WebKit::ResourceLoadStatisticsDatabaseStore::resourceToString const): Ditto.
(WebKit::ResourceLoadStatisticsDatabaseStore::attributionToString): Ditto.
(WebKit::ResourceLoadStatisticsDatabaseStore::privateClickMeasurementToString): Ditto.
* Shared/WebMemorySampler.cpp:
(WebKit::WebMemorySampler::appendCurrentMemoryUsageToFile): Ditto.
* UIProcess/API/glib/WebKitWebView.cpp:
(webkitWebViewRunJavaScriptCallback): Ditto.
* UIProcess/WebBackForwardList.cpp:
(WebKit::WebBackForwardList::loggingString): Ditto.

* WebProcess/InjectedBundle/API/glib/WebKitWebPage.cpp:
(PageResourceLoadClient::didReceiveResponseForResource): Use makeString instead
of StringBuilder.

* WebProcess/Plugins/PluginView.cpp:
(WebKit::buildHTTPHeaders): Use append instead of appendNumber.

Source/WebKitLegacy/win:

* WebKitStatistics.cpp:
(WebKitStatistics::comClassNameCounts): Use append instead of
appendNumber.

Source/WTF:

We originally added StringBuilder::appendNumber to resolve the ambiguity
between UChar and uint16_t, but that problem was solved long ago and it
is safe to use StringBuilder::append, including the variadic form, on all
types of numbers and we'll get the same results we did with appendNumber.

* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::writeJSON const): Use append instead of appendNumber.

* wtf/text/StringBuilder.cpp:
(WTF::StringBuilder::appendNumber): Deleted.
* wtf/text/StringBuilder.h: Removed appendNumber.

* wtf/text/TextStream.cpp:
(WTF::TextStream::operator<<): Use append instead of appendNumber.

Tools:

* TestWebKitAPI/Tests/WTF/StringBuilder.cpp:
Test append with a number instead of appendNumber.

* TestWebKitAPI/Tests/WebKitGLib/TestAutomationSession.cpp:
Use append instead of appendNumber.

* WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
(WTR::dumpResponseDescriptionSuitableForTestResult): Use append instead
of appendNumber.
(WTR::dumpFrameScrollPosition): Ditto.
(WTR::InjectedBundlePage::didFinishDocumentLoadForFrame): Use makeString
instead of StringBuilder.
(WTR::InjectedBundlePage::shouldCacheResponse): Ditto.

* WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp:
(WTR::attributesOfElement): Use append instead of appendNumber.
(WTR::AccessibilityUIElement::attributedStringForRange): Ditto.
(WTR::stringAtOffset): Ditto.


Canonical link: https://commits.webkit.org/237685@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277437 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-13 16:18:32 +00:00
Darin Adler ec09c5ee1b Remove the String::toInt family of functions
https://bugs.webkit.org/show_bug.cgi?id=225599

Reviewed by Anders Carlsson.

Source/WebCore:

* platform/graphics/GLContext.cpp:
(WebCore::GLContext::version): Use
parseIntegerAllowingTrailingJunk<unsigned> instead of String::toUInt.

* platform/graphics/GlyphBuffer.h:
(WebCore::GlyphBuffer::checkedStringOffsetAt const): Fix code that was
assuming GlyphBufferStringOffset was signed to compile without a warning
regardless of whether it's signed or unsigned. This was making GTK
builds have tons and tons of warnings, which was distracting while
working on the other fixes here.

* platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
(CachedResourceStreamingClient::responseReceived): Use
parseIntegerAllowingTrailingJunk<uint64_t> instead of String::toUInt64.

Source/WebKit:

* Shared/win/AuxiliaryProcessMainWin.cpp:
(WebKit::AuxiliaryProcessMainCommon::parseCommandLine): Use
parseIntegerAllowingTrailingJunk<uint64_t> instead of String::toUInt64.
* UIProcess/API/gtk/WebKitRemoteInspectorProtocolHandler.cpp:
(WebKit::ScriptMessageClient::didPostMessage): Ditto.
* UIProcess/win/WebProcessPoolWin.cpp:
(WebKit::initializeRemoteInspectorServer): Use
parseIntegerAllowingTrailingJunk<uint16_t> instead of StringView::toUInt64.
This is a 16-bit port number, so not valuable to parse larger integers.

Source/WTF:

* wtf/text/AtomString.h: Deleted AtomString::toInt.

* wtf/text/StringImpl.cpp:
(WTF::StringImpl::toIntStrict): Deleted.
(WTF::StringImpl::toUIntStrict): Deleted.
(WTF::StringImpl::toInt64Strict): Deleted.
(WTF::StringImpl::toUInt64Strict): Deleted.
(WTF::StringImpl::toIntPtrStrict): Deleted.
(WTF::StringImpl::toInt): Deleted.
(WTF::StringImpl::toUInt): Deleted.
(WTF::StringImpl::toInt64): Deleted.
(WTF::StringImpl::toUInt64): Deleted.
(WTF::StringImpl::toIntPtr): Deleted.
* wtf/text/StringImpl.h: Deleted the above functions.

* wtf/text/StringToIntegerConversion.h: Removed toIntegralType.

* wtf/text/StringView.cpp:
(WTF::parseUInt16): Deleted.

* wtf/text/StringView.h: Deleted StringView::toInt,
StringView::toIntStrict, StringView::toUInt64Strict,
StringView::toInt64Strict, and parseUInt16. Changed the constructor
that takes a const char* to work when passed nullptr. StringView has
a null value, and converting a null const char* should produce that.

* wtf/text/WTFString.cpp:
(WTF::String::toIntStrict const): Deleted.
(WTF::String::toUIntStrict const): Deleted.
(WTF::String::toInt64Strict const): Deleted.
(WTF::String::toUInt64Strict const): Deleted.
(WTF::String::toIntPtrStrict const): Deleted.
(WTF::String::toInt const): Deleted.
(WTF::String::toUInt const): Deleted.
(WTF::String::toInt64 const): Deleted.
(WTF::String::toUInt64 const): Deleted.
(WTF::String::toIntPtr const): Deleted.
(WTF::lengthOfCharactersAsInteger): Deleted.
(WTF::charactersToIntStrict): Deleted.
(WTF::charactersToUIntStrict): Deleted.
(WTF::charactersToInt64Strict): Deleted.
(WTF::charactersToUInt64Strict): Deleted.
(WTF::charactersToIntPtrStrict): Deleted.
(WTF::charactersToInt): Deleted.
(WTF::charactersToUInt): Deleted.
(WTF::charactersToInt64): Deleted.
(WTF::charactersToUInt64): Deleted.
(WTF::charactersToIntPtr): Deleted.
* wtf/text/WTFString.h: Deleted the above functions.

Tools:

* TestWebKitAPI/CMakeLists.txt: Added StringToIntegerConversion.cpp.
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Ditto.

* TestWebKitAPI/Tests/WTF/StringToIntegerConversion.cpp: Added.
Contains tests moved and adapted from the files below so we don't
lose test coverage. We and and should add many more tests.

* TestWebKitAPI/Tests/WTF/StringView.cpp: Removed tests for parseUInt16
and StringView::toIntStrict.

* TestWebKitAPI/Tests/WTF/WTFString.cpp: Removed tests for String::toInt.

* TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm: Use
parseInteger<uint64_t> instead of StringView::toUInt64Strict.
* TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm: Ditto.

Canonical link: https://commits.webkit.org/237613@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277355 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-12 04:23:30 +00:00
Darin Adler 0a8df2e43c Remove uses of the String::toInt family of functions from WebCore/html and similar directories
https://bugs.webkit.org/show_bug.cgi?id=225577

Reviewed by Sam Weinig.

Source/WebCore:

* dom/Document.cpp:
(WebCore::Document::createEvent): Fix spelling error.

* html/FTPDirectoryDocument.cpp:
(WebCore::processFilesizeString): Use parseIntegerAllowingTrailingJunk<uint64_t>
instead of String::toUInt64.

* html/FormController.cpp:
(WebCore::deserializeFormControlState): Use parseIntegerAllowingTrailingJunk<size_t>
instead of String::toUInt.
(WebCore::SavedFormState::deserialize): Ditto.

* html/HTMLFontElement.cpp:
(WebCore::parseFontSize): Use parseInteger<int> instead of
charactersToIntStrict.
* html/HTMLFrameElement.cpp:
(WebCore::HTMLFrameElement::parseAttribute): Use parseIntegerAllowingTrailingJunk<int>
instead of String::toInt.
* html/HTMLFrameSetElement.cpp:
(WebCore::HTMLFrameSetElement::parseAttribute): Ditto.
* html/HTMLHRElement.cpp:
(WebCore::HTMLHRElement::collectStyleForPresentationAttribute): Ditto.
* html/HTMLIFrameElement.cpp:
(WebCore::HTMLIFrameElement::collectStyleForPresentationAttribute): Ditto.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::parseAttribute): Ditto.
* html/HTMLLIElement.cpp:
(WebCore::HTMLLIElement::parseValue): Ditto.
* html/HTMLMarqueeElement.cpp:
(WebCore::HTMLMarqueeElement::loop const): Ditto.
* html/HTMLTableCellElement.cpp:
(WebCore::HTMLTableCellElement::collectStyleForPresentationAttribute): Ditto.
* html/HTMLTableColElement.cpp:
(WebCore::HTMLTableColElement::parseAttribute): Ditto.
* html/HTMLTableElement.cpp:
(WebCore::HTMLTableElement::parseAttribute): Ditto.

* html/LinkIconCollector.cpp:
(WebCore::LinkIconCollector::iconsOfTypes): Use parseIntegerAllowingTrailingJunk<unsigned>
instead of String::toUInt. Also removed unneeded call to stripWhiteSpace since the
integer parsing function already skips leading and trailing spaces.

* html/MediaFragmentURIParser.cpp:
(WebCore::MediaFragmentURIParser::parseNPTTime): Use parseInteger<int> instead of
String::toInt. The strings passsed in are fixed size and all digits.

* html/TypeAhead.cpp:
(WebCore::TypeAhead::handleEvent): Use parseIntegerAllowingTrailingJunk<int>
instead of String::toInt.

* html/URLDecomposition.cpp:
(WebCore::URLDecomposition::setHost): Use parseInteger<uint16_t> instead of parseUInt16.
(WebCore::parsePort): Ditto.

* html/shadow/DateTimeNumericFieldElement.cpp:
(WebCore::DateTimeNumericFieldElement::handleKeyboardEvent): Use
parseIntegerAllowingTrailingJunk<int> instead of String::toInt.

* html/track/VTTScanner.cpp:
(WebCore::VTTScanner::scanDigits): Use parseInteger<int> instead of
charactersToIntStrict.

* mathml/MathMLSelectElement.cpp:
(WebCore::MathMLSelectElement::getSelectedActionChildAndIndex): Use
parseIntegerAllowingTrailingJunk<int> instead of AtomString::toInt.

Source/WTF:

* wtf/text/StringBuilder.h: Added conversion operator to make a StringView, built on the exiting
is8Bit, characters8, characters16 and length functions. Removed now-uneeded equal function and
== and != operators since the StringView ones work for those same cases with the same syntax.

Canonical link: https://commits.webkit.org/237514@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277245 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-09 18:22:23 +00:00
Darin Adler c78ad29f6a Rename toIntegralType to parseInteger and prepare to use it to replace all our integer-parsing functions
https://bugs.webkit.org/show_bug.cgi?id=225560

Reviewed by Sam Weinig.

I have a much larger patch that replaces all the many toInt functions with these parseInteger
function templates. The parseInteger ones take StringView, which means we can pass almost any
type of string or character/length pair including a substring without allocating a new string,
return Optional rather than using an out argument to report failure, take the integer type as
a template parameter so can be used for precisely the desired type at each call site, and make
the "allow trailing junk" feature explicit, rather than implicitly including it in the shortest
named functions, which I hope will discourage people from using that junk-ignoring mode
when it's not desirable.

Also includes adoption of parseInteger within WTF itself, outside the string classes.

My plan is to land the rest of adoption of this in chunks so we can review carefully and spot
mistakes as we go. Then return to files like WTFString.h and remove the many old functions
this replaces, including the String::toInt and charactersToInt families of functions.

* wtf/URL.cpp:
(WTF::URL::port const): Use parseInteger<uint16_t>.
(WTF::URL::setHostAndPort): Ditto.

* wtf/text/StringToIntegerConversion.h: Refactored the existing code to tighten things up
a bit, and got rid of overloads that take pointer and length and the the generic "any string
type" feature, since StringView already works well for that. Renamed toIntegralType to
parseInteger, leaving the old name behind to ease the transition while adopting parseInteger.

* wtf/text/WTFString.cpp:
(WTF::toDoubleType): Use the TrailingJunkPolicy enumeration from the
StringToIntegerConversion.h header.
(WTF::charactersToDouble): Ditto.
(WTF::charactersToFloat): Ditto.


Canonical link: https://commits.webkit.org/237503@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277234 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-09 00:59:28 +00:00
Darin Adler 0f73b4d435 Use SortedArrayMap in a few more places
https://bugs.webkit.org/show_bug.cgi?id=225251

Reviewed by Sam Weinig.

Source/WebCore:

* Modules/encryptedmedia/CDM.h: Removed unneeded includes.
* Modules/indexeddb/server/IDBServer.h: Ditto.
* contentextensions/ContentExtensionActions.h: Ditto.
* css/CSSVariableData.h: Ditto.
* dom/FullscreenManager.h: Ditto.

* dom/ScriptElement.cpp:
(WebCore::isLegacySupportedJavaScriptLanguage): Use SortedArraySet.
(WebCore::ScriptElement::executeClassicScript): Fixed typo.
(WebCore::ScriptElement::executeModuleScript): Ditto.

* inspector/InspectorAuditResourcesObject.cpp: Removed unneeded includes.
* inspector/agents/InspectorNetworkAgent.cpp: Ditto.
* loader/appcache/ApplicationCacheGroup.cpp: Ditto.
* page/UserContentProvider.h: Ditto.
* page/ios/DOMTimerHoldingTank.cpp: Ditto.
* page/scrolling/ScrollingCoordinator.h: Ditto.

* page/scrolling/ScrollingTreeNode.h: Added forward declaration
that used to be inherited from another file where it's not needed.

* platform/gamepad/cocoa/GameControllerGamepadProvider.mm:
(WebCore::GameControllerGamepadProvider::willHandleVendorAndProduct):
Use a switch statement.

* platform/gamepad/mac/HIDGamepadElement.h: Removed unneeded includes.
* platform/graphics/FontPlatformData.cpp: Ditto.
* platform/graphics/HEVCUtilities.cpp: Ditto.
* platform/graphics/IntRectHash.h: Ditto.

* platform/graphics/MIMETypeCache.cpp:
(WebCore::MIMETypeCache::isStaticContainerType): Renamed; this replaces
the old staticContainerTypeList function and just returns false.

* platform/graphics/MIMETypeCache.h: Replaced the staticContainerTypeList
fucntion with an isStaticContainerType function. Also made it, and one
other function, private.

* platform/graphics/avfoundation/objc/AVAssetMIMETypeCache.h: Updated
for the change to MIMETypeCache.

* platform/graphics/avfoundation/objc/AVAssetMIMETypeCache.mm:
(WebCore::AVAssetMIMETypeCache::isStaticContainerType): Use SortedArraySet.

* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h:
Removed unneeded includes.
* platform/graphics/coreimage/FilterEffectRendererCoreImage.h: Ditto.
* platform/mediastream/RealtimeMediaSourceSupportedConstraints.cpp: Ditto.
* platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.h: Ditto.
* platform/mediastream/mac/CoreAudioCaptureDeviceManager.h: Ditto.
* platform/mediastream/mac/CoreAudioCaptureSource.h: Ditto.
* platform/network/cf/FormDataStreamCFNet.cpp: Ditto.

* platform/network/mac/UTIUtilities.mm:
(WebCore::UTIFromUnknownMIMEType): Use SortedArrayMap. Also fixed a regression
from r271533 where we accidentally deleted the MIME type model/vnd.reality.

* rendering/ComplexLineLayout.cpp:
(WebCore::setLogicalWidthForTextRun): Use a range-based for loop.

* rendering/updating/RenderTreeUpdater.h: Removed unneeded includes.
* storage/StorageNamespaceProvider.h: Ditto.
* storage/StorageQuotaManager.h: Ditto.
* style/StyleUpdate.h: Ditto.
* svg/SVGFitToViewBox.h: Ditto.

* svg/SVGTests.cpp:
(WebCore::SVGTests::isValid const): Use SortedArraySet.
(WebCore::SVGTests::hasFeatureForLegacyBindings): Ditto.

Source/WebKit:

* NetworkProcess/NetworkLoad.cpp: Removed unneeded includes.
* NetworkProcess/NetworkResourceLoadMap.h: Ditto.
* Shared/SharedStringHashStore.h: Ditto.
* UIProcess/API/APIPageConfiguration.h: Ditto.
* UIProcess/API/Cocoa/WKWebsiteDataRecord.mm: Ditto.
* UIProcess/API/Cocoa/_WKInspector.mm: Ditto.
* UIProcess/Automation/SimulatedInputDispatcher.h: Ditto.
* UIProcess/Inspector/WebInspectorUIProxy.cpp: Ditto.
* UIProcess/Plugins/mac/PluginInfoStoreMac.mm: Ditto.
* UIProcess/WebPageGroup.h: Ditto.
* UIProcess/WebPasteboardProxy.h: Ditto.
* UIProcess/WebPreferences.h: Ditto.
* WebProcess/Geolocation/WebGeolocationManager.h: Ditto.
* WebProcess/WebPage/WebBackForwardListProxy.h: Ditto.

Source/WTF:

* wtf/SortedArrayMap.h: Added support for types that don't have a parse member function.

* wtf/cocoa/MainThreadCocoa.mm: Removed unneeded includes.
* wtf/text/AtomStringImpl.cpp: Ditto.
* wtf/text/AtomStringTable.cpp: Ditto.

Canonical link: https://commits.webkit.org/237226@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276880 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-02 03:09:34 +00:00
Adrien Destugues 067ed1a600 Merge commit '64d90e2833c6ba1d42029acb522543d3772ddeae' into haiku 2021-04-30 20:37:33 +02:00
Adrien Destugues 4f70bc5d40 Merge 'd9f40e97aec73d30021f41104087c450e7958f8c' into haiku branch 2021-04-25 19:38:40 +02:00
Lauro Moura 5a14e48f02 [WTF] Undefined behavior warning in StringBuilder::allocateBuffer
https://bugs.webkit.org/show_bug.cgi?id=224942

Reviewed by Chris Dumez.

* wtf/text/StringBuilder.cpp:
(WTF::StringBuilder::allocateBuffer): Add check before calling memcpy


Canonical link: https://commits.webkit.org/236944@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276485 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-23 05:06:43 +00:00
Yusuke Suzuki d98d24746a Define AtomString(ASCIILiteral) and use ASCIILiteral more to avoid memory allocation
https://bugs.webkit.org/show_bug.cgi?id=224125

Reviewed by Saam Barati.

Source/WebCore:

We apply "..."_s more. This avoids allocating of string storage when creating StringImpl.

* accessibility/AccessibilityObject.cpp:
(WebCore::initializeRoleMap):
* dom/ScriptElement.cpp:
(WebCore::isLegacySupportedJavaScriptLanguage):
* editing/EditorCommand.cpp:
(WebCore::createCommandMap):
* html/Autofill.cpp:
(WebCore::fieldNameMap):
* platform/LegacySchemeRegistry.cpp:
(WebCore::builtinLocalURLSchemes):
(WebCore::builtinSecureSchemes):
(WebCore::builtinSchemesWithUniqueOrigins):
(WebCore::builtinEmptyDocumentSchemes):
(WebCore::builtinCanDisplayOnlyIfCanRequestSchemes):
(WebCore::builtinCORSEnabledSchemes):
* platform/MIMETypeRegistry.cpp:
(WebCore::MIMETypeRegistry::systemPreviewMIMETypes):
* platform/graphics/FontCascade.cpp:
(WebCore::FontCascade::hasValidAverageCharWidth const):
* platform/graphics/HEVCUtilities.cpp:
(WebCore::codecStringForDoViCodecType):
(WebCore::profileIDForAlphabeticDoViProfile):
* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
(WebCore::MediaPlayerPrivateAVFoundation::staticMIMETypeList):
* platform/graphics/avfoundation/objc/AVAssetMIMETypeCache.mm:
(WebCore::AVAssetMIMETypeCache::staticContainerTypeList):
* platform/graphics/cg/ImageSourceCGWin.cpp:
(WebCore::preferredExtensionForImageType):
* svg/SVGTests.cpp:
(WebCore::supportedSVGFeatures):

Source/WTF:

Add AtomString(ASCIILiteral). ASCIILiteral ensures that storage is constant non-heap string by its type.
So we can just use it as a literal (not allocating a string storage).

* wtf/text/AtomString.h:


Canonical link: https://commits.webkit.org/236117@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-06 00:09:31 +00:00
Yusuke Suzuki 4fb6881d9c [WTF] Introduce RobinHoodHashTable
https://bugs.webkit.org/show_bug.cgi?id=223895

Reviewed by Fil Pizlo.

Source/JavaScriptCore:

* builtins/BuiltinNames.cpp:
(JSC::lookUpPrivateNameImpl):
(JSC::lookUpWellKnownSymbolImpl):
* builtins/BuiltinNames.h:
* bytecode/BytecodeIntrinsicRegistry.h:
* runtime/Identifier.h:
* runtime/IntlCollator.cpp:
(JSC::IntlCollator::initializeCollator):
(JSC::IntlCollator::checkICULocaleInvariants):
* runtime/IntlCollator.h:
* runtime/IntlDateTimeFormat.cpp:
(JSC::IntlDateTimeFormat::initializeDateTimeFormat):
* runtime/IntlDateTimeFormatConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* runtime/IntlDisplayNames.cpp:
(JSC::IntlDisplayNames::initializeDisplayNames):
* runtime/IntlDisplayNamesConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* runtime/IntlListFormat.cpp:
(JSC::IntlListFormat::initializeListFormat):
* runtime/IntlListFormatConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* runtime/IntlNumberFormat.cpp:
(JSC::IntlNumberFormat::initializeNumberFormat):
* runtime/IntlNumberFormatConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* runtime/IntlObject.cpp:
(JSC::addScriptlessLocaleIfNeeded):
(JSC::intlAvailableLocales):
(JSC::intlCollatorAvailableLocales):
(JSC::intlSegmenterAvailableLocales):
(JSC::bestAvailableLocale):
(JSC::lookupMatcher):
(JSC::bestFitMatcher):
(JSC::resolveLocale):
(JSC::lookupSupportedLocales):
(JSC::bestFitSupportedLocales):
(JSC::supportedLocales):
* runtime/IntlObject.h:
(JSC::intlDateTimeFormatAvailableLocales):
(JSC::intlDisplayNamesAvailableLocales):
(JSC::intlNumberFormatAvailableLocales):
(JSC::intlPluralRulesAvailableLocales):
(JSC::intlRelativeTimeFormatAvailableLocales):
(JSC::intlListFormatAvailableLocales):
* runtime/IntlPluralRules.cpp:
(JSC::IntlPluralRules::initializePluralRules):
* runtime/IntlPluralRulesConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* runtime/IntlRelativeTimeFormat.cpp:
(JSC::IntlRelativeTimeFormat::initializeRelativeTimeFormat):
* runtime/IntlRelativeTimeFormatConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* runtime/IntlSegmenter.cpp:
(JSC::IntlSegmenter::initializeSegmenter):
* runtime/IntlSegmenterConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* runtime/RegExpCache.h:
* runtime/RegExpKey.h:

Source/WebCore:

* Modules/mediacapabilities/MediaCapabilities.cpp:
(WebCore::bucketMIMETypes):
* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::popupValue const):
* dom/Element.cpp:
(WebCore::canAttachAuthorShadowRoot):
* dom/QualifiedName.h:
* dom/make_names.pl:
(printNamesHeaderFile):
(printFactoryCppFile):
(printWrapperFactoryCppFile):
* editing/FormatBlockCommand.cpp:
(WebCore::isElementForFormatBlock):
* editing/RemoveFormatCommand.cpp:
(WebCore::isElementForRemoveFormatCommand):
* editing/ReplaceSelectionCommand.cpp:
(WebCore::isProhibitedParagraphChild):
* html/Autofill.cpp:
(WebCore::fieldNameMap):
* html/HTMLDocument.cpp:
(WebCore::HTMLDocument::isCaseSensitiveAttribute):
* html/HTMLObjectElement.cpp:
(WebCore::preventsParentObjectFromExposure):
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::createCaseMap):
(WebCore::adjustSVGTagNameCase):
(WebCore::adjustAttributes):
(WebCore::createForeignAttributesMap):
(WebCore::adjustForeignAttributes):
(WebCore::addNamesWithPrefix): Deleted.
* page/DebugPageOverlays.cpp:
(WebCore::touchEventRegionColors):
(WebCore::NonFastScrollableRegionOverlay::drawRect):
* page/PerformanceUserTiming.cpp:
(WebCore::restrictedMarkNamesToNavigationTimingFunctionMap):
* platform/cocoa/MIMETypeRegistryCocoa.mm:
(WebCore::extensionsForMIMETypeMap):
* platform/graphics/FontCascade.cpp:
(WebCore::useBackslashAsYenSignForFamily):
(WebCore::FontCascade::hasValidAverageCharWidth const):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::validInitDataTypes):
* platform/graphics/cg/UTIRegistry.cpp:
(WebCore::defaultSupportedImageTypes):
* platform/graphics/cg/UTIRegistry.h:
* platform/graphics/cocoa/HEVCUtilitiesCocoa.mm:
(WebCore::codecTypeForDoViCodecString):
* platform/graphics/cocoa/SourceBufferParserWebM.cpp:
(WebCore::SourceBufferParserWebM::supportedVideoCodecs):
(WebCore::SourceBufferParserWebM::supportedAudioCodecs):
* platform/graphics/cocoa/SourceBufferParserWebM.h:
* rendering/svg/SVGResources.cpp:
(WebCore::clipperFilterMaskerTags):
(WebCore::markerTags):
(WebCore::fillAndStrokeTags):
(WebCore::chainableResourceTags):
* style/StyleAdjuster.cpp:
(WebCore::Style::hasEffectiveDisplayNoneForDisplayContents):
* svg/SVGAnimationElement.cpp:
(WebCore::SVGAnimationElement::isSupportedAttribute):
* svg/SVGElement.cpp:
(WebCore::createAttributeNameToCSSPropertyIDMap):
(WebCore::SVGElement::animatableAttributeForName):
(WebCore::SVGElement::cssPropertyIdForSVGAttributeName):
* svg/SVGTests.cpp:
(WebCore::SVGTests::addSupportedAttributes):
* svg/SVGTests.h:
* svg/SVGUseElement.cpp:
(WebCore::createAllowedElementSet):
(WebCore::isDisallowedElement):
* svg/animation/SVGSMILElement.cpp:
(WebCore::SVGSMILElement::isSupportedAttribute):
* xml/XPathFunctions.cpp:
(WebCore::XPath::createFunctionMap):
* xml/XPathParser.cpp:
(WebCore::XPath::createAxisNamesMap):

Source/WebKit:

* NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
(WebKit::ObservedDomainsTableSchemaV1Alternate):
(WebKit::expectedUnattributedColumns):
(WebKit::expectedAttributedColumns):
(WebKit::createTableQueries):
* Platform/IPC/ArgumentCoders.h:
* Shared/Cocoa/DefaultWebBrowserChecks.mm:
(WebKit::getAppBoundDomainsTesting):
* Shared/WebPreferencesStore.cpp:
(WebKit::WebPreferencesStore::decode):
* Shared/WebPreferencesStore.h:
* UIProcess/Cocoa/WebProcessProxyCocoa.mm:
(WebKit::WebProcessProxy::platformPathsWithAssumedReadAccess):
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::platformPathsWithAssumedReadAccess):
* UIProcess/WebProcessProxy.h:

Source/WTF:

This patch implements RobinHoodHashTable[1]. We don't use it as a default hashtable since it has different performance v.s. memory-saving characteristics,
and this patch's goal is not tackling on making this default. Rather, the goal of this patch is introducing it to non-performance sensitive area quickly
so that we can save memory. RobinHoodHashTable more frequently computes hash value compared to HashTable, so this is not drop-in replacement for the existing
one. But still, this is useful since we know that "while there are many small HashTables and they holds much memory, there are super large HashTables and
they holds almost same amount of memory while they are a few.". This patch's goal is applying this RobinHoodHashTable to these "large, but a few" singleton tables.

RobinHoodHashTable maintains distance-from-initial-bucket (DIB) small by adjusting existing entries when inserting. When inserting, if we found that the
existing entry has less DIB than the current inserting entry's DIB, then we swap entries, and insert the existing entry to the other place. This is giving
some good DIB from rich entry to poor entry (that's why it is called RobinHood Hashing), and making average DIB lower. And this algorithm adds good invariant
that, when looking up an entry, and we found that existing entry has smaller DIB, then we can stop searching in the middle of the chain since we know that
we should swap entries when this happened when inserting. These two tricks maintain HashTable performance even under significantly high load factor: 90% load-factor
just works. 95% load-factor regress adding performance, but still it does not become catastrophic compared to normal open-addressing HashTable.

We introduce RobinHoodHashTable, and adding several kinds of tables based on load-factors.

1. MemoryCompactLookupOnlyRobinHoodHashSet / HashMap

    This has 95% load-factor. This is suitable for sets and maps which is mostly-constant: constructing once, and looking up repeatedly. In WebKit, there are so
    many this kind of tables e.g. singleton HashMap for various kinds of things. We can use this super high load-factor table so that we can save memory even while
    we are maintains fast HashTable lookup.

2. MemoryCompactRobinHoodHashSet / HashMap

    This has 90% load-factor. It just works, and we can try using it if sets and maps are significantly performance intensive.

3. FastRobinHoodHashSet / HashMap

    This has 75% load-factor. This is still good compared to HashSet and HashMap since they are using 50% load-factor for large sized tables. This has very slightly performance regressed
    compared to 50% load-factor large HashSet and HashMap, but if that is not performance intensive (e.g. AtomStringTable is one of the most performance intensive table), this is good.

In this patch, we replace many singleton HashSet / HashMap with RobinHoodHashTable.

[1]: https://www.sebastiansylvan.com/post/robin-hood-hashing-should-be-your-default-hash-table-implementation/

* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/Forward.h:
* wtf/HashMap.h:
(WTF::Y>::swap):
(WTF::Y>::size const):
(WTF::Y>::capacity const):
(WTF::Y>::isEmpty const):
(WTF::Y>::begin):
(WTF::Y>::end):
(WTF::Y>::begin const):
(WTF::Y>::end const):
(WTF::Y>::find):
(WTF::Y>::find const):
(WTF::Y>::contains const):
(WTF::Y>::get const):
(WTF::Y>::inlineGet const):
(WTF::TableTraitsArg>::inlineSet):
(WTF::TableTraitsArg>::inlineAdd):
(WTF::TableTraitsArg>::inlineEnsure):
(WTF::TableTraitsArg>::set):
(WTF::TableTraitsArg>::add):
(WTF::TableTraitsArg>::fastAdd):
(WTF::TableTraitsArg>::ensure):
(WTF::Y>::remove):
(WTF::Y>::removeIf):
(WTF::Y>::clear):
(WTF::Y>::take):
(WTF::Y>::checkConsistency const):
(WTF::Y>::isValidKey):
(WTF::operator==):
(WTF::operator!=):
(WTF::X>::swap): Deleted.
(WTF::X>::size const): Deleted.
(WTF::X>::capacity const): Deleted.
(WTF::X>::isEmpty const): Deleted.
(WTF::X>::begin): Deleted.
(WTF::X>::end): Deleted.
(WTF::X>::begin const): Deleted.
(WTF::X>::end const): Deleted.
(WTF::X>::find): Deleted.
(WTF::X>::find const): Deleted.
(WTF::X>::contains const): Deleted.
(WTF::X>::get const): Deleted.
(WTF::X>::inlineGet const): Deleted.
(WTF::MappedTraitsArg>::inlineSet): Deleted.
(WTF::MappedTraitsArg>::inlineAdd): Deleted.
(WTF::MappedTraitsArg>::inlineEnsure): Deleted.
(WTF::MappedTraitsArg>::set): Deleted.
(WTF::MappedTraitsArg>::add): Deleted.
(WTF::MappedTraitsArg>::fastAdd): Deleted.
(WTF::MappedTraitsArg>::ensure): Deleted.
(WTF::MappedTraits>::get const): Deleted.
(WTF::MappedTraits>::inlineGet const): Deleted.
(WTF::X>::remove): Deleted.
(WTF::X>::removeIf): Deleted.
(WTF::X>::clear): Deleted.
(WTF::MappedTraits>::take): Deleted.
(WTF::X>::take): Deleted.
(WTF::X>::checkConsistency const): Deleted.
(WTF::X>::isValidKey): Deleted.
* wtf/HashSet.h:
(WTF::W>::swap):
(WTF::W>::size const):
(WTF::W>::capacity const):
(WTF::W>::isEmpty const):
(WTF::W>::begin const):
(WTF::W>::end const):
(WTF::W>::find const):
(WTF::W>::contains const):
(WTF::TableTraits>::find const):
(WTF::TableTraits>::contains const):
(WTF::TableTraits>::ensure):
(WTF::W>::add):
(WTF::W>::addVoid):
(WTF::TableTraits>::add):
(WTF::W>::remove):
(WTF::W>::removeIf):
(WTF::W>::clear):
(WTF::W>::take):
(WTF::W>::takeAny):
(WTF::TableTraits>::remove):
(WTF::TableTraits>::take):
(WTF::W>::isValidValue):
(WTF::= const):
(WTF::W>::checkConsistency const):
(WTF::V>::swap): Deleted.
(WTF::V>::size const): Deleted.
(WTF::V>::capacity const): Deleted.
(WTF::V>::isEmpty const): Deleted.
(WTF::V>::begin const): Deleted.
(WTF::V>::end const): Deleted.
(WTF::V>::find const): Deleted.
(WTF::V>::contains const): Deleted.
(WTF::Traits>::find const): Deleted.
(WTF::Traits>::contains const): Deleted.
(WTF::Traits>::ensure): Deleted.
(WTF::V>::add): Deleted.
(WTF::V>::addVoid): Deleted.
(WTF::Traits>::add): Deleted.
(WTF::V>::remove): Deleted.
(WTF::V>::removeIf): Deleted.
(WTF::V>::clear): Deleted.
(WTF::V>::take): Deleted.
(WTF::V>::takeAny): Deleted.
(WTF::Traits>::remove): Deleted.
(WTF::Traits>::take): Deleted.
(WTF::V>::isValidValue): Deleted.
(WTF::V>::checkConsistency const): Deleted.
* wtf/HashTable.h:
(WTF::addIterator):
(WTF::removeIterator):
(WTF::invalidateIterators):
(WTF::HashTable::~HashTable):
(WTF::HashTable::random):
(WTF::KeyTraits>::inlineLookup):
(WTF::KeyTraits>::lookupForWriting):
(WTF::KeyTraits>::fullLookupForWriting):
(WTF::KeyTraits>::addUniqueForInitialization):
(WTF::KeyTraits>::add):
(WTF::KeyTraits>::addPassingHashCode):
(WTF::KeyTraits>::removeAndInvalidateWithoutEntryConsistencyCheck):
(WTF::KeyTraits>::removeAndInvalidate):
(WTF::KeyTraits>::clear):
(WTF::KeyTraits>::swap):
(WTF::KeyTraits>::HashTable):
(WTF::HashTable::invalidateIterators): Deleted.
(WTF::KeyTraits>::invalidateIterators): Deleted.
* wtf/RobinHoodHashMap.h: Added.
* wtf/RobinHoodHashSet.h: Added.
* wtf/RobinHoodHashTable.h: Added.
(WTF::RobinHoodHashTable::~RobinHoodHashTable):
(WTF::RobinHoodHashTable::begin):
(WTF::RobinHoodHashTable::end):
(WTF::RobinHoodHashTable::begin const):
(WTF::RobinHoodHashTable::end const):
(WTF::RobinHoodHashTable::random):
(WTF::RobinHoodHashTable::random const):
(WTF::RobinHoodHashTable::size const):
(WTF::RobinHoodHashTable::capacity const):
(WTF::RobinHoodHashTable::isEmpty const):
(WTF::RobinHoodHashTable::reserveInitialCapacity):
(WTF::RobinHoodHashTable::add):
(WTF::RobinHoodHashTable::find):
(WTF::RobinHoodHashTable::find const):
(WTF::RobinHoodHashTable::contains const):
(WTF::RobinHoodHashTable::isEmptyBucket):
(WTF::RobinHoodHashTable::isEmptyOrDeletedBucket):
(WTF::RobinHoodHashTable::lookup):
(WTF::RobinHoodHashTable::checkTableConsistency):
(WTF::RobinHoodHashTable::internalCheckTableConsistency const):
(WTF::RobinHoodHashTable::internalCheckTableConsistencyExceptSize const):
(WTF::RobinHoodHashTable::internalCheckTableConsistencyExceptSize):
(WTF::RobinHoodHashTable::internalCheckTableConsistency):
(WTF::RobinHoodHashTable::shouldExpand):
(WTF::RobinHoodHashTable::computeTableHash):
(WTF::RobinHoodHashTable::shouldExpand const):
(WTF::RobinHoodHashTable::shouldShrink const):
(WTF::RobinHoodHashTable::shrink):
(WTF::RobinHoodHashTable::deleteBucket):
(WTF::RobinHoodHashTable::desiredIndex):
(WTF::RobinHoodHashTable::probeDistance):
(WTF::RobinHoodHashTable::makeIterator):
(WTF::RobinHoodHashTable::makeConstIterator const):
(WTF::RobinHoodHashTable::makeKnownGoodIterator):
(WTF::RobinHoodHashTable::makeKnownGoodConstIterator const):
(WTF::RobinHoodHashTable::checkTableConsistencyExceptSize):
(WTF::RobinHoodHashTable::tableSize const):
(WTF::RobinHoodHashTable::tableSizeMask const):
(WTF::RobinHoodHashTable::keyCount const):
(WTF::RobinHoodHashTable::tableHash const):
(WTF::SizePolicy>::checkKey):
(WTF::SizePolicy>::lookup):
(WTF::SizePolicy>::inlineLookup):
(WTF::SizePolicy>::initializeBucket):
(WTF::SizePolicy>::add):
(WTF::SizePolicy>::maintainProbeDistanceForAdd):
(WTF::SizePolicy>::addPassingHashCode):
(WTF::SizePolicy>::reinsert):
(WTF::SizePolicy>::find):
(WTF::SizePolicy>::find const):
(WTF::SizePolicy>::contains const):
(WTF::SizePolicy>::removeAndInvalidateWithoutEntryConsistencyCheck):
(WTF::SizePolicy>::removeAndInvalidate):
(WTF::SizePolicy>::remove):
(WTF::SizePolicy>::removeWithoutEntryConsistencyCheck):
(WTF::SizePolicy>::allocateTable):
(WTF::SizePolicy>::deallocateTable):
(WTF::SizePolicy>::expand):
(WTF::SizePolicy>::computeBestTableSize):
(WTF::SizePolicy>::shrinkToBestSize):
(WTF::SizePolicy>::rehash):
(WTF::SizePolicy>::clear):
(WTF::SizePolicy>::RobinHoodHashTable):
(WTF::SizePolicy>::swap):
(WTF::=):
(WTF::SizePolicy>::checkTableConsistency const):
(WTF::SizePolicy>::checkTableConsistencyExceptSize const):
* wtf/text/AtomStringHash.h:
* wtf/text/AtomStringImpl.cpp:
* wtf/text/AtomStringTable.cpp:
(WTF::AtomStringTable::~AtomStringTable):
* wtf/text/AtomStringTable.h:
(WTF::AtomStringTable::table):
* wtf/text/StringHash.h:

Tools:

* TestWebKitAPI/CMakeLists.txt:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/DeletedAddressOfOperator.h:
* TestWebKitAPI/Tests/WTF/HashMap.cpp:
(TestWebKitAPI::testMovingUsingEnsure):
(TestWebKitAPI::testMovingUsingAdd):
* TestWebKitAPI/Tests/WTF/HashSet.cpp:
(TestWebKitAPI::generateTestCapacityUpToSize<0>):
(TestWebKitAPI::generateTestCapacityUpToSize):
* TestWebKitAPI/Tests/WTF/MoveOnly.h:
* TestWebKitAPI/Tests/WTF/RobinHoodHashMap.cpp: Copied from Tools/TestWebKitAPI/Tests/WTF/HashMap.cpp.
(TestWebKitAPI::TEST):
(TestWebKitAPI::bucketForKey):
(TestWebKitAPI::ZeroHash::hash):
(TestWebKitAPI::ObjectWithRefLogger::ObjectWithRefLogger):
(TestWebKitAPI::testMovingUsingEnsure):
(TestWebKitAPI::testMovingUsingAdd):
(TestWebKitAPI::DerefObserver::ref):
(TestWebKitAPI::DerefObserver::deref):
(TestWebKitAPI::TestObjectWithCustomDestructor::TestObjectWithCustomDestructor):
(TestWebKitAPI::TestObjectWithCustomDestructor::~TestObjectWithCustomDestructor):
* TestWebKitAPI/Tests/WTF/RobinHoodHashSet.cpp: Copied from Tools/TestWebKitAPI/Tests/WTF/HashSet.cpp.
(TestWebKitAPI::capacityForSize):
(TestWebKitAPI::testInitialCapacity):
(TestWebKitAPI::generateTestCapacityUpToSize<0>):
(TestWebKitAPI::generateTestCapacityUpToSize):
(TestWebKitAPI::TEST):
(TestWebKitAPI::DerefObserver::ref):
(TestWebKitAPI::DerefObserver::deref):

Canonical link: https://commits.webkit.org/236073@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275410 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-02 08:33:32 +00:00
Adrien Destugues 26916f086c Merge commit 'e98c8002727a676a11981f290452a9f39dfc1b67' into haiku 2021-03-27 21:53:05 +01:00
Adrien Destugues 15aa9c7f7b Merge commit 'd159f8bec75790a9b50cbe42f16dda4236bc4f00' into haiku 2021-03-27 16:37:25 +01:00
Yusuke Suzuki 8929b67592 All string resources from UserAgentStyleSheets / UserAgentScripts should be used as non-copying StringImpl
https://bugs.webkit.org/show_bug.cgi?id=223685

Reviewed by Saam Barati.

Source/WebCore:

We use StringImpl::createWithoutCopying for string resources from UserAgentStyleSheets / UserAgentScripts to make sure that
these resources do not allocate heap strings.

This patch also fixes HTMLMeterElement's bug (and imageOverlayUserAgentStyleSheet's bug). Previously, we are using String::ConstructFromLiteral,
but this only accepts string literal as it says. As a result, we are dropping the last character since UserAgentStyleSheets's last character is not \0.

* Modules/plugins/QuickTimePluginReplacement.mm:
(WebCore::quickTimePluginReplacementScript):
* WebCoreMacros.cmake:
* dom/Document.cpp:
(WebCore::Document::ensurePlugInsInjectedScript):
* html/HTMLElement.cpp:
(WebCore::HTMLElement::updateWithImageExtractionResult):
* html/HTMLMeterElement.cpp:
(WebCore::HTMLMeterElement::didAddUserAgentShadowRoot):
* rendering/RenderThemeAdwaita.cpp:
(WebCore::RenderThemeAdwaita::extraDefaultStyleSheet):
(WebCore::RenderThemeAdwaita::extraMediaControlsStyleSheet):
(WebCore::RenderThemeAdwaita::mediaControlsScripts):
* rendering/RenderThemeCocoa.mm:
(WebCore::RenderThemeCocoa::mediaControlsStyleSheet):
(WebCore::RenderThemeCocoa::mediaControlsScripts):
* rendering/RenderThemeWin.cpp:
(WebCore::RenderThemeWin::extraDefaultStyleSheet):
(WebCore::RenderThemeWin::extraQuirksStyleSheet):
* style/UserAgentStyle.cpp:
(WebCore::Style::UserAgentStyle::initDefaultStyleSheet):
(WebCore::Style::UserAgentStyle::ensureDefaultStyleSheetsForElement):

Source/WebDriver:

* Session.cpp:
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::findElements):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::elementClear):

Source/WTF:

Add StringImpl::createWithoutCopying for `const char*`.

* wtf/text/StringImpl.h:
(WTF::StringImpl::createWithoutCopying):

LayoutTests:

* fast/dom/HTMLMeterElement/meter-element-markup-expected.txt:

Canonical link: https://commits.webkit.org/235738@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274997 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-25 01:55:58 +00:00
Chris Dumez 0b98d90157 Address undefined behavior found by UBSan in StringToIntegerConversion.h
https://bugs.webkit.org/show_bug.cgi?id=223694

Reviewed by Geoffrey Garen.

Source/WTF:

Update StringToIntegerConversion to deal with overflows in a well-defined manner,
by relying on CheckedArithmetics. This addresses undefined behavior reborted by
UBSan:
- wtf/text/StringToIntegerConversion.h:94:30: runtime error: signed integer overflow: 2147483640 + 8 cannot be represented in type 'int'
- wtf/text/StringToIntegerConversion.h:104:17: runtime error: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself

* wtf/text/StringToIntegerConversion.h:
(WTF::toIntegralType):

Tools:

Add API test coverage.

* TestWebKitAPI/Tests/WTF/StringView.cpp:
(TestWebKitAPI::TEST):

Canonical link: https://commits.webkit.org/235712@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274959 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-24 19:30:31 +00:00
Alex Christensen daa5409004 Remove unused WTF::String::percentage
https://bugs.webkit.org/show_bug.cgi?id=223651

Patch by Alex Christensen <achristensen@webkit.org> on 2021-03-23
Reviewed by Chris Dumez.

* wtf/text/AtomString.h:
* wtf/text/WTFString.cpp:
(WTF::String::percentage const): Deleted.
* wtf/text/WTFString.h:

Canonical link: https://commits.webkit.org/235671@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274896 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-23 20:32:53 +00:00
Chris Dumez a139f507b0 wtf/text/IntegerToStringConversion.h:54:104: runtime error: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself
https://bugs.webkit.org/show_bug.cgi?id=223614

Reviewed by Darin Adler.

Source/WTF:

numberToStringSigned() was calling -number when number is negative. This could trigger undefined behavior
since -number may not be representable in the input type. For example, if the type was int and number was
INT_MIN, -INT_MIN would overflow and the result would be undefined. To address the issue, we now cast
number to the destination *unsigned* type *before* negating it.

* wtf/text/IntegerToStringConversion.h:
(WTF::numberToStringSigned):

Tools:

Add API test coverage.

* TestWebKitAPI/Tests/WTF/StringBuilder.cpp:
(TestWebKitAPI::TEST):


Canonical link: https://commits.webkit.org/235660@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274878 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-23 16:54:05 +00:00
Alex Christensen f5f6def6a2 Optimize StringView::CodePoints::Iterator
https://bugs.webkit.org/show_bug.cgi?id=162315

Reviewed by Darin Adler.

This stores range pointers in the iterator instead of a pointer to a pointer.

* wtf/text/StringView.h:
(WTF::StringView::CodePoints::Iterator::Iterator):
(WTF::StringView::CodePoints::Iterator::operator++):
(WTF::StringView::CodePoints::Iterator::operator* const):
(WTF::StringView::CodePoints::Iterator::operator== const):



Canonical link: https://commits.webkit.org/235654@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274872 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-23 15:56:50 +00:00
Chris Dumez f54a332cae Introduce ensureOnMainThread()
https://bugs.webkit.org/show_bug.cgi?id=223105

Reviewed by Darin Adler.

Introduce ensureOnMainThread(), similarly to the recently added ensureOnMainThreadRunLoop(). It runs
the task synchronously when on the main thread, otherwise dispatches the task to the main thread.

Source/WebCore:

* accessibility/AccessibilityObjectInterface.h:
(WebCore::Accessibility::performFunctionOnMainThread):
(WebCore::Accessibility::retrieveValueFromMainThread):
(WebCore::Accessibility::retrieveAutoreleasedValueFromMainThread):
* dom/MessagePort.cpp:
(WebCore::MessagePort::close):
* dom/messageports/MessagePortChannelProviderImpl.cpp:
(WebCore::MessagePortChannelProviderImpl::createNewMessagePortChannel):
(WebCore::MessagePortChannelProviderImpl::entangleLocalPortInThisProcessToRemote):
(WebCore::MessagePortChannelProviderImpl::messagePortDisentangled):
(WebCore::MessagePortChannelProviderImpl::messagePortClosed):
(WebCore::MessagePortChannelProviderImpl::postMessageToRemote):
(WebCore::MessagePortChannelProviderImpl::takeAllMessagesForPort):
(WebCore::MessagePortChannelProviderImpl::checkRemotePortForActivity):
(WebCore::MessagePortChannelProviderImpl::performActionOnMainThread): Deleted.
* dom/messageports/MessagePortChannelProviderImpl.h:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::enqueueTaskForDispatcher):
* page/WheelEventTestMonitor.cpp:
(WebCore::WheelEventTestMonitor::scheduleCallbackCheck):
* platform/GenericTaskQueue.cpp:
(WebCore::TaskDispatcher<Timer>::postTask):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(ensureOnMainThread): Deleted.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
(-[WebRootSampleBufferBoundsChangeListener observeValueForKeyPath:ofObject:change:context:]):
* platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::invalidateFontCache):
* platform/graphics/cocoa/WebCoreDecompressionSession.mm:
(WebCore::WebCoreDecompressionSession::maybeBecomeReadyForMoreMediaData):
* platform/mediastream/CaptureDeviceManager.cpp:
(WebCore::CaptureDeviceManager::deviceChanged):
* platform/mediastream/RealtimeOutgoingVideoSource.cpp:
(WebCore::RealtimeOutgoingVideoSource::applyRotation):
* platform/mediastream/mac/CoreAudioCaptureSource.cpp:
(WebCore::CoreAudioCaptureSourceFactory::beginInterruption):
(WebCore::CoreAudioCaptureSourceFactory::endInterruption):
(WebCore::CoreAudioCaptureSourceFactory::scheduleReconfiguration):
* platform/network/cocoa/WebCoreNSURLSession.mm:
(-[WebCoreNSURLSessionDataTask resource:receivedRedirect:request:completionHandler:]):
* platform/network/curl/CurlRequest.cpp:
(WebCore::CurlRequest::runOnMainThread):

Source/WebKitLegacy:

* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::setOriginDetails):

Source/WTF:

* wtf/MainThread.cpp:
(WTF::ensureOnMainThread):
* wtf/MainThread.h:
* wtf/ThreadSafeRefCounted.h:
(WTF::ThreadSafeRefCounted::deref const):
* wtf/text/cf/StringImplCF.cpp:
(WTF::StringWrapperCFAllocator::deallocate):
* wtf/unix/MemoryPressureHandlerUnix.cpp:
(WTF::MemoryPressureHandler::triggerMemoryPressureEvent):


Canonical link: https://commits.webkit.org/235212@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274324 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-12 04:48:22 +00:00
Chris Dumez 27d4cf22ef Use RetainPtr<> / OSObjectPtr<> more in WebKit
https://bugs.webkit.org/show_bug.cgi?id=223030

Reviewed by Darin Adler.

Source/JavaScriptCore:

* inspector/remote/cocoa/RemoteInspectorCocoa.mm:
(Inspector::RemoteInspector::setupXPCConnectionIfNeeded):
* inspector/remote/cocoa/RemoteInspectorXPCConnection.h:
* inspector/remote/cocoa/RemoteInspectorXPCConnection.mm:
(Inspector::RemoteInspectorXPCConnection::RemoteInspectorXPCConnection):
(Inspector::RemoteInspectorXPCConnection::closeFromMessage):
(Inspector::RemoteInspectorXPCConnection::closeOnQueue):
(Inspector::RemoteInspectorXPCConnection::handleEvent):
(Inspector::RemoteInspectorXPCConnection::sendMessage):
* jsc.cpp:
(jscmain):

Source/WebCore:

* bridge/objc/objc_class.mm:
(JSC::Bindings::classesByIsA):
(JSC::Bindings::_createClassesByIsAIfNecessary):
(JSC::Bindings::ObjcClass::classForIsA):
* editing/SmartReplaceCF.cpp:
(WebCore::getSmartSet):
* page/cocoa/ResourceUsageOverlayCocoa.mm:
(WebCore::createColor):
(WebCore::ResourceUsageOverlay::platformInitialize):
(WebCore::drawGraphLabel):
(WebCore::drawCpuHistory):
(WebCore::drawGCHistory):
(WebCore::ResourceUsageOverlay::platformDraw):
* platform/cf/win/CertificateCFWin.cpp:
(WebCore::createCertContextDeallocator):
(WebCore::copyCertificateToData):
* platform/graphics/FontPlatformData.h:
* platform/graphics/Pattern.h:
* platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
(WebCore::AVFWrapper::dispatchQueue const):
(WebCore::createMetadataKeyNames):
(WebCore::metadataKeyNames):
(WebCore::AVFWrapper::AVFWrapper):
(WebCore::AVFWrapper::~AVFWrapper):
(WebCore::AVFWrapper::createAssetForURL):
(WebCore::AVFWrapper::createPlayer):
(WebCore::AVFWrapper::createPlayerItem):
(WebCore::AVFWrapper::checkPlayability):
(WebCore::AVFWrapper::createAVCFVideoLayer):
* platform/graphics/cg/ColorCG.cpp:
(WTF::RetainPtr<CGColorRef>>::createValueForKey):
(WebCore::createCGColor):
(WebCore::cachedCGColor):
* platform/graphics/cg/ColorSpaceCG.cpp:
(WebCore::namedColorSpace):
* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContext::applyStrokePattern):
(WebCore::GraphicsContext::applyFillPattern):
* platform/graphics/cg/GraphicsContextPlatformPrivateCG.h:
(WebCore::GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate):
* platform/graphics/cg/PathCG.cpp:
(WebCore::createScratchContext):
(WebCore::scratchContext):
(WebCore::copyCGPathClosingSubpaths):
(WebCore::Path::contains const):
* platform/graphics/cg/PatternCG.cpp:
(WebCore::Pattern::createPlatformPattern const):
* platform/graphics/coretext/FontPlatformDataCoreText.cpp:
(WebCore::FontPlatformData::FontPlatformData):
* platform/graphics/cv/ImageTransferSessionVT.mm:
(WebCore::ImageTransferSessionVT::createPixelBuffer):
* platform/graphics/mac/ComplexTextControllerCoreText.mm:
(WebCore::ComplexTextController::collectComplexTextRunsForCharacters):
* platform/graphics/mac/SimpleFontDataCoreText.cpp:
(WebCore::Font::getCFStringAttributes const):
* platform/graphics/win/GraphicsContextCGWin.cpp:
(WebCore::CGContextWithHDC):
* platform/ios/Device.cpp:
(WebCore::deviceName):
* platform/ios/DragImageIOS.mm:
(WebCore::cascadeForSystemFont):
* platform/ios/wak/WebCoreThread.mm:
(webThreadReleaseSource):
(webThreadReleaseObjArray):
(delegateSource):
(mainRunLoopAutoUnlockObserver):
(SendDelegateMessage):
(WebThreadAdoptAndRelease):
(HandleWebThreadReleaseSource):
(MainRunLoopAutoUnlock):
(_WebThreadAutoLock):
(_WebRunLoopEnableNestedFromMainThread):
(_WebRunLoopDisableNestedFromMainThread):
(RunWebThread):
(StartWebThread):
* platform/ios/wak/WebCoreThreadRun.cpp:
* platform/mac/PowerObserverMac.cpp:
(WebCore::PowerObserver::PowerObserver):
(WebCore::PowerObserver::~PowerObserver):
* platform/mac/PowerObserverMac.h:
* platform/mediarecorder/cocoa/AudioSampleBufferCompressor.h:
* platform/mediarecorder/cocoa/AudioSampleBufferCompressor.mm:
(WebCore::AudioSampleBufferCompressor::AudioSampleBufferCompressor):
(WebCore::AudioSampleBufferCompressor::~AudioSampleBufferCompressor):
(WebCore::AudioSampleBufferCompressor::finish):
(WebCore::AudioSampleBufferCompressor::addSampleBuffer):
* platform/mediarecorder/cocoa/VideoSampleBufferCompressor.h:
* platform/mediarecorder/cocoa/VideoSampleBufferCompressor.mm:
(WebCore::VideoSampleBufferCompressor::VideoSampleBufferCompressor):
(WebCore::VideoSampleBufferCompressor::~VideoSampleBufferCompressor):
(WebCore::VideoSampleBufferCompressor::finish):
(WebCore::VideoSampleBufferCompressor::addSampleBuffer):
* platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.h:
* platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.mm:
(WebCore::AVAudioSessionCaptureDeviceManager::AVAudioSessionCaptureDeviceManager):
(WebCore::AVAudioSessionCaptureDeviceManager::~AVAudioSessionCaptureDeviceManager):
(WebCore::AVAudioSessionCaptureDeviceManager::refreshAudioCaptureDevices):
(WebCore::AVAudioSessionCaptureDeviceManager::getCaptureDevices):
(WebCore::AVAudioSessionCaptureDeviceManager::disableAllDevicesQuery):
* platform/network/NetworkStorageSession.h:
* platform/network/cf/AuthenticationCF.cpp:
(WebCore::createCF):
* platform/network/cf/AuthenticationCF.h:
* platform/network/cf/CertificateInfoCFNet.cpp:
(WebCore::CertificateInfo::certificateChainFromSecTrust):
* platform/network/cf/CredentialStorageCFNet.cpp:
(WebCore::copyCredentialFromProtectionSpace):
(WebCore::CredentialStorage::getFromPersistentStorage):
* platform/network/cf/LoaderRunLoopCF.cpp:
(WebCore::loaderRunLoop):
* platform/network/cf/NetworkStorageSessionCFNetWin.cpp:
(WebCore::createPrivateStorageSession):
* platform/network/cf/ProtectionSpaceCFNet.cpp:
(WebCore::ProtectionSpace::receivesCredentialSecurely const):
* platform/network/cf/ResourceHandleCFNet.cpp:
(WebCore::ResourceHandle::tryHandlePasswordBasedAuthentication):
(WebCore::ResourceHandle::receivedCredential):
(WebCore::ResourceHandle::platformLoadResourceSynchronously):
* platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp:
(WebCore::getRunLoop):
* platform/network/cf/ResourceRequestCFNet.cpp:
(WebCore::siteForCookies):
(WebCore::ResourceRequest::doUpdatePlatformRequest):
(WebCore::ResourceRequest::doUpdatePlatformHTTPBody):
(WebCore::ResourceRequest::setStorageSession):
* platform/network/cocoa/NetworkStorageSessionCocoa.mm:
(WebCore::createPrivateStorageSession):
* platform/network/ios/WebCoreURLResponseIOS.mm:
(WebCore::createExtensionToMIMETypeMap):
(WebCore::adjustMIMETypeIfNecessary):
* platform/network/mac/WebCoreURLResponse.mm:
(WebCore::createExtensionToMIMETypeMap):
(WebCore::adjustMIMETypeIfNecessary):
* platform/text/mac/TextBoundaries.mm:
(WebCore::tokenizerForString):
* platform/win/DragImageCGWin.cpp:
(WebCore::allocImage):
* rendering/RenderThemeIOS.mm:
(WebCore::getSharedFunctionRef):
* testing/cocoa/WebArchiveDumpSupport.mm:
(WebCoreTestSupport::createCFURLResponseFromResponseData):
(WebCoreTestSupport::convertWebResourceResponseToDictionary):

Source/WebKit:

* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::newTestingSession):
(WebKit::NetworkProcess::ensureSession):
* NetworkProcess/NetworkProcess.h:
* NetworkProcess/cocoa/NetworkProcessCocoa.mm:
(WebKit::NetworkProcess::clearDiskCache):
* NetworkProcess/mac/NetworkProcessMac.mm:
(WebKit::NetworkProcess::platformTerminate):
* Platform/IPC/Connection.h:
* Platform/IPC/cocoa/ConnectionCocoa.mm:
(IPC::Connection::platformInvalidate):
(IPC::Connection::cancelReceiveSource):
(IPC::Connection::open):
(IPC::Connection::initializeSendSource):
(IPC::Connection::receiveSourceEventHandler):
* Shared/Cocoa/DefaultWebBrowserChecks.mm:
(WebKit::itpQueue):
(WebKit::determineITPState):
(WebKit::doesAppHaveITPEnabled):
* Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceMain.mm:
(WebKit::XPCServiceEventHandler):
* Shared/ShareableResource.cpp:
(WebKit::createShareableResourceDeallocator):
(WebKit::ShareableResource::wrapInSharedBuffer):
* Shared/cf/ArgumentCodersCF.cpp:
(IPC::decode):
* UIProcess/mac/LegacySessionStateCoding.cpp:
(WebKit::encodeSessionHistoryEntryData):
* WebProcess/WebPage/Cocoa/WebCookieCacheCocoa.mm:
(WebKit::WebCookieCache::inMemoryStorageSession):
* WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h:
* WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm:
(WebKit::RemoteLayerTreeDrawingArea::RemoteLayerTreeDrawingArea):
(WebKit::RemoteLayerTreeDrawingArea::updateRendering):

Source/WebKitLegacy:

223030_RetainPtr

* WebCoreSupport/NetworkStorageSessionMap.cpp:
(NetworkStorageSessionMap::switchToNewTestingSession):
(NetworkStorageSessionMap::ensureSession):

Source/WebKitLegacy/ios:

* WebView/WebPDFViewIOS.mm:
(createCGColorWithDeviceWhite):
(+[WebPDFView shadowColor]):
(+[WebPDFView backgroundColor]):

Source/WebKitLegacy/mac:

* Misc/WebElementDictionary.mm:
(lookupTable):
(addLookupKey):
(+[WebElementDictionary initializeLookupTable]):
(-[WebElementDictionary _fillCache]):
(-[WebElementDictionary objectForKey:]):
* WebView/WebView.mm:
(+[WebView _makeAllWebViewsPerformSelector:]):
(-[WebView _removeFromAllWebViewsSet]):
(-[WebView _addToAllWebViewsSet]):
(+[WebView closeAllWebViews]):
(+[WebView _maxCacheModelInAnyInstance]):

Source/WebKitLegacy/win:

* WebApplicationCache.cpp:
(WebApplicationCache::originsWithCache):
* WebDownloadCFNet.cpp:
(WebDownload::useCredential):
(WebDownload::didReceiveAuthenticationChallenge):
* WebKitQuartzCoreAdditions/CAD3DRenderer.cpp:
(WKQCA::updateBounds):
* WebLocalizableStrings.cpp:
(LocalizedString::LocalizedString):
(LocalizedString::operator CFStringRef const):
(LocalizedString::operator LPCTSTR const):
(copyLocalizedStringFromBundle):
* WebPreferences.cpp:
(defaultSettings):
(WebPreferences::initializeDefaultSettings):
(WebPreferences::valueForKey):
(WebPreferences::copyWebKitPreferencesToCFPreferences):

Source/WTF:

* wtf/MemoryPressureHandler.cpp:
(WTF::MemoryPressureHandler::setDispatchQueue):
* wtf/MemoryPressureHandler.h:
* wtf/WorkQueue.h:
* wtf/cocoa/MemoryPressureHandlerCocoa.mm:
(WTF::MemoryPressureHandler::install):
(WTF::MemoryPressureHandler::uninstall):
(WTF::MemoryPressureHandler::holdOff):
* wtf/cocoa/WorkQueueCocoa.cpp:
(WTF::WorkQueue::dispatch):
(WTF::WorkQueue::dispatchAfter):
(WTF::WorkQueue::platformInitialize):
(WTF::WorkQueue::platformInvalidate):
* wtf/text/cf/StringImplCF.cpp:
(WTF::StringWrapperCFAllocator::allocator):
(WTF::StringImpl::createCFString):

Tools:

* DumpRenderTree/cg/PixelDumpSupportCG.cpp:
(createBitmapContext):
* DumpRenderTree/cg/PixelDumpSupportCG.h:
(BitmapContext::createByAdoptingBitmapAndContext):
(BitmapContext::BitmapContext):
* DumpRenderTree/mac/DumpRenderTree.mm:
(WebThreadLockAfterDelegateCallbacksHaveCompleted):
* DumpRenderTree/win/PixelDumpSupportWin.cpp:
(createBitmapContextFromWebView):
* ImageDiff/ImageDiff.xcodeproj/project.pbxproj:
* ImageDiff/cg/PlatformImageCG.cpp:
(ImageDiff::PlatformImage::pixels const):
* WebKitTestRunner/cg/TestInvocationCG.cpp:
(WTR::createCGContextFromCGImage):
(WTR::createCGContextFromImage):
(WTR::TestInvocation::dumpPixelsAndCompareWithExpected):

Canonical link: https://commits.webkit.org/235156@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274252 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-11 01:08:15 +00:00