Last modified: 2013-04-08 11:02:00 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T30693, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 28693 - Implement command for double directionality in CSSJanus.php
Implement command for double directionality in CSSJanus.php
Status: RESOLVED WONTFIX
Product: MediaWiki
Classification: Unclassified
ResourceLoader (Other open bugs)
1.18.x
All All
: Unprioritized enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
: i18n
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-04-25 11:57 UTC by Niklas Laxström
Modified: 2013-04-08 11:02 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Niklas Laxström 2011-04-25 11:57:31 UTC
Can we implement for resource loader, besides @noflip, something like @doubleflip which would generate css for both ltr and rtl simultaneously. For example
/* @doubleflip */
.foo { float: left; }

->

[dir=ltr] .foo { float: left; }
[dir=rtl] .foo { float: right; }
Comment 1 Roan Kattouw 2011-04-25 12:00:14 UTC
CC Krinkle

We would need this kind of feature to make pages with mixed directionality play
nice (i.e. pages where the page as a whole is RTL but some things are inside a
<div dir="ltr"> or vice versa).
Comment 2 Krinkle 2011-04-26 21:13:39 UTC
Sounds like a plausible situation.

Do we haved such a scenario currently somewhere and/or is it blocking near development that needs this ? (trying to determine a priority)
Comment 3 Krinkle 2011-06-18 00:46:07 UTC
Note that this will most likely mess with the cascading part of "CSS" as those rules will override things since they are more specific and thus are given more points by the style parser of the browser.

ie. 


.foo { float: none; margin: 0 auto; width: 500px;  }

/* @doubleflip */
div { float: left; margin: 0; }

normally <div class="foo"> will be centered because .foo is more specific (more points). but with @doubleflip adding some kind of directionality (ie. [dir=rtl] and [dir=ltr]) it could end up more specific.
Comment 4 Robin Pepermans (SPQRobin) 2011-07-11 15:19:30 UTC
It would be useful for e.g. the Translate extension where the direction depends on the language of the interface message (see e.g. r91881 where I added classes named *-ltr, *-rtl added by Language->getDir() in PHP.

However, overall I don't think @doubleflip would be needed, Translate is more an exceptional extension in terms of directionality.
Core MW is OK without it: I added sitedir-ltr/rtl (on body) for the site content language, and mw-content-ltr/rtl classes for the page content language, and that seems to be enough for most things. (I also had to add rules like .mw-content-ltr .mw-content-rtl { ... } to circumvent the CSS priority system, for cases where there was different directionality within the content.)

I think it would be more useful if there was something like
/* @flipclasses */ .class-ltr { margin-left:1em; }
that would generate
.class-ltr { margin-left:1em; }
and
.class-rtl { margin-right:1em; }
Comment 5 Niklas Laxström 2011-07-11 16:05:29 UTC
I'm leaning to WONTFIX, it doesn't seem to be as useful as I originally thought.
Comment 6 Robin Pepermans (SPQRobin) 2011-07-11 17:55:40 UTC
Yes, however, thinking about it, what I wrote above would be quite useful (imho):

/* @flipclasses */ .class-ltr { margin-left:1em; }
->
.class-ltr { margin-left:1em; }
+
.class-rtl { margin-right:1em; }
Comment 7 Krinkle 2011-08-05 06:47:05 UTC
 I still don't understand why one must introduce new classes related to directionality, this makes styling a page a lot harder. When styling one should not be aware of directionality.

If it's possible to override a class in PHP from "foo" to "foo-ltr" or "foo-rtl", isn't it just as easy to let PHP output '<div class="foo" dir="rtl">' or '<div class="foo" dir="ltr">' ?
Comment 8 Niklas Laxström 2011-08-05 07:08:05 UTC
Heard in the i18n talk: (text) directionality should be in html.

Anyway, due how css is, one needs to be aware of the directionality.
Comment 9 Krinkle 2011-08-08 07:33:17 UTC
I agree it should be in the HTML, in the (semantic) attribute for "dir".

So there'd be <foo class="bar" dir="ltr"> and/or <foo class="bar" dir="rtl"> on a page.

Styling could be done now as:

.bar { font-size: 85%; background: #f2f2f2; }

/* @noflip */ .bar[dir=rtl] { margin-right: 1em; }
/* @noflip */ .bar[dir=ltr] { margin-left: 1em; }

One extra gain is that later overrides will always work in LTR and in RTL.
For example, if someone wants to change some of these stylings, ".bar { margin-left: 2em; }" will not work (even if it's after the above), because ".bar[dir=...]" is more specific and thus still overrides that later rules. 
The override would have to include the "dir" parts.

This could be automated with:

/* @addflipped */ .bar[dir=ltr] { margin-left: 1em; }
Comment 10 Krinkle 2011-08-08 07:40:28 UTC
The only downside in comment 9 is that it messes with the CSS cascading rules. Not caused by "@addflipped" but caused by the fact that it uses an additional directionality selector.

Perhaps a cleaner solution would be to use both.

--

HTML:

<foo class="bar bar-ltr" dir="ltr"> + <foo class="bar bar-rtl" dir="rtl">
* The "dir"-attribute for semantics and other power rules
* The "bar"-class for general application of the design independent from directionality
* The  "bar-xxx"-class for direction specific rules

CSS:

.bar { font-size: 85%; background: #f2f2f2; }

/* @noflip */ .bar-ltr { margin-right: 1em; }
/* @noflip */ .bar-rtl { margin-left: 1em; }

CSS (proposed syntax after this bug is fixed?)

.bar { font-size: 85%; background: #f2f2f2; }
.bar-ltr { margin-right: 1em; }

--

This would work similar to the way it replaces -ltr in background images ( "background-image: url(foo-ltr.png)" ). Except that it would add that selector group, rather than replacing it.

The main advantage here is that it doesn't mess with the cascading of the CSS (both are class-level selectors). And doesn't make it harder to style them since "bar" is still there.
Comment 11 Bugmeister Bot 2011-08-19 19:12:58 UTC
Unassigning default assignments. http://article.gmane.org/gmane.science.linguistics.wikipedia.technical/54734
Comment 12 Niklas Laxström 2011-09-20 09:14:03 UTC
Is there enough code that would benefit to justify implementing this?

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links