Bug 93922

Summary: [Shadow DOM] Insertion points need resetStyleInheritance
Product: WebKit Reporter: Hajime Morrita <morrita>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, cmarcelo, dglazkov, macpherson, menard, ojan, tasak, webcomponents-bugzilla, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 97282    
Attachments:
Description Flags
WIP
none
Patch
none
Patch
none
Patch
none
Patch for landing none

Comment 1 Takashi Sakamoto 2012-08-27 03:24:04 PDT
Created attachment 160684 [details]
WIP
Comment 2 Takashi Sakamoto 2012-10-05 01:18:26 PDT
Created attachment 167277 [details]
Patch
Comment 3 Dimitri Glazkov (Google) 2012-10-05 11:19:36 PDT
Comment on attachment 167277 [details]
Patch

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

> Source/WebCore/ChangeLog:8
> +        Additional information of the change such as approach, rationale. Please add per-function descriptions below (OOPS!).

Oops :)

> Source/WebCore/css/StyleResolver.cpp:1232
> +    for ( ; insertionPoint; ) {
> +        InsertionPoint* youngerInsertionPoint = shadow->insertionPointFor(insertionPoint);
> +        if (!youngerInsertionPoint)
> +            break;
> +        insertionPoint = youngerInsertionPoint;
> +    }

This seems forced. Can you help me understand why the styles of the insertion point wouldn't implicitly have this information? Presumably, their styles have already been computed and they already have the correctly reset inheritance.

> LayoutTests/ChangeLog:8
> +        Additional information of the change such as approach, rationale. Please add per-function descriptions below (OOPS!).

Oops :)

> LayoutTests/fast/dom/shadow/insertion-point-resetStyleInheritance-expected.txt:10
> +FAIL window.getComputedStyle(document.getElementById("reset-style-inheritance-dynamic").firstChild).color should be rgb(0, 0, 0). Was rgb(255, 238, 238).

Why'd we fail this?
Comment 4 Takashi Sakamoto 2012-10-08 23:07:25 PDT
Created attachment 167694 [details]
Patch
Comment 5 Takashi Sakamoto 2012-10-08 23:17:22 PDT
Comment on attachment 167277 [details]
Patch

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

Thank you for reviewing.

>> Source/WebCore/ChangeLog:8
>> +        Additional information of the change such as approach, rationale. Please add per-function descriptions below (OOPS!).
> 
> Oops :)

I'm sorry. I forgot to update ChangeLogs. 
Done.

>> Source/WebCore/css/StyleResolver.cpp:1232
>> +    }
> 
> This seems forced. Can you help me understand why the styles of the insertion point wouldn't implicitly have this information? Presumably, their styles have already been computed and they already have the correctly reset inheritance.

I think, as insertion points don't have any renderers, insertion points don't have any render styles.
I know, it is possible for some element to have render styles without any renderers, i.e. implementing its own nonRendererRenderStyle method. 
However currently insertion points uses default nonRenderRenderStyle which just returns 0.
Talking about render styles, currently no information about reset-style-inheritance is added to render styles.

>> LayoutTests/ChangeLog:8
>> +        Additional information of the change such as approach, rationale. Please add per-function descriptions below (OOPS!).
> 
> Oops :)

Sorry. Done.

>> LayoutTests/fast/dom/shadow/insertion-point-resetStyleInheritance-expected.txt:10
>> +FAIL window.getComputedStyle(document.getElementById("reset-style-inheritance-dynamic").firstChild).color should be rgb(0, 0, 0). Was rgb(255, 238, 238).
> 
> Why'd we fail this?

I see. This is a bug of insertion-point-resetStyleInheritance.html. I fixed.
Comment 6 Darin Adler 2012-10-09 09:56:29 PDT
Comment on attachment 167694 [details]
Patch

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

> Source/WebCore/css/StyleResolver.cpp:1066
> +inline bool isResetStyleInheritance(NodeRenderingContext& context)

It makes no sense to say that a context “is reset style inheritance”. Instead we should ask if a context “should reset style inheritance” or “resets style inheritance”.

> Source/WebCore/html/shadow/InsertionPoint.h:81
> +    bool m_resetStyleInheritance : 1;

It’s unfortunate that the shadow specification gives a property a verb phrase name. The function resetStyleInheritance sounds like something that would perform a reset operation, not a getter that returns a boolean.

