LCOV - code coverage report
Current view: top level - layout/style - ServoImportRule.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 49 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 15 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       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             : /* representation of CSSImportRule for stylo */
       8             : 
       9             : #include "mozilla/ServoImportRule.h"
      10             : 
      11             : #include "mozilla/ServoBindings.h"
      12             : #include "mozilla/ServoStyleSheet.h"
      13             : 
      14             : namespace mozilla {
      15             : 
      16           0 : ServoImportRule::ServoImportRule(RefPtr<RawServoImportRule> aRawRule,
      17           0 :                                  uint32_t aLine, uint32_t aColumn)
      18             :   : CSSImportRule(aLine, aColumn)
      19           0 :   , mRawRule(Move(aRawRule))
      20             : {
      21           0 :   const auto* sheet = Servo_ImportRule_GetSheet(mRawRule.get());
      22           0 :   MOZ_ASSERT(sheet);
      23           0 :   mChildSheet = const_cast<ServoStyleSheet*>(sheet);
      24           0 : }
      25             : 
      26           0 : ServoImportRule::~ServoImportRule()
      27             : {
      28           0 :   if (mChildSheet) {
      29           0 :     mChildSheet->SetOwnerRule(nullptr);
      30             :   }
      31           0 : }
      32             : 
      33             : // QueryInterface implementation for ServoImportRule
      34           0 : NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(ServoImportRule)
      35           0 : NS_INTERFACE_MAP_END_INHERITING(dom::CSSImportRule)
      36             : 
      37             : NS_IMPL_CYCLE_COLLECTION_CLASS(ServoImportRule)
      38             : 
      39           0 : NS_IMPL_ADDREF_INHERITED(ServoImportRule, dom::CSSImportRule)
      40           0 : NS_IMPL_RELEASE_INHERITED(ServoImportRule, dom::CSSImportRule)
      41             : 
      42           0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(ServoImportRule,
      43             :                                                   dom::CSSImportRule)
      44             :   // Note the child sheet twice, since the Servo rule also holds a strong
      45             :   // reference to it.
      46           0 :   NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mChildSheet");
      47           0 :   cb.NoteXPCOMChild(static_cast<nsIDOMCSSStyleSheet*>(tmp->mChildSheet));
      48           0 :   MOZ_ASSERT_IF(tmp->mRawRule,
      49             :                 Servo_ImportRule_GetSheet(tmp->mRawRule) == tmp->mChildSheet);
      50           0 :   cb.NoteXPCOMChild(static_cast<nsIDOMCSSStyleSheet*>(tmp->mChildSheet));
      51           0 :   NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mRawRule.stylesheet");
      52           0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
      53             : 
      54           0 : NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ServoImportRule)
      55           0 :   if (tmp->mChildSheet) {
      56           0 :     tmp->mChildSheet->SetOwnerRule(nullptr);
      57           0 :     tmp->mChildSheet = nullptr;
      58             :   }
      59           0 :   tmp->mRawRule = nullptr;
      60           0 : NS_IMPL_CYCLE_COLLECTION_UNLINK_END_INHERITED(dom::CSSImportRule)
      61             : 
      62             : /* virtual */ already_AddRefed<css::Rule>
      63           0 : ServoImportRule::Clone() const
      64             : {
      65             :   // Rule::Clone is only used when CSSStyleSheetInner is cloned in
      66             :   // preparation of being mutated. However, ServoStyleSheet never clones
      67             :   // anything, so this method should never be called.
      68           0 :   MOZ_ASSERT_UNREACHABLE("Shouldn't be cloning ServoImportRule");
      69             :   return nullptr;
      70             : }
      71             : 
      72             : #ifdef DEBUG
      73             : /* virtual */ void
      74           0 : ServoImportRule::List(FILE* out, int32_t aIndent) const
      75             : {
      76           0 :   nsAutoCString str;
      77           0 :   for (int32_t i = 0; i < aIndent; i++) {
      78           0 :     str.AppendLiteral("  ");
      79             :   }
      80           0 :   Servo_ImportRule_Debug(mRawRule, &str);
      81           0 :   fprintf_stderr(out, "%s\n", str.get());
      82           0 : }
      83             : #endif
      84             : 
      85             : dom::MediaList*
      86           0 : ServoImportRule::GetMedia() const
      87             : {
      88             :   // When Bug 1326509 is fixed, we can assert mChildSheet instead.
      89           0 :   return mChildSheet ? mChildSheet->Media() : nullptr;
      90             : }
      91             : 
      92             : StyleSheet*
      93           0 : ServoImportRule::GetStyleSheet() const
      94             : {
      95           0 :   return mChildSheet;
      96             : }
      97             : 
      98             : NS_IMETHODIMP
      99           0 : ServoImportRule::GetHref(nsAString& aHref)
     100             : {
     101           0 :   Servo_ImportRule_GetHref(mRawRule, &aHref);
     102           0 :   return NS_OK;
     103             : }
     104             : 
     105             : /* virtual */ void
     106           0 : ServoImportRule::GetCssTextImpl(nsAString& aCssText) const
     107             : {
     108           0 :   Servo_ImportRule_GetCssText(mRawRule, &aCssText);
     109           0 : }
     110             : 
     111             : /* virtual */ size_t
     112           0 : ServoImportRule::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
     113             : {
     114             :   // TODO Implement this!
     115           0 :   return aMallocSizeOf(this);
     116             : }
     117             : 
     118             : } // namespace mozilla

Generated by: LCOV version 1.13