1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef ViewDisplayList_h
6 #define ViewDisplayList_h
8 #include "core/rendering/PaintPhase.h"
9 #include "wtf/HashSet.h"
10 #include "wtf/PassOwnPtr.h"
11 #include "wtf/Vector.h"
15 class GraphicsContext;
22 // DisplayItem types must be kept in sync with PaintPhase.
23 DrawingPaintPhaseBlockBackground = 0,
24 DrawingPaintPhaseChildBlockBackground = 1,
25 DrawingPaintPhaseChildBlockBackgrounds = 2,
26 DrawingPaintPhaseFloat = 3,
27 DrawingPaintPhaseForeground = 4,
28 DrawingPaintPhaseOutline = 5,
29 DrawingPaintPhaseChildOutlines = 6,
30 DrawingPaintPhaseSelfOutline = 7,
31 DrawingPaintPhaseSelection = 8,
32 DrawingPaintPhaseCollapsedTableBorders = 9,
33 DrawingPaintPhaseTextClip = 10,
34 DrawingPaintPhaseMask = 11,
35 DrawingPaintPhaseClippingMask = 12,
36 ClipLayerOverflowControls = 13,
37 ClipLayerBackground = 14,
40 ClipLayerForeground = 17,
41 ClipLayerFragmentFloat = 18,
42 ClipLayerFragmentForeground = 19,
43 ClipLayerFragmentChildOutline = 20,
44 ClipLayerFragmentOutline = 21,
45 ClipLayerFragmentMask = 22,
46 ClipLayerFragmentClippingMask = 23,
47 ClipLayerFragmentParent = 24,
48 ClipLayerFragmentSelection = 25,
49 ClipLayerFragmentChildBlockBackgrounds = 26,
53 virtual ~DisplayItem() { }
55 virtual void replay(GraphicsContext*) = 0;
57 const RenderObject* renderer() const { return m_id.renderer; }
58 Type type() const { return m_id.type; }
59 bool idsEqual(const DisplayItem& other) const { return m_id.renderer == other.m_id.renderer && m_id.type == other.m_id.type; }
62 static WTF::String typeAsDebugString(DisplayItem::Type);
63 static WTF::String rendererDebugString(const RenderObject*);
64 virtual WTF::String asDebugString() const;
68 DisplayItem(const RenderObject* renderer, Type type)
69 : m_id(renderer, type)
74 Id(const RenderObject* r, Type t)
79 const RenderObject* renderer;
84 typedef Vector<OwnPtr<DisplayItem> > PaintList;
86 class ViewDisplayList {
88 ViewDisplayList() { };
90 const PaintList& paintList();
91 void add(WTF::PassOwnPtr<DisplayItem>);
92 void invalidate(const RenderObject*);
95 void showDebugData() const;
99 PaintList::iterator findDisplayItem(PaintList::iterator, const DisplayItem&);
100 bool wasInvalidated(const DisplayItem&) const;
101 void updatePaintList();
103 PaintList m_paintList;
104 HashSet<const RenderObject*> m_paintListRenderers;
105 HashSet<const RenderObject*> m_invalidated;
106 PaintList m_newPaints;
111 #endif // ViewDisplayList_h