W3C home > Mailing lists > Public > www-dom@w3.org > July to September 1999

DOM2 Stylesheets

From: L. David Baron <dbaron@fas.harvard.edu>
Date: Wed, 4 Aug 1999 12:54:52 -0400 (EDT)
Message-Id: <199908041654.MAA17576@ice4.fas.harvard.edu>
To: www-dom@w3.org
Here are some comments on chapter 3 of the current DOM2 WD [1].  These
stem from my own personal interest in the draft, not from anything I am
doing this summer at Netscape.

Interface StyleSheet
--------------------

 - If no media are specified, what is the media attribute?  I suggest it
   be created automatically with one item: "all".  If not, then it could
   have length 0 and cssText of "".  I think making it null would be a
   bad idea.

 - How do media and disabled interact?
     1) (my preference)  If the medium is not matched by the media list,
        the stylesheet is not applied and the disabled attribute is
        ignored.  I like this because:
          * a change in media would automatically change which stylesheets
            are applied, without requiring changes to disabled
          * printing would make sense
          * the mechanims I propose below are simple
     2) The disabled attribute is initially false if the medium is not
        matched by the media list, and setting disabled throws an
        exception.
     3) The disabled attribute is initially false if the medium is not
        matched by the media list, and setting disabled applies sheet in
        spite of the media list.

Interface StyleSheetList
------------------------------

The notion of setting a disabled attribute on the stylesheet runs
somewhat counter to the mechanism used in HTML 4.0 [2] (and thus in
xml-stylesheet [3]) for selecting between alternate stylesheets.  I
therefore propose the following mechanism in addition to the disabled
attribute to allow for the selection of groups of stylesheets by their
titles.  The current definitions assume that the interaction between
disabled and media is defined by my first choice above.  I don't like
all the names I used below, but I just gave them names so the proposal
would be concrete.  I'm not at all attached to this particular proposal
(although I still think it's good), but I want to put something
concrete on the table because I think the capabilities it provides are
important.

interface TitleList {
  readonly attribute unsigned long  length;
  DOMString          item(in unsigned long index);
};

Attributes 
     length 
          The number of DOMString in the list. The range of valid
          indices is 0 to length-1 inclusive.
Methods 
     item 
          Used to retrieve a title by ordinal index. 
          Parameters 
                index
                     Index into the collection

          Return Value 
               The title at the index position in the TitleList, or
               null [the empty string??] if that is not a valid index.


interface StyleSheetList {
           attribute DOMString      selected;
                                     // raises(DOMException) on setting
           attribute unsigned long  selectedIndex;
                                     // raises(DOMException) on setting
  readonly attribute TitleList      names;
  readonly attribute unsigned long    length;
  StyleSheet         item(in unsigned long index);
}

Attributes
     selected

        The stylesheet title currently in use. Initially, this is set
        to the title of the preferred stylesheets as defined by HTML
        4.0 [2] or xml-stylesheet [3] or to the empty string if there
        is no preferred stylesheet.  If the disabled attribute of a
        stylesheet in the list is set, this does not change.  [Is this
        the best behavior?]  If this is set to a string that is an item
        in the names attribute, it sets disabled to false on any
        stylesheets in the StyleSheetList that have a title equal to
        that string (the new value of selected) or the empty string,
        and sets disabled to true for any other stylesheets.  If it is
        set to the empty string, all stylesheets with non-empty titles
        have disabled set to true, and those with empty titles have
        disabled set to false.  In either case, the value of
        selectedIndex is changed to reflect the change to selected.

        Exceptions on setting
            DOMException
                NOT_FOUND_ERR [ Probably the wrong one? ]
                    If the specified string is not in names and is
                    not the empty sting.
     selectedIndex

        This string gives the index of the current selected attribute
        in names, or -1 if selected is the empty string.  Setting it
        to any value between -1 and names.length-1 changes
        selected appropriately and causes the corresponding changes
        to the disabled attribute of the stylesheets in the
        StyleSheetList.

        Exceptions on setting
            DOMException
                INDEX_SIZE_ERR
                    If the specified index is not between -1 and
                    names.length-1, inclusive.
     names
        A TitleList containing the titles from which the user can
        select alternate stylesheets, as defined by HTML 4.0 [2]
        or xml-stylesheet [3].
     length
        AS CURRENTLY DEFINED
Methods
     item
        AS CURRENTLY DEFINED

David

[1] http://www.w3.org/TR/1999/WD-DOM-Level-2-19990719/stylesheets.html
[2] http://www.w3.org/TR/1998/REC-html40-19980424/present/styles.html#h-14.3
[3] http://www.w3.org/1999/06/REC-xml-stylesheet-19990629/

L. David Baron     Rising Sophomore, Harvard     dbaron@fas.harvard.edu
Links, SatPix, CSS, etc.        < http://www.fas.harvard.edu/~dbaron/ >
Summer Intern, Netscape - however, opinions are entirely my own, etc.
Received on Wednesday, 4 August 1999 12:55:02 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:46 GMT