Bug 76262 - StyleRecalc should occur when shadow root exists and light children are changed.
Summary: StyleRecalc should occur when shadow root exists and light children are changed.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on: 75306 77322
Blocks: 75301 76611 77584
  Show dependency treegraph
 
Reported: 2012-01-13 02:33 PST by Shinya Kawanaka
Modified: 2012-02-02 18:47 PST (History)
5 users (show)

See Also:


Attachments
Patch (15.56 KB, patch)
2012-01-19 05:29 PST, Shinya Kawanaka
no flags Details | Formatted Diff | Diff
Test Patch (19.05 KB, patch)
2012-01-30 18:09 PST, Shinya Kawanaka
no flags Details | Formatted Diff | Diff
Patch (19.03 KB, patch)
2012-02-01 00:00 PST, Shinya Kawanaka
no flags Details | Formatted Diff | Diff
Patch (19.86 KB, patch)
2012-02-01 16:50 PST, Shinya Kawanaka
no flags Details | Formatted Diff | Diff
Patch for landing (19.87 KB, patch)
2012-02-01 19:24 PST, Shinya Kawanaka
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Shinya Kawanaka 2012-01-13 02:33:12 PST
To support dynamic ShadowContentElement fallback, style recalculation should occur when children of node which has shadow tree and content element are changed.
To achieve it, maybe we should add some code into Element::childrenChanged.
We should measure the performance when adding code.
Comment 1 Shinya Kawanaka 2012-01-13 03:09:18 PST
This is a result before adding if-statement.
http://dromaeo.com/?id=160729
Comment 2 Shinya Kawanaka 2012-01-13 03:14:35 PST
This is after adding if-statement. About 5% performance degrade?
http://dromaeo.com/?id=160730
Comment 3 Shinya Kawanaka 2012-01-13 03:45:01 PST
I've tried a few times again.

Before adding if-statement
http://dromaeo.com/?id=160732
http://dromaeo.com/?id=160733
http://dromaeo.com/?id=160734

Then, I've added 
if (hasRareDate() && shadowRoot())
    setNeedsStyleRecalc()
in the last of Element::childrenChanged.

After adding it,
http://dromaeo.com/?id=160735
http://dromaeo.com/?id=160736
http://dromaeo.com/?id=160738

It seems adding if-statement is not harmful to performance.
Comment 4 Dimitri Glazkov (Google) 2012-01-13 07:40:20 PST
Can haz patch? :)
Comment 5 Shinya Kawanaka 2012-01-19 05:29:00 PST
Created attachment 123113 [details]
Patch
Comment 6 WebKit Review Bot 2012-01-19 06:39:09 PST
Comment on attachment 123113 [details]
Patch

Attachment 123113 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/11299091

