First of all: You do a great job! An HTML engine is so basic for further analysis und processing that I do not know why you are the first and only guys who have developed such an engine in Java.
However, please, either explain the contentBounds and the bounds properties of cssbox to me or instruct me to post a bug report: Consider the example below.
We investigate div.page: Why is contentBounds.y=0 and bounds.y negative? Although the contentBounds are still correctly relative to the bounds, the negative y-value of the bounds takes me by surprise. I expect the bounds.y to be 0 as always and the contentBounds.y to be the sum of the corresponding margin+border+padding.
Thank you,
Nogge
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
the reason is margin collapsing as defined in CSS specs. In the presented case, the negative Y is equal to the computed value of top margin of div.page. For collapsing the margins, the top margin is propagated to parent nodes (see the EMargin of body and html elements and the content bounds of html). Then, the top margins are collapsed (placed over each other) and therefore, the body and div.page need to be shifted up by Y in order to align the border edges.
Radek
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ok, I see. But couldn't you also provide a relative content property that considers and thus abstracts those cases, too? Negative values are not intuitive and you need to combine them with the contentbound to get the exact relative content poition.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have been thinking about it but I mean it would make the API more complicated as I would have to provide the "original" content bounds as well. I don't know the details of your application but couldn't you just subtract the computed absolute coordinates if you need something like relative values?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
First of all: You do a great job! An HTML engine is so basic for further analysis und processing that I do not know why you are the first and only guys who have developed such an engine in Java.
However, please, either explain the contentBounds and the bounds properties of cssbox to me or instruct me to post a bug report: Consider the example below.
We investigate div.page: Why is contentBounds.y=0 and bounds.y negative? Although the contentBounds are still correctly relative to the bounds, the negative y-value of the bounds takes me by surprise. I expect the bounds.y to be 0 as always and the contentBounds.y to be the sum of the corresponding margin+border+padding.
Thank you,
Nogge
Hello,
the reason is margin collapsing as defined in CSS specs. In the presented case, the negative Y is equal to the computed value of top margin of div.page. For collapsing the margins, the top margin is propagated to parent nodes (see the EMargin of body and html elements and the content bounds of html). Then, the top margins are collapsed (placed over each other) and therefore, the body and div.page need to be shifted up by Y in order to align the border edges.
Radek
Ok, I see. But couldn't you also provide a relative content property that considers and thus abstracts those cases, too? Negative values are not intuitive and you need to combine them with the contentbound to get the exact relative content poition.
I have been thinking about it but I mean it would make the API more complicated as I would have to provide the "original" content bounds as well. I don't know the details of your application but couldn't you just subtract the computed absolute coordinates if you need something like relative values?
Of course, thank you for your suggestion.