| Differences between
and this patch
- a/Source/WebCore/ChangeLog +34 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2022-05-04  Nikolaos Mouchtaris  <nmouchtaris@apple.com>
2
3
        Support ray() shape in offset-path
4
        https://bugs.webkit.org/show_bug.cgi?id=233344
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Add support for rendering ray path. Involves getting containing block and offset
9
        of the element from the containing block. Using the size of the containing block
10
        and offset, calculate the length of the ray and create a Line path using the length
11
        and angle. Calculating closest/farthest-side and closest/farthest-corner are simple 
12
        but calculating side requires some explanation. First, we get the two possible sides of 
13
        the containing block the ray could be intersecting with, based on the angle. To calculate 
14
        which side is being intersected, if tan(theta) * top/bottom is outside of the containing 
15
        block, this means that the ray is intersecting with the other side. Finally, we calculate 
16
        the acute angle based on which side we intersected with. Using the length and angle, we 
17
        calculate the length of the hypotenuse, which corresponds with the length of the start point
18
        of the ray to its intersection with a side of the containing block. Test 7 is still failing 
19
        due to getting incorrect width of containing block (doesn't happen when animating the path
20
        for some reason). Will implement contain in another patch.
21
22
        * WebCore.xcodeproj/project.pbxproj:
23
        * rendering/PathOperation.cpp:
24
        (WebCore::toPositiveAngle):
25
        (WebCore::RayPathOperation::getLengthForPath const):
26
        (WebCore::RayPathOperation::pathForReferenceRect const):
27
        * rendering/PathOperation.h:
28
        * rendering/RenderLayer.cpp:
29
        (WebCore::RenderLayer::setReferenceBoxForPathOperations):
30
        (WebCore::RenderLayer::updateTransform):
31
        * rendering/RenderLayer.h:
32
        * rendering/style/RenderStyle.cpp:
33
        (WebCore::getPathFromPathOperation):
34
1
2022-04-28  Philippe Normand  <philn@igalia.com>
35
2022-04-28  Philippe Normand  <philn@igalia.com>
2
36
3
        [GStreamer] Pipewire display capture broken
37
        [GStreamer] Pipewire display capture broken
- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj +2 lines
Lines 6987-6992 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec1
6987
		1AB7FC660A8B92EC00D9D37B /* XPathVariableReference.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = XPathVariableReference.cpp; sourceTree = "<group>"; };
6987
		1AB7FC660A8B92EC00D9D37B /* XPathVariableReference.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = XPathVariableReference.cpp; sourceTree = "<group>"; };
6988
		1AB7FC670A8B92EC00D9D37B /* XPathVariableReference.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = XPathVariableReference.h; sourceTree = "<group>"; };
6988
		1AB7FC670A8B92EC00D9D37B /* XPathVariableReference.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = XPathVariableReference.h; sourceTree = "<group>"; };
6989
		1ABA7FFF1897341200DCE9D6 /* VisitedLinkStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VisitedLinkStore.h; sourceTree = "<group>"; };
6989
		1ABA7FFF1897341200DCE9D6 /* VisitedLinkStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VisitedLinkStore.h; sourceTree = "<group>"; };
6990
		1ABC260327FD02140064F68F /* PathOperation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PathOperation.cpp; sourceTree = "<group>"; };
6990
		1AC2260A0DB69F190089B669 /* JSDOMApplicationCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMApplicationCache.cpp; sourceTree = "<group>"; };
6991
		1AC2260A0DB69F190089B669 /* JSDOMApplicationCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMApplicationCache.cpp; sourceTree = "<group>"; };
6991
		1AC2260B0DB69F190089B669 /* JSDOMApplicationCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMApplicationCache.h; sourceTree = "<group>"; };
6992
		1AC2260B0DB69F190089B669 /* JSDOMApplicationCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMApplicationCache.h; sourceTree = "<group>"; };
6992
		1AC2D89C1B1E291F00D52E87 /* FontAntialiasingStateSaver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontAntialiasingStateSaver.h; sourceTree = "<group>"; };
6993
		1AC2D89C1B1E291F00D52E87 /* FontAntialiasingStateSaver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontAntialiasingStateSaver.h; sourceTree = "<group>"; };
Lines 32247-32252 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec2
32247
				55EC95972069C92D007DD0A9 /* PaintFrequencyTracker.h */,
