LCOV - code coverage report
Current view: top level - parser/html - nsHtml5Portability.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 21 48 43.8 %
Date: 2017-07-14 16:53:18 Functions: 8 15 53.3 %
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 "nsIAtom.h"
       6             : #include "nsString.h"
       7             : #include "jArray.h"
       8             : #include "nsHtml5Portability.h"
       9             : #include "nsHtml5TreeBuilder.h"
      10             : 
      11             : nsIAtom*
      12           1 : nsHtml5Portability::newLocalNameFromBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner)
      13             : {
      14           1 :   NS_ASSERTION(!offset, "The offset should always be zero here.");
      15           1 :   NS_ASSERTION(interner, "Didn't get an atom service.");
      16           1 :   return interner->GetAtom(nsDependentSubstring(buf, buf + length));
      17             : }
      18             : 
      19             : nsHtml5String
      20          19 : nsHtml5Portability::newStringFromBuffer(char16_t* buf,
      21             :                                         int32_t offset,
      22             :                                         int32_t length,
      23             :                                         nsHtml5TreeBuilder* treeBuilder)
      24             : {
      25          19 :   return nsHtml5String::FromBuffer(buf + offset, length, treeBuilder);
      26             : }
      27             : 
      28             : nsHtml5String
      29           1 : nsHtml5Portability::newEmptyString()
      30             : {
      31           1 :   return nsHtml5String::EmptyString();
      32             : }
      33             : 
      34             : nsHtml5String
      35           0 : nsHtml5Portability::newStringFromLiteral(const char* literal)
      36             : {
      37           0 :   return nsHtml5String::FromLiteral(literal);
      38             : }
      39             : 
      40             : nsHtml5String
      41           0 : nsHtml5Portability::newStringFromString(nsHtml5String string)
      42             : {
      43           0 :   return string.Clone();
      44             : }
      45             : 
      46             : jArray<char16_t,int32_t>
      47           0 : nsHtml5Portability::newCharArrayFromLocal(nsIAtom* local)
      48             : {
      49           0 :   nsAutoString temp;
      50           0 :   local->ToString(temp);
      51           0 :   int32_t len = temp.Length();
      52           0 :   jArray<char16_t,int32_t> arr = jArray<char16_t,int32_t>::newJArray(len);
      53           0 :   memcpy(arr, temp.BeginReading(), len * sizeof(char16_t));
      54           0 :   return arr;
      55             : }
      56             : 
      57             : jArray<char16_t, int32_t>
      58           0 : nsHtml5Portability::newCharArrayFromString(nsHtml5String string)
      59             : {
      60           0 :   MOZ_RELEASE_ASSERT(string);
      61           0 :   uint32_t len = string.Length();
      62           0 :   MOZ_RELEASE_ASSERT(len < INT32_MAX);
      63           0 :   jArray<char16_t,int32_t> arr = jArray<char16_t,int32_t>::newJArray(len);
      64           0 :   string.CopyToBuffer(arr);
      65           0 :   return arr;
      66             : }
      67             : 
      68             : nsIAtom*
      69          20 : nsHtml5Portability::newLocalFromLocal(nsIAtom* local, nsHtml5AtomTable* interner)
      70             : {
      71          20 :   NS_PRECONDITION(local, "Atom was null.");
      72          20 :   NS_PRECONDITION(interner, "Atom table was null");
      73          20 :   if (!local->IsStaticAtom()) {
      74           0 :     nsAutoString str;
      75           0 :     local->ToString(str);
      76           0 :     local = interner->GetAtom(str);
      77             :   }
      78          20 :   return local;
      79             : }
      80             : 
      81             : bool
      82          34 : nsHtml5Portability::localEqualsBuffer(nsIAtom* local, char16_t* buf, int32_t offset, int32_t length)
      83             : {
      84          34 :   return local->Equals(buf + offset, length);
      85             : }
      86             : 
      87             : bool
      88          55 : nsHtml5Portability::lowerCaseLiteralIsPrefixOfIgnoreAsciiCaseString(
      89             :   const char* lowerCaseLiteral,
      90             :   nsHtml5String string)
      91             : {
      92          55 :   return string.LowerCaseStartsWithASCII(lowerCaseLiteral);
      93             : }
      94             : 
      95             : bool
      96           8 : nsHtml5Portability::lowerCaseLiteralEqualsIgnoreAsciiCaseString(
      97             :   const char* lowerCaseLiteral,
      98             :   nsHtml5String string)
      99             : {
     100           8 :   return string.LowerCaseEqualsASCII(lowerCaseLiteral);
     101             : }
     102             : 
     103             : bool
     104           0 : nsHtml5Portability::literalEqualsString(const char* literal,
     105             :                                         nsHtml5String string)
     106             : {
     107           0 :   return string.EqualsASCII(literal);
     108             : }
     109             : 
     110             : bool
     111           0 : nsHtml5Portability::stringEqualsString(nsHtml5String one, nsHtml5String other)
     112             : {
     113           0 :   return one.Equals(other);
     114             : }
     115             : 
     116             : void
     117           3 : nsHtml5Portability::initializeStatics()
     118             : {
     119           3 : }
     120             : 
     121             : void
     122           0 : nsHtml5Portability::releaseStatics()
     123             : {
     124           0 : }

Generated by: LCOV version 1.13