source: webkit/trunk/Source/WebCore/css/DOMCSSNamespace.cpp

Last change on this file was 294611, checked in by Chris Dumez, 3 years ago

Start preparing the code base for marking the StringView(const char*) constructor explicit
https://bugs.webkit.org/show_bug.cgi?id=240687

Reviewed by Darin Adler.

Start preparing the code base for marking the StringView(const char*) constructor explicit.
This encourages people to ensure ASCIILiteral / ""_s whenever possible.

  • Source/JavaScriptCore/API/JSAPIGlobalObject.mm:

(JSC::computeValidImportSpecifier):

  • Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp:

(Inspector::isWebKitInjectedScript):

  • Source/JavaScriptCore/jit/ExecutableAllocator.cpp:

(JSC::dumpJITMemory):

  • Source/JavaScriptCore/jsc.cpp:

(GlobalObject::moduleLoaderImportModule):
(GlobalObject::moduleLoaderResolve):

  • Source/JavaScriptCore/runtime/FileBasedFuzzerAgent.cpp:

(JSC::FileBasedFuzzerAgent::getPredictionInternal):

  • Source/JavaScriptCore/runtime/IntlLocale.cpp:

(JSC::IntlLocale::initializeLocale):

  • Source/JavaScriptCore/runtime/IntlObject.cpp:

(JSC::isValidTimeZoneNameFromICUTimeZone):

  • Source/JavaScriptCore/runtime/TypeProfiler.cpp:

(JSC::TypeProfiler::logTypesForTypeLocation):

  • Source/JavaScriptCore/testRegExp.cpp:

(parseRegExpLine):

  • Source/JavaScriptCore/yarr/YarrUnicodeProperties.cpp:

(JSC::Yarr::HashTable::entry const):

  • Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:

(WebKit::NetworkDataTaskCocoa::willPerformHTTPRedirection):

  • Source/WebKit/UIProcess/PageLoadState.cpp:

(WebKit::PageLoadState::hasOnlySecureContent):

  • Source/WebKit/UIProcess/mac/WKImmediateActionController.mm:

(-[WKImmediateActionController _defaultAnimationController]):

  • Source/WebKitLegacy/mac/WebView/WebImmediateActionController.mm:

(-[WebImmediateActionController _defaultAnimationController]):

  • Source/WTF/wtf/DateMath.cpp:

(WTF::parseDateFromNullTerminatedCharacters):

  • Source/WTF/wtf/SortedArrayMap.h:

(WTF::operator<):

  • Source/WTF/wtf/URL.cpp:

(WTF::URL::hasSpecialScheme const):
(WTF::URL::setPath):
(WTF::protocolIsInternal):
(WTF::protocolIs):
(WTF::URL::isLocalFile const):
(WTF::protocolIsJavaScript):
(WTF::URL::protocolIsAbout const):
(WTF::portAllowed):
(WTF::mimeTypeFromDataURL):
(WTF::URL::isAboutBlank const):
(WTF::URL::isAboutSrcDoc const):

  • Source/WTF/wtf/URL.h:

(WTF::URL::protocolIsBlob const):
(WTF::URL::protocolIsData const):

  • Source/WTF/wtf/URLHelpers.cpp:

(WTF::URLHelpers::applyHostNameFunctionToURLString):

  • Source/WTF/wtf/URLParser.cpp:

(WTF::URLParser::copyBaseWindowsDriveLetter):
(WTF::URLParser::URLParser):
(WTF::URLParser::parse):

  • Source/WTF/wtf/text/ASCIILiteral.h:
  • Source/WTF/wtf/text/StringView.h:

(WTF::operator==):
(WTF::operator!=):
(WTF::equal):

  • Source/WebCore/Modules/applepay/PaymentSession.cpp:

(WebCore::isSecure):

  • Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp:

(WebCore::resolveRelativeVirtualPath):
(WebCore::DOMFileSystem::getParent):

  • Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp:

(WebCore::FetchBodyConsumer::packageFormData):

  • Source/WebCore/Modules/indexeddb/server/IDBServer.cpp:

