From ff490cc42a3818ce330ce336f9c59123f4f25270 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 18 Oct 2016 12:04:40 -0700 Subject: [PATCH] Add 'noflip' option on RL modules to disable CSSJanus 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 | 4 ++++ docs/extension.schema.v1.json | 4 ++++ includes/resourceloader/ResourceLoaderFileModule.php | 6 +++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/extension.schema.json b/docs/extension.schema.json index 84a404a2e2..e408d03b07 100644 --- a/docs/extension.schema.json +++ b/docs/extension.schema.json @@ -222,6 +222,10 @@ "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." } } }, diff --git a/docs/extension.schema.v1.json b/docs/extension.schema.v1.json index 94999270a1..6d48a06877 100644 --- a/docs/extension.schema.v1.json +++ b/docs/extension.schema.v1.json @@ -222,6 +222,10 @@ "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." } } }, diff --git a/includes/resourceloader/ResourceLoaderFileModule.php b/includes/resourceloader/ResourceLoaderFileModule.php index 2dcc841e92..07649e3449 100644 --- a/includes/resourceloader/ResourceLoaderFileModule.php +++ b/includes/resourceloader/ResourceLoaderFileModule.php @@ -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; } /** -- 2.20.1