2
* Copyright (C) 2019 Apple Inc. All rights reserved.
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions
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.
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.
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>
44
struct BuilderContext {
45
Ref<const Document> document;
46
const RenderStyle& parentStyle;
47
const RenderStyle* rootElementStyle = nullptr;
48
RefPtr<const Element> element = nullptr;
53
BuilderState(Builder&, RenderStyle&, BuilderContext&&);
55
Builder& builder() { return m_builder; }
57
RenderStyle& style() { return m_style; }
58
const RenderStyle& parentStyle() const { return m_context.parentStyle; }
59
const RenderStyle* rootElementStyle() const { return m_context.rootElementStyle; }
61
const Document& document() const { return m_context.document.get(); }
62
const Element* element() const { return m_context.element.get(); }
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); }
71
bool fontDirty() const { return m_fontDirty; }
72
void setFontDirty() { m_fontDirty = true; }
74
const FontCascadeDescription& fontDescription() { return m_style.fontDescription(); }
75
const FontCascadeDescription& parentFontDescription() { return parentStyle().fontDescription(); }
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; }
81
bool useSVGZoomRules() const;
82
bool useSVGZoomRulesForLength() const;
83
ScopeOrdinal styleScopeOrdinal() const { return m_styleScopeOrdinal; }
85
Ref<CSSValue> resolveImageStyles(CSSValue&);
86
RefPtr<StyleImage> createStyleImage(CSSValue&);
87
bool createFilterOperations(const CSSValue&, FilterOperations& outOperations);
89
static bool isColorFromPrimitiveValueDerivedFromElement(const CSSPrimitiveValue&);
90
Color colorFromPrimitiveValue(const CSSPrimitiveValue&, bool forVisitedLink = false) const;
92
const Vector<AtomString>& registeredContentAttributes() const { return m_registeredContentAttributes; }
93
void registerContentAttribute(const AtomString& attributeLocalName);
95
const CSSToLengthConversionData& cssToLengthConversionData() const { return m_cssToLengthConversionData; }
96
CSSToStyleMap& styleMap() { return m_styleMap; }
101
void adjustStyleForInterCharacterRuby();
104
#if ENABLE(TEXT_AUTOSIZING)
105
void updateFontForTextSizeAdjust();
107
void updateFontForZoomChange();
108
void updateFontForGenericFamilyChange();
109
void updateFontForOrientationChange();
113
CSSToStyleMap m_styleMap;
115
RenderStyle& m_style;
116
const BuilderContext m_context;
118
const CSSToLengthConversionData m_cssToLengthConversionData;
120
Bitmap<numCSSProperties> m_appliedProperties;
121
HashSet<String> m_appliedCustomProperties;
122
Bitmap<numCSSProperties> m_inProgressProperties;
123
HashSet<String> m_inProgressPropertiesCustom;
125
CascadeLevel m_cascadeLevel { };
126
ScopeOrdinal m_styleScopeOrdinal { };
127
SelectorChecker::LinkMatchMask m_linkMatch { };
129
bool m_fontDirty { false };
130
Vector<AtomString> m_registeredContentAttributes;