From d6b4d3c537fa5944c2f234213b20037fe3192d62 Mon Sep 17 00:00:00 2001 From: Gilles Dubuc Date: Mon, 25 May 2015 16:04:57 +0200 Subject: [PATCH] Add ability to load plain CSS files at the bottom Currently all styles modules added to the page using addModuleStyles are put into the head, regardless of their "position" value. Bug: T97420 Change-Id: Ie4287e17d6f298cc63f42f257b1f67ee36961b77 --- includes/OutputPage.php | 24 ++++++- .../ResourceLoaderFileModule.php | 3 +- .../ResourceLoaderImageModule.php | 18 +++++ .../resourceloader/ResourceLoaderModule.php | 17 +++++ resources/Resources.php | 65 +++++++++++++++---- 5 files changed, 113 insertions(+), 14 deletions(-) diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 770cf47f6e..a3a5a2730a 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -591,6 +591,19 @@ class OutputPage extends ContextSource { * @return array Array of module names */ public function getModuleStyles( $filter = false, $position = null ) { + // T97420 + $resourceLoader = $this->getResourceLoader(); + + foreach ( $this->mModuleStyles as $val ) { + $module = $resourceLoader->getModule( $val ); + + if ( $module instanceof ResourceLoaderModule && $module->isPositionDefault() ) { + $warning = __METHOD__ . ': style module should define its position explicitly: ' . $val . ' ' . get_class( $module ); + wfDebugLog( 'resourceloader', $warning ); + wfLogWarning( $warning ); + } + } + return $this->getModules( $filter, $position, 'mModuleStyles' ); } @@ -3008,11 +3021,17 @@ class OutputPage extends ContextSource { // Scripts "only" requests marked for bottom inclusion // If we're in the , use load() calls rather than