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 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
|
// 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 THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_STYLE_DIFFERENCE_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_STYLE_DIFFERENCE_H_
#include <algorithm>
#include <iosfwd>
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
#include "third_party/blink/renderer/platform/wtf/assertions.h"
namespace blink {
class StyleDifference {
STACK_ALLOCATED();
public:
enum PropertyDifference {
kTransformChanged = 1 << 0,
kOpacityChanged = 1 << 1,
kZIndexChanged = 1 << 2,
kFilterChanged = 1 << 3,
kCSSClipChanged = 1 << 4,
// The object needs to issue paint invalidations if it is affected by text
// decorations or properties dependent on color (e.g., border or outline).
// TextDecoration changes must also invalidate ink overflow.
kTextDecorationOrColorChanged = 1 << 5,
kBlendModeChanged = 1 << 6,
kMaskChanged = 1 << 7,
// Whether background-color changed alpha to or from 1.
kHasAlphaChanged = 1 << 8,
// If you add a value here, be sure to update kPropertyDifferenceCount.
};
StyleDifference()
: needs_paint_invalidation_(false),
layout_type_(kNoLayout),
needs_reshape_(false),
recompute_visual_overflow_(false),
visual_rect_update_(false),
property_specific_differences_(0),
scroll_anchor_disabling_property_changed_(false),
compositing_reasons_changed_(false) {}
void Merge(StyleDifference other) {
needs_paint_invalidation_ |= other.needs_paint_invalidation_;
layout_type_ = std::max(layout_type_, other.layout_type_);
needs_reshape_ |= other.needs_reshape_;
recompute_visual_overflow_ |= other.recompute_visual_overflow_;
visual_rect_update_ |= other.visual_rect_update_;
property_specific_differences_ |= other.property_specific_differences_;
scroll_anchor_disabling_property_changed_ |=
other.scroll_anchor_disabling_property_changed_;
compositing_reasons_changed_ |= other.compositing_reasons_changed_;
}
bool HasDifference() const {
return needs_paint_invalidation_ || layout_type_ || needs_reshape_ ||
property_specific_differences_ || recompute_visual_overflow_ ||
visual_rect_update_ || scroll_anchor_disabling_property_changed_ ||
compositing_reasons_changed_;
}
bool HasAtMostPropertySpecificDifferences(
unsigned property_differences) const {
return !needs_paint_invalidation_ && !layout_type_ &&
!compositing_reasons_changed_ &&
!(property_specific_differences_ & ~property_differences);
}
bool NeedsPaintInvalidation() const { return needs_paint_invalidation_; }
void SetNeedsPaintInvalidation() { needs_paint_invalidation_ = true; }
bool NeedsLayout() const { return layout_type_ != kNoLayout; }
void ClearNeedsLayout() { layout_type_ = kNoLayout; }
// The offset of this positioned object has been updated.
bool NeedsPositionedMovementLayout() const {
return layout_type_ == kPositionedMovement;
}
void SetNeedsPositionedMovementLayout() {
DCHECK(!NeedsFullLayout());
layout_type_ = kPositionedMovement;
}
bool NeedsFullLayout() const { return layout_type_ == kFullLayout; }
void SetNeedsFullLayout() { layout_type_ = kFullLayout; }
bool NeedsReshape() const { return needs_reshape_; }
void SetNeedsReshape() { needs_reshape_ = true; }
bool NeedsRecomputeVisualOverflow() const {
return recompute_visual_overflow_;
}
void SetNeedsRecomputeVisualOverflow() { recompute_visual_overflow_ = true; }
bool NeedsVisualRectUpdate() const { return visual_rect_update_; }
void SetNeedsVisualRectUpdate() { visual_rect_update_ = true; }
bool TransformChanged() const {
return property_specific_differences_ & kTransformChanged;
}
void SetTransformChanged() {
property_specific_differences_ |= kTransformChanged;
}
bool OpacityChanged() const {
return property_specific_differences_ & kOpacityChanged;
}
void SetOpacityChanged() {
property_specific_differences_ |= kOpacityChanged;
}
bool ZIndexChanged() const {
return property_specific_differences_ & kZIndexChanged;
}
void SetZIndexChanged() { property_specific_differences_ |= kZIndexChanged; }
bool FilterChanged() const {
return property_specific_differences_ & kFilterChanged;
}
void SetFilterChanged() { property_specific_differences_ |= kFilterChanged; }
bool CssClipChanged() const {
return property_specific_differences_ & kCSSClipChanged;
}
void SetCSSClipChanged() {
property_specific_differences_ |= kCSSClipChanged;
}
bool BlendModeChanged() const {
return property_specific_differences_ & kBlendModeChanged;
}
void SetBlendModeChanged() {
property_specific_differences_ |= kBlendModeChanged;
}
bool TextDecorationOrColorChanged() const {
return property_specific_differences_ & kTextDecorationOrColorChanged;
}
void SetTextDecorationOrColorChanged() {
property_specific_differences_ |= kTextDecorationOrColorChanged;
}
bool MaskChanged() const {
return property_specific_differences_ & kMaskChanged;
}
void SetMaskChanged() { property_specific_differences_ |= kMaskChanged; }
bool HasAlphaChanged() const {
return property_specific_differences_ & kHasAlphaChanged;
}
void SetHasAlphaChanged() {
property_specific_differences_ |= kHasAlphaChanged;
}
bool ScrollAnchorDisablingPropertyChanged() const {
return scroll_anchor_disabling_property_changed_;
}
void SetScrollAnchorDisablingPropertyChanged() {
scroll_anchor_disabling_property_changed_ = true;
}
bool CompositingReasonsChanged() const {
return compositing_reasons_changed_;
}
void SetCompositingReasonsChanged() { compositing_reasons_changed_ = true; }
private:
static constexpr int kPropertyDifferenceCount = 9;
friend CORE_EXPORT std::ostream& operator<<(std::ostream&,
const StyleDifference&);
unsigned needs_paint_invalidation_ : 1;
enum LayoutType { kNoLayout = 0, kPositionedMovement, kFullLayout };
unsigned layout_type_ : 2;
unsigned needs_reshape_ : 1;
unsigned recompute_visual_overflow_ : 1;
unsigned visual_rect_update_ : 1;
unsigned property_specific_differences_ : kPropertyDifferenceCount;
unsigned scroll_anchor_disabling_property_changed_ : 1;
unsigned compositing_reasons_changed_ : 1;
};
CORE_EXPORT std::ostream& operator<<(std::ostream&, const StyleDifference&);
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_STYLE_DIFFERENCE_H_
|