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

Unified Diff: Source/core/layout/LayoutObject.h

Issue 1294233004: Subtree caching implementation in blink-core (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add a complex-subtree-update test Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/layout/LayoutObject.h
diff --git a/Source/core/layout/LayoutObject.h b/Source/core/layout/LayoutObject.h
index 06e8d0270fba1af8f836169364b4e2f30ebf0d3b..43b9cb0b6ce68abaebc19d0a050859c774b364af 100644
--- a/Source/core/layout/LayoutObject.h
+++ b/Source/core/layout/LayoutObject.h
@@ -115,6 +115,15 @@ typedef WTF::HashMap<const DeprecatedPaintLayer*, Vector<LayoutRect>> LayerHitTe
const int showTreeCharacterOffset = 39;
#endif
+class NonLayoutObjectDisplayItemClientWrapper : public DisplayItemClientWrapper {
+public:
+ template <typename T>
+ NonLayoutObjectDisplayItemClientWrapper(const T& client)
+ : DisplayItemClientWrapper(client) { }
+
+ NonLayoutObjectDisplayItemClientWrapper(const LayoutObject&) = delete;
+};
+
// Base class for all layout tree objects.
class CORE_EXPORT LayoutObject : public ImageResourceClient {
friend class LayoutBlock;
@@ -856,8 +865,8 @@ public:
void invalidatePaintUsingContainer(const LayoutBoxModelObject& 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 invalidatePaintRectangleNotInvalidatingDisplayItemClients(const LayoutRect& r) const { invalidatePaintRectangleInternal(r); }
+ void invalidatePaintRectangle(const LayoutRect&);
+ void invalidatePaintRectangleNotInvalidatingDisplayItemClients(const LayoutRect& r) { invalidatePaintRectangleInternal(r); }
// Walk the tree after layout issuing paint invalidations for layoutObjects that have changed or moved, updating bounds that have changed, and clearing paint invalidation state.
virtual void invalidateTreeIfNeeded(PaintInvalidationState&);
@@ -1043,15 +1052,25 @@ public:
DisplayItemClient displayItemClient() const { return toDisplayItemClient(this); }
- void invalidateDisplayItemClient(const DisplayItemClientWrapper&) const;
- void invalidateDisplayItemClientForNonCompositingDescendants() const { invalidateDisplayItemClientForNonCompositingDescendantsOf(*this); }
+ void invalidateDisplayItemClient(const NonLayoutObjectDisplayItemClientWrapper&);
+ void invalidateDisplayItemClient(LayoutObject&);
+ void invalidateDisplayItemClientForNonCompositingDescendants() { invalidateDisplayItemClientForNonCompositingDescendantsOf(*this); }
// A normal object should use invalidateDisplayItemClientForNonCompositingDescendants()
// to invalidate its descendants which are painted on the same backing. However, for
// an object (e.g. LayoutScrollbarPart, custom scroll corner, custom resizer) which is
// not hooked up in the layout tree and not able to find its paint backing, it should
// let its owning layout object call the following function.
// FIXME: should we hook up scrollbar parts in the layout tree? crbug.com/484263.
- void invalidateDisplayItemClientForNonCompositingDescendantsOf(const LayoutObject&) const;
+ void invalidateDisplayItemClientForNonCompositingDescendantsOf(LayoutObject&);
+
+ // Slimming paint v2 tracks whether a LayoutObject is invalid instead of using invalidation rects.
+ // For more information, see: https://docs.google.com/a/chromium.org/document/d/1FTqk3MwUAS1qLJsnA9zgfDbeqAQBdLYC4GJ9jpN-xdA
+ bool selfNeedsRepaint() const { return m_bitfields.selfNeedsRepaint(); }
+ void setNeedsRepaint();
+ bool childNeedsRepaint() const { return m_bitfields.childNeedsRepaint(); }
+ bool shouldCheckForRepaint() const { return selfNeedsRepaint() || childNeedsRepaint(); }
+
+ void clearRepaintFlagsRecursively();
protected:
enum LayoutObjectType {
@@ -1179,7 +1198,9 @@ protected:
// owned by this object, including the object itself, LayoutText/LayoutInline line boxes, etc.,
// not including children which will be invalidated normally during invalidateTreeIfNeeded() and
// parts which are invalidated separately (e.g. scrollbars).
- virtual void invalidateDisplayItemClients(const LayoutBoxModelObject& paintInvalidationContainer) const;
+ virtual void invalidateDisplayItemClients(const LayoutBoxModelObject& paintInvalidationContainer);
+
+ virtual void clearRepaintFlagsOfSubtrees();
void setIsSlowRepaintObject(bool);
@@ -1210,6 +1231,9 @@ private:
inline void markContainerChainForPaintInvalidation();
+ void markContainerChainForChildNeedsRepaint();
+ void setChildNeedsRepaint();
+
inline void invalidateSelectionIfNeeded(const LayoutBoxModelObject&, PaintInvalidationReason);
inline void invalidateContainerPreferredLogicalWidths();
@@ -1240,7 +1264,9 @@ private:
static bool isAllowedToModifyLayoutTreeStructure(Document&);
- const LayoutBoxModelObject* invalidatePaintRectangleInternal(const LayoutRect&) const;
+ const LayoutBoxModelObject* invalidatePaintRectangleInternal(const LayoutRect&);
+
+ void invalidateDisplayItemClientInternal(const DisplayItemClientWrapper&);
RefPtr<ComputedStyle> m_style;
@@ -1311,6 +1337,8 @@ private:
, m_alwaysCreateLineBoxesForLayoutInline(false)
, m_lastBoxDecorationBackgroundObscured(false)
, m_isSlowRepaintObject(false)
+ , m_selfNeedsRepaint(false)
+ , m_childNeedsRepaint(false)
, m_positionedState(IsStaticallyPositioned)
, m_selectionState(SelectionNone)
, m_boxDecorationBackgroundState(NoBoxDecorationBackground)
@@ -1318,7 +1346,7 @@ private:
{
}
- // 32 bits have been used in the first word, and 16 in the second.
+ // 32 bits have been used in the first word, and 18 in the second.
ADD_BOOLEAN_BITFIELD(selfNeedsLayout, SelfNeedsLayout);
ADD_BOOLEAN_BITFIELD(shouldInvalidateOverflowForPaint, ShouldInvalidateOverflowForPaint); // TODO(wangxianzhu): Remove for slimming paint v2.
ADD_BOOLEAN_BITFIELD(childShouldCheckForPaintInvalidation, ChildShouldCheckForPaintInvalidation);
@@ -1370,6 +1398,12 @@ private:
ADD_BOOLEAN_BITFIELD(isSlowRepaintObject, IsSlowRepaintObject);
+ // For slimming-paint v2.
+ // TODO(wangxianzhu): Combine repaint flags with paint invalidation flags when we remove
+ // old paint invalidation code.
+ ADD_BOOLEAN_BITFIELD(selfNeedsRepaint, SelfNeedsRepaint);
+ ADD_BOOLEAN_BITFIELD(childNeedsRepaint, ChildNeedsRepaint);
+
private:
unsigned m_positionedState : 2; // PositionedState
unsigned m_selectionState : 3; // SelectionState

Powered by Google App Engine
This is Rietveld 408576698