32248
				55EC95972069C92D007DD0A9 /* PaintFrequencyTracker.h */,
32248
				0885067D11DA045B00182B98 /* PaintInfo.h */,
32249
				0885067D11DA045B00182B98 /* PaintInfo.h */,
32249
				0885067E11DA045B00182B98 /* PaintPhase.h */,
32250
				0885067E11DA045B00182B98 /* PaintPhase.h */,
32251
				1ABC260327FD02140064F68F /* PathOperation.cpp */,
32250
				FB92DF4915FED08700994433 /* PathOperation.h */,
32252
				FB92DF4915FED08700994433 /* PathOperation.h */,
32251
				B2B1F7140D00CAA8004AEA64 /* PointerEventsHitRules.cpp */,
32253
				B2B1F7140D00CAA8004AEA64 /* PointerEventsHitRules.cpp */,
32252
				B2B1F7150D00CAA8004AEA64 /* PointerEventsHitRules.h */,
32254
				B2B1F7150D00CAA8004AEA64 /* PointerEventsHitRules.h */,
- a/Source/WebCore/rendering/PathOperation.cpp +54 lines
Lines 48-51 const SVGElement* ReferencePathOperation::element() const a/Source/WebCore/rendering/PathOperation.cpp_sec1
48
{
48
{
49
    return m_element.get();
49
    return m_element.get();
50
}
50
}
51
52
static double toPositiveAngle(double angle)
53
{
54
    angle = fmod(angle, 360);
55
    while (angle < 0)
56
        angle += 360.0;
57
    return angle;
58
}
59
60
double RayPathOperation::getLengthForPath() const
61
{
62
    auto boundingBox = m_containingBlockBoundingRect;
63
    // Distance to each side of the containing box
64
    double top = std::abs(m_position.height());
65
    double bottom = std::abs(m_position.height() - boundingBox.height());
66
    double left = std::abs(m_position.width());
67
    double right = std::abs(m_position.width() - boundingBox.width());
68
    
69
    switch (m_size) {
70
    case Size::ClosestSide:
71
        return std::min( { top, bottom, left, right } );
72
    case Size::FarthestSide:
73
        return std::max( { top, bottom, left, right } );
74
    case Size::FarthestCorner:
75
        return std::sqrt(std::pow(std::max(left, right), 2) + std::pow(std::max(top, bottom), 2));
76
    case Size::ClosestCorner:
77
        return std::sqrt(std::pow(std::min(left, right), 2) + std::pow(std::min(top, bottom), 2));
78
    case Size::Sides:
79
        if (m_position.width() < 0 || m_position.width() > boundingBox.width() || m_position.height() < 0 || m_position.height() > boundingBox.height())
80
            return 0;
81
        auto radians = deg2rad(m_angle);
82
        // Get possible intersection sides
83
        double s1 = cos(radians) >= 0 ? top : bottom;
84
        double s2 = sin(radians) >= 0 ? right : left;
85
        // Get intersection side - based on length of tan() * s1
86
        double intersectionSide = sin(radians) * s1 > cos(radians) * s2 ? s1 : s2;
87
        // Calculate angle based on what side we intersected with
88
        double angle = deg2rad(sin(radians) * s1 > cos(radians) * s2 ? 90 - std::fmod(toPositiveAngle(m_angle), 90) : std::fmod(toPositiveAngle(m_angle), 90));
89
        return intersectionSide / cos(angle);
90
    }
91
}
92
93
const Path RayPathOperation::pathForReferenceRect() const
94
{
95
    Path path;
96
    if (m_containingBlockBoundingRect.isZero())
97
        return path;
98
    auto length = getLengthForPath();
99
    auto radians = deg2rad(toPositiveAngle(m_angle) - 90);
100
    auto point = FloatPoint(std::cos(radians) * length, std::sin(radians) * length);
101
    path.addLineTo(point);
102
    return path;
103
}
104
51
} // namespace WebCore
105
} // namespace WebCore
- a/Source/WebCore/rendering/PathOperation.h -1 / +14 lines
Lines 195-201 public: a/Source/WebCore/rendering/PathOperation.h_sec1
195
    {
195
    {
196
        return RayPathOperation::create(WebCore::blend(m_angle, to.m_angle, context), m_size, m_isContaining);
196
        return RayPathOperation::create(WebCore::blend(m_angle, to.m_angle, context), m_size, m_isContaining);
197
    }
197
    }