We don’t have to repeat that mistake in our data member. I would suggest the name “m_shouldResetStyleInheritance” or at least “m_resetsStyleInheritance”, and also suggest discussing changing the name in the spec.
Comment 7 Dimitri Glazkov (Google) 2012-10-09 10:04:21 PDT
(In reply to comment #6)
> (From update of attachment 167694 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=167694&action=review
> 
> > Source/WebCore/css/StyleResolver.cpp:1066
> > +inline bool isResetStyleInheritance(NodeRenderingContext& context)
> 
> It makes no sense to say that a context “is reset style inheritance”. Instead we should ask if a context “should reset style inheritance” or “resets style inheritance”.
> 
> > Source/WebCore/html/shadow/InsertionPoint.h:81
> > +    bool m_resetStyleInheritance : 1;
> 
> It’s unfortunate that the shadow specification gives a property a verb phrase name. The function resetStyleInheritance sounds like something that would perform a reset operation, not a getter that returns a boolean.

Hey, you have the spec editor's ears right here :)

It's a flag that, if set, will reset style inheritance. What would be a better name?

> 
> We don’t have to repeat that mistake in our data member. I would suggest the name “m_shouldResetStyleInheritance” or at least “m_resetsStyleInheritance”, and also suggest discussing changing the name in the spec.
Comment 8 Dimitri Glazkov (Google) 2012-10-09 10:09:07 PDT
(In reply to comment #7)

> It's a flag that, if set, will reset style inheritance. What would be a better name?

Here's the spec definition: http://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#dfn-reset-style-inheritance
Comment 9 Dimitri Glazkov (Google) 2012-10-09 10:29:07 PDT
Comment on attachment 167694 [details]
Patch

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

This is getting close. We need to get CSS WG to go ahead and spec display: contents, so that we can redefine <content>/<shadow> in terms of that primitive, instead of the hacking this into StyleResolver.

> Source/WebCore/html/shadow/HTMLShadowElement.idl:37
> +        attribute boolean resetStyleInheritance;

What about adding the attribute to HTML?

>> Source/WebCore/html/shadow/InsertionPoint.h:81
>> +    bool m_resetStyleInheritance : 1;
> 
> It’s unfortunate that the shadow specification gives a property a verb phrase name. The function resetStyleInheritance sounds like something that would perform a reset operation, not a getter that returns a boolean.
> 
> We don’t have to repeat that mistake in our data member. I would suggest the name “m_shouldResetStyleInheritance” or at least “m_resetsStyleInheritance”, and also suggest discussing changing the name in the spec.

For what it's worth, since it reflects the "reset-style-inheritance" attribute on HTMLContentElement/HTMLShadowElement, I think the name falls well into the current naming convention for attributes, such as "autoplay", "autofocus", "defer", etc. http://www.whatwg.org/specs/web-apps/current-work/multipage/section-index.html#attributes-1
Comment 10 Takashi Sakamoto 2012-10-09 21:47:27 PDT
Created attachment 167917 [details]
Patch
Comment 11 Takashi Sakamoto 2012-10-09 21:52:07 PDT
Comment on attachment 167694 [details]
Patch

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

Thank you for reviewing.

>>> Source/WebCore/css/StyleResolver.cpp:1066
>>> +inline bool isResetStyleInheritance(NodeRenderingContext& context)
>> 
>> It makes no sense to say that a context “is reset style inheritance”. Instead we should ask if a context “should reset style inheritance” or “resets style inheritance”.
> 
> Hey, you have the spec editor's ears right here :)
> 
> It's a flag that, if set, will reset style inheritance. What would be a better name?

As resetStyleInheritance in HTMLShadowElement.idl and HTMLContentElement.idl  is defined in Shadow DOM spec, we cannot change the code. Firstly we have to change the spec.
However talking about this inline function and m_resetStyleInhertiance in class InsertionPoint, we can change. So I renamed.

>> Source/WebCore/html/shadow/HTMLShadowElement.idl:37
>> +        attribute boolean resetStyleInheritance;
> 
> What about adding the attribute to HTML?

Would you mean moving resetStyleInheritance from HTMLShadow/ContentElement.idl to HTMLElement.idl?
If so, I talked with morrita@ and haraken@ about this and heard that IDL files allow such duplication and it is bad to add resetStyleInheritance to HTMLElement because users can see HTMLElement has resetStyleInheritance.
Comment 12 Dimitri Glazkov (Google) 2012-10-10 09:09:55 PDT
(In reply to comment #11)
> Would you mean moving resetStyleInheritance from HTMLShadow/ContentElement.idl to HTMLElement.idl?
> If so, I talked with morrita@ and haraken@ about this and heard that IDL files allow such duplication and it is bad to add resetStyleInheritance to HTMLElement because users can see HTMLElement has resetStyleInheritance.

No, no -- none of that. Why would we need to do something like this? :)

I was just talking about adding the HTML attribute "reset-style-inheritance" to HTMLAttributeNames.in and the corresponding plumbing to set/unset it. You can do this in the follow-up patch.
Comment 13 Takashi Sakamoto 2012-10-11 20:01:06 PDT
Created attachment 168339 [details]
Patch for landing
Comment 14 WebKit Review Bot 2012-10-11 20:51:36 PDT
Comment on attachment 168339 [details]
Patch for landing

Clearing flags on attachment: 168339

Committed r131136: <http://trac.webkit.org/changeset/131136>
Comment 15 WebKit Review Bot 2012-10-11 20:51:41 PDT
All reviewed patches have been landed.  Closing bug.