Bug 72440 - Removing <ul>, <li> inside shadow DOM triggers assertion in updateListMarkerNumbers
Summary: Removing <ul>, <li> inside shadow DOM triggers assertion in updateListMarkerN...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Hajime Morrita
URL:
Keywords:
Depends on:
Blocks: 59802
  Show dependency treegraph
 
Reported: 2011-11-15 16:23 PST by Dominic Cooney
Modified: 2012-02-27 16:18 PST (History)
8 users (show)

See Also:


Attachments
Repro layout test (1.65 KB, text/plain)
2011-12-07 17:29 PST, Dominic Cooney
no flags Details
Patch (3.80 KB, patch)
2011-12-21 03:35 PST, Shinya Kawanaka
no flags Details | Formatted Diff | Diff
Patch (4.07 KB, patch)
2012-02-26 21:53 PST, Hajime Morrita
rniwa: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dominic Cooney 2011-11-15 16:23:10 PST
ASSERTION FAILED: listNode && listNode->renderer()
/Volumes/HD2/chromium/src/third_party/WebKit/Source/WebCore/WebCore.gyp/../rendering/RenderListItem.cpp(431) : void WebCore::RenderListItem::updateListMarkerNumbers()
Comment 1 Hajime Morrita 2011-12-05 00:08:23 PST
Tree reforming pushing down this to 59802
Comment 2 Hajime Morrita 2011-12-05 03:34:01 PST
Hi Dominic,
Could you provide any repro for this?
I'm trying to reproduce this, but I have had none.

Thanks in advance,
Comment 3 Dominic Cooney 2011-12-06 01:51:07 PST
I will work on a repro.
Comment 4 Dominic Cooney 2011-12-07 17:29:59 PST
Created attachment 118291 [details]
Repro layout test
Comment 5 Shinya Kawanaka 2011-12-20 21:48:38 PST
I was investigating this.
UL seems destroyed twice...?
Comment 6 Shinya Kawanaka 2011-12-21 02:36:15 PST
(In reply to comment #5)
> I was investigating this.
> UL seems destroyed twice...?

RenderObjectChildList::destroyLeftoverChildren() destroys shadow objects, and it removes a renderer. The renderer of UL is deleted here, then LI is being deleted after that.
I'm not sure setting renderer 0 in the function is necessary.
Comment 7 Shinya Kawanaka 2011-12-21 03:35:58 PST
Created attachment 120166 [details]
Patch
Comment 8 Shinya Kawanaka 2011-12-21 03:36:39 PST
(In reply to comment #7)
> Created an attachment (id=120166) [details]
> Patch

I'm not sure this is the right way, but this patch fixes the issue.
Comment 9 Ryosuke Niwa 2012-01-30 12:03:15 PST
Comment on attachment 120166 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=120166&action=review

> Source/WebCore/rendering/RenderObjectChildList.cpp:62
> -            if (firstChild()->node())
> -                firstChild()->node()->setRenderer(0);
> +            Node* node = firstChild()->node();
>              firstChild()->destroy();
> +            if (node)
> +                node->setRenderer(0);

This doesn't look like a right fix.
Comment 10 Ryosuke Niwa 2012-01-30 12:04:05 PST
This is renderer related so should belong "Layout and Rendering".
Comment 11 Dimitri Glazkov (Google) 2012-02-08 09:22:39 PST
Comment on attachment 120166 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=120166&action=review

> Source/WebCore/ChangeLog:9
> +        This patch postpones removing renderers just after children are destroyed.

Can you explain a bit more as to why this is the right solution? Why does this behave differently in a shadow DOM subtree?
Comment 12 Shinya Kawanaka 2012-02-14 04:00:00 PST
(In reply to comment #11)
> (From update of attachment 120166 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=120166&action=review
> 
> > Source/WebCore/ChangeLog:9
> > +        This patch postpones removing renderers just after children are destroyed.
> 
> Can you explain a bit more as to why this is the right solution? Why does this behave differently in a shadow DOM subtree?

Actually that code was written when I was a (very) newbie of rendering tree...
Let me consider more right solution (or confirm this is the right solution) later.
Comment 13 Hajime Morrita 2012-02-26 21:53:53 PST
Created attachment 128949 [details]
Patch
Comment 14 Hajime Morrita 2012-02-26 21:56:30 PST
Dimitri, could you take a look?
It looks making code consistent just fixes the problem.
Comment 15 Ryosuke Niwa 2012-02-26 22:30:50 PST
Comment on attachment 128949 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=128949&action=review

> Source/WebCore/dom/Element.cpp:971
> +        for (Node* child = firstChild(); child; child = child->nextSibling()) {
> +            if (child->attached())
> +                child->detach();
> +        }

Can we call ContainerNode::detach() here instead?
Comment 16 Shinya Kawanaka 2012-02-26 23:25:50 PST
Comment on attachment 128949 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=128949&action=review

>> Source/WebCore/dom/Element.cpp:971
>> +        }
> 
> Can we call ContainerNode::detach() here instead?

I don't think so, because ContainerNode::detach() will call Node::detach().
Having ContainerNode::detachChildren() might be useful, because we have a lot of similar code.

> Source/WebCore/dom/Element.cpp:973
> +        shadowRootList()->detach();

Now that shadowRootList() has been renamed to shadowTree().
Comment 17 Ryosuke Niwa 2012-02-26 23:33:46 PST
Comment on attachment 128949 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=128949&action=review

Okay, I think I understand what's happening on my second look.

>>> Source/WebCore/dom/Element.cpp:971
>>> +        }
>> 
>> Can we call ContainerNode::detach() here instead?
> 
> I don't think so, because ContainerNode::detach() will call Node::detach().
> Having ContainerNode::detachChildren() might be useful, because we have a lot of similar code.

Oh I see what you're saying. Yeah, adding ContainerNode::detachChildren seems like a valuable refactoring of its own. I wonder it should be inlined or not.

> LayoutTests/fast/dom/shadow/shadow-ul-li.html:8
> +        return;  // needs ShadowRoot

Can we output some message about needing shadowRoot? Presumably, we should be able to modify test to be able to run without DRT once shadow DOM API becomes available to DOM?
Comment 18 Hajime Morrita 2012-02-27 01:34:26 PST
(In reply to comment #17)
> > LayoutTests/fast/dom/shadow/shadow-ul-li.html:8
> > +        return;  // needs ShadowRoot
> 
> Can we output some message about needing shadowRoot? Presumably, we should be able to modify test to be able to run without DRT once shadow DOM API becomes available to DOM?
Oops. This has been there when it was an attached repro. I'll remove it and add Skipped lines.

(In reply to comment #16)
> (From update of attachment 128949 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=128949&action=review
> > Source/WebCore/dom/Element.cpp:973
> > +        shadowRootList()->detach();
> 
> Now that shadowRootList() has been renamed to shadowTree().
God catch! I'll followup shortly.
Comment 19 Julien Chaffraix 2012-02-27 07:38:02 PST
It looks like the change was landed in http://trac.webkit.org/changeset/108980. Because the ChangeLog contained the wrong bug number, the final patch ended up in bug 79630. Morrita, could you update the ChangeLog bug URL and close this bug if I haven't missed anything?
Comment 20 Hajime Morrita 2012-02-27 16:18:35 PST
Good catch! Fixed http://trac.webkit.org/changeset/109037.
Thank you for pointing it out.