2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
3 * Copyright (C) 2004-2015 Apple Inc. All rights reserved.
4 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
24 #include "RenderStyle.h"
26 #include "ContentData.h"
27 #include "CursorList.h"
28 #include "CSSPropertyNames.h"
29 #include "FloatRoundedRect.h"
30 #include "FontCascade.h"
31 #include "FontSelector.h"
32 #include "InlineTextBoxStyle.h"
33 #include "Pagination.h"
34 #include "QuotesData.h"
35 #include "RenderObject.h"
36 #include "ScaleTransformOperation.h"
37 #include "ShadowData.h"
38 #include "StyleImage.h"
39 #include "StyleInheritedData.h"
40 #include "StyleResolver.h"
41 #include "StyleScrollSnapPoints.h"
42 #include <wtf/MathExtras.h>
43 #include <wtf/StdLibExtras.h>
46 #if ENABLE(IOS_TEXT_AUTOSIZING)
47 #include <wtf/text/StringHash.h>
50 #if ENABLE(TEXT_AUTOSIZING)
51 #include "TextAutosizer.h"
54 #if ENABLE(TOUCH_EVENTS)
55 #include "RenderTheme.h"
60 struct SameSizeAsBorderValue {
66 COMPILE_ASSERT(sizeof(BorderValue) == sizeof(SameSizeAsBorderValue), BorderValue_should_not_grow);
68 struct SameSizeAsRenderStyle : public RefCounted<SameSizeAsRenderStyle> {
71 void* dataRefSvgStyle;
72 struct InheritedFlags {
73 unsigned m_bitfields[2];
76 struct NonInheritedFlags {
81 COMPILE_ASSERT(sizeof(RenderStyle) == sizeof(SameSizeAsRenderStyle), RenderStyle_should_stay_small);
83 inline RenderStyle& defaultStyle()
85 static RenderStyle& style = RenderStyle::createDefaultStyle().leakRef();
89 Ref<RenderStyle> RenderStyle::create()
91 return adoptRef(*new RenderStyle(defaultStyle()));
94 Ref<RenderStyle> RenderStyle::createDefaultStyle()
96 return adoptRef(*new RenderStyle(true));
99 Ref<RenderStyle> RenderStyle::createAnonymousStyleWithDisplay(const RenderStyle* parentStyle, EDisplay display)
101 auto newStyle = RenderStyle::create();
102 newStyle.get().inheritFrom(parentStyle);
103 newStyle.get().inheritUnicodeBidiFrom(parentStyle);
104 newStyle.get().setDisplay(display);
108 Ref<RenderStyle> RenderStyle::clone(const RenderStyle* other)
110 return adoptRef(*new RenderStyle(*other));
113 Ref<RenderStyle> RenderStyle::createStyleInheritingFromPseudoStyle(const RenderStyle& pseudoStyle)
115 ASSERT(pseudoStyle.styleType() == BEFORE || pseudoStyle.styleType() == AFTER);
117 auto style = RenderStyle::create();
118 style.get().inheritFrom(&pseudoStyle);
122 ALWAYS_INLINE RenderStyle::RenderStyle(bool)
123 : m_box(StyleBoxData::create())
124 , visual(StyleVisualData::create())
125 , m_background(StyleBackgroundData::create())
126 , surround(StyleSurroundData::create())
127 , rareNonInheritedData(StyleRareNonInheritedData::create())
128 , rareInheritedData(StyleRareInheritedData::create())
129 , inherited(StyleInheritedData::create())
130 , m_svgStyle(SVGRenderStyle::create())
132 inherited_flags._empty_cells = initialEmptyCells();
133 inherited_flags._caption_side = initialCaptionSide();
134 inherited_flags._list_style_type = initialListStyleType();
135 inherited_flags._list_style_position = initialListStylePosition();
136 inherited_flags._visibility = initialVisibility();
137 inherited_flags._text_align = initialTextAlign();
138 inherited_flags._text_transform = initialTextTransform();
139 inherited_flags._text_decorations = initialTextDecoration();
140 inherited_flags._cursor_style = initialCursor();
141 #if ENABLE(CURSOR_VISIBILITY)
142 inherited_flags.m_cursorVisibility = initialCursorVisibility();
144 inherited_flags._direction = initialDirection();
145 inherited_flags._white_space = initialWhiteSpace();
146 inherited_flags._border_collapse = initialBorderCollapse();
147 inherited_flags.m_rtlOrdering = initialRTLOrdering();
148 inherited_flags._box_direction = initialBoxDirection();
149 inherited_flags.m_printColorAdjust = initialPrintColorAdjust();
150 inherited_flags._pointerEvents = initialPointerEvents();
151 inherited_flags._insideLink = NotInsideLink;
152 inherited_flags._insideDefaultButton = false;
153 inherited_flags.m_writingMode = initialWritingMode();
155 static_assert((sizeof(InheritedFlags) <= 8), "InheritedFlags does not grow");
156 static_assert((sizeof(NonInheritedFlags) <= 8), "NonInheritedFlags does not grow");
159 ALWAYS_INLINE RenderStyle::RenderStyle(const RenderStyle& o)
160 : RefCounted<RenderStyle>()
163 , m_background(o.m_background)
164 , surround(o.surround)
165 , rareNonInheritedData(o.rareNonInheritedData)
166 , rareInheritedData(o.rareInheritedData)
167 , inherited(o.inherited)
168 , m_svgStyle(o.m_svgStyle)
169 , inherited_flags(o.inherited_flags)
170 , noninherited_flags(o.noninherited_flags)
174 ItemPosition RenderStyle::resolveAlignment(const RenderStyle& parentStyle, const RenderStyle& childStyle, ItemPosition resolvedAutoPositionForRenderer)
176 // The auto keyword computes to the parent's align-items computed value, or to "stretch", if not set or "auto".
177 if (childStyle.alignSelf() == ItemPositionAuto)
178 return (parentStyle.alignItems() == ItemPositionAuto) ? resolvedAutoPositionForRenderer : parentStyle.alignItems();
179 return childStyle.alignSelf();
182 void RenderStyle::inheritFrom(const RenderStyle* inheritParent, IsAtShadowBoundary isAtShadowBoundary)
184 if (isAtShadowBoundary == AtShadowBoundary) {
185 // Even if surrounding content is user-editable, shadow DOM should act as a single unit, and not necessarily be editable
186 EUserModify currentUserModify = userModify();
187 rareInheritedData = inheritParent->rareInheritedData;
188 setUserModify(currentUserModify);
190 rareInheritedData = inheritParent->rareInheritedData;
191 inherited = inheritParent->inherited;
192 inherited_flags = inheritParent->inherited_flags;
194 if (m_svgStyle != inheritParent->m_svgStyle)
195 m_svgStyle.access()->inheritFrom(inheritParent->m_svgStyle.get());
198 void RenderStyle::copyNonInheritedFrom(const RenderStyle* other)
200 m_box = other->m_box;
201 visual = other->visual;
202 m_background = other->m_background;
203 surround = other->surround;
204 rareNonInheritedData = other->rareNonInheritedData;
205 noninherited_flags.copyNonInheritedFrom(other->noninherited_flags);
207 if (m_svgStyle != other->m_svgStyle)
208 m_svgStyle.access()->copyNonInheritedFrom(other->m_svgStyle.get());
210 ASSERT(zoom() == initialZoom());
213 bool RenderStyle::operator==(const RenderStyle& o) const
215 // compare everything except the pseudoStyle pointer
216 return inherited_flags == o.inherited_flags
217 && noninherited_flags == o.noninherited_flags
219 && visual == o.visual
220 && m_background == o.m_background
221 && surround == o.surround
222 && rareNonInheritedData == o.rareNonInheritedData
223 && rareInheritedData == o.rareInheritedData
224 && inherited == o.inherited
225 && m_svgStyle == o.m_svgStyle
229 bool RenderStyle::isStyleAvailable() const
231 return this != StyleResolver::styleNotYetAvailable();
234 bool RenderStyle::hasUniquePseudoStyle() const
236 if (!m_cachedPseudoStyles || styleType() != NOPSEUDO)
239 for (size_t i = 0; i < m_cachedPseudoStyles->size(); ++i) {
240 RenderStyle* pseudoStyle = m_cachedPseudoStyles->at(i).get();
241 if (pseudoStyle->unique())
248 RenderStyle* RenderStyle::getCachedPseudoStyle(PseudoId pid) const
250 if (!m_cachedPseudoStyles || !m_cachedPseudoStyles->size())
253 if (styleType() != NOPSEUDO)
256 for (size_t i = 0; i < m_cachedPseudoStyles->size(); ++i) {
257 RenderStyle* pseudoStyle = m_cachedPseudoStyles->at(i).get();
258 if (pseudoStyle->styleType() == pid)
265 RenderStyle* RenderStyle::addCachedPseudoStyle(PassRefPtr<RenderStyle> pseudo)
270 ASSERT(pseudo->styleType() > NOPSEUDO);
272 RenderStyle* result = pseudo.get();
274 if (!m_cachedPseudoStyles)
275 m_cachedPseudoStyles = std::make_unique<PseudoStyleCache>();
277 m_cachedPseudoStyles->append(pseudo);
282 void RenderStyle::removeCachedPseudoStyle(PseudoId pid)
284 if (!m_cachedPseudoStyles)
286 for (size_t i = 0; i < m_cachedPseudoStyles->size(); ++i) {
287 RenderStyle* pseudoStyle = m_cachedPseudoStyles->at(i).get();
288 if (pseudoStyle->styleType() == pid) {
289 m_cachedPseudoStyles->remove(i);
295 bool RenderStyle::inheritedNotEqual(const RenderStyle* other) const
297 return inherited_flags != other->inherited_flags
298 || inherited != other->inherited
299 || m_svgStyle->inheritedNotEqual(other->m_svgStyle.get())
300 || rareInheritedData != other->rareInheritedData;
303 #if ENABLE(IOS_TEXT_AUTOSIZING)
304 inline unsigned computeFontHash(const FontCascade& font)
306 unsigned hashCodes[2] = {
307 CaseFoldingHash::hash(font.fontDescription().firstFamily().impl()),
308 static_cast<unsigned>(font.fontDescription().specifiedSize())
310 return StringHasher::computeHash(reinterpret_cast<UChar*>(hashCodes), 2 * sizeof(unsigned) / sizeof(UChar));
313 uint32_t RenderStyle::hashForTextAutosizing() const
315 // FIXME: Not a very smart hash. Could be improved upon. See <https://bugs.webkit.org/show_bug.cgi?id=121131>.
318 hash ^= rareNonInheritedData->m_appearance;
319 hash ^= rareNonInheritedData->marginBeforeCollapse;
320 hash ^= rareNonInheritedData->marginAfterCollapse;
321 hash ^= rareNonInheritedData->lineClamp.value();
322 hash ^= rareInheritedData->overflowWrap;
323 hash ^= rareInheritedData->nbspMode;
324 hash ^= rareInheritedData->lineBreak;
325 hash ^= WTF::FloatHash<float>::hash(inherited->specifiedLineHeight.value());
326 hash ^= computeFontHash(inherited->fontCascade);
327 hash ^= inherited->horizontal_border_spacing;
328 hash ^= inherited->vertical_border_spacing;
329 hash ^= inherited_flags._box_direction;
330 hash ^= inherited_flags.m_rtlOrdering;
331 hash ^= noninherited_flags.position();
332 hash ^= noninherited_flags.floating();
333 hash ^= rareNonInheritedData->textOverflow;
334 hash ^= rareInheritedData->textSecurity;
338 bool RenderStyle::equalForTextAutosizing(const RenderStyle* other) const
340 return rareNonInheritedData->m_appearance == other->rareNonInheritedData->m_appearance
341 && rareNonInheritedData->marginBeforeCollapse == other->rareNonInheritedData->marginBeforeCollapse
342 && rareNonInheritedData->marginAfterCollapse == other->rareNonInheritedData->marginAfterCollapse
343 && rareNonInheritedData->lineClamp == other->rareNonInheritedData->lineClamp
344 && rareInheritedData->textSizeAdjust == other->rareInheritedData->textSizeAdjust
345 && rareInheritedData->overflowWrap == other->rareInheritedData->overflowWrap
346 && rareInheritedData->nbspMode == other->rareInheritedData->nbspMode
347 && rareInheritedData->lineBreak == other->rareInheritedData->lineBreak
348 && rareInheritedData->textSecurity == other->rareInheritedData->textSecurity
349 && inherited->specifiedLineHeight == other->inherited->specifiedLineHeight
350 && inherited->fontCascade.equalForTextAutoSizing(other->inherited->fontCascade)
351 && inherited->horizontal_border_spacing == other->inherited->horizontal_border_spacing
352 && inherited->vertical_border_spacing == other->inherited->vertical_border_spacing
353 && inherited_flags._box_direction == other->inherited_flags._box_direction
354 && inherited_flags.m_rtlOrdering == other->inherited_flags.m_rtlOrdering
355 && noninherited_flags.position() == other->noninherited_flags.position()
356 && noninherited_flags.floating() == other->noninherited_flags.floating()
357 && rareNonInheritedData->textOverflow == other->rareNonInheritedData->textOverflow;
359 #endif // ENABLE(IOS_TEXT_AUTOSIZING)
361 bool RenderStyle::inheritedDataShared(const RenderStyle* other) const
363 // This is a fast check that only looks if the data structures are shared.
364 return inherited_flags == other->inherited_flags
365 && inherited.get() == other->inherited.get()
366 && m_svgStyle.get() == other->m_svgStyle.get()
367 && rareInheritedData.get() == other->rareInheritedData.get();
370 static bool positionChangeIsMovementOnly(const LengthBox& a, const LengthBox& b, const Length& width)
372 // If any unit types are different, then we can't guarantee
373 // that this was just a movement.
374 if (a.left().type() != b.left().type()
375 || a.right().type() != b.right().type()
376 || a.top().type() != b.top().type()
377 || a.bottom().type() != b.bottom().type())
380 // Only one unit can be non-auto in the horizontal direction and
381 // in the vertical direction. Otherwise the adjustment of values
382 // is changing the size of the box.
383 if (!a.left().isIntrinsicOrAuto() && !a.right().isIntrinsicOrAuto())
385 if (!a.top().isIntrinsicOrAuto() && !a.bottom().isIntrinsicOrAuto())
387 // If our width is auto and left or right is specified then this
388 // is not just a movement - we need to resize to our container.
389 if ((!a.left().isIntrinsicOrAuto() || !a.right().isIntrinsicOrAuto()) && width.isIntrinsicOrAuto())
392 // One of the units is fixed or percent in both directions and stayed
393 // that way in the new style. Therefore all we are doing is moving.
397 inline bool RenderStyle::changeAffectsVisualOverflow(const RenderStyle& other) const
399 if (rareNonInheritedData.get() != other.rareNonInheritedData.get()
400 && !rareNonInheritedData->shadowDataEquivalent(*other.rareNonInheritedData.get()))
403 if (rareInheritedData.get() != other.rareInheritedData.get()
404 && !rareInheritedData->shadowDataEquivalent(*other.rareInheritedData.get()))
407 if (inherited_flags._text_decorations != other.inherited_flags._text_decorations
408 || visual->textDecoration != other.visual->textDecoration
409 || rareNonInheritedData->m_textDecorationStyle != other.rareNonInheritedData->m_textDecorationStyle) {
410 // Underlines are always drawn outside of their textbox bounds when text-underline-position: under;
411 // is specified. We can take an early out here.
412 if (textUnderlinePosition() == TextUnderlinePositionUnder
413 || other.textUnderlinePosition() == TextUnderlinePositionUnder)
415 return visualOverflowForDecorations(*this, nullptr) != visualOverflowForDecorations(other, nullptr);
421 bool RenderStyle::changeRequiresLayout(const RenderStyle& other, unsigned& changedContextSensitiveProperties) const
423 if (m_box->width() != other.m_box->width()
424 || m_box->minWidth() != other.m_box->minWidth()
425 || m_box->maxWidth() != other.m_box->maxWidth()
426 || m_box->height() != other.m_box->height()
427 || m_box->minHeight() != other.m_box->minHeight()
428 || m_box->maxHeight() != other.m_box->maxHeight())
431 if (m_box->verticalAlign() != other.m_box->verticalAlign() || noninherited_flags.verticalAlign() != other.noninherited_flags.verticalAlign())
434 if (m_box->boxSizing() != other.m_box->boxSizing())
437 if (surround->margin != other.surround->margin)
440 if (surround->padding != other.surround->padding)
443 // FIXME: We should add an optimized form of layout that just recomputes visual overflow.
444 if (changeAffectsVisualOverflow(other))
447 if (rareNonInheritedData.get() != other.rareNonInheritedData.get()) {
448 if (rareNonInheritedData->m_appearance != other.rareNonInheritedData->m_appearance
449 || rareNonInheritedData->marginBeforeCollapse != other.rareNonInheritedData->marginBeforeCollapse
450 || rareNonInheritedData->marginAfterCollapse != other.rareNonInheritedData->marginAfterCollapse
451 || rareNonInheritedData->lineClamp != other.rareNonInheritedData->lineClamp
452 || rareNonInheritedData->m_initialLetter != other.rareNonInheritedData->m_initialLetter
453 || rareNonInheritedData->textOverflow != other.rareNonInheritedData->textOverflow)
456 if (rareNonInheritedData->m_regionFragment != other.rareNonInheritedData->m_regionFragment)
459 #if ENABLE(CSS_SHAPES)
460 if (rareNonInheritedData->m_shapeMargin != other.rareNonInheritedData->m_shapeMargin)
464 if (rareNonInheritedData->m_deprecatedFlexibleBox.get() != other.rareNonInheritedData->m_deprecatedFlexibleBox.get()
465 && *rareNonInheritedData->m_deprecatedFlexibleBox.get() != *other.rareNonInheritedData->m_deprecatedFlexibleBox.get())
468 if (rareNonInheritedData->m_flexibleBox.get() != other.rareNonInheritedData->m_flexibleBox.get()
469 && *rareNonInheritedData->m_flexibleBox.get() != *other.rareNonInheritedData->m_flexibleBox.get())
471 if (rareNonInheritedData->m_order != other.rareNonInheritedData->m_order
472 || rareNonInheritedData->m_alignContent != other.rareNonInheritedData->m_alignContent
473 || rareNonInheritedData->m_alignItems != other.rareNonInheritedData->m_alignItems
474 || rareNonInheritedData->m_alignSelf != other.rareNonInheritedData->m_alignSelf
475 || rareNonInheritedData->m_justifyContent != other.rareNonInheritedData->m_justifyContent)
478 if (!rareNonInheritedData->reflectionDataEquivalent(*other.rareNonInheritedData.get()))
481 if (rareNonInheritedData->m_multiCol.get() != other.rareNonInheritedData->m_multiCol.get()
482 && *rareNonInheritedData->m_multiCol.get() != *other.rareNonInheritedData->m_multiCol.get())
485 if (rareNonInheritedData->m_transform != other.rareNonInheritedData->m_transform) {
486 if (rareNonInheritedData->m_transform->hasTransform() != other.rareNonInheritedData->m_transform->hasTransform())
488 if (*rareNonInheritedData->m_transform != *other.rareNonInheritedData->m_transform) {
489 changedContextSensitiveProperties |= ContextSensitivePropertyTransform;
490 // Don't return; keep looking for another change
494 #if ENABLE(CSS_GRID_LAYOUT)
495 if (rareNonInheritedData->m_grid.get() != other.rareNonInheritedData->m_grid.get()
496 || rareNonInheritedData->m_gridItem.get() != other.rareNonInheritedData->m_gridItem.get())
500 #if ENABLE(DASHBOARD_SUPPORT)
501 // If regions change, trigger a relayout to re-calc regions.
502 if (rareNonInheritedData->m_dashboardRegions != other.rareNonInheritedData->m_dashboardRegions)
507 if (rareInheritedData.get() != other.rareInheritedData.get()) {
508 if (rareInheritedData->indent != other.rareInheritedData->indent
509 #if ENABLE(CSS3_TEXT)
510 || rareInheritedData->m_textAlignLast != other.rareInheritedData->m_textAlignLast
511 || rareInheritedData->m_textJustify != other.rareInheritedData->m_textJustify
512 || rareInheritedData->m_textIndentLine != other.rareInheritedData->m_textIndentLine
514 || rareInheritedData->m_effectiveZoom != other.rareInheritedData->m_effectiveZoom
515 #if ENABLE(IOS_TEXT_AUTOSIZING)
516 || rareInheritedData->textSizeAdjust != other.rareInheritedData->textSizeAdjust
518 || rareInheritedData->wordBreak != other.rareInheritedData->wordBreak
519 || rareInheritedData->overflowWrap != other.rareInheritedData->overflowWrap
520 || rareInheritedData->nbspMode != other.rareInheritedData->nbspMode
521 || rareInheritedData->lineBreak != other.rareInheritedData->lineBreak
522 || rareInheritedData->textSecurity != other.rareInheritedData->textSecurity
523 || rareInheritedData->hyphens != other.rareInheritedData->hyphens
524 || rareInheritedData->hyphenationLimitBefore != other.rareInheritedData->hyphenationLimitBefore
525 || rareInheritedData->hyphenationLimitAfter != other.rareInheritedData->hyphenationLimitAfter
526 || rareInheritedData->hyphenationString != other.rareInheritedData->hyphenationString
527 || rareInheritedData->locale != other.rareInheritedData->locale
528 || rareInheritedData->m_rubyPosition != other.rareInheritedData->m_rubyPosition
529 || rareInheritedData->textEmphasisMark != other.rareInheritedData->textEmphasisMark
530 || rareInheritedData->textEmphasisPosition != other.rareInheritedData->textEmphasisPosition
531 || rareInheritedData->textEmphasisCustomMark != other.rareInheritedData->textEmphasisCustomMark
532 || rareInheritedData->m_textOrientation != other.rareInheritedData->m_textOrientation
533 || rareInheritedData->m_tabSize != other.rareInheritedData->m_tabSize
534 || rareInheritedData->m_lineBoxContain != other.rareInheritedData->m_lineBoxContain
535 || rareInheritedData->m_lineGrid != other.rareInheritedData->m_lineGrid
536 #if ENABLE(CSS_IMAGE_ORIENTATION)
537 || rareInheritedData->m_imageOrientation != other.rareInheritedData->m_imageOrientation
539 #if ENABLE(CSS_IMAGE_RESOLUTION)
540 || rareInheritedData->m_imageResolutionSource != other.rareInheritedData->m_imageResolutionSource
541 || rareInheritedData->m_imageResolutionSnap != other.rareInheritedData->m_imageResolutionSnap
542 || rareInheritedData->m_imageResolution != other.rareInheritedData->m_imageResolution
544 || rareInheritedData->m_lineSnap != other.rareInheritedData->m_lineSnap
545 || rareInheritedData->m_lineAlign != other.rareInheritedData->m_lineAlign
546 #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
547 || rareInheritedData->useTouchOverflowScrolling != other.rareInheritedData->useTouchOverflowScrolling
549 || rareInheritedData->listStyleImage != other.rareInheritedData->listStyleImage)
552 if (textStrokeWidth() != other.textStrokeWidth())
556 #if ENABLE(TEXT_AUTOSIZING)
557 if (visual->m_textAutosizingMultiplier != other.visual->m_textAutosizingMultiplier)
561 if (inherited->line_height != other.inherited->line_height
562 #if ENABLE(IOS_TEXT_AUTOSIZING)
563 || inherited->specifiedLineHeight != other.inherited->specifiedLineHeight
565 || inherited->fontCascade != other.inherited->fontCascade
566 || inherited->horizontal_border_spacing != other.inherited->horizontal_border_spacing
567 || inherited->vertical_border_spacing != other.inherited->vertical_border_spacing
568 || inherited_flags._box_direction != other.inherited_flags._box_direction
569 || inherited_flags.m_rtlOrdering != other.inherited_flags.m_rtlOrdering
570 || noninherited_flags.position() != other.noninherited_flags.position()
571 || noninherited_flags.floating() != other.noninherited_flags.floating()
572 || noninherited_flags.originalDisplay() != other.noninherited_flags.originalDisplay())
576 if ((noninherited_flags.effectiveDisplay()) >= TABLE) {
577 if (inherited_flags._border_collapse != other.inherited_flags._border_collapse
578 || inherited_flags._empty_cells != other.inherited_flags._empty_cells
579 || inherited_flags._caption_side != other.inherited_flags._caption_side
580 || noninherited_flags.tableLayout() != other.noninherited_flags.tableLayout())
583 // In the collapsing border model, 'hidden' suppresses other borders, while 'none'
584 // does not, so these style differences can be width differences.
585 if (inherited_flags._border_collapse
586 && ((borderTopStyle() == BHIDDEN && other.borderTopStyle() == BNONE)
587 || (borderTopStyle() == BNONE && other.borderTopStyle() == BHIDDEN)
588 || (borderBottomStyle() == BHIDDEN && other.borderBottomStyle() == BNONE)
589 || (borderBottomStyle() == BNONE && other.borderBottomStyle() == BHIDDEN)
590 || (borderLeftStyle() == BHIDDEN && other.borderLeftStyle() == BNONE)
591 || (borderLeftStyle() == BNONE && other.borderLeftStyle() == BHIDDEN)
592 || (borderRightStyle() == BHIDDEN && other.borderRightStyle() == BNONE)
593 || (borderRightStyle() == BNONE && other.borderRightStyle() == BHIDDEN)))
597 if (noninherited_flags.effectiveDisplay() == LIST_ITEM) {
598 if (inherited_flags._list_style_type != other.inherited_flags._list_style_type
599 || inherited_flags._list_style_position != other.inherited_flags._list_style_position)
603 if (inherited_flags._text_align != other.inherited_flags._text_align
604 || inherited_flags._text_transform != other.inherited_flags._text_transform
605 || inherited_flags._direction != other.inherited_flags._direction
606 || inherited_flags._white_space != other.inherited_flags._white_space
607 || noninherited_flags.clear() != other.noninherited_flags.clear()
608 || noninherited_flags.unicodeBidi() != other.noninherited_flags.unicodeBidi())
611 // Check block flow direction.
612 if (inherited_flags.m_writingMode != other.inherited_flags.m_writingMode)
615 // Check text combine mode.
616 if (rareNonInheritedData->m_textCombine != other.rareNonInheritedData->m_textCombine)
619 // Overflow returns a layout hint.
620 if (noninherited_flags.overflowX() != other.noninherited_flags.overflowX()
621 || noninherited_flags.overflowY() != other.noninherited_flags.overflowY())
624 // If our border widths change, then we need to layout. Other changes to borders
625 // only necessitate a repaint.
626 if (borderLeftWidth() != other.borderLeftWidth()
627 || borderTopWidth() != other.borderTopWidth()
628 || borderBottomWidth() != other.borderBottomWidth()
629 || borderRightWidth() != other.borderRightWidth())
632 // If the counter directives change, trigger a relayout to re-calculate counter values and rebuild the counter node tree.
633 const CounterDirectiveMap* mapA = rareNonInheritedData->m_counterDirectives.get();
634 const CounterDirectiveMap* mapB = other.rareNonInheritedData->m_counterDirectives.get();
635 if (!(mapA == mapB || (mapA && mapB && *mapA == *mapB)))
638 if ((visibility() == COLLAPSE) != (other.visibility() == COLLAPSE))
641 if (rareNonInheritedData->hasOpacity() != other.rareNonInheritedData->hasOpacity()) {
642 // FIXME: We would like to use SimplifiedLayout here, but we can't quite do that yet.
643 // We need to make sure SimplifiedLayout can operate correctly on RenderInlines (we will need
644 // to add a selfNeedsSimplifiedLayout bit in order to not get confused and taint every line).
645 // In addition we need to solve the floating object issue when layers come and go. Right now
646 // a full layout is necessary to keep floating object lists sane.
650 if (rareNonInheritedData->hasFilters() != other.rareNonInheritedData->hasFilters())
653 #if ENABLE(FILTERS_LEVEL_2)
654 if (rareNonInheritedData->hasBackdropFilters() != other.rareNonInheritedData->hasBackdropFilters())
658 const QuotesData* quotesDataA = rareInheritedData->quotes.get();
659 const QuotesData* quotesDataB = other.rareInheritedData->quotes.get();
660 if (!(quotesDataA == quotesDataB || (quotesDataA && quotesDataB && *quotesDataA == *quotesDataB)))
663 if (position() != StaticPosition) {
664 if (surround->offset != other.surround->offset) {
665 // FIXME: We would like to use SimplifiedLayout for relative positioning, but we can't quite do that yet.
666 // We need to make sure SimplifiedLayout can operate correctly on RenderInlines (we will need
667 // to add a selfNeedsSimplifiedLayout bit in order to not get confused and taint every line).
668 if (position() != AbsolutePosition)
671 // Optimize for the case where a positioned layer is moving but not changing size.
672 if (!positionChangeIsMovementOnly(surround->offset, other.surround->offset, m_box->width()))
680 bool RenderStyle::changeRequiresPositionedLayoutOnly(const RenderStyle& other, unsigned&) const
682 if (position() == StaticPosition)
685 if (surround->offset != other.surround->offset) {
686 // Optimize for the case where a positioned layer is moving but not changing size.
687 if (position() == AbsolutePosition && positionChangeIsMovementOnly(surround->offset, other.surround->offset, m_box->width()))
694 bool RenderStyle::changeRequiresLayerRepaint(const RenderStyle& other, unsigned& changedContextSensitiveProperties) const
696 // StyleResolver has ensured that zIndex is non-auto only if it's applicable.
697 if (m_box->zIndex() != other.m_box->zIndex() || m_box->hasAutoZIndex() != other.m_box->hasAutoZIndex())
700 if (position() != StaticPosition) {
701 if (visual->clip != other.visual->clip || visual->hasClip != other.visual->hasClip) {
702 changedContextSensitiveProperties |= ContextSensitivePropertyClipRect;
707 #if ENABLE(CSS_COMPOSITING)
708 if (rareNonInheritedData->m_effectiveBlendMode != other.rareNonInheritedData->m_effectiveBlendMode)
712 if (rareNonInheritedData->opacity != other.rareNonInheritedData->opacity) {
713 changedContextSensitiveProperties |= ContextSensitivePropertyOpacity;
714 // Don't return; keep looking for another change.
717 if (rareNonInheritedData->m_filter.get() != other.rareNonInheritedData->m_filter.get()
718 && *rareNonInheritedData->m_filter.get() != *other.rareNonInheritedData->m_filter.get()) {
719 changedContextSensitiveProperties |= ContextSensitivePropertyFilter;
720 // Don't return; keep looking for another change.
723 if (rareNonInheritedData->m_mask != other.rareNonInheritedData->m_mask
724 || rareNonInheritedData->m_maskBoxImage != other.rareNonInheritedData->m_maskBoxImage)
730 bool RenderStyle::changeRequiresRepaint(const RenderStyle& other, unsigned& changedContextSensitiveProperties) const
732 if (inherited_flags._visibility != other.inherited_flags._visibility
733 || inherited_flags.m_printColorAdjust != other.inherited_flags.m_printColorAdjust
734 || inherited_flags._insideLink != other.inherited_flags._insideLink
735 || inherited_flags._insideDefaultButton != other.inherited_flags._insideDefaultButton
736 || surround->border != other.surround->border
737 || !m_background->isEquivalentForPainting(*other.m_background)
738 || rareInheritedData->userModify != other.rareInheritedData->userModify
739 || rareInheritedData->userSelect != other.rareInheritedData->userSelect
740 || rareNonInheritedData->userDrag != other.rareNonInheritedData->userDrag
741 || rareNonInheritedData->m_borderFit != other.rareNonInheritedData->m_borderFit
742 || rareNonInheritedData->m_objectFit != other.rareNonInheritedData->m_objectFit
743 || rareInheritedData->m_imageRendering != other.rareInheritedData->m_imageRendering)
746 #if ENABLE(CSS_SHAPES)
747 if (rareNonInheritedData->m_shapeOutside != other.rareNonInheritedData->m_shapeOutside)
751 // FIXME: this should probably be moved to changeRequiresLayerRepaint().
752 if (rareNonInheritedData->m_clipPath != other.rareNonInheritedData->m_clipPath) {
753 changedContextSensitiveProperties |= ContextSensitivePropertyClipPath;
754 // Don't return; keep looking for another change.
760 bool RenderStyle::changeRequiresRepaintIfTextOrBorderOrOutline(const RenderStyle& other, unsigned&) const
762 if (inherited->color != other.inherited->color
763 || inherited_flags._text_decorations != other.inherited_flags._text_decorations
764 || visual->textDecoration != other.visual->textDecoration
765 || rareNonInheritedData->m_textDecorationStyle != other.rareNonInheritedData->m_textDecorationStyle
766 || rareNonInheritedData->m_textDecorationColor != other.rareNonInheritedData->m_textDecorationColor
767 || rareInheritedData->m_textDecorationSkip != other.rareInheritedData->m_textDecorationSkip
768 || rareInheritedData->textFillColor != other.rareInheritedData->textFillColor
769 || rareInheritedData->textStrokeColor != other.rareInheritedData->textStrokeColor
770 || rareInheritedData->textEmphasisColor != other.rareInheritedData->textEmphasisColor
771 || rareInheritedData->textEmphasisFill != other.rareInheritedData->textEmphasisFill)
777 bool RenderStyle::changeRequiresRecompositeLayer(const RenderStyle& other, unsigned&) const
779 if (rareNonInheritedData.get() != other.rareNonInheritedData.get()) {
780 if (rareNonInheritedData->m_transformStyle3D != other.rareNonInheritedData->m_transformStyle3D
781 || rareNonInheritedData->m_backfaceVisibility != other.rareNonInheritedData->m_backfaceVisibility
782 || rareNonInheritedData->m_perspective != other.rareNonInheritedData->m_perspective
783 || rareNonInheritedData->m_perspectiveOriginX != other.rareNonInheritedData->m_perspectiveOriginX
784 || rareNonInheritedData->m_perspectiveOriginY != other.rareNonInheritedData->m_perspectiveOriginY)
791 StyleDifference RenderStyle::diff(const RenderStyle& other, unsigned& changedContextSensitiveProperties) const
793 changedContextSensitiveProperties = ContextSensitivePropertyNone;
795 StyleDifference svgChange = StyleDifferenceEqual;
796 if (m_svgStyle != other.m_svgStyle) {
797 svgChange = m_svgStyle->diff(other.m_svgStyle.get());
798 if (svgChange == StyleDifferenceLayout)
802 if (changeRequiresLayout(other, changedContextSensitiveProperties))
803 return StyleDifferenceLayout;
805 // SVGRenderStyle::diff() might have returned StyleDifferenceRepaint, eg. if fill changes.
806 // If eg. the font-size changed at the same time, we're not allowed to return StyleDifferenceRepaint,
807 // but have to return StyleDifferenceLayout, that's why this if branch comes after all branches
808 // that are relevant for SVG and might return StyleDifferenceLayout.
809 if (svgChange != StyleDifferenceEqual)
812 if (changeRequiresPositionedLayoutOnly(other, changedContextSensitiveProperties))
813 return StyleDifferenceLayoutPositionedMovementOnly;
815 if (changeRequiresLayerRepaint(other, changedContextSensitiveProperties))
816 return StyleDifferenceRepaintLayer;
818 if (changeRequiresRepaint(other, changedContextSensitiveProperties))
819 return StyleDifferenceRepaint;
821 if (changeRequiresRecompositeLayer(other, changedContextSensitiveProperties))
822 return StyleDifferenceRecompositeLayer;
824 if (changeRequiresRepaintIfTextOrBorderOrOutline(other, changedContextSensitiveProperties))
825 return StyleDifferenceRepaintIfTextOrBorderOrOutline;
827 // Cursors are not checked, since they will be set appropriately in response to mouse events,
828 // so they don't need to cause any repaint or layout.
830 // Animations don't need to be checked either. We always set the new style on the RenderObject, so we will get a chance to fire off
831 // the resulting transition properly.
832 return StyleDifferenceEqual;
835 bool RenderStyle::diffRequiresLayerRepaint(const RenderStyle& style, bool isComposited) const
837 unsigned changedContextSensitiveProperties = 0;
839 if (changeRequiresRepaint(style, changedContextSensitiveProperties))
842 if (isComposited && changeRequiresLayerRepaint(style, changedContextSensitiveProperties))
843 return changedContextSensitiveProperties & ContextSensitivePropertyClipRect;
848 void RenderStyle::setMaskImage(const Vector<RefPtr<MaskImageOperation>>& ops)
850 FillLayer* curLayer = &rareNonInheritedData.access()->m_mask;
852 curLayer->setMaskImage(nullptr);
853 curLayer = curLayer->next();
856 curLayer = &rareNonInheritedData.access()->m_mask;
857 FillLayer* prevLayer = nullptr;
858 for (auto& maskImage : ops) {
860 prevLayer->setNext(std::make_unique<FillLayer>(MaskFillLayer));
861 curLayer = prevLayer->next();
864 curLayer->setMaskImage(maskImage);
865 prevLayer = curLayer;
866 curLayer = curLayer->next();
870 void RenderStyle::setClip(Length top, Length right, Length bottom, Length left)
872 StyleVisualData* data = visual.access();
873 data->clip.m_top = top;
874 data->clip.m_right = right;
875 data->clip.m_bottom = bottom;
876 data->clip.m_left = left;
879 void RenderStyle::addCursor(PassRefPtr<StyleImage> image, const IntPoint& hotSpot)
881 if (!rareInheritedData.access()->cursorData)
882 rareInheritedData.access()->cursorData = CursorList::create();
883 rareInheritedData.access()->cursorData->append(CursorData(image, hotSpot));
886 void RenderStyle::setCursorList(PassRefPtr<CursorList> other)
888 rareInheritedData.access()->cursorData = other;
891 void RenderStyle::setQuotes(PassRefPtr<QuotesData> q)
893 if (rareInheritedData->quotes == q || (rareInheritedData->quotes && q && *rareInheritedData->quotes == *q))
896 rareInheritedData.access()->quotes = q;
899 void RenderStyle::clearCursorList()
901 if (rareInheritedData->cursorData)
902 rareInheritedData.access()->cursorData = 0;
905 void RenderStyle::clearContent()
907 if (rareNonInheritedData->m_content)
908 rareNonInheritedData.access()->m_content = nullptr;
911 void RenderStyle::appendContent(std::unique_ptr<ContentData> contentData)
913 auto& content = rareNonInheritedData.access()->m_content;
914 ContentData* lastContent = content.get();
915 while (lastContent && lastContent->next())
916 lastContent = lastContent->next();
919 lastContent->setNext(WTF::move(contentData));
921 content = WTF::move(contentData);
924 void RenderStyle::setContent(PassRefPtr<StyleImage> image, bool add)
930 appendContent(std::make_unique<ImageContentData>(image));
934 rareNonInheritedData.access()->m_content = std::make_unique<ImageContentData>(image);
935 if (!rareNonInheritedData.access()->m_altText.isNull())
936 rareNonInheritedData.access()->m_content->setAltText(rareNonInheritedData.access()->m_altText);
939 void RenderStyle::setContent(const String& string, bool add)
941 auto& content = rareNonInheritedData.access()->m_content;
943 ContentData* lastContent = content.get();
944 while (lastContent && lastContent->next())
945 lastContent = lastContent->next();
948 // We attempt to merge with the last ContentData if possible.
949 if (is<TextContentData>(*lastContent)) {
950 TextContentData& textContent = downcast<TextContentData>(*lastContent);
951 textContent.setText(textContent.text() + string);
953 lastContent->setNext(std::make_unique<TextContentData>(string));
955 if (!rareNonInheritedData.access()->m_altText.isNull())
956 lastContent->setAltText(rareNonInheritedData.access()->m_altText);
961 content = std::make_unique<TextContentData>(string);
962 if (!rareNonInheritedData.access()->m_altText.isNull())
963 content->setAltText(rareNonInheritedData.access()->m_altText);
966 void RenderStyle::setContent(std::unique_ptr<CounterContent> counter, bool add)
972 appendContent(std::make_unique<CounterContentData>(WTF::move(counter)));
976 rareNonInheritedData.access()->m_content = std::make_unique<CounterContentData>(WTF::move(counter));
979 void RenderStyle::setContent(QuoteType quote, bool add)
982 appendContent(std::make_unique<QuoteContentData>(quote));
986 rareNonInheritedData.access()->m_content = std::make_unique<QuoteContentData>(quote);
989 void RenderStyle::setContentAltText(const String& string)
991 rareNonInheritedData.access()->m_altText = string;
993 if (rareNonInheritedData.access()->m_content)
994 rareNonInheritedData.access()->m_content->setAltText(string);
997 const String& RenderStyle::contentAltText() const
999 return rareNonInheritedData->m_altText;
1002 // FIXME: use affectedByTransformOrigin().
1003 static inline bool requireTransformOrigin(const Vector<RefPtr<TransformOperation>>& transformOperations, RenderStyle::ApplyTransformOrigin applyOrigin)
1005 // transform-origin brackets the transform with translate operations.
1006 // Optimize for the case where the only transform is a translation, since the transform-origin is irrelevant
1008 if (applyOrigin != RenderStyle::IncludeTransformOrigin)
1011 for (auto& operation : transformOperations) {
1012 TransformOperation::OperationType type = operation->type();
1013 if (type != TransformOperation::TRANSLATE_X
1014 && type != TransformOperation::TRANSLATE_Y
1015 && type != TransformOperation::TRANSLATE
1016 && type != TransformOperation::TRANSLATE_Z
1017 && type != TransformOperation::TRANSLATE_3D)
1024 void RenderStyle::applyTransform(TransformationMatrix& transform, const FloatRect& boundingBox, ApplyTransformOrigin applyOrigin) const
1026 auto& operations = rareNonInheritedData->m_transform->m_operations.operations();
1027 bool applyTransformOrigin = requireTransformOrigin(operations, applyOrigin);
1029 float offsetX = transformOriginX().isPercentNotCalculated() ? boundingBox.x() : 0;
1030 float offsetY = transformOriginY().isPercentNotCalculated() ? boundingBox.y() : 0;
1032 if (applyTransformOrigin) {
1033 transform.translate3d(floatValueForLength(transformOriginX(), boundingBox.width()) + offsetX,
1034 floatValueForLength(transformOriginY(), boundingBox.height()) + offsetY,
1035 transformOriginZ());
1038 for (auto& operation : operations)
1039 operation->apply(transform, boundingBox.size());
1041 if (applyTransformOrigin) {
1042 transform.translate3d(-floatValueForLength(transformOriginX(), boundingBox.width()) - offsetX,
1043 -floatValueForLength(transformOriginY(), boundingBox.height()) - offsetY,
1044 -transformOriginZ());
1048 void RenderStyle::setPageScaleTransform(float scale)
1052 TransformOperations transform;
1053 transform.operations().append(ScaleTransformOperation::create(scale, scale, ScaleTransformOperation::SCALE));
1054 setTransform(transform);
1055 setTransformOriginX(Length(0, Fixed));
1056 setTransformOriginY(Length(0, Fixed));
1059 void RenderStyle::setTextShadow(std::unique_ptr<ShadowData> shadowData, bool add)
1061 ASSERT(!shadowData || (!shadowData->spread() && shadowData->style() == Normal));
1063 StyleRareInheritedData* rareData = rareInheritedData.access();
1065 rareData->textShadow = WTF::move(shadowData);
1069 shadowData->setNext(WTF::move(rareData->textShadow));
1070 rareData->textShadow = WTF::move(shadowData);
1073 void RenderStyle::setBoxShadow(std::unique_ptr<ShadowData> shadowData, bool add)
1075 StyleRareNonInheritedData* rareData = rareNonInheritedData.access();
1077 rareData->m_boxShadow = WTF::move(shadowData);
1081 shadowData->setNext(WTF::move(rareData->m_boxShadow));
1082 rareData->m_boxShadow = WTF::move(shadowData);
1085 static RoundedRect::Radii calcRadiiFor(const BorderData& border, const LayoutSize& size)
1087 return RoundedRect::Radii(
1088 LayoutSize(valueForLength(border.topLeft().width(), size.width()),
1089 valueForLength(border.topLeft().height(), size.height())),
1090 LayoutSize(valueForLength(border.topRight().width(), size.width()),
1091 valueForLength(border.topRight().height(), size.height())),
1092 LayoutSize(valueForLength(border.bottomLeft().width(), size.width()),
1093 valueForLength(border.bottomLeft().height(), size.height())),
1094 LayoutSize(valueForLength(border.bottomRight().width(), size.width()),
1095 valueForLength(border.bottomRight().height(), size.height())));
1098 StyleImage* RenderStyle::listStyleImage() const { return rareInheritedData->listStyleImage.get(); }
1099 void RenderStyle::setListStyleImage(PassRefPtr<StyleImage> v)
1101 if (rareInheritedData->listStyleImage != v)
1102 rareInheritedData.access()->listStyleImage = v;
1105 Color RenderStyle::color() const { return inherited->color; }
1106 Color RenderStyle::visitedLinkColor() const { return inherited->visitedLinkColor; }
1107 void RenderStyle::setColor(const Color& v) { SET_VAR(inherited, color, v); }
1108 void RenderStyle::setVisitedLinkColor(const Color& v) { SET_VAR(inherited, visitedLinkColor, v); }
1110 short RenderStyle::horizontalBorderSpacing() const { return inherited->horizontal_border_spacing; }
1111 short RenderStyle::verticalBorderSpacing() const { return inherited->vertical_border_spacing; }
1112 void RenderStyle::setHorizontalBorderSpacing(short v) { SET_VAR(inherited, horizontal_border_spacing, v); }
1113 void RenderStyle::setVerticalBorderSpacing(short v) { SET_VAR(inherited, vertical_border_spacing, v); }
1115 RoundedRect RenderStyle::getRoundedBorderFor(const LayoutRect& borderRect, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const
1117 RoundedRect roundedRect(borderRect);
1118 if (hasBorderRadius()) {
1119 RoundedRect::Radii radii = calcRadiiFor(surround->border, borderRect.size());
1120 radii.scale(calcBorderRadiiConstraintScaleFor(borderRect, radii));
1121 roundedRect.includeLogicalEdges(radii, isHorizontalWritingMode(), includeLogicalLeftEdge, includeLogicalRightEdge);
1126 RoundedRect RenderStyle::getRoundedInnerBorderFor(const LayoutRect& borderRect, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const
1128 bool horizontal = isHorizontalWritingMode();
1130 LayoutUnit leftWidth = (!horizontal || includeLogicalLeftEdge) ? borderLeftWidth() : 0;
1131 LayoutUnit rightWidth = (!horizontal || includeLogicalRightEdge) ? borderRightWidth() : 0;
1132 LayoutUnit topWidth = (horizontal || includeLogicalLeftEdge) ? borderTopWidth() : 0;
1133 LayoutUnit bottomWidth = (horizontal || includeLogicalRightEdge) ? borderBottomWidth() : 0;
1135 return getRoundedInnerBorderFor(borderRect, topWidth, bottomWidth, leftWidth, rightWidth, includeLogicalLeftEdge, includeLogicalRightEdge);
1138 RoundedRect RenderStyle::getRoundedInnerBorderFor(const LayoutRect& borderRect, LayoutUnit topWidth, LayoutUnit bottomWidth,
1139 LayoutUnit leftWidth, LayoutUnit rightWidth, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const
1141 LayoutRect innerRect(borderRect.x() + leftWidth,
1142 borderRect.y() + topWidth,
1143 borderRect.width() - leftWidth - rightWidth,
1144 borderRect.height() - topWidth - bottomWidth);
1146 RoundedRect roundedRect(innerRect);
1148 if (hasBorderRadius()) {
1149 RoundedRect::Radii radii = getRoundedBorderFor(borderRect).radii();
1150 radii.shrink(topWidth, bottomWidth, leftWidth, rightWidth);
1151 roundedRect.includeLogicalEdges(radii, isHorizontalWritingMode(), includeLogicalLeftEdge, includeLogicalRightEdge);
1156 static bool allLayersAreFixed(const FillLayer* layer)
1158 bool allFixed = true;
1160 for (const FillLayer* currLayer = layer; currLayer; currLayer = currLayer->next())
1161 allFixed &= (currLayer->image() && currLayer->attachment() == FixedBackgroundAttachment);
1163 return layer && allFixed;
1166 bool RenderStyle::hasEntirelyFixedBackground() const
1168 return allLayersAreFixed(backgroundLayers());
1171 const CounterDirectiveMap* RenderStyle::counterDirectives() const
1173 return rareNonInheritedData->m_counterDirectives.get();
1176 CounterDirectiveMap& RenderStyle::accessCounterDirectives()
1178 auto& map = rareNonInheritedData.access()->m_counterDirectives;
1180 map = std::make_unique<CounterDirectiveMap>();
1184 const CounterDirectives RenderStyle::getCounterDirectives(const AtomicString& identifier) const
1186 if (const CounterDirectiveMap* directives = counterDirectives())
1187 return directives->get(identifier);
1188 return CounterDirectives();
1191 const AtomicString& RenderStyle::hyphenString() const
1193 ASSERT(hyphens() != HyphensNone);
1195 const AtomicString& hyphenationString = rareInheritedData.get()->hyphenationString;
1196 if (!hyphenationString.isNull())
1197 return hyphenationString;
1199 // FIXME: This should depend on locale.
1200 DEPRECATED_DEFINE_STATIC_LOCAL(AtomicString, hyphenMinusString, (&hyphenMinus, 1));
1201 DEPRECATED_DEFINE_STATIC_LOCAL(AtomicString, hyphenString, (&hyphen, 1));
1202 return fontCascade().primaryFont().glyphForCharacter(hyphen) ? hyphenString : hyphenMinusString;
1205 const AtomicString& RenderStyle::textEmphasisMarkString() const
1207 switch (textEmphasisMark()) {
1208 case TextEmphasisMarkNone:
1210 case TextEmphasisMarkCustom:
1211 return textEmphasisCustomMark();
1212 case TextEmphasisMarkDot: {
1213 DEPRECATED_DEFINE_STATIC_LOCAL(AtomicString, filledDotString, (&bullet, 1));
1214 DEPRECATED_DEFINE_STATIC_LOCAL(AtomicString, openDotString, (&whiteBullet, 1));
1215 return textEmphasisFill() == TextEmphasisFillFilled ? filledDotString : openDotString;
1217 case TextEmphasisMarkCircle: {
1218 DEPRECATED_DEFINE_STATIC_LOCAL(AtomicString, filledCircleString, (&blackCircle, 1));
1219 DEPRECATED_DEFINE_STATIC_LOCAL(AtomicString, openCircleString, (&whiteCircle, 1));
1220 return textEmphasisFill() == TextEmphasisFillFilled ? filledCircleString : openCircleString;
1222 case TextEmphasisMarkDoubleCircle: {
1223 DEPRECATED_DEFINE_STATIC_LOCAL(AtomicString, filledDoubleCircleString, (&fisheye, 1));
1224 DEPRECATED_DEFINE_STATIC_LOCAL(AtomicString, openDoubleCircleString, (&bullseye, 1));
1225 return textEmphasisFill() == TextEmphasisFillFilled ? filledDoubleCircleString : openDoubleCircleString;
1227 case TextEmphasisMarkTriangle: {
1228 DEPRECATED_DEFINE_STATIC_LOCAL(AtomicString, filledTriangleString, (&blackUpPointingTriangle, 1));
1229 DEPRECATED_DEFINE_STATIC_LOCAL(AtomicString, openTriangleString, (&whiteUpPointingTriangle, 1));
1230 return textEmphasisFill() == TextEmphasisFillFilled ? filledTriangleString : openTriangleString;
1232 case TextEmphasisMarkSesame: {
1233 DEPRECATED_DEFINE_STATIC_LOCAL(AtomicString, filledSesameString, (&sesameDot, 1));
1234 DEPRECATED_DEFINE_STATIC_LOCAL(AtomicString, openSesameString, (&whiteSesameDot, 1));
1235 return textEmphasisFill() == TextEmphasisFillFilled ? filledSesameString : openSesameString;
1237 case TextEmphasisMarkAuto:
1238 ASSERT_NOT_REACHED();
1242 ASSERT_NOT_REACHED();
1246 #if ENABLE(DASHBOARD_SUPPORT)
1247 const Vector<StyleDashboardRegion>& RenderStyle::initialDashboardRegions()
1249 DEPRECATED_DEFINE_STATIC_LOCAL(Vector<StyleDashboardRegion>, emptyList, ());
1253 const Vector<StyleDashboardRegion>& RenderStyle::noneDashboardRegions()
1255 DEPRECATED_DEFINE_STATIC_LOCAL(Vector<StyleDashboardRegion>, noneList, ());
1256 static bool noneListInitialized = false;
1258 if (!noneListInitialized) {
1259 StyleDashboardRegion region;
1261 region.offset.m_top = Length();
1262 region.offset.m_right = Length();
1263 region.offset.m_bottom = Length();
1264 region.offset.m_left = Length();
1265 region.type = StyleDashboardRegion::None;
1266 noneList.append(region);
1267 noneListInitialized = true;
1273 void RenderStyle::adjustAnimations()
1275 AnimationList* animationList = rareNonInheritedData->m_animations.get();
1279 // Get rid of empty animations and anything beyond them
1280 for (size_t i = 0; i < animationList->size(); ++i) {
1281 if (animationList->animation(i).isEmpty()) {
1282 animationList->resize(i);
1287 if (animationList->isEmpty()) {
1292 // Repeat patterns into layers that don't have some properties set.
1293 animationList->fillUnsetProperties();
1296 void RenderStyle::adjustTransitions()
1298 AnimationList* transitionList = rareNonInheritedData->m_transitions.get();
1299 if (!transitionList)
1302 // Get rid of empty transitions and anything beyond them
1303 for (size_t i = 0; i < transitionList->size(); ++i) {
1304 if (transitionList->animation(i).isEmpty()) {
1305 transitionList->resize(i);
1310 if (transitionList->isEmpty()) {
1315 // Repeat patterns into layers that don't have some properties set.
1316 transitionList->fillUnsetProperties();
1318 // Make sure there are no duplicate properties. This is an O(n^2) algorithm
1319 // but the lists tend to be very short, so it is probably ok
1320 for (size_t i = 0; i < transitionList->size(); ++i) {
1321 for (size_t j = i+1; j < transitionList->size(); ++j) {
1322 if (transitionList->animation(i).property() == transitionList->animation(j).property()) {
1324 transitionList->remove(i);
1331 AnimationList& RenderStyle::ensureAnimations()
1333 if (!rareNonInheritedData.access()->m_animations)
1334 rareNonInheritedData.access()->m_animations = std::make_unique<AnimationList>();
1335 return *rareNonInheritedData->m_animations;
1338 AnimationList& RenderStyle::ensureTransitions()
1340 if (!rareNonInheritedData.access()->m_transitions)
1341 rareNonInheritedData.access()->m_transitions = std::make_unique<AnimationList>();
1342 return *rareNonInheritedData->m_transitions;
1345 const Animation* RenderStyle::transitionForProperty(CSSPropertyID property) const
1347 if (transitions()) {
1348 for (size_t i = 0; i < transitions()->size(); ++i) {
1349 const Animation& p = transitions()->animation(i);
1350 if (p.animationMode() == Animation::AnimateAll || p.property() == property) {
1358 const FontCascade& RenderStyle::fontCascade() const { return inherited->fontCascade; }
1359 const FontMetrics& RenderStyle::fontMetrics() const { return inherited->fontCascade.fontMetrics(); }
1360 const FontDescription& RenderStyle::fontDescription() const { return inherited->fontCascade.fontDescription(); }
1361 float RenderStyle::specifiedFontSize() const { return fontDescription().specifiedSize(); }
1362 float RenderStyle::computedFontSize() const { return fontDescription().computedSize(); }
1363 int RenderStyle::fontSize() const { return inherited->fontCascade.pixelSize(); }
1365 const Length& RenderStyle::wordSpacing() const { return rareInheritedData->wordSpacing; }
1366 float RenderStyle::letterSpacing() const { return inherited->fontCascade.letterSpacing(); }
1368 bool RenderStyle::setFontDescription(const FontDescription& v)
1370 if (inherited->fontCascade.fontDescription() != v) {
1371 inherited.access()->fontCascade = FontCascade(v, inherited->fontCascade.letterSpacing(), inherited->fontCascade.wordSpacing());
1377 #if ENABLE(IOS_TEXT_AUTOSIZING)
1378 const Length& RenderStyle::specifiedLineHeight() const { return inherited->specifiedLineHeight; }
1379 void RenderStyle::setSpecifiedLineHeight(Length v) { SET_VAR(inherited, specifiedLineHeight, v); }
1381 const Length& RenderStyle::specifiedLineHeight() const { return inherited->line_height; }
1384 Length RenderStyle::lineHeight() const
1386 const Length& lh = inherited->line_height;
1387 #if ENABLE(TEXT_AUTOSIZING)
1388 // Unlike fontDescription().computedSize() and hence fontSize(), this is
1389 // recalculated on demand as we only store the specified line height.
1390 // FIXME: Should consider scaling the fixed part of any calc expressions
1391 // too, though this involves messily poking into CalcExpressionLength.
1392 float multiplier = textAutosizingMultiplier();
1393 if (multiplier > 1 && lh.isFixed())
1394 return Length(TextAutosizer::computeAutosizedFontSize(lh.value(), multiplier), Fixed);
1398 void RenderStyle::setLineHeight(Length specifiedLineHeight) { SET_VAR(inherited, line_height, specifiedLineHeight); }
1400 int RenderStyle::computedLineHeight() const
1402 const Length& lh = lineHeight();
1404 // Negative value means the line height is not set. Use the font's built-in spacing.
1405 if (lh.isNegative())
1406 return fontMetrics().lineSpacing();
1409 return minimumValueForLength(lh, fontSize());
1414 void RenderStyle::setWordSpacing(Length value)
1416 float fontWordSpacing;
1417 switch (value.type()) {
1419 fontWordSpacing = 0;
1422 fontWordSpacing = value.percent() * fontCascade().spaceWidth() / 100;
1425 fontWordSpacing = value.value();
1428 fontWordSpacing = value.nonNanCalculatedValue(maxValueForCssLength);
1431 ASSERT_NOT_REACHED();
1432 fontWordSpacing = 0;
1435 inherited.access()->fontCascade.setWordSpacing(fontWordSpacing);
1436 rareInheritedData.access()->wordSpacing = WTF::move(value);
1439 void RenderStyle::setLetterSpacing(float v) { inherited.access()->fontCascade.setLetterSpacing(v); }
1441 void RenderStyle::setFontSize(float size)
1443 // size must be specifiedSize if Text Autosizing is enabled, but computedSize if text
1444 // zoom is enabled (if neither is enabled it's irrelevant as they're probably the same).
1446 ASSERT(std::isfinite(size));
1447 if (!std::isfinite(size) || size < 0)
1450 size = std::min(maximumAllowedFontSize, size);
1452 FontSelector* currentFontSelector = fontCascade().fontSelector();
1453 FontDescription desc(fontDescription());
1454 desc.setSpecifiedSize(size);
1455 desc.setComputedSize(size);
1457 #if ENABLE(TEXT_AUTOSIZING)
1458 float multiplier = textAutosizingMultiplier();
1459 if (multiplier > 1) {
1460 float autosizedFontSize = TextAutosizer::computeAutosizedFontSize(size, multiplier);
1461 desc.setComputedSize(min(maximumAllowedFontSize, autosizedFontSize));
1465 setFontDescription(desc);
1466 fontCascade().update(currentFontSelector);
1469 void RenderStyle::getShadowExtent(const ShadowData* shadow, LayoutUnit &top, LayoutUnit &right, LayoutUnit &bottom, LayoutUnit &left) const
1476 for ( ; shadow; shadow = shadow->next()) {
1477 if (shadow->style() == Inset)
1480 int extentAndSpread = shadow->paintingExtent() + shadow->spread();
1481 top = std::min<LayoutUnit>(top, shadow->y() - extentAndSpread);
1482 right = std::max<LayoutUnit>(right, shadow->x() + extentAndSpread);
1483 bottom = std::max<LayoutUnit>(bottom, shadow->y() + extentAndSpread);
1484 left = std::min<LayoutUnit>(left, shadow->x() - extentAndSpread);
1488 LayoutBoxExtent RenderStyle::getShadowInsetExtent(const ShadowData* shadow) const
1491 LayoutUnit right = 0;
1492 LayoutUnit bottom = 0;
1493 LayoutUnit left = 0;
1495 for ( ; shadow; shadow = shadow->next()) {
1496 if (shadow->style() == Normal)
1499 int extentAndSpread = shadow->paintingExtent() + shadow->spread();
1500 top = std::max<LayoutUnit>(top, shadow->y() + extentAndSpread);
1501 right = std::min<LayoutUnit>(right, shadow->x() - extentAndSpread);
1502 bottom = std::min<LayoutUnit>(bottom, shadow->y() - extentAndSpread);
1503 left = std::max<LayoutUnit>(left, shadow->x() + extentAndSpread);
1506 return LayoutBoxExtent(top, right, bottom, left);
1509 void RenderStyle::getShadowHorizontalExtent(const ShadowData* shadow, LayoutUnit &left, LayoutUnit &right) const
1514 for ( ; shadow; shadow = shadow->next()) {
1515 if (shadow->style() == Inset)
1518 int extentAndSpread = shadow->paintingExtent() + shadow->spread();
1519 left = std::min<LayoutUnit>(left, shadow->x() - extentAndSpread);
1520 right = std::max<LayoutUnit>(right, shadow->x() + extentAndSpread);
1524 void RenderStyle::getShadowVerticalExtent(const ShadowData* shadow, LayoutUnit &top, LayoutUnit &bottom) const
1529 for ( ; shadow; shadow = shadow->next()) {
1530 if (shadow->style() == Inset)
1533 int extentAndSpread = shadow->paintingExtent() + shadow->spread();
1534 top = std::min<LayoutUnit>(top, shadow->y() - extentAndSpread);
1535 bottom = std::max<LayoutUnit>(bottom, shadow->y() + extentAndSpread);
1539 Color RenderStyle::colorIncludingFallback(int colorProperty, bool visitedLink) const
1542 EBorderStyle borderStyle = BNONE;
1543 switch (colorProperty) {
1544 case CSSPropertyBackgroundColor:
1545 return visitedLink ? visitedLinkBackgroundColor() : backgroundColor(); // Background color doesn't fall back.
1546 case CSSPropertyBorderLeftColor:
1547 result = visitedLink ? visitedLinkBorderLeftColor() : borderLeftColor();
1548 borderStyle = borderLeftStyle();
1550 case CSSPropertyBorderRightColor:
1551 result = visitedLink ? visitedLinkBorderRightColor() : borderRightColor();
1552 borderStyle = borderRightStyle();
1554 case CSSPropertyBorderTopColor:
1555 result = visitedLink ? visitedLinkBorderTopColor() : borderTopColor();
1556 borderStyle = borderTopStyle();
1558 case CSSPropertyBorderBottomColor:
1559 result = visitedLink ? visitedLinkBorderBottomColor() : borderBottomColor();
1560 borderStyle = borderBottomStyle();
1562 case CSSPropertyColor:
1563 result = visitedLink ? visitedLinkColor() : color();
1565 case CSSPropertyOutlineColor:
1566 result = visitedLink ? visitedLinkOutlineColor() : outlineColor();
1568 case CSSPropertyColumnRuleColor:
1569 result = visitedLink ? visitedLinkColumnRuleColor() : columnRuleColor();
1571 case CSSPropertyWebkitTextDecorationColor:
1572 // Text decoration color fallback is handled in RenderObject::decorationColor.
1573 return visitedLink ? visitedLinkTextDecorationColor() : textDecorationColor();
1574 case CSSPropertyWebkitTextEmphasisColor:
1575 result = visitedLink ? visitedLinkTextEmphasisColor() : textEmphasisColor();
1577 case CSSPropertyWebkitTextFillColor:
1578 result = visitedLink ? visitedLinkTextFillColor() : textFillColor();
1580 case CSSPropertyWebkitTextStrokeColor:
1581 result = visitedLink ? visitedLinkTextStrokeColor() : textStrokeColor();
1584 ASSERT_NOT_REACHED();
1588 if (!result.isValid()) {
1589 if (!visitedLink && (borderStyle == INSET || borderStyle == OUTSET || borderStyle == RIDGE || borderStyle == GROOVE))
1590 result.setRGB(238, 238, 238);
1592 result = visitedLink ? visitedLinkColor() : color();
1597 Color RenderStyle::visitedDependentColor(int colorProperty) const
1599 Color unvisitedColor = colorIncludingFallback(colorProperty, false);
1600 if (insideLink() != InsideVisitedLink)
1601 return unvisitedColor;
1603 Color visitedColor = colorIncludingFallback(colorProperty, true);
1605 // Text decoration color validity is preserved (checked in RenderObject::decorationColor).
1606 if (colorProperty == CSSPropertyWebkitTextDecorationColor)
1607 return visitedColor;
1609 // FIXME: Technically someone could explicitly specify the color transparent, but for now we'll just
1610 // assume that if the background color is transparent that it wasn't set. Note that it's weird that
1611 // we're returning unvisited info for a visited link, but given our restriction that the alpha values
1612 // have to match, it makes more sense to return the unvisited background color if specified than it
1613 // does to return black. This behavior matches what Firefox 4 does as well.
1614 if (colorProperty == CSSPropertyBackgroundColor && visitedColor == Color::transparent)
1615 return unvisitedColor;
1617 // Take the alpha from the unvisited color, but get the RGB values from the visited color.
1618 return Color(visitedColor.red(), visitedColor.green(), visitedColor.blue(), unvisitedColor.alpha());
1621 const BorderValue& RenderStyle::borderBefore() const
1623 switch (writingMode()) {
1624 case TopToBottomWritingMode:
1626 case BottomToTopWritingMode:
1627 return borderBottom();
1628 case LeftToRightWritingMode:
1629 return borderLeft();
1630 case RightToLeftWritingMode:
1631 return borderRight();
1633 ASSERT_NOT_REACHED();
1637 const BorderValue& RenderStyle::borderAfter() const
1639 switch (writingMode()) {
1640 case TopToBottomWritingMode:
1641 return borderBottom();
1642 case BottomToTopWritingMode:
1644 case LeftToRightWritingMode:
1645 return borderRight();
1646 case RightToLeftWritingMode:
1647 return borderLeft();
1649 ASSERT_NOT_REACHED();
1650 return borderBottom();
1653 const BorderValue& RenderStyle::borderStart() const
1655 if (isHorizontalWritingMode())
1656 return isLeftToRightDirection() ? borderLeft() : borderRight();
1657 return isLeftToRightDirection() ? borderTop() : borderBottom();
1660 const BorderValue& RenderStyle::borderEnd() const
1662 if (isHorizontalWritingMode())
1663 return isLeftToRightDirection() ? borderRight() : borderLeft();
1664 return isLeftToRightDirection() ? borderBottom() : borderTop();
1667 float RenderStyle::borderBeforeWidth() const
1669 switch (writingMode()) {
1670 case TopToBottomWritingMode:
1671 return borderTopWidth();
1672 case BottomToTopWritingMode:
1673 return borderBottomWidth();
1674 case LeftToRightWritingMode:
1675 return borderLeftWidth();
1676 case RightToLeftWritingMode:
1677 return borderRightWidth();
1679 ASSERT_NOT_REACHED();
1680 return borderTopWidth();
1683 float RenderStyle::borderAfterWidth() const
1685 switch (writingMode()) {
1686 case TopToBottomWritingMode:
1687 return borderBottomWidth();
1688 case BottomToTopWritingMode:
1689 return borderTopWidth();
1690 case LeftToRightWritingMode:
1691 return borderRightWidth();
1692 case RightToLeftWritingMode:
1693 return borderLeftWidth();
1695 ASSERT_NOT_REACHED();
1696 return borderBottomWidth();
1699 float RenderStyle::borderStartWidth() const
1701 if (isHorizontalWritingMode())
1702 return isLeftToRightDirection() ? borderLeftWidth() : borderRightWidth();
1703 return isLeftToRightDirection() ? borderTopWidth() : borderBottomWidth();
1706 float RenderStyle::borderEndWidth() const
1708 if (isHorizontalWritingMode())
1709 return isLeftToRightDirection() ? borderRightWidth() : borderLeftWidth();
1710 return isLeftToRightDirection() ? borderBottomWidth() : borderTopWidth();
1713 void RenderStyle::setMarginStart(Length margin)
1715 if (isHorizontalWritingMode()) {
1716 if (isLeftToRightDirection())
1717 setMarginLeft(margin);
1719 setMarginRight(margin);
1721 if (isLeftToRightDirection())
1722 setMarginTop(margin);
1724 setMarginBottom(margin);
1728 void RenderStyle::setMarginEnd(Length margin)
1730 if (isHorizontalWritingMode()) {
1731 if (isLeftToRightDirection())
1732 setMarginRight(margin);
1734 setMarginLeft(margin);
1736 if (isLeftToRightDirection())
1737 setMarginBottom(margin);
1739 setMarginTop(margin);
1743 TextEmphasisMark RenderStyle::textEmphasisMark() const
1745 TextEmphasisMark mark = static_cast<TextEmphasisMark>(rareInheritedData->textEmphasisMark);
1746 if (mark != TextEmphasisMarkAuto)
1749 if (isHorizontalWritingMode())
1750 return TextEmphasisMarkDot;
1752 return TextEmphasisMarkSesame;
1755 #if ENABLE(TOUCH_EVENTS)
1756 Color RenderStyle::initialTapHighlightColor()
1758 return RenderTheme::tapHighlightColor();
1762 LayoutBoxExtent RenderStyle::imageOutsets(const NinePieceImage& image) const
1764 return LayoutBoxExtent(NinePieceImage::computeOutset(image.outset().top(), borderTopWidth()),
1765 NinePieceImage::computeOutset(image.outset().right(), borderRightWidth()),
1766 NinePieceImage::computeOutset(image.outset().bottom(), borderBottomWidth()),
1767 NinePieceImage::computeOutset(image.outset().left(), borderLeftWidth()));
1770 void RenderStyle::getFontAndGlyphOrientation(FontOrientation& fontOrientation, NonCJKGlyphOrientation& glyphOrientation)
1772 if (isHorizontalWritingMode()) {
1773 fontOrientation = Horizontal;
1774 glyphOrientation = NonCJKGlyphOrientationVerticalRight;
1778 switch (textOrientation()) {
1779 case TextOrientationVerticalRight:
1780 fontOrientation = Vertical;
1781 glyphOrientation = NonCJKGlyphOrientationVerticalRight;
1783 case TextOrientationUpright:
1784 fontOrientation = Vertical;
1785 glyphOrientation = NonCJKGlyphOrientationUpright;
1787 case TextOrientationSideways:
1788 if (writingMode() == LeftToRightWritingMode) {
1789 // FIXME: This should map to sideways-left, which is not supported yet.
1790 fontOrientation = Vertical;
1791 glyphOrientation = NonCJKGlyphOrientationVerticalRight;
1794 fontOrientation = Horizontal;
1795 glyphOrientation = NonCJKGlyphOrientationVerticalRight;
1797 case TextOrientationSidewaysRight:
1798 fontOrientation = Horizontal;
1799 glyphOrientation = NonCJKGlyphOrientationVerticalRight;
1802 ASSERT_NOT_REACHED();
1803 fontOrientation = Horizontal;
1804 glyphOrientation = NonCJKGlyphOrientationVerticalRight;
1809 void RenderStyle::setBorderImageSource(PassRefPtr<StyleImage> image)
1811 if (surround->border.m_image.image() == image.get())
1813 surround.access()->border.m_image.setImage(image);
1816 void RenderStyle::setBorderImageSlices(LengthBox slices)
1818 if (surround->border.m_image.imageSlices() == slices)
1820 surround.access()->border.m_image.setImageSlices(slices);
1823 void RenderStyle::setBorderImageWidth(LengthBox slices)
1825 if (surround->border.m_image.borderSlices() == slices)
1827 surround.access()->border.m_image.setBorderSlices(slices);
1830 void RenderStyle::setBorderImageOutset(LengthBox outset)
1832 if (surround->border.m_image.outset() == outset)
1834 surround.access()->border.m_image.setOutset(outset);
1837 void RenderStyle::setColumnStylesFromPaginationMode(const Pagination::Mode& paginationMode)
1839 if (paginationMode == Pagination::Unpaginated)
1842 setColumnFill(ColumnFillAuto);
1844 switch (paginationMode) {
1845 case Pagination::LeftToRightPaginated:
1846 setColumnAxis(HorizontalColumnAxis);
1847 if (isHorizontalWritingMode())
1848 setColumnProgression(isLeftToRightDirection() ? NormalColumnProgression : ReverseColumnProgression);
1850 setColumnProgression(isFlippedBlocksWritingMode() ? ReverseColumnProgression : NormalColumnProgression);
1852 case Pagination::RightToLeftPaginated:
1853 setColumnAxis(HorizontalColumnAxis);
1854 if (isHorizontalWritingMode())
1855 setColumnProgression(isLeftToRightDirection() ? ReverseColumnProgression : NormalColumnProgression);
1857 setColumnProgression(isFlippedBlocksWritingMode() ? NormalColumnProgression : ReverseColumnProgression);
1859 case Pagination::TopToBottomPaginated:
1860 setColumnAxis(VerticalColumnAxis);
1861 if (isHorizontalWritingMode())
1862 setColumnProgression(isFlippedBlocksWritingMode() ? ReverseColumnProgression : NormalColumnProgression);
1864 setColumnProgression(isLeftToRightDirection() ? NormalColumnProgression : ReverseColumnProgression);
1866 case Pagination::BottomToTopPaginated:
1867 setColumnAxis(VerticalColumnAxis);
1868 if (isHorizontalWritingMode())
1869 setColumnProgression(isFlippedBlocksWritingMode() ? NormalColumnProgression : ReverseColumnProgression);
1871 setColumnProgression(isLeftToRightDirection() ? ReverseColumnProgression : NormalColumnProgression);
1873 case Pagination::Unpaginated:
1874 ASSERT_NOT_REACHED();
1879 #if ENABLE(CSS_SCROLL_SNAP)
1880 LengthSize RenderStyle::initialScrollSnapDestination()
1882 return defaultScrollSnapDestination();
1885 Vector<LengthSize> RenderStyle::initialScrollSnapCoordinates()
1887 return Vector<LengthSize>();
1890 const ScrollSnapPoints* RenderStyle::scrollSnapPointsX() const
1892 return rareNonInheritedData->m_scrollSnapPoints->xPoints.get();
1895 const ScrollSnapPoints* RenderStyle::scrollSnapPointsY() const
1897 return rareNonInheritedData->m_scrollSnapPoints->yPoints.get();
1900 const LengthSize& RenderStyle::scrollSnapDestination() const
1902 return rareNonInheritedData->m_scrollSnapPoints->destination;
1905 const Vector<LengthSize>& RenderStyle::scrollSnapCoordinates() const
1907 return rareNonInheritedData->m_scrollSnapPoints->coordinates;
1910 void RenderStyle::setScrollSnapPointsX(std::unique_ptr<ScrollSnapPoints> points)
1912 if (rareNonInheritedData->m_scrollSnapPoints->xPoints.get() == points.get())
1914 rareNonInheritedData.access()->m_scrollSnapPoints.access()->xPoints = WTF::move(points);
1917 void RenderStyle::setScrollSnapPointsY(std::unique_ptr<ScrollSnapPoints> points)
1919 if (rareNonInheritedData->m_scrollSnapPoints->yPoints.get() == points.get())
1921 rareNonInheritedData.access()->m_scrollSnapPoints.access()->yPoints = WTF::move(points);
1924 void RenderStyle::setScrollSnapDestination(LengthSize destination)
1926 if (rareNonInheritedData->m_scrollSnapPoints->destination == destination)
1928 rareNonInheritedData.access()->m_scrollSnapPoints.access()->destination = WTF::move(destination);
1931 void RenderStyle::setScrollSnapCoordinates(Vector<LengthSize> coordinates)
1933 if (rareNonInheritedData->m_scrollSnapPoints->coordinates == coordinates)
1935 rareNonInheritedData.access()->m_scrollSnapPoints.access()->coordinates = WTF::move(coordinates);
1940 } // namespace WebCore