RE: [css-content] Generated content: should distinguish between content that's above or below a reference

Just in case. Quite a while ago I was experimenting with so called CSS-script.

Basic idea is in set of “active CSS properties”  - properties with names ending with ‘!’.
Such properties support CSS-script – simple language that allows to do quite many things, for example here is 
basic <label> functionality defined by that CSS! script means: 

label[for]
{
  hover-on!  : $1(#< self.for >):hover = true;
  hover-off! : $1(#< self.for >):hover = false;
  active-on! : $1(#< self.for >):focus = true;
  cursor:pointer;
}

So click on label  ( event active-on! ) sets focus on element described by “for” DOM attribute. 

Sort of specification of the language:  
https://sciter.com/docs/core/csss!.htm 
https://sciter.com/docs/core/csss!-events.htm 
https://sciter.com/docs/core/csss!-dom-object.htm

Yet calc() function in the engine can use all that CSS! means.

My 2 cents.


Andrew Fedoniouk

Terra Informatica Software, Inc.

Richmond, BC, Canada

phone:+1(604)244-1074
mailto:andrew@sciter.com
http://sciter.com

From: Peter Moulder
Sent: November 12, 2018 11:18 PM
To: Hans Meiser
Cc: www-style@w3.org
Subject: Re: [css-content] Generated content: should distinguish between content that's above or below a reference

The approach taken by the PDF user-agent Prince is that construction of
natural language is best left to script: otherwise, the parameter array
will inevitably be found lacking once someone wants text like "at the top
of" or "in the appendix" or whatever.

More specifically, it allows a generated-content function
prince-script(FUNC-IDENT, ARGS) where ARGS are other generated-content
items (such as counter(page) and target-counter(URI, page)).

So for just the page-number description, one might have CSS

  a[href ^= "#"]::after {
      content: " (on "
              prince-script(describeRef,
                      counter(page),
                      target-counter(attr(href), page))
              ")" ;
  }

and javascript

  Prince.addScriptFunc("describeRef", function(ownPage, targetPage) {
      /* To distinguish "above" from "below", one would query the dom
       * here, after adding function arguments attr(id), attr(href).
       */
      if (ownPage == targetPage) {
          return "this page";
      } else if (targetPage == ownPage + 1) {
          return "next page";
      } else if (targetPage == ownPage - 1) {
          return "previous page";
      } else {
          return "page " + targetPage;
      }
  });

(Prince cautiously requires FUNC-IDENT to be registered explicitly using
Prince.addScriptFunc rather than automatically exposing all global named
javascript functions.  The second argument can either be a named javascript
function, or an anonymous function as used above.)

Depending on the desired behaviour of the suggested paragraph() function,
it might be implementable just by querying a particular counter (and/or
the page counter of paragraph elements).  For the most general case,
one can query the formatted document and re-start the layout with
revised javascript inputs.

A number of PDF-centric user agents for CSS allow use of javascript;
I haven't looked at how the above would differ between them.

pjrm.

Received on Tuesday, 13 November 2018 15:55:27 UTC