-
Notifications
You must be signed in to change notification settings - Fork 661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[css-text] text-align: match-parent on the root element with direction: rtl doesn't match browsers #6542
Comments
I think so.
Is there any particular reason it would be difficult to fix the browsers? From a theoretical / author point of view, the specified behavior makes more sense, so I'd rather not give up on it too easily.
Isn't this clear enough:
Especially given that clicking through the definitions of start and end to css-writing-modes will tell you this about
and this about
I don't mind clarifying if it's not, but I'd rather avoid redundant normative text, and it does seem clear to me already. |
I don't expect it to be particularly hard to change implementations. What worries me more is getting 3 different behaviors and then it's never fixed in the other 2 browsers because it's too low prio. A literal reading allows any behavior so long as the computed value is either left or right. |
If it only said
I'd agree with you, but right before that there's
which doesn't seem to allow "any behavior so long as the computer value is either left or right", but calls for a specific way to find whether it's left or right. At least as far as I can tell. Does it not? |
Do we have any usage numbers on this case? My expectation would be that using it on the root would be pretty rare, but that when it is used there, the specified behavior does make more sense. However, if it's hardly even used, maybe it doesn't matter too much and we could indeed take the quickest path to interop? |
If it doesn't matter too much, then having interop or not doesn't matter either. I'd rather the spec defined reasonable, expected behavior so that when the relevant bits of code get rewritten they get rewritten to sensible behavior not some random "shortest path to interop on an insignificant problem back in 2022" behavior. |
Proposal: no change to spec, land the testcase as-is. @zcorpan do you have any objection to this? |
I disagree, getting interop on the details even if the details are by themselves not important makes for a robust and predictable platform where developers can test what happens in one UA and expect it to work the same in others. Specifying something that no UA implements now means the first to conform will make interop worse and risk breaking some web content. I object to this. Ways to resolve my objection:
|
For the record gecko behavior is intentional, see: // on the root <html> element we should still respect the dir
// but the parent dir of that element is LTR even if it's <html dir=rtl>
// and will only be RTL if certain prefs have been set.
// In that case, the default behavior here will set it to left,
// but we want to set it to right -- instead set it to the default (`start`),
// which will do the right thing in this case (but not the general case)
if _context.builder.is_root_element {
return TextAlignKeyword::Start;
} |
The CSS Working Group just discussed The full IRC log of that discussion<TabAtkins> Topic: text-align: match-parent<TabAtkins> florian: match-parent on text-align does as the name implies, matches the parent's alignment <TabAtkins> florian: Different form just inheriting, as the meanign of start and end might have switched if the direction switches. With match-parent it doesn't flip, it def matches the parent <TabAtkins> florian: So the question is what to do on the root. The spec has an answer that I think makes sense, but doesn't have interop. <TabAtkins> florian: But not sure I'm aware of significant real problems triggered by this, so if we have a sensible behavior in the spec that doesn't cause real issues I think it's okay to leave it as-is and consider non-compliance a bug, but zcorpan didn't see it that way <TabAtkins> fantasai: zcorpan wanted us to either change the spec to match impls, or get a commitment from browser engines that they want to fix this bug <TabAtkins> fantasai: My personal take is that this is a very low-prio fix, but it should be considered a bug so when someone is fixing that area of the code they could fix it too. <TabAtkins> fantasai: Don't think we should require anyone to prioritize fixing it. Super low prio, possibly lowest prio I've ever seen. But don't think we should change the spec, I think the spec is more correct. <TabAtkins> astearns: Assume there's not bugs filed on this? <TabAtkins> florian: Not sure. <TabAtkins> astearns: So part of zcorpan's request is to get bugs filed. I agree with him. <TabAtkins> fantasai: I can take an action to make sure bugs are filed. <TabAtkins> astearns: And once bugs are filed, we'll see if we can get evals from impls on the bugs themselves. <TabAtkins> astearns: But like fantasai said, don't think a timely fix is strictly required for this. <TabAtkins> fantasai: Well is it okay to close the bug, with the understanding that we have bugs filed and impls plan to fix it at some point? <TabAtkins> astearns: Right, let's file the bugs and get to the next part <TabAtkins> emilio: Gecko behavior here is intentional. I'd need to investigate why it's a special case, I didn't write the code. <TabAtkins> florian: That's relevant, if browsers have specific reasons for differeing from the spec it would be good to report so we can see if the spec should reflect that. But if it's just accidental we should know that too, so we can be confident of keeping the current spec. <TabAtkins> astearns: So next step is writing bugs. |
Is that spec compliant? Unless I'm confused, that seems to go against https://www.w3.org/TR/css-writing-modes-3/#icb Either way, the keyword that gecko resolves to is |
@frivoal propagation to the icb is done after style resolution, though, so it can't really be used to deal with this. We could use the root element's writing-mode itself, but that wouldn't match the spec either because the principal writing mode is propagated from the body (and we don't have the body style when computing the root style for obvious reasons, you need the root style for the I tracked that bit of code down through blame. Reasoning for our behavior is here: Maybe the spec didn't say anything about the ICB back then? I think making it compute to start is the most reasonable thing FWIW. |
https://bugzilla.mozilla.org/show_bug.cgi?id=1341714#c25 is additional conversation here. |
A third way to resolve my objection is to specify what Gecko does and get sign-off from at least one of WebKit and Chromium that they want to match Gecko. |
I think the problem with that is that If that's unacceptable then I'd rather go with the Blink/WebKit behavior than Firefox, because at least it inherits as an absolute alignment, and having it resolve against the default directionality (LTR) at least has some kind of logic to it. |
Chromium seems to match Firefox's behavior of using |
https://bugs.webkit.org/show_bug.cgi?id=241164 Reviewed by Myles C. Maxfield. The spec says the initial containing block's direction should be used when the element has no parent. Regarding the computed value, Chrome & Firefox computes to `start` for this case. This may change in w3c/csswg-drafts#6542 to `left`/`right`. Test: imported/w3c/web-platform-tests/css/css-text/text-align/text-align-match-parent-root-rtl.html * LayoutTests/TestExpectations: * Source/WebCore/style/StyleBuilderConverter.h: (WebCore::Style::BuilderConverter::convertTextAlign): Canonical link: https://commits.webkit.org/251211@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@295120 268f45cc-cd09-0410-ab3c-d52691b4dbfc
I've implemented this in WebKit to return |
The CSS Working Group just discussed
The full IRC log of that discussion<fantasai> topic: [css-text] text-align: match-parent on the root element with direction: rtl doesn't match browsers<fantasai> github: https://github.com//issues/6542 <emilio> LOL <emilio> fantasai: seems we currently have all browsers matching <emilio> ... I don't think this is the ideal behavior but it's not terrible <emilio> ... and it's a situation that is almost never going to happen in a real page <emilio> ... unless somebody did something super weird by accident <emilio> ... given we currently seem all engines compute to start <emilio> ... which is Firefox's behavior <emilio> ... I'm happy to resolve to that <emilio> ... I think the right answer is to compute to right <emilio> ... because it otherwise resolves to an absolute side <emilio> florian: so proposal is computing to start <emilio> ... behavior is the same as the spec asked for <fantasai> on single-direction pages <fantasai> emilio: I would rather to this, mostly because of how it interacts with writing-mode propagation <fantasai> emilio: just compute to start value <fantasai> Rossen_: any objections? <fantasai> RESOLVED: text-align: match-parent computes to 'start' on the root element See official minutes |
…-align:match parent, a=testonly Automatic update from web-platform-tests Add tests for boundary condition of text-align:match parent See w3c/csswg-drafts#6542 -- wpt-commits: 60a2b189b81354c7efdc70e6da0d142e81a23b08 wpt-pr: 37693
…-align:match parent, a=testonly Automatic update from web-platform-tests Add tests for boundary condition of text-align:match parent See w3c/csswg-drafts#6542 -- wpt-commits: 60a2b189b81354c7efdc70e6da0d142e81a23b08 wpt-pr: 37693
…r implementation simplicity. w3c#6542
See this test: web-platform-tests/wpt#30175
If I understand correctly, a used value of 'direction: rtl' on the root element is propagated to the ICB per https://drafts.csswg.org/css-writing-modes-3/#icb
Then, https://drafts.csswg.org/css-text/#valdef-text-align-match-parent says
The initial value of text-align is 'start', so I guess the inherited value for the root element has to be 'start'. Therefore, it looks at the 'direction' of the ICB, which is propagated from the root element, and is thus 'rtl'. Therefore text-align should compute to 'right'.
Here are the results of the test:
Is my reading of the spec correct?
Should the spec be changed to side with either Firefox or Safari/Chrome?
Also, the spec only says that the computed value is "either left or right", which doesn't say which value to use. I assume a mapping where direction: ltr -> left and direction: rtl -> right, but the spec should say so explicitly.
The text was updated successfully, but these errors were encountered: