Commit 87ad4a2f authored by Vladimir Levin's avatar Vladimir Levin Committed by Commit Bot

Unalias effect nodes when determining whether it has opacity/distorsions

This patch unaliases effect nodes in two places in layout object:
- HasDistortingVisualEffects
- HasNonZeroEffectiveOpacity,

both of which navigate up the effect node chain and check properties.

R=chrishtr@chromium.org, pdr@chromium.org, wangxianzhu@chromium.org

Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: Ib035679dff6822a7cc6127d6b7589e10a89e0cc3
Reviewed-on: https://chromium-review.googlesource.com/c/1265088Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Commit-Queue: vmpstr <vmpstr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#597367}
parent 5fa4f0df
...@@ -1443,15 +1443,14 @@ bool LayoutObject::HasDistortingVisualEffects() const { ...@@ -1443,15 +1443,14 @@ bool LayoutObject::HasDistortingVisualEffects() const {
.LocalBorderBoxProperties(); .LocalBorderBoxProperties();
// No filters, no blends, no opacity < 100%. // No filters, no blends, no opacity < 100%.
const EffectPaintPropertyNode* effects = paint_properties.Effect(); for (const auto* effect = SafeUnalias(paint_properties.Effect()); effect;
while (effects && !effects->IsRoot()) { effect = SafeUnalias(effect->Parent())) {
if (!effects->Filter().IsEmpty() || if (!effect->Filter().IsEmpty() ||
effects->GetColorFilter() != kColorFilterNone || effect->GetColorFilter() != kColorFilterNone ||
effects->BlendMode() != SkBlendMode::kSrcOver || effect->BlendMode() != SkBlendMode::kSrcOver ||
effects->Opacity() != 1.0) { effect->Opacity() != 1.0) {
return true; return true;
} }
effects = effects->Parent();
} }
PropertyTreeState root_properties = GetDocument() PropertyTreeState root_properties = GetDocument()
...@@ -1477,11 +1476,10 @@ bool LayoutObject::HasNonZeroEffectiveOpacity() const { ...@@ -1477,11 +1476,10 @@ bool LayoutObject::HasNonZeroEffectiveOpacity() const {
.FirstFragment() .FirstFragment()
.LocalBorderBoxProperties(); .LocalBorderBoxProperties();
const EffectPaintPropertyNode* effects = paint_properties.Effect(); for (const auto* effect = SafeUnalias(paint_properties.Effect()); effect;
while (effects && !effects->IsRoot()) { effect = SafeUnalias(effect->Parent())) {
if (effects->Opacity() == 0.0) if (effect->Opacity() == 0.0)
return false; return false;
effects = effects->Parent();
} }
return true; return true;
} }
......
...@@ -790,6 +790,23 @@ TEST_F(LayoutObjectTest, HasDistortingVisualEffects) { ...@@ -790,6 +790,23 @@ TEST_F(LayoutObjectTest, HasDistortingVisualEffects) {
ASSERT_TRUE(inner->GetLayoutObject()->HasDistortingVisualEffects()); ASSERT_TRUE(inner->GetLayoutObject()->HasDistortingVisualEffects());
} }
TEST_F(LayoutObjectTest, DistortingVisualEffectsUnaliases) {
SetBodyInnerHTML(R"HTML(
<div style="opacity: 0.2;">
<div style="width: 100px height:100px; contain: paint">
<div id="child"
style="position: relative; width: 100px; height:100px;"></div>
</div>
</div>
)HTML");
const auto* child = GetDocument().getElementById("child");
const auto* object = child->GetLayoutObject();
// This should pass and not DCHECK if the nodes are unaliased correctly.
EXPECT_TRUE(object->HasDistortingVisualEffects());
EXPECT_TRUE(object->HasNonZeroEffectiveOpacity());
}
class LayoutObjectSimTest : public SimTest { class LayoutObjectSimTest : public SimTest {
public: public:
bool DocumentHasTouchActionRegion(const EventHandlerRegistry& registry) { bool DocumentHasTouchActionRegion(const EventHandlerRegistry& registry) {
......
...@@ -9,11 +9,6 @@ ...@@ -9,11 +9,6 @@
namespace blink { namespace blink {
template <typename NodeType>
const NodeType* SafeUnalias(const NodeType* node) {
return node ? node->Unalias() : nullptr;
}
const TransformationMatrix& GeometryMapper::SourceToDestinationProjection( const TransformationMatrix& GeometryMapper::SourceToDestinationProjection(
const TransformPaintPropertyNode* source, const TransformPaintPropertyNode* source,
const TransformPaintPropertyNode* destination) { const TransformPaintPropertyNode* destination) {
......
...@@ -54,6 +54,11 @@ PLATFORM_EXPORT const TransformPaintPropertyNode& LowestCommonAncestorInternal( ...@@ -54,6 +54,11 @@ PLATFORM_EXPORT const TransformPaintPropertyNode& LowestCommonAncestorInternal(
const TransformPaintPropertyNode&, const TransformPaintPropertyNode&,
const TransformPaintPropertyNode&); const TransformPaintPropertyNode&);
template <typename NodeType>
const NodeType* SafeUnalias(const NodeType* node) {
return node ? node->Unalias() : nullptr;
}
template <typename NodeType> template <typename NodeType>
class PaintPropertyNode : public RefCounted<NodeType> { class PaintPropertyNode : public RefCounted<NodeType> {
public: public:
......
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