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

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

Issue 1813383002: Move all fast-path paint invalidation mapping into PaintInvalidationState (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reorganize conditions in PaintInvalidationState constructor Created 4 years, 9 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
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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 #endif 316 #endif
317 ASSERT_WITH_SECURITY_IMPLICATION(!needsLayout()); 317 ASSERT_WITH_SECURITY_IMPLICATION(!needsLayout());
318 } 318 }
319 319
320 void assertSubtreeIsLaidOut() const 320 void assertSubtreeIsLaidOut() const
321 { 321 {
322 for (const LayoutObject* layoutObject = this; layoutObject; layoutObject = layoutObject->nextInPreOrder()) 322 for (const LayoutObject* layoutObject = this; layoutObject; layoutObject = layoutObject->nextInPreOrder())
323 layoutObject->assertLaidOut(); 323 layoutObject->assertLaidOut();
324 } 324 }
325 325
326 void assertClearedPaintInvalidationState() const 326 void assertClearedPaintInvalidationFlags() const
327 { 327 {
328 #ifndef NDEBUG 328 #ifndef NDEBUG
329 if (paintInvalidationStateIsDirty()) { 329 if (paintInvalidationStateIsDirty()) {
330 showLayoutTreeForThis(); 330 showLayoutTreeForThis();
331 ASSERT_NOT_REACHED(); 331 ASSERT_NOT_REACHED();
332 } 332 }
333 #endif 333 #endif
334 } 334 }
335 335
336 void assertSubtreeClearedPaintInvalidationState() const 336 void assertSubtreeClearedPaintInvalidationFlags() const
337 { 337 {
338 for (const LayoutObject* layoutObject = this; layoutObject; layoutObject = layoutObject->nextInPreOrder()) 338 for (const LayoutObject* layoutObject = this; layoutObject; layoutObject = layoutObject->nextInPreOrder())
339 layoutObject->assertClearedPaintInvalidationState(); 339 layoutObject->assertClearedPaintInvalidationFlags();
340 } 340 }
341 341
342 #endif 342 #endif
343 343
344 // Correct version of !layoutObjectHasNoBoxEffectObsolete(). 344 // Correct version of !layoutObjectHasNoBoxEffectObsolete().
345 bool hasBoxEffect() const 345 bool hasBoxEffect() const
346 { 346 {
347 return hasBoxDecorationBackground() || style()->hasVisualOverflowingEffe ct(); 347 return hasBoxDecorationBackground() || style()->hasVisualOverflowingEffe ct();
348 } 348 }
349 349
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 { 989 {
990 return ancestorToLocalQuad(nullptr, quad, mode); 990 return ancestorToLocalQuad(nullptr, quad, mode);
991 } 991 }
992 992
993 // Convert a local quad into the coordinate system of container, taking tran sforms into account. 993 // Convert a local quad into the coordinate system of container, taking tran sforms into account.
994 // If the LayoutBoxModelObject ancestor is non-null, the result will be in t he space of the ancestor. 994 // If the LayoutBoxModelObject ancestor is non-null, the result will be in t he space of the ancestor.
995 // Otherwise: 995 // Otherwise:
996 // If TraverseDocumentBoundaries is specified, the result will be in the s pace of the local root frame. 996 // If TraverseDocumentBoundaries is specified, the result will be in the s pace of the local root frame.
997 // Otherwise, the result will be in the space of the containing frame. 997 // Otherwise, the result will be in the space of the containing frame.
998 FloatQuad localToAncestorQuad(const FloatQuad&, const LayoutBoxModelObject* ancestor, MapCoordinatesFlags = 0, bool* wasFixed = nullptr) const; 998 FloatQuad localToAncestorQuad(const FloatQuad&, const LayoutBoxModelObject* ancestor, MapCoordinatesFlags = 0, bool* wasFixed = nullptr) const;
999 FloatPoint localToAncestorPoint(const FloatPoint&, const LayoutBoxModelObjec t* ancestor, MapCoordinatesFlags = 0, bool* wasFixed = nullptr, const PaintInval idationState* = nullptr) const; 999 FloatPoint localToAncestorPoint(const FloatPoint&, const LayoutBoxModelObjec t* ancestor, MapCoordinatesFlags = 0, bool* wasFixed = nullptr) const;
1000 void localToAncestorRects(Vector<LayoutRect>&, const LayoutBoxModelObject* a ncestor, const LayoutPoint& preOffset, const LayoutPoint& postOffset) const; 1000 void localToAncestorRects(Vector<LayoutRect>&, const LayoutBoxModelObject* a ncestor, const LayoutPoint& preOffset, const LayoutPoint& postOffset) const;
1001 1001
1002 // Return the transformation matrix to map points from local to the coordina te system of a container, taking transforms into account. 1002 // Return the transformation matrix to map points from local to the coordina te system of a container, taking transforms into account.
1003 // Passing null for |ancestor| behaves the same as localToAncestorQuad. 1003 // Passing null for |ancestor| behaves the same as localToAncestorQuad.
1004 TransformationMatrix localToAncestorTransform(const LayoutBoxModelObject* an cestor, MapCoordinatesFlags = 0, bool* wasFixed = nullptr) const; 1004 TransformationMatrix localToAncestorTransform(const LayoutBoxModelObject* an cestor, MapCoordinatesFlags = 0, bool* wasFixed = nullptr) const;
1005 TransformationMatrix localToAbsoluteTransform(MapCoordinatesFlags mode = 0, bool* wasFixed = nullptr) const 1005 TransformationMatrix localToAbsoluteTransform(MapCoordinatesFlags mode = 0, bool* wasFixed = nullptr) const
1006 { 1006 {
1007 return localToAncestorTransform(nullptr, mode, wasFixed); 1007 return localToAncestorTransform(nullptr, mode, wasFixed);
1008 } 1008 }
1009 1009
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 // is responsible for painting this object. The function crosses 1101 // is responsible for painting this object. The function crosses
1102 // frames boundaries so the returned value can be in a 1102 // frames boundaries so the returned value can be in a
1103 // different document. 1103 // different document.
1104 // 1104 //
1105 // This is the container that should be passed to 1105 // This is the container that should be passed to
1106 // the '*forPaintInvalidation' methods. 1106 // the '*forPaintInvalidation' methods.
1107 const LayoutBoxModelObject& containerForPaintInvalidation() const; 1107 const LayoutBoxModelObject& containerForPaintInvalidation() const;
1108 1108
1109 bool isPaintInvalidationContainer() const; 1109 bool isPaintInvalidationContainer() const;
1110 1110
1111 LayoutRect computePaintInvalidationRect()
1112 {
1113 return computePaintInvalidationRect(containerForPaintInvalidation());
1114 }
1115
1116 // Returns the paint invalidation rect for this LayoutObject in the coordina te space of the paint backing (typically a GraphicsLayer) for |paintInvalidation Container|.
1117 LayoutRect computePaintInvalidationRect(const LayoutBoxModelObject& paintInv alidationContainer, const PaintInvalidationState* = nullptr) const;
1118
1119 // Returns the rect bounds needed to invalidate the paint of this object, in the coordinate space of the layoutObject backing of |paintInvalidationContainer |
1120 LayoutRect boundsRectForPaintInvalidation(const LayoutBoxModelObject& paintI nvalidationContainer, const PaintInvalidationState* = nullptr) const;
1121
1122 // Actually do the paint invalidate of rect r for this object which has been computed in the coordinate space 1111 // Actually do the paint invalidate of rect r for this object which has been computed in the coordinate space
1123 // of the GraphicsLayer backing of |paintInvalidationContainer|. Note that t his coordinaten space is not the same 1112 // of the GraphicsLayer backing of |paintInvalidationContainer|. Note that t his coordinaten space is not the same
1124 // as the local coordinate space of |paintInvalidationContainer| in the pres ence of layer squashing. 1113 // as the local coordinate space of |paintInvalidationContainer| in the pres ence of layer squashing.
1125 void invalidatePaintUsingContainer(const LayoutBoxModelObject& paintInvalida tionContainer, const LayoutRect&, PaintInvalidationReason) const; 1114 void invalidatePaintUsingContainer(const LayoutBoxModelObject& paintInvalida tionContainer, const LayoutRect&, PaintInvalidationReason) const;
1126 1115
1127 // Invalidate the paint of a specific subrectangle within a given object. Th e rect is in the object's coordinate space. 1116 // Invalidate the paint of a specific subrectangle within a given object. Th e rect is in the object's coordinate space.
1128 void invalidatePaintRectangle(const LayoutRect&) const; 1117 void invalidatePaintRectangle(const LayoutRect&) const;
1129 void invalidatePaintRectangleNotInvalidatingDisplayItemClients(const LayoutR ect&) const; 1118 void invalidatePaintRectangleNotInvalidatingDisplayItemClients(const LayoutR ect&) const;
1130 1119
1131 // Walk the tree after layout issuing paint invalidations for layoutObjects that have changed or moved, updating bounds that have changed, and clearing pain t invalidation state. 1120 // Walk the tree after layout issuing paint invalidations for layoutObjects that have changed or moved, updating bounds that have changed, and clearing pain t invalidation state.
1132 virtual void invalidateTreeIfNeeded(const PaintInvalidationState&); 1121 virtual void invalidateTreeIfNeeded(const PaintInvalidationState&);
1133 1122
1134 // This function only invalidates the visual overflow. 1123 // This function only invalidates the visual overflow.
1135 // 1124 //
1136 // Note that overflow is a box concept but this function 1125 // Note that overflow is a box concept but this function
1137 // is only supported for block-flow. 1126 // is only supported for block-flow.
1138 virtual void invalidatePaintForOverflow(); 1127 virtual void invalidatePaintForOverflow();
1139 void invalidatePaintForOverflowIfNeeded(); 1128 void invalidatePaintForOverflowIfNeeded();
1140 1129
1141 void invalidatePaintIncludingNonCompositingDescendants(); 1130 void invalidatePaintIncludingNonCompositingDescendants();
1142 void invalidatePaintIncludingNonSelfPaintingLayerDescendants(const LayoutBox ModelObject& paintInvalidationContainer); 1131 void invalidatePaintIncludingNonSelfPaintingLayerDescendants(const LayoutBox ModelObject& paintInvalidationContainer);
1143 void setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(); 1132 void setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants();
1144 1133
1145 // Returns the rect that should have paint invalidated whenever this object changes. The rect is in the view's 1134 // Returns the rect that should have paint invalidated whenever this object changes. The rect is in the view's
1146 // coordinate space. This method deals with outlines and overflow. 1135 // coordinate space. This method deals with outlines and overflow.
1147 virtual LayoutRect absoluteClippedOverflowRect() const; 1136 virtual LayoutRect absoluteClippedOverflowRect() const;
1148 virtual LayoutRect clippedOverflowRectForPaintInvalidation(const LayoutBoxMo delObject* paintInvalidationContainer, const PaintInvalidationState* = nullptr) const; 1137
1138 // Returns the rect that should have paint invalidated whenever this object changes. The rect is in the object's
1139 // local coordinate space.
1140 virtual LayoutRect localOverflowRectForPaintInvalidation() const;
1149 1141
1150 // Given a rect in the object's coordinate space, compute a rect in the coor dinate space of |ancestor|. If 1142 // Given a rect in the object's coordinate space, compute a rect in the coor dinate space of |ancestor|. If
1151 // intermediate containers have clipping or scrolling of any kind, it is app lied; but overflow clipping is *not* 1143 // intermediate containers have clipping or scrolling of any kind, it is app lied; but overflow clipping is *not*
1152 // applied for |ancestor| itself. The output rect is suitable for purposes s uch as paint invalidation. 1144 // applied for |ancestor| itself. The output rect is suitable for purposes s uch as paint invalidation.
1153 virtual void mapToVisibleRectInAncestorSpace(const LayoutBoxModelObject* anc estor, LayoutRect&, const PaintInvalidationState*) const; 1145 virtual void mapToVisibleRectInAncestorSpace(const LayoutBoxModelObject* anc estor, LayoutRect&) const;
1154 1146
1155 // Return the offset to the column in which the specified point (in flow-thr ead coordinates) 1147 // Return the offset to the column in which the specified point (in flow-thr ead coordinates)
1156 // lives. This is used to convert a flow-thread point to a visual point. 1148 // lives. This is used to convert a flow-thread point to a visual point.
1157 virtual LayoutSize columnOffset(const LayoutPoint&) const { return LayoutSiz e(); } 1149 virtual LayoutSize columnOffset(const LayoutPoint&) const { return LayoutSiz e(); }
1158 1150
1159 virtual unsigned length() const { return 1; } 1151 virtual unsigned length() const { return 1; }
1160 1152
1161 bool isFloatingOrOutOfFlowPositioned() const { return (isFloating() || isOut OfFlowPositioned()); } 1153 bool isFloatingOrOutOfFlowPositioned() const { return (isFloating() || isOut OfFlowPositioned()); }
1162 1154
1163 bool isTransparent() const { return style()->hasOpacity(); } 1155 bool isTransparent() const { return style()->hasOpacity(); }
1164 float opacity() const { return style()->opacity(); } 1156 float opacity() const { return style()->opacity(); }
1165 1157
1166 bool hasReflection() const { return m_bitfields.hasReflection(); } 1158 bool hasReflection() const { return m_bitfields.hasReflection(); }
1167 1159
1168 // The current selection state for an object. For blocks, the state refers to the state of the leaf 1160 // The current selection state for an object. For blocks, the state refers to the state of the leaf
1169 // descendants (as described above in the SelectionState enum declaration). 1161 // descendants (as described above in the SelectionState enum declaration).
1170 SelectionState getSelectionState() const { return m_bitfields.getSelectionSt ate(); } 1162 SelectionState getSelectionState() const { return m_bitfields.getSelectionSt ate(); }
1171 virtual void setSelectionState(SelectionState state) { m_bitfields.setSelect ionState(state); } 1163 virtual void setSelectionState(SelectionState state) { m_bitfields.setSelect ionState(state); }
1172 inline void setSelectionStateIfNeeded(SelectionState); 1164 inline void setSelectionStateIfNeeded(SelectionState);
1173 bool canUpdateSelectionOnRootLineBoxes() const; 1165 bool canUpdateSelectionOnRootLineBoxes() const;
1174 1166
1175 // A single rectangle that encompasses all of the selected objects within th is object. Used to determine the tightest 1167 // A single rectangle that encompasses all of the selected objects within th is object. Used to determine the tightest
1176 // possible bounding box for the selection. The rect returned is in the coor dinate space of the paint invalidation container's backing. 1168 // possible bounding box for the selection. The rect returned is in the obje ct's local coordinate space.
1177 virtual LayoutRect selectionRectForPaintInvalidation(const LayoutBoxModelObj ect* /* paintInvalidationContainer */) const { return LayoutRect(); } 1169 virtual LayoutRect localSelectionRect() const { return LayoutRect(); }
1178 1170
1179 // View coordinates means the coordinate space of |view()|. 1171 // View coordinates means the coordinate space of |view()|.
1180 LayoutRect selectionRectInViewCoordinates() const; 1172 LayoutRect selectionRectInViewCoordinates() const;
1181 1173
1182 virtual bool canBeSelectionLeaf() const { return false; } 1174 virtual bool canBeSelectionLeaf() const { return false; }
1183 bool hasSelectedChildren() const { return getSelectionState() != SelectionNo ne; } 1175 bool hasSelectedChildren() const { return getSelectionState() != SelectionNo ne; }
1184 1176
1185 bool isSelectable() const; 1177 bool isSelectable() const;
1186 // Obtains the selection colors that should be used when painting a selectio n. 1178 // Obtains the selection colors that should be used when painting a selectio n.
1187 Color selectionBackgroundColor() const; 1179 Color selectionBackgroundColor() const;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1243 if (parent()) 1235 if (parent())
1244 parent()->removeChild(this); 1236 parent()->removeChild(this);
1245 } 1237 }
1246 1238
1247 bool visibleToHitTestRequest(const HitTestRequest& request) const { return s tyle()->visibility() == VISIBLE && (request.ignorePointerEventsNone() || style() ->pointerEvents() != PE_NONE) && !isInert(); } 1239 bool visibleToHitTestRequest(const HitTestRequest& request) const { return s tyle()->visibility() == VISIBLE && (request.ignorePointerEventsNone() || style() ->pointerEvents() != PE_NONE) && !isInert(); }
1248 1240
1249 bool visibleToHitTesting() const { return style()->visibility() == VISIBLE & & style()->pointerEvents() != PE_NONE && !isInert(); } 1241 bool visibleToHitTesting() const { return style()->visibility() == VISIBLE & & style()->pointerEvents() != PE_NONE && !isInert(); }
1250 1242
1251 // Map points and quads through elements, potentially via 3d transforms. You should never need to call these directly; use 1243 // Map points and quads through elements, potentially via 3d transforms. You should never need to call these directly; use
1252 // localToAbsolute/absoluteToLocal methods instead. 1244 // localToAbsolute/absoluteToLocal methods instead.
1253 virtual void mapLocalToAncestor(const LayoutBoxModelObject* ancestor, Transf ormState&, MapCoordinatesFlags = ApplyContainerFlip, bool* wasFixed = nullptr, c onst PaintInvalidationState* = nullptr) const; 1245 virtual void mapLocalToAncestor(const LayoutBoxModelObject* ancestor, Transf ormState&, MapCoordinatesFlags = ApplyContainerFlip, bool* wasFixed = nullptr) c onst;
1254 // If the LayoutBoxModelObject ancestor is non-null, the input quad is in th e space of the ancestor. 1246 // If the LayoutBoxModelObject ancestor is non-null, the input quad is in th e space of the ancestor.
1255 // Otherwise: 1247 // Otherwise:
1256 // If TraverseDocumentBoundaries is specified, the input quad is in the sp ace of the local root frame. 1248 // If TraverseDocumentBoundaries is specified, the input quad is in the sp ace of the local root frame.
1257 // Otherwise, the input quad is in the space of the containing frame. 1249 // Otherwise, the input quad is in the space of the containing frame.
1258 virtual void mapAncestorToLocal(const LayoutBoxModelObject*, TransformState& , MapCoordinatesFlags = ApplyContainerFlip) const; 1250 virtual void mapAncestorToLocal(const LayoutBoxModelObject*, TransformState& , MapCoordinatesFlags = ApplyContainerFlip) const;
1259 void mapAbsoluteToLocalPoint(MapCoordinatesFlags flags, TransformState& tran sformState) const 1251 void mapAbsoluteToLocalPoint(MapCoordinatesFlags flags, TransformState& tran sformState) const
1260 { 1252 {
1261 return mapAncestorToLocal(nullptr, transformState, flags); 1253 return mapAncestorToLocal(nullptr, transformState, flags);
1262 } 1254 }
1263 1255
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 return paintInvalidationState.forcedSubtreeInvalidationWithinContainer() 1352 return paintInvalidationState.forcedSubtreeInvalidationWithinContainer()
1361 || paintInvalidationState.forcedSubtreeInvalidationRectUpdateWithinC ontainer() 1353 || paintInvalidationState.forcedSubtreeInvalidationRectUpdateWithinC ontainer()
1362 || shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState (); 1354 || shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState ();
1363 } 1355 }
1364 1356
1365 bool shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState() con st 1357 bool shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState() con st
1366 { 1358 {
1367 return mayNeedPaintInvalidation() || shouldDoFullPaintInvalidation() || shouldInvalidateSelection() || m_bitfields.childShouldCheckForPaintInvalidation( ); 1359 return mayNeedPaintInvalidation() || shouldDoFullPaintInvalidation() || shouldInvalidateSelection() || m_bitfields.childShouldCheckForPaintInvalidation( );
1368 } 1360 }
1369 1361
1370 virtual bool supportsPaintInvalidationStateCachedOffsets() const { return !h asTransformRelatedProperty() && !hasReflection() && !style()->isFlippedBlocksWri tingMode(); }
1371
1372 virtual LayoutRect viewRect() const; 1362 virtual LayoutRect viewRect() const;
1373 1363
1374 void invalidateDisplayItemClient(const DisplayItemClient&) const; 1364 void invalidateDisplayItemClient(const DisplayItemClient&) const;
1375 void invalidateDisplayItemClientsIncludingNonCompositingDescendants(const La youtBoxModelObject* paintInvalidationContainer, PaintInvalidationReason) const; 1365 void invalidateDisplayItemClientsIncludingNonCompositingDescendants(const La youtBoxModelObject* paintInvalidationContainer, PaintInvalidationReason) const;
1376 1366
1377 // Called before anonymousChild.setStyle(). Override to set custom styles fo r the child. 1367 // Called before anonymousChild.setStyle(). Override to set custom styles fo r the child.
1378 virtual void updateAnonymousChildStyle(const LayoutObject& anonymousChild, C omputedStyle& style) const { } 1368 virtual void updateAnonymousChildStyle(const LayoutObject& anonymousChild, C omputedStyle& style) const { }
1379 1369
1380 // Painters can use const methods only, except for these explicitly declared methods. 1370 // Painters can use const methods only, except for these explicitly declared methods.
1381 class MutableForPainting { 1371 class MutableForPainting {
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
2170 void showTree(const blink::LayoutObject*); 2160 void showTree(const blink::LayoutObject*);
2171 void showLineTree(const blink::LayoutObject*); 2161 void showLineTree(const blink::LayoutObject*);
2172 void showLayoutTree(const blink::LayoutObject* object1); 2162 void showLayoutTree(const blink::LayoutObject* object1);
2173 // We don't make object2 an optional parameter so that showLayoutTree 2163 // We don't make object2 an optional parameter so that showLayoutTree
2174 // can be called from gdb easily. 2164 // can be called from gdb easily.
2175 void showLayoutTree(const blink::LayoutObject* object1, const blink::LayoutObjec t* object2); 2165 void showLayoutTree(const blink::LayoutObject* object1, const blink::LayoutObjec t* object2);
2176 2166
2177 #endif 2167 #endif
2178 2168
2179 #endif // LayoutObject_h 2169 #endif // LayoutObject_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698