Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General tidying, clearer adoptedStyleSheets, remove document restriction #60

Merged
merged 3 commits into from
Oct 26, 2018

Conversation

rakina
Copy link
Member

@rakina rakina commented Oct 24, 2018

Trying to resolve a lot of issues at once:

General tidying:

Clearer adoptedStyleSheets

Remove document restriction

Since other open issues still need discussion, I'm only resolving issues mentioned above for now.


Preview | Diff

@rakina rakina requested a review from tabatkins October 24, 2018 14:51
@rakina
Copy link
Member Author

rakina commented Oct 24, 2018

FYI @domenic and @bzbarsky.

Copy link
Contributor

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great start! Some cleanups possible.

index.bs Outdated
[NewObject] CSSStyleSheet createCSSStyleSheetSync(DOMString text, optional CSSStyleSheetInit options);
[NewObject] CSSStyleSheet createEmptyCSSStyleSheet(optional CSSStyleSheetInit options);
[NewObject] Promise<CSSStyleSheet> createCSSStyleSheet(optional DOMString text, optional CSSStyleSheetInit options);
[NewObject] CSSStyleSheet createCSSStyleSheetSync(optional DOMString text, optional CSSStyleSheetInit options);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably want = "" on both text params

index.bs Outdated
7. Wait for loading of <a spec=css-cascade-4>@import</a> rules in <var>sheet</var>.
* If any of them resulted in a resource with a <a spec=html>Content-Type metadata</a> of anything other than <code>text/css</code>, reject <var>promise</var> with a {{TypeError}}.
* If any of them failed to load, reject <var>promise</var> with reason set to {{DOMException}} with the message "Loading import rules failed".
7. Wait for loading of <a spec=css-cascade-4>@import</a> rules in <var>sheet</var> and any nested loads from those rules in parallel.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'll be more conventional if you put "In parallel," first, before "wait".

index.bs Outdated
7. Wait for loading of <a spec=css-cascade-4>@import</a> rules in <var>sheet</var>.
* If any of them resulted in a resource with a <a spec=html>Content-Type metadata</a> of anything other than <code>text/css</code>, reject <var>promise</var> with a {{TypeError}}.
* If any of them failed to load, reject <var>promise</var> with reason set to {{DOMException}} with the message "Loading import rules failed".
7. Wait for loading of <a spec=css-cascade-4>@import</a> rules in <var>sheet</var> and any nested loads from those rules in parallel.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"nested loads" is a bit confusing. "nested @imports" would be more precise.

