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 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626
|
/*
* 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, 2004, 2005, 2006, 2007, 2008, 2009, 2012 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.
*
*/
#ifndef RenderObject_h
#define RenderObject_h
#include "core/dom/Document.h"
#include "core/dom/DocumentLifecycle.h"
#include "core/dom/Element.h"
#include "core/editing/TextAffinity.h"
#include "core/fetch/ImageResourceClient.h"
#include "core/html/HTMLElement.h"
#include "core/inspector/InspectorTraceEvents.h"
#include "core/rendering/HitTestRequest.h"
#include "core/rendering/PaintInvalidationState.h"
#include "core/rendering/PaintPhase.h"
#include "core/rendering/RenderObjectChildList.h"
#include "core/rendering/ScrollAlignment.h"
#include "core/rendering/SubtreeLayoutScope.h"
#include "core/rendering/compositing/CompositingState.h"
#include "core/rendering/compositing/CompositingTriggers.h"
#include "core/rendering/style/RenderStyle.h"
#include "core/rendering/style/StyleInheritedData.h"
#include "platform/geometry/FloatQuad.h"
#include "platform/geometry/LayoutRect.h"
#include "platform/graphics/CompositingReasons.h"
#include "platform/graphics/PaintInvalidationReason.h"
#include "platform/graphics/paint/DisplayItem.h"
#include "platform/transforms/TransformationMatrix.h"
namespace blink {
class AffineTransform;
class Cursor;
class Document;
class HitTestLocation;
class HitTestResult;
class InlineBox;
class Position;
class PositionWithAffinity;
class PseudoStyleRequest;
class RenderBoxModelObject;
class RenderBlock;
class RenderFlowThread;
class RenderGeometryMap;
class RenderLayer;
class RenderLayerModelObject;
class RenderMultiColumnSpannerPlaceholder;
class RenderView;
class TransformState;
struct PaintInfo;
enum CursorDirective {
SetCursorBasedOnStyle,
SetCursor,
DoNotSetCursor
};
enum HitTestFilter {
HitTestAll,
HitTestSelf,
HitTestDescendants
};
enum HitTestAction {
HitTestBlockBackground,
HitTestChildBlockBackground,
HitTestChildBlockBackgrounds,
HitTestFloat,
HitTestForeground
};
enum MarkingBehavior {
MarkOnlyThis,
MarkContainingBlockChain,
};
enum MapCoordinatesMode {
IsFixed = 1 << 0,
UseTransforms = 1 << 1,
ApplyContainerFlip = 1 << 2,
TraverseDocumentBoundaries = 1 << 3,
};
typedef unsigned MapCoordinatesFlags;
const int caretWidth = 1;
struct AnnotatedRegionValue {
bool operator==(const AnnotatedRegionValue& o) const
{
return draggable == o.draggable && bounds == o.bounds;
}
LayoutRect bounds;
bool draggable;
};
typedef WTF::HashMap<const RenderLayer*, Vector<LayoutRect> > LayerHitTestRects;
#ifndef NDEBUG
const int showTreeCharacterOffset = 39;
#endif
// Base class for all rendering tree objects.
class RenderObject : public NoBaseWillBeGarbageCollectedFinalized<RenderObject>, public ImageResourceClient {
friend class RenderBlock;
friend class RenderBlockFlow;
friend class RenderLayerReflectionInfo; // For setParent
friend class RenderLayerScrollableArea; // For setParent.
friend class RenderObjectChildList;
WTF_MAKE_NONCOPYABLE(RenderObject);
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();
virtual void trace(Visitor*);
virtual const char* renderName() const = 0;
String debugName() const;
RenderObject* parent() const { return m_parent; }
bool isDescendantOf(const RenderObject*) const;
RenderObject* previousSibling() const { return m_previous; }
RenderObject* nextSibling() const { return m_next; }
RenderObject* slowFirstChild() const
{
if (const RenderObjectChildList* children = virtualChildren())
return children->firstChild();
return 0;
}
RenderObject* slowLastChild() const
{
if (const RenderObjectChildList* children = virtualChildren())
return children->lastChild();
return 0;
}
virtual RenderObjectChildList* virtualChildren() { return 0; }
virtual const RenderObjectChildList* virtualChildren() const { return 0; }
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;
RenderObject* childAt(unsigned) const;
RenderObject* lastLeafChild() const;
// The following six functions are used when the render tree hierarchy changes to make sure layers get
// properly added and removed. Since containership can be implemented by any subclass, and since a hierarchy
// can contain a mixture of boxes and other object types, these functions need to be in the base class.
RenderLayer* enclosingLayer() const;
void addLayers(RenderLayer* parentLayer);
void removeLayers(RenderLayer* parentLayer);
void moveLayers(RenderLayer* oldParent, RenderLayer* newParent);
RenderLayer* findNextLayer(RenderLayer* parentLayer, RenderObject* startPoint, bool checkParent = true);
// Scrolling is a RenderBox concept, however some code just cares about recursively scrolling our enclosing ScrollableArea(s).
bool scrollRectToVisible(const LayoutRect&, const ScrollAlignment& alignX = ScrollAlignment::alignCenterIfNeeded, const ScrollAlignment& alignY = ScrollAlignment::alignCenterIfNeeded);
// Convenience function for getting to the nearest enclosing box of a RenderObject.
RenderBox* enclosingBox() const;
RenderBoxModelObject* enclosingBoxModelObject() const;
RenderBox* enclosingScrollableBox() const;
// Function to return our enclosing flow thread if we are contained inside one. This
// function follows the containing block chain.
RenderFlowThread* flowThreadContainingBlock() const
{
if (flowThreadState() == NotInsideFlowThread)
return 0;
return locateFlowThreadContainingBlock();
}
#if ENABLE(ASSERT)
void setHasAXObject(bool flag) { m_hasAXObject = flag; }
bool hasAXObject() const { return m_hasAXObject; }
// Helper class forbidding calls to setNeedsLayout() during its lifetime.
class SetLayoutNeededForbiddenScope {
public:
explicit SetLayoutNeededForbiddenScope(RenderObject&);
~SetLayoutNeededForbiddenScope();
private:
RenderObject& m_renderObject;
bool m_preexistingForbidden;
};
void assertRendererLaidOut() const
{
#ifndef NDEBUG
if (needsLayout())
showRenderTreeForThis();
#endif
ASSERT_WITH_SECURITY_IMPLICATION(!needsLayout());
}
void assertSubtreeIsLaidOut() const
{
for (const RenderObject* renderer = this; renderer; renderer = renderer->nextInPreOrder())
renderer->assertRendererLaidOut();
}
void assertRendererClearedPaintInvalidationState() const
{
#ifndef NDEBUG
if (paintInvalidationStateIsDirty()) {
showRenderTreeForThis();
ASSERT_NOT_REACHED();
}
#endif
}
void assertSubtreeClearedPaintInvalidationState() const
{
for (const RenderObject* renderer = this; renderer; renderer = renderer->nextInPreOrder())
renderer->assertRendererClearedPaintInvalidationState();
}
#endif
// FIXME: This could be used when changing the size of a renderer without children to skip some invalidations.
bool rendererHasNoBoxEffect() const
{
return !style()->hasVisualOverflowingEffect() && !style()->hasBorder() && !style()->hasBackground();
}
// Obtains the nearest enclosing block (including this block) that contributes a first-line style to our inline
// children.
virtual RenderBlock* firstLineBlock() const;
// Called when an object that was floating or positioned becomes a normal flow object
// again. We have to make sure the render tree updates as needed to accommodate the new
// normal flow object.
void handleDynamicFloatPositionChange();
// RenderObject tree manipulation
//////////////////////////////////////////
virtual bool canHaveChildren() const { return virtualChildren(); }
virtual bool canHaveGeneratedChildren() const;
virtual bool isChildAllowed(RenderObject*, RenderStyle*) const { return true; }
virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0);
virtual void addChildIgnoringContinuation(RenderObject* newChild, RenderObject* beforeChild = 0) { return addChild(newChild, beforeChild); }
virtual void removeChild(RenderObject*);
virtual bool createsAnonymousWrapper() const { return false; }
//////////////////////////////////////////
protected:
//////////////////////////////////////////
// Helper functions. Dangerous to use!
void setPreviousSibling(RenderObject* previous) { m_previous = previous; }
void setNextSibling(RenderObject* next) { m_next = next; }
void setParent(RenderObject* parent)
{
m_parent = parent;
// Only update if our flow thread state is different from our new parent and if we're not a RenderFlowThread.
// A RenderFlowThread is always considered to be inside itself, so it never has to change its state
// in response to parent changes.
FlowThreadState newState = parent ? parent->flowThreadState() : NotInsideFlowThread;
if (newState != flowThreadState() && !isRenderFlowThread())
setFlowThreadStateIncludingDescendants(newState);
}
//////////////////////////////////////////
private:
#if ENABLE(ASSERT)
bool isSetNeedsLayoutForbidden() const { return m_setNeedsLayoutForbidden; }
void setNeedsLayoutIsForbidden(bool flag) { m_setNeedsLayoutForbidden = flag; }
#endif
void addAbsoluteRectForLayer(LayoutRect& result);
bool requiresAnonymousTableWrappers(const RenderObject*) const;
// Gets pseudoStyle from Shadow host(in case of input elements)
// or from Parent element.
PassRefPtr<RenderStyle> getUncachedPseudoStyleFromParentOrShadowHost() const;
bool skipInvalidationWhenLaidOutChildren() const;
public:
#ifndef NDEBUG
void showTreeForThis() const;
void showRenderTreeForThis() const;
void showLineTreeForThis() const;
void showRenderObject() const;
// We don't make printedCharacters an optional parameter so that
// showRenderObject can be called from gdb easily.
void showRenderObject(int printedCharacters) const;
void showRenderTreeAndMark(const RenderObject* markedObject1 = 0, const char* markedLabel1 = 0, const RenderObject* markedObject2 = 0, const char* markedLabel2 = 0, int depth = 0) const;
#endif
static RenderObject* createObject(Element*, RenderStyle*);
static unsigned instanceCount() { return s_instanceCount; }
#if !ENABLE(OILPAN)
// RenderObjects are allocated out of the rendering partition.
void* operator new(size_t);
void operator delete(void*);
#endif
public:
bool isPseudoElement() const { return node() && node()->isPseudoElement(); }
virtual bool isBoxModelObject() const { return false; }
bool isBR() const { return isOfType(RenderObjectBr); }
bool isCanvas() const { return isOfType(RenderObjectCanvas); }
bool isCounter() const { return isOfType(RenderObjectCounter); }
bool isDetailsMarker() const { return isOfType(RenderObjectDetailsMarker); }
bool isEmbeddedObject() const { return isOfType(RenderObjectEmbeddedObject); }
bool isFieldset() const { return isOfType(RenderObjectFieldset); }
bool isFileUploadControl() const { return isOfType(RenderObjectFileUploadControl); }
bool isFrame() const { return isOfType(RenderObjectFrame); }
bool isFrameSet() const { return isOfType(RenderObjectFrameSet); }
bool isListBox() const { return isOfType(RenderObjectListBox); }
bool isListItem() const { return isOfType(RenderObjectListItem); }
bool isListMarker() const { return isOfType(RenderObjectListMarker); }
bool isMedia() const { return isOfType(RenderObjectMedia); }
bool isMenuList() const { return isOfType(RenderObjectMenuList); }
bool isMeter() const { return isOfType(RenderObjectMeter); }
bool isProgress() const { return isOfType(RenderObjectProgress); }
bool isQuote() const { return isOfType(RenderObjectQuote); }
bool isRenderButton() const { return isOfType(RenderObjectRenderButton); }
bool isRenderFullScreen() const { return isOfType(RenderObjectRenderFullScreen); }
bool isRenderFullScreenPlaceholder() const { return isOfType(RenderObjectRenderFullScreenPlaceholder); }
bool isRenderGrid() const { return isOfType(RenderObjectRenderGrid); }
bool isRenderIFrame() const { return isOfType(RenderObjectRenderIFrame); }
bool isRenderImage() const { return isOfType(RenderObjectRenderImage); }
bool isRenderMultiColumnSet() const { return isOfType(RenderObjectRenderMultiColumnSet); }
bool isRenderMultiColumnSpannerPlaceholder() const { return isOfType(RenderObjectRenderMultiColumnSpannerPlaceholder); }
bool isRenderRegion() const { return isOfType(RenderObjectRenderRegion); }
bool isRenderScrollbarPart() const { return isOfType(RenderObjectRenderScrollbarPart); }
bool isRenderTableCol() const { return isOfType(RenderObjectRenderTableCol); }
bool isRenderView() const { return isOfType(RenderObjectRenderView); }
bool isReplica() const { return isOfType(RenderObjectReplica); }
bool isRuby() const { return isOfType(RenderObjectRuby); }
bool isRubyBase() const { return isOfType(RenderObjectRubyBase); }
bool isRubyRun() const { return isOfType(RenderObjectRubyRun); }
bool isRubyText() const { return isOfType(RenderObjectRubyText); }
bool isSlider() const { return isOfType(RenderObjectSlider); }
bool isSliderThumb() const { return isOfType(RenderObjectSliderThumb); }
bool isTable() const { return isOfType(RenderObjectTable); }
bool isTableCaption() const { return isOfType(RenderObjectTableCaption); }
bool isTableCell() const { return isOfType(RenderObjectTableCell); }
bool isTableRow() const { return isOfType(RenderObjectTableRow); }
bool isTableSection() const { return isOfType(RenderObjectTableSection); }
bool isTextArea() const { return isOfType(RenderObjectTextArea); }
bool isTextControl() const { return isOfType(RenderObjectTextControl); }
bool isTextField() const { return isOfType(RenderObjectTextField); }
bool isVideo() const { return isOfType(RenderObjectVideo); }
bool isWidget() const { return isOfType(RenderObjectWidget); }
virtual bool isImage() const { return false; }
virtual bool isInlineBlockOrInlineTable() const { return false; }
virtual bool isLayerModelObject() const { return false; }
virtual bool isRenderBlock() const { return false; }
virtual bool isRenderBlockFlow() const { return false; }
virtual bool isRenderFlowThread() const { return false; }
virtual bool isRenderInline() const { return false; }
virtual bool isRenderPart() const { return false; }
bool isDocumentElement() const { return document().documentElement() == m_node; }
// isBody is called from RenderBox::styleWillChange and is thus quite hot.
bool isBody() const { return node() && node()->hasTagName(HTMLNames::bodyTag); }
bool isHR() const;
bool isLegend() 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 isAfterContent(const RenderObject* obj) { return obj && obj->isAfterContent(); }
bool hasCounterNodeMap() const { return m_bitfields.hasCounterNodeMap(); }
void setHasCounterNodeMap(bool hasCounterNodeMap) { m_bitfields.setHasCounterNodeMap(hasCounterNodeMap); }
bool everHadLayout() const { return m_bitfields.everHadLayout(); }
bool childrenInline() const { return m_bitfields.childrenInline(); }
void setChildrenInline(bool b) { m_bitfields.setChildrenInline(b); }
bool hasColumns() const { return m_bitfields.hasColumns(); }
void setHasColumns(bool b = true) { m_bitfields.setHasColumns(b); }
bool alwaysCreateLineBoxesForRenderInline() const
{
ASSERT(isRenderInline());
return m_bitfields.alwaysCreateLineBoxesForRenderInline();
}
void setAlwaysCreateLineBoxesForRenderInline(bool alwaysCreateLineBoxes)
{
ASSERT(isRenderInline());
m_bitfields.setAlwaysCreateLineBoxesForRenderInline(alwaysCreateLineBoxes);
}
bool ancestorLineBoxDirty() const { return m_bitfields.ancestorLineBoxDirty(); }
void setAncestorLineBoxDirty(bool value = true)
{
m_bitfields.setAncestorLineBoxDirty(value);
if (value)
setNeedsLayoutAndFullPaintInvalidation();
}
enum FlowThreadState {
NotInsideFlowThread = 0,
InsideOutOfFlowThread = 1,
InsideInFlowThread = 2,
};
void setFlowThreadStateIncludingDescendants(FlowThreadState);
FlowThreadState flowThreadState() const { return m_bitfields.flowThreadState(); }
void setFlowThreadState(FlowThreadState state) { m_bitfields.setFlowThreadState(state); }
// FIXME: Until all SVG renders can be subclasses of RenderSVGModelObject we have
// to add SVG renderer methods to RenderObject with an ASSERT_NOT_REACHED() default implementation.
bool isSVG() const { return isOfType(RenderObjectSVG); }
bool isSVGRoot() const { return isOfType(RenderObjectSVGRoot); }
bool isSVGContainer() const { return isOfType(RenderObjectSVGContainer); }
bool isSVGTransformableContainer() const { return isOfType(RenderObjectSVGTransformableContainer); }
bool isSVGViewportContainer() const { return isOfType(RenderObjectSVGViewportContainer); }
bool isSVGGradientStop() const { return isOfType(RenderObjectSVGGradientStop); }
bool isSVGHiddenContainer() const { return isOfType(RenderObjectSVGHiddenContainer); }
bool isSVGShape() const { return isOfType(RenderObjectSVGShape); }
bool isSVGText() const { return isOfType(RenderObjectSVGText); }
bool isSVGTextPath() const { return isOfType(RenderObjectSVGTextPath); }
bool isSVGInline() const { return isOfType(RenderObjectSVGInline); }
bool isSVGInlineText() const { return isOfType(RenderObjectSVGInlineText); }
bool isSVGImage() const { return isOfType(RenderObjectSVGImage); }
bool isSVGForeignObject() const { return isOfType(RenderObjectSVGForeignObject); }
bool isSVGResourceContainer() const { return isOfType(RenderObjectSVGResourceContainer); }
bool isSVGResourceFilter() const { return isOfType(RenderObjectSVGResourceFilter); }
bool isSVGResourceFilterPrimitive() const { return isOfType(RenderObjectSVGResourceFilterPrimitive); }
// 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();
bool isBlendingAllowed() const { return !isSVG() || (isSVGContainer() && !isSVGHiddenContainer()) || isSVGShape() || isSVGImage() || isSVGText(); }
virtual bool hasNonIsolatedBlendingDescendants() const { return false; }
enum DescendantIsolationState {
DescendantIsolationRequired,
DescendantIsolationNeedsUpdate,
};
virtual void descendantIsolationRequirementsChanged(DescendantIsolationState) { }
// 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;
// Returns the smallest rectangle enclosing all of the painted content
// respecting clipping, masking, filters, opacity, stroke-width and markers
virtual FloatRect paintInvalidationRectInLocalCoordinates() 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 paint invalidaiton 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_bitfields.isAnonymous(); }
bool isAnonymousBlock() const
{
// This function is kept in sync with anonymous block creation conditions in
// RenderBlock::createAnonymousBlock(). This includes creating an anonymous
// RenderBlock having a BLOCK or BOX display. Other classes such as RenderTextFragment
// are not RenderBlocks and will return false. See https://bugs.webkit.org/show_bug.cgi?id=56709.
return isAnonymous() && (style()->display() == BLOCK || style()->display() == BOX) && style()->styleType() == NOPSEUDO && isRenderBlock() && !isListMarker() && !isRenderFlowThread() && !isRenderMultiColumnSet()
&& !isRenderFullScreen()
&& !isRenderFullScreenPlaceholder();
}
bool isAnonymousColumnsBlock() const { return style()->specifiesColumns() && isAnonymousBlock(); }
bool isAnonymousColumnSpanBlock() const { return style()->columnSpan() && isAnonymousBlock(); }
bool isElementContinuation() const { return node() && node()->renderer() != this; }
bool isInlineElementContinuation() const { return isElementContinuation() && isInline(); }
virtual RenderBoxModelObject* virtualContinuation() const { return 0; }
bool isFloating() const { return m_bitfields.floating(); }
bool isOutOfFlowPositioned() const { return m_bitfields.isOutOfFlowPositioned(); } // absolute or fixed positioning
bool isRelPositioned() const { return m_bitfields.isRelPositioned(); } // relative positioning
bool isPositioned() const { return m_bitfields.isPositioned(); }
bool isText() const { return m_bitfields.isText(); }
bool isBox() const { return m_bitfields.isBox(); }
bool isInline() const { return m_bitfields.isInline(); } // inline object
bool isDragging() const { return m_bitfields.isDragging(); }
bool isReplaced() const { return m_bitfields.isReplaced(); } // a "replaced" element (see CSS)
bool isHorizontalWritingMode() const { return m_bitfields.horizontalWritingMode(); }
bool hasFlippedBlocksWritingMode() const
{
return style()->isFlippedBlocksWritingMode();
}
bool hasLayer() const { return m_bitfields.hasLayer(); }
// "Box decoration background" includes all box decorations and backgrounds
// that are painted as the background of the object. It includes borders,
// box-shadows, background-color and background-image, etc.
enum BoxDecorationBackgroundState {
NoBoxDecorationBackground,
HasBoxDecorationBackgroundObscurationStatusInvalid,
HasBoxDecorationBackgroundKnownToBeObscured,
HasBoxDecorationBackgroundMayBeVisible,
};
bool hasBoxDecorationBackground() const { return m_bitfields.boxDecorationBackgroundState() != NoBoxDecorationBackground; }
bool boxDecorationBackgroundIsKnownToBeObscured();
bool canRenderBorderImage() const;
bool mustInvalidateBackgroundOrBorderPaintOnWidthChange() const;
bool mustInvalidateBackgroundOrBorderPaintOnHeightChange() const;
bool mustInvalidateFillLayersPaintOnWidthChange(const FillLayer&) const;
bool mustInvalidateFillLayersPaintOnHeightChange(const FillLayer&) const;
bool hasBackground() const { return style()->hasBackground(); }
bool hasEntirelyFixedBackground() const;
bool needsLayoutBecauseOfChildren() const { return needsLayout() && !selfNeedsLayout() && !needsPositionedMovementLayout() && !needsSimplifiedNormalFlowLayout(); }
bool needsLayout() const
{
return m_bitfields.selfNeedsLayout() || m_bitfields.normalChildNeedsLayout() || m_bitfields.posChildNeedsLayout()
|| m_bitfields.needsSimplifiedNormalFlowLayout() || m_bitfields.needsPositionedMovementLayout();
}
bool selfNeedsLayout() const { return m_bitfields.selfNeedsLayout(); }
bool needsPositionedMovementLayout() const { return m_bitfields.needsPositionedMovementLayout(); }
bool needsPositionedMovementLayoutOnly() const
{
return m_bitfields.needsPositionedMovementLayout() && !m_bitfields.selfNeedsLayout() && !m_bitfields.normalChildNeedsLayout()
&& !m_bitfields.posChildNeedsLayout() && !m_bitfields.needsSimplifiedNormalFlowLayout();
}
bool posChildNeedsLayout() const { return m_bitfields.posChildNeedsLayout(); }
bool needsSimplifiedNormalFlowLayout() const { return m_bitfields.needsSimplifiedNormalFlowLayout(); }
bool normalChildNeedsLayout() const { return m_bitfields.normalChildNeedsLayout(); }
bool preferredLogicalWidthsDirty() const { return m_bitfields.preferredLogicalWidthsDirty(); }
bool needsOverflowRecalcAfterStyleChange() const { return m_bitfields.selfNeedsOverflowRecalcAfterStyleChange() || m_bitfields.childNeedsOverflowRecalcAfterStyleChange(); }
bool selfNeedsOverflowRecalcAfterStyleChange() const { return m_bitfields.selfNeedsOverflowRecalcAfterStyleChange(); }
bool childNeedsOverflowRecalcAfterStyleChange() const { return m_bitfields.childNeedsOverflowRecalcAfterStyleChange(); }
bool isSelectionBorder() const;
bool hasClip() const { return isOutOfFlowPositioned() && !style()->hasAutoClip(); }
bool hasOverflowClip() const { return m_bitfields.hasOverflowClip(); }
bool hasClipOrOverflowClip() const { return hasClip() || hasOverflowClip(); }
bool hasTransformRelatedProperty() const { return m_bitfields.hasTransformRelatedProperty(); }
bool hasMask() const { return style() && style()->hasMask(); }
bool hasClipPath() const { return style() && style()->clipPath(); }
bool hasHiddenBackface() const { return style() && style()->backfaceVisibility() == BackfaceVisibilityHidden; }
bool hasFilter() const { return style() && style()->hasFilter(); }
bool hasShapeOutside() const { return style() && style()->shapeOutside(); }
inline bool preservesNewline() const;
// The pseudo element style can be cached or uncached. Use the cached method if the pseudo element doesn't respect
// any pseudo classes (and therefore has no concept of changing state).
RenderStyle* getCachedPseudoStyle(PseudoId, RenderStyle* parentStyle = 0) const;
PassRefPtr<RenderStyle> getUncachedPseudoStyle(const PseudoStyleRequest&, RenderStyle* parentStyle = 0, RenderStyle* ownStyle = 0) const;
virtual void updateDragState(bool dragOn);
RenderView* view() const { return document().renderView(); };
FrameView* frameView() const { return document().view(); };
bool isRooted() const;
Node* node() const
{
return isAnonymous() ? 0 : m_node.get();
}
Node* nonPseudoNode() const
{
return isPseudoElement() ? 0 : node();
}
// FIXME: Why does RenderPart need this? crbug.com/422457
void clearNode() { m_node = nullptr; }
// Returns the styled node that caused the generation of this renderer.
// This is the same as node() except for renderers of :before, :after and
// :first-letter pseudo elements for which their parent node is returned.
Node* generatingNode() const { return isPseudoElement() ? node()->parentOrShadowHostNode() : node(); }
Document& document() const { return m_node->document(); }
LocalFrame* frame() const { return document().frame(); }
virtual RenderMultiColumnSpannerPlaceholder* spannerPlaceholder() const { return 0; }
bool isColumnSpanAll() const { return style()->columnSpan() == ColumnSpanAll && spannerPlaceholder(); }
// Returns the object containing this one. Can be different from parent for positioned elements.
// If paintInvalidationContainer and paintInvalidationContainerSkipped are not null, on return *paintInvalidationContainerSkipped
// is true if the renderer returned is an ancestor of paintInvalidationContainer.
RenderObject* container(const RenderLayerModelObject* paintInvalidationContainer = 0, bool* paintInvalidationContainerSkipped = 0) const;
RenderBlock* containerForFixedPosition(const RenderLayerModelObject* paintInvalidationContainer = 0, bool* paintInvalidationContainerSkipped = 0) const;
virtual RenderObject* hoverAncestor() const { return parent(); }
Element* offsetParent() const;
void markContainingBlocksForLayout(bool scheduleRelayout = true, RenderObject* newRoot = 0, SubtreeLayoutScope* = 0);
void setNeedsLayout(MarkingBehavior = MarkContainingBlockChain, SubtreeLayoutScope* = 0);
void setNeedsLayoutAndFullPaintInvalidation(MarkingBehavior = MarkContainingBlockChain, SubtreeLayoutScope* = 0);
void clearNeedsLayout();
void setChildNeedsLayout(MarkingBehavior = MarkContainingBlockChain, SubtreeLayoutScope* = 0);
void setNeedsPositionedMovementLayout();
void setPreferredLogicalWidthsDirty(MarkingBehavior = MarkContainingBlockChain);
void clearPreferredLogicalWidthsDirty();
void invalidateContainerPreferredLogicalWidths();
void setNeedsLayoutAndPrefWidthsRecalc()
{
setNeedsLayout();
setPreferredLogicalWidthsDirty();
}
void setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation()
{
setNeedsLayoutAndFullPaintInvalidation();
setPreferredLogicalWidthsDirty();
}
void setPositionState(EPosition position)
{
ASSERT((position != AbsolutePosition && position != FixedPosition) || isBox());
m_bitfields.setPositionedState(position);
}
void clearPositionedState() { m_bitfields.clearPositionedState(); }
void setFloating(bool isFloating) { m_bitfields.setFloating(isFloating); }
void setInline(bool isInline) { m_bitfields.setIsInline(isInline); }
void setHasBoxDecorationBackground(bool);
void invalidateBackgroundObscurationStatus();
virtual bool computeBackgroundIsKnownToBeObscured() { return false; }
void setIsText() { m_bitfields.setIsText(true); }
void setIsBox() { m_bitfields.setIsBox(true); }
void setReplaced(bool isReplaced) { m_bitfields.setIsReplaced(isReplaced); }
void setHorizontalWritingMode(bool hasHorizontalWritingMode) { m_bitfields.setHorizontalWritingMode(hasHorizontalWritingMode); }
void setHasOverflowClip(bool hasOverflowClip) { m_bitfields.setHasOverflowClip(hasOverflowClip); }
void setHasLayer(bool hasLayer) { m_bitfields.setHasLayer(hasLayer); }
void setHasTransformRelatedProperty(bool hasTransform) { m_bitfields.setHasTransformRelatedProperty(hasTransform); }
void setHasReflection(bool hasReflection) { m_bitfields.setHasReflection(hasReflection); }
void scheduleRelayout();
void updateFillImages(const FillLayer* oldLayers, const FillLayer& newLayers);
void updateImage(StyleImage*, StyleImage*);
void updateShapeImage(const ShapeValue*, const ShapeValue*);
// paintOffset is the offset from the origin of the GraphicsContext at which to paint the current object.
virtual void paint(const PaintInfo&, const LayoutPoint& paintOffset);
// Subclasses must reimplement this method to compute the size and position
// of this object and all its descendants.
virtual void layout() = 0;
virtual bool updateImageLoadingPriorities() { return false; }
void setHasPendingResourceUpdate(bool hasPendingResourceUpdate) { m_bitfields.setHasPendingResourceUpdate(hasPendingResourceUpdate); }
bool hasPendingResourceUpdate() const { return m_bitfields.hasPendingResourceUpdate(); }
/* This function performs a layout only if one is needed. */
void layoutIfNeeded() { if (needsLayout()) layout(); }
void forceLayout();
void forceChildLayout();
// Used for element state updates that cannot be fixed with a
// paint invalidation and do not need a relayout.
virtual void updateFromElement() { }
virtual void addAnnotatedRegions(Vector<AnnotatedRegionValue>&);
void collectAnnotatedRegions(Vector<AnnotatedRegionValue>&);
CompositingState compositingState() const;
virtual CompositingReasons additionalCompositingReasons() const;
bool hitTest(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestFilter = HitTestAll);
virtual void updateHitTestResult(HitTestResult&, const LayoutPoint&);
virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
virtual PositionWithAffinity positionForPoint(const LayoutPoint&);
PositionWithAffinity createPositionWithAffinity(int offset, EAffinity);
PositionWithAffinity createPositionWithAffinity(const Position&);
virtual void dirtyLinesFromChangedChild(RenderObject*);
// Set the style of the object and update the state of the object accordingly.
void setStyle(PassRefPtr<RenderStyle>);
// Set the style of the object if it's generated content.
void setPseudoStyle(PassRefPtr<RenderStyle>);
// Updates only the local style ptr of the object. Does not update the state of the object,
// and so only should be called when the style is known not to have changed (or from setStyle).
void setStyleInternal(PassRefPtr<RenderStyle> style) { m_style = style; }
// returns the containing block level element for this element.
RenderBlock* containingBlock() const;
bool canContainFixedPositionObjects() const
{
return isRenderView() || (hasTransformRelatedProperty() && isRenderBlock()) || isSVGForeignObject();
}
// Convert the given local point to absolute coordinates
// FIXME: Temporary. If UseTransforms is true, take transforms into account. Eventually localToAbsolute() will always be transform-aware.
FloatPoint localToAbsolute(const FloatPoint& localPoint = FloatPoint(), MapCoordinatesFlags = 0) const;
FloatPoint absoluteToLocal(const FloatPoint&, MapCoordinatesFlags = 0) const;
// Convert a local quad to absolute coordinates, taking transforms into account.
FloatQuad localToAbsoluteQuad(const FloatQuad& quad, MapCoordinatesFlags mode = 0, bool* wasFixed = 0) const
{
return localToContainerQuad(quad, 0, mode, wasFixed);
}
// Convert an absolute quad to local coordinates.
FloatQuad absoluteToLocalQuad(const FloatQuad&, MapCoordinatesFlags mode = 0) const;
// Convert a local quad into the coordinate system of container, taking transforms into account.
FloatQuad localToContainerQuad(const FloatQuad&, const RenderLayerModelObject* paintInvalidatinoContainer, MapCoordinatesFlags = 0, bool* wasFixed = 0) const;
FloatPoint localToContainerPoint(const FloatPoint&, const RenderLayerModelObject* paintInvalidationContainer, MapCoordinatesFlags = 0, bool* wasFixed = 0, const PaintInvalidationState* = 0) const;
// Convert a local point into the coordinate system of backing coordinates. Also returns the backing layer if needed.
FloatPoint localToInvalidationBackingPoint(const LayoutPoint&, RenderLayer** backingLayer = nullptr);
// 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 RenderObject*, const LayoutPoint&, bool* offsetDependsOnPoint = 0) const;
// Return the offset from an object up the container() chain. Asserts that none of the intermediate objects have transforms.
LayoutSize offsetFromAncestorContainer(const RenderObject*) const;
virtual void absoluteRects(Vector<IntRect>&, const LayoutPoint&) const { }
IntRect absoluteBoundingBoxRect() const;
// FIXME: This function should go away eventually
IntRect absoluteBoundingBoxRectIgnoringTransforms() const;
// Build an array of quads in absolute coords for line boxes
virtual void absoluteQuads(Vector<FloatQuad>&, bool* /*wasFixed*/ = 0) const { }
virtual IntRect absoluteFocusRingBoundingBoxRect() const;
static FloatRect absoluteBoundingBoxRectForRange(const Range*);
// the rect that will be painted if this object is passed as the paintingRoot
LayoutRect paintingRootRect(LayoutRect& topLevelRect);
virtual LayoutUnit minPreferredLogicalWidth() const { return 0; }
virtual LayoutUnit maxPreferredLogicalWidth() const { return 0; }
RenderStyle* style() const { return m_style.get(); }
/* The two following methods are inlined in RenderObjectInlines.h */
RenderStyle* firstLineStyle() const;
RenderStyle* style(bool firstLine) const;
inline Color resolveColor(const RenderStyle* styleToUse, int colorProperty) const
{
return styleToUse->visitedDependentColor(colorProperty);
}
inline Color resolveColor(int colorProperty) const
{
return style()->visitedDependentColor(colorProperty);
}
// Used only by Element::pseudoStyleCacheIsInvalid to get a first line style based off of a
// given new style, without accessing the cache.
PassRefPtr<RenderStyle> uncachedFirstLineStyle(RenderStyle*) const;
virtual CursorDirective getCursor(const LayoutPoint&, Cursor&) const;
struct AppliedTextDecoration {
Color color;
TextDecorationStyle style;
AppliedTextDecoration() : color(Color::transparent), style(TextDecorationStyleSolid) { }
};
void getTextDecorations(unsigned decorations, AppliedTextDecoration& underline, AppliedTextDecoration& overline, AppliedTextDecoration& linethrough, bool quirksMode = false, bool firstlineStyle = false);
// Return the RenderLayerModelObject in the container chain which is responsible for painting this object, or 0
// if painting is root-relative. This is the container that should be passed to the 'forPaintInvalidation'
// methods.
const RenderLayerModelObject* containerForPaintInvalidation() const;
const RenderLayerModelObject* adjustCompositedContainerForSpecialAncestors(const RenderLayerModelObject* paintInvalidationContainer) const;
bool isPaintInvalidationContainer() const;
LayoutRect computePaintInvalidationRect()
{
return computePaintInvalidationRect(containerForPaintInvalidation());
}
// Returns the paint invalidation rect for this RenderObject in the coordinate space of the paint backing (typically a GraphicsLayer) for |paintInvalidationContainer|.
LayoutRect computePaintInvalidationRect(const RenderLayerModelObject* paintInvalidationContainer, const PaintInvalidationState* = 0) const;
// Returns the rect bounds needed to invalidate the paint of this object, in the coordinate space of the rendering backing of |paintInvalidationContainer|
LayoutRect boundsRectForPaintInvalidation(const RenderLayerModelObject* paintInvalidationContainer, const PaintInvalidationState* = 0) const;
// Actually do the paint invalidate of rect r for this object which has been computed in the coordinate space
// of the GraphicsLayer backing of |paintInvalidationContainer|. Note that this coordinaten space is not the same
// as the local coordinate space of |paintInvalidationContainer| in the presence of layer squashing.
// If |paintInvalidationContainer| is 0, invalidate paints via the view.
// FIXME: |paintInvalidationContainer| should never be 0. See crbug.com/363699.
void invalidatePaintUsingContainer(const RenderLayerModelObject* paintInvalidationContainer, const LayoutRect&, PaintInvalidationReason) const;
// Invalidate the paint of a specific subrectangle within a given object. The rect |r| is in the object's coordinate space.
void invalidatePaintRectangle(const LayoutRect&) const;
void invalidateSelectionIfNeeded(const RenderLayerModelObject&, PaintInvalidationReason);
// Walk the tree after layout issuing paint invalidations for renderers that have changed or moved, updating bounds that have changed, and clearing paint invalidation state.
virtual void invalidateTreeIfNeeded(const PaintInvalidationState&);
virtual void invalidatePaintForOverflow();
void invalidatePaintForOverflowIfNeeded();
void invalidatePaintIncludingNonCompositingDescendants();
// Returns the rect that should have paint invalidated whenever this object changes. The rect is in the view's
// coordinate space. This method deals with outlines and overflow.
virtual LayoutRect absoluteClippedOverflowRect() const;
virtual LayoutRect clippedOverflowRectForPaintInvalidation(const RenderLayerModelObject* paintInvalidationContainer, const PaintInvalidationState* = 0) const;
virtual LayoutRect rectWithOutlineForPaintInvalidation(const RenderLayerModelObject* paintInvalidationContainer, LayoutUnit outlineWidth, const PaintInvalidationState* = 0) const;
// Given a rect in the object's coordinate space, compute a rect suitable for invalidating paints of
// that rect in the coordinate space of paintInvalidationContainer.
virtual void mapRectToPaintInvalidationBacking(const RenderLayerModelObject* paintInvalidationContainer, LayoutRect&, const PaintInvalidationState*) const;
// Return the offset to the column in which the specified point (in flow-thread coordinates)
// lives. This is used to convert a flow-thread point to a visual point.
virtual LayoutSize columnOffset(const LayoutPoint&) const { return LayoutSize(); }
virtual unsigned length() const { return 1; }
bool isFloatingOrOutOfFlowPositioned() const { return (isFloating() || isOutOfFlowPositioned()); }
bool isTransparent() const { return style()->hasOpacity(); }
float opacity() const { return style()->opacity(); }
bool hasReflection() const { return m_bitfields.hasReflection(); }
enum SelectionState {
SelectionNone, // The object is not selected.
SelectionStart, // The object either contains the start of a selection run or is the start of a run
SelectionInside, // The object is fully encompassed by a selection run
SelectionEnd, // The object either contains the end of a selection run or is the end of a run
SelectionBoth // 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 SelectionState enum declaration).
SelectionState selectionState() const { return m_bitfields.selectionState(); }
virtual void setSelectionState(SelectionState state) { m_bitfields.setSelectionState(state); }
inline void setSelectionStateIfNeeded(SelectionState);
bool canUpdateSelectionOnRootLineBoxes() const;
// 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 selectionRectForPaintInvalidation(const RenderLayerModelObject* /*paintInvalidationContainer*/) const { return LayoutRect(); }
virtual bool canBeSelectionLeaf() const { return false; }
bool hasSelectedChildren() const { return selectionState() != SelectionNone; }
bool isSelectable() const;
// Obtains the selection colors that should be used when painting a selection.
Color selectionBackgroundColor() const;
Color selectionForegroundColor() const;
Color selectionEmphasisMarkColor() const;
// Whether or not a given block needs to paint selection gaps.
virtual bool shouldPaintSelectionGaps() const { return false; }
/**
* Returns the local coordinates of the caret within this render object.
* @param caretOffset zero-based offset determining position within the render object.
* @param extraWidthToEndOfLine optional out arg to give extra width to end of line -
* useful for character range rect computations
*/
virtual LayoutRect localCaretRect(InlineBox*, int caretOffset, LayoutUnit* extraWidthToEndOfLine = 0);
// When performing a global document tear-down, the renderer of the document is cleared. We use this
// as a hook to detect the case of document destruction and don't waste time doing unnecessary work.
bool documentBeingDestroyed() const;
void destroyAndCleanupAnonymousWrappers();
virtual 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;
virtual void imageChanged(ImageResource*, const IntRect* = 0) override final;
virtual void imageChanged(WrappedImagePtr, const IntRect* = 0) { }
virtual bool willRenderImage(ImageResource*) override final;
virtual bool getImageAnimationPolicy(ImageResource*, ImageAnimationPolicy&) override final;
void selectionStartEnd(int& spos, int& epos) const;
void remove() { if (parent()) parent()->removeChild(this); }
bool isInert() const;
bool supportsTouchAction() const;
bool visibleToHitTestRequest(const HitTestRequest& request) const { return style()->visibility() == VISIBLE && (request.ignorePointerEventsNone() || style()->pointerEvents() != PE_NONE) && !isInert(); }
bool visibleToHitTesting() const { return style()->visibility() == VISIBLE && style()->pointerEvents() != PE_NONE && !isInert(); }
// 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* paintInvalidationContainer, TransformState&, MapCoordinatesFlags = ApplyContainerFlip, bool* wasFixed = 0, const PaintInvalidationState* = 0) const;
virtual void mapAbsoluteToLocalPoint(MapCoordinatesFlags, 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;
bool createsGroup() const { return isTransparent() || hasMask() || hasFilter() || style()->hasBlendMode(); }
virtual void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint& additionalOffset) const { }
// Compute a list of hit-test rectangles per layer rooted at this renderer.
virtual void computeLayerHitTestRects(LayerHitTestRects&) const;
// Return the renderer whose background style is used to paint the root background. Should only be called on the renderer for which isDocumentElement() is true.
RenderObject* rendererForRootBackground();
RespectImageOrientationEnum shouldRespectImageOrientation() const;
bool isRelayoutBoundaryForInspector() const;
// The previous paint invalidation rect in the object's previous paint backing.
const LayoutRect& previousPaintInvalidationRect() const { return m_previousPaintInvalidationRect; }
void setPreviousPaintInvalidationRect(const LayoutRect& rect) { m_previousPaintInvalidationRect = rect; }
// The previous position of the top-left corner of the object in its previous paint backing.
const LayoutPoint& previousPositionFromPaintInvalidationBacking() const { return m_previousPositionFromPaintInvalidationBacking; }
void setPreviousPositionFromPaintInvalidationBacking(const LayoutPoint& positionFromPaintInvalidationBacking) { m_previousPositionFromPaintInvalidationBacking = positionFromPaintInvalidationBacking; }
bool shouldDoFullPaintInvalidation() const { return m_bitfields.fullPaintInvalidationReason() != PaintInvalidationNone; }
void setShouldDoFullPaintInvalidation(PaintInvalidationReason = PaintInvalidationFull);
void clearShouldDoFullPaintInvalidation() { m_bitfields.setFullPaintInvalidationReason(PaintInvalidationNone); }
bool shouldInvalidateOverflowForPaint() const { return m_bitfields.shouldInvalidateOverflowForPaint(); }
virtual void clearPaintInvalidationState(const PaintInvalidationState&);
// Indicates whether this render object was re-laid-out since the last frame.
// The flag will be cleared during invalidateTreeIfNeeded.
bool layoutDidGetCalledSinceLastFrame() const { return m_bitfields.layoutDidGetCalledSinceLastFrame(); }
bool mayNeedPaintInvalidation() const { return m_bitfields.mayNeedPaintInvalidation(); }
void setMayNeedPaintInvalidation(bool b)
{
m_bitfields.setMayNeedPaintInvalidation(b);
// Make sure our parent is marked as needing invalidation.
if (b)
markContainingBlockChainForPaintInvalidation();
}
bool shouldInvalidateSelection() const { return m_bitfields.shouldInvalidateSelection(); }
void setShouldInvalidateSelection()
{
if (!canUpdateSelectionOnRootLineBoxes())
return;
m_bitfields.setShouldInvalidateSelection(true);
markContainingBlockChainForPaintInvalidation();
}
void clearShouldInvalidateSelection() { m_bitfields.setShouldInvalidateSelection(false); }
bool neededLayoutBecauseOfChildren() const { return m_bitfields.neededLayoutBecauseOfChildren(); }
void setNeededLayoutBecauseOfChildren(bool b) { m_bitfields.setNeededLayoutBecauseOfChildren(b); }
bool shouldCheckForPaintInvalidation(const PaintInvalidationState& paintInvalidationState) const
{
return paintInvalidationState.forceCheckForPaintInvalidation() || shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState();
}
bool shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState() const
{
return layoutDidGetCalledSinceLastFrame() || mayNeedPaintInvalidation() || shouldDoFullPaintInvalidation() || shouldInvalidateSelection();
}
virtual bool supportsPaintInvalidationStateCachedOffsets() const { return !hasColumns() && !hasTransformRelatedProperty() && !hasReflection() && !style()->isFlippedBlocksWritingMode(); }
void setNeedsOverflowRecalcAfterStyleChange();
void markContainingBlocksForOverflowRecalc();
virtual LayoutRect viewRect() const;
DisplayItemClient displayItemClient() const { return static_cast<DisplayItemClientInternalVoid*>((void*)this); }
protected:
enum RenderObjectType {
RenderObjectBr,
RenderObjectCanvas,
RenderObjectFieldset,
RenderObjectCounter,
RenderObjectDetailsMarker,
RenderObjectEmbeddedObject,
RenderObjectFileUploadControl,
RenderObjectFrame,
RenderObjectFrameSet,
RenderObjectListBox,
RenderObjectListItem,
RenderObjectListMarker,
RenderObjectMedia,
RenderObjectMenuList,
RenderObjectMeter,
RenderObjectProgress,
RenderObjectQuote,
RenderObjectRenderButton,
RenderObjectRenderFlowThread,
RenderObjectRenderFullScreen,
RenderObjectRenderFullScreenPlaceholder,
RenderObjectRenderGrid,
RenderObjectRenderIFrame,
RenderObjectRenderImage,
RenderObjectRenderInline,
RenderObjectRenderMultiColumnSet,
RenderObjectRenderMultiColumnSpannerPlaceholder,
RenderObjectRenderPart,
RenderObjectRenderRegion,
RenderObjectRenderScrollbarPart,
RenderObjectRenderTableCol,
RenderObjectRenderView,
RenderObjectReplica,
RenderObjectRuby,
RenderObjectRubyBase,
RenderObjectRubyRun,
RenderObjectRubyText,
RenderObjectSlider,
RenderObjectSliderThumb,
RenderObjectTable,
RenderObjectTableCaption,
RenderObjectTableCell,
RenderObjectTableRow,
RenderObjectTableSection,
RenderObjectTextArea,
RenderObjectTextControl,
RenderObjectTextField,
RenderObjectVideo,
RenderObjectWidget,
RenderObjectSVG, /* Keep by itself? */
RenderObjectSVGRoot,
RenderObjectSVGContainer,
RenderObjectSVGTransformableContainer,
RenderObjectSVGViewportContainer,
RenderObjectSVGHiddenContainer,
RenderObjectSVGGradientStop,
RenderObjectSVGShape,
RenderObjectSVGText,
RenderObjectSVGTextPath,
RenderObjectSVGInline,
RenderObjectSVGInlineText,
RenderObjectSVGImage,
RenderObjectSVGForeignObject,
RenderObjectSVGResourceContainer,
RenderObjectSVGResourceFilter,
RenderObjectSVGResourceFilterPrimitive,
};
virtual bool isOfType(RenderObjectType type) const { return false; }
inline bool layerCreationAllowedForSubtree() const;
// Overrides should call the superclass at the end. m_style will be 0 the first time
// this function will be called.
virtual void styleWillChange(StyleDifference, const RenderStyle& newStyle);
// Overrides should call the superclass at the start. |oldStyle| will be 0 the first
// time this function is called.
virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
void propagateStyleToAnonymousChildren(bool blockChildrenOnly = false);
virtual void updateAnonymousChildStyle(const RenderObject* child, RenderStyle* style) const { }
protected:
void clearLayoutRootIfNeeded() const;
virtual void willBeDestroyed();
void postDestroy();
virtual void insertedIntoTree();
virtual void willBeRemovedFromTree();
void setDocumentForAnonymous(Document* document) { ASSERT(isAnonymous()); m_node = document; }
// Add hit-test rects for the render tree rooted at this node to the provided collection on a
// per-RenderLayer basis.
// currentLayer must be the enclosing layer, and layerOffset is the current offset within
// this layer. Subclass implementations will add any offset for this renderer within it's
// container, so callers should provide only the offset of the container within it's layer.
// containerRect is a rect that has already been added for the currentLayer which is likely to
// be a container for child elements. Any rect wholly contained by containerRect can be
// skipped.
virtual void addLayerHitTestRects(LayerHitTestRects&, const RenderLayer* currentLayer, const LayoutPoint& layerOffset, const LayoutRect& containerRect) const;
// Add hit-test rects for this renderer only to the provided list. layerOffset is the offset
// of this renderer within the current layer that should be used for each result.
virtual void computeSelfHitTestRects(Vector<LayoutRect>&, const LayoutPoint& layerOffset) const { };
virtual PaintInvalidationReason paintInvalidationReason(const RenderLayerModelObject& paintInvalidationContainer,
const LayoutRect& oldPaintInvalidationRect, const LayoutPoint& oldPositionFromPaintInvalidationBacking,
const LayoutRect& newPaintInvalidationRect, const LayoutPoint& newPositionFromPaintInvalidationBacking) const;
virtual void incrementallyInvalidatePaint(const RenderLayerModelObject& paintInvalidationContainer, const LayoutRect& oldBounds, const LayoutRect& newBounds, const LayoutPoint& positionFromPaintInvalidationBacking);
void fullyInvalidatePaint(const RenderLayerModelObject& paintInvalidationContainer, PaintInvalidationReason, const LayoutRect& oldBounds, const LayoutRect& newBounds);
#if ENABLE(ASSERT)
virtual bool paintInvalidationStateIsDirty() const
{
return neededLayoutBecauseOfChildren() || shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState();
}
#endif
virtual void invalidatePaintOfSubtreesIfNeeded(const PaintInvalidationState& childPaintInvalidationState);
virtual PaintInvalidationReason invalidatePaintIfNeeded(const PaintInvalidationState&, const RenderLayerModelObject& paintInvalidationContainer);
private:
void setLayoutDidGetCalledSinceLastFrame()
{
m_bitfields.setLayoutDidGetCalledSinceLastFrame(true);
// Make sure our parent is marked as needing invalidation.
// This would be unneeded if we allowed sub-tree invalidation (akin to sub-tree layouts).
markContainingBlockChainForPaintInvalidation();
}
void clearLayoutDidGetCalledSinceLastFrame() { m_bitfields.setLayoutDidGetCalledSinceLastFrame(false); }
void invalidatePaintIncludingNonCompositingDescendantsInternal(const RenderLayerModelObject* repaintContainer);
LayoutRect previousSelectionRectForPaintInvalidation() const;
void setPreviousSelectionRectForPaintInvalidation(const LayoutRect&);
const RenderLayerModelObject* enclosingCompositedContainer() const;
RenderFlowThread* locateFlowThreadContainingBlock() const;
void removeFromRenderFlowThread();
void removeFromRenderFlowThreadRecursive(RenderFlowThread*);
RenderStyle* cachedFirstLineStyle() const;
StyleDifference adjustStyleDifference(StyleDifference) const;
Color selectionColor(int colorProperty) const;
void removeShapeImageClient(ShapeValue*);
#if ENABLE(ASSERT)
void checkBlockPositionedObjectsNeedLayout();
#endif
void markContainingBlockChainForPaintInvalidation()
{
for (RenderObject* container = this->container(); container && !container->shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState(); container = container->container())
container->setMayNeedPaintInvalidation(true);
}
static bool isAllowedToModifyRenderTreeStructure(Document&);
RefPtr<RenderStyle> m_style;
RawPtrWillBeMember<Node> m_node;
RawPtrWillBeMember<RenderObject> m_parent;
RawPtrWillBeMember<RenderObject> m_previous;
RawPtrWillBeMember<RenderObject> m_next;
#if ENABLE(ASSERT)
unsigned m_hasAXObject : 1;
unsigned m_setNeedsLayoutForbidden : 1;
#if ENABLE(OILPAN)
protected:
unsigned m_didCallDestroy : 1;
private:
#endif
#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; }\
class RenderObjectBitfields {
enum PositionedState {
IsStaticallyPositioned = 0,
IsRelativelyPositioned = 1,
IsOutOfFlowPositioned = 2,
};
public:
RenderObjectBitfields(Node* node)
: m_selfNeedsLayout(false)
, m_shouldInvalidateOverflowForPaint(false)
// FIXME: We should remove mayNeedPaintInvalidation once we are able to
// use the other layout flags to detect the same cases. crbug.com/370118
, m_mayNeedPaintInvalidation(false)
, m_shouldInvalidateSelection(false)
, m_neededLayoutBecauseOfChildren(false)
, m_needsPositionedMovementLayout(false)
, m_normalChildNeedsLayout(false)
, m_posChildNeedsLayout(false)
, m_needsSimplifiedNormalFlowLayout(false)
, m_preferredLogicalWidthsDirty(false)
, m_floating(false)
, m_selfNeedsOverflowRecalcAfterStyleChange(false)
, m_childNeedsOverflowRecalcAfterStyleChange(false)
, m_isAnonymous(!node)
, m_isText(false)
, m_isBox(false)
, m_isInline(true)
, m_isReplaced(false)
, m_horizontalWritingMode(true)
, m_isDragging(false)
, m_hasLayer(false)
, m_hasOverflowClip(false)
, m_hasTransformRelatedProperty(false)
, m_hasReflection(false)
, m_hasCounterNodeMap(false)
, m_everHadLayout(false)
, m_ancestorLineBoxDirty(false)
, m_layoutDidGetCalledSinceLastFrame(false)
, m_hasPendingResourceUpdate(false)
, m_childrenInline(false)
, m_hasColumns(false)
, m_alwaysCreateLineBoxesForRenderInline(false)
, m_positionedState(IsStaticallyPositioned)
, m_selectionState(SelectionNone)
, m_flowThreadState(NotInsideFlowThread)
, m_boxDecorationBackgroundState(NoBoxDecorationBackground)
, m_fullPaintInvalidationReason(PaintInvalidationNone)
{
}
// 32 bits have been used in the first word, and 14 in the second.
ADD_BOOLEAN_BITFIELD(selfNeedsLayout, SelfNeedsLayout);
ADD_BOOLEAN_BITFIELD(shouldInvalidateOverflowForPaint, ShouldInvalidateOverflowForPaint);
ADD_BOOLEAN_BITFIELD(mayNeedPaintInvalidation, MayNeedPaintInvalidation);
ADD_BOOLEAN_BITFIELD(shouldInvalidateSelection, ShouldInvalidateSelection);
ADD_BOOLEAN_BITFIELD(neededLayoutBecauseOfChildren, NeededLayoutBecauseOfChildren);
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(selfNeedsOverflowRecalcAfterStyleChange, SelfNeedsOverflowRecalcAfterStyleChange);
ADD_BOOLEAN_BITFIELD(childNeedsOverflowRecalcAfterStyleChange, ChildNeedsOverflowRecalcAfterStyleChange);
ADD_BOOLEAN_BITFIELD(isAnonymous, IsAnonymous);
ADD_BOOLEAN_BITFIELD(isText, IsText);
ADD_BOOLEAN_BITFIELD(isBox, IsBox);
ADD_BOOLEAN_BITFIELD(isInline, IsInline);
ADD_BOOLEAN_BITFIELD(isReplaced, IsReplaced);
ADD_BOOLEAN_BITFIELD(horizontalWritingMode, HorizontalWritingMode);
ADD_BOOLEAN_BITFIELD(isDragging, IsDragging);
ADD_BOOLEAN_BITFIELD(hasLayer, HasLayer);
ADD_BOOLEAN_BITFIELD(hasOverflowClip, HasOverflowClip); // Set in the case of overflow:auto/scroll/hidden
ADD_BOOLEAN_BITFIELD(hasTransformRelatedProperty, HasTransformRelatedProperty);
ADD_BOOLEAN_BITFIELD(hasReflection, HasReflection);
ADD_BOOLEAN_BITFIELD(hasCounterNodeMap, HasCounterNodeMap);
ADD_BOOLEAN_BITFIELD(everHadLayout, EverHadLayout);
ADD_BOOLEAN_BITFIELD(ancestorLineBoxDirty, AncestorLineBoxDirty);
ADD_BOOLEAN_BITFIELD(layoutDidGetCalledSinceLastFrame, LayoutDidGetCalledSinceLastFrame);
ADD_BOOLEAN_BITFIELD(hasPendingResourceUpdate, HasPendingResourceUpdate);
// from RenderBlock
ADD_BOOLEAN_BITFIELD(childrenInline, ChildrenInline);
ADD_BOOLEAN_BITFIELD(hasColumns, HasColumns);
// from RenderInline
ADD_BOOLEAN_BITFIELD(alwaysCreateLineBoxesForRenderInline, AlwaysCreateLineBoxesForRenderInline);
private:
unsigned m_positionedState : 2; // PositionedState
unsigned m_selectionState : 3; // SelectionState
unsigned m_flowThreadState : 2; // FlowThreadState
unsigned m_boxDecorationBackgroundState : 2; // BoxDecorationBackgroundState
unsigned m_fullPaintInvalidationReason : 5; // PaintInvalidationReason
public:
bool isOutOfFlowPositioned() const { return m_positionedState == IsOutOfFlowPositioned; }
bool isRelPositioned() const { return m_positionedState == IsRelativelyPositioned; }
bool isPositioned() const { return m_positionedState != IsStaticallyPositioned; }
void setPositionedState(int positionState)
{
// This mask maps FixedPosition and AbsolutePosition to IsOutOfFlowPositioned, saving one bit.
m_positionedState = static_cast<PositionedState>(positionState & 0x3);
}
void clearPositionedState() { m_positionedState = StaticPosition; }
ALWAYS_INLINE SelectionState selectionState() const { return static_cast<SelectionState>(m_selectionState); }
ALWAYS_INLINE void setSelectionState(SelectionState selectionState) { m_selectionState = selectionState; }
ALWAYS_INLINE FlowThreadState flowThreadState() const { return static_cast<FlowThreadState>(m_flowThreadState); }
ALWAYS_INLINE void setFlowThreadState(FlowThreadState flowThreadState) { m_flowThreadState = flowThreadState; }
ALWAYS_INLINE BoxDecorationBackgroundState boxDecorationBackgroundState() const { return static_cast<BoxDecorationBackgroundState>(m_boxDecorationBackgroundState); }
ALWAYS_INLINE void setBoxDecorationBackgroundState(BoxDecorationBackgroundState s) { m_boxDecorationBackgroundState = s; }
PaintInvalidationReason fullPaintInvalidationReason() const { return static_cast<PaintInvalidationReason>(m_fullPaintInvalidationReason); }
void setFullPaintInvalidationReason(PaintInvalidationReason reason) { m_fullPaintInvalidationReason = reason; }
};
#undef ADD_BOOLEAN_BITFIELD
RenderObjectBitfields m_bitfields;
void setSelfNeedsLayout(bool b) { m_bitfields.setSelfNeedsLayout(b); }
void setNeedsPositionedMovementLayout(bool b) { m_bitfields.setNeedsPositionedMovementLayout(b); }
void setNormalChildNeedsLayout(bool b) { m_bitfields.setNormalChildNeedsLayout(b); }
void setPosChildNeedsLayout(bool b) { m_bitfields.setPosChildNeedsLayout(b); }
void setNeedsSimplifiedNormalFlowLayout(bool b) { m_bitfields.setNeedsSimplifiedNormalFlowLayout(b); }
void setIsDragging(bool b) { m_bitfields.setIsDragging(b); }
void setEverHadLayout(bool b) { m_bitfields.setEverHadLayout(b); }
void setShouldInvalidateOverflowForPaint(bool b) { m_bitfields.setShouldInvalidateOverflowForPaint(b); }
void setSelfNeedsOverflowRecalcAfterStyleChange(bool b) { m_bitfields.setSelfNeedsOverflowRecalcAfterStyleChange(b); }
void setChildNeedsOverflowRecalcAfterStyleChange(bool b) { m_bitfields.setChildNeedsOverflowRecalcAfterStyleChange(b); }
private:
// Store state between styleWillChange and styleDidChange
static bool s_affectsParentBlock;
// This stores the paint invalidation rect from the previous frame.
LayoutRect m_previousPaintInvalidationRect;
// This stores the position in the paint invalidation backing's coordinate.
// It is used to detect renderer shifts that forces a full invalidation.
LayoutPoint m_previousPositionFromPaintInvalidationBacking;
static unsigned s_instanceCount;
};
WILL_NOT_BE_EAGERLY_TRACED_CLASS(RenderObject);
// FIXME: remove this once the render object lifecycle ASSERTS are no longer hit.
class DeprecatedDisableModifyRenderTreeStructureAsserts {
WTF_MAKE_NONCOPYABLE(DeprecatedDisableModifyRenderTreeStructureAsserts);
public:
DeprecatedDisableModifyRenderTreeStructureAsserts();
static bool canModifyRenderTreeStateInAnyState();
private:
TemporaryChange<bool> m_disabler;
};
// Allow equality comparisons of RenderObjects by reference or pointer, interchangeably.
DEFINE_COMPARISON_OPERATORS_WITH_REFERENCES(RenderObject)
inline bool RenderObject::documentBeingDestroyed() const
{
return document().lifecycle().state() >= DocumentLifecycle::Stopping;
}
inline bool RenderObject::isBeforeContent() const
{
if (style()->styleType() != BEFORE)
return false;
// Text nodes don't have their own styles, so ignore the style on a text node.
if (isText() && !isBR())
return false;
return true;
}
inline bool RenderObject::isAfterContent() const
{
if (style()->styleType() != AFTER)
return false;
// Text nodes don't have their own styles, so ignore the style on a text node.
if (isText() && !isBR())
return false;
return true;
}
inline bool RenderObject::isBeforeOrAfterContent() const
{
return isBeforeContent() || isAfterContent();
}
// setNeedsLayout() won't cause full paint invalidations as
// setNeedsLayoutAndFullPaintInvalidation() does. Otherwise the two methods are identical.
inline void RenderObject::setNeedsLayout(MarkingBehavior markParents, SubtreeLayoutScope* layouter)
{
TRACE_EVENT_INSTANT1(
TRACE_DISABLED_BY_DEFAULT("devtools.timeline.invalidationTracking"),
"LayoutInvalidationTracking",
"data",
InspectorLayoutInvalidationTrackingEvent::data(this));
ASSERT(!isSetNeedsLayoutForbidden());
bool alreadyNeededLayout = m_bitfields.selfNeedsLayout();
setSelfNeedsLayout(true);
if (!alreadyNeededLayout) {
if (markParents == MarkContainingBlockChain && (!layouter || layouter->root() != this))
markContainingBlocksForLayout(true, 0, layouter);
}
}
inline void RenderObject::setNeedsLayoutAndFullPaintInvalidation(MarkingBehavior markParents, SubtreeLayoutScope* layouter)
{
setNeedsLayout(markParents, layouter);
setShouldDoFullPaintInvalidation();
}
inline void RenderObject::clearNeedsLayout()
{
setNeededLayoutBecauseOfChildren(needsLayoutBecauseOfChildren());
setLayoutDidGetCalledSinceLastFrame();
setSelfNeedsLayout(false);
setEverHadLayout(true);
setPosChildNeedsLayout(false);
setNeedsSimplifiedNormalFlowLayout(false);
setNormalChildNeedsLayout(false);
setNeedsPositionedMovementLayout(false);
setAncestorLineBoxDirty(false);
#if ENABLE(ASSERT)
checkBlockPositionedObjectsNeedLayout();
#endif
}
inline void RenderObject::setChildNeedsLayout(MarkingBehavior markParents, SubtreeLayoutScope* layouter)
{
ASSERT(!isSetNeedsLayoutForbidden());
bool alreadyNeededLayout = normalChildNeedsLayout();
setNormalChildNeedsLayout(true);
// FIXME: Replace MarkOnlyThis with the SubtreeLayoutScope code path and remove the MarkingBehavior argument entirely.
if (!alreadyNeededLayout && markParents == MarkContainingBlockChain && (!layouter || layouter->root() != this))
markContainingBlocksForLayout(true, 0, layouter);
}
inline void RenderObject::setNeedsPositionedMovementLayout()
{
bool alreadyNeededLayout = needsPositionedMovementLayout();
setNeedsPositionedMovementLayout(true);
ASSERT(!isSetNeedsLayoutForbidden());
if (!alreadyNeededLayout)
markContainingBlocksForLayout();
}
inline bool RenderObject::preservesNewline() const
{
if (isSVGInlineText())
return false;
return style()->preserveNewline();
}
inline bool RenderObject::layerCreationAllowedForSubtree() const
{
RenderObject* parentRenderer = parent();
while (parentRenderer) {
if (parentRenderer->isSVGHiddenContainer())
return false;
parentRenderer = parentRenderer->parent();
}
return true;
}
inline void RenderObject::setSelectionStateIfNeeded(SelectionState state)
{
if (selectionState() == state)
return;
setSelectionState(state);
}
inline void RenderObject::setHasBoxDecorationBackground(bool b)
{
if (!b) {
m_bitfields.setBoxDecorationBackgroundState(NoBoxDecorationBackground);
return;
}
if (hasBoxDecorationBackground())
return;
m_bitfields.setBoxDecorationBackgroundState(HasBoxDecorationBackgroundObscurationStatusInvalid);
}
inline void RenderObject::invalidateBackgroundObscurationStatus()
{
if (!hasBoxDecorationBackground())
return;
m_bitfields.setBoxDecorationBackgroundState(HasBoxDecorationBackgroundObscurationStatusInvalid);
}
inline bool RenderObject::boxDecorationBackgroundIsKnownToBeObscured()
{
if (m_bitfields.boxDecorationBackgroundState() == HasBoxDecorationBackgroundObscurationStatusInvalid) {
BoxDecorationBackgroundState state = computeBackgroundIsKnownToBeObscured() ? HasBoxDecorationBackgroundKnownToBeObscured : HasBoxDecorationBackgroundMayBeVisible;
m_bitfields.setBoxDecorationBackgroundState(state);
}
return m_bitfields.boxDecorationBackgroundState() == HasBoxDecorationBackgroundKnownToBeObscured;
}
inline void makeMatrixRenderable(TransformationMatrix& matrix, bool has3DRendering)
{
if (!has3DRendering)
matrix.makeAffine();
}
inline int adjustForAbsoluteZoom(int value, RenderObject* renderer)
{
return adjustForAbsoluteZoom(value, renderer->style());
}
inline double adjustDoubleForAbsoluteZoom(double value, RenderObject& renderer)
{
ASSERT(renderer.style());
return adjustDoubleForAbsoluteZoom(value, *renderer.style());
}
inline LayoutUnit adjustLayoutUnitForAbsoluteZoom(LayoutUnit value, RenderObject& renderer)
{
ASSERT(renderer.style());
return adjustLayoutUnitForAbsoluteZoom(value, *renderer.style());
}
inline void adjustFloatQuadForAbsoluteZoom(FloatQuad& quad, RenderObject& renderer)
{
float zoom = renderer.style()->effectiveZoom();
if (zoom != 1)
quad.scale(1 / zoom, 1 / zoom);
}
inline void adjustFloatRectForAbsoluteZoom(FloatRect& rect, RenderObject& renderer)
{
float zoom = renderer.style()->effectiveZoom();
if (zoom != 1)
rect.scale(1 / zoom, 1 / zoom);
}
inline double adjustScrollForAbsoluteZoom(double value, RenderObject& renderer)
{
ASSERT(renderer.style());
return adjustScrollForAbsoluteZoom(value, *renderer.style());
}
#define DEFINE_RENDER_OBJECT_TYPE_CASTS(thisType, predicate) \
DEFINE_TYPE_CASTS(thisType, RenderObject, object, object->predicate, object.predicate)
} // namespace blink
#ifndef NDEBUG
// Outside the WebCore namespace for ease of invocation from gdb.
void showTree(const blink::RenderObject*);
void showLineTree(const blink::RenderObject*);
void showRenderTree(const blink::RenderObject* object1);
// We don't make object2 an optional parameter so that showRenderTree
// can be called from gdb easily.
void showRenderTree(const blink::RenderObject* object1, const blink::RenderObject* object2);
#endif
#endif // RenderObject_h
|