Bug 21892 - nested SVGs inside html table element fail to hit-test correctly
Summary: nested SVGs inside html table element fail to hit-test correctly
Status: RESOLVED DUPLICATE of bug 25432
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac (Intel) OS X 10.5
: P3 Normal
Assignee: Nobody
URL:
Keywords:
: 21890 21891 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-10-25 19:22 PDT by elliottcable
Modified: 2009-04-28 18:00 PDT (History)
3 users (show)

See Also:


Attachments
A simple test case for the problem (3.11 KB, application/xhtml+xml)
2008-10-25 19:24 PDT, elliottcable
no flags Details
A reduction which shows this is not a problem with raw SVGs (1.40 KB, image/svg+xml)
2008-10-27 13:26 PDT, Eric Seidel (no email)
no flags Details
simpler test case (hovering the blue square should turn it green) (587 bytes, application/xhtml+xml)
2008-10-27 13:39 PDT, Eric Seidel (no email)
no flags Details
Testcase using an actual table instead of display: table; (582 bytes, application/xhtml+xml)
2008-10-27 14:18 PDT, elliottcable
no flags Details
Add a couple table hit tests (3.60 KB, patch)
2009-04-28 17:50 PDT, Eric Seidel (no email)
simon.fraser: review-
Details | Formatted Diff | Diff
Add a couple table hit tests (3.62 KB, patch)
2009-04-28 17:57 PDT, Eric Seidel (no email)
simon.fraser: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description elliottcable 2008-10-25 19:22:14 PDT
When I have an SVG document embedded inside another SVG document, and then functionality that relies on the mouse (such as click events in JavaScript, or hover attributes on CSS), then none of this is triggered for the lower document when the space above it is fill: none.
Comment 1 elliottcable 2008-10-25 19:24:06 PDT
Created attachment 24679 [details]
A simple test case for the problem

This test case is pretty straight forward - it shows an example of an element with both a CSS :hover attribute, and a JavaScript onclick attribute. In FireFox, both 'work' as intended; in WebKit, neither does.
Comment 2 elliottcable 2008-10-25 19:25:14 PDT
*** Bug 21890 has been marked as a duplicate of this bug. ***
Comment 3 mitz 2008-10-25 19:26:53 PDT
Confirming based on difference from Firefox.
Comment 4 Mark Rowe (bdash) 2008-10-25 19:44:58 PDT
*** Bug 21891 has been marked as a duplicate of this bug. ***
Comment 5 Eric Seidel (no email) 2008-10-27 13:25:32 PDT
This is about embedding SVG content in HTML.  The mouse events seem to be off in that case.
Comment 6 Eric Seidel (no email) 2008-10-27 13:26:17 PDT
Created attachment 24690 [details]
A reduction which shows this is not a problem with raw SVGs
Comment 7 Eric Seidel (no email) 2008-10-27 13:39:45 PDT
Created attachment 24692 [details]
simpler test case (hovering the blue square should turn it green)
Comment 8 Eric Seidel (no email) 2008-10-27 13:51:39 PDT
Ok, the bug is that this code in RenderSVGContainer::nodeAtPoint

    if (!viewport().isEmpty()
        && style()->overflowX() == OHIDDEN
        && style()->overflowY() == OHIDDEN) {
        // Check if we need to do anything at all.
        IntRect overflowBox = overflowRect(false);
        overflowBox.move(_tx, _ty);
        AffineTransform ctm = RenderObject::absoluteTransform();
        ctm.translate(viewport().x(), viewport().y());
        double localX, localY;
        ctm.inverse().map(_x - _tx, _y - _ty, &localX, &localY);
        if (!overflowBox.contains((int)localX, (int)localY))
            return false;
    }

