Add 'noflip' option on RL modules to disable CSSJanus
authorBrion Vibber <brion@pobox.com>
Tue, 18 Oct 2016 19:04:40 +0000 (12:04 -0700)
committerBrion Vibber <brion@pobox.com>
Tue, 18 Oct 2016 20:36:27 +0000 (13:36 -0700)
Should be useful for cases where we pull in an external library
that already manages RTL flipping in its styles, and CSSJanus
does the wrong thing without extra markup.

Example:

  'ext.tmh.video-js' => $baseExtensionResource + [
      'scripts' => 'resources/videojs/video.js',
      'styles' => 'resources/videojs/video-js.css',
      'noflip' => true,
      ...
  ],

Bug: T148572
Bug: T148565
Change-Id: Icbad20d8a6e9a0d354ad159f5816f4fb67cc2775

docs/extension.schema.json
docs/extension.schema.v1.json
includes/resourceloader/ResourceLoaderFileModule.php

index 84a404a..e408d03 100644 (file)
                                                                        "items": {
                                                                                "type": "string"
                                                                        }
+                                                               },
+                                                               "noflip": {
+                                                                       "type": "boolean",
+                                                                       "description": "Whether to skip CSSJanus LTR-to-RTL flipping for this module. Recommended for styles imported from libraries that already properly handle their RTL styles. Default is false, meaning CSSJanus will be applied on RTL-mode output."
                                                                }
                                                        }
                                                },
index 9499927..6d48a06 100644 (file)
                                                                        "items": {
                                                                                "type": "string"
                                                                        }
+                                                               },
+                                                               "noflip": {
+                                                                       "type": "boolean",
+                                                                       "description": "Whether to skip CSSJanus LTR-to-RTL flipping for this module. Recommended for styles imported from libraries that already properly handle their RTL styles. Default is false, meaning CSSJanus will be applied on RTL-mode output."
                                                                }
                                                        }
                                                },
index 2dcc841..07649e3 100644 (file)
@@ -128,6 +128,9 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
 
        protected $targets = [ 'desktop' ];
 
+       /** @var bool Whether CSSJanus flipping should be skipped for this module */
+       protected $noflip = false;
+
        /**
         * @var bool Whether getStyleURLsForDebug should return raw file paths,
         * or return load.php urls
@@ -277,6 +280,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
                                // Single booleans
                                case 'debugRaw':
                                case 'raw':
+                               case 'noflip':
                                        $this->{$member} = (bool)$option;
                                        break;
                        }
@@ -913,7 +917,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
         * @return bool
         */
        public function getFlip( $context ) {
-               return $context->getDirection() === 'rtl';
+               return $context->getDirection() === 'rtl' && !$this->noflip;
        }
 
        /**