source: webkit/trunk/Source/WebCore/css/MediaQueryEvaluator.h

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

Have equalIgnoringASCIICase() take in an ASCIILiteral instead of a const char*
https://bugs.webkit.org/show_bug.cgi?id=239802

Reviewed by Darin Adler.

Have equalIgnoringASCIICase() take in an ASCIILiteral instead of a const char*,
as we are encouraging developers to use ""_s for string literals.

  • Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp:

(TestWebKitAPI::TEST):

  • Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:

(TestWebKitAPI::TEST):

  • Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm:

(parameterValue):
(WebFrameLoaderClient::createPlugin):

  • Source/WTF/wtf/text/AtomString.h:

(WTF::equalIgnoringASCIICase):

  • Source/WTF/wtf/text/StringImpl.h:

(WTF::equalIgnoringASCIICase):

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

(WTF::equalIgnoringASCIICase):

  • Source/WTF/wtf/text/WTFString.h:

(WTF::equalIgnoringASCIICase):

  • Source/WTF/wtf/unix/LanguageUnix.cpp:

(WTF::platformLanguage):

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

(WebCore::PaymentCoordinator::validatedPaymentNetwork const):

  • Source/WebCore/accessibility/AccessibilityNodeObject.cpp:

(WebCore::siblingWithAriaRole):
(WebCore::AccessibilityNodeObject::menuElementForMenuButton const):
(WebCore::AccessibilityNodeObject::menuItemElementForMenu const):

  • Source/WebCore/accessibility/AccessibilityObject.cpp:

(WebCore::AccessibilityObject::popupValue const):

  • Source/WebCore/css/MediaQueryEvaluator.cpp:

(WebCore::MediaQueryEvaluator::mediaTypeMatchSpecific const):

  • Source/WebCore/css/MediaQueryEvaluator.h:
  • Source/WebCore/dom/Document.cpp:

(WebCore::messageSourceForWTFLogChannel):

  • Source/WebCore/dom/SecurityContext.cpp:

(WebCore::SecurityContext::isSupportedSandboxPolicy):

  • Source/WebCore/html/HiddenInputType.cpp:

(WebCore::HiddenInputType::appendFormData const):

  • Source/WebCore/html/LinkRelAttribute.cpp:

(WebCore::LinkRelAttribute::isSupported):

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

(WebCore::WebGL2RenderingContext::getExtension):

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

(WebCore::WebGLRenderingContext::getExtension):

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

(WebCore::WebGLRenderingContextBase::extensionIsEnabled):

  • Source/WebCore/page/FrameTree.cpp:

(WebCore::isBlankTargetFrameName):
(WebCore::isParentTargetFrameName):
(WebCore::isSelfTargetFrameName):
(WebCore::isTopTargetFrameName):

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

(WebCore::keySystemIsSupported):

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

(WebCore::FontCache::similarFont):
(WebCore::FontCache::platformAlternateFamilyName):

  • Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp:

(WebCore::Font::platformInit):

  • Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp:

(WebCore::isThunderRanked):

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

(WebCore::normalizeHTTPMethod):
(WebCore::isSafeMethod):

  • Source/WebCore/platform/network/curl/CurlMultipartHandle.cpp:

(WebCore::CurlMultipartHandle::extractBoundary):

  • Source/WebCore/platform/playstation/MIMETypeRegistryPlayStation.cpp:

(WebCore::MIMETypeRegistry::mimeTypeForExtension):
(WebCore::MIMETypeRegistry::preferredExtensionForMIMEType):

  • Source/WebCore/style/ElementRuleCollector.h:

(WebCore::Style::ElementRuleCollector::setMedium):

  • Source/WebCore/svg/SVGToOTFFontConversion.cpp:

(WebCore::SVGToOTFFontConverter::appendArabicReplacementSubtable):
(WebCore::SVGToOTFFontConverter::appendGSUBTable):

  • Source/WebCore/xml/XMLHttpRequest.cpp:

(WebCore::replaceCharsetInMediaTypeIfNeeded):

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

  • Property svn:eol-style set to native
File size: 3.9 KB
Line 
1/*
2 * CSS Media Query Evaluator
3 *
4 * Copyright (C) 2006 Kimmo Kinnunen <[email protected]>.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#pragma once
29
30#include "IntSize.h"
31#include "MediaQueryExpression.h"
32#include <wtf/WeakPtr.h>
33
34namespace WebCore {
35
36class Document;
37class MediaQuerySet;
38class RenderStyle;
39
40struct MediaQueryResult {
41 MediaQueryExpression expression;
42 bool result;
43};
44
45struct MediaQueryDynamicResults {
46 Vector<MediaQueryResult> viewport;
47 Vector<MediaQueryResult> appearance;
48 Vector<MediaQueryResult> accessibilitySettings;
49
50 void append(const MediaQueryDynamicResults& other)
51 {
52 viewport.appendVector(other.viewport);
53 appearance.appendVector(other.appearance);
54 accessibilitySettings.appendVector(other.accessibilitySettings);
55 }
56 bool isEmpty() const { return viewport.isEmpty() && appearance.isEmpty() && accessibilitySettings.isEmpty(); }
57};
58
59using MediaQueryViewportState = std::tuple<IntSize, float, bool>;
60
61MediaQueryViewportState mediaQueryViewportStateForDocument(const Document&);
62
63// Some of the constructors are used for cases where the device characteristics are not known.
64// These can be used to prune the loading of stylesheets to only those which are not already known to not match.
65
66class MediaQueryEvaluator {
67public:
68 // Creates evaluator which evaluates only simple media queries.
69 // Evaluator returns true for "all", and returns value of \mediaFeatureResult for any media features.
70 explicit MediaQueryEvaluator(bool mediaFeatureResult = false);
71
72 // Creates evaluator which evaluates only simple media queries.
73 // Evaluator returns true for acceptedMediaType and returns value of \mediaFeatureResult for any media features.
74 MediaQueryEvaluator(const String& acceptedMediaType, bool mediaFeatureResult = false);
75
76 // Creates evaluator which evaluates full media queries.
77 WEBCORE_EXPORT MediaQueryEvaluator(const String& acceptedMediaType, const Document&, const RenderStyle*);
78
79 bool mediaTypeMatch(const String& mediaTypeToMatch) const;
80 bool mediaTypeMatchSpecific(ASCIILiteral mediaTypeToMatch) const;
81
82 // Evaluates media query subexpression, ie "and (media-feature: value)" part.
83 bool evaluate(const MediaQueryExpression&) const;
84 bool evaluateForChanges(const MediaQueryDynamicResults&) const;
85
86 enum class Mode { Normal, AlwaysMatchDynamic };
87 WEBCORE_EXPORT bool evaluate(const MediaQuerySet&, MediaQueryDynamicResults* = nullptr, Mode = Mode::Normal) const;
88
89 static bool mediaAttributeMatches(Document&, const String& attributeValue);
90
91private:
92 String m_mediaType;
93 WeakPtr<const Document> m_document;
94 const RenderStyle* m_style { nullptr };
95 bool m_fallbackResult { false };
96};
97
98} // namespace
Note: See TracBrowser for help on using the repository browser.