Re: [css3-text-layout] New editor's draft - margin-before/after/start/end etc.

Also sprach Boris Zbarsky:

 > > It seems fair that one cannot expect APIs meant for specified property
 > > values to work for aliases -- 'margin-start' is an alias, not a
 > > property.
 > 
 > Hold on.  So I can write "* { margin-start: 20px }" in my CSS, but I 
 > can't do this in JS?
 > 
 >    var sheet = document.styleSheets[0];
 >    sheet.insertRule("* {}", 0);
 >    sheet.cssRules[0].style.setProperty("margin-start", "20px", "");
 > 
 > Why shouldn't I be able to do that?  Why shouldn't I be able to do 
 > thisElement.style.setProperty("margin-start", "3px", "")?
 >
 > That is, it seems like you have defined this thing to be an "alias" 
 > (whatever that is, _that_'s not defined) for some reason and are now 
 > arguing circularly that this means specified values for it "shouldn't 
 > work".  But why shouldn't they?  Specified values for *-start/end are 
 > dead simple; it's the computed and used values that are complicated!

Let's take one step back. What I'm trying to do is to see if it's
possible to construct a model where (a) it's possible to use
direction-dependent property names in CSS, while (b) keeping costs to
a minimum for implementors. 

(I'm not conviced that (a) should be a requirement; there may be better
ways to solve the problem, e.g., Andrew Fedoniouk's proposal to add
pseudo-classses (such as :rtl, :ltr and :ttb). However, I'm willing to
try work it out.)

I'm scared by the complexity of David Baron's proposal, which adds 130
new properties [1]. I'm also happy to see him being very honest about
the complexity [2].

[1] http://lists.w3.org/Archives/Public/www-style/2010Jun/0003.html
[2] http://lists.w3.org/Archives/Public/www-style/2010Jun/0014.html

So, I'm trying to see if it's possible to support "margin-start: 10px"
without adding *-source properties. Also, I'd like for implementations
to forget about direction-dependent properties/aliases as soon as
possible. Ideally, this should be done at parse-time, but at that
point we don't know what the value of 'writing-mode' will end up
being. So, I think we need to hold only them until the computed value
of 'writing-mode' is known.

At that point, we should be able to map settings from
direction-dependent settings to physical seetings. So, e.g., we can
map:

  margin-start: 10px

to one of these:

  margin-left: 10px
  margin-top: 10px
  margin-right: 10px

and forget about "margin-start: 10px". 

As you have pointed out in the past [3], specified values need a lot less
memory than computed values. So, it may be that we can keep them
around so that scripts can get to them. But, this, may have limited
value. For example:

  margin-start: 20px;
  margin-left: 10px;

In the example above, knowing the 'margin-start' declaration has
limited value as it is overridden by the subsequent 'margin-left'
declaration (assuming ltr).

Therefore, the computed value is more interesting. In David Baron's
model, 'margin-start' has its own computed value [4]. I think it's
possible to avoid that by mapping the direction-dependent
properties/aliases to physical properties. So, only the physical
properties would have computed values -- the direction-dependendt
properties/aliases could be computed in a lazy fashion based on the
values of the physical properties and 'writing-mode'.

Now, to come back to your question:

 > Hold on.  So I can write "* { margin-start: 20px }" in my CSS, but I 
 > can't do this in JS?
 > 
 >    var sheet = document.styleSheets[0];
 >    sheet.insertRule("* {}", 0);
 >    sheet.cssRules[0].style.setProperty("margin-start", "20px", "");
 > 
 > Why shouldn't I be able to do that?  Why shouldn't I be able to do 
 > thisElement.style.setProperty("margin-start", "3px", "")?

I think it should be possible to support this code. However, a mapping
will have to take place internally so that 'margin-start' is mapped to
the right physical property, by way of 'writing-mode'. It may be that
an external library can do the job just as well, but I'm not opposed
to adding such declarations through the DOM.

Does this make sense?

[3] http://lists.w3.org/Archives/Public/www-style/2010Jun/0013.html
[4] http://lists.w3.org/Archives/Public/www-style/2010Jun/0014.html

-h&kon
              Håkon Wium Lie                          CTO °þe®ª
howcome@opera.com                  http://people.opera.com/howcome

Received on Thursday, 3 June 2010 17:22:19 UTC