198
198
    
199
    const Path pathForReferenceRect() const;
200
    double getLengthForPath() const;
201
    
202
    void setContainingBloackReferenceRect(const FloatRect& boundingRect)
203
    {
204
        m_containingBlockBoundingRect = boundingRect;
205
    }
206
    void setStartingPosition(const FloatSize& position)
207
    {
208
        m_position = position;
209
    }
199
private:
210
private:
200
    bool operator==(const PathOperation& other) const override
211
    bool operator==(const PathOperation& other) const override
201
    {
212
    {
Lines 219-224 private: a/Source/WebCore/rendering/PathOperation.h_sec2
219
    float m_angle;
230
    float m_angle;
220
    Size m_size;
231
    Size m_size;
221
    bool m_isContaining;
232
    bool m_isContaining;
233
    FloatRect m_containingBlockBoundingRect;
234
    FloatSize m_position;
222
};
235
};
223
236
224
} // namespace WebCore
237
} // namespace WebCore
- a/Source/WebCore/rendering/RenderLayer.cpp -7 / +23 lines
Lines 1317-1322 void RenderLayer::updateTransformFromStyle(TransformationMatrix& transform, cons a/Source/WebCore/rendering/RenderLayer.cpp_sec1
1317
    makeMatrixRenderable(transform, canRender3DTransforms());
1317
    makeMatrixRenderable(transform, canRender3DTransforms());
1318
}
1318
}
1319
1319
1320
void RenderLayer::setReferenceBoxForPathOperations()
1321
{
1322
    if (auto pathOperation = renderer().style().offsetPath(); pathOperation && is<BoxPathOperation>(pathOperation)) {
1323
        auto& boxPathOperation = downcast<BoxPathOperation>(*pathOperation);
1324
        auto pathReferenceBoxRect = snapRectToDevicePixelsIfNeeded(renderer().referenceBoxRect(boxPathOperation.referenceBox()), renderer());
1325
        boxPathOperation.setPathForReferenceRect(FloatRoundedRect { pathReferenceBoxRect });
1326
    } else if (pathOperation && is<RayPathOperation>(pathOperation)) {
1327
        if (const auto* containingBlock = renderer().containingBlock()) {
1328
            auto& rayPathOperation = downcast<RayPathOperation>(*pathOperation);
1329
            auto pathReferenceBoxRect = snapRectToDevicePixelsIfNeeded(containingBlock->transformReferenceBoxRect(containingBlock->style()), renderer());
1330
            if (!pathReferenceBoxRect.width())
1331
                pathReferenceBoxRect.setWidth(pathReferenceBoxRect.height());
1332
            if (!pathReferenceBoxRect.height())
1333
                pathReferenceBoxRect.setHeight(pathReferenceBoxRect.width());
1334
            rayPathOperation.setContainingBloackReferenceRect(pathReferenceBoxRect);
1335
            auto left = renderer().style().left();
1336
            auto top = renderer().style().top();
1337
            rayPathOperation.setStartingPosition(FloatSize(left.isPercent() ? left.value() / 100 * pathReferenceBoxRect.width() : left.value(), top.isPercent() ? top.value() / 100 * pathReferenceBoxRect.height() : top.value()));
1338
        }
1339
    }
1340
}
1341
1320
void RenderLayer::updateTransform()
1342
void RenderLayer::updateTransform()
1321
{
1343
{
1322
    bool hasTransform = renderer().hasTransform();
1344
    bool hasTransform = renderer().hasTransform();
Lines 1335-1347 void RenderLayer::updateTransform() a/Source/WebCore/rendering/RenderLayer.cpp_sec2
1335
    
1357
    
1336
    if (hasTransform) {
1358
    if (hasTransform) {
1337
        m_transform->makeIdentity();
1359
        m_transform->makeIdentity();
1338
1360
        setReferenceBoxForPathOperations();
1339
        if (auto pathOperation = renderer().style().offsetPath(); pathOperation && is<BoxPathOperation>(pathOperation)) {
1340
            auto& boxPathOperation = downcast<BoxPathOperation>(*pathOperation);
1341
            auto pathReferenceBoxRect = snapRectToDevicePixelsIfNeeded(renderer().referenceBoxRect(boxPathOperation.referenceBox()), renderer());
1342
            boxPathOperation.setPathForReferenceRect(FloatRoundedRect { pathReferenceBoxRect });
1343
        }
1344
1345
        updateTransformFromStyle(*m_transform, renderer().style(), RenderStyle::allTransformOperations);
1361
        updateTransformFromStyle(*m_transform, renderer().style(), RenderStyle::allTransformOperations);
1346
    }
1362
    }
1347
1363
- a/Source/WebCore/rendering/RenderLayer.h -1 / +2 lines
Lines 508-514 public: a/Source/WebCore/rendering/RenderLayer.h_sec1
508
            return nullptr;
508
            return nullptr;
509
        return m_enclosingPaginationLayer.get();
509
        return m_enclosingPaginationLayer.get();
510
    }
510
    }
