Bug 100922 - [Shadow] ShadowRoot should know the existence of element having ElementShadow.
Summary: [Shadow] ShadowRoot should know the existence of element having ElementShadow.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Shinya Kawanaka
URL:
Keywords:
Depends on:
Blocks: 100451
  Show dependency treegraph
 
Reported: 2012-10-31 23:59 PDT by Shinya Kawanaka
Modified: 2012-11-06 02:15 PST (History)
3 users (show)

See Also:


Attachments
Patch (17.18 KB, patch)
2012-11-02 01:40 PDT, Shinya Kawanaka
no flags Details | Formatted Diff | Diff
Patch (17.12 KB, patch)
2012-11-04 17:47 PST, Shinya Kawanaka
no flags Details | Formatted Diff | Diff
Patch (16.73 KB, patch)
2012-11-06 00:46 PST, Shinya Kawanaka
no flags Details | Formatted Diff | Diff
Patch (16.13 KB, patch)
2012-11-06 01:23 PST, Shinya Kawanaka
no flags Details | Formatted Diff | Diff
Patch for landing (16.14 KB, patch)
2012-11-06 01:31 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-10-31 23:59:22 PDT
This is similar to https://bugs.webkit.org/show_bug.cgi?id=100921
We would like to know the existence of elements having shadow when we check the necessity of distribution invalidation.
Comment 1 Shinya Kawanaka 2012-11-01 21:59:59 PDT
The patterns where the number of elements having shadow may be changed are:

(1) An element having shadow is inserted.
(2) An element having shadow is removed.
(3) ShadowRoot is added to an element
(4) ShadowRoot is removed from an element.
Comment 2 Shinya Kawanaka 2012-11-02 01:05:33 PDT
Actually we don't have to consider (4) case, since there is no API to remove it.
Comment 3 Shinya Kawanaka 2012-11-02 01:40:29 PDT
Created attachment 172005 [details]
Patch
Comment 4 Shinya Kawanaka 2012-11-02 01:41:09 PDT
This patch will definitely be conflicted with a patch for Bug 100921.
Comment 5 Shinya Kawanaka 2012-11-04 17:47:51 PST
Created attachment 172250 [details]
Patch
Comment 6 Hajime Morrita 2012-11-04 23:13:29 PST
Comment on attachment 172250 [details]
Patch

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

> Source/WebCore/dom/Element.cpp:1061
> +    if (ElementShadow* elementShadow = shadow()) {

ShadowRoot also has insertedInto(). Can we move this to there?
insertedInto() is relatively hot function and better to keep slim if possible.
Same can be said for removedFrom().
Comment 7 Shinya Kawanaka 2012-11-04 23:19:44 PST
Comment on attachment 172250 [details]
Patch

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

>> Source/WebCore/dom/Element.cpp:1061
>> +    if (ElementShadow* elementShadow = shadow()) {
> 
> ShadowRoot also has insertedInto(). Can we move this to there?
> insertedInto() is relatively hot function and better to keep slim if possible.
> Same can be said for removedFrom().

OK.
Comment 8 Shinya Kawanaka 2012-11-05 20:04:28 PST
The number of calling ShadowRoot::insertedInto and ShadowRoot::removedFrom does not seem balanced correctly... Maybe we have another bug around there?
Comment 9 Shinya Kawanaka 2012-11-06 00:46:06 PST
Created attachment 172508 [details]
Patch
Comment 10 Hajime Morrita 2012-11-06 01:02:04 PST
Comment on attachment 172508 [details]
Patch

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

> Source/WebCore/dom/ShadowRoot.cpp:263
> +    // Note that host element might be being destroyed here.

What is the point of this comment?

> Source/WebCore/dom/ShadowRoot.h:102
> +    void unregisterElementHavingShadow() { --m_numberOfElementsHavingShadow; }

Let's ASSERT() the count cannot be zero.

> Source/WebCore/dom/ShadowRoot.h:134
> +    size_t m_numberOfElementsHavingShadow;

This is basically a count of ElementShadow, is that right?
If so, I'd prefer more brief name. "ElementHavingShadow" sound a bit cryptic.
Comment 11 Shinya Kawanaka 2012-11-06 01:23:28 PST
Created attachment 172514 [details]
Patch
Comment 12 Shinya Kawanaka 2012-11-06 01:24:26 PST
(In reply to comment #10)
> (From update of attachment 172508 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=172508&action=review
> 
> > Source/WebCore/dom/ShadowRoot.cpp:263
> > +    // Note that host element might be being destroyed here.
> 
> What is the point of this comment?

Removed.

> 
> > Source/WebCore/dom/ShadowRoot.h:102
> > +    void unregisterElementHavingShadow() { --m_numberOfElementsHavingShadow; }
> 
> Let's ASSERT() the count cannot be zero.

Added.

> 
> > Source/WebCore/dom/ShadowRoot.h:134
> > +    size_t m_numberOfElementsHavingShadow;
> 
> This is basically a count of ElementShadow, is that right?
> If so, I'd prefer more brief name. "ElementHavingShadow" sound a bit cryptic.

Yes. I used m_numberOfElementShadow... I couldn't come up with better name...
Comment 13 Hajime Morrita 2012-11-06 01:26:16 PST
Comment on attachment 172514 [details]
Patch

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

> Source/WebCore/testing/Internals.cpp:332
> +    ec = INVALID_ACCESS_ERR;

Let's take check-error-then do happy path pattern.
Pushing error path to late is unusual thus confusing.
Comment 14 Shinya Kawanaka 2012-11-06 01:31:18 PST
Created attachment 172518 [details]
Patch for landing
Comment 15 WebKit Review Bot 2012-11-06 02:15:32 PST
Comment on attachment 172518 [details]
Patch for landing

Clearing flags on attachment: 172518

Committed r133575: <http://trac.webkit.org/changeset/133575>
Comment 16 WebKit Review Bot 2012-11-06 02:15:36 PST
All reviewed patches have been landed.  Closing bug.