Commit f6d06400 authored by rune@opera.com's avatar rune@opera.com

RenderStyle operator== incorrect for shape-outside and clip-path.

Use dataEquivalent instead of comparing pointers. Updating the base
RenderStyle in ActiveAnimations asserts that the cached base RenderStyle
is correct by comparing RenderStyle objects. It triggered an assert when
comparing two shape-outside values represented by different objects
representing the same value.

R=esprehn@chromium.org,dstockwell@chromium.org
BUG=425473

Review URL: https://codereview.chromium.org/669093002

git-svn-id: svn://svn.chromium.org/blink/trunk@184345 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent ea27da21
<!DOCTYPE html>
<p>This test passes if it does not assert or crash.</p>
<input autofocus ontransitionend="transitionFinished();">
<style>
input {
transition: ease, 50ms;
shape-outside: padding-box;
}
</style>
<script>
function transitionFinished() {
if (window.testRunner)
testRunner.notifyDone();
}
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
</script>
......@@ -3598,6 +3598,7 @@
'rendering/TextPainterTest.cpp',
'rendering/shapes/BoxShapeTest.cpp',
'rendering/style/OutlineValueTest.cpp',
'rendering/style/RenderStyleTest.cpp',
'testing/PrivateScriptTestTest.cpp',
'streams/ReadableStreamTest.cpp',
'testing/UnitTestHelpers.cpp',
......
......@@ -668,8 +668,8 @@ bool RenderStyle::diffNeedsPaintInvalidationObject(const RenderStyle& other) con
|| rareNonInheritedData->m_objectFit != other.rareNonInheritedData->m_objectFit
|| rareNonInheritedData->m_objectPosition != other.rareNonInheritedData->m_objectPosition
|| !rareNonInheritedData->shadowDataEquivalent(*other.rareNonInheritedData.get())
|| !dataEquivalent(rareNonInheritedData->m_shapeOutside, other.rareNonInheritedData->m_shapeOutside)
|| !dataEquivalent(rareNonInheritedData->m_clipPath, other.rareNonInheritedData->m_clipPath))
|| !rareNonInheritedData->shapeOutsideDataEquivalent(*other.rareNonInheritedData.get())
|| !rareNonInheritedData->clipPathDataEquivalent(*other.rareNonInheritedData.get()))
return true;
}
......
// 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.
#include "config.h"
#include "core/rendering/style/RenderStyle.h"
#include "core/rendering/ClipPathOperation.h"
#include "core/rendering/style/ShapeValue.h"
#include <gtest/gtest.h>
using namespace blink;
namespace {
TEST(RenderStyleTest, ShapeOutsideBoxEqual)
{
RefPtr<ShapeValue> shape1 = ShapeValue::createBoxShapeValue(ContentBox);
RefPtr<ShapeValue> shape2 = ShapeValue::createBoxShapeValue(ContentBox);
RefPtr<RenderStyle> style1 = RenderStyle::create();
RefPtr<RenderStyle> style2 = RenderStyle::create();
style1->setShapeOutside(shape1);
style2->setShapeOutside(shape2);
ASSERT_EQ(*style1, *style2);
}
TEST(RenderStyleTest, ShapeOutsideCircleEqual)
{
RefPtr<BasicShapeCircle> circle1 = BasicShapeCircle::create();
RefPtr<BasicShapeCircle> circle2 = BasicShapeCircle::create();
RefPtr<ShapeValue> shape1 = ShapeValue::createShapeValue(circle1, ContentBox);
RefPtr<ShapeValue> shape2 = ShapeValue::createShapeValue(circle2, ContentBox);
RefPtr<RenderStyle> style1 = RenderStyle::create();
RefPtr<RenderStyle> style2 = RenderStyle::create();
style1->setShapeOutside(shape1);
style2->setShapeOutside(shape2);
ASSERT_EQ(*style1, *style2);
}
TEST(RenderStyleTest, ClipPathEqual)
{
RefPtr<BasicShapeCircle> shape = BasicShapeCircle::create();
RefPtr<ShapeClipPathOperation> path1 = ShapeClipPathOperation::create(shape);
RefPtr<ShapeClipPathOperation> path2 = ShapeClipPathOperation::create(shape);
RefPtr<RenderStyle> style1 = RenderStyle::create();
RefPtr<RenderStyle> style2 = RenderStyle::create();
style1->setClipPath(path1);
style2->setClipPath(path2);
ASSERT_EQ(*style1, *style2);
}
}
......@@ -32,6 +32,7 @@
#include "core/fetch/ImageResource.h"
#include "core/rendering/style/BasicShapes.h"
#include "core/rendering/style/DataEquivalency.h"
#include "core/rendering/style/RenderStyleConstants.h"
#include "core/rendering/style/StyleImage.h"
#include "wtf/PassRefPtr.h"
......@@ -122,11 +123,11 @@ inline bool ShapeValue::operator==(const ShapeValue& other) const
switch (type()) {
case Shape:
return shape() == other.shape() && cssBox() == other.cssBox();
return dataEquivalent(shape(), other.shape()) && cssBox() == other.cssBox();
case Box:
return cssBox() == other.cssBox();
case Image:
return image() == other.image();
return dataEquivalent(image(), other.image());
}
ASSERT_NOT_REACHED();
......
......@@ -204,10 +204,10 @@ bool StyleRareNonInheritedData::operator==(const StyleRareNonInheritedData& o) c
&& m_mask == o.m_mask
&& m_maskBoxImage == o.m_maskBoxImage
&& m_pageSize == o.m_pageSize
&& m_shapeOutside == o.m_shapeOutside
&& shapeOutsideDataEquivalent(o)
&& m_shapeMargin == o.m_shapeMargin
&& m_shapeImageThreshold == o.m_shapeImageThreshold
&& m_clipPath == o.m_clipPath
&& clipPathDataEquivalent(o)
&& m_textDecorationColor == o.m_textDecorationColor
&& m_visitedLinkTextDecorationColor == o.m_visitedLinkTextDecorationColor
&& m_visitedLinkBackgroundColor == o.m_visitedLinkBackgroundColor
......@@ -306,4 +306,14 @@ bool StyleRareNonInheritedData::hasFilters() const
return m_filter.get() && !m_filter->m_operations.isEmpty();
}
bool StyleRareNonInheritedData::shapeOutsideDataEquivalent(const StyleRareNonInheritedData& o) const
{
return dataEquivalent(m_shapeOutside, o.m_shapeOutside);
}
bool StyleRareNonInheritedData::clipPathDataEquivalent(const StyleRareNonInheritedData& o) const
{
return dataEquivalent(m_clipPath, o.m_clipPath);
}
} // namespace blink
......@@ -86,6 +86,8 @@ public:
bool reflectionDataEquivalent(const StyleRareNonInheritedData&) const;
bool animationDataEquivalent(const StyleRareNonInheritedData&) const;
bool transitionDataEquivalent(const StyleRareNonInheritedData&) const;
bool shapeOutsideDataEquivalent(const StyleRareNonInheritedData&) const;
bool clipPathDataEquivalent(const StyleRareNonInheritedData&) const;
bool hasFilters() const;
bool hasOpacity() const { return opacity < 1; }
......
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