511
511
    
512
    void setReferenceBoxForPathOperations();
512
    void updateTransform();
513
    void updateTransform();
513
    
514
    
514
#if ENABLE(CSS_COMPOSITING)
515
#if ENABLE(CSS_COMPOSITING)
- a/Source/WebCore/rendering/style/RenderStyle.cpp -2 / +1 lines
Lines 1538-1545 static std::optional<Path> getPathFromPathOperation(const FloatRect& box, const a/Source/WebCore/rendering/style/RenderStyle.cpp_sec1
1538
    case PathOperation::Box:
1538
    case PathOperation::Box:
1539
        return downcast<BoxPathOperation>(operation).getPath();
1539
        return downcast<BoxPathOperation>(operation).getPath();
1540
    case PathOperation::Ray:
1540
    case PathOperation::Ray:
1541
        // FIXME: implement ray- https://bugs.webkit.org/show_bug.cgi?id=233344
1541
        return downcast<RayPathOperation>(operation).pathForReferenceRect();
1542
        return std::nullopt;
1543
    }
1542
    }
1544
    RELEASE_ASSERT_NOT_REACHED();
1543
    RELEASE_ASSERT_NOT_REACHED();
1545
}
1544
}
- a/LayoutTests/ChangeLog +9 lines
Lines 1-3 a/LayoutTests/ChangeLog_sec1
1
2022-05-04  Nikolaos Mouchtaris  <nmouchtaris@apple.com>
2
3
        Support ray() shape in offset-path
4
        https://bugs.webkit.org/show_bug.cgi?id=233344
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        * TestExpectations:
9
1
2022-04-28  Simon Fraser  <simon.fraser@apple.com>
10
2022-04-28  Simon Fraser  <simon.fraser@apple.com>
2
11
3
        [ macOS Debug wk2 ] Thirteen imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/ are a flaky crash (ASSERTION FAILED: willBeComposited == needsToBeComposited(layer, queryData))
