haikuwebkit/LayoutTests/svg/hittest/text-with-text-path.svg

34 lines
1.2 KiB
XML
Raw Permalink Normal View History

SVG: hit testing region for <text> elements is incorrect https://bugs.webkit.org/show_bug.cgi?id=150838 Patch by Antoine Quint <graouts@apple.com> on 2015-11-04 Reviewed by Dean Jackson. Source/WebCore: Hit testing for SVG <text> elements was using the same code as hit testing for CSS-rendered elements. However, in SVG, text elements should only hit test based on their character cells, not the rectangular bounds of the element, see section 16.6 of the SVG 1.1 specification: http://www.w3.org/TR/SVG11/interact.html#PointerEventsProperty So we now hit test each SVGTextFragment of each SVGInlineTextBox that is a child of an SVGRootInlineBox to correctly find whether the provided HitTestLocation is contained within a character cell. Tests: svg/hittest/text-dominant-baseline-hanging.svg svg/hittest/text-multiple-dx-values.svg svg/hittest/text-with-multiple-tspans.svg svg/hittest/text-with-text-node-and-content-elements.svg svg/hittest/text-with-text-node-only.svg svg/hittest/text-with-text-path.svg * rendering/RootInlineBox.h: Remove the final keyword since nodeAtPoint() may now be subclassed as implemented in SVGRootInlineBox. * rendering/svg/SVGInlineTextBox.cpp: (WebCore::SVGInlineTextBox::nodeAtPoint): Iterate over the SVGTextFragments to look for a fragment containing the provided HitTestLocation. * rendering/svg/SVGRootInlineBox.cpp: (WebCore::SVGRootInlineBox::nodeAtPoint): * rendering/svg/SVGRootInlineBox.h: Override RootInlineBox::nodeAtPoint() to delegate hit testing to the children inline boxes. LayoutTests: * svg/hittest/text-dominant-baseline-hanging-expected.svg: Added. * svg/hittest/text-dominant-baseline-hanging.svg: Added. * svg/hittest/text-multiple-dx-values-expected.svg: Added. * svg/hittest/text-multiple-dx-values.svg: Added. * svg/hittest/text-with-multiple-tspans-expected.svg: Added. * svg/hittest/text-with-multiple-tspans.svg: Added. * svg/hittest/text-with-text-node-and-content-elements-expected.svg: Added. * svg/hittest/text-with-text-node-and-content-elements.svg: Added. * svg/hittest/text-with-text-node-only-expected.svg: Added. * svg/hittest/text-with-text-node-only.svg: Added. * svg/hittest/text-with-text-path-expected.svg: Added. * svg/hittest/text-with-text-path.svg: Added. Canonical link: https://commits.webkit.org/169103@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@192020 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-11-04 10:40:17 +00:00
<svg width="500" height="150" viewBox="0 0 1000 300" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<rect id="background" width="100%" height="100%" fill="red" />
<text id="text">
<textPath xlink:href="#path">This is text on a path</textPath>
</text>
<defs>
<path id="path"
d="M 100 200
C 200 100 300 0 400 100
C 500 200 600 300 700 200
C 800 100 900 100 900 100" />
<style type="text/css">
<![CDATA[
@font-face {
font-family: Ahem;
src: url(../../resources/Ahem.ttf);
}
text {
font-family: Ahem;
font-size: 40px;
}
]]>
</style>
<script type="text/javascript">
<![CDATA[
// The point at 150,75 is contained within the text's bounding box
// but not in a painted part so the element should be the background.
document.elementFromPoint(150, 75).setAttribute("fill", "green");
document.getElementById("text").remove();
]]>
</script>
</defs>
</svg>