New failing tests:
fast/html/details-replace-text.html
fast/html/details-remove-child-2.html
fast/html/details-remove-child-1.html
Comment 7 Dimitri Glazkov (Google) 2012-01-19 09:32:37 PST
Why are details tests sad?
Comment 8 Shinya Kawanaka 2012-01-19 18:27:10 PST
(In reply to comment #7)
> Why are details tests sad?

Hmm...
Let me check it.
Comment 9 Shinya Kawanaka 2012-01-19 23:47:36 PST
(In reply to comment #8)
> (In reply to comment #7)
> > Why are details tests sad?
> 
> Hmm...
> Let me check it.

Some unnecessary RenderBlock exists in DETAILS block.
I'm thinking we should reconsider the attach order of light children when a shadow tree exists (Bug 76611) to fix it...
Comment 10 Hajime Morrita 2012-01-19 23:59:55 PST
(In reply to comment #9)
> Some unnecessary RenderBlock exists in DETAILS block.
> I'm thinking we should reconsider the attach order of light children when a shadow tree exists (Bug 76611) to fix it...
Yeah, let's fix Bug 76611 before this one.
Comment 11 Shinya Kawanaka 2012-01-25 23:29:44 PST
I was investigating why anonymous RenderBlock was created today.

Let's consider the following. 
<div>foo<div>bar</div></div>

This will create renderer tree like the following:
RenderBlock
    RenderBlock (anonymous)
         RenderText                    <-- (1)
    RenderBlock {DIV}               <-- (2)
         RenderText

When (1) is removed, the parent RenderBlock is not deleted. If (2) is removed, the previous anonymous RenderBlock is deleted.

Also, let's consider the following.
<div>foo<div>bar</div>baz</div>

RenderBlock
    RenderBlock (anonymous)
         RenderText
    RenderBlock {DIV}
         RenderText
    RenderBlock (anonymous)
         RenderText

When foo and baz are removed, these anonymous RenderBlock won't be removed. When DIV is deleted, 
those anonymous RenderBlocks are merged, then removed.
Comment 12 Shinya Kawanaka 2012-01-25 23:31:39 PST
I'm now thinking left anonymous RenderBlock are not harmful at all...

Can I change the test result (and create a bug to delete empty anonymous render block)?
Or should I think another way?
Comment 13 Shinya Kawanaka 2012-01-26 01:50:02 PST
(In reply to comment #12)
> I'm now thinking left anonymous RenderBlock are not harmful at all...
> 
> Can I change the test result (and create a bug to delete empty anonymous render block)?
> Or should I think another way?

Hmm... I'm now thinking when detaching SUMMARY, anonymous RenderBlock for DETAILS should be deleted. If SUMMARY and DETAILS are DIV, anonymous RenderBlock is deleted.
Comment 14 Dimitri Glazkov (Google) 2012-01-26 09:18:41 PST
(In reply to comment #2)
> This is after adding if-statement. About 5% performance degrade?
> http://dromaeo.com/?id=160730

I think you need a bit more investigation here. I don't understand how DOM attributes test could be even impacted by this.
Comment 15 Shinya Kawanaka 2012-01-30 03:56:31 PST
(In reply to comment #14)
> (In reply to comment #2)
> > This is after adding if-statement. About 5% performance degrade?
> > http://dromaeo.com/?id=160730
> 
> I think you need a bit more investigation here. I don't understand how DOM attributes test could be even impacted by this.

OKay...
(In reply to comment #14)
> (In reply to comment #2)
> > This is after adding if-statement. About 5% performance degrade?
> > http://dromaeo.com/?id=160730
> 
> I think you need a bit more investigation here. I don't understand how DOM attributes test could be even impacted by this.

I agree that DOM attribute test is not relevant to this.
But I think DOM modification test is relevant, because childrenChanged is called when children are changed.

From the test result (especially from appendChild test and insertBefore test), I don't think my patch affect performance so much.
Comment 16 Shinya Kawanaka 2012-01-30 18:09:05 PST
Created attachment 124647 [details]
Test Patch
Comment 17 Shinya Kawanaka 2012-01-30 18:45:30 PST
(In reply to comment #16)
> Created an attachment (id=124647) [details]
> Test Patch

Ah, actually this patch depends on Bug 76611...
Comment 18 WebKit Review Bot 2012-01-30 19:15:34 PST
Comment on attachment 124647 [details]
Test Patch

Attachment 124647 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/11150498

New failing tests:
fast/html/details-replace-text.html
fast/html/details-remove-child-2.html
fast/html/details-remove-child-1.html
Comment 19 Shinya Kawanaka 2012-02-01 00:00:44 PST
Created attachment 124891 [details]
Patch
Comment 20 Shinya Kawanaka 2012-02-01 00:01:40 PST
(In reply to comment #19)
> Created an attachment (id=124891) [details]
> Patch

Now Bug 76611 was fixed, this patch won't make tests sad...hopefully.
Comment 21 Hajime Morrita 2012-02-01 01:35:06 PST
Comment on attachment 124891 [details]
Patch

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

> Source/WebCore/ChangeLog:8
> +        Set style recalculation flag when a child element is changed.

Could you elaborate why we need this change?

> Source/WebCore/dom/Element.cpp:1371
> +        setNeedsStyleRecalc();

This could be shadowRoot->hostChildrenChanged().
Comment 22 Shinya Kawanaka 2012-02-01 16:50:12 PST
Created attachment 125045 [details]
Patch
Comment 23 Hajime Morrita 2012-02-01 18:43:04 PST
Comment on attachment 125045 [details]
Patch

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

> Source/WebCore/ChangeLog:9
> +        So we have to recalculate content element again.

"recalculate content element" sounds strange. What we need to recompute is inclusion of that, right?
Comment 24 Shinya Kawanaka 2012-02-01 19:24:08 PST
Created attachment 125064 [details]
Patch for landing
Comment 25 WebKit Review Bot 2012-02-02 18:47:21 PST
Comment on attachment 125064 [details]
Patch for landing

Clearing flags on attachment: 125064

Committed r106613: <http://trac.webkit.org/changeset/106613>
Comment 26 WebKit Review Bot 2012-02-02 18:47:27 PST
All reviewed patches have been landed.  Closing bug.