(WebCore::IDBServer::removeAllDatabasesForFullOriginPath):

  • Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:

(WebCore::IDBServer::SQLiteIDBBackingStore::databasesSizeForDirectory):

  • Source/WebCore/Modules/mediasource/MediaSource.cpp:

(WebCore::addVP9FullRangeVideoFlagToContentType):

  • Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp:

(WebCore::shouldIgnoreIceCandidate):

  • Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp:

(WebCore::RTCPeerConnection::iceServersFromConfiguration):

  • Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp:

(WebCore::isValidURLBasedPaymentMethodIdentifier):

  • Source/WebCore/Modules/plugins/YouTubePluginReplacement.cpp:

(WebCore::YouTubePluginReplacement::youTubeURLFromAbsoluteURL):

  • Source/WebCore/Modules/webauthn/AuthenticatorCoordinator.cpp:

(WebCore::AuthenticatorCoordinatorInternal::needsAppIdQuirks):

  • Source/WebCore/Modules/webdatabase/Database.cpp:

(WebCore::fullyQualifiedInfoTableName):

  • Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp:

(WebCore::DatabaseTracker::usage):

  • Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp:

(WebCore::ThreadableWebSocketChannel::validateURL):

  • Source/WebCore/Modules/websockets/WebSocket.cpp:

(WebCore::WebSocket::connect):
(WebCore::WebSocket::didUpgradeURL):

  • Source/WebCore/Modules/websockets/WebSocketHandshake.cpp:

(WebCore::hostName):
(WebCore::WebSocketHandshake::WebSocketHandshake):
(WebCore::WebSocketHandshake::httpURLForAuthenticationAndCookies const):
(WebCore::headerHasValidHTTPVersion):

  • Source/WebCore/accessibility/AXObjectCache.cpp:

(WebCore::AXObjectCache::handleAttributeChange):

  • Source/WebCore/accessibility/AccessibilityNodeObject.cpp:

(WebCore::AccessibilityNodeObject::isSearchField const):

  • Source/WebCore/accessibility/AccessibilityObject.cpp:

(WebCore::AccessibilityObject::ariaLandmarkRoleDescription const):

  • Source/WebCore/accessibility/mac/AccessibilityObjectMac.mm:

(WebCore::AccessibilityObject::rolePlatformDescription const):

  • Source/WebCore/animation/KeyframeEffect.cpp:

(WebCore::KeyframeEffect::setPseudoElement):

  • Source/WebCore/bindings/js/ScriptModuleLoader.cpp:

(WebCore::resolveModuleSpecifier):

  • Source/WebCore/contentextensions/ContentExtensionsBackend.cpp:

(WebCore::ContentExtensions::ContentExtensionsBackend::processContentRuleListsForLoad):
(WebCore::ContentExtensions::ContentExtensionsBackend::processContentRuleListsForPingLoad):
(WebCore::ContentExtensions::applyResultsToRequest):

  • Source/WebCore/css/CSSFontFaceSrcValue.cpp:

(WebCore::CSSFontFaceSrcValue::isSupportedFormat const):

  • Source/WebCore/css/CSSPrimitiveValue.cpp:

(WebCore::CSSPrimitiveValue::formatInfiniteOrNanValue const):
(WebCore::CSSPrimitiveValue::formatNumberValue const):
(WebCore::CSSPrimitiveValue::formatIntegerValue const):
(WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText const):

  • Source/WebCore/css/CSSPrimitiveValue.h:
  • Source/WebCore/css/CSSSelector.cpp:

(WebCore::CSSSelector::parsePseudoElementType):

  • Source/WebCore/css/ContainerQueryParser.cpp:

(WebCore::ContainerQueryParser::consumePlainSizeFeature):

  • Source/WebCore/css/DOMCSSNamespace.cpp:

(WebCore::valueWithoutImportant):

  • Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:

(WebCore::CSSPropertyParserHelpers::consumeDashedIdent):

  • Source/WebCore/css/parser/CSSSelectorParser.cpp:

(WebCore::consumeLangArgumentList):

  • Source/WebCore/css/typedom/CSSOMVariableReferenceValue.cpp:

