LCOV - code coverage report
Current view: top level - parser/html - nsHtml5Atom.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 42 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 9 0.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 "nsHtml5Atom.h"
       6             : #include "nsAutoPtr.h"
       7             : #include "mozilla/Unused.h"
       8             : 
       9           0 : nsHtml5Atom::nsHtml5Atom(const nsAString& aString)
      10             : {
      11           0 :   mLength = aString.Length();
      12           0 :   mIsStatic = false;
      13           0 :   RefPtr<nsStringBuffer> buf = nsStringBuffer::FromString(aString);
      14           0 :   if (buf) {
      15           0 :     mString = static_cast<char16_t*>(buf->Data());
      16             :   } else {
      17           0 :     const size_t size = (mLength + 1) * sizeof(char16_t);
      18           0 :     buf = nsStringBuffer::Alloc(size);
      19           0 :     if (MOZ_UNLIKELY(!buf)) {
      20             :       // We OOM because atom allocations should be small and it's hard to
      21             :       // handle them more gracefully in a constructor.
      22           0 :       NS_ABORT_OOM(size);
      23             :     }
      24           0 :     mString = static_cast<char16_t*>(buf->Data());
      25           0 :     CopyUnicodeTo(aString, 0, mString, mLength);
      26           0 :     mString[mLength] = char16_t(0);
      27             :   }
      28             : 
      29           0 :   NS_ASSERTION(mString[mLength] == char16_t(0), "null terminated");
      30           0 :   NS_ASSERTION(buf && buf->StorageSize() >= (mLength+1) * sizeof(char16_t),
      31             :                "enough storage");
      32           0 :   NS_ASSERTION(Equals(aString), "correct data");
      33             : 
      34             :   // Take ownership of buffer
      35           0 :   mozilla::Unused << buf.forget();
      36           0 : }
      37             : 
      38           0 : nsHtml5Atom::~nsHtml5Atom()
      39             : {
      40           0 :   nsStringBuffer::FromData(mString)->Release();
      41           0 : }
      42             : 
      43             : NS_IMETHODIMP_(MozExternalRefCountType)
      44           0 : nsHtml5Atom::AddRef()
      45             : {
      46           0 :   NS_NOTREACHED("Attempt to AddRef an nsHtml5Atom.");
      47           0 :   return 2;
      48             : }
      49             : 
      50             : NS_IMETHODIMP_(MozExternalRefCountType)
      51           0 : nsHtml5Atom::Release()
      52             : {
      53           0 :   NS_NOTREACHED("Attempt to Release an nsHtml5Atom.");
      54           0 :   return 1;
      55             : }
      56             : 
      57             : NS_IMETHODIMP
      58           0 : nsHtml5Atom::QueryInterface(REFNSIID aIID, void** aInstancePtr)
      59             : {
      60           0 :   NS_NOTREACHED("Attempt to call QueryInterface an nsHtml5Atom.");
      61           0 :   return NS_ERROR_UNEXPECTED;
      62             : }
      63             : 
      64             : NS_IMETHODIMP 
      65           0 : nsHtml5Atom::ScriptableToString(nsAString& aBuf)
      66             : {
      67           0 :   NS_NOTREACHED("Should not call ScriptableToString.");
      68           0 :   return NS_ERROR_NOT_IMPLEMENTED;
      69             : }
      70             : 
      71             : NS_IMETHODIMP
      72           0 : nsHtml5Atom::ToUTF8String(nsACString& aReturn)
      73             : {
      74           0 :   NS_NOTREACHED("Should not attempt to convert to an UTF-8 string.");
      75           0 :   return NS_ERROR_NOT_IMPLEMENTED;
      76             : }
      77             : 
      78             : NS_IMETHODIMP
      79           0 : nsHtml5Atom::ScriptableEquals(const nsAString& aString, bool* aResult)
      80             : {
      81           0 :   NS_NOTREACHED("Should not call ScriptableEquals.");
      82           0 :   return NS_ERROR_NOT_IMPLEMENTED;
      83             : }
      84             : 
      85             : NS_IMETHODIMP_(size_t)
      86           0 : nsHtml5Atom::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
      87             : {
      88           0 :   NS_NOTREACHED("Should not call SizeOfIncludingThis.");
      89           0 :   return 0;
      90             : }
      91             : 

Generated by: LCOV version 1.13