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 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278
|
/*
* Copyright (C) 2000 Lars Knoll (knoll@kde.org)
* (C) 2000 Antti Koivisto (koivisto@kde.org)
* (C) 2000 Dirk Mueller (mueller@kde.org)
* (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com)
* 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 "CachedImageClient.h"
#include "Element.h"
#include "FloatQuad.h"
#include "FrameDestructionObserverInlines.h"
#include "HTMLNames.h"
#include "InspectorInstrumentationPublic.h"
#include "LayoutRect.h"
#include "LocalFrame.h"
#include "Page.h"
#include "RenderObjectEnums.h"
#include "RenderStyle.h"
#include "ScrollAlignment.h"
#include "StyleImage.h"
#include "TextAffinity.h"
#include <wtf/CheckedPtr.h>
#include <wtf/IsoMalloc.h>
namespace WTF {
class TextStream;
}
namespace WebCore {
class AffineTransform;
class Color;
class ControlPart;
class Cursor;
class Document;
class HitTestLocation;
class HitTestRequest;
class HitTestResult;
class HostWindow;
class LegacyInlineBox;
class Path;
class Position;
class ReferencedSVGResources;
class RenderBoxModelObject;
class RenderInline;
class RenderBlock;
class RenderBlockFlow;
class RenderElement;
class RenderFragmentedFlow;
class RenderGeometryMap;
class RenderLayer;
class RenderLayerModelObject;
class RenderFragmentContainer;
class RenderTheme;
class RenderTreeBuilder;
class HighlightData;
class TransformState;
class VisiblePosition;
#if PLATFORM(IOS_FAMILY)
class SelectionGeometry;
#endif
struct InlineBoxAndOffset;
struct PaintInfo;
struct SimpleRange;
struct ScrollRectToVisibleOptions;
namespace Layout {
class Box;
}
namespace Style {
class PseudoElementRequest;
}
// Base class for all rendering tree objects.
class RenderObject : public CachedImageClient {
WTF_MAKE_ISO_ALLOCATED(RenderObject);
friend class RenderBlock;
friend class RenderBlockFlow;
friend class RenderBox;
friend class RenderElement;
friend class RenderLayer;
friend class RenderLayerScrollableArea;
public:
// Anonymous objects should pass the document as their node, and they will then automatically be
// marked as anonymous in the constructor.
explicit RenderObject(Node&);
virtual ~RenderObject();
Layout::Box* layoutBox() { return m_layoutBox.get(); }
const Layout::Box* layoutBox() const { return m_layoutBox.get(); }
void setLayoutBox(Layout::Box&);
void clearLayoutBox();
RenderTheme& theme() const;
virtual ASCIILiteral renderName() const = 0;
RenderElement* parent() const { return m_parent; }
bool isDescendantOf(const RenderObject*) const;
RenderObject* previousSibling() const { return m_previous; }
RenderObject* nextSibling() const { return m_next; }
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* 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* enclosingLayer() const;
WEBCORE_EXPORT RenderBox& enclosingBox() const;
RenderBoxModelObject& enclosingBoxModelObject() const;
RenderBox* enclosingScrollableContainerForSnapping() 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;
OptionSet<StyleColorOptions> styleColorOptions() const;
#if ASSERT_ENABLED
void setHasAXObject(bool flag) { m_hasAXObject = flag; }
bool hasAXObject() const { return m_hasAXObject; }
#endif
// 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 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
bool isPseudoElement() const { return node() && node()->isPseudoElement(); }
bool isRenderElement() const { return !isText(); }
bool isRenderReplaced() const;
bool isBoxModelObject() const;
bool isRenderBlock() const;
bool isRenderBlockFlow() const;
bool isRenderInline() const;
bool isRenderLayerModelObject() const;
inline bool isAtomicInlineLevelBox() const;
virtual bool isCounter() const { return false; }
virtual bool isQuote() const { return false; }
virtual bool isDetailsMarker() const { return false; }
virtual bool isEmbeddedObject() const { return false; }
bool isFieldset() const;
virtual bool isFileUploadControl() const { return false; }
virtual bool isFrame() const { return false; }
virtual bool isFrameSet() const { return false; }
virtual bool isImage() const { return false; }
virtual bool isInlineBlockOrInlineTable() const { return false; }
virtual bool isListBox() const { return false; }
virtual bool isListItem() const { return false; }
virtual bool isListMarker() const { return false; }
virtual bool isMedia() const { return false; }
virtual bool isMenuList() const { return false; }
virtual bool isMeter() const { return false; }
virtual bool isProgress() const { return false; }
virtual bool isRenderButton() const { return false; }
virtual bool isRenderIFrame() const { return false; }
virtual bool isRenderImage() const { return false; }
#if ENABLE(MODEL_ELEMENT)
virtual bool isRenderModel() const { return false; }
#endif
virtual bool isRenderFragmentContainer() const { return false; }
virtual bool isReplica() const { return false; }
virtual bool isRubyInline() const { return false; }
virtual bool isRubyBlock() const { return false; }
virtual bool isRubyBase() const { return false; }
virtual bool isRubyRun() const { return false; }
virtual bool isRubyText() const { return false; }
virtual bool isSlider() const { return false; }
virtual bool isTable() const { return false; }
virtual bool isTableCell() const { return false; }
virtual bool isRenderTableCol() const { return false; }
virtual bool isTableCaption() const { return false; }
virtual bool isTableSection() const { return false; }
virtual bool isTextControl() const { return false; }
virtual bool isTextArea() const { return false; }
virtual bool isTextField() const { return false; }
virtual bool isSearchField() const { return false; }
virtual bool isTextControlInnerBlock() const { return false; }
virtual bool isVideo() const { return false; }
virtual bool isWidget() const { return false; }
virtual bool isCanvas() const { return false; }
#if ENABLE(ATTACHMENT_ELEMENT)
virtual bool isAttachment() const { return false; }
#endif
virtual bool isRenderGrid() const { return false; }
virtual bool isMultiColumnBlockFlow() const { return false; }
virtual bool isRenderMultiColumnSet() const { return false; }
virtual bool isRenderMultiColumnFlow() const { return false; }
virtual bool isRenderMultiColumnSpannerPlaceholder() const { return false; }
virtual bool isRenderScrollbarPart() const { return false; }
virtual bool isRenderVTTCue() const { return false; }
bool isDocumentElementRenderer() const { return document().documentElement() == m_node; }
bool isBody() const { return node() && node()->hasTagName(HTMLNames::bodyTag); }
bool isHR() const { return node() && node()->hasTagName(HTMLNames::hrTag); }
bool isLegend() const;
bool isHTMLMarquee() const;
bool isTablePart() const { return isTableCell() || isRenderTableCol() || isTableCaption() || isTableRow() || isTableSection(); }
inline bool isBeforeContent() const;
inline bool isAfterContent() const;
inline bool isBeforeOrAfterContent() const;
static inline bool isBeforeContent(const RenderObject* obj) { return obj && obj->isBeforeContent(); }
static inline bool isAfterContent(const RenderObject* obj) { return obj && obj->isAfterContent(); }
static inline bool isBeforeOrAfterContent(const RenderObject* obj) { return obj && obj->isBeforeOrAfterContent(); }
bool beingDestroyed() const { return m_bitfields.beingDestroyed(); }
bool everHadLayout() const { return m_bitfields.everHadLayout(); }
bool childrenInline() const { return m_bitfields.childrenInline(); }
virtual void setChildrenInline(bool b) { m_bitfields.setChildrenInline(b); }
enum FragmentedFlowState {
NotInsideFragmentedFlow = 0,
InsideInFragmentedFlow = 1,
};
enum class SkipDescendentFragmentedFlow { No, Yes };
void setFragmentedFlowStateIncludingDescendants(FragmentedFlowState, SkipDescendentFragmentedFlow = SkipDescendentFragmentedFlow::Yes);
FragmentedFlowState fragmentedFlowState() const { return m_bitfields.fragmentedFlowState(); }
void setFragmentedFlowState(FragmentedFlowState state) { m_bitfields.setFragmentedFlowState(state); }
#if ENABLE(MATHML)
virtual bool isRenderMathMLBlock() const { return false; }
virtual bool isRenderMathMLTable() const { return false; }
virtual bool isRenderMathMLOperator() const { return false; }
virtual bool isRenderMathMLRow() const { return false; }
virtual bool isRenderMathMLMath() const { return false; }
virtual bool isRenderMathMLMenclose() const { return false; }
virtual bool isRenderMathMLFenced() const { return false; }
virtual bool isRenderMathMLFencedOperator() const { return false; }
virtual bool isRenderMathMLFraction() const { return false; }
virtual bool isRenderMathMLPadded() const { return false; }
virtual bool isRenderMathMLRoot() const { return false; }
virtual bool isRenderMathMLSpace() const { return false; }
virtual bool isRenderMathMLSquareRoot() const { return false; }
virtual bool isRenderMathMLScripts() const { return false; }
virtual bool isRenderMathMLToken() const { return false; }
virtual bool isRenderMathMLUnderOver() const { return false; }
#endif // ENABLE(MATHML)
virtual bool isLegacyRenderSVGModelObject() const { return false; }
virtual bool isRenderSVGModelObject() const { return false; }
virtual bool isRenderSVGBlock() const { return false; };
virtual bool isLegacySVGRoot() const { return false; }
virtual bool isSVGRoot() const { return false; }
virtual bool isSVGContainer() const { return false; }
virtual bool isLegacySVGContainer() const { return false; }
virtual bool isSVGTransformableContainer() const { return false; }
virtual bool isLegacySVGTransformableContainer() const { return false; }
virtual bool isSVGViewportContainer() const { return false; }
virtual bool isLegacySVGViewportContainer() const { return false; }
virtual bool isSVGGradientStop() const { return false; }
virtual bool isLegacySVGHiddenContainer() const { return false; }
virtual bool isSVGHiddenContainer() const { return false; }
virtual bool isLegacySVGPath() const { return false; }
virtual bool isSVGPath() const { return false; }
virtual bool isSVGShape() const { return false; }
virtual bool isLegacySVGShape() const { return false; }
virtual bool isSVGText() const { return false; }
virtual bool isSVGTextPath() const { return false; }
virtual bool isSVGTSpan() const { return false; }
virtual bool isSVGInline() const { return false; }
virtual bool isSVGInlineText() const { return false; }
virtual bool isLegacySVGImage() const { return false; }
virtual bool isSVGImage() const { return false; }
virtual bool isLegacySVGForeignObject() const { return false; }
virtual bool isSVGForeignObject() const { return false; }
virtual bool isSVGResourceContainer() const { return false; }
virtual bool isSVGResourceFilter() const { return false; }
virtual bool isSVGResourceClipper() const { return false; }
virtual bool isSVGResourceFilterPrimitive() const { return false; }
bool isSVGRootOrLegacySVGRoot() const { return isSVGRoot() || isLegacySVGRoot(); }
bool isSVGShapeOrLegacySVGShape() const { return isSVGShape() || isLegacySVGShape(); }
bool isSVGPathOrLegacySVGPath() const { return isSVGPath() || isLegacySVGPath(); }
bool isSVGImageOrLegacySVGImage() const { return isSVGImage() || isLegacySVGImage(); }
bool isSVGForeignObjectOrLegacySVGForeignObject() const { return isSVGForeignObject() || isLegacySVGForeignObject(); }
bool isRenderOrLegacyRenderSVGModelObject() const { return isRenderSVGModelObject() || isLegacyRenderSVGModelObject(); }
bool isSVGLayerAwareRenderer() const { return isSVGRoot() || isRenderSVGModelObject() || isSVGText() || isSVGInline() || isSVGForeignObject(); }
// 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)
virtual void setNeedsTransformUpdate() { }
virtual void setNeedsBoundariesUpdate();
virtual bool needsBoundariesUpdate() { return false; }
// 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 SVGLocatable::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;
#if ENABLE(LAYER_BASED_SVG_ENGINE)
// 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(); }
#endif
// Returns the smallest rectangle enclosing all of the painted content
// respecting clipping, masking, filters, opacity, stroke-width and markers
virtual FloatRect repaintRectInLocalCoordinates() const;
// This only returns the transform="" value from the element
// most callsites want localToParentTransform() instead.
virtual AffineTransform 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;
// 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);
virtual bool hasIntrinsicAspectRatio() const { return isReplacedOrInlineBlock() && (isImage() || isVideo() || isCanvas()); }
bool isAnonymous() const { return m_bitfields.isAnonymous(); }
bool isAnonymousBlock() const;
bool isBlockContainer() const;
bool isFloating() const { return m_bitfields.floating(); }
bool isPositioned() const { return m_bitfields.isPositioned(); }
bool isInFlowPositioned() const { return m_bitfields.isRelativelyPositioned() || m_bitfields.isStickilyPositioned(); }
bool isOutOfFlowPositioned() const { return m_bitfields.isOutOfFlowPositioned(); } // absolute or fixed positioning
bool isFixedPositioned() const { return isOutOfFlowPositioned() && style().position() == PositionType::Fixed; }
bool isAbsolutelyPositioned() const { return isOutOfFlowPositioned() && style().position() == PositionType::Absolute; }
bool isRelativelyPositioned() const { return m_bitfields.isRelativelyPositioned(); }
bool isStickilyPositioned() const { return m_bitfields.isStickilyPositioned(); }
bool shouldUsePositionedClipping() const { return isAbsolutelyPositioned() || isSVGForeignObject(); }
bool isText() const { return !m_bitfields.isBox() && m_bitfields.isTextOrRenderView(); }
bool isLineBreak() const { return m_bitfields.isLineBreak(); }
bool isBR() const { return isLineBreak() && !isWBR(); }
bool isLineBreakOpportunity() const { return isLineBreak() && isWBR(); }
bool isTextOrLineBreak() const { return isText() || isLineBreak(); }
bool isBox() const { return m_bitfields.isBox(); }
bool isTableRow() const { return m_bitfields.isTableRow(); }
bool isRenderView() const { return m_bitfields.isBox() && m_bitfields.isTextOrRenderView(); }
bool isInline() const { return m_bitfields.isInline(); } // inline object
bool isReplacedOrInlineBlock() const { return m_bitfields.isReplacedOrInlineBlock(); }
bool isHorizontalWritingMode() const { return m_bitfields.horizontalWritingMode(); }
bool hasReflection() const { return m_bitfields.hasRareData() && rareData().hasReflection(); }
bool isRenderFragmentedFlow() const { return m_bitfields.hasRareData() && rareData().isRenderFragmentedFlow(); }
bool hasOutlineAutoAncestor() const { return m_bitfields.hasRareData() && rareData().hasOutlineAutoAncestor(); }
bool paintContainmentApplies() const { return m_bitfields.hasRareData() && rareData().paintContainmentApplies(); }
#if ENABLE(LAYER_BASED_SVG_ENGINE)
bool hasSVGTransform() const { return m_bitfields.hasRareData() && rareData().hasSVGTransform(); }
#else
bool hasSVGTransform() const { return false; }
#endif
bool isExcludedFromNormalLayout() const { return m_bitfields.isExcludedFromNormalLayout(); }
void setIsExcludedFromNormalLayout(bool excluded) { m_bitfields.setIsExcludedFromNormalLayout(excluded); }
bool isExcludedAndPlacedInBorder() const { return isExcludedFromNormalLayout() && isLegend(); }
bool hasLayer() const { return m_bitfields.hasLayer(); }
enum BoxDecorationState {
NoBoxDecorations,
HasBoxDecorationsAndBackgroundObscurationStatusInvalid,
HasBoxDecorationsAndBackgroundIsKnownToBeObscured,
HasBoxDecorationsAndBackgroundMayBeVisible,
};
bool hasVisibleBoxDecorations() const { return m_bitfields.boxDecorationState() != NoBoxDecorations; }
bool backgroundIsKnownToBeObscured(const LayoutPoint& paintOffset);
bool needsLayout() const;
bool selfNeedsLayout() const { return m_bitfields.needsLayout(); }
bool needsPositionedMovementLayout() const { return m_bitfields.needsPositionedMovementLayout(); }
bool needsPositionedMovementLayoutOnly() const;
bool posChildNeedsLayout() const { return m_bitfields.posChildNeedsLayout(); }
bool needsSimplifiedNormalFlowLayout() const { return m_bitfields.needsSimplifiedNormalFlowLayout(); }
bool needsSimplifiedNormalFlowLayoutOnly() const;
bool normalChildNeedsLayout() const { return m_bitfields.normalChildNeedsLayout(); }
bool preferredLogicalWidthsDirty() const { return m_bitfields.preferredLogicalWidthsDirty(); }
bool isSelectionBorder() const;
bool hasNonVisibleOverflow() const { return m_bitfields.hasNonVisibleOverflow(); }
bool hasPotentiallyScrollableOverflow() const;
bool hasTransformRelatedProperty() const { return m_bitfields.hasTransformRelatedProperty(); } // Transform, perspective or transform-style: preserve-3d.
inline bool isTransformed() const;
inline bool hasTransformOrPerspective() const;
inline bool preservesNewline() const;
RenderView& view() const { return *document().renderView(); };
HostWindow* hostWindow() const;
// Returns true if this renderer is rooted.
bool isRooted() const;
Node* node() const
{
if (isAnonymous())
return nullptr;
ASSERT(m_node);
return m_node.get();
}
Node* nonPseudoNode() const { return isPseudoElement() ? nullptr : node(); }
// Returns the styled node that caused the generation of this renderer.
// This is the same as node() except for renderers of :before and :after
// pseudo elements for which their parent node is returned.
Node* generatingNode() const { return isPseudoElement() ? generatingPseudoHostElement() : node(); }
Document& document() const { ASSERT(m_node); return m_node->document(); }
TreeScope& treeScopeForSVGReferences() const { ASSERT(m_node); return m_node->treeScopeForSVGReferences(); }
LocalFrame& frame() const;
Page& page() const;
Settings& settings() const { return page().settings(); }
// 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;
RenderBoxModelObject* offsetParent() const;
void markContainingBlocksForLayout(ScheduleRelayout = ScheduleRelayout::Yes, RenderElement* newRoot = nullptr);
void setNeedsLayout(MarkingBehavior = MarkContainingBlockChain);
void clearNeedsLayout();
void setPreferredLogicalWidthsDirty(bool, MarkingBehavior = MarkContainingBlockChain);
void invalidateContainerPreferredLogicalWidths();
void setNeedsLayoutAndPrefWidthsRecalc();
void setPositionState(PositionType);
void clearPositionedState() { m_bitfields.clearPositionedState(); }
void setFloating(bool b = true) { m_bitfields.setFloating(b); }
void setInline(bool b = true) { m_bitfields.setIsInline(b); }
void setHasVisibleBoxDecorations(bool = true);
void invalidateBackgroundObscurationStatus();
virtual bool computeBackgroundIsKnownToBeObscured(const LayoutPoint&) { return false; }
void setIsText() { ASSERT(!isBox()); m_bitfields.setIsTextOrRenderView(true); }
void setIsLineBreak() { m_bitfields.setIsLineBreak(true); }
void setIsBox() { m_bitfields.setIsBox(true); }
void setIsTableRow() { m_bitfields.setIsTableRow(true); }
void setIsRenderView() { ASSERT(isBox()); m_bitfields.setIsTextOrRenderView(true); }
void setReplacedOrInlineBlock(bool b = true) { m_bitfields.setIsReplacedOrInlineBlock(b); }
void setHorizontalWritingMode(bool b = true) { m_bitfields.setHorizontalWritingMode(b); }
void setHasNonVisibleOverflow(bool b = true) { m_bitfields.setHasNonVisibleOverflow(b); }
void setHasLayer(bool b = true) { m_bitfields.setHasLayer(b); }
void setHasTransformRelatedProperty(bool b = true) { m_bitfields.setHasTransformRelatedProperty(b); }
void setHasReflection(bool = true);
void setIsRenderFragmentedFlow(bool = true);
void setHasOutlineAutoAncestor(bool = true);
void setPaintContainmentApplies(bool = true);
#if ENABLE(LAYER_BASED_SVG_ENGINE)
void setHasSVGTransform(bool = true);
#endif
// Hook so that RenderTextControl can return the line height of its inner renderer.
// For other renderers, the value is the same as lineHeight(false).
virtual int innerLineHeight() const;
// used for element state updates that cannot be fixed with a
// repaint and do not need a relayout
virtual void updateFromElement() { }
bool 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&);
virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
virtual Position positionForPoint(const LayoutPoint&);
virtual VisiblePosition positionForPoint(const LayoutPoint&, const RenderFragmentContainer*);
VisiblePosition createVisiblePosition(int offset, Affinity) const;
VisiblePosition createVisiblePosition(const Position&) const;
// 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;
FloatPoint absoluteToLocal(const FloatPoint&, OptionSet<MapCoordinatesMode> = { }) const;
// Convert a local quad to absolute coordinates, taking transforms into account.
FloatQuad localToAbsoluteQuad(const FloatQuad&, OptionSet<MapCoordinatesMode> = UseTransforms, bool* wasFixed = nullptr) const;
// 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(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;
#if PLATFORM(IOS_FAMILY)
virtual void collectSelectionGeometries(Vector<SelectionGeometry>&, unsigned startOffset = 0, unsigned endOffset = std::numeric_limits<unsigned>::max());
virtual void absoluteQuadsForSelection(Vector<FloatQuad>& quads) const { absoluteQuads(quads); }
WEBCORE_EXPORT static Vector<SelectionGeometry> collectSelectionGeometries(const SimpleRange&);
WEBCORE_EXPORT static Vector<SelectionGeometry> collectSelectionGeometriesWithoutUnionInteriorLines(const SimpleRange&);
#endif
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);
virtual LayoutUnit minPreferredLogicalWidth() const { return 0; }
virtual LayoutUnit maxPreferredLogicalWidth() const { return 0; }
const RenderStyle& style() const;
const RenderStyle& firstLineStyle() const;
// Anonymous blocks that are part of of a continuation chain will return their inline continuation's outline style instead.
// This is typically only relevant when repainting.
virtual const RenderStyle& outlineStyleForRepaint() const { return style(); }
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 aleady been scheduled for full repaint.
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(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.
void repaint() 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 };
enum class ForceRepaint : 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;
enum class VisibleRectContextOption {
UseEdgeInclusiveIntersection = 1 << 0,
ApplyCompositedClips = 1 << 1,
ApplyCompositedContainerScrolls = 1 << 2,
ApplyContainerClip = 1 << 3,
};
struct VisibleRectContext {
VisibleRectContext(bool hasPositionFixedDescendant = false, bool dirtyRectIsFlipped = false, OptionSet<VisibleRectContextOption> options = { })
: hasPositionFixedDescendant(hasPositionFixedDescendant)
, dirtyRectIsFlipped(dirtyRectIsFlipped)
, options(options)
{
}
bool hasPositionFixedDescendant { false };
bool dirtyRectIsFlipped { false };
bool descendantNeedsEnclosingIntRect { false };
OptionSet<VisibleRectContextOption> options;
};
// 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.
LayoutRect absoluteClippedOverflowRectForRepaint() const { return clippedOverflowRect(nullptr, visibleRectContextForRepaint()); }
LayoutRect absoluteClippedOverflowRectForSpatialNavigation() const { return clippedOverflowRect(nullptr, visibleRectContextForSpatialNavigation()); }
WEBCORE_EXPORT IntRect pixelSnappedAbsoluteClippedOverflowRect() const;
virtual LayoutRect clippedOverflowRect(const RenderLayerModelObject* repaintContainer, VisibleRectContext) const;
LayoutRect clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const { return clippedOverflowRect(repaintContainer, visibleRectContextForRepaint()); }
virtual LayoutRect rectWithOutlineForRepaint(const RenderLayerModelObject* repaintContainer, LayoutUnit outlineWidth) const;
virtual LayoutRect outlineBoundsForRepaint(const RenderLayerModelObject* /*repaintContainer*/, const RenderGeometryMap* = nullptr) const { return LayoutRect(); }
// Given a rect in the object's coordinate space, compute a rect suitable for repainting
// that rect in view coordinates.
LayoutRect computeAbsoluteRepaintRect(const LayoutRect& rect) const { return computeRect(rect, nullptr, visibleRectContextForRepaint()); }
// Given a rect in the object's coordinate space, compute a rect in the coordinate space
// of repaintContainer suitable for the given VisibleRectContext.
LayoutRect computeRect(const LayoutRect&, const RenderLayerModelObject* repaintContainer, VisibleRectContext) const;
virtual LayoutRect computeRectForRepaint(const LayoutRect& rect, const RenderLayerModelObject* repaintContainer) const { return computeRect(rect, repaintContainer, visibleRectContextForRepaint()); }
FloatRect computeFloatRectForRepaint(const FloatRect&, const RenderLayerModelObject* repaintContainer) 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<LayoutRect> computeVisibleRectInContainer(const LayoutRect&, const RenderLayerModelObject* repaintContainer, VisibleRectContext) const;
virtual std::optional<FloatRect> computeFloatVisibleRectInContainer(const FloatRect&, const RenderLayerModelObject* repaintContainer, VisibleRectContext) const;
WEBCORE_EXPORT bool hasNonEmptyVisibleRectRespectingParentFrames() const;
virtual unsigned length() const { return 1; }
bool isFloatingOrOutOfFlowPositioned() const { return (isFloating() || isOutOfFlowPositioned()); }
bool isInFlow() const { return !isFloatingOrOutOfFlowPositioned(); }
enum HighlightState {
None, // The object is not selected.
Start, // The object either contains the start of a selection run or is the start of a run
Inside, // The object is fully encompassed by a selection run
End, // The object either contains the end of a selection run or is the end of a run
Both // The object contains an entire run or is the sole selected object in that run
};
// The current selection state for an object. For blocks, the state refers to the state of the leaf
// descendants (as described above in the HighlightState enum declaration).
HighlightState selectionState() const { return m_bitfields.selectionState(); }
virtual void setSelectionState(HighlightState);
inline void setSelectionStateIfNeeded(HighlightState);
bool canUpdateSelectionOnRootLineBoxes();
// A single rectangle that encompasses all of the selected objects within this object. Used to determine the tightest
// possible bounding box for the selection. The rect returned is in the coordinate space of the paint invalidation container's backing.
virtual LayoutRect selectionRectForRepaint(const RenderLayerModelObject* /*repaintContainer*/, bool /*clipToVisibleContent*/ = true) { return LayoutRect(); }
virtual bool canBeSelectionLeaf() const { return false; }
// Whether or not a given block needs to paint selection gaps.
virtual bool shouldPaintSelectionGaps() const { return false; }
// When performing a global document tear-down, or when going into the back/forward cache, the renderer of the document is cleared.
bool renderTreeBeingDestroyed() const;
void destroy();
// Virtual function helpers for the deprecated Flexible Box Layout (display: -webkit-box).
virtual bool isDeprecatedFlexibleBox() const { return false; }
// Virtual function helper for the new FlexibleBox Layout (display: -webkit-flex).
virtual bool isFlexibleBox() const { return false; }
bool isFlexibleBoxIncludingDeprecated() const { return isFlexibleBox() || isDeprecatedFlexibleBox(); }
virtual bool isCombineText() const { return false; }
virtual int caretMinOffset() const;
virtual int caretMaxOffset() const;
virtual int previousOffset(int current) const;
virtual int previousOffsetForBackwardDeletion(int current) const;
virtual int nextOffset(int current) const;
void imageChanged(CachedImage*, const IntRect* = nullptr) override;
virtual void imageChanged(WrappedImagePtr, const IntRect* = nullptr) { }
// Map points and quads through elements, potentially via 3d transforms. You should never need to call these directly; use
// localToAbsolute/absoluteToLocal methods instead.
virtual void mapLocalToContainer(const RenderLayerModelObject* repaintContainer, TransformState&, OptionSet<MapCoordinatesMode>, bool* wasFixed = nullptr) const;
virtual void mapAbsoluteToLocalPoint(OptionSet<MapCoordinatesMode>, TransformState&) const;
// Pushes state onto RenderGeometryMap about how to map coordinates from this renderer to its container, or ancestorToStopAt (whichever is encountered first).
// Returns the renderer which was mapped to (container or ancestorToStopAt).
virtual const RenderObject* pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap&) const;
bool shouldUseTransformFromContainer(const RenderObject* container) const;
void getTransformFromContainer(const RenderObject* container, const LayoutSize& offsetInContainer, TransformationMatrix&) const;
void pushOntoTransformState(TransformState&, OptionSet<MapCoordinatesMode>, const RenderLayerModelObject* repaintContainer, const RenderElement* container, const LayoutSize& offsetInContainer, bool containerSkipped) const;
void pushOntoGeometryMap(RenderGeometryMap&, const RenderLayerModelObject* repaintContainer, RenderElement* container, bool containerSkipped) const;
bool participatesInPreserve3D(const RenderElement* container) const;
virtual void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint& /* additionalOffset */, const RenderLayerModelObject* /* paintContainer */ = nullptr) const { };
LayoutRect absoluteOutlineBounds() const { return outlineBoundsForRepaint(nullptr); }
// FIXME: Renderers should not need to be notified about internal reparenting (webkit.org/b/224143).
enum class IsInternalMove : bool { No, Yes };
virtual void insertedIntoTree(IsInternalMove = IsInternalMove::No);
virtual void willBeRemovedFromTree(IsInternalMove = IsInternalMove::No);
void resetFragmentedFlowStateOnRemoval();
void initializeFragmentedFlowStateOnInsertion();
virtual String description() const;
virtual String debugDescription() const;
void addPDFURLRect(const PaintInfo&, const LayoutPoint&) const;
bool isSkippedContent() const;
bool isSkippedContentRoot() const;
protected:
//////////////////////////////////////////
// Helper functions. Dangerous to use!
void setPreviousSibling(RenderObject* previous) { m_previous = previous; }
void setNextSibling(RenderObject* next) { m_next = next; }
void setParent(RenderElement*);
//////////////////////////////////////////
Node& nodeForNonAnonymous() const { ASSERT(!isAnonymous()); ASSERT(m_node); return *m_node; }
void adjustRectForOutlineAndShadow(LayoutRect&) const;
virtual void willBeDestroyed();
void setNeedsPositionedMovementLayoutBit(bool b) { m_bitfields.setNeedsPositionedMovementLayout(b); }
void setNormalChildNeedsLayoutBit(bool b) { m_bitfields.setNormalChildNeedsLayout(b); }
void setPosChildNeedsLayoutBit(bool b) { m_bitfields.setPosChildNeedsLayout(b); }
void setNeedsSimplifiedNormalFlowLayoutBit(bool b) { m_bitfields.setNeedsSimplifiedNormalFlowLayout(b); }
virtual RenderFragmentedFlow* locateEnclosingFragmentedFlow() const;
static FragmentedFlowState computedFragmentedFlowState(const RenderObject&);
static VisibleRectContext visibleRectContextForRepaint();
static VisibleRectContext visibleRectContextForSpatialNavigation();
bool isSetNeedsLayoutForbidden() const;
void issueRepaint(std::optional<LayoutRect> partialRepaintRect = std::nullopt, ClipRepaintToLayer = ClipRepaintToLayer::No, ForceRepaint = ForceRepaint::No, std::optional<LayoutBoxExtent> additionalRepaintOutsets = std::nullopt) const;
private:
void addAbsoluteRectForLayer(LayoutRect& result);
void setLayerNeedsFullRepaint();
void setLayerNeedsFullRepaintForPositionedMovementLayout();
#if PLATFORM(IOS_FAMILY)
struct SelectionGeometries {
Vector<SelectionGeometry> geometries;
int maxLineNumber;
};
WEBCORE_EXPORT static SelectionGeometries collectSelectionGeometriesInternal(const SimpleRange&);
#endif
Node* generatingPseudoHostElement() const;
void propagateRepaintToParentWithOutlineAutoIfNeeded(const RenderLayerModelObject& repaintContainer, const LayoutRect& repaintRect) const;
virtual bool isWBR() const { ASSERT_NOT_REACHED(); return false; }
void setEverHadLayout(bool b) { m_bitfields.setEverHadLayout(b); }
bool hasRareData() const { return m_bitfields.hasRareData(); }
void setHasRareData(bool b) { m_bitfields.setHasRareData(b); }
#if ASSERT_ENABLED
void setNeedsLayoutIsForbidden(bool flag) const { m_setNeedsLayoutForbidden = flag; }
void checkBlockPositionedObjectsNeedLayout();
#endif
WeakPtr<Node, WeakPtrImplWithEventTargetData> m_node;
RenderElement* m_parent;
RenderObject* m_previous;
RenderObject* m_next;
CheckedPtr<Layout::Box> m_layoutBox;
#if ASSERT_ENABLED
bool m_hasAXObject : 1;
mutable bool m_setNeedsLayoutForbidden : 1;
#endif
#define ADD_BOOLEAN_BITFIELD(name, Name) \
private:\
unsigned m_##name : 1;\
public:\
bool name() const { return m_##name; }\
void set##Name(bool name) { m_##name = name; }\
#define ADD_ENUM_BITFIELD(name, Name, Type, width) \
private:\
unsigned m_##name : width;\
public:\
Type name() const { return static_cast<Type>(m_##name); }\
void set##Name(Type name) { m_##name = static_cast<unsigned>(name); }\
class RenderObjectBitfields {
enum PositionedState {
IsStaticallyPositioned = 0,
IsRelativelyPositioned = 1,
IsOutOfFlowPositioned = 2,
IsStickilyPositioned = 3
};
public:
RenderObjectBitfields(const Node& node)
: m_hasRareData(false)
, m_beingDestroyed(false)
, m_needsLayout(false)
, m_needsPositionedMovementLayout(false)
, m_normalChildNeedsLayout(false)
, m_posChildNeedsLayout(false)
, m_needsSimplifiedNormalFlowLayout(false)
, m_preferredLogicalWidthsDirty(false)
, m_floating(false)
, m_isAnonymous(node.isDocumentNode())
, m_isTextOrRenderView(false)
, m_isBox(false)
, m_isTableRow(false)
, m_isInline(true)
, m_isReplacedOrInlineBlock(false)
, m_isLineBreak(false)
, m_horizontalWritingMode(true)
, m_hasLayer(false)
, m_hasNonVisibleOverflow(false)
, m_hasTransformRelatedProperty(false)
, m_everHadLayout(false)
, m_childrenInline(false)
, m_isExcludedFromNormalLayout(false)
, m_positionedState(IsStaticallyPositioned)
, m_selectionState(HighlightState::None)
, m_fragmentedFlowState(NotInsideFragmentedFlow)
, m_boxDecorationState(NoBoxDecorations)
{
}
ADD_BOOLEAN_BITFIELD(hasRareData, HasRareData);
ADD_BOOLEAN_BITFIELD(beingDestroyed, BeingDestroyed);
ADD_BOOLEAN_BITFIELD(needsLayout, NeedsLayout);
ADD_BOOLEAN_BITFIELD(needsPositionedMovementLayout, NeedsPositionedMovementLayout);
ADD_BOOLEAN_BITFIELD(normalChildNeedsLayout, NormalChildNeedsLayout);
ADD_BOOLEAN_BITFIELD(posChildNeedsLayout, PosChildNeedsLayout);
ADD_BOOLEAN_BITFIELD(needsSimplifiedNormalFlowLayout, NeedsSimplifiedNormalFlowLayout);
ADD_BOOLEAN_BITFIELD(preferredLogicalWidthsDirty, PreferredLogicalWidthsDirty);
ADD_BOOLEAN_BITFIELD(floating, Floating);
ADD_BOOLEAN_BITFIELD(isAnonymous, IsAnonymous);
ADD_BOOLEAN_BITFIELD(isTextOrRenderView, IsTextOrRenderView);
ADD_BOOLEAN_BITFIELD(isBox, IsBox);
ADD_BOOLEAN_BITFIELD(isTableRow, IsTableRow);
ADD_BOOLEAN_BITFIELD(isInline, IsInline);
ADD_BOOLEAN_BITFIELD(isReplacedOrInlineBlock, IsReplacedOrInlineBlock);
ADD_BOOLEAN_BITFIELD(isLineBreak, IsLineBreak);
ADD_BOOLEAN_BITFIELD(horizontalWritingMode, HorizontalWritingMode);
ADD_BOOLEAN_BITFIELD(hasLayer, HasLayer);
ADD_BOOLEAN_BITFIELD(hasNonVisibleOverflow, HasNonVisibleOverflow); // Set in the case of overflow:auto/scroll/hidden
ADD_BOOLEAN_BITFIELD(hasTransformRelatedProperty, HasTransformRelatedProperty);
ADD_BOOLEAN_BITFIELD(everHadLayout, EverHadLayout);
// from RenderBlock
ADD_BOOLEAN_BITFIELD(childrenInline, ChildrenInline);
ADD_BOOLEAN_BITFIELD(isExcludedFromNormalLayout, IsExcludedFromNormalLayout);
private:
unsigned m_positionedState : 2; // PositionedState
unsigned m_selectionState : 3; // HighlightState
unsigned m_fragmentedFlowState : 1; // FragmentedFlowState
unsigned m_boxDecorationState : 2; // BoxDecorationState
public:
bool isOutOfFlowPositioned() const { return m_positionedState == IsOutOfFlowPositioned; }
bool isRelativelyPositioned() const { return m_positionedState == IsRelativelyPositioned; }
bool isStickilyPositioned() const { return m_positionedState == IsStickilyPositioned; }
bool isPositioned() const { return m_positionedState != IsStaticallyPositioned; }
void setPositionedState(int positionState)
{
// This mask maps PositionType::Fixed and PositionType::Absolute to IsOutOfFlowPositioned, saving one bit.
m_positionedState = static_cast<PositionedState>(positionState & 0x3);
}
void clearPositionedState() { m_positionedState = static_cast<unsigned>(PositionType::Static); }
ALWAYS_INLINE HighlightState selectionState() const { return static_cast<HighlightState>(m_selectionState); }
ALWAYS_INLINE void setSelectionState(HighlightState selectionState) { m_selectionState = selectionState; }
ALWAYS_INLINE FragmentedFlowState fragmentedFlowState() const { return static_cast<FragmentedFlowState>(m_fragmentedFlowState); }
ALWAYS_INLINE void setFragmentedFlowState(FragmentedFlowState fragmentedFlowState) { m_fragmentedFlowState = fragmentedFlowState; }
ALWAYS_INLINE BoxDecorationState boxDecorationState() const { return static_cast<BoxDecorationState>(m_boxDecorationState); }
ALWAYS_INLINE void setBoxDecorationState(BoxDecorationState boxDecorationState) { m_boxDecorationState = boxDecorationState; }
};
RenderObjectBitfields m_bitfields;
// FIXME: This should be RenderElementRareData.
class RenderObjectRareData {
WTF_MAKE_FAST_ALLOCATED;
public:
RenderObjectRareData();
~RenderObjectRareData();
ADD_BOOLEAN_BITFIELD(hasReflection, HasReflection);
ADD_BOOLEAN_BITFIELD(isRenderFragmentedFlow, IsRenderFragmentedFlow);
ADD_BOOLEAN_BITFIELD(hasOutlineAutoAncestor, HasOutlineAutoAncestor);
ADD_BOOLEAN_BITFIELD(paintContainmentApplies, PaintContainmentApplies);
#if ENABLE(LAYER_BASED_SVG_ENGINE)
ADD_BOOLEAN_BITFIELD(hasSVGTransform, HasSVGTransform);
#endif
ADD_ENUM_BITFIELD(trimmedMargins, TrimmedMargins, unsigned, 4);
// From RenderElement
std::unique_ptr<ReferencedSVGResources> referencedSVGResources;
WeakPtr<RenderBlockFlow> backdropRenderer;
// From RenderBox
RefPtr<ControlPart> controlPart;
};
WEBCORE_EXPORT const RenderObject::RenderObjectRareData& rareData() const;
RenderObjectRareData& ensureRareData();
void removeRareData();
typedef HashMap<const RenderObject*, std::unique_ptr<RenderObjectRareData>> RareDataMap;
static RareDataMap& rareDataMap();
#undef ADD_BOOLEAN_BITFIELD
};
class RenderObject::SetLayoutNeededForbiddenScope {
public:
explicit SetLayoutNeededForbiddenScope(const RenderObject&, bool isForbidden = true);
#if ASSERT_ENABLED
~SetLayoutNeededForbiddenScope();
private:
const RenderObject& m_renderObject;
bool m_preexistingForbidden;
#endif
};
inline LocalFrame& RenderObject::frame() const
{
return *document().frame();
}
inline Page& RenderObject::page() const
{
// The render tree will always be torn down before Frame is disconnected from Page,
// so it's safe to assume Frame::page() is non-null as long as there are live RenderObjects.
ASSERT(frame().page());
return *frame().page();
}
inline bool RenderObject::renderTreeBeingDestroyed() const
{
return document().renderTreeBeingDestroyed();
}
inline bool RenderObject::isBeforeContent() const
{
// Text nodes don't have their own styles, so ignore the style on a text node.
if (isText())
return false;
if (style().styleType() != PseudoId::Before)
return false;
return true;
}
inline bool RenderObject::isAfterContent() const
{
// Text nodes don't have their own styles, so ignore the style on a text node.
if (isText())
return false;
if (style().styleType() != PseudoId::After)
return false;
return true;
}
inline bool RenderObject::isBeforeOrAfterContent() const
{
return isBeforeContent() || isAfterContent();
}
inline void RenderObject::setNeedsLayout(MarkingBehavior markParents)
{
ASSERT(!isSetNeedsLayoutForbidden());
if (m_bitfields.needsLayout())
return;
m_bitfields.setNeedsLayout(true);
if (markParents == MarkContainingBlockChain)
markContainingBlocksForLayout();
if (hasLayer())
setLayerNeedsFullRepaint();
}
inline void RenderObject::setSelectionStateIfNeeded(HighlightState state)
{
if (selectionState() == state)
return;
setSelectionState(state);
}
inline void RenderObject::setHasVisibleBoxDecorations(bool b)
{
if (!b) {
m_bitfields.setBoxDecorationState(NoBoxDecorations);
return;
}
if (hasVisibleBoxDecorations())
return;
m_bitfields.setBoxDecorationState(HasBoxDecorationsAndBackgroundObscurationStatusInvalid);
}
inline void RenderObject::invalidateBackgroundObscurationStatus()
{
if (!hasVisibleBoxDecorations())
return;
m_bitfields.setBoxDecorationState(HasBoxDecorationsAndBackgroundObscurationStatusInvalid);
}
inline bool RenderObject::backgroundIsKnownToBeObscured(const LayoutPoint& paintOffset)
{
if (m_bitfields.boxDecorationState() == HasBoxDecorationsAndBackgroundObscurationStatusInvalid) {
BoxDecorationState boxDecorationState = computeBackgroundIsKnownToBeObscured(paintOffset) ? HasBoxDecorationsAndBackgroundIsKnownToBeObscured : HasBoxDecorationsAndBackgroundMayBeVisible;
m_bitfields.setBoxDecorationState(boxDecorationState);
}
return m_bitfields.boxDecorationState() == HasBoxDecorationsAndBackgroundIsKnownToBeObscured;
}
inline bool RenderObject::needsSimplifiedNormalFlowLayoutOnly() const
{
return m_bitfields.needsSimplifiedNormalFlowLayout() && !m_bitfields.needsLayout() && !m_bitfields.normalChildNeedsLayout()
&& !m_bitfields.posChildNeedsLayout() && !m_bitfields.needsPositionedMovementLayout();
}
inline RenderFragmentedFlow* RenderObject::enclosingFragmentedFlow() const
{
if (fragmentedFlowState() == NotInsideFragmentedFlow)
return nullptr;
return locateEnclosingFragmentedFlow();
}
inline bool RenderObject::isAnonymousBlock() const
{
// This function must be kept in sync with anonymous block creation conditions in RenderBlock::createAnonymousBlock().
// FIXME: That seems difficult. Can we come up with a simpler way to make behavior correct?
// FIXME: Does this relatively long function benefit from being inlined?
return isAnonymous()
&& (style().display() == DisplayType::Block || style().display() == DisplayType::Box)
&& style().styleType() == PseudoId::None
&& isRenderBlock()
#if ENABLE(MATHML)
&& !isRenderMathMLBlock()
#endif
&& !isListMarker()
&& !isRenderFragmentedFlow()
&& !isRenderMultiColumnSet()
&& !isRenderView();
}
inline bool RenderObject::needsLayout() const
{
return m_bitfields.needsLayout()
|| m_bitfields.normalChildNeedsLayout()
|| m_bitfields.posChildNeedsLayout()
|| m_bitfields.needsSimplifiedNormalFlowLayout()
|| m_bitfields.needsPositionedMovementLayout();
}
inline bool RenderObject::needsPositionedMovementLayoutOnly() const
{
return m_bitfields.needsPositionedMovementLayout()
&& !m_bitfields.needsLayout()
&& !m_bitfields.normalChildNeedsLayout()
&& !m_bitfields.posChildNeedsLayout()
&& !m_bitfields.needsSimplifiedNormalFlowLayout();
}
inline void RenderObject::setNeedsLayoutAndPrefWidthsRecalc()
{
setNeedsLayout();
setPreferredLogicalWidthsDirty(true);
}
inline void RenderObject::setPositionState(PositionType position)
{
ASSERT((position != PositionType::Absolute && position != PositionType::Fixed) || isBox());
m_bitfields.setPositionedState(static_cast<int>(position));
}
inline FloatQuad RenderObject::localToAbsoluteQuad(const FloatQuad& quad, OptionSet<MapCoordinatesMode> mode, bool* wasFixed) const
{
return localToContainerQuad(quad, nullptr, mode, wasFixed);
}
inline auto RenderObject::visibleRectContextForRepaint() -> VisibleRectContext
{
return { false, false, { VisibleRectContextOption::ApplyContainerClip, VisibleRectContextOption::ApplyCompositedContainerScrolls } };
}
inline auto RenderObject::visibleRectContextForSpatialNavigation() -> VisibleRectContext
{
return { false, false, { VisibleRectContextOption::ApplyContainerClip, VisibleRectContextOption::ApplyCompositedContainerScrolls, VisibleRectContextOption::ApplyCompositedClips } };
}
inline bool RenderObject::isSetNeedsLayoutForbidden() const
{
#if ASSERT_ENABLED
return m_setNeedsLayoutForbidden;
#else
return false;
#endif
}
#if !ASSERT_ENABLED
inline RenderObject::SetLayoutNeededForbiddenScope::SetLayoutNeededForbiddenScope(const RenderObject&, bool)
{
}
#endif
inline void Node::setRenderer(RenderObject* renderer)
{
m_rendererWithStyleFlags.setPointer(renderer);
if (UNLIKELY(InspectorInstrumentationPublic::hasFrontends()))
notifyInspectorOfRendererChange();
}
inline RenderObject* RenderObject::previousInFlowSibling() const
{
auto* previousSibling = this->previousSibling();
while (previousSibling && !previousSibling->isInFlow())
previousSibling = previousSibling->previousSibling();
return previousSibling;
}
inline RenderObject* RenderObject::nextInFlowSibling() const
{
auto* nextSibling = this->nextSibling();
while (nextSibling && !nextSibling->isInFlow())
nextSibling = nextSibling->nextSibling();
return nextSibling;
}
inline bool RenderObject::hasPotentiallyScrollableOverflow() const
{
// We only need to test one overflow dimension since 'visible' and 'clip' always get accompanied
// with 'clip' or 'visible' in the other dimension (see Style::Adjuster::adjust).
return hasNonVisibleOverflow() && style().overflowX() != Overflow::Clip && style().overflowX() != Overflow::Visible;
}
WTF::TextStream& operator<<(WTF::TextStream&, const RenderObject&);
#if ENABLE(TREE_DEBUGGING)
void printPaintOrderTreeForLiveDocuments();
void printRenderTreeForLiveDocuments();
void printLayerTreeForLiveDocuments();
void printGraphicsLayerTreeForLiveDocuments();
#endif
} // namespace WebCore
#define SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(ToValueTypeName, predicate) \
SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToValueTypeName) \
static bool isType(const WebCore::RenderObject& renderer) { return renderer.predicate; } \
SPECIALIZE_TYPE_TRAITS_END()
#if ENABLE(TREE_DEBUGGING)
// Outside the WebCore namespace for ease of invocation from the debugger.
void showNodeTree(const WebCore::RenderObject*);
void showLineTree(const WebCore::RenderObject*);
void showRenderTree(const WebCore::RenderObject*);
#endif
|