Re: [css3-writing-modes] a third option for implementing logical properties

On Oct 24, 2010, at 9:16 AM, John Daggett wrote:

> My point here is that if there are some elements that don't rotate
> within vertical text layouts, then simply flipping box properties
> based on the writing mode isn't always going to give you a workable
> layout in both vertical and horizontal modes.

Sure.  Obviously the logical properties don't cover everything.  It's a question of whether they are good enough for the kinds of dual layouts people want to construct.  We need to be thinking about use cases, i.e., what content is it that people want to be dual, and how complex is it going to be?

> 
>>> Unless *all* directionally dependent properties in CSS 2.1 *and*
>>> in various CSS3 modules include directional equivalents (e.g.
>>> border-radius), authors need some way of defining styles that are
>>> dependent on the writing mode of a given element.
>> 
>> This may in fact be necessary, but that doesn't mean you should
>> force authors to duplicate many physical declarations in two
>> different blocks.  There is still value in having a logical
>> abstraction even if it doesn't cover 100%.  If it covers 90%, that's
>> still going to make life much easier for authors.
> 
> The new properties effectively make box properties a function of the
> writing mode.  Why not define a more general way of making an arbitrary
> set of styles dependent on the writing mode?  Especially if we can
> avoid the need to define a bazillion new properties that interact
> with each other.
> 
> Several ideas have been proposed but I think a pseudo-element that's
> dependent on the value of writing-mode seems interesting.
> 
>  p { margin: 1em 0px; }
>  p::writing-mode(vertical-rl) { margin: 0px 1em; }
> 

>From an implementation perspective this is a really bad solution.  You'd be checking for pseudo-elements on every element in the engine while you did your layout, and then for vertical pages in particular, there would be extra pseudo-elements for many elements.  Pseudo-elements are also very poorly understood by authors, so if we're talking about keeping things simple, then we really shouldn't be using pseudo-elements.

I'm not opposed to some way of writing style rules for different writing modes.  I hope it didn't sound like i was.  I think nobody has suggested a good way to do this though.  

Conceptually a pseudo-element just isn't the right way to do this, and from an implementation perspective, it will introduce a lot more complexity into the code, since you'll have to ask for this special pseudo element all over the place.  The logical properties by comparison have no impact on existing code.

I think we would have to introduce a 2-stage resolution into the CSS language in order to allow writing-mode to be matched as a pseudo-class instead.  It makes more sense as a pseudo-class, and like the logical properties, it would have no impact on existing layout code.

Another idea: just specify writing-mode in HTML instead and don't have it be in CSS at all (except as a pseudo class you match on in order to provide rules for that writing mode).  This is a little weird in that we already have direction in CSS though.

> Another interesting thing to point out is that the defaults for
> Western text don't really make sense as defaults for Japanese vertical
> text.  The margin settings above are the Webkit user agent stylesheet
> values.  With logical margins, the 1em top/bottom margins for
> horizontal layout become 1em left/right margins for vertical text
> layout. But vertical text layout in Japanese generally doesn't include
> spaces between paragraphs.  With this model there's no way for user
> agent stylesheets to use different defaults for different writing modes.

That's a good point.  I don't think IE varies the defaults when you rotate, so I didn't know this was the case.

> 
> I looked over Webkit's html.css [1], there appear to be 20 style rules
> that define directionally-dependent box properties.  Of those, most set
> top/bottom and left/right to the same value, so the vertical writing
> modes are the only ones that would be affected.   That doesn't seem
> like a huge list of properties that require a lot of maintenance.

I think you're underestimating the # of rules, but I'm too lazy to crawl over the whole sheet to argue. :)

> 
>> ...and if you need them in the UA sheet for directional abstraction,
>> don't you think an author trying to write directionally abstract
>> content would need them also?
> 
> Directionally abstract in what sense?!?  If someone is designing a
> vertical text layout in Japanese do you really think they intend to
> use that same layout as a template for an English layout?  

No, that's not what I meant.  I'm thinking specifically of people designing dual layouts in the same language.  As you point out, the UA sheet is trying to serve all languages, and so different defaults might be required there.  In author sheets, though, I'm thinking about dual layouts in the same language.

> Vertical
> text layout has lots of features that make it quite distinct from
> horizontal text layout, I think limiting authors to a "directionally
> abstract" solution is a mistake.
> 

I have never said that the logical properties are all that is needed.  I am not opposed to a way of writing style rules based off the writing mode.  I just don't think anyone has suggested a good way to do that yet.

dave
(hyatt@apple.com)

Received on Sunday, 24 October 2010 16:30:02 UTC