REGRESSION (r154769): Wrong <title> taken as a tooltip for SVG element.
https://bugs.webkit.org/show_bug.cgi?id=139690.
Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2015-01-14
Reviewed by Daniel Bates.
Source/WebCore:
Before r154769, we were calling Traversal<SVGTitleElement>::firstWithin(), which returns
the first immediate SVGTitleElement child. In r154769, Traversal<SVGTitleElement>::firstWithin()
was replaced by descendantsOfType<SVGTitleElement> which returns all descendants SVGTitleElements.
Then we were returning the first element of these descendants, which may not be an immediate
child of the element, as the title of the SVGElement. This was the reason of this bug. The
fix is to use childrenOfType<SVGTitleElement>() instead, which returns the immediate SVGTitleElement
children of an SVGElement.
Also we were not following exactly the specs for the rootmost SVG element's title value.
According to the W3C specs, for stand-alone SVG documents only, the rootmost SVG element
should not return a title. But we were not returning a title for the rootmost SVG element
always. The fix is to return a empty title for the rootmost SVG element only if topDocument()
of the element isSVGDocument().
NOTE: The main SVG specs http://www.w3.org/TR/SVG/interact.html#hit-testing (W3C Recommendation
16 August 2011) and http://www.w3.org/TR/SVG/struct.html#DescriptionAndTitleElements (W3C
Recommendation 16 August 2011) do not say how the tooltip of an SVG element is calculated. But
the SVG tiny specs http://www.w3.org/TR/SVGTiny12/struct.html#uiTitleDescBehavior (W3C
Recommendation 22 December 2008) however explains well the tooltip calculation for the embedded
and the stand-alone SVG cases. And it seems this what we should rely on.
Test: svg/hittest/svg-standalone-tooltip.svg
svg/hittest/svg-embedded-tooltip.html
* WebCore.exp.in:
* rendering/HitTestResult.h:
Make HitTestResult::setInnerNode be WEBCORE_EXPORT
* svg/SVGElement.cpp:
(WebCore::SVGElement::title):
Replace descendantsOfType<SVGTitleElement>() by childrenOfType<SVGTitleElement>().
Fix the title value of the rootmost SVG element.
* testing/Internals.cpp:
(WebCore::Internals::toolTipFromElement):
* testing/Internals.h:
* testing/Internals.idl:
Add a new internal function toolTipFromElement() which returns the tooltip text for a
given element.
LayoutTests:
* svg/hittest/resources: Added.
* svg/hittest/resources/svg-tooltip.svg: Added.
Shared resources to be used by the tests.
* svg/hittest/resources/svg-tooltip.js: Added.
This code mimics the C++ tooltip calculation and compares its result with what the C++
code returns.
* svg/hittest/svg-embedded-tooltip-expected.txt: Added.
* svg/hittest/svg-embedded-tooltip.html: Added.
This test ensures that the tooltip text for SVG elements is calculated correctly when
the SVG is embedded in an HTML either through inline <svg> tag or through an <embed>
tag. In both cases, the rootmost SVG element should return the SVG document title.
* svg/hittest/svg-standalone-tooltip-expected.txt: Added.
* svg/hittest/svg-standalone-tooltip.svg: Added.
This test ensures that for stand-alone SVG documents, the tooltip text for SVG elements
is calculated correctly. In this case, the rootmost SVG element should not return a
title since the SVG document title will be displayed in the browser chrome.
Canonical link: https://commits.webkit.org/158450@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178459 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-01-14 23:50:57 +00:00
|
|
|
Verifying the SVG document:
|