Skip to content

Commit

Permalink
Path::operator== is incorrect and unused
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=265333
rdar://problem/118823083

Reviewed by Tim Nguyen.

It is not entirely trivial to compare paths for equality. The
current implementation is confusing since it returns false for equal
Paths. Remove the implementation instead of fixing since it's not used.

* Source/WebCore/platform/graphics/Path.cpp:
(WebCore::Path::operator== const): Deleted.
* Source/WebCore/platform/graphics/Path.h:
* Tools/TestWebKitAPI/Tests/WebCore/DisplayListTests.cpp:
(TestWebKitAPI::convertToString):
(TestWebKitAPI::TEST):

Canonical link: https://commits.webkit.org/271136@main
  • Loading branch information
kkinnunen-apple committed Nov 27, 2023
1 parent 3d00b46 commit 2502481
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ void AXIsolatedObject::setProperty(AXPropertyName propertyName, AXPropertyValueV
[](Vector<AXID>& typedValue) { return typedValue.isEmpty(); },
[](Vector<std::pair<AXID, AXID>>& typedValue) { return typedValue.isEmpty(); },
[](Vector<String>& typedValue) { return typedValue.isEmpty(); },
[](Path& typedValue) { return typedValue == Path(); },
[](Path& typedValue) { return typedValue.isEmpty(); },
[](OptionSet<AXAncestorFlag>& typedValue) { return typedValue.isEmpty(); },
#if PLATFORM(COCOA)
[](RetainPtr<NSAttributedString>& typedValue) { return !typedValue; },
Expand Down
17 changes: 0 additions & 17 deletions Source/WebCore/platform/graphics/Path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,6 @@ Path::Path(PathSegment&& segment)
m_data = WTFMove(segment);
}

bool Path::operator==(const Path& other) const
{
if (auto segment = asSingle()) {
if (auto otherSegment = other.asSingle())
return *segment == *otherSegment;
return false;
}

if (auto impl = asImpl()) {
if (auto otherImpl = other.asImpl())
return impl == otherImpl;
return false;
}

return true;
}

PathImpl& Path::setImpl(Ref<PathImpl>&& impl)
{
auto& platformPathImpl = impl.get();
Expand Down
2 changes: 0 additions & 2 deletions Source/WebCore/platform/graphics/Path.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ class Path {
Path& operator=(const Path&) = default;
Path& operator=(Path&&) = default;

WEBCORE_EXPORT bool operator==(const Path&) const;

WEBCORE_EXPORT void moveTo(const FloatPoint&);

WEBCORE_EXPORT void addLineTo(const FloatPoint&);
Expand Down
10 changes: 9 additions & 1 deletion Tools/TestWebKitAPI/Tests/WebCore/DisplayListTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,20 @@
#include <WebCore/DisplayListItems.h>
#include <WebCore/Filter.h>
#include <WebCore/Gradient.h>
#include <wtf/text/TextStream.h>

namespace TestWebKitAPI {
using namespace WebCore;
using DisplayList::DisplayList;
using namespace DisplayList;

static String convertToString(const Path& path)
{
TextStream stream(TextStream::LineMode::SingleLine);
stream << path;
return stream.release();
}

static Ref<Gradient> createGradient()
{
auto gradient = Gradient::create(Gradient::ConicData { { 0., 0. }, 1.25 }, { ColorInterpolationMethod::SRGB { }, AlphaPremultiplication::Unpremultiplied });
Expand Down Expand Up @@ -81,7 +89,7 @@ TEST(DisplayListTests, AppendItems)
[&](const SetInlineStroke& item) {
EXPECT_EQ(item.thickness(), 1.5);
}, [&](const FillPath& item) {
EXPECT_EQ(item.path(), path);
EXPECT_EQ(convertToString(item.path()), convertToString(path));
}, [&](const FillRectWithGradient& item) {
EXPECT_EQ(item.rect(), FloatRect(1., 1., 10., 10.));
EXPECT_EQ(item.gradient().ptr(), gradient.ptr());
Expand Down

0 comments on commit 2502481

Please sign in to comment.