I have a serious problem related to the page properties of a web editor. All web editors are able to deal with the basic color and background properties of an HTML4 document. These include:

  1. background color
  2. foreground color
  3. background image
  4. links color
  5. active links color
  6. visited links color

Most editors only deal with the HTML attributes on the body element, but that's clearly not enough in our CSS-based world... So what about a document where styles are set only through CSS, a document you want to edit but have no control on ?

1 is rather easy to obtain : get the computed background-color value of the body element.

2 is also easy, just get the computed color value of the body element.

3 is the same but for the background-image property.

4 is a hack, the only way you can get it is inserting an anchor with a dummy target at the end of the document, retrieve the computed color property and remove the anchor from the document before the reflow happens.

6 is about the same, but set the target to the current document so the anchor is visited.

But 5 ? How do you get the default color for active links ??? There's no simple solution and I see only two ways of doing :

  • a new API on the document retrieving the computed styles for a given element if it was inserted at a given point with a given state (hover, active, ...),
  • browse all CSS rules applying to the document, select the ones applying to active links contained in the body or the root of the document, compute the resulting color...

Do you have any suggestion for 4, 5 and 6 ?