1 | /*
|
---|
2 | * Copyright (C) 2018-2022 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 APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
---|
14 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
---|
15 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
---|
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
---|
17 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
---|
18 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
---|
19 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
---|
20 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
---|
21 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
---|
22 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
---|
23 | * THE POSSIBILITY OF SUCH DAMAGE.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #pragma once
|
---|
27 |
|
---|
28 | #include "CSSParserMode.h"
|
---|
29 | #include "CSSPropertyNames.h"
|
---|
30 | #include "StyleRuleType.h"
|
---|
31 | #include <pal/text/TextEncoding.h>
|
---|
32 | #include <wtf/HashFunctions.h>
|
---|
33 | #include <wtf/Hasher.h>
|
---|
34 | #include <wtf/URL.h>
|
---|
35 |
|
---|
36 | namespace WebCore {
|
---|
37 |
|
---|
38 | class Document;
|
---|
39 |
|
---|
40 | struct ResolvedURL;
|
---|
41 |
|
---|
42 | struct CSSParserContext {
|
---|
43 | WTF_MAKE_STRUCT_FAST_ALLOCATED;
|
---|
44 |
|
---|
45 | URL baseURL;
|
---|
46 | String charset;
|
---|
47 | CSSParserMode mode { HTMLStandardMode };
|
---|
48 | std::optional<StyleRuleType> enclosingRuleType;
|
---|
49 | bool isHTMLDocument { false };
|
---|
50 |
|
---|
51 | // This is only needed to support getMatchedCSSRules.
|
---|
52 | bool hasDocumentSecurityOrigin { false };
|
---|
53 |
|
---|
54 | bool isContentOpaque { false };
|
---|
55 | bool useSystemAppearance { false };
|
---|
56 |
|
---|
57 | // Settings.
|
---|
58 | bool accentColorEnabled { false };
|
---|
59 | bool aspectRatioEnabled { false };
|
---|
60 | bool colorContrastEnabled { false };
|
---|
61 | bool colorFilterEnabled { false };
|
---|
62 | bool colorMixEnabled { false };
|
---|
63 | bool constantPropertiesEnabled { false };
|
---|
64 | bool containmentEnabled { false };
|
---|
65 | bool counterStyleAtRulesEnabled { false };
|
---|
66 | bool counterStyleAtRuleImageSymbolsEnabled { false };
|
---|
67 | bool cssColor4 { false };
|
---|
68 | bool individualTransformPropertiesEnabled { false };
|
---|
69 | #if ENABLE(OVERFLOW_SCROLLING_TOUCH)
|
---|
70 | bool legacyOverflowScrollingTouchEnabled { false };
|
---|
71 | #endif
|
---|
72 | bool overscrollBehaviorEnabled { false };
|
---|
73 | bool relativeColorSyntaxEnabled { false };
|
---|
74 | bool scrollBehaviorEnabled { false };
|
---|
75 | bool springTimingFunctionEnabled { false };
|
---|
76 | #if ENABLE(TEXT_AUTOSIZING)
|
---|
77 | bool textAutosizingEnabled { false };
|
---|
78 | #endif
|
---|
79 | #if ENABLE(CSS_TRANSFORM_STYLE_OPTIMIZED_3D)
|
---|
80 | bool transformStyleOptimized3DEnabled { false };
|
---|
81 | #endif
|
---|
82 | bool useLegacyBackgroundSizeShorthandBehavior { false };
|
---|
83 | bool focusVisibleEnabled { false };
|
---|
84 | bool hasPseudoClassEnabled { false };
|
---|
85 | bool cascadeLayersEnabled { false };
|
---|
86 | bool containerQueriesEnabled { false };
|
---|
87 | bool overflowClipEnabled { false };
|
---|
88 | bool gradientPremultipliedAlphaInterpolationEnabled { false };
|
---|
89 | bool gradientInterpolationColorSpacesEnabled { false };
|
---|
90 | bool inputSecurityEnabled { false };
|
---|
91 | bool subgridEnabled { false };
|
---|
92 | bool containIntrinsicSizeEnabled { false };
|
---|
93 | bool motionPathEnabled { false };
|
---|
94 | bool cssTextAlignLastEnabled { false };
|
---|
95 | bool cssTextJustifyEnabled { false };
|
---|
96 |
|
---|
97 | // RuntimeEnabledFeatures.
|
---|
98 | #if ENABLE(ATTACHMENT_ELEMENT)
|
---|
99 | bool attachmentEnabled { false };
|
---|
100 | #endif
|
---|
101 |
|
---|
102 | CSSParserContext(CSSParserMode, const URL& baseURL = URL());
|
---|
103 | WEBCORE_EXPORT CSSParserContext(const Document&, const URL& baseURL = URL(), const String& charset = emptyString());
|
---|
104 | bool isPropertyRuntimeDisabled(CSSPropertyID) const;
|
---|
105 | ResolvedURL completeURL(const String&) const;
|
---|
106 | };
|
---|
107 |
|
---|
108 | bool operator==(const CSSParserContext&, const CSSParserContext&);
|
---|
109 | inline bool operator!=(const CSSParserContext& a, const CSSParserContext& b) { return !(a == b); }
|
---|
110 |
|
---|
111 | void add(Hasher&, const CSSParserContext&);
|
---|
112 |
|
---|
113 | WEBCORE_EXPORT const CSSParserContext& strictCSSParserContext();
|
---|
114 |
|
---|
115 | struct CSSParserContextHash {
|
---|
116 | static unsigned hash(const CSSParserContext& context) { return computeHash(context); }
|
---|
117 | static bool equal(const CSSParserContext& a, const CSSParserContext& b) { return a == b; }
|
---|
118 | static const bool safeToCompareToEmptyOrDeleted = false;
|
---|
119 | };
|
---|
120 |
|
---|
121 | } // namespace WebCore
|
---|
122 |
|
---|
123 | namespace WTF {
|
---|
124 |
|
---|
125 | template<> struct HashTraits<WebCore::CSSParserContext> : GenericHashTraits<WebCore::CSSParserContext> {
|
---|
126 | static void constructDeletedValue(WebCore::CSSParserContext& slot) { new (NotNull, &slot.baseURL) URL(WTF::HashTableDeletedValue); }
|
---|
127 | static bool isDeletedValue(const WebCore::CSSParserContext& value) { return value.baseURL.isHashTableDeletedValue(); }
|
---|
128 | static WebCore::CSSParserContext emptyValue() { return WebCore::CSSParserContext(WebCore::HTMLStandardMode); }
|
---|
129 | };
|
---|
130 |
|
---|
131 | template<> struct DefaultHash<WebCore::CSSParserContext> : WebCore::CSSParserContextHash { };
|
---|
132 |
|
---|
133 | } // namespace WTF
|
---|