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

Side by Side Diff: Source/core/rendering/style/StyleDifference.h

Issue 247713003: Separate repaint and layout requirements of StyleDifference (Step 3) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef StyleDifference_h 5 #ifndef StyleDifference_h
6 #define StyleDifference_h 6 #define StyleDifference_h
7 7
8 namespace WebCore { 8 namespace WebCore {
9 9
10 // This class represents the difference between two computed styles (RenderStyle ). 10 // This class represents the difference between two computed styles (RenderStyle ).
11 // The difference can be of 3 types: 11 // The difference can be combination of 3 types according to the actions needed:
12 // - Layout difference 12 // - Difference needing layout
13 // - Repaint difference 13 // - Difference needing repaint
14 // - Recompositing difference 14 // - Difference needing recompositing layers
15 //
16 // Only directly needed actions are included. Indirect needed actions, such as
Julien - ping for review 2014/04/30 18:02:26 I don't think this comment helps, especially since
Xianzhu 2014/04/30 18:40:15 Removed.
17 // repaint caused by a layout change, are not included.
15 class StyleDifference { 18 class StyleDifference {
16 public: 19 public:
17 StyleDifference() 20 StyleDifference()
18 : m_needsRecompositeLayer(false) 21 : m_needsRecompositeLayer(false)
19 , m_repaintType(NoRepaint) 22 , m_repaintType(NoRepaint)
20 , m_layoutType(NoLayout) { } 23 , m_layoutType(NoLayout) { }
21 24
22 // The two styles are identical. 25 // The two styles are identical.
23 bool hasNoChange() const { return !m_needsRecompositeLayer && !m_repaintType && !m_layoutType; } 26 bool hasNoChange() const { return !m_needsRecompositeLayer && !m_repaintType && !m_layoutType; }
24 27
25 // The layer needs its position and transform updated. Implied by other repa int and layout flags. 28 // The layer needs its position and transform updated. Implied by other repa int and layout flags.
26 bool needsRecompositeLayer() const { return m_needsRecompositeLayer || needs Repaint() || needsLayout(); } 29 bool needsRecompositeLayer() const { return m_needsRecompositeLayer || needs Repaint() || needsLayout(); }
27 void setNeedsRecompositeLayer() { m_needsRecompositeLayer = true; } 30 void setNeedsRecompositeLayer() { m_needsRecompositeLayer = true; }
28 31
29 bool needsRepaint() const { return m_repaintType != NoRepaint; } 32 bool needsRepaint() const { return m_repaintType != NoRepaint; }
30 void clearNeedsRepaint() { m_repaintType = NoRepaint; } 33 void clearNeedsRepaint() { m_repaintType = NoRepaint; }
31 34
32 // The object just needs to be repainted. 35 // The object just needs to be repainted.
33 bool needsRepaintObjectOnly() const { return m_repaintType == RepaintObjectO nly; } 36 bool needsRepaintObject() const { return m_repaintType == RepaintObject; }
34 void setNeedsRepaintObject() 37 void setNeedsRepaintObject()
35 { 38 {
36 if (!needsRepaintLayer()) 39 if (!needsRepaintLayer())
37 m_repaintType = RepaintObjectOnly; 40 m_repaintType = RepaintObject;
38 } 41 }
39 42
40 // The layer and its descendant layers need to be repainted. 43 // The layer and its descendant layers need to be repainted.
41 bool needsRepaintLayer() const { return m_repaintType == RepaintLayer; } 44 bool needsRepaintLayer() const { return m_repaintType == RepaintLayer; }
42 void setNeedsRepaintLayer() { m_repaintType = RepaintLayer; } 45 void setNeedsRepaintLayer() { m_repaintType = RepaintLayer; }
43 46
44 bool needsLayout() const { return m_layoutType != NoLayout; } 47 bool needsLayout() const { return m_layoutType != NoLayout; }
45 void clearNeedsLayout() { m_layoutType = NoLayout; } 48 void clearNeedsLayout() { m_layoutType = NoLayout; }
46 49
47 // The offset of this positioned object has been updated. 50 // The offset of this positioned object has been updated.
48 bool needsPositionedMovementLayout() const { return m_layoutType & Positione dMovement; } 51 bool needsPositionedMovementLayout() const { return m_layoutType == Position edMovement; }
49 void setNeedsPositionedMovementLayout() 52 void setNeedsPositionedMovementLayout()
50 { 53 {
51 if (!needsFullLayout()) 54 if (!needsFullLayout())
52 m_layoutType |= PositionedMovement; 55 m_layoutType = PositionedMovement;
53 // FIXME: This is temporary to keep the StyleDifferenceLegacy behavior.
54 m_repaintType = NoRepaint;
55 } 56 }
56 57
57 bool needsFullLayout() const { return m_layoutType == FullLayout; } 58 bool needsFullLayout() const { return m_layoutType == FullLayout; }
58 void setNeedsFullLayout() 59 void setNeedsFullLayout() { m_layoutType = FullLayout; }
59 {
60 m_layoutType = FullLayout;
61 // FIXME: This is temporary to keep the StyleDifferenceLegacy behavior.
62 m_repaintType = NoRepaint;
63 }
64 60
65 private: 61 private:
66 unsigned m_needsRecompositeLayer : 1; 62 unsigned m_needsRecompositeLayer : 1;
67 63
68 enum RepaintType { 64 enum RepaintType {
69 NoRepaint = 0, 65 NoRepaint = 0,
70 RepaintObjectOnly, 66 RepaintObject,
71 RepaintLayer 67 RepaintLayer
72 }; 68 };
73 unsigned m_repaintType : 2; 69 unsigned m_repaintType : 2;
74 70
75 enum LayoutType { 71 enum LayoutType {
76 NoLayout = 0, 72 NoLayout = 0,
77 PositionedMovement = 1 << 0, 73 PositionedMovement,
78 FullLayout = 1 << 1 74 FullLayout
79 }; 75 };
80 unsigned m_layoutType : 2; 76 unsigned m_layoutType : 2;
81 }; 77 };
82 78
83 } // namespace WebCore 79 } // namespace WebCore
84 80
85 #endif // StyleDifference_h 81 #endif // StyleDifference_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698