Daniel Friesen has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/63267


Change subject: Move our meta charset so it's placed above the title.
......................................................................

Move our meta charset so it's placed above the title.

It's recommended for the meta charset to be placed before the <title> since
<title> contains text which is inside the character set defined by the meta 
charset.

Use of meta charset inside XHTML also seems to be redundant, not recommended,
and is very likely completely ignored.

Change-Id: I335b0598a9615540dc5e917682508b4a8d32d96e
---
M includes/OutputPage.php
1 file changed, 18 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/67/63267/1

diff --git a/includes/OutputPage.php b/includes/OutputPage.php
index af3a452..e078993 100644
--- a/includes/OutputPage.php
+++ b/includes/OutputPage.php
@@ -2475,7 +2475,7 @@
         * @return String: The doctype, opening "<html>", and head element.
         */
        public function headElement( Skin $sk, $includeStyle = true ) {
-               global $wgContLang;
+               global $wgContLang, $wgMimeType;
 
                $userdir = $this->getLanguage()->getDir();
                $sitedir = $wgContLang->getDir();
@@ -2496,10 +2496,21 @@
                        $ret .= "$openHead\n";
                }
 
+               if ( !Html::isXmlMimeType( $wgMimeType ) ) {
+                       // Add <meta charset="UTF-8">
+                       // This should be before <title> since it defines the 
charset used by
+                       // text including the text inside <title>.
+                       // The spec recommends defining XHTML5's charset using 
the XML declaration
+                       // instead of meta.
+                       // 
http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#attr-meta-http-equiv-content-type
+                       // 
http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#charset
+                       $ret .= Html::element( 'meta', array( 'charset' => 
'UTF-8' ) );
+               }
+
                $ret .= Html::element( 'title', null, $this->getHTMLTitle() ) . 
"\n";
 
                $ret .= implode( "\n", array(
-                       $this->getHeadLinks( null, true ),
+                       $this->getHeadLinks(),
                        $this->buildCssLinks(),
                        $this->getHeadScripts(),
                        $this->getHeadItems()
@@ -3128,11 +3139,11 @@
        }
 
        /**
-        * @param bool $addContentType Whether "<meta>" specifying content type 
should be returned
+        * @param $unused
         *
         * @return array in format "link name or number => 'link html'".
         */
-       public function getHeadLinksArray( $addContentType = false ) {
+       public function getHeadLinksArray( $unused = null ) {
                global $wgUniversalEditButton, $wgFavicon, $wgAppleTouchIcon, 
$wgEnableAPI,
                        $wgSitename, $wgVersion,
                        $wgFeed, $wgOverrideSiteFeed, $wgAdvertisedFeedTypes,
@@ -3142,12 +3153,6 @@
                $tags = array();
 
                $canonicalUrl = $this->mCanonicalUrl;
-
-               if ( $addContentType ) {
-                       # More succinct than <meta http-equiv=Content-Type>, 
has the
-                       # same effect
-                       $tags['meta-charset'] = Html::element( 'meta', array( 
'charset' => 'UTF-8' ) );
-               }
 
                $tags['meta-generator'] = Html::element( 'meta', array(
                        'name' => 'generator',
@@ -3367,12 +3372,12 @@
 
        /**
         * @param $unused
-        * @param bool $addContentType Whether "<meta>" specifying content type 
should be returned
+        * @param $unused2
         *
         * @return string HTML tag links to be put in the header.
         */
-       public function getHeadLinks( $unused = null, $addContentType = false ) 
{
-               return implode( "\n", $this->getHeadLinksArray( $addContentType 
) );
+       public function getHeadLinks( $unused = null, $unused2 = null ) {
+               return implode( "\n", $this->getHeadLinksArray() );
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/63267
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I335b0598a9615540dc5e917682508b4a8d32d96e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Daniel Friesen <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to