LCOV - code coverage report
Current view: top level - parser/html - nsHtml5MetaScannerCppSupplement.h (source / functions) Hit Total Coverage
Test: output.info Lines: 17 22 77.3 %
Date: 2017-07-14 16:53:18 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* This Source Code Form is subject to the terms of the Mozilla Public
       2             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       3             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       4             :  
       5             : #include "nsISupportsImpl.h"
       6             : 
       7             : #include "mozilla/Encoding.h"
       8             : 
       9             : const Encoding*
      10           2 : nsHtml5MetaScanner::sniff(nsHtml5ByteReadable* bytes)
      11             : {
      12           2 :   readable = bytes;
      13           2 :   stateLoop(stateSave);
      14           2 :   readable = nullptr;
      15           2 :   return mEncoding;
      16             : }
      17             : 
      18             : bool
      19           2 : nsHtml5MetaScanner::tryCharset(nsHtml5String charset)
      20             : {
      21             :   // This code needs to stay in sync with
      22             :   // nsHtml5StreamParser::internalEncodingDeclaration. Unfortunately, the
      23             :   // trickery with member fields here leads to some copy-paste reuse. :-(
      24           4 :   nsAutoCString label;
      25           4 :   nsString charset16; // Not Auto, because using it to hold nsStringBuffer*
      26           2 :   charset.ToString(charset16);
      27           2 :   CopyUTF16toUTF8(charset16, label);
      28           2 :   const Encoding* encoding = Encoding::ForLabel(label);
      29           2 :   if (!encoding) {
      30           0 :     return false;
      31             :   }
      32           4 :   if (encoding == UTF_16BE_ENCODING ||
      33           2 :       encoding == UTF_16LE_ENCODING) {
      34           0 :     mEncoding = UTF_8_ENCODING;
      35           0 :     return true;
      36             :   }
      37           2 :   if (encoding == X_USER_DEFINED_ENCODING) {
      38             :     // WebKit/Blink hack for Indian and Armenian legacy sites
      39           0 :     mEncoding = WINDOWS_1252_ENCODING;
      40           0 :     return true;
      41             :   }
      42           2 :   mEncoding = encoding;
      43           2 :   return true;
      44             : }

Generated by: LCOV version 1.13