Merge "Work around T87871 to avoid double-loading OOjs UI PHP styles"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 11 Feb 2016 03:51:16 +0000 (03:51 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 11 Feb 2016 03:51:16 +0000 (03:51 +0000)
includes/OutputPage.php
resources/ResourcesOOUI.php
resources/src/oojs-ui-styles-skip.js [new file with mode: 0644]

index 317c126..f161cb3 100644 (file)
@@ -4088,5 +4088,8 @@ class OutputPage extends ContextSource {
                        'oojs-ui.styles.textures',
                        'mediawiki.widgets.styles',
                ) );
+               // Used by 'skipFunction' of the four 'oojs-ui.styles.*' modules. Please don't treat this as a
+               // public API or you'll be severely disappointed when T87871 is fixed and it disappears.
+               $this->addMeta( 'X-OOUI-PHP', '1' );
        }
 }
index 647efa2..851b1c7 100644 (file)
@@ -68,9 +68,6 @@ return call_user_func( function () {
                        'es5-shim',
                        'oojs',
                        'oojs-ui.styles',
-                       'oojs-ui.styles.icons',
-                       'oojs-ui.styles.indicators',
-                       'oojs-ui.styles.textures',
                        'mediawiki.language',
                ),
                'targets' => array( 'desktop', 'mobile' ),
@@ -81,6 +78,14 @@ return call_user_func( function () {
                'styles' => 'resources/src/oojs-ui-local.css', // HACK, see inside the file
                'skinStyles' => $getSkinSpecific( 'core' ),
                'targets' => array( 'desktop', 'mobile' ),
+               // ResourceLoaderImageModule doesn't support 'skipFunction', so instead we set this up so that
+               // this module is skipped together with its dependencies. Nothing else depends on these modules.
+               'dependencies' => array(
+                       'oojs-ui.styles.icons',
+                       'oojs-ui.styles.indicators',
+                       'oojs-ui.styles.textures',
+               ),
+               'skipFunction' => 'resources/src/oojs-ui-styles-skip.js',
        );
 
        // Deprecated old name for the module 'oojs-ui-core.styles'.
diff --git a/resources/src/oojs-ui-styles-skip.js b/resources/src/oojs-ui-styles-skip.js
new file mode 100644 (file)
index 0000000..57c905a
--- /dev/null
@@ -0,0 +1,9 @@
+/*!
+ * Skip function for OOjs UI PHP style modules.
+ *
+ * The `<meta name="X-OOUI-PHP" />` is added to pages by OutputPage::enableOOUI().
+ *
+ * Looking for elements in the DOM might be expensive, but it's probably better than double-loading
+ * 200 KB of CSS with embedded images because of bug T87871.
+ */
+return !!jQuery( 'meta[name="X-OOUI-PHP"]' ).length;