LCOV - code coverage report
Current view: top level - layout/style - ServoPageRule.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 76 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 28 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 CSSPageRule for stylo */
       8             : 
       9             : #include "mozilla/ServoPageRule.h"
      10             : 
      11             : #include "mozilla/DeclarationBlockInlines.h"
      12             : #include "mozilla/ServoBindings.h"
      13             : #include "mozilla/ServoDeclarationBlock.h"
      14             : 
      15             : using namespace mozilla::dom;
      16             : 
      17             : namespace mozilla {
      18             : 
      19             : // -- ServoPageRuleDeclaration ---------------------------------------
      20             : 
      21           0 : ServoPageRuleDeclaration::ServoPageRuleDeclaration(
      22           0 :   already_AddRefed<RawServoDeclarationBlock> aDecls)
      23           0 :   : mDecls(new ServoDeclarationBlock(Move(aDecls)))
      24             : {
      25           0 : }
      26             : 
      27           0 : ServoPageRuleDeclaration::~ServoPageRuleDeclaration()
      28             : {
      29           0 : }
      30             : 
      31             : // QueryInterface implementation for ServoPageRuleDeclaration
      32           0 : NS_INTERFACE_MAP_BEGIN(ServoPageRuleDeclaration)
      33           0 :   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
      34             :   // We forward the cycle collection interfaces to Rule(), which is
      35             :   // never null (in fact, we're part of that object!)
      36           0 :   if (aIID.Equals(NS_GET_IID(nsCycleCollectionISupports)) ||
      37           0 :       aIID.Equals(NS_GET_IID(nsXPCOMCycleCollectionParticipant))) {
      38           0 :     return Rule()->QueryInterface(aIID, aInstancePtr);
      39             :   }
      40             :   else
      41           0 : NS_IMPL_QUERY_TAIL_INHERITING(nsDOMCSSDeclaration)
      42             : 
      43           0 : NS_IMPL_ADDREF_USING_AGGREGATOR(ServoPageRuleDeclaration, Rule())
      44           0 : NS_IMPL_RELEASE_USING_AGGREGATOR(ServoPageRuleDeclaration, Rule())
      45             : 
      46             : /* nsDOMCSSDeclaration implementation */
      47             : 
      48             : NS_IMETHODIMP
      49           0 : ServoPageRuleDeclaration::GetParentRule(nsIDOMCSSRule** aParent)
      50             : {
      51           0 :   *aParent = do_AddRef(Rule()).take();
      52           0 :   return NS_OK;
      53             : }
      54             : 
      55             : nsINode*
      56           0 : ServoPageRuleDeclaration::GetParentObject()
      57             : {
      58           0 :   return Rule()->GetDocument();
      59             : }
      60             : 
      61             : DeclarationBlock*
      62           0 : ServoPageRuleDeclaration::GetCSSDeclaration(Operation aOperation)
      63             : {
      64           0 :   return mDecls;
      65             : }
      66             : 
      67             : nsresult
      68           0 : ServoPageRuleDeclaration::SetCSSDeclaration(DeclarationBlock* aDecl)
      69             : {
      70           0 :   MOZ_ASSERT(aDecl, "must be non-null");
      71           0 :   ServoPageRule* rule = Rule();
      72             : 
      73           0 :   if (aDecl != mDecls) {
      74           0 :     mDecls->SetOwningRule(nullptr);
      75           0 :     RefPtr<ServoDeclarationBlock> decls = aDecl->AsServo();
      76           0 :     Servo_PageRule_SetStyle(rule->Raw(), decls->Raw());
      77           0 :     mDecls = decls.forget();
      78           0 :     mDecls->SetOwningRule(rule);
      79             :   }
      80             : 
      81           0 :   return NS_OK;
      82             : }
      83             : 
      84             : nsIDocument*
      85           0 : ServoPageRuleDeclaration::DocToUpdate()
      86             : {
      87           0 :   return nullptr;
      88             : }
      89             : 
      90             : void
      91           0 : ServoPageRuleDeclaration::GetCSSParsingEnvironment(
      92             :   CSSParsingEnvironment& aCSSParseEnv)
      93             : {
      94           0 :   MOZ_ASSERT_UNREACHABLE("GetCSSParsingEnvironment "
      95             :                          "shouldn't be calling for a Servo rule");
      96             :   GetCSSParsingEnvironmentForRule(Rule(), aCSSParseEnv);
      97             : }
      98             : 
      99             : nsDOMCSSDeclaration::ServoCSSParsingEnvironment
     100           0 : ServoPageRuleDeclaration::GetServoCSSParsingEnvironment() const
     101             : {
     102           0 :   return GetServoCSSParsingEnvironmentForRule(Rule());
     103             : }
     104             : 
     105             : // -- ServoPageRule --------------------------------------------------
     106             : 
     107           0 : ServoPageRule::ServoPageRule(RefPtr<RawServoPageRule> aRawRule,
     108           0 :                              uint32_t aLine, uint32_t aColumn)
     109             :   : CSSPageRule(aLine, aColumn)
     110           0 :   , mRawRule(Move(aRawRule))
     111           0 :   , mDecls(Servo_PageRule_GetStyle(mRawRule).Consume())
     112             : {
     113           0 : }
     114             : 
     115           0 : ServoPageRule::~ServoPageRule()
     116             : {
     117           0 : }
     118             : 
     119           0 : NS_IMPL_ADDREF_INHERITED(ServoPageRule, CSSPageRule)
     120           0 : NS_IMPL_RELEASE_INHERITED(ServoPageRule, CSSPageRule)
     121             : 
     122             : // QueryInterface implementation for PageRule
     123           0 : NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(ServoPageRule)
     124           0 : NS_INTERFACE_MAP_END_INHERITING(CSSPageRule)
     125             : 
     126             : NS_IMPL_CYCLE_COLLECTION_CLASS(ServoPageRule)
     127             : 
     128           0 : NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(ServoPageRule, CSSPageRule)
     129             :   // Keep this in sync with IsCCLeaf.
     130             : 
     131             :   // Trace the wrapper for our declaration.  This just expands out
     132             :   // NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER which we can't use
     133             :   // directly because the wrapper is on the declaration, not on us.
     134           0 :   tmp->mDecls.TraceWrapper(aCallbacks, aClosure);
     135           0 : NS_IMPL_CYCLE_COLLECTION_TRACE_END
     136             : 
     137           0 : NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(ServoPageRule, CSSPageRule)
     138             :   // Keep this in sync with IsCCLeaf.
     139             : 
     140             :   // Unlink the wrapper for our declaraton.  This just expands out
     141             :   // NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER which we can't use
     142             :   // directly because the wrapper is on the declaration, not on us.
     143           0 :   tmp->mDecls.ReleaseWrapper(static_cast<nsISupports*>(p));
     144           0 : NS_IMPL_CYCLE_COLLECTION_UNLINK_END
     145             : 
     146           0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(ServoPageRule, CSSPageRule)
     147             :   // Keep this in sync with IsCCLeaf.
     148           0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
     149             : 
     150             : bool
     151           0 : ServoPageRule::IsCCLeaf() const
     152             : {
     153           0 :   if (!Rule::IsCCLeaf()) {
     154           0 :     return false;
     155             :   }
     156             : 
     157           0 :   return !mDecls.PreservingWrapper();
     158             : }
     159             : 
     160             : already_AddRefed<css::Rule>
     161           0 : ServoPageRule::Clone() const
     162             : {
     163             :   // Rule::Clone is only used when CSSStyleSheetInner is cloned in
     164             :   // preparation of being mutated. However, ServoStyleSheet never clones
     165             :   // anything, so this method should never be called.
     166           0 :   MOZ_ASSERT_UNREACHABLE("Shouldn't be cloning ServoPageRule");
     167             :   return nullptr;
     168             : }
     169             : 
     170             : size_t
     171           0 : ServoPageRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
     172             : {
     173             :   // TODO Implement this!
     174           0 :   return aMallocSizeOf(this);
     175             : }
     176             : 
     177             : #ifdef DEBUG
     178             : void
     179           0 : ServoPageRule::List(FILE* out, int32_t aIndent) const
     180             : {
     181           0 :   nsAutoCString str;
     182           0 :   for (int32_t i = 0; i < aIndent; i++) {
     183           0 :     str.AppendLiteral("  ");
     184             :   }
     185           0 :   Servo_PageRule_Debug(mRawRule, &str);
     186           0 :   fprintf_stderr(out, "%s\n", str.get());
     187           0 : }
     188             : #endif
     189             : 
     190             : /* CSSRule implementation */
     191             : 
     192             : void
     193           0 : ServoPageRule::GetCssTextImpl(nsAString& aCssText) const
     194             : {
     195           0 :   Servo_PageRule_GetCssText(mRawRule, &aCssText);
     196           0 : }
     197             : 
     198             : /* CSSPageRule implementation */
     199             : 
     200             : nsICSSDeclaration*
     201           0 : ServoPageRule::Style()
     202             : {
     203           0 :   return &mDecls;
     204             : }
     205             : 
     206             : } // namespace mozilla

Generated by: LCOV version 1.13