LCOV - code coverage report
Current view: top level - parser/html - nsHtml5DocumentBuilder.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 26 53 49.1 %
Date: 2017-07-14 16:53:18 Functions: 7 15 46.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=2 sw=2 et tw=78: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #include "nsHtml5DocumentBuilder.h"
       8             : 
       9             : #include "nsIStyleSheetLinkingElement.h"
      10             : #include "nsStyleLinkElement.h"
      11             : #include "nsIHTMLDocument.h"
      12             : #include "nsNameSpaceManager.h"
      13             : #include "mozilla/dom/ScriptLoader.h"
      14             : 
      15           0 : NS_IMPL_CYCLE_COLLECTION_INHERITED(nsHtml5DocumentBuilder, nsContentSink,
      16             :                                    mOwnedElements)
      17             : 
      18           2 : NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsHtml5DocumentBuilder)
      19           2 : NS_INTERFACE_MAP_END_INHERITING(nsContentSink)
      20             : 
      21           0 : NS_IMPL_ADDREF_INHERITED(nsHtml5DocumentBuilder, nsContentSink)
      22           0 : NS_IMPL_RELEASE_INHERITED(nsHtml5DocumentBuilder, nsContentSink)
      23             : 
      24           2 : nsHtml5DocumentBuilder::nsHtml5DocumentBuilder(bool aRunsToCompletion)
      25             :   : mBroken(NS_OK)
      26           2 :   , mFlushState(eHtml5FlushState::eNotFlushing)
      27             : {
      28           2 :   mRunsToCompletion = aRunsToCompletion;
      29           2 : }
      30             : 
      31             : nsresult
      32           2 : nsHtml5DocumentBuilder::Init(nsIDocument* aDoc,
      33             :                             nsIURI* aURI,
      34             :                             nsISupports* aContainer,
      35             :                             nsIChannel* aChannel)
      36             : {
      37           2 :   return nsContentSink::Init(aDoc, aURI, aContainer, aChannel);
      38             : }
      39             : 
      40           0 : nsHtml5DocumentBuilder::~nsHtml5DocumentBuilder()
      41             : {
      42           0 : }
      43             : 
      44             : nsresult
      45           0 : nsHtml5DocumentBuilder::MarkAsBroken(nsresult aReason)
      46             : {
      47           0 :   mBroken = aReason;
      48           0 :   return aReason;
      49             : }
      50             : 
      51             : void
      52           4 : nsHtml5DocumentBuilder::SetDocumentCharsetAndSource(NotNull<const Encoding*> aEncoding,
      53             :                                                     int32_t aCharsetSource)
      54             : {
      55           4 :   if (mDocument) {
      56           2 :     mDocument->SetDocumentCharacterSetSource(aCharsetSource);
      57           2 :     mDocument->SetDocumentCharacterSet(aEncoding);
      58             :   }
      59           4 : }
      60             : 
      61             : void
      62           0 : nsHtml5DocumentBuilder::UpdateStyleSheet(nsIContent* aElement)
      63             : {
      64           0 :   nsCOMPtr<nsIStyleSheetLinkingElement> ssle(do_QueryInterface(aElement));
      65           0 :   if (!ssle) {
      66           0 :     MOZ_ASSERT(nsNameSpaceManager::GetInstance()->mSVGDisabled, "Node didn't QI to style, but SVG wasn't disabled.");
      67           0 :     return;
      68             :   }
      69             : 
      70             :   // Break out of the doc update created by Flush() to zap a runnable
      71             :   // waiting to call UpdateStyleSheet without the right observer
      72           0 :   EndDocUpdate();
      73             : 
      74           0 :   if (MOZ_UNLIKELY(!mParser)) {
      75             :     // EndDocUpdate ran stuff that called nsIParser::Terminate()
      76           0 :     return;
      77             :   }
      78             : 
      79           0 :   ssle->SetEnableUpdates(true);
      80             : 
      81             :   bool willNotify;
      82             :   bool isAlternate;
      83           0 :   nsresult rv = ssle->UpdateStyleSheet(mRunsToCompletion ? nullptr : this,
      84             :                                        &willNotify,
      85           0 :                                        &isAlternate);
      86           0 :   if (NS_SUCCEEDED(rv) && willNotify && !isAlternate && !mRunsToCompletion) {
      87           0 :     ++mPendingSheetCount;
      88           0 :     mScriptLoader->AddParserBlockingScriptExecutionBlocker();
      89             :   }
      90             : 
      91             :   // Re-open update
      92           0 :   BeginDocUpdate();
      93             : }
      94             : 
      95             : void
      96           2 : nsHtml5DocumentBuilder::SetDocumentMode(nsHtml5DocumentMode m)
      97             : {
      98           2 :   nsCompatibility mode = eCompatibility_NavQuirks;
      99           2 :   switch (m) {
     100             :     case STANDARDS_MODE:
     101           0 :       mode = eCompatibility_FullStandards;
     102           0 :       break;
     103             :     case ALMOST_STANDARDS_MODE:
     104           0 :       mode = eCompatibility_AlmostStandards;
     105           0 :       break;
     106             :     case QUIRKS_MODE:
     107           2 :       mode = eCompatibility_NavQuirks;
     108           2 :       break;
     109             :   }
     110           4 :   nsCOMPtr<nsIHTMLDocument> htmlDocument = do_QueryInterface(mDocument);
     111           2 :   NS_ASSERTION(htmlDocument, "Document didn't QI into HTML document.");
     112           2 :   htmlDocument->SetCompatibilityMode(mode);
     113           2 : }
     114             : 
     115             : // nsContentSink overrides
     116             : 
     117             : void
     118          11 : nsHtml5DocumentBuilder::UpdateChildCounts()
     119             : {
     120             :   // No-op
     121          11 : }
     122             : 
     123             : nsresult
     124          13 : nsHtml5DocumentBuilder::FlushTags()
     125             : {
     126          13 :   return NS_OK;
     127             : }

Generated by: LCOV version 1.13