~mmach/netext73/webkit2gtk

« back to all changes in this revision

Viewing changes to Source/WebCore/style/StyleBuilderState.h

  • Committer: mmach
  • Date: 2023-06-16 17:21:37 UTC
  • Revision ID: netbit73@gmail.com-20230616172137-2rqx6yr96ga9g3kp
1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2019 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 "CSSToLengthConversionData.h"
 
29
#include "CSSToStyleMap.h"
 
30
#include "CascadeLevel.h"
 
31
#include "RenderStyle.h"
 
32
#include "SelectorChecker.h"
 
33
#include <wtf/Bitmap.h>
 
34
 
 
35
namespace WebCore {
 
36
 
 
37
class StyleImage;
 
38
class StyleResolver;
 
39
 
 
40
namespace Style {
 
41
 
 
42
class Builder;
 
43
 
 
44
struct BuilderContext {
 
45
    Ref<const Document> document;
 
46
    const RenderStyle& parentStyle;
 
47
    const RenderStyle* rootElementStyle = nullptr;
 
48
    RefPtr<const Element> element = nullptr;
 
49
};
 
50
 
 
51
class BuilderState {
 
52
public:
 
53
    BuilderState(Builder&, RenderStyle&, BuilderContext&&);
 
54
 
 
55
    Builder& builder() { return m_builder; }
 
56
 
 
57
    RenderStyle& style() { return m_style; }
 
58
    const RenderStyle& parentStyle() const { return m_context.parentStyle; }
 
59
    const RenderStyle* rootElementStyle() const { return m_context.rootElementStyle; }
 
60
 
 
61
    const Document& document() const { return m_context.document.get(); }
 
62
    const Element* element() const { return m_context.element.get(); }
 
63
 
 
64
    void setFontDescription(FontCascadeDescription&& fontDescription) { m_fontDirty |= m_style.setFontDescription(WTFMove(fontDescription)); }
 
65
    void setFontSize(FontCascadeDescription&, float size);
 
66
    void setZoom(float f) { m_fontDirty |= m_style.setZoom(f); }
 
67
    void setEffectiveZoom(float f) { m_fontDirty |= m_style.setEffectiveZoom(f); }
 
68
    void setWritingMode(WritingMode writingMode) { m_fontDirty |= m_style.setWritingMode(writingMode); }
 
69
    void setTextOrientation(TextOrientation textOrientation) { m_fontDirty |= m_style.setTextOrientation(textOrientation); }
 
70
 
 
71
    bool fontDirty() const { return m_fontDirty; }
 
72
    void setFontDirty() { m_fontDirty = true; }
 
73
 
 
74
    const FontCascadeDescription& fontDescription() { return m_style.fontDescription(); }
 
75
    const FontCascadeDescription& parentFontDescription() { return parentStyle().fontDescription(); }
 
76
 
 
77
    // FIXME: These are mutually exclusive, clean up the code to take that into account.
 
78
    bool applyPropertyToRegularStyle() const { return m_linkMatch != SelectorChecker::MatchVisited; }
 
79
    bool applyPropertyToVisitedLinkStyle() const { return m_linkMatch == SelectorChecker::MatchVisited; }
 
80
 
 
81
    bool useSVGZoomRules() const;
 
82
    bool useSVGZoomRulesForLength() const;
 
83
    ScopeOrdinal styleScopeOrdinal() const { return m_styleScopeOrdinal; }
 
84
 
 
85
    Ref<CSSValue> resolveImageStyles(CSSValue&);
 
86
    RefPtr<StyleImage> createStyleImage(CSSValue&);
 
87
    bool createFilterOperations(const CSSValue&, FilterOperations& outOperations);
 
88
 
 
89
    static bool isColorFromPrimitiveValueDerivedFromElement(const CSSPrimitiveValue&);
 
90
    Color colorFromPrimitiveValue(const CSSPrimitiveValue&, bool forVisitedLink = false) const;
 
91
 
 
92
    const Vector<AtomString>& registeredContentAttributes() const { return m_registeredContentAttributes; }
 
93
    void registerContentAttribute(const AtomString& attributeLocalName);
 
94
 
 
95
    const CSSToLengthConversionData& cssToLengthConversionData() const { return m_cssToLengthConversionData; }
 
96
    CSSToStyleMap& styleMap() { return m_styleMap; }
 
97
 
 
98
private:
 
99
    friend class Builder;
 
100
 
 
101
    void adjustStyleForInterCharacterRuby();
 
102
 
 
103
    void updateFont();
 
104
#if ENABLE(TEXT_AUTOSIZING)
 
105
    void updateFontForTextSizeAdjust();
 
106
#endif
 
107
    void updateFontForZoomChange();
 
108
    void updateFontForGenericFamilyChange();
 
109
    void updateFontForOrientationChange();
 
110
 
 
111
    Builder& m_builder;
 
112
 
 
113
    CSSToStyleMap m_styleMap;
 
114
 
 
115
    RenderStyle& m_style;
 
116
    const BuilderContext m_context;
 
117
 
 
118
    const CSSToLengthConversionData m_cssToLengthConversionData;
 
119
 
 
120
    Bitmap<numCSSProperties> m_appliedProperties;
 
121
    HashSet<String> m_appliedCustomProperties;
 
122
    Bitmap<numCSSProperties> m_inProgressProperties;
 
123
    HashSet<String> m_inProgressPropertiesCustom;
 
124
 
 
125
    CascadeLevel m_cascadeLevel { };
 
126
    ScopeOrdinal m_styleScopeOrdinal { };
 
127
    SelectorChecker::LinkMatchMask m_linkMatch { };
 
128
 
 
129
    bool m_fontDirty { false };
 
130
    Vector<AtomString> m_registeredContentAttributes;
 
131
};
 
132
 
 
133
}
 
134
}