source:
webkit/trunk/Source/WebCore/css/CSSPaintImageValue.cpp
Last change on this file was 277967, checked in by Darin Adler, 4 years ago | |
---|---|
Remove StringBuilder::appendLiteral
Reviewed by Chris Dumez.
Source/JavaScriptCore:
(PingPongStackOverflowObject_hasInstance): Use append instead of appendLiteral.
(Deprecated::ScriptCallArgumentHandler::appendArgument): Remove unnecessary cast
(JSC::ArrayPatternNode::toString const): Use append instead of appendLiteral.
(JSC::HeapSnapshotBuilder::json): Use append instead of appendLiteral.
(Inspector::InspectorAuditAgent::run): Use makeString instead of StringBuilder.
(JSC::IdentifierArena::makePrivateIdentifier): Use auto for the result of makeString.
(JSC::ConsoleClient::printConsoleMessage): Use append instead of appendLiteral.
(JSC::formatDateTime): Ditto.
(JSC::ErrorInstance::sanitizedToString): Use makeString instead of StringBuilder.
(JSC::notAFunctionSourceAppender): Use append instead of appendLiteral.
(JSC::IntlDateTimeFormat::initializeDateTimeFormat): Ditto.
(JSC::IntlNumberFormat::initializeNumberFormat): Ditto.
(JSC::JSCustomGetterFunction::create): Use auto and cut down on reference count
(JSC::JSCustomSetterFunction::create): Ditto.
append for better efficiency.
(JSC::Stringifier::appendStringifiedValue): Use append instead of appendLiteral.
Unrelated to StringBuilder::appendLiteral, but dead code.
(JSC::Options::dumpOption): Use append instead of appendLiteral.
(JSC::appendLineTerminatorEscape<UChar>): Ditto.
(JSC::SamplingProfiler::reportTopFunctions): Use auto for the result of makeString.
(JSC::TypeProfiler::typeInformationForExpressionAtOffset): Use append instead of
(JSC::TypeSet::dumpTypes const): Use append instead of appendLiteral.
Source/WebCore:
(WebCore::packageFormData): Use auto for the result of makeString.
(WebCore::IDBKeyData::loggingString const): Use append instead
(WebCore::IDBServer::SQLiteIDBBackingStore::addRecord): Use auto
(WebCore::IDBServer::buildPreIndexStatement): Use makeString
(WebCore::encodeProtocolString): Use append instead of appendLiteral.
(WebCore::WebSocketExtensionDispatcher::appendAcceptedExtension): Ditto.
(WebCore::WebSocketHandshake::clientHandshakeMessage const): Use
(formatForDebugger): Use makeString instead of StringBuilder.
(WebCore::ContentExtensions::prefixTreeVertexToString): Use
(WebCore::buildCircleString): Ditto.
(WebCore::CSSLinearGradientValue::customCSSText const): Ditto.
(WebCore::CSSGridIntegerRepeatValue::customCSSText const):
(WebCore::CSSImageSetValue::customCSSText const): Use append
(WebCore::CSSImportRule::cssText const): Use makeString instead
(WebCore::StyleRuleKeyframe::cssText const): Ditto.
(WebCore::CSSKeyframesRule::cssText const): Use variadic append.
(WebCore::CSSLineBoxContainValue::customCSSText const): Use
(WebCore::CSSNamespaceRule::cssText const): Ditto.
(WebCore::CSSPageRule::cssText const): Use makeString instead of
(WebCore::CSSPaintImageValue::customCSSText const): Ditto.
(WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText const):
(WebCore::appendLangArgumentList): Use variadic append.
(WebCore::CSSSelectorList::buildSelectorsText const): Use
(WebCore::CSSStyleSheet::CSSStyleSheet): Moved more of the
(WebCore::CSSStepsTimingFunctionValue::customCSSText const):
(WebCore::MediaQuerySet::mediaText const): Use append instead
(WebCore::MediaQuery::serialize const): Ditto.
(WebCore::MediaQueryExpression::serialize const): Use makeString
(WebCore::StyleProperties::getLayeredShorthandValue const):
(WebCore::CSSParserToken::serialize const): Removed a lot of
(WebCore::Document::initSecurityContext): Use auto for the result
(WebCore::appendAttributes): Use variadic append and append
(WebCore::SecurityContext::parseSandboxPolicy): Ditto.
(WebCore::convertHTMLTextToInterchangeFormat): Ditto.
(WebCore::createSearcher): Use auto for the result of makeString.
(WebCore::StyledMarkupAccumulator::appendStyleNodeOpenTag):
(WebCore::recordFormStructure): Ditto.
(WebCore::HTMLFormControlElement::reportValidity): Use auto for
(WebCore::HTMLFormElement::validateInteractively): Ditto.
(WebCore::HTMLImageElement::completeURLsInAttributeValue const):
(WebCore::restrictionNames): Use auto for the result of makeString.
(WebCore::WebGLRenderingContextBase::getUniformLocation): Ditto.
(WebCore::HTMLTreeBuilder::ExternalCharacterTokenBuffer::takeRemaining): Ditto.
(WebCore::buildConsoleError): Use makeString instead of StringBuilder.
(WebCore::TextTrackCue::rebuildDisplayTree): Ditto.
(WebCore::expressionForEvaluatingCommand): Use append instead of appendLiteral.
(WebCore::InspectorOverlay::drawElementTitle): Use auto for the result of makeString.
(WebCore::InspectorStyleSheet::addRule): Use append instead of appendLiteral.
(WebCore::InspectorApplicationCacheAgent::buildObjectForApplicationCacheResource):
(WebCore::WebConsoleAgent::didReceiveResponse): Use auto for the result of makeString.
(WebCore::logWarning): Ditto
(WebCore::makeValidURL): Added. Used for various cases below that all construct
(WebCore::appendBoolean): Use append instead of appendLiteral.
(WebCore::WorkerThreadableLoader::loadResourceSynchronously): Use auto for
(WebCore::DOMWindow::postMessage): Ditto.
(WebCore::createRegExpForLabels): Use append instead of appendLiteral.
(WebCore::FrameView::logMockScrollAnimatorMessage const): Use makeString
(WebCore::PageSerializer::SerializerMarkupAccumulator::appendStartTag):
(WebCore::PerformanceLoggingClient::synchronousScrollingReasonsAsString):
(WebCore::ResourceUsageOverlay::platformDraw): Use auto for the result of
(WebCore::consoleMessageForViolation): Use makeString instsead of StringBuilder.
(WebCore::ContentSecurityPolicyDirectiveList::create): Get rid of local
(WebCore::ScrollingCoordinator::synchronousScrollingReasonsAsText):
(WebCore::Decimal::toString const): Use append instead of appendLiteral.
(WebCore::TimingFunction::createFromCSSText): Use makeString instead
(WebCore::HRTFElevation::calculateKernelsForAzimuthElevation): Use auto
(WebCore::buildUserAgentString): Use append instead of appendLiteral.
(WebCore::InbandTextTrackPrivateAVF::processCueAttributes): Use
(WebCore::GraphicsLayerCA::recursiveCommitChanges): Got rid of local
(WebCore::TileController::tileRevalidationTimerFired): Update to
(WebCore::validationPolicyAsString): Use OptionSet.
Removed some type names.
(WebCore::PlatformCAFilters::setFiltersOnLayer): Use auto for
(WebCore::MockRealtimeVideoSource::drawText): Ditto.
(WebCore::ScrollAnimatorMock::scrollbarPrefix const): Added
(WebCore::appendProxyServerString): Use append instead of appendLiteral.
(WebCore::ResourceResponseBase::sanitizeSuggestedFilename): Get rid
(WebCore::platformForUAString): Deleted. No need for a global variable
(WebCore::SQLiteDatabase::open): Use auto for result of makeString.
(WebCore::SQLiteFileSystem::deleteDatabaseFile): Ditto.
(WebCore::DateTimeFormat::quoteAndAppendLiteral): Use append instead
(WebCore::replaceNewlinesWithWindowsStyleNewlines): Use append
(WebCore::standardUserAgent): Use makeString instead of StringBuildeer.
(WebCore::RenderLayer::name const): Ditto.
(WebCore::RenderLayerCompositor::logLayerInfo): Use append instead of
(WebCore::quoteAndEscapeNonPrintables): Ditto.
(WebCore::SVGPathStringBuilder::moveTo): Ditto.
(WebCore::Internals::dumpMarkerRects): Ditto.
(WebCore::WorkerScriptLoader::validateWorkerResponse): Use auto
Source/WebKit:
(WebKit::ResourceLoadStatisticsDatabaseStore::ensureAndMakeDomainList): Use append
(WebKit::ResourceLoadStatisticsMemoryStore::dumpResourceLoadStatistics): Ditto.
(WebKit::domainsToString): Ditto.
(WebKit::WebResourceLoadStatisticsStore::create): Moved this here from the header.
functions of the nested structures into the implementation file and fixed
(WebKit::NetworkLoadChecker::continueCheckingRequest): Do not use a local
(WebKit::NetworkProcess::newTestingSession): Ditto.
(WebKit::NetworkCache::Cache::dumpContentsToFile): Use append instead of appendLiteral
(WebKit::NetworkCache::Entry::asJSON const): Ditto.
(WebKit::NetworkCache::makeVersionedDirectoryPath): Do not use a local variable for
(WebKit::buildAcceptLanguages): Use append instead of appendLiteral.
(WebKit::WebSocketTask::acceptedExtensions const): Ditto.
(WebKit::NetworkMDNSRegister::registerMDNSName): Use auto for the result of makeString.
(WebKit::WebMemorySampler::writeHeaders): Ditto.
(WebKit::initializeSandboxParameters): Do not use a local variable for the result of
(WebKit::WebMemorySampler::sampleWebKit const): Use ASCIILiteral and remove explicit
(webkitWebViewRunJavaScriptCallback): Use append instead of appendLiteral.
(WebKit::fileCanBeAcceptedForUpload): Use auto for result of makeString.
StringBuilder.
(WebKit::NetworkProcessProxy::requestStorageSpace): Use auto for result of makeString.
(WebKit::WebBackForwardList::loggingString): Use append instead of appendLiteral.
(WebKit::WebProcessPool::processDidFinishLaunching): Use auto for result of makeString.
(WebKit::dumpHistoryItem): Use append instead of appendLiteral.
Source/WebKitLegacy:
(NetworkStorageSessionMap::switchToNewTestingSession): Do not use local
Source/WebKitLegacy/mac:
(regExpForLabels): Use append instead of appendLiteral.
Source/WebKitLegacy/win:
(AccessibleBase::get_accKeyboardShortcut): Use append instead of appnedLiteral.
Source/WTF:
The optimization done by appendLiteral has minimal value and is something we
If we decide we need an optimization for literals, we can come up with a
(WTF::FileSystemImpl::encodeForFileName): Streamline logic,
(WTF::JSONImpl::Value::escapeString): Use append instead
(WTF::Logger::log): Use auto for result of makeString.
(WTF::MediaTime::toString const): Use makeString instead of StringBuilder.
Made lengthOfIntegerAsString a constexpr function so we can use it to
(WTF::StringBuilder::appendLiteral): Deleted.
StringImpl*, AtomStringImpl&, and AtomStringImpl*.
Tools:
Use append instead of appendLiteral.
(TestWebKitAPI::createCommand): Use makeString instead of StringBuilder.
(TestWebKitAPI::TEST_F): Made lots of fixes to code inside #if TEST_OUTPUT,
(TestWebKitAPI::testDecode): Use append instead of appendLiteral.
(WTR::AccessibilityUIElement::helpText const): Ditto. |
|
File size: 3.1 KB |
Line | |
---|---|
1 | /* |
2 | * Copyright (C) 2018 Apple Inc. All rights reserved. |
3 | * |
4 | * Redistribution and use in source and binary forms, with or without |
5 | * modification, are permitted provided that the following conditions |
6 | * are met: |
7 | * 1. Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. |
9 | * 2. Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. |
12 | * |
13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY |
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE |
17 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, |
18 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR |
22 | * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF |
23 | * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
24 | * SUCH DAMAGE. |
25 | */ |
26 | |
27 | #include "config.h" |
28 | #include "CSSPaintImageValue.h" |
29 | |
30 | #if ENABLE(CSS_PAINTING_API) |
31 | |
32 | #include "CSSVariableData.h" |
33 | #include "CustomPaintImage.h" |
34 | #include "PaintWorkletGlobalScope.h" |
35 | #include "RenderElement.h" |
36 | #include <wtf/text/StringBuilder.h> |
37 | |
38 | namespace WebCore { |
39 | |
40 | String CSSPaintImageValue::customCSSText() const |
41 | { |
42 | // FIXME: This should include the arguments too. |
43 | return makeString("paint(", m_name, ')'); |
44 | } |
45 | |
46 | RefPtr<Image> CSSPaintImageValue::image(RenderElement& renderElement, const FloatSize& size) |
47 | { |
48 | if (size.isEmpty()) |
49 | return nullptr; |
50 | auto* selectedGlobalScope = renderElement.document().paintWorkletGlobalScopeForName(m_name); |
51 | if (!selectedGlobalScope) |
52 | return nullptr; |
53 | Locker locker { selectedGlobalScope->paintDefinitionLock() }; |
54 | auto* registration = selectedGlobalScope->paintDefinitionMap().get(m_name); |
55 | |
56 | if (!registration) |
57 | return nullptr; |
58 | |
59 | // FIXME: Check if argument list matches syntax. |
60 | Vector<String> arguments; |
61 | CSSParserTokenRange localRange(m_arguments->tokenRange()); |
62 | |
63 | while (!localRange.atEnd()) { |
64 | StringBuilder builder; |
65 | while (!localRange.atEnd() && localRange.peek() != CommaToken) { |
66 | if (localRange.peek() == CommentToken) |
67 | localRange.consume(); |
68 | else if (localRange.peek().getBlockType() == CSSParserToken::BlockStart) { |
69 | localRange.peek().serialize(builder); |
70 | builder.append(localRange.consumeBlock().serialize(), ')'); |
71 | } else |
72 | localRange.consume().serialize(builder); |
73 | } |
74 | if (!localRange.atEnd()) |
75 | localRange.consume(); // comma token |
76 | arguments.append(builder.toString()); |
77 | } |
78 | |
79 | return CustomPaintImage::create(*registration, size, renderElement, arguments); |
80 | } |
81 | |
82 | } // namespace WebCore |
83 | |
84 | #endif |