Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: Source/core/layout/LayoutObject.h

Issue 1315213002: (WIP) Paint invalidation for slimming paint v2 (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/layout/LayoutBox.cpp ('k') | Source/core/layout/LayoutObject.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Antti Koivisto (koivisto@kde.org) 3 * (C) 2000 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com)
6 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2009 Google Inc. All rights reserved. 7 * Copyright (C) 2009 Google Inc. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 906
907 bool hasReflection() const { return m_bitfields.hasReflection(); } 907 bool hasReflection() const { return m_bitfields.hasReflection(); }
908 908
909 // The current selection state for an object. For blocks, the state refers to the state of the leaf 909 // The current selection state for an object. For blocks, the state refers to the state of the leaf
910 // descendants (as described above in the SelectionState enum declaration). 910 // descendants (as described above in the SelectionState enum declaration).
911 SelectionState selectionState() const { return m_bitfields.selectionState(); } 911 SelectionState selectionState() const { return m_bitfields.selectionState(); }
912 virtual void setSelectionState(SelectionState state) { m_bitfields.setSelect ionState(state); } 912 virtual void setSelectionState(SelectionState state) { m_bitfields.setSelect ionState(state); }
913 inline void setSelectionStateIfNeeded(SelectionState); 913 inline void setSelectionStateIfNeeded(SelectionState);
914 bool canUpdateSelectionOnRootLineBoxes() const; 914 bool canUpdateSelectionOnRootLineBoxes() const;
915 915
916 // TODO: Remove for slimming paint v2.
916 // A single rectangle that encompasses all of the selected objects within th is object. Used to determine the tightest 917 // A single rectangle that encompasses all of the selected objects within th is object. Used to determine the tightest
917 // possible bounding box for the selection. The rect returned is in the coor dinate space of the paint invalidation container's backing. 918 // possible bounding box for the selection. The rect returned is in the coor dinate space of the paint invalidation container's backing.
918 virtual LayoutRect selectionRectForPaintInvalidation(const LayoutBoxModelObj ect* /*paintInvalidationContainer*/) const { return LayoutRect(); } 919 virtual LayoutRect selectionRectForPaintInvalidation(const LayoutBoxModelObj ect* /*paintInvalidationContainer*/) const { return LayoutRect(); }
919 920
920 // View coordinates means the coordinate space of |view()|. 921 // View coordinates means the coordinate space of |view()|.
921 LayoutRect selectionRectInViewCoordinates() const; 922 LayoutRect selectionRectInViewCoordinates() const;
922 923
923 virtual bool canBeSelectionLeaf() const { return false; } 924 virtual bool canBeSelectionLeaf() const { return false; }
924 bool hasSelectedChildren() const { return selectionState() != SelectionNone; } 925 bool hasSelectedChildren() const { return selectionState() != SelectionNone; }
925 926
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 void setPreviousPositionFromPaintInvalidationBacking(const LayoutPoint& posi tionFromPaintInvalidationBacking) { m_previousPositionFromPaintInvalidationBacki ng = positionFromPaintInvalidationBacking; } 1026 void setPreviousPositionFromPaintInvalidationBacking(const LayoutPoint& posi tionFromPaintInvalidationBacking) { m_previousPositionFromPaintInvalidationBacki ng = positionFromPaintInvalidationBacking; }
1026 1027
1027 PaintInvalidationReason fullPaintInvalidationReason() const { return m_bitfi elds.fullPaintInvalidationReason(); } 1028 PaintInvalidationReason fullPaintInvalidationReason() const { return m_bitfi elds.fullPaintInvalidationReason(); }
1028 bool shouldDoFullPaintInvalidation() const { return m_bitfields.fullPaintInv alidationReason() != PaintInvalidationNone; } 1029 bool shouldDoFullPaintInvalidation() const { return m_bitfields.fullPaintInv alidationReason() != PaintInvalidationNone; }
1029 void setShouldDoFullPaintInvalidation(PaintInvalidationReason = PaintInvalid ationFull); 1030 void setShouldDoFullPaintInvalidation(PaintInvalidationReason = PaintInvalid ationFull);
1030 void clearShouldDoFullPaintInvalidation() { m_bitfields.setFullPaintInvalida tionReason(PaintInvalidationNone); } 1031 void clearShouldDoFullPaintInvalidation() { m_bitfields.setFullPaintInvalida tionReason(PaintInvalidationNone); }
1031 1032
1032 bool shouldInvalidateOverflowForPaint() const { return m_bitfields.shouldInv alidateOverflowForPaint(); } 1033 bool shouldInvalidateOverflowForPaint() const { return m_bitfields.shouldInv alidateOverflowForPaint(); }
1033 1034
1034 virtual void clearPaintInvalidationState(const PaintInvalidationState&); 1035 virtual void clearPaintInvalidationState(const PaintInvalidationState&);
1036 void clearSelfPaintInvalidationFlags();
1035 1037
1036 bool mayNeedPaintInvalidation() const { return m_bitfields.mayNeedPaintInval idation(); } 1038 bool mayNeedPaintInvalidation() const { return m_bitfields.mayNeedPaintInval idation(); }
1037 void setMayNeedPaintInvalidation(); 1039 void setMayNeedPaintInvalidation();
1038 1040
1039 bool shouldInvalidateSelection() const { return m_bitfields.shouldInvalidate Selection(); } 1041 bool shouldInvalidateSelection() const { return m_bitfields.shouldInvalidate Selection(); }
1040 void setShouldInvalidateSelection(); 1042 void setShouldInvalidateSelection();
1041 1043
1042 bool shouldCheckForPaintInvalidation(const PaintInvalidationState& paintInva lidationState) const 1044 bool shouldCheckForPaintInvalidation(const PaintInvalidationState& paintInva lidationState) const
1043 { 1045 {
1044 // Should check for paint invalidation if some ancestor changed location , because this object 1046 // Should check for paint invalidation if some ancestor changed location , because this object
1045 // may also change paint offset or location in paint invalidation contai ner, even if there is 1047 // may also change paint offset or location in paint invalidation contai ner, even if there is
1046 // no paint invalidation flag set. 1048 // no paint invalidation flag set.
1047 return paintInvalidationState.ancestorHadPaintInvalidationForLocationCha nge() || shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState(); 1049 return paintInvalidationState.ancestorHadPaintInvalidationForLocationCha nge() || shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState();
1048 } 1050 }
1049 1051
1050 bool shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState() con st 1052 bool shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState() con st
1051 { 1053 {
1052 return mayNeedPaintInvalidation() || shouldDoFullPaintInvalidation() || shouldInvalidateSelection() || m_bitfields.childShouldCheckForPaintInvalidation( ); 1054 return selfShouldCheckForPaintInvalidation() || m_bitfields.childShouldC heckForPaintInvalidation();
1055 }
1056
1057 bool selfShouldCheckForPaintInvalidation() const
1058 {
1059 return mayNeedPaintInvalidation() || shouldDoFullPaintInvalidation() || shouldInvalidateSelection();
1053 } 1060 }
1054 1061
1055 virtual bool supportsPaintInvalidationStateCachedOffsets() const { return !h asTransformRelatedProperty() && !hasReflection() && !style()->isFlippedBlocksWri tingMode(); } 1062 virtual bool supportsPaintInvalidationStateCachedOffsets() const { return !h asTransformRelatedProperty() && !hasReflection() && !style()->isFlippedBlocksWri tingMode(); }
1056 1063
1057 virtual LayoutRect viewRect() const; 1064 virtual LayoutRect viewRect() const;
1058 1065
1059 DisplayItemClient displayItemClient() const { return toDisplayItemClient(thi s); } 1066 DisplayItemClient displayItemClient() const { return toDisplayItemClient(thi s); }
1060 1067
1061 void invalidateDisplayItemClient(const NonLayoutObjectDisplayItemClientWrapp er&); 1068 void invalidateDisplayItemClient(const NonLayoutObjectDisplayItemClientWrapp er&);
1062 void invalidateDisplayItemClient(LayoutObject&); 1069 void invalidateDisplayItemClient(LayoutObject&);
1063 void invalidateDisplayItemClientForNonCompositingDescendants() { invalidateD isplayItemClientForNonCompositingDescendantsOf(*this); } 1070 void invalidateDisplayItemClientForNonCompositingDescendants() { invalidateD isplayItemClientForNonCompositingDescendantsOf(*this); }
1064 // A normal object should use invalidateDisplayItemClientForNonCompositingDe scendants() 1071 // A normal object should use invalidateDisplayItemClientForNonCompositingDe scendants()
1065 // to invalidate its descendants which are painted on the same backing. Howe ver, for 1072 // to invalidate its descendants which are painted on the same backing. Howe ver, for
1066 // an object (e.g. LayoutScrollbarPart, custom scroll corner, custom resizer ) which is 1073 // an object (e.g. LayoutScrollbarPart, custom scroll corner, custom resizer ) which is
1067 // not hooked up in the layout tree and not able to find its paint backing, it should 1074 // not hooked up in the layout tree and not able to find its paint backing, it should
1068 // let its owning layout object call the following function. 1075 // let its owning layout object call the following function.
1069 // FIXME: should we hook up scrollbar parts in the layout tree? crbug.com/48 4263. 1076 // FIXME: should we hook up scrollbar parts in the layout tree? crbug.com/48 4263.
1070 void invalidateDisplayItemClientForNonCompositingDescendantsOf(LayoutObject& ); 1077 void invalidateDisplayItemClientForNonCompositingDescendantsOf(LayoutObject& );
1071 1078
1072 // Slimming paint v2 tracks whether a LayoutObject is invalid instead of usi ng invalidation rects. 1079 // Slimming paint v2 tracks whether a LayoutObject is invalid instead of usi ng invalidation rects.
1073 // For more information, see: https://docs.google.com/a/chromium.org/documen t/d/1FTqk3MwUAS1qLJsnA9zgfDbeqAQBdLYC4GJ9jpN-xdA 1080 // For more information, see: https://docs.google.com/a/chromium.org/documen t/d/1FTqk3MwUAS1qLJsnA9zgfDbeqAQBdLYC4GJ9jpN-xdA
1074 bool selfNeedsRepaint() const { return m_bitfields.selfNeedsRepaint(); } 1081 bool selfNeedsRepaint() const { return m_bitfields.selfNeedsRepaint(); }
1075 void setNeedsRepaint(); 1082 void setNeedsRepaint();
1076 bool childNeedsRepaint() const { return m_bitfields.childNeedsRepaint(); } 1083 bool childNeedsRepaint() const { return m_bitfields.childNeedsRepaint(); }
1077 bool shouldCheckForRepaint() const { return selfNeedsRepaint() || childNeeds Repaint(); } 1084 bool shouldCheckForRepaint() const { return selfNeedsRepaint() || childNeeds Repaint(); }
1078 1085
1086 virtual PaintInvalidationReason invalidatePaintIfNeededForSlimmingPaintV2(co nst LayoutPoint& newPaintOffset);
1079 void clearRepaintFlagsRecursively(); 1087 void clearRepaintFlagsRecursively();
1080 1088
1081 protected: 1089 protected:
1082 enum LayoutObjectType { 1090 enum LayoutObjectType {
1083 LayoutObjectBr, 1091 LayoutObjectBr,
1084 LayoutObjectCanvas, 1092 LayoutObjectCanvas,
1085 LayoutObjectFieldset, 1093 LayoutObjectFieldset,
1086 LayoutObjectCounter, 1094 LayoutObjectCounter,
1087 LayoutObjectDetailsMarker, 1095 LayoutObjectDetailsMarker,
1088 LayoutObjectEmbeddedObject, 1096 LayoutObjectEmbeddedObject,
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 1247
1240 void markContainerChainForChildNeedsRepaint(); 1248 void markContainerChainForChildNeedsRepaint();
1241 void setChildNeedsRepaint(); 1249 void setChildNeedsRepaint();
1242 1250
1243 inline void invalidateSelectionIfNeeded(const LayoutBoxModelObject&, PaintIn validationReason); 1251 inline void invalidateSelectionIfNeeded(const LayoutBoxModelObject&, PaintIn validationReason);
1244 1252
1245 inline void invalidateContainerPreferredLogicalWidths(); 1253 inline void invalidateContainerPreferredLogicalWidths();
1246 1254
1247 void invalidatePaintIncludingNonCompositingDescendantsInternal(const LayoutB oxModelObject& repaintContainer); 1255 void invalidatePaintIncludingNonCompositingDescendantsInternal(const LayoutB oxModelObject& repaintContainer);
1248 1256
1257 // TODO: Remove for slimming paint v2.
1249 LayoutRect previousSelectionRectForPaintInvalidation() const; 1258 LayoutRect previousSelectionRectForPaintInvalidation() const;
1250 void setPreviousSelectionRectForPaintInvalidation(const LayoutRect&); 1259 void setPreviousSelectionRectForPaintInvalidation(const LayoutRect&);
1251 1260
1252 const LayoutBoxModelObject* enclosingCompositedContainer() const; 1261 const LayoutBoxModelObject* enclosingCompositedContainer() const;
1253 1262
1254 LayoutFlowThread* locateFlowThreadContainingBlock() const; 1263 LayoutFlowThread* locateFlowThreadContainingBlock() const;
1255 void removeFromLayoutFlowThread(); 1264 void removeFromLayoutFlowThread();
1256 void removeFromLayoutFlowThreadRecursive(LayoutFlowThread*); 1265 void removeFromLayoutFlowThreadRecursive(LayoutFlowThread*);
1257 1266
1258 ComputedStyle* cachedFirstLineStyle() const; 1267 ComputedStyle* cachedFirstLineStyle() const;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 , m_isSlowRepaintObject(false) 1354 , m_isSlowRepaintObject(false)
1346 , m_selfNeedsRepaint(false) 1355 , m_selfNeedsRepaint(false)
1347 , m_childNeedsRepaint(false) 1356 , m_childNeedsRepaint(false)
1348 , m_positionedState(IsStaticallyPositioned) 1357 , m_positionedState(IsStaticallyPositioned)
1349 , m_selectionState(SelectionNone) 1358 , m_selectionState(SelectionNone)
1350 , m_boxDecorationBackgroundState(NoBoxDecorationBackground) 1359 , m_boxDecorationBackgroundState(NoBoxDecorationBackground)
1351 , m_fullPaintInvalidationReason(PaintInvalidationNone) 1360 , m_fullPaintInvalidationReason(PaintInvalidationNone)
1352 { 1361 {
1353 } 1362 }
1354 1363
1355 // 32 bits have been used in the first word, and 18 in the second. 1364 // 32 bits have been used in the first word, and 19 in the second.
1356 ADD_BOOLEAN_BITFIELD(selfNeedsLayout, SelfNeedsLayout); 1365 ADD_BOOLEAN_BITFIELD(selfNeedsLayout, SelfNeedsLayout);
1357 ADD_BOOLEAN_BITFIELD(shouldInvalidateOverflowForPaint, ShouldInvalidateO verflowForPaint); // TODO(wangxianzhu): Remove for slimming paint v2. 1366 ADD_BOOLEAN_BITFIELD(shouldInvalidateOverflowForPaint, ShouldInvalidateO verflowForPaint); // TODO(wangxianzhu): Remove for slimming paint v2.
1358 ADD_BOOLEAN_BITFIELD(childShouldCheckForPaintInvalidation, ChildShouldCh eckForPaintInvalidation); 1367 ADD_BOOLEAN_BITFIELD(childShouldCheckForPaintInvalidation, ChildShouldCh eckForPaintInvalidation);
1359 ADD_BOOLEAN_BITFIELD(mayNeedPaintInvalidation, MayNeedPaintInvalidation) ; 1368 ADD_BOOLEAN_BITFIELD(mayNeedPaintInvalidation, MayNeedPaintInvalidation) ;
1360 ADD_BOOLEAN_BITFIELD(shouldInvalidateSelection, ShouldInvalidateSelectio n); // TODO(wangxianzhu): Remove for slimming paint v2. 1369 ADD_BOOLEAN_BITFIELD(shouldInvalidateSelection, ShouldInvalidateSelectio n); // TODO(wangxianzhu): Remove for slimming paint v2.
1361 ADD_BOOLEAN_BITFIELD(neededLayoutBecauseOfChildren, NeededLayoutBecauseO fChildren); // TODO(wangxianzhu): Remove for slimming paint v2. 1370 ADD_BOOLEAN_BITFIELD(neededLayoutBecauseOfChildren, NeededLayoutBecauseO fChildren); // TODO(wangxianzhu): Remove for slimming paint v2.
1362 ADD_BOOLEAN_BITFIELD(needsPositionedMovementLayout, NeedsPositionedMovem entLayout); 1371 ADD_BOOLEAN_BITFIELD(needsPositionedMovementLayout, NeedsPositionedMovem entLayout);
1363 ADD_BOOLEAN_BITFIELD(normalChildNeedsLayout, NormalChildNeedsLayout); 1372 ADD_BOOLEAN_BITFIELD(normalChildNeedsLayout, NormalChildNeedsLayout);
1364 ADD_BOOLEAN_BITFIELD(posChildNeedsLayout, PosChildNeedsLayout); 1373 ADD_BOOLEAN_BITFIELD(posChildNeedsLayout, PosChildNeedsLayout);
1365 ADD_BOOLEAN_BITFIELD(needsSimplifiedNormalFlowLayout, NeedsSimplifiedNor malFlowLayout); 1374 ADD_BOOLEAN_BITFIELD(needsSimplifiedNormalFlowLayout, NeedsSimplifiedNor malFlowLayout);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1454 void setShouldInvalidateOverflowForPaint(bool b) { m_bitfields.setShouldInva lidateOverflowForPaint(b); } 1463 void setShouldInvalidateOverflowForPaint(bool b) { m_bitfields.setShouldInva lidateOverflowForPaint(b); }
1455 void setSelfNeedsOverflowRecalcAfterStyleChange(bool b) { m_bitfields.setSel fNeedsOverflowRecalcAfterStyleChange(b); } 1464 void setSelfNeedsOverflowRecalcAfterStyleChange(bool b) { m_bitfields.setSel fNeedsOverflowRecalcAfterStyleChange(b); }
1456 void setChildNeedsOverflowRecalcAfterStyleChange(bool b) { m_bitfields.setCh ildNeedsOverflowRecalcAfterStyleChange(b); } 1465 void setChildNeedsOverflowRecalcAfterStyleChange(bool b) { m_bitfields.setCh ildNeedsOverflowRecalcAfterStyleChange(b); }
1457 1466
1458 private: 1467 private:
1459 // Store state between styleWillChange and styleDidChange 1468 // Store state between styleWillChange and styleDidChange
1460 static bool s_affectsParentBlock; 1469 static bool s_affectsParentBlock;
1461 1470
1462 // This stores the paint invalidation rect from the previous frame. This rec t does *not* account for composited scrolling. See 1471 // This stores the paint invalidation rect from the previous frame. This rec t does *not* account for composited scrolling. See
1463 // adjustInvalidationRectForCompositedScrolling(). 1472 // adjustInvalidationRectForCompositedScrolling().
1473 // TODO: Remove for slimming paint v2.
1464 LayoutRect m_previousPaintInvalidationRect; 1474 LayoutRect m_previousPaintInvalidationRect;
1465 1475
1466 // This stores the position in the paint invalidation backing's coordinate. 1476 // This stores the position in the paint invalidation backing's coordinate.
1467 // It is used to detect layoutObject shifts that forces a full invalidation. 1477 // It is used to detect layoutObject shifts that forces a full invalidation.
1468 // This point does *not* account for composited scrolling. See adjustInvalid ationRectForCompositedScrolling(). 1478 // This point does *not* account for composited scrolling. See adjustInvalid ationRectForCompositedScrolling().
1469 LayoutPoint m_previousPositionFromPaintInvalidationBacking; 1479 union {
1480 LayoutPoint m_previousPositionFromPaintInvalidationBacking; // TODO: Rem ove for slimming paint v2.
1481 // For slimming paint v2: previous paint offset in the space of the near est transform container.
1482 LayoutPoint m_previousPaintOffset;
1483 };
1470 }; 1484 };
1471 1485
1472 // FIXME: remove this once the layout object lifecycle ASSERTS are no longer hit . 1486 // FIXME: remove this once the layout object lifecycle ASSERTS are no longer hit .
1473 class DeprecatedDisableModifyLayoutTreeStructureAsserts { 1487 class DeprecatedDisableModifyLayoutTreeStructureAsserts {
1474 WTF_MAKE_NONCOPYABLE(DeprecatedDisableModifyLayoutTreeStructureAsserts); 1488 WTF_MAKE_NONCOPYABLE(DeprecatedDisableModifyLayoutTreeStructureAsserts);
1475 public: 1489 public:
1476 DeprecatedDisableModifyLayoutTreeStructureAsserts(); 1490 DeprecatedDisableModifyLayoutTreeStructureAsserts();
1477 1491
1478 static bool canModifyLayoutTreeStateInAnyState(); 1492 static bool canModifyLayoutTreeStateInAnyState();
1479 1493
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1696 void showTree(const blink::LayoutObject*); 1710 void showTree(const blink::LayoutObject*);
1697 void showLineTree(const blink::LayoutObject*); 1711 void showLineTree(const blink::LayoutObject*);
1698 void showLayoutTree(const blink::LayoutObject* object1); 1712 void showLayoutTree(const blink::LayoutObject* object1);
1699 // We don't make object2 an optional parameter so that showLayoutTree 1713 // We don't make object2 an optional parameter so that showLayoutTree
1700 // can be called from gdb easily. 1714 // can be called from gdb easily.
1701 void showLayoutTree(const blink::LayoutObject* object1, const blink::LayoutObjec t* object2); 1715 void showLayoutTree(const blink::LayoutObject* object1, const blink::LayoutObjec t* object2);
1702 1716
1703 #endif 1717 #endif
1704 1718
1705 #endif // LayoutObject_h 1719 #endif // LayoutObject_h
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutBox.cpp ('k') | Source/core/layout/LayoutObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698