Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LBSE] Add support for 'foreignObject' elements #3664

Conversation

nikolaszimmermann
Copy link
Contributor

@nikolaszimmermann nikolaszimmermann commented Aug 25, 2022

5956331

[LBSE] Add support for 'foreignObject' elements
https://bugs.webkit.org/show_bug.cgi?id=243498

Reviewed by Rob Buis.

Rename RenderSVGForeignObject -> LegacyRenderSVGForeignObject.

Re-introduce RenderSVGForeignObject for LBSE. This marks the finish
of the renderer conversion: all non-resource related renderers have both a legacy
and LBSE Renderer class now: <foreignObject> was the last missing element in LBSE.

Covered by existing svg/foreignObject tests, which all pass now in LBSE (except
three that depends on clipping / masking / filters).

* LayoutTests/platform/mac-monterey-wk2-lbse-text/TestExpectations:
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/background-render-phase-expected.txt: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/body-background-expected.txt: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/clip-expected.txt: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/disallowed-svg-nodes-as-direct-children-expected.txt: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/fO-display-none-expected.txt: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/fO-display-none-with-relative-pos-content-expected.txt: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/fO-parent-display-changes-expected.txt: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/fO-parent-display-none-expected.txt: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/fO-parent-display-none-with-relative-pos-content-expected.txt: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/fO-parent-of-parent-display-none-expected.txt: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/fO-parent-of-parent-display-none-with-relative-pos-content-expected.txt: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/filter-expected.txt: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/mask-expected.txt: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/multiple-foreign-objects-expected.txt: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/no-crash-with-svg-content-in-html-document-expected.png: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/no-crash-with-svg-content-in-html-document-expected.txt: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/svg-document-as-direct-child-expected.txt: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/svg-document-in-html-document-expected.png: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/svg-document-in-html-document-expected.txt: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/text-tref-02-b-expected.png: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/text-tref-02-b-expected.txt: Added.
* LayoutTests/platform/mac/svg/foreignObject/fO-parent-display-changes-expected.txt:
* LayoutTests/svg/foreignObject/fO-parent-display-changes.svg:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/accessibility/AccessibilitySVGElement.cpp:
(WebCore::AccessibilitySVGElement::determineAccessibilityRole):
* Source/WebCore/rendering/RenderElement.cpp:
(WebCore::RenderElement::didAttachChild):
(WebCore::RenderElement::layerCreationAllowedForSubtree const):
* Source/WebCore/rendering/RenderElement.h:
(WebCore::RenderElement::canContainFixedPositionObjects const):
(WebCore::RenderElement::canContainAbsolutelyPositionedObjects const):
* Source/WebCore/rendering/RenderLayer.cpp:
(WebCore::RenderLayer::updateAncestorDependentState):
(WebCore::RenderLayer::paintForegroundForFragments):
* Source/WebCore/rendering/RenderLayerModelObject.cpp:
(WebCore::RenderLayerModelObject::shouldPaintSVGRenderer const):
* Source/WebCore/rendering/RenderLayerModelObject.h:
* Source/WebCore/rendering/RenderObject.h:
(WebCore::RenderObject::isLegacySVGForeignObject const):
(WebCore::RenderObject::isSVGForeignObjectOrLegacySVGForeignObject const):
* Source/WebCore/rendering/svg/LegacyRenderSVGForeignObject.cpp: Copied from Source/WebCore/rendering/svg/RenderSVGForeignObject.cpp.
(WebCore::LegacyRenderSVGForeignObject::LegacyRenderSVGForeignObject):
(WebCore::LegacyRenderSVGForeignObject::foreignObjectElement const):
(WebCore::LegacyRenderSVGForeignObject::paint):
(WebCore::LegacyRenderSVGForeignObject::localToParentTransform const):
(WebCore::LegacyRenderSVGForeignObject::updateLogicalWidth):
(WebCore::LegacyRenderSVGForeignObject::computeLogicalHeight const):
(WebCore::LegacyRenderSVGForeignObject::layout):
(WebCore::LegacyRenderSVGForeignObject::nodeAtFloatPoint):
* Source/WebCore/rendering/svg/LegacyRenderSVGForeignObject.h: Copied from Source/WebCore/rendering/svg/RenderSVGForeignObject.h.
* Source/WebCore/rendering/svg/LegacyRenderSVGModelObject.h:
* Source/WebCore/rendering/svg/RenderSVGBlock.cpp:
(WebCore::RenderSVGBlock::updateFromStyle):
(WebCore::RenderSVGBlock::mapLocalToContainer const):
(WebCore::RenderSVGBlock::pushMappingToContainer const):
* Source/WebCore/rendering/svg/RenderSVGBlock.h:
* Source/WebCore/rendering/svg/RenderSVGForeignObject.cpp:
(WebCore::RenderSVGForeignObject::paint):
(WebCore::RenderSVGForeignObject::updateLogicalWidth):
(WebCore::RenderSVGForeignObject::computeLogicalHeight const):
(WebCore::RenderSVGForeignObject::layout):
(WebCore::RenderSVGForeignObject::overflowClipRect const):
(WebCore::RenderSVGForeignObject::updateFromStyle):
(WebCore::RenderSVGForeignObject::applyTransform const):
(WebCore::RenderSVGForeignObject::localToParentTransform const): Deleted.
(WebCore::RenderSVGForeignObject::nodeAtFloatPoint): Deleted.
* Source/WebCore/rendering/svg/RenderSVGForeignObject.h:
* Source/WebCore/rendering/svg/RenderSVGModelObject.h:
* Source/WebCore/rendering/svg/RenderSVGRoot.cpp:
* Source/WebCore/rendering/svg/SVGContainerLayout.cpp:
* Source/WebCore/svg/SVGElement.cpp:
(WebCore::createSVGLayerAwareElementSet):
* Source/WebCore/svg/SVGForeignObjectElement.cpp:
(WebCore::SVGForeignObjectElement::createElementRenderer):
(WebCore::SVGForeignObjectElement::rendererIsNeeded):

Canonical link: https://commits.webkit.org/253816@main

ab9dc4c

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac   πŸ›  wpe βœ… πŸ›  πŸ§ͺ win
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim   πŸ›  mac-debug   πŸ›  gtk βœ… πŸ›  wincairo
βœ… πŸ§ͺ webkitperl   πŸ§ͺ ios-wk2 βœ… πŸ›  mac-AS-debug   πŸ§ͺ gtk-wk2
  πŸ§ͺ api-ios   πŸ§ͺ api-mac   πŸ§ͺ api-gtk
βœ… πŸ›  tv   πŸ§ͺ mac-wk1
βœ… πŸ›  tv-sim   πŸ§ͺ mac-wk2
βœ… πŸ›  πŸ§ͺ merge βœ… πŸ›  watch   πŸ§ͺ mac-AS-debug-wk2
βœ… πŸ›  watch-sim   πŸ§ͺ mac-wk2-stress

@nikolaszimmermann nikolaszimmermann self-assigned this Aug 25, 2022
@nikolaszimmermann nikolaszimmermann added SVG For bugs in the SVG implementation. WebKit Local Build labels Aug 25, 2022
@nikolaszimmermann nikolaszimmermann changed the title [LBSE] Add support for ' [LBSE] Add support for 'foreignObject' elements Aug 25, 2022
@nikolaszimmermann
Copy link
Contributor Author

This depends on PR #3532.

@nikolaszimmermann nikolaszimmermann removed the request for review from cdumez August 25, 2022 20:35
@nikolaszimmermann nikolaszimmermann force-pushed the eng/LBSE-Add-support-for-foreignObject-elements branch from 4a35780 to 406e515 Compare August 25, 2022 21:55
@nikolaszimmermann
Copy link
Contributor Author

PR #3532 was merged, this is ready to review now.

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Aug 26, 2022
Copy link
Contributor

@rwlbuis rwlbuis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like the image patch, this is easier to review with two separate patches.

@@ -114,8 +119,7 @@ bool SVGForeignObjectElement::rendererIsNeeded(const RenderStyle& style)
// parentOrShadowHostElement() instead.
RefPtr ancestor = parentElement();
while (ancestor && ancestor->isSVGElement()) {
// FIXME: [LBSE] Upstream foreignObject support.
if (ancestor->renderer() && ancestor->renderer()->isLegacySVGHiddenContainer())
if (ancestor->renderer() && (ancestor->renderer()->isSVGHiddenContainer() || ancestor->renderer()->isLegacySVGHiddenContainer()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My as well introduce a isSVGHiddenContainerOrLegacySVGHiddenContainer method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, however it would only be this place using it -- I only introduced these helpers so far if there is more than one callsite that needs it.

@rwlbuis
Copy link
Contributor

rwlbuis commented Aug 26, 2022

Like the image patch, this is easier to review with two separate patches.

Never mind, still learning github...

Copy link
Contributor

@rwlbuis rwlbuis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@nikolaszimmermann nikolaszimmermann removed the merging-blocked Applied to prevent a change from being merged label Aug 26, 2022
@nikolaszimmermann nikolaszimmermann force-pushed the eng/LBSE-Add-support-for-foreignObject-elements branch from 406e515 to ab9dc4c Compare August 26, 2022 13:20
@nikolaszimmermann nikolaszimmermann added the merge-queue Applied to send a pull request to merge-queue label Aug 26, 2022
https://bugs.webkit.org/show_bug.cgi?id=243498

Reviewed by Rob Buis.

Rename RenderSVGForeignObject -> LegacyRenderSVGForeignObject.

Re-introduce RenderSVGForeignObject for LBSE. This marks the finish
of the renderer conversion: all non-resource related renderers have both a legacy
and LBSE Renderer class now: <foreignObject> was the last missing element in LBSE.

Covered by existing svg/foreignObject tests, which all pass now in LBSE (except
three that depends on clipping / masking / filters).

* LayoutTests/platform/mac-monterey-wk2-lbse-text/TestExpectations:
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/background-render-phase-expected.txt: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/body-background-expected.txt: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/clip-expected.txt: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/disallowed-svg-nodes-as-direct-children-expected.txt: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/fO-display-none-expected.txt: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/fO-display-none-with-relative-pos-content-expected.txt: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/fO-parent-display-changes-expected.txt: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/fO-parent-display-none-expected.txt: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/fO-parent-display-none-with-relative-pos-content-expected.txt: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/fO-parent-of-parent-display-none-expected.txt: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/fO-parent-of-parent-display-none-with-relative-pos-content-expected.txt: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/filter-expected.txt: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/mask-expected.txt: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/multiple-foreign-objects-expected.txt: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/no-crash-with-svg-content-in-html-document-expected.png: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/no-crash-with-svg-content-in-html-document-expected.txt: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/svg-document-as-direct-child-expected.txt: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/svg-document-in-html-document-expected.png: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/svg-document-in-html-document-expected.txt: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/text-tref-02-b-expected.png: Added.
* LayoutTests/platform/mac-monterey-wk2-lbse-text/svg/foreignObject/text-tref-02-b-expected.txt: Added.
* LayoutTests/platform/mac/svg/foreignObject/fO-parent-display-changes-expected.txt:
* LayoutTests/svg/foreignObject/fO-parent-display-changes.svg:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/accessibility/AccessibilitySVGElement.cpp:
(WebCore::AccessibilitySVGElement::determineAccessibilityRole):
* Source/WebCore/rendering/RenderElement.cpp:
(WebCore::RenderElement::didAttachChild):
(WebCore::RenderElement::layerCreationAllowedForSubtree const):
* Source/WebCore/rendering/RenderElement.h:
(WebCore::RenderElement::canContainFixedPositionObjects const):
(WebCore::RenderElement::canContainAbsolutelyPositionedObjects const):
* Source/WebCore/rendering/RenderLayer.cpp:
(WebCore::RenderLayer::updateAncestorDependentState):
(WebCore::RenderLayer::paintForegroundForFragments):
* Source/WebCore/rendering/RenderLayerModelObject.cpp:
(WebCore::RenderLayerModelObject::shouldPaintSVGRenderer const):
* Source/WebCore/rendering/RenderLayerModelObject.h:
* Source/WebCore/rendering/RenderObject.h:
(WebCore::RenderObject::isLegacySVGForeignObject const):
(WebCore::RenderObject::isSVGForeignObjectOrLegacySVGForeignObject const):
* Source/WebCore/rendering/svg/LegacyRenderSVGForeignObject.cpp: Copied from Source/WebCore/rendering/svg/RenderSVGForeignObject.cpp.
(WebCore::LegacyRenderSVGForeignObject::LegacyRenderSVGForeignObject):
(WebCore::LegacyRenderSVGForeignObject::foreignObjectElement const):
(WebCore::LegacyRenderSVGForeignObject::paint):
(WebCore::LegacyRenderSVGForeignObject::localToParentTransform const):
(WebCore::LegacyRenderSVGForeignObject::updateLogicalWidth):
(WebCore::LegacyRenderSVGForeignObject::computeLogicalHeight const):
(WebCore::LegacyRenderSVGForeignObject::layout):
(WebCore::LegacyRenderSVGForeignObject::nodeAtFloatPoint):
* Source/WebCore/rendering/svg/LegacyRenderSVGForeignObject.h: Copied from Source/WebCore/rendering/svg/RenderSVGForeignObject.h.
* Source/WebCore/rendering/svg/LegacyRenderSVGModelObject.h:
* Source/WebCore/rendering/svg/RenderSVGBlock.cpp:
(WebCore::RenderSVGBlock::updateFromStyle):
(WebCore::RenderSVGBlock::mapLocalToContainer const):
(WebCore::RenderSVGBlock::pushMappingToContainer const):
* Source/WebCore/rendering/svg/RenderSVGBlock.h:
* Source/WebCore/rendering/svg/RenderSVGForeignObject.cpp:
(WebCore::RenderSVGForeignObject::paint):
(WebCore::RenderSVGForeignObject::updateLogicalWidth):
(WebCore::RenderSVGForeignObject::computeLogicalHeight const):
(WebCore::RenderSVGForeignObject::layout):
(WebCore::RenderSVGForeignObject::overflowClipRect const):
(WebCore::RenderSVGForeignObject::updateFromStyle):
(WebCore::RenderSVGForeignObject::applyTransform const):
(WebCore::RenderSVGForeignObject::localToParentTransform const): Deleted.
(WebCore::RenderSVGForeignObject::nodeAtFloatPoint): Deleted.
* Source/WebCore/rendering/svg/RenderSVGForeignObject.h:
* Source/WebCore/rendering/svg/RenderSVGModelObject.h:
* Source/WebCore/rendering/svg/RenderSVGRoot.cpp:
* Source/WebCore/rendering/svg/SVGContainerLayout.cpp:
* Source/WebCore/svg/SVGElement.cpp:
(WebCore::createSVGLayerAwareElementSet):
* Source/WebCore/svg/SVGForeignObjectElement.cpp:
(WebCore::SVGForeignObjectElement::createElementRenderer):
(WebCore::SVGForeignObjectElement::rendererIsNeeded):

Canonical link: https://commits.webkit.org/253816@main
@webkit-early-warning-system webkit-early-warning-system force-pushed the eng/LBSE-Add-support-for-foreignObject-elements branch from ab9dc4c to 5956331 Compare August 26, 2022 14:47
@webkit-commit-queue
Copy link
Collaborator

Committed 253816@main (5956331): https://commits.webkit.org/253816@main

Reviewed commits have been landed. Closing PR #3664 and removing active labels.

@webkit-early-warning-system webkit-early-warning-system merged commit 5956331 into WebKit:main Aug 26, 2022
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Aug 26, 2022
@nikolaszimmermann nikolaszimmermann deleted the eng/LBSE-Add-support-for-foreignObject-elements branch August 29, 2022 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SVG For bugs in the SVG implementation.
Projects
None yet
5 participants