Commit graph

26 commits

Author SHA1 Message Date
Roan Kattouw
2a428a1755 Follow-up 23cfe1bba: harmonize image embedding CSS
23cfe1bba changed ResourceLoaderImageModule::getCssDeclarations(),
but contrary to the documentation did not synchronize it with
mediawiki.mixins.less. This commit does that.

This commit brings the -o-linear-gradient rule back (this time with
a comment that explains why it's there), and removes the
-webkit-linear-gradient rules from mediawiki.mixins.less
and CSS code that copypasted it.

Change-Id: Ia7e9738d90919248748e6968192bf02e420cddd0
2015-12-14 16:00:49 -08:00
Ed Sanders
23cfe1bba6 Remove vendor prefix support for SVG embedding
Also remove the -o- prefix which uses 'fallback', as without
that rule it will use 'fallback' anyway.

Bug: T118815
Change-Id: I6a6e3b24b1cda55dfa9675743c39d21e792275c7
2015-11-17 02:40:05 +00:00
Timo Tijhof
afcfc3290c resourceloader: Consistently refer to the framework as ResourceLoader
Change-Id: Ia59e4eac9662723e80d62f7cfcb9e4292e3ee4de
2015-10-28 03:24:40 +00:00
Timo Tijhof
9435cd81b0 resoureloader: Consolidate styles-only queue at the top
This effectively reverts d6b4d3c537 and declines T97420.
This was previously attempted in b7c0e537eb.

Drop support for position "bottom" for addModuleStyles().
This feature was only recently introduced with the intent
to optimise page load performance, but had an adverse effect.

It increases chances of FOUC due to late discovery of these styles.
It also caused minor problems for some gadgets and extensions
that did not or were unable to set these flags. Some mobile
code was introduced around the same time as this feature and
was never given position=top.

Stylesheets that don't affect initial render or are only needed
on interaction should be loaded via addModules() instead; which
is handled by the asynchronous loader in JavaScript.

Change-Id: Ib9821b7b87cfc8a59062bb6ca358974fdb01ced1
2015-10-27 03:39:34 +00:00
paladox
dca469bb87 Fix phpcs warnings
Bug: T102614
Change-Id: Iecea365f83bbb0c336b58f1cfdebfc9b1112087e
2015-06-18 20:13:37 +00:00
umherirrender
d8821f2b0b Fixed spacing
- Removed space after casts
- Removed spaces in array index
- Added spaces around string concat
- Added space after words: switch, foreach
- else if -> elseif
- Removed parentheses around require_once, because it is not a function
- Added newline at end of file
- Removed double spaces
- Added spaces around operations
- Removed repeated newlines

Bug: T102609
Change-Id: Ib860222b24f8ad8e9062cd4dc42ec88dc63fb49e
2015-06-17 20:22:32 +00:00
Roan Kattouw
2e1916f96d ResourceLoaderImageModule: Fix incorrect documentation
The docs claimed that you had to do something like
'images' => array( 'filename.svg' => array( 'name' => 'foo' ) )
but what you actually need to do is
'images' => array( 'foo' => array( 'file' => 'filename.svg' ) )

Change-Id: Idca2d5c58e4d9fcf008ef5cfe7f8ce77b996c203
2015-06-16 19:37:39 -07:00
Bartosz Dziewoński
c4b6fd313d ResourceLoaderImageModule: Add missing doc stuffs
Follow-up to 1fc57830e2.

Change-Id: I66985fe2edc4d0e92aebcdb39cd56d212fd3270c
2015-06-06 00:38:06 +02:00
Timo Tijhof
64ecc77422 resourceloader: Remove redundant getModifiedTime implementations
Follows-up f37cee996e which replaced the getHashMtime() and
getDefinitionMtime() methods with dummies that always return 1.

These getModifiedTime() implementations were only tracking the
definition summary or custom hash, which is already tracked
by getVersionHash().

Notes:
* SpecialCharacterDataModule: This one was odd as it was tracking
  both the mtime *and* the file contents.

* UserCSSPrefsModule/UserOptionsModule: Remove redundant caching.
  Already taken care of by getVersionHash() as of f37cee996e.

Bug: T94074
Change-Id: I6e37c3c2f85ef4599a8643b0efabc18de2f51ec4
2015-06-03 14:27:38 +00:00
Bartosz Dziewoński
1fc57830e2 OOUI theme support
* Split off OOjs UI's module definitions to a separate file from
  Resources.php.
* Extend ResourceLoaderImageModule to support per-skin images and
  variants.
* Allow skins to specify their preferred OOjs UI theme using new
  skin registry attribute 'SkinOOUIThemes'. The default remains the
  'mediawiki' theme, 'apex' can also be chosen now.
* Implement custom ResourceLoaderOOUIImageModule which implements some
  special sauce required to shoehorn OOjs UI image set definitions into
  ResourceLoaderImageModule with skin-specific styles support.

Bug: T100895
Change-Id: I3fbacbce95126a4cc29221352f3ef846f41e7b1b
2015-05-31 22:55:13 +00:00
Gilles Dubuc
d6b4d3c537 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
2015-05-25 21:10:14 +00:00
Bartosz Dziewoński
9bb0c2ac4e resourceloader: Rename ResourceLoaderImageModule::ensureStuffLoaded to loadFromDefinition
The name was a result of my having a bad day when I wrote that code.

Change-Id: I6b729764a963563f0820b8063c3d04f6e676c61e
2015-05-24 11:22:32 +00:00
Bartosz Dziewoński
9e5c3e9521 Use ResourceLoaderImageModule to serve icons for OOjs UI
Benefits:
* Full per-language icons support. Icons that differ for each language
  (such as the 'Bold' icon) will now always display correctly
  according to user interface language, even on old browsers.
* MediaWiki UI icons support. When the 'mediawiki.ui.icon' module is
  loaded, you can use syntaxes such as below to display any OOUI icons
  (from the packs that were loaded) without involving OOUI itself.
    <div class="mw-ui-icon mw-ui-icon-before mw-ui-icon-check">OK</div>
    <div class="mw-ui-icon mw-ui-icon-after mw-ui-icon-check">OK</div>
    <div class="mw-ui-icon mw-ui-icon-element mw-ui-icon-check">OK</div>

Summary of changes:
* Resources.php:
  * Remove icons CSS files. Include image data JSON files instead.
  * Split the images from 'oojs-ui.styles' module to separate ones.
* OutputPage: Update enableOOUI() method for newly split modules.
* ResourceLoaderImageModule: Make it possible to load image data from
  a JSON file.
* update-oojs-ui.sh: Copy source files rather than distribution for
  icon packs.

This is not an improvement when it comes to code quality, though :(
Issues include some nasty code duplication, using "source code" (image
definitions) from OOUI rather than just distribution files, and hacky
methods to load image data from JSON files live.

Bug: T92551
Change-Id: Id369ecaec7048dcf68ba1e4df748362760533782
2015-04-28 13:48:30 +00:00
Bartosz Dziewoński
807c08295a ResourceLoaderImageModule: Implement cache invalidation
Bug: T94733
Change-Id: I6ac2ef8d897813e560daa133b89a7932f8c1a362
2015-04-14 21:31:19 +02:00
Bartosz Dziewoński
2b696972a5 ResourceLoaderImageModule: Remove stupid TODO
Change-Id: I36ade1713b593504a34b1ec92bc4d9e536aa262a
2015-04-01 21:36:08 +02:00
Bartosz Dziewoński
cd73f6e788 ResourceLoaderImageModule: Remove bogus CSSJanus call
We explicitly do not want to use CSSJanus flipping here, as
ResourceLoaderImage has a separate and more sophisticated mechanism
for choosing the right image for given language. This was a no-op,
since there were no flippable paths in the output at this point.

Change-Id: Ieff5f21653504a28afe3d4c110a52d8b06fc6a07
2015-04-01 19:10:03 +00:00
Bartosz Dziewoński
7aeadb7f68 resourceloader: Throw InvalidArgumentException for invalid constructor arguments
(But not for exceptions about missing files.)

Per Legoktm's comments on 8edbfb5feb.

Change-Id: I725f846476d2d97d3d820bc22674f7b5aab812bb
2015-03-30 19:15:36 +02:00
Bartosz Dziewoński
fca3887393 ResourceLoaderImageModule: Rename 'image' in descriptors to 'file'
Like in OOjs UI. Less confusing. No one is using this yet.

Bug: T93669
Change-Id: Ib1c9af96b46ba660b3697d272129e071da1fdf18
2015-03-29 19:38:14 +02:00
Bartosz Dziewoński
8c9ff9c46c ResourceLoaderImageModule: Remove 'type' stuff
Provides no value and makes the definitions uglier. Also, the
implementation sucks.

This is a breaking change, but ResourceLoaderImageModule was not in
any public release yet.

Submitted patches to fix two usages in extensions:
* Gather: I371209afe7b48e7c215ea9912826d4eb2cacf4e5
* MobileFrontend: I1963f5fe759c3a031220157d3a6f0f3b42bc5426

Bug: T94073
Change-Id: I36cfdb09bb203b8d9958e6016447e446dd6ff78b
2015-03-29 19:37:11 +02:00
Bartosz Dziewoński
8edbfb5feb ResourceLoaderImageModule: Implement CSS selector templates
Instead of a 'prefix', a 'selector' can be specified, with a string
containing a simple template to use for CSS selector. For example:

    'selector' => '.mw-ui-icon-{name}'

'prefix' continues to work as before.

When using variants, one might want to provide separate
'selectorWithoutVariant' and 'selectorWithVariant' options.

Available variables are {prefix}, {type}, {name}, and {variant}.

Bug: T78215
Change-Id: I99ccaf25e8d24fed5afd0c4b770d2f389789ce4b
2015-03-29 17:25:02 +00:00
Bartosz Dziewoński
5042d260ce ResourceLoaderImageModule: Improve PHP 5.3 compatibility
In PHP 5.3.x and older, the isset() check in code example below will
yield true. In PHP 5.4 and later, and HHVM, it will correctly yield
false. http://3v4l.org/8p3hm

  $options = 'foo';
  isset( $options['bar'] );

Let's not depend on this behavior here.

Change-Id: I67e83af8afe85b3ddfb5db0009759b8ac5bb7d67
2015-03-29 18:29:41 +02:00
Bartosz Dziewoński
a71167895c ResourceLoaderImageModule: Synchronize CSS with .background-image-svg LESS mixin
Bug: T87504
Change-Id: I790bd953fabbd4ff03f15c94fe101e2f65891520
2015-03-24 18:54:04 +00:00
Kunal Mehta
f63bbdeb08 Fix phpcs warning and errors in includes/resourceloader
Mainly breaking long lines

Change-Id: Ide37c81d156348cfb8a010043d79eaf80f95fded
2015-03-14 18:52:45 -07:00
Bryan Davis
1157312f1e Guard against unset key access in ResourceLoaderImageModule
Seen in production error logs:
  Undefined index: icon in ResourceLoaderImageModule.php on line 162
  Undefined index: icon in ResourceLoaderImageModule.php on line 185

Change-Id: I44e16563bda2dcc0be3c9694ed2b09d20b3d7468
2015-01-09 18:58:46 +00:00
jdlrobson
4cd748a006 ResourceLoaderImageModule: Allow use on mobile
Change-Id: Ic7913aa1a1e1fb8d3742503cbe8a6cb3427fc826
2014-12-10 23:34:40 +00:00
Bartosz Dziewoński
aa00a3e838 ResourceLoaderImageModule for icons
ResourceLoaderImageModule needs a set of SVG files and some data in
the module definition, and produces styles for a set of CSS classes,
one for each image, optionally with differently colored variants,
generated in SVG and PNG, data-URI-embedded if possible, compatible
with all browsers, and generally slick.

The intended usage is to ship icon libraries with MediaWiki that can
be used throughout the pages with no additional code.

* ResourceLoaderImageModule implements all of the logic for data
  parsing and CSS generation.
* ResourceLoaderImage implements the logic for SVG image colorization
  (for variants) and rasterization.
* ResourceLoader and ResourceLoaderContext were extended to serve a
  new kind of load.php request that delivers a single image file. This
  is used for fallback PNG images served to browsers that don't
  understand SVG.

See change Ic6a76bfb for a demo.

Bug: T76473
Co-Authored-By: Trevor Parscal <trevorparscal@gmail.com>
Co-Authored-By: Bartosz Dziewoński <matma.rex@gmail.com>
Change-Id: Idf6ff4eb8e94f45946f15d283d34108b881fae6e
2014-12-09 20:11:07 +01:00