File: StyleComputedStyleProperties%2BGettersCustomInlines.h

package info (click to toggle)
webkit2gtk 2.51.91-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 484,084 kB
  • sloc: cpp: 3,931,583; javascript: 197,713; ansic: 167,619; python: 53,160; asm: 21,857; ruby: 18,114; perl: 17,149; xml: 4,631; sh: 2,462; yacc: 2,394; java: 2,032; lex: 1,358; pascal: 372; makefile: 215
file content (374 lines) | stat: -rw-r--r-- 13,497 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
/*
 * Copyright (C) 2025-2026 Samuel Weinig <sam@webkit.org>
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#pragma once

#include <WebCore/StyleComputedStyleProperties.h>
#include <WebCore/StyleComputedStyleBase+GettersInlines.h>

#include <WebCore/AnchorPositionEvaluator.h>
#include <WebCore/AutosizeStatus.h>
#include <WebCore/Element.h>
#include <WebCore/FontCascadeDescription.h>
#include <WebCore/GraphicsTypes.h>
#include <WebCore/HitTestRequest.h>
#include <WebCore/PositionTryOrder.h>
#include <WebCore/ScrollTypes.h>
#include <WebCore/StyleAppearance.h>
#include <WebCore/StyleAppleColorFilterData.h>
#include <WebCore/StyleBackdropFilterData.h>
#include <WebCore/StyleBackgroundData.h>
#include <WebCore/StyleBoxData.h>
#include <WebCore/StyleColorResolver.h>
#include <WebCore/StyleCustomPropertyData.h>
#include <WebCore/StyleDeprecatedFlexibleBoxData.h>
#include <WebCore/StyleFillLayers.h>
#include <WebCore/StyleFilterData.h>
#include <WebCore/StyleFlexibleBoxData.h>
#include <WebCore/StyleFontData.h>
#include <WebCore/StyleFontFamily.h>
#include <WebCore/StyleFontFeatureSettings.h>
#include <WebCore/StyleFontPalette.h>
#include <WebCore/StyleFontSizeAdjust.h>
#include <WebCore/StyleFontStyle.h>
#include <WebCore/StyleFontVariantAlternates.h>
#include <WebCore/StyleFontVariantEastAsian.h>
#include <WebCore/StyleFontVariantLigatures.h>
#include <WebCore/StyleFontVariantNumeric.h>
#include <WebCore/StyleFontVariationSettings.h>
#include <WebCore/StyleFontWeight.h>
#include <WebCore/StyleFontWidth.h>
#include <WebCore/StyleGridData.h>
#include <WebCore/StyleGridItemData.h>
#include <WebCore/StyleGridTrackSizingDirection.h>
#include <WebCore/StyleInheritedData.h>
#include <WebCore/StyleInheritedRareData.h>
#include <WebCore/StyleMarqueeData.h>
#include <WebCore/StyleMultiColumnData.h>
#include <WebCore/StyleNonInheritedData.h>
#include <WebCore/StyleNonInheritedMiscData.h>
#include <WebCore/StyleNonInheritedRareData.h>
#include <WebCore/StyleSVGData.h>
#include <WebCore/StyleSVGFillData.h>
#include <WebCore/StyleSVGLayoutData.h>
#include <WebCore/StyleSVGMarkerResourceData.h>
#include <WebCore/StyleSVGNonInheritedMiscData.h>
#include <WebCore/StyleSVGStopData.h>
#include <WebCore/StyleSVGStrokeData.h>
#include <WebCore/StyleSurroundData.h>
#include <WebCore/StyleTextAlign.h>
#include <WebCore/StyleTextAutospace.h>
#include <WebCore/StyleTextDecorationLine.h>
#include <WebCore/StyleTextSpacingTrim.h>
#include <WebCore/StyleTextTransform.h>
#include <WebCore/StyleTransformData.h>
#include <WebCore/StyleVisitedLinkColorData.h>
#include <WebCore/StyleWebKitLocale.h>
#include <WebCore/UnicodeBidi.h>
#include <WebCore/ViewTimeline.h>
#include <WebCore/WebAnimationTypes.h>

#if ENABLE(APPLE_PAY)
#include <WebCore/ApplePayButtonPart.h>
#endif

#if HAVE(CORE_MATERIAL)
#include <WebCore/AppleVisualEffect.h>
#endif

namespace WebCore {
namespace Style {

// FIXME: Support generating properties that have their storage spread out

inline Cursor ComputedStyleProperties::cursor() const
{
    return { m_inheritedRareData->cursorImages, static_cast<CursorType>(m_inheritedFlags.cursorType) };
}

inline ZIndex ComputedStyleProperties::specifiedZIndex() const
{
    return m_nonInheritedData->boxData->specifiedZIndex();
}

// FIXME: Support writing mode properties.

inline TextDirection ComputedStyleProperties::computedDirection() const
{
    return writingMode().computedTextDirection();
}

inline StyleWritingMode ComputedStyleProperties::computedWritingMode() const
{
    return writingMode().computedWritingMode();
}

inline TextOrientation ComputedStyleProperties::computedTextOrientation() const
{
    return writingMode().computedTextOrientation();
}

// FIXME: Support font properties.

float ComputedStyleProperties::specifiedFontSize() const
{
    return fontDescription().specifiedSize();
}

inline FontFamilies ComputedStyleProperties::fontFamily() const
{
    return { fontDescription().families(), fontDescription().isSpecifiedFont() };
}

inline FontPalette ComputedStyleProperties::fontPalette() const
{
    return fontDescription().fontPalette();
}

inline FontSizeAdjust ComputedStyleProperties::fontSizeAdjust() const
{
    return fontDescription().fontSizeAdjust();
}

inline FontStyle ComputedStyleProperties::fontStyle() const
{
    return { fontDescription().fontStyleSlope(), fontDescription().fontStyleAxis() };
}

#if ENABLE(VARIATION_FONTS)

inline FontOpticalSizing ComputedStyleProperties::fontOpticalSizing() const
{
    return fontDescription().opticalSizing();
}

#endif

inline FontFeatureSettings ComputedStyleProperties::fontFeatureSettings() const
{
    return fontDescription().featureSettings();
}

#if ENABLE(VARIATION_FONTS)

inline FontVariationSettings ComputedStyleProperties::fontVariationSettings() const
{
    return fontDescription().variationSettings();
}

#endif

inline FontWeight ComputedStyleProperties::fontWeight() const
{
    return fontDescription().weight();
}

inline FontWidth ComputedStyleProperties::fontWidth() const
{
    return fontDescription().width();
}

inline Kerning ComputedStyleProperties::fontKerning() const
{
    return fontDescription().kerning();
}

inline FontSmoothingMode ComputedStyleProperties::fontSmoothing() const
{
    return fontDescription().fontSmoothing();
}

inline FontSynthesisLonghandValue ComputedStyleProperties::fontSynthesisSmallCaps() const
{
    return fontDescription().fontSynthesisSmallCaps();
}

inline FontSynthesisLonghandValue ComputedStyleProperties::fontSynthesisStyle() const
{
    return fontDescription().fontSynthesisStyle();
}

inline FontSynthesisLonghandValue ComputedStyleProperties::fontSynthesisWeight() const
{
    return fontDescription().fontSynthesisWeight();
}

inline FontVariantAlternates ComputedStyleProperties::fontVariantAlternates() const
{
    return fontDescription().variantAlternates();
}

inline FontVariantCaps ComputedStyleProperties::fontVariantCaps() const
{
    return fontDescription().variantCaps();
}

inline FontVariantEastAsian ComputedStyleProperties::fontVariantEastAsian() const
{
    return fontDescription().variantEastAsian();
}

inline FontVariantEmoji ComputedStyleProperties::fontVariantEmoji() const
{
    return fontDescription().variantEmoji();
}

inline FontVariantLigatures ComputedStyleProperties::fontVariantLigatures() const
{
    return fontDescription().variantLigatures();
}

inline FontVariantNumeric ComputedStyleProperties::fontVariantNumeric() const
{
    return fontDescription().variantNumeric();
}

inline FontVariantPosition ComputedStyleProperties::fontVariantPosition() const
{
    return fontDescription().variantPosition();
}

inline TextRenderingMode ComputedStyleProperties::textRendering() const
{
    return fontDescription().textRenderingMode();
}

inline TextAutospace ComputedStyleProperties::textAutospace() const
{
    return fontDescription().textAutospace();
}

inline TextSpacingTrim ComputedStyleProperties::textSpacingTrim() const
{
    return fontDescription().textSpacingTrim();
}

inline WebkitLocale ComputedStyleProperties::locale() const
{
    return fontDescription().specifiedLocale();
}

// MARK: - Custom ColorPropertyTrait function definitions

inline const Color& ColorPropertyTraits<PropertyNameConstant<CSSPropertyColor>>::color(const ComputedStyleProperties&)
{
    // FIXME: This works because because `currentColor` will be resolved to `color()`. It would be slightly nicer if we could return an actual `Style::Color`, but `color()` is currently stored as a `WebCore::Color` and therefore we cannot return it as a reference.
    return Color::currentColor();
}

inline const Color& ColorPropertyTraits<PropertyNameConstant<CSSPropertyColor>>::visitedLinkColor(const ComputedStyleProperties&)
{
    // FIXME: This works because because `currentColor` will be resolved to `visitedLinkColor()`. It would be slightly nicer if we could return an actual `Style::Color`, but `visitedLinkColor()` is currently stored as a `WebCore::Color` and therefore we cannot return it as a reference.
    return Color::currentColor();
}

inline const Color& ColorPropertyTraits<PropertyNameConstant<CSSPropertyAccentColor>>::color(const ComputedStyleProperties& style)
{
    return style.accentColor().colorOrCurrentColor();
}

inline const Color& ColorPropertyTraits<PropertyNameConstant<CSSPropertyCaretColor>>::color(const ComputedStyleProperties& style)
{
    return style.caretColor().colorOrCurrentColor();
}

inline const Color& ColorPropertyTraits<PropertyNameConstant<CSSPropertyCaretColor>>::visitedLinkColor(const ComputedStyleProperties& style)
{
    return style.visitedLinkCaretColor().colorOrCurrentColor();
}

inline const Color& ColorPropertyTraits<PropertyNameConstant<CSSPropertyFill>>::color(const ComputedStyleProperties& style)
{
    return style.fill().colorDisregardingType();
}

inline const Color& ColorPropertyTraits<PropertyNameConstant<CSSPropertyFill>>::visitedLinkColor(const ComputedStyleProperties& style)
{
    return style.visitedLinkFill().colorDisregardingType();
}

inline const Color& ColorPropertyTraits<PropertyNameConstant<CSSPropertyStroke>>::color(const ComputedStyleProperties& style)
{
    return style.stroke().colorDisregardingType();
}

inline const Color& ColorPropertyTraits<PropertyNameConstant<CSSPropertyStroke>>::visitedLinkColor(const ComputedStyleProperties& style)
{
    return style.visitedLinkStroke().colorDisregardingType();
}

inline WebCore::Color ColorPropertyTraits<PropertyNameConstant<CSSPropertyTextDecorationColor>>::colorResolvingCurrentColor(const ComputedStyleProperties& style)
{
    auto& result = style.textDecorationColor();
    if (result.isCurrentColor()) {
        if ((style.hasExplicitlySetStrokeWidth() && style.strokeWidth().isPossiblyPositive()) || style.textStrokeWidth().isPositive()) {
            // Prefer stroke color if possible but not if it's fully transparent.
            if (style.hasExplicitlySetStrokeColor()) {
                auto strokeColor = style.strokeColor().resolveColor(style.color());
                if (strokeColor.isVisible())
                    return strokeColor;
            } else {
                auto strokeColor = style.textStrokeColor().resolveColor(style.color());
                if (strokeColor.isVisible())
                    return strokeColor;
            }
        }
        return style.textFillColor().resolveColor(style.color());
    }
    return result.resolveColor(style.color());
}

inline WebCore::Color ColorPropertyTraits<PropertyNameConstant<CSSPropertyTextDecorationColor>>::visitedLinkColorResolvingCurrentColor(const ComputedStyleProperties& style)
{
    auto& result = style.visitedLinkTextDecorationColor();
    if (result.isCurrentColor()) {
        if ((style.hasExplicitlySetStrokeWidth() && style.strokeWidth().isPossiblyPositive()) || style.textStrokeWidth().isPositive()) {
            // Prefer stroke color if possible but not if it's fully transparent.
            if (style.hasExplicitlySetStrokeColor()) {
                auto strokeColor = style.visitedLinkStrokeColor().resolveColor(style.visitedLinkColor());
                if (strokeColor.isVisible())
                    return strokeColor;
            } else {
                auto strokeColor = style.visitedLinkTextStrokeColor().resolveColor(style.visitedLinkColor());
                if (strokeColor.isVisible())
                    return strokeColor;
            }
        }
        return style.visitedLinkTextFillColor().resolveColor(style.visitedLinkColor());
    }
    return result.resolveColor(style.visitedLinkColor());
}

inline bool ColorPropertyTraits<PropertyNameConstant<CSSPropertyBackgroundColor>>::excludesVisitedLinkColor(const WebCore::Color& visitedLinkColor)
{
    // FIXME: Technically someone could explicitly specify the color transparent, but for now we'll just
    // assume that if the background color is transparent that it wasn't set. Note that it's weird that
    // we're returning unvisited info for a visited link, but given our restriction that the alpha values
    // have to match, it makes more sense to return the unvisited background color if specified than it
    // does to return black. This behavior matches what Firefox 4 does as well.
    return visitedLinkColor == WebCore::Color::transparentBlack;
}

} // namespace Style
} // namespace WebCore