Skip to content

Conversation

@TKDev7
Copy link
Contributor

@TKDev7 TKDev7 commented Apr 20, 2023

I believe CSS works with document trees and not the source document itself. I am not sure if I am being correct here or not.

I believe CSS works with document trees and not the source document itself. I am not sure if I am being correct here or not.
and renders it onto a <a href="https://www.w3.org/TR/CSS2/intro.html#canvas">canvas</a>
such as your screen, a piece of paper, or an audio stream.
Although any such source document can be rendered with CSS,
Although any such document tree can be rendered with CSS,
Copy link
Collaborator

@fantasai fantasai Apr 21, 2023

Choose a reason for hiding this comment

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

We could change this to “element tree”, which is defined in the previous sentence. But we can't change this to “document tree” which would be cross-linking to the DOM specifically, since it's about how element trees don't have to be the DOM...

Copy link
Contributor Author

@TKDev7 TKDev7 Apr 22, 2023

Choose a reason for hiding this comment

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

the most commonly used type is the DOM. Some of these more complex tree types might have additional types of nodes, such as the comment nodes in the DOM

I don’t think DOMs are element trees since they contain comment nodes. i believe they are more of document trees.

This is also the term used in Box Model Module:

CSS describes how each element and each string of text in a source document is laid out by transforming the document tree into a set of boxes, whose size, position, and stacking level on the canvas depend on the values of their CSS properties.

Also Cascading and Inheritance Module:

Once a user agent has parsed a document and constructed a document tree, it must assign, to every element in the tree, and correspondingly to every box in the formatting structure, a value to every property that applies to the target media type.

Also in the CSS 2.1 Specification, Chapter 2 section 2.3:

  1. From the annotated document tree, generate a formatting structure. Often, the formatting structure closely resembles the document tree, but it may also differ significantly, notably when authors make use of pseudo-elements and generated content. First, the formatting structure need not be "tree-shaped" at all -- the nature of the structure depends on the implementation. Second, the formatting structure may contain more or less information than the document tree. For instance, if an element in the document tree has a value of 'none' for the 'display' property, that element will generate nothing in the formatting structure. A list element, on the other hand, may generate more information in the formatting structure: the list element's content and list style information (e.g., a bullet image).

So from my understanding CSS will render document trees, ignoring non-element and non-text nodes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm the Selectors Module does refer to the DOM as element tree

Selectors are evaluated against an element tree such as the DOM. Within this specification, this may be referred to as the "document tree" or "source document".

Yeah I am just confused now.

Copy link
Collaborator

@fantasai fantasai Apr 25, 2023

Choose a reason for hiding this comment

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

Looks like that all needs a bit of clean-up... the term “element tree” didn't have a definition before, so there wasn't anything to anchor the terminology before. :/

I don’t think DOMs are element trees since they contain comment nodes. i believe they are more of document trees.

CSS operates on element trees, fundamentally, and wrt the DOM, it essentially operates on an element-tree projection of the DOM (ignoring comment nodes, etc.). That's the concept that this paragraph is defining.

This sentence specifically is about how you can apply CSS to an element tree that isn't derived from the DOM, so we definitely shouldn't be using the term “document tree” here. We can either leave it as “source document” or change it to “element tree”.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suppose I will leave it as is and close this PR then.

@TKDev7
Copy link
Contributor Author

TKDev7 commented Apr 22, 2023

@fantasai Do you think we should wait for #1810 to be resolved first?

@TKDev7 TKDev7 closed this Apr 25, 2023
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