index.bs Outdated
@@ -144,6 +128,17 @@ partial interface DocumentOrShadowRoot {
</dd>
</dl>

Applying Styles In All Contexts {#styles-in-all-contexts}
===================
Every {{DocumentOrShadowRoot}} has adopted stylesheets (of type FrozenArray&lt;CSSStyleSheet>).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use <dfn> around "adopted stylesheets" here, then when referring to it later, say [=adopted stylesheets=] to link to it.

index.bs Outdated
* If any of them resulted in a resource with a <a spec=html>Content-Type metadata</a> of anything other than <code>text/css</code>, reject <var>promise</var> with a {{TypeError}}.
* If any of them failed to load, reject <var>promise</var> with reason set to {{DOMException}} with the message "Loading import rules failed".
7. Wait for loading of <a spec=css-cascade-4>@import</a> rules in <var>sheet</var> and any nested loads from those rules in parallel.
* If any of them failed to load or resulted in a resource with a <a spec=html>Content-Type metadata</a> of anything other than <code>text/css</code>, reject <var>promise</var> with reason set to {{DOMException}} with name {{NotAllowedError}}.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and elsewhere, you can use the more conventional "{{NotAllowedError}}" {{DOMException}}.

index.bs Outdated
@@ -144,6 +128,17 @@ partial interface DocumentOrShadowRoot {
</dd>
</dl>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dl here has a statement of fact, not a normative requirement. It's also at the wrong level, talking about the attribute instead of the "adopted stylesheets" concept. I would suggest deleting it, and instead putting the <dfn> around the getter.

index.bs Outdated
@@ -144,6 +128,17 @@ partial interface DocumentOrShadowRoot {
</dd>
</dl>

Applying Styles In All Contexts {#styles-in-all-contexts}
===================
Every {{DocumentOrShadowRoot}} has adopted stylesheets (of type FrozenArray&lt;CSSStyleSheet>).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is where you should add a normative requirement about how to treat the adopted stylesheets. For example

For documents, the user agent must include all style sheets in the {{Document}}'s
[=adopted stylesheets=] inside its <a spec=cssom-1>document CSS style sheets</a> collection,
ordered after all the other style sheets (i.e. those derived from {{Document/styleSheets}}).

Also, we need some statement for how this affects shadow roots?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this but combined it with shadow root also. I don't know where "shadow stylesheets" is defined though..

index.bs Outdated
1. Let <var>adopted</var> be the result of converting the given value to a FrozenArray&lt;CSSStyleSheet>
2. If any entry of <var>adopted</var> has no associated document (e.g. it's not made by factory methods to construct stylesheets), throw a {{DOMException}} with name {{NotAllowedError}}.
3. Set this {{DocumentOrShadowRoot}}'s adopted stylesheets to <var>adopted</var>.
4. Now the adopted stylesheets are part of the {{DocumentOrShadowRoot}}'s style sheets and are ordered after the style sheets in {{Document/styleSheets}}, and will be considered in style calcualtion of the {{DocumentOrShadowRoot}}.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can omit this step if we add the above normative requirement.

Copy link
Contributor

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with nits/one more substantial fix for the collection.

index.bs Outdated
@@ -90,60 +105,40 @@ dictionary CSSStyleSheetInit {
assign the list as <var>sheet’s</var> CSS rules;
otherwise,
set <var>sheet’s</var> CSS rules to an empty list.
6. If <var>sheet</var> contains one or more <a spec=css-cascade-4>@import</a> rules, throw a {{SyntaxError}}.
6. If <var>sheet</var> contains one or more <a spec=css-cascade-4>@import</a> rules, throw a {{NotAllowedError}} {{DOMException}}.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The convention is quotes around {{NotAllowedError}}

index.bs Outdated
<dl>
<dt><dfn attribute for=DocumentOrShadowRoot lt="adoptedStyleSheets">adoptedStyleSheets</dfn></dt>
<dd>
Style sheets assigned to this attribute are part of the <a spec=cssom-1>document CSS style sheets</a>.
They are ordered after the stylesheets in {{Document/styleSheets}}.
On getting, {{adoptedStyleSheets}} returns this DocumentOrShadowRoot's [=adopted stylesheets=].
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{{DocumentOrShadowRoot}}

index.bs Outdated

1. Let <var>adopted</var> be the result of converting the given value to a FrozenArray&lt;CSSStyleSheet>
2. If any entry of <var>adopted</var> has no associated document (e.g. it's not made by factory methods to construct stylesheets), throw a {{NotAllowedError}} {{DOMException}}.
3. Set this {{DocumentOrShadowRoot}}'s adopted stylesheets to <var>adopted</var>.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[=adopted stylesheets=]

index.bs Outdated
Every {{DocumentOrShadowRoot}} has <dfn>adopted stylesheets</dfn>.

The user agent must include all style sheets in the {{DocumentOrShadowRoot}}'s
[=adopted stylesheets=] inside its <a spec=cssom-1>document CSS style sheets</a> collection if it is a {{Document}}, or shadow CSS style sheets collection if it is a {{ShadowRoot}}. The [=adopted stylesheets=] are ordered after all the other style sheets (i.e. those derived from {{DocumentOrShadowRoot/styleSheets}}).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, I figured out the solution. Just use <a>document or shadow root CSS style sheets</a> and it will link to https://drafts.csswg.org/cssom/#documentorshadowroot-document-or-shadow-root-css-style-sheets, which does what you want.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh it was right there! Thanks.

@rakina rakina merged commit 706508a into gh-pages Oct 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants