Note: There are a few cases of duplicates in user autocompletion which are being worked on.

Style processing with Imports

RESOLVED WONTFIX

Status

()

Core
DOM: Core & HTML
RESOLVED WONTFIX
3 years ago
a year ago

People

(Reporter: krizsa, Assigned: krizsa)

Tracking

(Blocks: 1 bug)

Firefox Tracking Flags

(Not tracked)

Details

(Assignee)

Description

3 years ago
According to the spec:
The contents of the style elements and the external resources of the link elements in imports must be considered as input sources of the style processing model of the master document.

This is currently the most important (also maybe only...) missing feature for the GAIA folks to be able to use imports.
(Assignee)

Updated

3 years ago
Assignee: nobody → gkrizsanits
Blocks: 811542
Test-case: http://wilsonpage.github.io/html-imports/nested-link/
(Assignee)

Comment 2

3 years ago
Boris, what do you think about the current spec? (sorry for the long comment)

current spec:

"
Style processing with Imports

The contents of the style elements and the external resources of the link elements in imports must be considered as input sources of the style processing model of the master document.

Between declarations from different documents, the document order in terms of order of appearance is defined based on the document order of the link elements of their import referrer ancestors which are in the same document. If thre are more than one of such documents, the comparison result in the first document, in the document order, wins.

See Bug 24756.
"

(https://www.w3.org/Bugs/Public/show_bug.cgi?id=24756)

It does specify the order for style-sheets of different imports but does not say anything about when to apply them. And I'm not fully sure about the order of imports in the master vs import case. Nor am I sure that this is the right thing to do at all.... Anyway, My plan is to do it whenever an import is loaded. It will be a bit tricky, for DocStyleSheets I will have to add them to the StyleSet that belong to the master document, while for AuthorStyleSheets I will have to make sure that up until this point the import document should not add them to the shared docshell. I'm not sure what would be the right time to notify the observers... when the parser adds the sheet to the import, or when we apply them in a bundle on the master document? Or it should depends if the observer is attached to the import or the master document?

One thing I'm particularly worried about is that we don't block the parser of the main document, only the script execution is blocked. I hope that will not mess up the ordering between the style sheets of the master vs the sheets of the import. What does ensure it in the regular case, that when two style sheet links are parsed that they end up in the right order?

Any input here would be great really both at spec level and implementation level, and I'm pretty sure I'm leaving out a lot of important questions I'm not even aware of...
Flags: needinfo?(bzbarsky)

Comment 3

3 years ago
> is defined based on the document order of the link elements 

That doesn't define how they order from styles that are directly in the importing document.

> the comparison result in the first document, in the document order, wins

Is "in the document order" defined?

> but does not say anything about when to apply them

Presumably once the import has loaded the stylesheets, right?  Or maybe once the import is loaded?  Or both?  I agree it's not very clear.

> And I'm not fully sure about the order of imports in the master vs import case.

Right, it's not defined.

> Nor am I sure that this is the right thing to do at all

I'm not either.

> while for AuthorStyleSheets

I think you can ignore AuthorStyleSheets in import documents, right?

> I'm not sure what would be the right time to notify the observers...

Which observers?

> What does ensure it in the regular case, that when two style sheet links are parsed that
> they end up in the right order?

css::Loader::InsertSheetInDoc sorts based on the element that caused the sheet to exist.
Flags: needinfo?(bzbarsky)
(Assignee)

Comment 4

3 years ago
(In reply to Boris Zbarsky [:bz] from comment #3)
> Right, it's not defined.

I guess I bring this to the mailing list and file a spec bug. Thanks for the input!

> > I'm not sure what would be the right time to notify the observers...
> 
> Which observers?

StyleSheetAdded/Removed, like http://mxr.mozilla.org/mozilla-central/source/content/base/src/nsDocument.cpp#4009

> I think you can ignore AuthorStyleSheets in import documents, right?

Ah yeah, those can be totally ignored, was looking at some nsStyleSheetService related code and mixed up something.

Comment 5

3 years ago
> StyleSheetAdded/Removed,

Those should get fired when sheets are added or removed (as in, when you want them to start or stop having an effect).
(Assignee)

Comment 6

3 years ago
There were some clarification made in https://www.w3.org/Bugs/Public/show_bug.cgi?id=24756 how all this should work, it's better defined now, but I'm still not sure if we are doing the right thing here. I added my concerns to the w3 bug.

Comment 7

3 years ago
when importing a html with <link rel="import" href="test.html"> the css inside a template tag get precessed but the css outside of template gets ignored
(Assignee)

Comment 8

3 years ago
(In reply to Marinescu Bogdan from comment #7)
> when importing a html with <link rel="import" href="test.html"> the css
> inside a template tag get precessed but the css outside of template gets
> ignored

Style sheet processing for import is simply not implemented. Actually I don't think that even the spec is ready, see bug mentioned in comment 6. So if something works, that's pretty much just a lucky coincidence at this point and I would not recommend you to depend on it until this bug is fixed.
(Assignee)

Comment 9

3 years ago
I've just had a talk with the spec. owners from Google, and the consensus was that we should probably not apply style sheets of the imports on the master document, because all the weird style order issues. The idea is that we should provide better API to apply those sheets on the master, and by default imports only will fetch them. I'm going to wait until the new version settles.

(I set the needinfo flag only to make sure you hear about this update)
Flags: needinfo?(wilsonpage)
Damn, that's a shame. Thanks for the update anyway! :)
Flags: needinfo?(wilsonpage)

Comment 11

a year ago
Marking this WONTFIX since Mozilla has no interest in shipping this feature.
Status: NEW → RESOLVED
Last Resolved: a year ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.