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
|
/**
* Copyright (C) 2000 Lars Knoll (knoll@kde.org)
* Copyright (C) 2000 Antti Koivisto (koivisto@kde.org)
* Copyright (C) 2000 Dirk Mueller (mueller@kde.org)
* Copyright (C) 2003-2025 Apple Inc. All rights reserved.
* Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
* Copyright (C) 2014-2021 Google Inc. All rights reserved.
* Copyright (C) 2025 Samuel Weinig <sam@webkit.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#pragma once
#include "RenderStyleInlines.h"
#include "StylePrimitiveNumericTypes+Evaluation.h"
#define RENDER_STYLE_PROPERTIES_SETTERS_INLINES_INCLUDE_TRAP 1
#include "RenderStylePropertiesSettersInlines.h"
#undef RENDER_STYLE_PROPERTIES_SETTERS_INLINES_INCLUDE_TRAP
namespace WebCore {
#define SET_STYLE_PROPERTY_BASE(read, value, write) do { if (!compareEqual(read, value)) write; } while (0)
#define SET_STYLE_PROPERTY(read, write, value) SET_STYLE_PROPERTY_BASE(read, value, write = value)
#define SET(group, variable, value) SET_STYLE_PROPERTY(group->variable, group.access().variable, value)
#define SET_NESTED(group, parent, variable, value) SET_STYLE_PROPERTY(group->parent->variable, group.access().parent.access().variable, value)
#define SET_DOUBLY_NESTED(group, grandparent, parent, variable, value) SET_STYLE_PROPERTY(group->grandparent->parent->variable, group.access().grandparent.access().parent.access().variable, value)
#define SET_NESTED_STRUCT(group, parent, variable, value) SET_STYLE_PROPERTY(group->parent.variable, group.access().parent.variable, value)
#define SET_STYLE_PROPERTY_PAIR(read, write, variable1, value1, variable2, value2) do { auto& readable = *read; if (!compareEqual(readable.variable1, value1) || !compareEqual(readable.variable2, value2)) { auto& writable = write; writable.variable1 = value1; writable.variable2 = value2; } } while (0)
#define SET_PAIR(group, variable1, value1, variable2, value2) SET_STYLE_PROPERTY_PAIR(group, group.access(), variable1, value1, variable2, value2)
#define SET_NESTED_PAIR(group, parent, variable1, value1, variable2, value2) SET_STYLE_PROPERTY_PAIR(group->parent, group.access().parent.access(), variable1, value1, variable2, value2)
#define SET_DOUBLY_NESTED_PAIR(group, grandparent, parent, variable1, value1, variable2, value2) SET_STYLE_PROPERTY_PAIR(group->grandparent->parent, group.access().grandparent.access().parent.access(), variable1, value1, variable2, value2)
// MARK: - Non-property setters
inline void RenderStyle::setHasPseudoStyles(EnumSet<PseudoElementType> set)
{
m_nonInheritedFlags.setHasPseudoStyles(set);
}
inline void RenderStyle::inheritColumnPropertiesFrom(const RenderStyle& parent)
{
m_nonInheritedData.access().miscData.access().multiCol = parent.m_nonInheritedData->miscData->multiCol;
}
inline void RenderStyle::setPseudoElementIdentifier(std::optional<Style::PseudoElementIdentifier>&& identifier)
{
if (identifier) {
m_nonInheritedFlags.pseudoElementType = enumToUnderlyingType(identifier->type) + 1;
SET_NESTED(m_nonInheritedData, rareData, pseudoElementNameArgument, WTFMove(identifier->nameArgument));
} else {
m_nonInheritedFlags.pseudoElementType = 0;
SET_NESTED(m_nonInheritedData, rareData, pseudoElementNameArgument, nullAtom());
}
}
// MARK: - Cache used values
inline void RenderStyle::setUsedAppearance(StyleAppearance a)
{
SET_NESTED(m_nonInheritedData, miscData, usedAppearance, static_cast<unsigned>(a));
}
inline void RenderStyle::setUsedTouchAction(Style::TouchAction touchAction)
{
SET(m_rareInheritedData, usedTouchAction, touchAction);
}
inline void RenderStyle::setUsedContentVisibility(ContentVisibility usedContentVisibility)
{
SET(m_rareInheritedData, usedContentVisibility, static_cast<unsigned>(usedContentVisibility));
}
inline void RenderStyle::setUsedZIndex(Style::ZIndex index)
{
SET_NESTED_PAIR(m_nonInheritedData, boxData, hasAutoUsedZIndex, static_cast<uint8_t>(index.m_isAuto), usedZIndexValue, index.m_value);
}
#if HAVE(CORE_MATERIAL)
inline void RenderStyle::setUsedAppleVisualEffectForSubtree(AppleVisualEffect effect)
{
SET(m_rareInheritedData, usedAppleVisualEffectForSubtree, static_cast<unsigned>(effect));
}
#endif
// MARK: - Style adjustment utilities
inline void RenderStyle::addToTextDecorationLineInEffect(Style::TextDecorationLine value)
{
m_inheritedFlags.textDecorationLineInEffect = textDecorationLineInEffect().addOrReplaceIfNotNone(value);
}
inline void RenderStyle::containIntrinsicWidthAddAuto()
{
setContainIntrinsicWidth(containIntrinsicWidth().addingAuto());
}
inline void RenderStyle::containIntrinsicHeightAddAuto()
{
setContainIntrinsicHeight(containIntrinsicHeight().addingAuto());
}
inline void RenderStyle::setGridAutoFlowDirection(Style::GridAutoFlow::Direction direction)
{
if (!compareEqual(m_nonInheritedData->rareData->grid->gridAutoFlow.direction(), direction))
m_nonInheritedData.access().rareData.access().grid.access().gridAutoFlow.setDirection(direction);
}
inline void RenderStyle::resetBorderBottom()
{
SET_NESTED(m_nonInheritedData, surroundData, border.edges().bottom(), BorderValue());
}
inline void RenderStyle::resetBorderBottomLeftRadius()
{
SET_NESTED(m_nonInheritedData, surroundData, border.radii().bottomLeft(), initialBorderRadius());
}
inline void RenderStyle::resetBorderBottomRightRadius()
{
SET_NESTED(m_nonInheritedData, surroundData, border.radii().bottomRight(), initialBorderRadius());
}
inline void RenderStyle::resetBorderImage()
{
SET_NESTED(m_nonInheritedData, surroundData, border.image(), Style::BorderImage());
}
inline void RenderStyle::resetBorderLeft()
{
SET_NESTED(m_nonInheritedData, surroundData, border.edges().left(), BorderValue());
}
inline void RenderStyle::resetBorderRight()
{
SET_NESTED(m_nonInheritedData, surroundData, border.edges().right(), BorderValue());
}
inline void RenderStyle::resetBorderTop()
{
SET_NESTED(m_nonInheritedData, surroundData, border.edges().top(), BorderValue { });
}
inline void RenderStyle::resetBorderTopLeftRadius()
{
SET_NESTED(m_nonInheritedData, surroundData, border.radii().topLeft(), initialBorderRadius());
}
inline void RenderStyle::resetBorderTopRightRadius()
{
SET_NESTED(m_nonInheritedData, surroundData, border.radii().topRight(), initialBorderRadius());
}
inline void RenderStyle::resetColumnRule()
{
SET_DOUBLY_NESTED(m_nonInheritedData, miscData, multiCol, columnRule, BorderValue());
}
inline void RenderStyle::resetMargin()
{
SET_NESTED(m_nonInheritedData, surroundData, margin, Style::MarginBox { 0_css_px });
}
inline void RenderStyle::resetPadding()
{
SET_NESTED(m_nonInheritedData, surroundData, padding, Style::PaddingBox { 0_css_px });
}
inline void RenderStyle::resetPageSize()
{
SET_NESTED(m_nonInheritedData, rareData, pageSize, Style::PageSize { CSS::Keyword::Auto { } });
}
inline void RenderStyle::resetBorder()
{
resetBorderExceptRadius();
resetBorderRadius();
}
inline void RenderStyle::resetBorderExceptRadius()
{
resetBorderImage();
resetBorderTop();
resetBorderRight();
resetBorderBottom();
resetBorderLeft();
}
inline void RenderStyle::resetBorderRadius()
{
resetBorderTopLeftRadius();
resetBorderTopRightRadius();
resetBorderBottomLeftRadius();
resetBorderBottomRightRadius();
}
// MARK: - Logical setters
inline void RenderStyle::setLogicalHeight(Style::PreferredSize&& height)
{
if (writingMode().isHorizontal())
setHeight(WTFMove(height));
else
setWidth(WTFMove(height));
}
inline void RenderStyle::setLogicalWidth(Style::PreferredSize&& width)
{
if (writingMode().isHorizontal())
setWidth(WTFMove(width));
else
setHeight(WTFMove(width));
}
inline void RenderStyle::setLogicalMinWidth(Style::MinimumSize&& width)
{
if (writingMode().isHorizontal())
setMinWidth(WTFMove(width));
else
setMinHeight(WTFMove(width));
}
inline void RenderStyle::setLogicalMaxWidth(Style::MaximumSize&& width)
{
if (writingMode().isHorizontal())
setMaxWidth(WTFMove(width));
else
setMaxHeight(WTFMove(width));
}
inline void RenderStyle::setLogicalMinHeight(Style::MinimumSize&& height)
{
if (writingMode().isHorizontal())
setMinHeight(WTFMove(height));
else
setMinWidth(WTFMove(height));
}
inline void RenderStyle::setLogicalMaxHeight(Style::MaximumSize&& height)
{
if (writingMode().isHorizontal())
setMaxHeight(WTFMove(height));
else
setMaxWidth(WTFMove(height));
}
#undef SET
#undef SET_DOUBLY_NESTED
#undef SET_DOUBLY_NESTED_PAIR
#undef SET_NESTED
#undef SET_NESTED_PAIR
#undef SET_NESTED_STRUCT
#undef SET_PAIR
#undef SET_STYLE_PROPERTY
#undef SET_STYLE_PROPERTY_BASE
#undef SET_STYLE_PROPERTY_PAIR
} // namespace WebCore
|