whatwg / html

HTML Standard
https://html.spec.whatwg.org/multipage/
Other
8.1k stars 2.66k forks source link

Default styling of <rp> #2134

Open zcorpan opened 7 years ago

zcorpan commented 7 years ago

It seems we don't have interop on the default style of rp.

Tests: http://software.hixie.ch/utilities/js/live-dom-viewer/saved/4711 http://software.hixie.ch/utilities/js/live-dom-viewer/saved/4714

'display' is...

Test case Edge 13 Blink, WebKit Gecko IE 8..9 IE 10..11
<p><ruby><rp> none none none none none
<p><ruby><rtc><rp> none inline none none none
<p><ruby><span><rp> none inline none none none
<p><rp> inline inline none inline none
<p><ruby><rp style="display: inline-block"> inline-block inline-block inline-block none none

That is, we have these UA stylesheets:

Edge 13
ruby rp { display: none; }
Blink, WebKit
ruby > rp { display: none; }
Gecko
rp { display: none; }
IE 8..9
ruby rp { display: none !important; }
IE 10..11
rp { display: none !important; }

Currently the spec says Gecko, IE 10..11 are correct.

In httparchive, looking for pages that have <rp> but no <ruby>, I found a single page that is "broken" in Gecko but not in the others:

http://www.kerala.com/ has

<script type="text/javascript">  
    Cufon.replace('rp');
</script>
...
                                      <div class="hrh_text">Rooms from</div><div class="hrh_pric">
                                      <strong><rp>`</rp> 
                                      1495/-</strong></div></div>

(The cufon thing inserts a canvas into the rp to render some glyph.)

The Blink and WebKit default style seems incompatible with rtc (#121). Gecko is simplest, but it is the only engine now to hide rp outside ruby, and it breaks at least the page above. Should we switch to the behavior of Edge 13?

cc @upsuper @yosinch @kojiishi @rniwa

zcorpan commented 7 years ago

From the spec:

An rp element that is a child of a ruby element represents nothing. An rp element whose parent element is not a ruby element represents its children.

In the absence of style-layer rules to the contrary (e.g. author style sheets), user agents are expected to render an element so that it conveys to the user the meaning that the element represents, as described by this specification.

[hidden], area, base, basefont, datalist, head, link, menu[type=context i], meta, noembed, noframes, param, rp, script, source, style, template, track, title { display: none; }

This is not internally consistent, so that should be fixed (regardless of which UA style we decide on).

kojiishi commented 7 years ago

I'm fine with Edge or Gecko. Thank you for your investigations.

upsuper commented 7 years ago

I'd prefer Gecko's current behavior, but I don't have strong opinion against Edge's, so if the webcompat impact is reasonable, I'm fine with Edge's behavior.

I have one concern that, per CSS Ruby spec, <rb>, <rt>, and <rtc> can appear outside <ruby>, and anonymous boxes would be built up automatically. In that case, only hiding <rp> in <ruby> may lead to some <rp>s stop working while they are expected to. That kind of automatic box-building is only supported in Firefox, so it is probably not a serious issue. <rt> outside <ruby> doesn't work in other browsers at all currently.

Another edge case would be using inline-blocks inside ruby, then its descendant <rp>s would suddently disappear with Edge's behavior. But that doesn't seem to be a sensible usecase.

kojiishi commented 7 years ago

The anonymous box case sounds reasonable. @zcorpan do we know someone to ask the opinion from Edge on this topic?

zcorpan commented 7 years ago

Using rp (or rt etc) outside ruby is invalid HTML. There is no use case for it.

Using the CSS ruby model with anonymous boxes is fine, but that has nothing to do with using the rp element not in a ruby element. span or something should be used.

While it is reasonable to think that it is expected that an rp not in ruby should still be hidden, I have not found any real-world page where that expectation holds. I have only found one page that is affected, and it had the opposite expectation.

Another edge case would be using inline-blocks inside ruby, then its descendant <rp>s would suddently disappear with Edge's behavior. But that doesn't seem to be a sensible usecase.

If the author explicitly sets display on rp, then that would be honored. Testing with http://software.hixie.ch/utilities/js/live-dom-viewer/saved/4714 shows that it is honored in Edge 13, but still hidden in IE 8..11. I can update the OP with this test case.

cc @gregwhitworth for opinions from Edge.

fantasai commented 3 years ago

I propose closing this issue as no change. We currently have interop across Gecko and Blink, I can't think of a use case for anything more complicated, and it's the simplest and most performant of the options presented.

annevk commented 3 years ago

Ah, so Blink changed something since https://github.com/whatwg/html/issues/2134#issue-193437288? Sounds good. Does Safari need a bug?

kojiishi commented 3 years ago

Ah, so Blink changed something since #2134 (comment)?

Yes, crbug.com/859416 in 2018.

annevk commented 3 years ago

cc @rniwa

zcorpan commented 3 years ago

This test covers this (through innerText, I don't know if there's a more direct test currently):

Lone <rp> ("<div><rp>abc</rp>") https://wpt.fyi/results/html/dom/elements/the-innertext-idl-attribute/getter.html?label=experimental&label=master&aligned

zcorpan commented 3 years ago

WebKit bug https://bugs.webkit.org/show_bug.cgi?id=44515