File: StyleDifference.h

package info (click to toggle)
chromium-browser 57.0.2987.98-1~deb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 2,637,852 kB
  • ctags: 2,544,394
  • sloc: cpp: 12,815,961; ansic: 3,676,222; python: 1,147,112; asm: 526,608; java: 523,212; xml: 286,794; perl: 92,654; sh: 86,408; objc: 73,271; makefile: 27,698; cs: 18,487; yacc: 13,031; tcl: 12,957; pascal: 4,875; ml: 4,716; lex: 3,904; sql: 3,862; ruby: 1,982; lisp: 1,508; php: 1,368; exp: 404; awk: 325; csh: 117; jsp: 39; sed: 37
file content (158 lines) | stat: -rw-r--r-- 5,111 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef StyleDifference_h
#define StyleDifference_h

#include "wtf/Allocator.h"
#include "wtf/Assertions.h"

namespace blink {

class StyleDifference {
  STACK_ALLOCATED();

 public:
  enum PropertyDifference {
    TransformChanged = 1 << 0,
    OpacityChanged = 1 << 1,
    ZIndexChanged = 1 << 2,
    FilterChanged = 1 << 3,
    BackdropFilterChanged = 1 << 4,
    CSSClipChanged = 1 << 5,
    // The object needs to issue paint invalidations if it is affected by text
    // decorations or properties dependent on color (e.g., border or outline).
    TextDecorationOrColorChanged = 1 << 6,
    // If you add a value here, be sure to update the number of bits on
    // m_propertySpecificDifferences.
  };

  StyleDifference()
      : m_paintInvalidationType(NoPaintInvalidation),
        m_layoutType(NoLayout),
        m_recomputeOverflow(false),
        m_propertySpecificDifferences(0),
        m_scrollAnchorDisablingPropertyChanged(false) {}

  bool hasDifference() const {
    bool result = m_paintInvalidationType || m_layoutType ||
                  m_propertySpecificDifferences;
    // m_recomputeOverflow, m_scrollAnchorDisablingPropertyChanged and
    // are never set without other flags set.
    DCHECK(result ||
           (!m_recomputeOverflow && !m_scrollAnchorDisablingPropertyChanged));
    return result;
  }

  bool hasAtMostPropertySpecificDifferences(
      unsigned propertyDifferences) const {
    return !m_paintInvalidationType && !m_layoutType &&
           !(m_propertySpecificDifferences & ~propertyDifferences);
  }

  bool needsPaintInvalidation() const {
    return m_paintInvalidationType != NoPaintInvalidation;
  }

  // The object just needs to issue paint invalidations.
  bool needsPaintInvalidationObject() const {
    return m_paintInvalidationType == PaintInvalidationObject;
  }
  void setNeedsPaintInvalidationObject() {
    ASSERT(!needsPaintInvalidationSubtree());
    m_paintInvalidationType = PaintInvalidationObject;
  }

  // The object and its descendants need to issue paint invalidations.
  bool needsPaintInvalidationSubtree() const {
    return m_paintInvalidationType == PaintInvalidationSubtree;
  }
  void setNeedsPaintInvalidationSubtree() {
    m_paintInvalidationType = PaintInvalidationSubtree;
  }

  bool needsLayout() const { return m_layoutType != NoLayout; }
  void clearNeedsLayout() { m_layoutType = NoLayout; }

  // The offset of this positioned object has been updated.
  bool needsPositionedMovementLayout() const {
    return m_layoutType == PositionedMovement;
  }
  void setNeedsPositionedMovementLayout() {
    ASSERT(!needsFullLayout());
    m_layoutType = PositionedMovement;
  }

  bool needsFullLayout() const { return m_layoutType == FullLayout; }
  void setNeedsFullLayout() { m_layoutType = FullLayout; }

  bool needsRecomputeOverflow() const { return m_recomputeOverflow; }
  void setNeedsRecomputeOverflow() { m_recomputeOverflow = true; }

  bool transformChanged() const {
    return m_propertySpecificDifferences & TransformChanged;
  }
  void setTransformChanged() {
    m_propertySpecificDifferences |= TransformChanged;
  }

  bool opacityChanged() const {
    return m_propertySpecificDifferences & OpacityChanged;
  }
  void setOpacityChanged() { m_propertySpecificDifferences |= OpacityChanged; }

  bool zIndexChanged() const {
    return m_propertySpecificDifferences & ZIndexChanged;
  }
  void setZIndexChanged() { m_propertySpecificDifferences |= ZIndexChanged; }

  bool filterChanged() const {
    return m_propertySpecificDifferences & FilterChanged;
  }
  void setFilterChanged() { m_propertySpecificDifferences |= FilterChanged; }

  bool backdropFilterChanged() const {
    return m_propertySpecificDifferences & BackdropFilterChanged;
  }
  void setBackdropFilterChanged() {
    m_propertySpecificDifferences |= BackdropFilterChanged;
  }

  bool cssClipChanged() const {
    return m_propertySpecificDifferences & CSSClipChanged;
  }
  void setCSSClipChanged() { m_propertySpecificDifferences |= CSSClipChanged; }

  bool textDecorationOrColorChanged() const {
    return m_propertySpecificDifferences & TextDecorationOrColorChanged;
  }
  void setTextDecorationOrColorChanged() {
    m_propertySpecificDifferences |= TextDecorationOrColorChanged;
  }

  bool scrollAnchorDisablingPropertyChanged() const {
    return m_scrollAnchorDisablingPropertyChanged;
  }
  void setScrollAnchorDisablingPropertyChanged() {
    m_scrollAnchorDisablingPropertyChanged = true;
  }

 private:
  enum PaintInvalidationType {
    NoPaintInvalidation = 0,
    PaintInvalidationObject,
    PaintInvalidationSubtree
  };
  unsigned m_paintInvalidationType : 2;

  enum LayoutType { NoLayout = 0, PositionedMovement, FullLayout };
  unsigned m_layoutType : 2;
  unsigned m_recomputeOverflow : 1;
  unsigned m_propertySpecificDifferences : 7;
  unsigned m_scrollAnchorDisablingPropertyChanged : 1;
};

}  // namespace blink

#endif  // StyleDifference_h