Chromium Code Reviews| Index: Source/core/rendering/style/StyleDifference.h |
| diff --git a/Source/core/rendering/style/StyleDifference.h b/Source/core/rendering/style/StyleDifference.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..bf6862a154d9dad0a459d0bd684529cf30092aa3 |
| --- /dev/null |
| +++ b/Source/core/rendering/style/StyleDifference.h |
| @@ -0,0 +1,119 @@ |
| +// 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 |
| + |
| +namespace WebCore { |
| + |
| +// The difference between two styles. It has the following types of flags: |
| +class StyleDifference { |
| +public: |
| + StyleDifference() |
| + : m_needsRecompositeLayer(0) |
| + , m_repaintType(NoRepaint) |
| + , m_layoutType(NoLayout) |
| + , m_contextSensitiveFlags(NotContextSensitive) { } |
| + |
| + // The two styles are identical. |
| + bool noChange() const |
|
Julien - ping for review
2014/04/18 16:37:00
Our coding style mandates a verb in boolean getter
Xianzhu
2014/04/18 17:46:56
Done.
|
| + { |
| + return !m_needsRecompositeLayer |
| + && m_repaintType == NoRepaint |
| + && m_layoutType == NoLayout |
| + && !isContextSensitive(); |
| + } |
| + |
| + // The layer needs its position and transform updated. Only meaningful when |
| + // no other flags are set because it's implied by other flags. |
|
Julien - ping for review
2014/04/18 16:37:00
It's weird that the getter doesn't check the other
Xianzhu
2014/04/18 17:46:56
Added other checks.
However for other implication
|
| + bool needsRecompositeLayer() const { return m_needsRecompositeLayer; } |
| + void setNeedsRecompositeLayer() { m_needsRecompositeLayer = 1; } |
| + |
| + bool needsRepaint() const { return m_repaintType != NoRepaint; } |
| + |
| + // The object just needs to be repainted. |
| + bool needsRepaintSelf() const { return m_repaintType == RepaintSelf; } |
| + void setNeedsRepaintSelf() { m_repaintType = RepaintSelf; } |
| + |
| + // Sub flag of needsRepaint. The layer and its descendant layers needs to be repainted. |
| + bool needsRepaintLayer() const { return m_repaintType == RepaintLayer; } |
| + void setNeedsRepaintLayer() { m_repaintType = RepaintLayer; } |
| + |
| + bool needsLayout() const { return m_layoutType != NoLayout; } |
| + |
| + // The position of this positioned object has been updated. |
| + bool needsPositionedMovementLayout() const { return m_layoutType & PositionedMovement; } |
| + void setNeedsPositionedMovementLayout() |
| + { |
| + if (!needsFullLayout()) |
| + m_layoutType |= PositionedMovement; |
| + } |
| + |
| + // Overflow needs to be recomputed. |
| + bool needsSimplifiedLayout() const { return m_layoutType & SimplifiedLayout; } |
| + void setNeedsSimplifiedLayout() |
| + { |
| + if (!needsFullLayout()) |
| + m_layoutType |= SimplifiedLayout; |
| + } |
| + |
| + // A full layout is required. |
| + bool needsFullLayout() const { return m_layoutType == FullLayout; } |
| + void setNeedsFullLayout() { m_layoutType = FullLayout; } |
| + |
| + // When some style properties change, different amounts of work have to be done depending on |
| + // context (e.g. whether the property is changing on an element which has a compositing layer). |
| + // Caller of RenderStyle::visualInvalidationDiff() needs to check the context and determine |
| + // what work is needed. |
| + bool isContextSensitive() const { return m_contextSensitiveFlags != NotContextSensitive; } |
| + void resetContextSensitiveFlags() { m_contextSensitiveFlags = NotContextSensitive; } |
| + |
| + bool transformChanged() const { return m_contextSensitiveFlags & TransformChanged; } |
| + void setTransformChanged() { m_contextSensitiveFlags |= TransformChanged; } |
| + |
| + bool opacityChanged() const { return m_contextSensitiveFlags & OpacityChanged; } |
| + void setOpacityChanged() { m_contextSensitiveFlags |= OpacityChanged; } |
| + |
| + bool zIndexChanged() const { return m_contextSensitiveFlags & ZIndexChanged; } |
| + void setZIndexChanged() { m_contextSensitiveFlags |= ZIndexChanged; } |
| + |
| + bool filterChanged() const { return m_contextSensitiveFlags & FilterChanged; } |
| + void setFilterChanged() { m_contextSensitiveFlags |= FilterChanged; } |
| + |
| + // Text decoration or color changed. Needs repaint if the object contains text or properties dependent or color (e.g., border or outline). |
| + bool textOrColorChanged() const { return m_contextSensitiveFlags & TextOrColorChanged; } |
| + void setTextOrColorChanged() { m_contextSensitiveFlags |= TextOrColorChanged; } |
| + |
| +private: |
| + unsigned m_needsRecompositeLayer : 1; |
| + |
| + enum RepaintType { |
| + NoRepaint, |
| + RepaintSelf, |
| + RepaintLayer |
| + }; |
| + unsigned m_repaintType : 2; |
| + |
| + enum LayoutType { |
| + NoLayout = 0, |
| + PositionedMovement = 1 << 0, |
| + SimplifiedLayout = 1 << 1, |
| + FullLayout = 1 << 2 |
| + }; |
|
Julien - ping for review
2014/04/18 16:37:00
We are going to change the code to not allow both
Xianzhu
2014/04/18 17:46:56
Glad to see the change has been landed :)
Rebasing
|
| + unsigned m_layoutType : 3; |
| + |
| + enum ContextSensitiveFlags { |
| + NotContextSensitive = 0, |
| + TransformChanged = 1 << 0, |
| + OpacityChanged = 1 << 1, |
| + ZIndexChanged = 1 << 2, |
| + FilterChanged = 1 << 3, |
| + TextOrColorChanged = 1 << 4 |
| + }; |
| + unsigned m_contextSensitiveFlags : 5; |
| +}; |
| + |
| +} // namespace WebCore |
| + |
| +#endif // StyleDifference_h |