12
        [ macOS Debug wk2 ] Thirteen imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/ are a flaky crash (ASSERTION FAILED: willBeComposited == needsToBeComposited(layer, queryData))
- a/LayoutTests/TestExpectations -9 / +1 lines
Lines 5072-5087 webkit.org/b/233340 imported/w3c/web-platform-tests/css/motion/offset-anchor-tra a/LayoutTests/TestExpectations_sec1
5072
webkit.org/b/233340 imported/w3c/web-platform-tests/css/motion/offset-anchor-transform-box-fill-box-002.html [ ImageOnlyFailure ]
5072
webkit.org/b/233340 imported/w3c/web-platform-tests/css/motion/offset-anchor-transform-box-fill-box-002.html [ ImageOnlyFailure ]
5073
webkit.org/b/233340 imported/w3c/web-platform-tests/css/motion/offset-anchor-transform-box-fill-box-003.html [ ImageOnlyFailure ]
5073
webkit.org/b/233340 imported/w3c/web-platform-tests/css/motion/offset-anchor-transform-box-fill-box-003.html [ ImageOnlyFailure ]
5074
5074
5075
# CSS motion path that depends on ray(), currently not implemented.
5075
# CSS motion path needs to implement contain.
5076
webkit.org/b/233344 imported/w3c/web-platform-tests/css/motion/offset-path-ray-001.html [ ImageOnlyFailure ]
5077
webkit.org/b/233344 imported/w3c/web-platform-tests/css/motion/offset-path-ray-002.html [ ImageOnlyFailure ]
5078
webkit.org/b/233344 imported/w3c/web-platform-tests/css/motion/offset-path-ray-003.html [ ImageOnlyFailure ]
5079
webkit.org/b/233344 imported/w3c/web-platform-tests/css/motion/offset-path-ray-004.html [ ImageOnlyFailure ]
5080
webkit.org/b/233344 imported/w3c/web-platform-tests/css/motion/offset-path-ray-005.html [ ImageOnlyFailure ]
5081
webkit.org/b/233344 imported/w3c/web-platform-tests/css/motion/offset-path-ray-006.html [ ImageOnlyFailure ]
5082
webkit.org/b/233344 imported/w3c/web-platform-tests/css/motion/offset-path-ray-007.html [ ImageOnlyFailure ]
5076
webkit.org/b/233344 imported/w3c/web-platform-tests/css/motion/offset-path-ray-007.html [ ImageOnlyFailure ]
5083
webkit.org/b/233344 imported/w3c/web-platform-tests/css/motion/offset-path-ray-008.html [ ImageOnlyFailure ]
5084
webkit.org/b/233344 imported/w3c/web-platform-tests/css/motion/offset-path-ray-009.html [ ImageOnlyFailure ]
5085
webkit.org/b/233344 imported/w3c/web-platform-tests/css/motion/offset-path-ray-contain-001.html [ ImageOnlyFailure ]
5077
webkit.org/b/233344 imported/w3c/web-platform-tests/css/motion/offset-path-ray-contain-001.html [ ImageOnlyFailure ]
5086
webkit.org/b/233344 imported/w3c/web-platform-tests/css/motion/offset-path-ray-contain-002.html [ ImageOnlyFailure ]
5078
webkit.org/b/233344 imported/w3c/web-platform-tests/css/motion/offset-path-ray-contain-002.html [ ImageOnlyFailure ]
5087
webkit.org/b/233344 imported/w3c/web-platform-tests/css/motion/offset-path-ray-contain-003.html [ ImageOnlyFailure ]
5079
webkit.org/b/233344 imported/w3c/web-platform-tests/css/motion/offset-path-ray-contain-003.html [ ImageOnlyFailure ]

Return to Bug 233344