(WebCore::CSSOMVariableReferenceValue::create):
(WebCore::CSSOMVariableReferenceValue::setVariable):

  • Source/WebCore/dom/ConstantPropertyMap.cpp:

(WebCore::variableDataForPositivePixelLength):
(WebCore::variableDataForPositiveDuration):

  • Source/WebCore/dom/DataTransfer.cpp:

(WebCore::normalizeType):

  • Source/WebCore/dom/Document.cpp:

(WebCore::Document::isCookieAverse const):

  • Source/WebCore/dom/Element.cpp:

(WebCore::Element::isEventHandlerAttribute const):

  • Source/WebCore/dom/TextDecoder.cpp:

(WebCore::TextDecoder::encoding const):

  • Source/WebCore/editing/cocoa/HTMLConverter.mm:

(HTMLConverterCaches::isBlockElement):
(HTMLConverter::computedAttributesForElement):
(HTMLConverter::_processText):

  • Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm:

(WebCore::stripMicrosoftPrefix):

  • Source/WebCore/editing/markup.cpp:

(WebCore::shouldPreserveMSOLists):

  • Source/WebCore/fileapi/BlobURL.cpp:
  • Source/WebCore/html/FeaturePolicy.cpp:

(WebCore::FeaturePolicy::parse):

  • Source/WebCore/html/HTMLAnchorElement.cpp:

(WebCore::HTMLAnchorElement::parseAttribute):

  • Source/WebCore/html/HTMLFormElement.cpp:

(WebCore::HTMLFormElement::formWouldHaveSecureSubmission):

  • Source/WebCore/html/HTMLLinkElement.cpp:

(WebCore::HTMLLinkElement::process):

  • Source/WebCore/html/HTMLMediaElement.cpp:
  • Source/WebCore/html/HTMLObjectElement.cpp:

(WebCore::HTMLObjectElement::hasValidClassId):

  • Source/WebCore/html/HTMLPlugInImageElement.cpp:

(WebCore::HTMLPlugInImageElement::isImageType):

  • Source/WebCore/html/TextFieldInputType.cpp:

(WebCore::TextFieldInputType::handleBeforeTextInsertedEvent):

  • Source/WebCore/html/URLDecomposition.cpp:

(WebCore::URLDecomposition::setUsername):
(WebCore::URLDecomposition::setPassword):
(WebCore::URLDecomposition::setHost):
(WebCore::URLDecomposition::setHostname):

  • Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:

(WebCore::CanvasRenderingContext2DBase::State::fontString const):

  • Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp:

(WebCore::WebGLRenderingContextBase::getActiveUniform):
(WebCore::WebGLRenderingContextBase::getUniformLocation):

  • Source/WebCore/html/parser/CSSPreloadScanner.cpp:

(WebCore::hasValidImportConditions):

  • Source/WebCore/html/parser/HTMLMetaCharsetParser.cpp:

(WebCore::extractCharset):

  • Source/WebCore/html/parser/HTMLPreloadScanner.cpp:

(WebCore::TokenPreloadScanner::StartTagScanner::shouldPreload):

  • Source/WebCore/html/track/WebVTTParser.cpp:
  • Source/WebCore/inspector/DOMPatchSupport.cpp:
  • Source/WebCore/inspector/InspectorFrontendHost.cpp:

(WebCore::InspectorFrontendHost::revealFileExternally):

  • Source/WebCore/inspector/InspectorStyleSheet.cpp:

(WebCore::StyleSheetHandler::observeComment):
(WebCore::lowercasePropertyName):
(WebCore::selectorsFromSource):

  • Source/WebCore/loader/CookieJar.cpp:

(WebCore::CookieJar::shouldIncludeSecureCookies):

  • Source/WebCore/loader/CustomHeaderFields.cpp:

(WebCore::CustomHeaderFields::thirdPartyDomainsMatch const):

  • Source/WebCore/loader/FormSubmission.cpp:

(WebCore::FormSubmission::create):

  • Source/WebCore/loader/FrameLoader.cpp:

(WebCore::FrameLoader::open):

  • Source/WebCore/loader/PolicyChecker.cpp:

(WebCore::FrameLoader::PolicyChecker::checkNavigationPolicy):

  • Source/WebCore/loader/PrivateClickMeasurement.cpp:

(WebCore::PrivateClickMeasurement::parseAttributionRequest):

  • Source/WebCore/loader/ResourceLoader.cpp:

(WebCore::ResourceLoader::isPDFJSResourceLoad const):

  • Source/WebCore/loader/appcache/ApplicationCacheManifestParser.cpp:

(WebCore::parseApplicationCacheManifest):

  • Source/WebCore/loader/archive/ArchiveResourceCollection.cpp:

(WebCore::ArchiveResourceCollection::archiveResourceForURL):

  • Source/WebCore/loader/cache/CachedResource.cpp:

(WebCore::CachedResource::makeRevalidationDecision const):

  • Source/WebCore/loader/cache/CachedResourceLoader.cpp:

(WebCore::CachedResourceLoader::requestResource):

  • Source/WebCore/page/ContextMenuController.cpp:

(WebCore::ContextMenuController::checkOrEnableIfNeeded const):

  • Source/WebCore/page/EventHandler.cpp:

(WebCore::hasDropZoneType):

  • Source/WebCore/page/Frame.cpp:

(WebCore::createRegExpForLabels):
(WebCore::matchLabelsAgainstString):

  • Source/WebCore/page/Page.cpp:

(WebCore::Page::userStyleSheetLocationChanged):
(WebCore::Page::allowsLoadFromURL const):

  • Source/WebCore/page/Quirks.cpp:

(WebCore::isYahooMail):
(WebCore::Quirks::shouldDisableContentChangeObserverTouchEventAdjustment const):
(WebCore::Quirks::shouldHideSearchFieldResultsButton const):
(WebCore::Quirks::isAmazon const):
(WebCore::Quirks::isGoogleMaps const):
(WebCore::Quirks::shouldDispatchSimulatedMouseEvents const):
(WebCore::Quirks::shouldDispatchedSimulatedMouseEventsAssumeDefaultPrevented const):
(WebCore::Quirks::simulatedMouseEventTypeForTarget const):
(WebCore::Quirks::shouldPreventPointerMediaQueryFromEvaluatingToCoarse const):
(WebCore::Quirks::shouldAvoidResizingWhenInputViewBoundsChange const):
(WebCore::Quirks::shouldDisablePointerEventsQuirk const):
(WebCore::Quirks::needsInputModeNoneImplicitly const):
(WebCore::Quirks::needsFullscreenDisplayNoneQuirk const):
(WebCore::Quirks::shouldSilenceWindowResizeEvents const):
(WebCore::Quirks::shouldSilenceMediaQueryListChangeEvents const):
(WebCore::Quirks::shouldUseLegacySelectPopoverDismissalBehaviorInDataActivation const):
(WebCore::Quirks::shouldOpenAsAboutBlank const):
(WebCore::Quirks::shouldBypassBackForwardCache const):
(WebCore::Quirks::shouldBypassAsyncScriptDeferring const):
(WebCore::Quirks::shouldMakeEventListenerPassive):
(WebCore::Quirks::shouldDisableElementFullscreenQuirk const):
(WebCore::Quirks::needsCanPlayAfterSeekedQuirk const):
(WebCore::Quirks::shouldLayOutAtMinimumWindowWidthWhenIgnoringScalingConstraints const):
(WebCore::Quirks::shouldIgnoreContentObservationForSyntheticClick const):
(WebCore::isKinjaLoginAvatarElement):
(WebCore::Quirks::isMicrosoftTeamsRedirectURL):
(WebCore::Quirks::needsBlackFullscreenBackgroundQuirk const):
(WebCore::Quirks::needsToForceUserSelectAndUserDragWhenInstallingImageOverlay const):

  • Source/WebCore/page/SecurityOrigin.cpp:

(WebCore::schemeRequiresHost):
(WebCore::SecurityOrigin::shouldIgnoreHost):
(WebCore::shouldTreatAsUniqueOrigin):
(WebCore::isLoopbackIPAddress):
(WebCore::SecurityOrigin::isLocalHostOrLoopbackIPAddress):

  • Source/WebCore/page/SecurityPolicy.cpp:

(WebCore::SecurityPolicy::shouldHideReferrer):
(WebCore::SecurityPolicy::generateOriginHeader):

  • Source/WebCore/page/UserContentURLPattern.cpp:

(WebCore::UserContentURLPattern::parse):

  • Source/WebCore/page/cocoa/ResourceUsageThreadCocoa.mm:

(WebCore::ResourceUsageThread::platformCollectCPUData):

  • Source/WebCore/page/csp/ContentSecurityPolicy.cpp:

(WebCore::shouldReportProtocolOnly):
(WebCore::ContentSecurityPolicy::upgradeInsecureRequestIfNeeded const):
(WebCore::ContentSecurityPolicy::setUpgradeInsecureRequests):

  • Source/WebCore/page/csp/ContentSecurityPolicySource.cpp:

(WebCore::ContentSecurityPolicySource::portMatches const):

  • Source/WebCore/page/csp/ContentSecurityPolicySourceList.cpp:

(WebCore::ContentSecurityPolicySourceList::isProtocolAllowedByStar const):

  • Source/WebCore/platform/MIMETypeRegistry.cpp:

(WebCore::MIMETypeRegistry::isSupportedJSONMIMEType):
(WebCore::MIMETypeRegistry::isXMLMIMEType):

  • Source/WebCore/platform/cocoa/RuntimeApplicationChecksCocoa.mm:

(WebCore::MacApplication::isSafari):

  • Source/WebCore/platform/graphics/Image.cpp:

(WebCore::Image::isPDFResource):
(WebCore::Image::isPostScriptResource):

  • Source/WebCore/platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:

(WebCore::CDMFactoryFairPlayStreaming::supportsKeySystem):

  • Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:

(WebCore::MediaPlayerPrivateAVFoundation::isUnsupportedMIMEType):

  • Source/WebCore/platform/graphics/avfoundation/objc/AVAssetMIMETypeCache.mm:

(WebCore::AVAssetMIMETypeCache::isUnsupportedContainerType):

  • Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp:

(WebCore::fontWithFamilySpecialCase):

  • Source/WebCore/platform/graphics/cocoa/MediaEngineConfigurationFactoryCocoa.cpp:

(WebCore::videoCodecTypeFromRFC4281Type):
(WebCore::computeMediaCapabilitiesInfo):

  • Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp:

(WebCore::SourceBufferParserWebM::isContentTypeSupported):

  • Source/WebCore/platform/mac/UserAgentMac.mm:

(WebCore::standardUserAgentWithApplicationName):

  • Source/WebCore/platform/mediastream/mac/CoreAudioCaptureDeviceManager.cpp:

(WebCore::isValidCaptureDevice):

  • Source/WebCore/platform/network/CacheValidation.cpp:

(WebCore::parseCacheControlDirectives):
(WebCore::cookieRequestHeaderFieldValue):

  • Source/WebCore/platform/network/DataURLDecoder.cpp:

(WebCore::DataURLDecoder::DecodeTask::process):

  • Source/WebCore/platform/network/HTTPParsers.cpp:

(WebCore::extractCharsetFromMediaType):

  • Source/WebCore/platform/network/ParsedContentRange.cpp:

(WebCore::parseContentRange):

  • Source/WebCore/platform/network/ParsedRequestRange.cpp:

(WebCore::ParsedRequestRange::parse):

  • Source/WebCore/platform/network/ResourceHandle.cpp:

(WebCore::ResourceHandle::shouldContentSniffURL):

  • Source/WebCore/platform/network/ResourceRequestBase.cpp:

(WebCore::ResourceRequestBase::redirectedRequest const):

  • Source/WebCore/platform/network/ResourceResponseBase.cpp:

(WebCore::ResourceResponseBase::isHTTP09 const):

  • Source/WebCore/platform/network/cf/SocketStreamHandleImpl.h:

(WebCore::SocketStreamHandleImpl::shouldUseSSL const):

  • Source/WebCore/platform/network/cf/SocketStreamHandleImplCFNet.cpp:

(WebCore::SocketStreamHandleImpl::SocketStreamHandleImpl):

  • Source/WebCore/platform/network/mac/ResourceHandleMac.mm:

(WebCore::ResourceHandle::willSendRequest):

  • Source/WebCore/plugins/PluginData.cpp:

(WebCore::shouldBePubliclyVisible):

  • Source/WebCore/rendering/HitTestResult.cpp:

(WebCore::HitTestResult::absolutePDFURL const):

  • Source/WebCore/rendering/RenderListMarker.cpp:

(WebCore::listMarkerSuffix):

  • Source/WebCore/svg/SVGSVGElement.cpp:

(WebCore::SVGSVGElement::scrollToFragment):

  • Source/WebCore/svg/animation/SVGSMILElement.cpp:

(WebCore::SVGSMILElement::parseOffsetValue):
(WebCore::SVGSMILElement::parseCondition):

  • Source/WebCore/workers/Worker.cpp:

(WebCore::Worker::didReceiveResponse):

  • Source/WebCore/workers/service/ServiceWorkerContainer.cpp:

(WebCore::ServiceWorkerContainer::addRegistration):

  • Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp:

(WebCore::shouldAllowExternalLoad):

Canonical link: https://commits.webkit.org/250837@main

File size: 3.7 KB
Line 
1/*
2 * Copyright (C) 2012 Motorola Mobility 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 are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of Motorola Mobility Inc. nor the names of its
14 * contributors may be used to endorse or promote products derived from this
15 * software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#include "config.h"
31#include "DOMCSSNamespace.h"
32
33#include "CSSMarkup.h"
34#include "CSSParser.h"
35#include "CSSPropertyParser.h"
36#include "Document.h"
37#include "HighlightRegister.h"
38#include "StyleProperties.h"
39#include <wtf/text/StringBuilder.h>
40#include <wtf/text/WTFString.h>
41
42namespace WebCore {
43
44static String valueWithoutImportant(const String& value)
45{
46 if (!value.endsWithIgnoringASCIICase("important"_s))
47 return value;
48
49 String newValue = value;
50 int bangIndex = newValue.length() - 9 - 1;
51 if (newValue[bangIndex] == ' ')
52 bangIndex--;
53 newValue = newValue.left(bangIndex);
54
55 return newValue;
56}
57
58bool DOMCSSNamespace::supports(Document& document, const String& property, const String& value)
59{
60 CSSPropertyID propertyID = cssPropertyID(property.stripWhiteSpace());
61
62 CSSParserContext parserContext(document);
63 if (parserContext.isPropertyRuntimeDisabled(propertyID))
64 return false;
65
66 if (isInternalCSSProperty(propertyID))
67 return false;
68
69 if (propertyID == CSSPropertyInvalid)
70 return false;
71
72 // CSSParser::parseValue() won't work correctly if !important is present,
73 // so just get rid of it. It doesn't matter to supports() if it's actually
74 // there or not, provided how it's specified in the value is correct.
75 String normalizedValue = value.stripWhiteSpace().simplifyWhiteSpace();
76 normalizedValue = valueWithoutImportant(normalizedValue);
77
78 if (normalizedValue.isEmpty())
79 return false;
80
81 auto dummyStyle = MutableStyleProperties::create();
82 return CSSParser::parseValue(dummyStyle, propertyID, normalizedValue, false, parserContext) != CSSParser::ParseResult::Error;
83}
84
85bool DOMCSSNamespace::supports(Document& document, const String& conditionText)
86{
87 CSSParserContext context(document);
88 CSSParser parser(context);
89 return parser.parseSupportsCondition(conditionText);
90}
91
92String DOMCSSNamespace::escape(const String& ident)
93{
94 StringBuilder builder;
95 serializeIdentifier(ident, builder);
96 return builder.toString();
97}
98
99HighlightRegister& DOMCSSNamespace::highlights(Document& document)
100{
101 return document.highlightRegister();
102}
103
104}
Note: See TracBrowser for help on using the repository browser.