Commit c34e49db authored by Rune Lillesveen's avatar Rune Lillesveen Committed by Commit Bot

FillLayer::VisuallyEqual incorrect comparison when first layer is none.

Even if the first background layer has none for image, we may have
subsequent layers with images. The previous implementation did an early
exit if both images in the first layer were null.

Implement VisuallyEqual without using operator== to fix this issue for
all layers without missing the optimization that different background
positions do not trigger a repaint if the background image for the layer
is none.

Bug: 793773
Change-Id: I846c75b2c4c273bcebecdf84685d834d946926b1
Reviewed-on: https://chromium-review.googlesource.com/822074
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Reviewed-by: default avatarFredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#523412}
parent 6dd82658
<!DOCTYPE html>
<html class="reftest-wait">
<meta charset="utf-8">
<title>CSS Backgrounds and Borders: Repaint gradient change in second layer</title>
<link rel="author" title="Rune Lillesveen" href="mailto:futhark@chromium.org">
<link rel="match" href="background-clip-color-repaint-ref.html">
<link rel="help" href="https://drafts.csswg.org/css-backgrounds/#layering">
<style>
#box {
width: 150px;
height: 150px;
}
.red {
background: none, linear-gradient(to right, red, red);
}
.green {
background: none, linear-gradient(to right, green, green);
}
</style>
<p>There should be a green square below.</p>
<div id="box" class="red"></div>
<script>
requestAnimationFrame(function(){
requestAnimationFrame(function(){
box.className = "green";
document.documentElement.classList.remove("reftest-wait");
});
});
</script>
......@@ -164,10 +164,7 @@ FillLayer& FillLayer::operator=(const FillLayer& o) {
return *this;
}
bool FillLayer::operator==(const FillLayer& o) const {
// We do not check the "isSet" booleans for each property, since those are
// only used during initial construction to propagate patterns into layers.
// All layer comparisons happen after values have all been filled in anyway.
bool FillLayer::LayerPropertiesEqual(const FillLayer& o) const {
return DataEquivalent(image_, o.image_) && x_position_ == o.x_position_ &&
y_position_ == o.y_position_ &&
background_x_origin_ == o.background_x_origin_ &&
......@@ -177,14 +174,22 @@ bool FillLayer::operator==(const FillLayer& o) const {
origin_ == o.origin_ && repeat_x_ == o.repeat_x_ &&
repeat_y_ == o.repeat_y_ && size_type_ == o.size_type_ &&
mask_source_type_ == o.mask_source_type_ &&
size_length_ == o.size_length_ && type_ == o.type_ &&
size_length_ == o.size_length_ && type_ == o.type_;
}
bool FillLayer::operator==(const FillLayer& o) const {
return LayerPropertiesEqual(o) &&
((next_ && o.next_) ? *next_ == *o.next_ : next_ == o.next_);
}
bool FillLayer::VisuallyEqual(const FillLayer& o) const {
if (!image_ && !o.image_ && clip_ == o.clip_)
return true;
return *this == o;
if (image_ || o.image_) {
if (!LayerPropertiesEqual(o))
return false;
}
if (next_ && o.next_)
return next_->VisuallyEqual(*o.next_);
return next_ == o.next_;
}
void FillLayer::FillUnsetProperties() {
......
......@@ -300,6 +300,7 @@ class CORE_EXPORT FillLayer {
bool ImageIsOpaque(const Document&, const ComputedStyle&) const;
bool ImageTilesLayer() const;
bool LayerPropertiesEqual(const FillLayer&) const;
FillLayer* next_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment