patch: text-indent
Johannes wrote:
On Sat, Nov 06, 2010 at 03:04:16PM +0000, corvid wrote:
"Percentage values: refer to parent element's width"
So a Textblock wants to decide how big it is, and it asks its children how big they are, and the child has, say, text-indent: 50%, and so it gets to wordWrap and asks "So, ah...how big are _you_?". And the parent doesn't know yet.
Ah interesting....
What about using something like availWidth in Textblock::wordWrap() as an aproximation of the future width of the Textblock? Maybe this would be good enough. In which cases would this be way off?
That's a good idea! It seems to work pretty well in general... (You will note that this ignores negative values (LENGTH_PERCENTAGE) and allows overflow.)
On Sun, Nov 07, 2010 at 12:43:42AM +0000, corvid wrote:
Johannes wrote:
On Sat, Nov 06, 2010 at 03:04:16PM +0000, corvid wrote:
"Percentage values: refer to parent element's width"
So a Textblock wants to decide how big it is, and it asks its children how big they are, and the child has, say, text-indent: 50%, and so it gets to wordWrap and asks "So, ah...how big are _you_?". And the parent doesn't know yet.
Ah interesting....
What about using something like availWidth in Textblock::wordWrap() as an aproximation of the future width of the Textblock? Maybe this would be good enough. In which cases would this be way off?
That's a good idea! It seems to work pretty well in general...
From looking at the specs I think it should use the whole width of
Wow nice! the block including margin and padding, like this: indent = misc::roundInt(this->availWidth * core::style::perLengthVal (getStyle()->textIndent)); As far as I can tell firefox is also doing it that way in: <div style="text-indent: 50%; border: 1px solid; padding: 2cm; margin: 2cm"> foo bar </div> Cheers, Johannes PS: Feel free to commit your patch!
On Sun, Nov 07, 2010 at 12:43:42AM +0000, corvid wrote:
Johannes wrote:
On Sat, Nov 06, 2010 at 03:04:16PM +0000, corvid wrote:
"Percentage values: refer to parent element's width"
So a Textblock wants to decide how big it is, and it asks its children how big they are, and the child has, say, text-indent: 50%, and so it gets to wordWrap and asks "So, ah...how big are _you_?". And the parent doesn't know yet.
Ah interesting....
What about using something like availWidth in Textblock::wordWrap() as an aproximation of the future width of the Textblock? Maybe this would be good enough. In which cases would this be way off?
That's a good idea! It seems to work pretty well in general...
(You will note that this ignores negative values (LENGTH_PERCENTAGE) and allows overflow.)
Thanks for committing the patch! I just noticed one thing that might complicate stuff a bit. Consider the following page: <div style="text-indent: 3em; border: 1px solid"> <div style="text-indent: 3em; border: 1px solid"> foo </div> bar </div> It seems that the inner <div> should not be indented, just text. The spec says: "More precisely, it specifies the indentation of the first box that flows into the block's first line box" I'd interpet it in dillo terms as to do the indent only if the first word is not a textblock widget. The question is then whether the "bar" should be indented. From the spec I would say yes, but firefox does not seem to do it... What do you think? Cheers, Johannes
Johannes wrote:
I just noticed one thing that might complicate stuff a bit. Consider the following page:
<div style="text-indent: 3em; border: 1px solid"> <div style="text-indent: 3em; border: 1px solid"> foo </div> bar </div>
It seems that the inner <div> should not be indented, just text. The spec says: "More precisely, it specifies the indentation of the first box that flows into the block's first line box"
I'd interpet it in dillo terms as to do the indent only if the first word is not a textblock widget.
As in the attached?
The question is then whether the "bar" should be indented. From the spec I would say yes, but firefox does not seem to do it...
What do you think?
My impression is that the inner div is a block, and the bar goes into an anonymous block according to the spec, and the anonymous block inherits text-indent, and would indent it, but the spec is a little monstrous, so there may be some reason why that's not it. I would think the intention of text-indent is only to indent the first thing...
On Tue, Nov 09, 2010 at 09:40:19PM +0000, corvid wrote:
Johannes wrote:
I just noticed one thing that might complicate stuff a bit. Consider the following page:
<div style="text-indent: 3em; border: 1px solid"> <div style="text-indent: 3em; border: 1px solid"> foo </div> bar </div>
It seems that the inner <div> should not be indented, just text. The spec says: "More precisely, it specifies the indentation of the first box that flows into the block's first line box"
I'd interpet it in dillo terms as to do the indent only if the first word is not a textblock widget.
As in the attached?
Yes, but also for Tables. What other widgets do we have? Bullet I guess they are inline Images are inline I think Ruler this is block level, so needs no indent ListItem do we need to check for it or will it show up as Textblock::CLASS_ID? TableCell same as for ListItem We probabely want some isBlockLevelWidget() function...
The question is then whether the "bar" should be indented. From the spec I would say yes, but firefox does not seem to do it...
What do you think?
My impression is that the inner div is a block, and the bar goes into an anonymous block according to the spec, and the anonymous block inherits text-indent, and would indent it, but the spec is a little monstrous, so there may be some reason why that's not it. I would think the intention of text-indent is only to indent the first thing...
Sounds reasonable. Cheers, Johannes
-----Urspr?ngliche Nachricht----- An: dillo-dev@dillo.org; Von: corvid <corvid@lavabit.com> Gesendet: Do 11.11.2010 02:43 Betreff: Re: [Dillo-dev] patch: text-indent
Johannes wrote:
We probabely want some isBlockLevelWidget() function...
Using Widget::Flags, perhaps, or would you think it best generally to save the flags for state that changes during a widget's life?
I was just thinking about something simple like bool isBlockLevelWidget(Widget *w) { return widget->instanceOf (Textblock::CLASS_ID) || widget->instanceOf (Table::CLASS_ID) ... ); } in textblock.cc to explain to the code reader why we are testing for exactly these widget types. Plus we might have to reuse at some point. Cheers, Johannes
Johannes wrote:
-----Urspr?ngliche Nachricht----- An: dillo-dev@dillo.org; Von: corvid <corvid@lavabit.com> Gesendet: Do 11.11.2010 02:43 Betreff: Re: [Dillo-dev] patch: text-indent
Johannes wrote:
We probabely want some isBlockLevelWidget() function...
Using Widget::Flags, perhaps, or would you think it best generally to save the flags for state that changes during a widget's life?
I was just thinking about something simple like
bool isBlockLevelWidget(Widget *w) { return widget->instanceOf (Textblock::CLASS_ID) || widget->instanceOf (Table::CLASS_ID) ... ); }
in textblock.cc to explain to the code reader why we are testing for exactly these widget types. Plus we might have to reuse at some point.
Textblock doesn't know what Table and Ruler are, though.
On Thu, Nov 18, 2010 at 06:44:57PM +0000, corvid wrote:
Johannes wrote:
-----Urspr?ngliche Nachricht----- An: dillo-dev@dillo.org; Von: corvid <corvid@lavabit.com> Gesendet: Do 11.11.2010 02:43 Betreff: Re: [Dillo-dev] patch: text-indent
Johannes wrote:
We probabely want some isBlockLevelWidget() function...
Using Widget::Flags, perhaps, or would you think it best generally to save the flags for state that changes during a widget's life?
I was just thinking about something simple like
bool isBlockLevelWidget(Widget *w) { return widget->instanceOf (Textblock::CLASS_ID) || widget->instanceOf (Table::CLASS_ID) ... ); }
in textblock.cc to explain to the code reader why we are testing for exactly these widget types. Plus we might have to reuse at some point.
Textblock doesn't know what Table and Ruler are, though.
Hm, I see. In that case your proposal of using the widget flags sounds just fine to me. Cheers, Johannes
Committed a change. I see that tables still don't work properly with it. <table border=1 style="text-indent: 1em"> <tr><td>I'm<td>a<td>table </table> doesn't make the cells big enough, but that's simply because I haven't looked into it yet. However, with <div style="text-indent: 1em; border: 1px solid"> <table border=1> <tr><td>I'm<td>a<td>table </table> text </div> firefox doesn't indent the text in the cells, and I don't know why not. The property inherits. Guess I have some deeper spec reading in my immediate future.
I wrote:
However, with <div style="text-indent: 1em; border: 1px solid"> <table border=1> <tr><td>I'm<td>a<td>table </table> text </div> firefox doesn't indent the text in the cells, and I don't know why not. The property inherits. Guess I have some deeper spec reading in my immediate future.
Ah, http://davidwalsh.name/firefox-internal-rendering-css shows table { .. text-indent: 0; }
On Fri, Nov 19, 2010 at 06:15:45PM +0000, corvid wrote:
I wrote:
However, with <div style="text-indent: 1em; border: 1px solid"> <table border=1> <tr><td>I'm<td>a<td>table </table> text </div> firefox doesn't indent the text in the cells, and I don't know why not. The property inherits. Guess I have some deeper spec reading in my immediate future.
Ah, http://davidwalsh.name/firefox-internal-rendering-css shows table { .. text-indent: 0; }
Yeah tables seem to reset some CSS values traditionally. There is already a related comment in css.cc with the following link: http://developer.mozilla.org/En/Fixing_Table_Inheritance_in_Quirks_Mode Cheers, Johannes
participants (3)
-
corvid@lavabit.com
-
Johannes.Hofmann@gmx.de
-
johannes.hofmann@gmx.de