Is getting back an overflowBox with a height of -1.  I'm not sure why, but something is wrong with the overflowBox calculation here it seems.
Comment 9 Eric Seidel (no email) 2008-10-27 14:09:04 PDT
The inner <svg> (RenderSVGViewportContainer) seems to be asking the outer <td> (its containing block) for its height, that's returning a length object 0, which turns into -1 based on this calculation:

    // We need to stop here, since we don't want to increase the height of the table
    // artificially.  We're going to rely on this cell getting expanded to some new
    // height, and then when we lay out again we'll use the calculation below.
    if (isTableCell() && (h.isAuto() || h.isPercent()))
        return overrideSize() - (borderLeft() + borderRight() + paddingLeft() + paddingRight());

It seems that this "second pass" is not happening correctly for SVG content.  Maybe hyatt or beth have some clue what is supposed to be going on here.
Comment 10 Eric Seidel (no email) 2008-10-27 14:10:01 PDT
I think the inner <svg> (RenderSVGViewportContainer) shouldn't be asking its containing block for height, or if it does, that "containing block" should be the outer <svg>.  I think that's the part which is wrong here.
Comment 11 Eric Seidel (no email) 2008-10-27 14:11:27 PDT
We end up asking the containing block via:

void RenderSVGViewportContainer::layout()

which calls "calcBounds()":

void RenderSVGContainer::calcBounds()
{
    m_width = calcReplacedWidth();
    m_height = calcReplacedHeight();
    m_absoluteBounds = absoluteClippedOverflowRect();
}


int RenderSVGContainer::calcReplacedHeight() const
{
    switch (style()->height().type()) {
    case Fixed:
        return max(0, style()->height().value());
    case Percent:
    {
        RenderBlock* cb = containingBlock();
        return style()->height().calcValue(cb->availableHeight());
    }
    default:
        return 0;
    }
}

It seems that containing block call is likely wrong.
Comment 12 elliottcable 2008-10-27 14:18:19 PDT
Created attachment 24693 [details]
Testcase using an actual table instead of display: table;

Might be considered a more consice test case - display: table; isn't necessary, this happens with a real table element as well.
Comment 13 Eric Seidel (no email) 2008-10-27 14:21:38 PDT
I think is actually entirely an SVG problem.  SVG deals with "viewport elements", unfortunately we don't really expose such in the render tree.  The DOM tree can be asked for things like the nearestViewportElement() via SVGElement.  SVGLength knows how to look for the closest viewport element and resolve relative to that, but width and length are not defined as SVGLength elements in this context, they're pulled from the RenderStyle as Length objects.

So I think this is just yet another side-effect of having a separate SVGLength class, and not very well exposting the whole "viewport" system in the render tree.
Comment 14 Eric Seidel (no email) 2009-04-28 17:31:33 PDT
This looks to be fixed by http://trac.webkit.org/changeset/42960 bug 25432.

We should still land these as test cases in LayoutTests.
Comment 15 Eric Seidel (no email) 2009-04-28 17:50:53 PDT
Created attachment 29873 [details]
Add a couple table hit tests

 5 files changed, 95 insertions(+), 0 deletions(-)
Comment 16 Simon Fraser (smfr) 2009-04-28 17:52:56 PDT
Comment on attachment 29873 [details]
Add a couple table hit tests



> +  if (window.eventSender) {
> +    layoutTestController.dumpAsText();
> +    eventSender.mouseMoveTo(50, 50);
> +    eventSender.mouseDown();
> +    eventSender.mouseUp();

I think using document.elementFromPoint() is preferable, because then your test works outside of DRT.
Comment 17 Eric Seidel (no email) 2009-04-28 17:57:44 PDT
Created attachment 29874 [details]
Add a couple table hit tests

 5 files changed, 81 insertions(+), 0 deletions(-)
Comment 18 Eric Seidel (no email) 2009-04-28 18:00:51 PDT
Committing to http://svn.webkit.org/repository/webkit/trunk ...
	M	LayoutTests/ChangeLog
	A	LayoutTests/svg/hittest/svg-inside-display-table-expected.txt
	A	LayoutTests/svg/hittest/svg-inside-display-table.xhtml
	A	LayoutTests/svg/hittest/svg-inside-table-expected.txt
	A	LayoutTests/svg/hittest/svg-inside-table.xhtml
Committed r42977


*** This bug has been marked as a duplicate of 25432 ***