-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathRenderObject.h
More file actions
1502 lines (1255 loc) · 72.6 KB
/
RenderObject.h
File metadata and controls
1502 lines (1255 loc) · 72.6 KB
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
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (C) 2000 Lars Knoll ([email protected])
* (C) 2000 Antti Koivisto ([email protected])
* (C) 2000 Dirk Mueller ([email protected])
* (C) 2004 Allan Sandfeld Jensen ([email protected])
* Copyright (C) 2003-2022 Apple Inc. All rights reserved.
* Copyright (C) 2009 Google Inc. All rights reserved.
*
* 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 <WebCore/CachedImageClient.h>
#include <WebCore/LayoutRect.h>
#include <WebCore/PlatformLayerIdentifier.h>
#include <WebCore/RenderObjectEnums.h>
#include <WebCore/RenderStyleConstants.h>
#include <WebCore/RepaintRectCalculation.h>
#include <wtf/CheckedPtr.h>
#include <wtf/EnumSet.h>
#include <wtf/Platform.h>
#include <wtf/TZoneMalloc.h>
namespace WTF {
class TextStream;
}
namespace WebCore {
class AffineTransform;
class Color;
class ControlPart;
class Cursor;
class Document;
class FloatQuad;
class HitTestLocation;
class HitTestRequest;
class HitTestResult;
class HostWindow;
class LegacyInlineBox;
class LocalFrame;
class LocalFrameViewLayoutContext;
class Node;
class Page;
class Path;
class Position;
class PositionWithAffinity;
class ReferencedSVGResources;
class RenderBox;
class RenderBoxModelObject;
class RenderInline;
class RenderBlock;
class RenderBlockFlow;
class RenderElement;
class RenderFragmentedFlow;
class RenderGeometryMap;
class RenderLayer;
class RenderLayerModelObject;
class RenderFragmentContainer;
class RenderStyle;
class RenderTheme;
class RenderTreeBuilder;
class RenderView;
class RenderHighlight;
class ScrollAnchoringController;
class SelectionGeometry;
class Settings;
class TransformState;
class TreeScope;
class VisiblePosition;
class WeakPtrImplWithEventTargetData;
struct InlineBoxAndOffset;
struct PaintInfo;
struct ScrollRectToVisibleOptions;
struct SimpleRange;
struct VisibleRectContext;
namespace Layout {
class Box;
}
namespace Style {
class PseudoElementRequest;
enum class MarginTrimSide : uint8_t;
}
enum class Affinity : bool;
enum class HitTestSource : bool;
enum class RepaintOutlineBounds : bool { No, Yes };
enum class PointerEvents : uint8_t;
enum class RequiresFullRepaint : bool { No, Yes };
enum class StyleColorOptions : uint8_t;
typedef const void* WrappedImagePtr;
// Base class for all rendering tree objects.
class RenderObject : public CanMakeSingleThreadWeakPtr<RenderObject>, public CanMakeCheckedPtr<RenderObject> {
WTF_MAKE_PREFERABLY_COMPACT_TZONE_ALLOCATED(RenderObject);
WTF_OVERRIDE_DELETE_FOR_CHECKED_PTR(RenderObject);
friend class RenderBlock;
friend class RenderBlockFlow;
friend class RenderBox;
friend class RenderElement;
friend class RenderLayer;
friend class RenderLayerScrollableArea;
friend class RenderTreeBuilder;
public:
enum class Type : uint8_t {
#if ENABLE(ATTACHMENT_ELEMENT)
Attachment,
#endif
BlockFlow,
Button,
CombineText,
Counter,
DeprecatedFlexibleBox,
DetailsMarker,
EmbeddedObject,
FileUploadControl,
FlexibleBox,
Frame,
FrameSet,
Grid,
HTMLCanvas,
IFrame,
Image,
Inline,
LineBreak,
ListBox,
ListItem,
ListMarker,
Media,
MenuList,
Meter,
#if ENABLE(MODEL_ELEMENT)
Model,
#endif
MultiColumnFlow,
MultiColumnSet,
MultiColumnSpannerPlaceholder,
Progress,
Quote,
Replica,
ScrollbarPart,
SearchField,
SelectFallbackButton,
Slider,
SliderContainer,
Table,
TableCaption,
TableCell,
TableCol,
TableRow,
TableSection,
Text,
TextControlInnerBlock,
TextControlInnerContainer,
TextControlMultiLine,
TextControlSingleLine,
TextFragment,
VTTCue,
Video,
View,
ViewTransitionCapture,
#if ENABLE(MATHML)
MathMLBlock,
MathMLFenced,
MathMLFencedOperator,
MathMLFraction,
MathMLMath,
MathMLMenclose,
MathMLOperator,
MathMLPadded,
MathMLRoot,
MathMLRow,
MathMLScripts,
MathMLSpace,
MathMLTable,
MathMLToken,
MathMLUnderOver,
#endif
SVGEllipse,
SVGForeignObject,
SVGGradientStop,
SVGHiddenContainer,
SVGImage,
SVGInline,
SVGInlineText,
SVGPath,
SVGRect,
SVGResourceClipper,
SVGResourceFilter,
SVGResourceFilterPrimitive,
SVGResourceLinearGradient,
SVGResourceMarker,
SVGResourceMasker,
SVGResourcePattern,
SVGResourceRadialGradient,
SVGRoot,
SVGTSpan,
SVGText,
SVGTextPath,
SVGTransformableContainer,
SVGViewportContainer,
LegacySVGEllipse,
LegacySVGForeignObject,
LegacySVGHiddenContainer,
LegacySVGImage,
LegacySVGPath,
LegacySVGRect,
LegacySVGResourceClipper,
LegacySVGResourceFilter,
LegacySVGResourceFilterPrimitive,
LegacySVGResourceLinearGradient,
LegacySVGResourceMarker,
LegacySVGResourceMasker,
LegacySVGResourcePattern,
LegacySVGResourceRadialGradient,
LegacySVGRoot,
LegacySVGTransformableContainer,
LegacySVGViewportContainer
};
enum class TypeFlag : uint8_t {
IsAnonymous = 1 << 0,
IsText = 1 << 1,
IsBox = 1 << 2,
IsBoxModelObject = 1 << 3,
IsLayerModelObject = 1 << 4,
IsRenderInline = 1 << 5,
IsRenderBlock = 1 << 6,
IsFlexibleBox = 1 << 7,
};
// Type Specific Flags
enum class BlockFlowFlag : uint8_t {
IsFragmentContainer = 1 << 0,
IsFragmentedFlow = 1 << 1,
IsTextControl = 1 << 2,
IsSVGBlock = 1 << 3,
IsViewTransitionContainingBlock = 1 << 4,
};
enum class LineBreakFlag : uint8_t {
IsWBR = 1 << 0,
};
enum class ReplacedFlag : uint8_t {
IsImage = 1 << 0,
IsMedia = 1 << 1,
IsWidget = 1 << 2,
IsViewTransitionCapture = 1 << 3,
UsesBoundaryCaching = 1 << 5,
};
enum class SVGModelObjectFlag : uint8_t {
IsLegacy = 1 << 0,
IsContainer = 1 << 1,
IsHiddenContainer = 1 << 2,
IsResourceContainer = 1 << 3,
IsShape = 1 << 4,
UsesBoundaryCaching = 1 << 5,
};
class TypeSpecificFlags {
public:
enum class Kind : uint8_t {
Invalid = 0,
BlockFlow,
LineBreak,
Replaced,
SVGModelObject,
};
TypeSpecificFlags() = default;
TypeSpecificFlags(OptionSet<BlockFlowFlag> flags)
: m_kind(std::to_underlying(Kind::BlockFlow))
, m_flags(flags.toRaw())
{
ASSERT(blockFlowFlags() == flags);
}
TypeSpecificFlags(OptionSet<LineBreakFlag> flags)
: m_kind(std::to_underlying(Kind::LineBreak))
, m_flags(flags.toRaw())
{
ASSERT(lineBreakFlags() == flags);
}
TypeSpecificFlags(OptionSet<ReplacedFlag> flags)
: m_kind(std::to_underlying(Kind::Replaced))
, m_flags(flags.toRaw())
{
ASSERT(replacedFlags() == flags);
}
TypeSpecificFlags(OptionSet<SVGModelObjectFlag> flags)
: m_kind(std::to_underlying(Kind::SVGModelObject))
, m_flags(flags.toRaw())
{
ASSERT(svgFlags() == flags);
}
Kind kind() const { return static_cast<Kind>(m_kind); }
OptionSet<BlockFlowFlag> blockFlowFlags() const { return OptionSet<BlockFlowFlag>::fromRaw(valueForKind(Kind::BlockFlow)); }
OptionSet<LineBreakFlag> lineBreakFlags() const { return OptionSet<LineBreakFlag>::fromRaw(valueForKind(Kind::LineBreak)); }
OptionSet<ReplacedFlag> replacedFlags() const { return OptionSet<ReplacedFlag>::fromRaw(valueForKind(Kind::Replaced)); }
OptionSet<SVGModelObjectFlag> svgFlags() const { return OptionSet<SVGModelObjectFlag>::fromRaw(valueForKind(Kind::SVGModelObject)); }
private:
uint8_t valueForKind(Kind kind) const
{
ASSERT(this->kind() == kind);
return this->kind() == kind ? m_flags : 0;
}
const uint8_t m_kind : 3 { std::to_underlying(Kind::Invalid) }; // Security hardening to store the type.
const uint8_t m_flags : 6 { 0 };
// 7 bits free.
};
// Anonymous objects should pass the document as their node, and they will then automatically be
// marked as anonymous in the constructor.
RenderObject(Type, Node&, OptionSet<TypeFlag>, TypeSpecificFlags);
virtual ~RenderObject();
Type type() const { return m_type; }
Layout::Box* layoutBox() { return m_layoutBox.get(); }
const Layout::Box* layoutBox() const { return m_layoutBox.get(); }
void NODELETE setLayoutBox(Layout::Box&);
void NODELETE clearLayoutBox();
WEBCORE_EXPORT RenderTheme& theme() const;
virtual ASCIILiteral renderName() const = 0;
inline RenderElement* parent() const; // Defined in RenderElement.h.
bool NODELETE isDescendantOf(const RenderObject*) const;
RenderObject* previousSibling() const { return m_previous.get(); }
RenderObject* nextSibling() const { return m_next.get(); }
RenderObject* previousInFlowSibling() const;
RenderObject* nextInFlowSibling() const;
// Use RenderElement versions instead.
virtual RenderObject* firstChildSlow() const { return nullptr; }
virtual RenderObject* lastChildSlow() const { return nullptr; }
RenderObject* nextInPreOrder() const;
RenderObject* nextInPreOrder(const RenderObject* stayWithin) const;
RenderObject* nextInPreOrderAfterChildren() const;
RenderObject* nextInPreOrderAfterChildren(const RenderObject* stayWithin) const;
RenderObject* previousInPreOrder() const;
RenderObject* previousInPreOrder(const RenderObject* stayWithin) const;
WEBCORE_EXPORT RenderObject* childAt(unsigned) const;
RenderObject* firstLeafChild() const;
RenderObject* lastLeafChild() const;
RenderElement* NODELETE firstNonAnonymousAncestor() const;
#if ENABLE(TEXT_AUTOSIZING)
// Minimal distance between the block with fixed height and overflowing content and the text block to apply text autosizing.
// The greater this constant is the more potential places we have where autosizing is turned off.
// So it should be as low as possible. There are sites that break at 2.
static const int TextAutoSizingFixedHeightDepth = 3;
enum BlockContentHeightType {
FixedHeight,
FlexibleHeight,
OverflowHeight
};
typedef BlockContentHeightType (*HeightTypeTraverseNextInclusionFunction)(const RenderObject&);
RenderObject* traverseNext(const RenderObject* stayWithin, HeightTypeTraverseNextInclusionFunction, int& currentDepth, int& newFixedDepth) const;
#endif
WEBCORE_EXPORT RenderLayer* NODELETE enclosingLayer() const;
WEBCORE_EXPORT RenderBox& NODELETE enclosingBox() const;
RenderBoxModelObject& NODELETE enclosingBoxModelObject() const;
RenderBox* enclosingScrollableContainer() const;
// Return our enclosing flow thread if we are contained inside one. Follows the containing block chain.
RenderFragmentedFlow* enclosingFragmentedFlow() const;
WEBCORE_EXPORT bool useDarkAppearance() const;
WEBCORE_EXPORT OptionSet<StyleColorOptions> styleColorOptions() const;
// Creates a scope where this object will assert on calls to setNeedsLayout().
class SetLayoutNeededForbiddenScope;
// RenderObject tree manipulation
//////////////////////////////////////////
virtual bool canHaveChildren() const = 0;
virtual bool canHaveGeneratedChildren() const;
virtual bool createsAnonymousWrapper() const { return false; }
//////////////////////////////////////////
#if ENABLE(TREE_DEBUGGING)
void showNodeTreeForThis() const;
void showRenderTreeForThis() const;
void showSubtreeForThis() const;
void showLineTreeForThis() const;
void outputRenderObject(WTF::TextStream&, bool mark, int depth) const;
void outputRenderSubTreeAndMark(WTF::TextStream&, const RenderObject* markedObject, int depth) const;
void outputRegionsInformation(WTF::TextStream&) const;
#endif
inline bool isPseudoElement() const; // Defined in RenderObjectNode.h
bool isRenderElement() const { return !isRenderText(); }
bool isRenderReplaced() const { return m_typeSpecificFlags.kind() == TypeSpecificFlags::Kind::Replaced; }
bool isRenderBoxModelObject() const { return m_typeFlags.contains(TypeFlag::IsBoxModelObject); }
bool isRenderBlock() const { return m_typeFlags.contains(TypeFlag::IsRenderBlock); }
bool isRenderBlockFlow() const { return m_typeSpecificFlags.kind() == TypeSpecificFlags::Kind::BlockFlow; }
bool isRenderInline() const { return m_typeFlags.contains(TypeFlag::IsRenderInline); }
bool isRenderLayerModelObject() const { return m_typeFlags.contains(TypeFlag::IsLayerModelObject); }
inline bool isAtomicInlineLevelBox() const; // Defined in RenderObjectStyle.h
inline bool isNonReplacedAtomicInlineLevelBox() const;
bool isRenderCounter() const { return type() == Type::Counter; }
bool isRenderQuote() const { return type() == Type::Quote; }
bool isRenderDetailsMarker() const { return type() == Type::DetailsMarker; }
bool isRenderEmbeddedObject() const { return type() == Type::EmbeddedObject; }
bool NODELETE isFieldset() const;
bool isRenderFileUploadControl() const { return type() == Type::FileUploadControl; }
bool isRenderFrame() const { return type() == Type::Frame; }
bool isRenderFrameSet() const { return type() == Type::FrameSet; }
virtual bool isImage() const { return false; }
bool isRenderListBox() const { return type() == Type::ListBox; }
bool isRenderListItem() const { return type() == Type::ListItem; }
bool isRenderListMarker() const { return type() == Type::ListMarker; }
bool isRenderMedia() const { return isRenderReplaced() && m_typeSpecificFlags.replacedFlags().contains(ReplacedFlag::IsMedia); }
bool isRenderMenuList() const { return type() == Type::MenuList; }
bool isRenderMeter() const { return type() == Type::Meter; }
bool isRenderProgress() const { return type() == Type::Progress; }
bool isRenderButton() const { return type() == Type::Button; }
bool isRenderIFrame() const { return type() == Type::IFrame; }
bool isRenderImage() const { return isRenderReplaced() && m_typeSpecificFlags.replacedFlags().contains(ReplacedFlag::IsImage); }
bool isRenderTextFragment() const { return type() == Type::TextFragment; }
#if ENABLE(MODEL_ELEMENT)
bool isRenderModel() const { return type() == Type::Model; }
#endif
bool isRenderFragmentContainer() const { return isRenderBlockFlow() && m_typeSpecificFlags.blockFlowFlags().contains(BlockFlowFlag::IsFragmentContainer); }
bool isRenderReplica() const { return type() == Type::Replica; }
bool isRenderSlider() const { return type() == Type::Slider; }
bool isRenderSliderContainer() const { return type() == Type::SliderContainer; }
bool isRenderTable() const;
bool isRenderTableCell() const { return type() == Type::TableCell; }
bool isRenderTableCol() const { return type() == Type::TableCol; }
bool isRenderTableCaption() const { return type() == Type::TableCaption; }
bool isRenderTableSection() const { return type() == Type::TableSection; }
bool isRenderTextControl() const { return isRenderBlockFlow() && m_typeSpecificFlags.blockFlowFlags().contains(BlockFlowFlag::IsTextControl); }
bool isRenderTextControlMultiLine() const { return type() == Type::TextControlMultiLine; }
bool isRenderTextControlSingleLine() const { return isRenderTextControl() && !isRenderTextControlMultiLine(); }
bool isRenderSearchField() const { return type() == Type::SearchField; }
bool isRenderSelectFallbackButton() const { return type() == Type::SelectFallbackButton; }
bool isRenderTextControlInnerBlock() const { return type() == Type::TextControlInnerBlock; }
bool isRenderTextControlInnerContainer() const { return type() == Type::TextControlInnerContainer; }
bool isRenderVideo() const { return type() == Type::Video; }
bool isRenderViewTransitionCapture() const { return isRenderReplaced() && m_typeSpecificFlags.replacedFlags().contains(ReplacedFlag::IsViewTransitionCapture); }
bool isRenderWidget() const { return isRenderReplaced() && m_typeSpecificFlags.replacedFlags().contains(ReplacedFlag::IsWidget); }
bool isRenderHTMLCanvas() const { return type() == Type::HTMLCanvas; }
#if ENABLE(ATTACHMENT_ELEMENT)
bool isRenderAttachment() const { return type() == Type::Attachment; }
#endif
bool isRenderGrid() const { return type() == Type::Grid; }
bool isRenderMultiColumnSet() const { return type() == Type::MultiColumnSet; }
bool isRenderMultiColumnFlow() const { return type() == Type::MultiColumnFlow; }
bool isRenderMultiColumnSpannerPlaceholder() const { return type() == Type::MultiColumnSpannerPlaceholder; }
bool isRenderScrollbarPart() const { return type() == Type::ScrollbarPart; }
bool isRenderVTTCue() const { return type() == Type::VTTCue; }
bool isViewTransitionContainingBlock() const { return isRenderBlockFlow() && m_typeSpecificFlags.blockFlowFlags().contains(BlockFlowFlag::IsViewTransitionContainingBlock); }
inline bool isDocumentElementRenderer() const; // Defined in RenderObjectInlines.h
inline bool isBody() const; // Defined in RenderObjectNode.h
inline bool isHR() const; // Defined in RenderObjectNode.h
bool NODELETE isLegend() const;
bool NODELETE isHTMLMarquee() const;
bool isTablePart() const { return isRenderTableCell() || isRenderTableCol() || isRenderTableCaption() || isRenderTableRow() || isRenderTableSection(); }
bool beingDestroyed() const { return m_stateBitfields.hasFlag(StateFlag::BeingDestroyed); }
bool everHadLayout() const { return m_stateBitfields.hasFlag(StateFlag::EverHadLayout); }
std::optional<bool> wasSkippedDuringLastLayoutDueToContentVisibility() const { return everHadLayout() ? std::make_optional(m_stateBitfields.hasFlag(StateFlag::WasSkippedDuringLastLayoutDueToContentVisibility)) : std::nullopt; }
static ScrollAnchoringController* searchParentChainForScrollAnchoringController(const RenderObject&);
bool childrenInline() const { return m_stateBitfields.hasFlag(StateFlag::ChildrenInline); }
virtual void setChildrenInline(bool b) { m_stateBitfields.setFlag(StateFlag::ChildrenInline, b); }
enum class FragmentedFlowState : bool {
NotInsideFlow = 0,
InsideFlow = 1,
};
enum class SkipDescendentFragmentedFlow : bool { No, Yes };
void setFragmentedFlowStateIncludingDescendants(FragmentedFlowState, SkipDescendentFragmentedFlow = SkipDescendentFragmentedFlow::Yes);
FragmentedFlowState fragmentedFlowState() const { return m_stateBitfields.fragmentedFlowState(); }
void setFragmentedFlowState(FragmentedFlowState state) { m_stateBitfields.setFragmentedFlowState(state); }
#if ENABLE(MATHML)
virtual bool isRenderMathMLBlock() const { return false; }
bool isRenderMathMLTable() const { return type() == Type::MathMLTable; }
virtual bool isRenderMathMLOperator() const { return false; }
bool isRenderMathMLRow() const;
bool isRenderMathMLMath() const { return type() == Type::MathMLMath; }
bool isRenderMathMLMenclose() const { return type() == Type::MathMLMenclose; }
bool isRenderMathMLFenced() const { return type() == Type::MathMLFenced; }
bool isRenderMathMLFencedOperator() const { return type() == Type::MathMLFencedOperator; }
bool isRenderMathMLFraction() const { return type() == Type::MathMLFraction; }
bool isRenderMathMLPadded() const { return type() == Type::MathMLPadded; }
bool isRenderMathMLRoot() const { return type() == Type::MathMLRoot; }
bool isRenderMathMLSpace() const { return type() == Type::MathMLSpace; }
virtual bool isRenderMathMLSquareRoot() const { return false; }
virtual bool isRenderMathMLScripts() const { return false; }
virtual bool isRenderMathMLToken() const { return false; }
bool isRenderMathMLUnderOver() const { return type() == Type::MathMLUnderOver; }
#endif // ENABLE(MATHML)
bool isLegacyRenderSVGModelObject() const { return m_typeSpecificFlags.kind() == TypeSpecificFlags::Kind::SVGModelObject && m_typeSpecificFlags.svgFlags().contains(SVGModelObjectFlag::IsLegacy); }
bool isRenderSVGModelObject() const { return m_typeSpecificFlags.kind() == TypeSpecificFlags::Kind::SVGModelObject && !m_typeSpecificFlags.svgFlags().contains(SVGModelObjectFlag::IsLegacy); }
bool isRenderSVGBlock() const { return isRenderBlockFlow() && m_typeSpecificFlags.blockFlowFlags().contains(BlockFlowFlag::IsSVGBlock); }
bool isLegacyRenderSVGRoot() const { return type() == Type::LegacySVGRoot; }
bool isRenderSVGRoot() const { return type() == Type::SVGRoot; }
bool isRenderSVGContainer() const { return isRenderSVGModelObject() && m_typeSpecificFlags.svgFlags().contains(SVGModelObjectFlag::IsContainer); }
bool isLegacyRenderSVGContainer() const { return isLegacyRenderSVGModelObject() && m_typeSpecificFlags.svgFlags().contains(SVGModelObjectFlag::IsContainer); }
bool isRenderSVGTransformableContainer() const { return type() == Type::SVGTransformableContainer; }
bool isLegacyRenderSVGTransformableContainer() const { return type() == Type::LegacySVGTransformableContainer; }
bool isRenderSVGViewportContainer() const { return type() == Type::SVGViewportContainer; }
bool isLegacyRenderSVGViewportContainer() const { return type() == Type::LegacySVGViewportContainer; }
bool isRenderSVGGradientStop() const { return type() == Type::SVGGradientStop; }
bool isLegacyRenderSVGHiddenContainer() const { return isLegacyRenderSVGModelObject() && m_typeSpecificFlags.svgFlags().contains(SVGModelObjectFlag::IsHiddenContainer); }
bool isRenderSVGHiddenContainer() const { return isRenderSVGModelObject() && m_typeSpecificFlags.svgFlags().contains(SVGModelObjectFlag::IsHiddenContainer); }
bool isLegacyRenderSVGPath() const { return type() == Type::LegacySVGPath; }
bool isRenderSVGPath() const { return type() == Type::SVGPath; }
bool isRenderSVGShape() const { return isRenderSVGModelObject() && m_typeSpecificFlags.svgFlags().contains(SVGModelObjectFlag::IsShape); }
bool isLegacyRenderSVGShape() const { return isLegacyRenderSVGModelObject() && m_typeSpecificFlags.svgFlags().contains(SVGModelObjectFlag::IsShape); }
bool isLegacyRenderSVGRect() const { return type() == Type::LegacySVGRect; }
bool isRenderSVGText() const { return type() == Type::SVGText; }
bool isRenderSVGTextPath() const { return type() == Type::SVGTextPath; }
bool isRenderSVGTSpan() const { return type() == Type::SVGTSpan; }
bool isRenderSVGInline() const { return type() == Type::SVGInline || type() == Type::SVGTSpan || type() == Type::SVGTextPath; }
bool isRenderSVGInlineText() const { return type() == Type::SVGInlineText; }
bool isLegacyRenderSVGImage() const { return type() == Type::LegacySVGImage; }
bool isRenderSVGImage() const { return type() == Type::SVGImage; }
bool isLegacyRenderSVGForeignObject() const { return type() == Type::LegacySVGForeignObject; }
bool isRenderSVGForeignObject() const { return type() == Type::SVGForeignObject; }
bool isLegacyRenderSVGResourceContainer() const { return isLegacyRenderSVGModelObject() && m_typeSpecificFlags.svgFlags().contains(SVGModelObjectFlag::IsResourceContainer); }
bool isRenderSVGResourceContainer() const { return isRenderSVGModelObject() && m_typeSpecificFlags.svgFlags().contains(SVGModelObjectFlag::IsResourceContainer); }
bool isLegacyRenderSVGResourceFilter() const { return type() == Type::LegacySVGResourceFilter; }
bool isRenderSVGResourceFilter() const { return type() == Type::SVGResourceFilter; }
bool isLegacyRenderSVGResourceClipper() const { return type() == Type::LegacySVGResourceClipper; }
bool isLegacyRenderSVGResourceMarker() const { return type() == Type::LegacySVGResourceMarker; }
bool isLegacyRenderSVGResourceMasker() const { return type() == Type::LegacySVGResourceMasker; }
bool isRenderSVGResourceGradient() const { return type() == Type::SVGResourceLinearGradient || type() == Type::SVGResourceRadialGradient; }
bool isRenderSVGResourcePaintServer() const { return isRenderSVGResourceFilter() || isRenderSVGResourceGradient() || isRenderSVGResourcePattern(); }
bool isRenderSVGResourcePattern() const { return type() == Type::SVGResourcePattern; }
bool isRenderSVGResourceClipper() const { return type() == Type::SVGResourceClipper; }
bool isLegacyRenderSVGResourceFilterPrimitive() const { return type() == Type::LegacySVGResourceFilterPrimitive; }
bool isRenderSVGResourceFilterPrimitive() const { return type() == Type::SVGResourceFilterPrimitive; }
bool isRenderSVGResourceLinearGradient() const { return type() == Type::SVGResourceLinearGradient; }
bool isRenderSVGResourceMarker() const { return type() == Type::SVGResourceMarker; }
bool isRenderSVGResourceMasker() const { return type() == Type::SVGResourceMasker; }
bool isRenderSVGResourceRadialGradient() const { return type() == Type::SVGResourceRadialGradient; }
bool isRenderOrLegacyRenderSVGRoot() const { return isRenderSVGRoot() || isLegacyRenderSVGRoot(); }
bool isRenderOrLegacyRenderSVGShape() const { return isRenderSVGShape() || isLegacyRenderSVGShape(); }
bool isRenderOrLegacyRenderSVGPath() const { return isRenderSVGPath() || isLegacyRenderSVGPath(); }
bool isRenderOrLegacyRenderSVGImage() const { return isRenderSVGImage() || isLegacyRenderSVGImage(); }
bool isRenderOrLegacyRenderSVGForeignObject() const { return isRenderSVGForeignObject() || isLegacyRenderSVGForeignObject(); }
bool isRenderOrLegacyRenderSVGModelObject() const { return isRenderSVGModelObject() || isLegacyRenderSVGModelObject(); }
bool isRenderOrLegacyRenderSVGResourceFilterPrimitive() const { return isRenderSVGResourceFilterPrimitive() || isLegacyRenderSVGResourceFilterPrimitive(); }
bool isSVGLayerAwareRenderer() const { return isRenderSVGRoot() || isRenderSVGModelObject() || isRenderSVGText() || isRenderSVGInline() || isRenderSVGForeignObject(); }
bool isSVGRenderer() const { return isRenderOrLegacyRenderSVGRoot() || isRenderOrLegacyRenderSVGModelObject() || isRenderSVGBlock() || isRenderSVGInline(); }
// FIXME: Those belong into a SVG specific base-class for all renderers (see above)
// Unfortunately we don't have such a class yet, because it's not possible for all renderers
// to inherit from RenderSVGObject -> RenderObject (some need RenderBlock inheritance for instance)
void NODELETE invalidateCachedBoundaries();
bool usesBoundaryCaching() const;
virtual void NODELETE setNeedsBoundariesUpdate();
virtual void setNeedsTransformUpdate() { }
// Per SVG 1.1 objectBoundingBox ignores clipping, masking, filter effects, opacity and stroke-width.
// This is used for all computation of objectBoundingBox relative units and by SVGGraphicsElement::getBBox().
// NOTE: Markers are not specifically ignored here by SVG 1.1 spec, but we ignore them
// since stroke-width is ignored (and marker size can depend on stroke-width).
// objectBoundingBox is returned local coordinates.
// The name objectBoundingBox is taken from the SVG 1.1 spec.
virtual FloatRect objectBoundingBox() const;
virtual FloatRect strokeBoundingBox() const;
virtual bool objectBoundingBoxIsEmpty() const { return false; }
// The objectBoundingBox of a SVG container is affected by the transformations applied on its children -- the container
// bounding box is a union of all child bounding boxes, mapped through their transformation matrices.
//
// This method ignores all transformations and computes the objectBoundingBox, without mapping through the child
// transformation matrices. The SVG render tree is constructed in such a way, that it can be mapped to CSS equivalents:
// The SVG render tree underneath the outermost <svg> behaves as a set of absolutely positioned, possibly nested, boxes.
// They are laid out in such a way that transformations do NOT affect layout, as in HTML/CSS world, but take affect during
// painting, hit-testing etc. This allows to minimize the amount of re-layouts when animating transformations in SVG
// (not using CSS Animations/Transitions / Web Animations, but e.g. SMIL <animateTransform>, JS, ...).
virtual FloatRect objectBoundingBoxWithoutTransformations() const { return objectBoundingBox(); }
// Returns the smallest rectangle enclosing all of the painted content
// respecting clipping, masking, filters, opacity, stroke-width and markers
// This returns approximate rectangle for SVG renderers when RepaintRectCalculation::Fast is specified.
virtual FloatRect repaintRectInLocalCoordinates(RepaintRectCalculation = RepaintRectCalculation::Fast) const;
// Returns the bounding box including fill, stroke, and markers.
// This is the geometric visual extent, used for masks/gradients/clippers.
// Unlike repaintRectInLocalCoordinates, this is always accurate.
virtual FloatRect decoratedBoundingBox() const;
// This only returns the transform="" value from the element
// most callsites want localToParentTransform() instead.
virtual AffineTransform NODELETE localTransform() const;
// Returns the full transform mapping from local coordinates to local coords for the parent SVG renderer
// This includes any viewport transforms and x/y offsets as well as the transform="" value off the element.
virtual const AffineTransform& localToParentTransform() const LIFETIME_BOUND;
// SVG uses FloatPoint precise hit testing, and passes the point in parent
// coordinates instead of in repaint container coordinates. Eventually the
// rest of the rendering tree will move to a similar model.
virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const FloatPoint& pointInParent, HitTestAction);
bool isAnonymous() const { return m_typeFlags.contains(TypeFlag::IsAnonymous); }
bool isFloating() const { return m_stateBitfields.hasFlag(StateFlag::Floating); }
bool isPositioned() const { return m_stateBitfields.isPositioned(); }
bool isInFlowPositioned() const { return m_stateBitfields.isRelativelyPositioned() || m_stateBitfields.isStickilyPositioned(); }
bool isOutOfFlowPositioned() const { return m_stateBitfields.isOutOfFlowPositioned(); } // absolute or fixed positioning
bool isRelativelyPositioned() const { return m_stateBitfields.isRelativelyPositioned(); }
bool isStickilyPositioned() const { return m_stateBitfields.isStickilyPositioned(); }
bool isRenderText() const { return m_typeFlags.contains(TypeFlag::IsText); }
bool isRenderLineBreak() const { return type() == Type::LineBreak; }
bool isBR() const { return isRenderLineBreak() && !hasWBRLineBreakFlag(); }
bool isWBR() const { return isRenderLineBreak() && hasWBRLineBreakFlag(); }
bool isLineBreakOpportunity() const { return isRenderLineBreak() && isWBR(); }
bool isRenderTextOrLineBreak() const { return isRenderText() || isRenderLineBreak(); }
bool isRenderBox() const { return m_typeFlags.contains(TypeFlag::IsBox); }
bool isRenderTableRow() const { return type() == Type::TableRow; }
bool isRenderView() const { return type() == Type::View; }
bool isInline() const { return !m_stateBitfields.hasFlag(StateFlag::IsBlock); } // inline object
bool isBlockLevelReplacedOrAtomicInline() const { return m_stateBitfields.hasFlag(StateFlag::IsBlockLevelReplacedOrAtomicInline); }
bool isHorizontalWritingMode() const { return !m_stateBitfields.hasFlag(StateFlag::VerticalWritingMode); }
bool hasReflection() const { return hasRareData() && rareData().hasReflection; }
bool isRenderFragmentedFlow() const { return isRenderBlockFlow() && m_typeSpecificFlags.blockFlowFlags().contains(BlockFlowFlag::IsFragmentedFlow); }
bool hasOutlineAutoAncestor() const { return hasRareData() && rareData().hasOutlineAutoAncestor; }
bool paintContainmentApplies() const { return m_stateBitfields.hasFlag(StateFlag::PaintContainmentApplies); }
bool hasSVGTransform() const { return m_stateBitfields.hasFlag(StateFlag::HasSVGTransform); }
bool isExcludedFromNormalLayout() const { return m_stateBitfields.hasFlag(StateFlag::IsExcludedFromNormalLayout); }
void setIsExcludedFromNormalLayout(bool excluded) { m_stateBitfields.setFlag(StateFlag::IsExcludedFromNormalLayout, excluded); }
bool isExcludedAndPlacedInBorder() const { return isExcludedFromNormalLayout() && isLegend(); }
bool isYouTubeReplacement() const { return hasRareData() && rareData().isYouTubeReplacement; }
void markIsYouTubeReplacement();
bool hasLayer() const { return m_stateBitfields.hasFlag(StateFlag::HasLayer); }
enum class BoxDecorationState : uint8_t {
None,
InvalidObscurationStatus,
IsKnownToBeObscured,
MayBeVisible,
};
bool hasVisibleBoxDecorations() const { return boxDecorationState() != BoxDecorationState::None; }
bool needsLayout() const;
bool needsPreferredLogicalWidthsUpdate() const { return m_stateBitfields.hasFlag(StateFlag::PreferredLogicalWidthsNeedUpdate); }
bool selfNeedsLayout() const { return m_stateBitfields.hasFlag(StateFlag::NeedsLayout); }
bool needsOutOfFlowMovementLayout() const { return m_stateBitfields.hasFlag(StateFlag::NeedsOutOfFlowMovementLayout); }
bool needsOutOfFlowMovementLayoutOnly() const;
bool outOfFlowChildNeedsLayout() const { return m_stateBitfields.hasFlag(StateFlag::OutOfFlowChildNeedsLayout); }
bool needsSimplifiedNormalFlowLayout() const { return m_stateBitfields.hasFlag(StateFlag::NeedsSimplifiedNormalFlowLayout); }
bool needsSimplifiedNormalFlowLayoutOnly() const;
bool needsNormalChildOrSimplifiedLayoutOnly() const;
bool normalChildNeedsLayout() const { return m_stateBitfields.hasFlag(StateFlag::NormalChildNeedsLayout); }
bool outOfFlowChildNeedsStaticPositionLayout() const { return m_stateBitfields.hasFlag(StateFlag::OutOfFlowChildNeedsStaticPositionLayout); }
bool NODELETE isSelectionBorder() const;
bool hasNonVisibleOverflow() const { return m_stateBitfields.hasFlag(StateFlag::HasNonVisibleOverflow); }
bool hasTransformRelatedProperty() const { return m_stateBitfields.hasFlag(StateFlag::HasTransformRelatedProperty); } // Transform, perspective or transform-style: preserve-3d.
inline bool isTransformed() const; // Defined in RenderObjectStyle.h
inline bool hasTransformOrPerspective() const; // Defined in RenderObjectStyle.h
bool capturedInViewTransition() const { return m_stateBitfields.hasFlag(StateFlag::CapturedInViewTransition); }
bool setCapturedInViewTransition(bool);
// When the document element is captured, the captured contents uses the RenderView
// instead. Returns the capture state with this adjustment applied.
bool effectiveCapturedInViewTransition() const;
inline RenderView& NODELETE view() const LIFETIME_BOUND; // Defined in RenderObjectDocument.h
inline LocalFrameViewLayoutContext& layoutContext() const;
HostWindow* hostWindow() const;
// Returns true if this renderer is rooted.
bool NODELETE isRooted() const;
inline Node* node() const; // Defined in RenderObjectNode.h
inline Node* nonPseudoNode() const; // Defined in RenderObjectNode.h
inline Document& document() const; // Defined in RenderObjectDocument.h
inline TreeScope& treeScopeForSVGReferences() const; // Defined in RenderObjectInlines.h
inline LocalFrame& frame() const; // Defined in RenderObjectInlines.h
inline Page& page() const; // Defined in RenderObjectInlines.h
inline const Settings& settings() const; // Defined in RenderObjectDocument.h
// Returns the object containing this one. Can be different from parent for positioned elements.
// If repaintContainer and repaintContainerSkipped are not null, on return *repaintContainerSkipped
// is true if the renderer returned is an ancestor of repaintContainer.
RenderElement* container() const;
RenderElement* container(const RenderLayerModelObject* repaintContainer, bool& repaintContainerSkipped) const;
RenderElement* markContainingBlocksForLayout(RenderElement* layoutRoot = nullptr);
inline void setNeedsLayout(MarkingBehavior = MarkContainingBlockChain);
enum class HadSkippedLayout { No, Yes };
void clearNeedsLayout(HadSkippedLayout = HadSkippedLayout::No);
void setNeedsPreferredWidthsUpdate(MarkingBehavior = MarkContainingBlockChain);
void clearNeedsPreferredWidthsUpdate() { m_stateBitfields.setFlag(StateFlag::PreferredLogicalWidthsNeedUpdate, { }); }
inline void setNeedsLayoutAndPreferredWidthsUpdate();
void setPositionState(PositionType);
void clearPositionedState() { m_stateBitfields.clearPositionedState(); }
void setFloating(bool b = true) { m_stateBitfields.setFlag(StateFlag::Floating, b); }
void setInline(bool b) { m_stateBitfields.setFlag(StateFlag::IsBlock, !b); }
void setHasVisibleBoxDecorations(bool = true);
void invalidateBackgroundObscurationStatus();
void setBlockLevelReplacedOrAtomicInline(bool b = true) { m_stateBitfields.setFlag(StateFlag::IsBlockLevelReplacedOrAtomicInline, b); }
void setHorizontalWritingMode(bool b = true) { m_stateBitfields.setFlag(StateFlag::VerticalWritingMode, !b); }
void setHasNonVisibleOverflow(bool b = true) { m_stateBitfields.setFlag(StateFlag::HasNonVisibleOverflow, b); }
void setHasLayer(bool b = true) { m_stateBitfields.setFlag(StateFlag::HasLayer, b); }
void setHasTransformRelatedProperty(bool b = true) { m_stateBitfields.setFlag(StateFlag::HasTransformRelatedProperty, b); }
void setHasReflection(bool = true);
void setHasOutlineAutoAncestor(bool = true);
void setPaintContainmentApplies(bool value = true) { m_stateBitfields.setFlag(StateFlag::PaintContainmentApplies, value); }
void setHasSVGTransform(bool value = true) { m_stateBitfields.setFlag(StateFlag::HasSVGTransform, value); }
// used for element state updates that cannot be fixed with a
// repaint and do not need a relayout
virtual void updateFromElement() { }
bool NODELETE isComposited() const;
bool hitTest(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestFilter = HitTestAll);
virtual Node* nodeForHitTest() const;
virtual void updateHitTestResult(HitTestResult&, const LayoutPoint&) const;
virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
virtual Position positionForPoint(const LayoutPoint&, HitTestSource);
virtual PositionWithAffinity positionForPoint(const LayoutPoint&, HitTestSource, const RenderFragmentContainer*);
PositionWithAffinity createPositionWithAffinity(int offset, Affinity) const;
PositionWithAffinity createPositionWithAffinity(const Position&) const;
WEBCORE_EXPORT VisiblePosition visiblePositionForPoint(const LayoutPoint&, HitTestSource);
// Returns the containing block level element for this element.
WEBCORE_EXPORT RenderBlock* containingBlock() const;
static RenderBlock* containingBlockForPositionType(PositionType, const RenderObject&);
// Convert the given local point to absolute coordinates. If OptionSet<MapCoordinatesMode> includes UseTransforms, take transforms into account.
WEBCORE_EXPORT FloatPoint localToAbsolute(const FloatPoint& localPoint = FloatPoint(), OptionSet<MapCoordinatesMode> = { }, bool* wasFixed = nullptr) const;
TransformState viewTransitionTransform() const;
FloatPoint absoluteToLocal(const DoublePoint&, OptionSet<MapCoordinatesMode> = { }) const;
// Convert a local quad to absolute coordinates, taking transforms into account.
inline FloatQuad localToAbsoluteQuad(const FloatQuad&, OptionSet<MapCoordinatesMode> = UseTransforms, bool* wasFixed = nullptr) const; // Defined in RenderObjectInlines.h
// Convert an absolute quad to local coordinates.
FloatQuad absoluteToLocalQuad(const FloatQuad&, OptionSet<MapCoordinatesMode> = UseTransforms) const;
// Convert a local quad into the coordinate system of container, taking transforms into account.
WEBCORE_EXPORT FloatQuad localToContainerQuad(const FloatQuad&, const RenderLayerModelObject* container, OptionSet<MapCoordinatesMode> = UseTransforms, bool* wasFixed = nullptr) const;
WEBCORE_EXPORT FloatPoint localToContainerPoint(const FloatPoint&, const RenderLayerModelObject* container, OptionSet<MapCoordinatesMode> = UseTransforms, bool* wasFixed = nullptr) const;
// Return the offset from the container() renderer (excluding transforms). In multi-column layout,
// different offsets apply at different points, so return the offset that applies to the given point.
virtual LayoutSize offsetFromContainer(const RenderElement&, const LayoutPoint&, bool* offsetDependsOnPoint = nullptr) const;
// Return the offset from an object up the container() chain. Asserts that none of the intermediate objects have transforms.
LayoutSize offsetFromAncestorContainer(const RenderElement&) const;
virtual void collectSelectionGeometries(Vector<SelectionGeometry>&, unsigned startOffset = 0, unsigned endOffset = std::numeric_limits<unsigned>::max());
virtual void absoluteQuadsForSelection(Vector<FloatQuad>& quads) const { absoluteQuads(quads); }
struct SelectionGeometries {
Vector<SelectionGeometry> geometries;
Vector<PlatformLayerIdentifier> intersectingLayerIDs;
};
WEBCORE_EXPORT static SelectionGeometries collectSelectionGeometries(const SimpleRange&);
WEBCORE_EXPORT static Vector<SelectionGeometry> collectSelectionGeometriesWithoutUnionInteriorLines(const SimpleRange&);
virtual void boundingRects(Vector<LayoutRect>&, const LayoutPoint& /* offsetFromRoot */) const { }
WEBCORE_EXPORT IntRect absoluteBoundingBoxRect(bool useTransform = true, bool* wasFixed = nullptr) const;
IntRect absoluteBoundingBoxRectIgnoringTransforms() const { return absoluteBoundingBoxRect(false); }
// Build an array of quads in absolute coords for line boxes
virtual void absoluteQuads(Vector<FloatQuad>&, bool* /*wasFixed*/ = nullptr) const { }
virtual void absoluteFocusRingQuads(Vector<FloatQuad>&);
enum class BoundingRectBehavior : uint8_t {
RespectClipping = 1 << 0,
UseVisibleBounds = 1 << 1,
IgnoreTinyRects = 1 << 2,
IgnoreEmptyTextSelections = 1 << 3,
UseSelectionHeight = 1 << 4,
ComputeIndividualCharacterRects = 1 << 5,
};
WEBCORE_EXPORT static Vector<FloatQuad> absoluteTextQuads(const SimpleRange&, OptionSet<BoundingRectBehavior> = { });
WEBCORE_EXPORT static Vector<IntRect> absoluteTextRects(const SimpleRange&, OptionSet<BoundingRectBehavior> = { });
WEBCORE_EXPORT static Vector<FloatRect> absoluteBorderAndTextRects(const SimpleRange&, OptionSet<BoundingRectBehavior> = { });
static Vector<FloatRect> clientBorderAndTextRects(const SimpleRange&);
// the rect that will be painted if this object is passed as the paintingRoot
WEBCORE_EXPORT LayoutRect paintingRootRect(LayoutRect& topLevelRect);
inline const RenderStyle& style() const LIFETIME_BOUND; // Defined in RenderObjectStyle.h.
inline CheckedRef<const RenderStyle> firstLineStyle() const LIFETIME_BOUND;
inline WritingMode writingMode() const; // Defined in RenderObjectStyle.h.
// writingMode().isHorizontal() is cached by isHorizontalWritingMode() above.
virtual const RenderStyle& outlineStyleForRepaint() const LIFETIME_BOUND;
virtual CursorDirective getCursor(const LayoutPoint&, Cursor&) const;
// Return the RenderLayerModelObject in the container chain which is responsible for painting this object, or nullptr
// if painting is root-relative. This is the container that should be passed to the 'forRepaint' functions.
struct RepaintContainerStatus {
bool fullRepaintIsScheduled { false }; // Either the repaint container or a layer in-between has already been scheduled for full repaint.
CheckedPtr<const RenderLayerModelObject> renderer { nullptr };
};
RepaintContainerStatus containerForRepaint() const;
// Actually do the repaint of rect r for this object which has been computed in the coordinate space
// of repaintContainer. If repaintContainer is nullptr, repaint via the view.
void repaintUsingContainer(SingleThreadWeakPtr<const RenderLayerModelObject>&& repaintContainer, const LayoutRect&, bool shouldClipToLayer = true) const;
// Repaint the entire object. Called when, e.g., the color of a border changes, or when a border
// style changes.
enum class ForceRepaint : bool { No, Yes };
void repaint(ForceRepaint = ForceRepaint::No) const;
// Repaint a specific subrectangle within a given object. The rect |r| is in the object's coordinate space.
WEBCORE_EXPORT void repaintRectangle(const LayoutRect&, bool shouldClipToLayer = true) const;
enum class ClipRepaintToLayer : bool { No, Yes };
void repaintRectangle(const LayoutRect&, ClipRepaintToLayer, ForceRepaint, std::optional<LayoutBoxExtent> additionalRepaintOutsets = std::nullopt) const;
// Repaint a slow repaint object, which, at this time, means we are repainting an object with background-attachment:fixed.
void repaintSlowRepaintObject() const;
struct RepaintRects {
LayoutRect clippedOverflowRect; // Some rect (normally the visual overflow rect) mapped up to the repaint container, respecting clipping.
std::optional<LayoutRect> outlineBoundsRect; // A rect representing the extent of outlines and shadows, mapped to the repaint container, but not clipped.
RepaintRects(LayoutRect rect = { }, const std::optional<LayoutRect>& outlineBounds = { })
: clippedOverflowRect(rect)
, outlineBoundsRect(outlineBounds)
{ }
bool operator==(const RepaintRects&) const = default;
void move(LayoutSize size)
{
clippedOverflowRect.move(size);
if (outlineBoundsRect)
outlineBoundsRect->move(size);
}
void moveBy(LayoutPoint size)
{
clippedOverflowRect.moveBy(size);
if (outlineBoundsRect)
outlineBoundsRect->moveBy(size);
}
void expand(LayoutSize size)
{
clippedOverflowRect.expand(size);
if (outlineBoundsRect)
outlineBoundsRect->expand(size);
}
void encloseToIntRects()
{
clippedOverflowRect = enclosingIntRect(clippedOverflowRect);
if (outlineBoundsRect)
*outlineBoundsRect = enclosingIntRect(*outlineBoundsRect);
}
void unite(const RepaintRects& other)
{
clippedOverflowRect.unite(other.clippedOverflowRect);
if (outlineBoundsRect && other.outlineBoundsRect)
outlineBoundsRect->unite(*other.outlineBoundsRect);
}
void flipForWritingMode(LayoutSize containerSize, bool isHorizontalWritingMode)
{
if (isHorizontalWritingMode) {
clippedOverflowRect.setY(containerSize.height() - clippedOverflowRect.maxY());
if (outlineBoundsRect)
outlineBoundsRect->setY(containerSize.height() - outlineBoundsRect->maxY());
} else {
clippedOverflowRect.setX(containerSize.width() - clippedOverflowRect.maxX());
if (outlineBoundsRect)
outlineBoundsRect->setX(containerSize.width() - outlineBoundsRect->maxX());
}
}
// Returns true if intersecting (clippedOverflowRect remains non-empty).
bool intersect(LayoutRect clipRect)
{
// Note the we only intersect clippedOverflowRect.
clippedOverflowRect.intersect(clipRect);
return !clippedOverflowRect.isEmpty();
}
// Returns true if intersecting (clippedOverflowRect remains non-empty).
bool edgeInclusiveIntersect(LayoutRect clipRect)
{
// Note the we only intersect clippedOverflowRect.
return clippedOverflowRect.edgeInclusiveIntersect(clipRect);
}
void transform(const TransformationMatrix&);
void transform(const TransformationMatrix&, float deviceScaleFactor);
};
// Returns the rect that should be repainted whenever this object changes. The rect is in the view's
// coordinate space. This method deals with outlines and overflow.
inline LayoutRect absoluteClippedOverflowRectForRepaint() const;
inline LayoutRect absoluteClippedOverflowRectForSpatialNavigation() const;
inline LayoutRect absoluteClippedOverflowRectForRenderTreeAsText() const;
WEBCORE_EXPORT IntRect pixelSnappedAbsoluteClippedOverflowRect() const;
virtual LayoutRect clippedOverflowRect(const RenderLayerModelObject* repaintContainer, VisibleRectContext) const;
inline LayoutRect clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const;
virtual LayoutRect rectWithOutlineForRepaint(const RenderLayerModelObject* repaintContainer, LayoutUnit outlineWidth) const;
virtual LayoutRect outlineBoundsForRepaint(const RenderLayerModelObject* /*repaintContainer*/, const RenderGeometryMap* = nullptr) const { return { }; }
// Given a rect in the object's coordinate space, compute a rect in the coordinate space
// of repaintContainer suitable for the given VisibleRectContext.
RepaintRects computeRects(const RepaintRects&, const RenderLayerModelObject* repaintContainer, VisibleRectContext) const;
inline LayoutRect computeRectForRepaint(const LayoutRect& rect, const RenderLayerModelObject* repaintContainer) const;
FloatRect computeFloatRectForRepaint(const FloatRect&, const RenderLayerModelObject* repaintContainer) const;
virtual RepaintRects rectsForRepaintingAfterLayout(const RenderLayerModelObject* repaintContainer, RepaintOutlineBounds) const;
// Given a rect in the object's coordinate space, compute the location in container space where this rect is visible,
// when clipping and scrolling as specified by the context. When using edge-inclusive intersection, return std::nullopt
// rather than an empty rect if the rect is completely clipped out in container space.
virtual std::optional<RepaintRects> computeVisibleRectsInContainer(const RepaintRects&, const RenderLayerModelObject* repaintContainer, VisibleRectContext) const;