W3C home > Mailing lists > Public > www-style@w3.org > September 2012

Re: Suggestion: "shown" and "shownText"

From: Simon Pieters <simonp@opera.com>
Date: Tue, 18 Sep 2012 13:39:01 +0200
To: "Simon Stewart" <shs@rocketpoweredjetpants.com>
Cc: "www-style@w3.org" <www-style@w3.org>
Message-ID: <op.wktxbbeyidj3kv@simons-macbook-pro.local>
cc www-style
bcc www-dom

On Tue, 11 Sep 2012 16:25:04 +0200, Simon Stewart  
<shs@rocketpoweredjetpants.com> wrote:

> Hi,
>
> As part of the work we're doing on the WebDriver spec, we're attempting  
> to
> identify properties or algorithms that may be better placed in other  
> specs.
> We think that there are two obvious candidates for inclusion into future
> revisions of the DOM spec: "shown" and "shownText".
>
> The "shown" property describes whether a particular element could be made
> visible to a user. The algorithm we use to determine this is described  
> in:
>
> http://www.w3.org/TR/webdriver/#determining-visibility

What's the use case?


> The "shownText" property returns the user visible text that corresponds  
> to
> what a user would see. The algorithm we use for this is described in:
>
> http://www.w3.org/TR/webdriver/#rendering-text
>
> Rationale:
>
> Of the two, "shownText" may seem the least necessary. After all, there's
> already "textContent" and "innerText". The latter isn't standardized, so
> cannot be depended on.

That doesn't make sense. "shownText" isn't standardized either.

If what you want is very close to something already implemented in some  
browsers, you should seriously consider Paving the Cowpath instead of  
inventing something new.

Also see http://aryeh.name/spec/innertext/innertext.html


> The former is standardized as being a concatenation
> of text nodes. This means that it often contains text that isn't visible  
> to
> the user (such as the content of SCRIPT tags, of text that wouldn't be
> rendered to the screen due to styling).
>
> In our experience, users tend to use the value of textContent for  
> comparing
> large bodies of text spanning several nodes. The current implementation
> means that the returned text isn't consistent between different browsers,
> and frequently contains output that a user wouldn't see. Worse, tests
> sometimes fail because a user compares a string returned from textContent
> with what they see on the screen: "I see dead text" is most definitely  
> not
> the same as "I see dead \n text" though both are rendered identically.
>
> An implementation of "shownText" would make extensive use of "shown". The
> calculations we currently need to perform to implement this cleanly  
> across
> browsers cause visibility checks to be extremely expensive. Making this
> property available to users via the DOM would also simplify some of the
> common operations that people perform currently by checking multiple
> properties ("displayed" and "visibility" values, for example) or making  
> use
> of custom classes. Even as a read-only property, it could simplify  
> existing
> code.
>
> We would be happy to donate the algorithms and a suite of JS-based tests
> that demonstrate conformance with the spec if that would help.
>
> Regards,
>
> Simon


-- 
Simon Pieters
Opera Software
Received on Tuesday, 18 September 2012 11:39:33 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:21:00 GMT