LCOV - code coverage report
Current view: top level - dom/base - nsIContentInlines.h (source / functions) Hit Total Coverage
Test: output.info Lines: 30 37 81.1 %
Date: 2017-07-14 16:53:18 Functions: 8 12 66.7 %
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             : #ifndef nsIContentInlines_h
       8             : #define nsIContentInlines_h
       9             : 
      10             : #include "nsIContent.h"
      11             : #include "nsIDocument.h"
      12             : #include "nsContentUtils.h"
      13             : #include "nsIAtom.h"
      14             : #include "mozilla/dom/Element.h"
      15             : 
      16             : inline bool
      17           8 : nsIContent::IsInHTMLDocument() const
      18             : {
      19           8 :   return OwnerDoc()->IsHTMLDocument();
      20             : }
      21             : 
      22             : inline bool
      23           0 : nsIContent::IsInChromeDocument() const
      24             : {
      25           0 :   return nsContentUtils::IsChromeDoc(OwnerDoc());
      26             : }
      27             : 
      28       17317 : inline mozilla::dom::ShadowRoot* nsIContent::GetShadowRoot() const
      29             : {
      30       17317 :   if (!IsElement()) {
      31           1 :     return nullptr;
      32             :   }
      33             : 
      34       17316 :   return AsElement()->FastGetShadowRoot();
      35             : }
      36             : 
      37             : template<nsIContent::FlattenedParentType Type>
      38        9541 : static inline bool FlattenedTreeParentIsParent(const nsINode* aNode)
      39             : {
      40             :   // Try to short-circuit past the complicated and not-exactly-fast logic for
      41             :   // computing the flattened parent.
      42             :   //
      43             :   // WARNING! This logic is replicated in Servo to avoid out of line calls.
      44             :   // If you change the cases here, you need to change them in Servo as well!
      45             : 
      46             :   // Check if the node is an explicit child of an XBL-bound element, re-bound to
      47             :   // an XBL insertion point, or is a top-level element in a shadow tree, whose
      48             :   // flattened parent is the host element (as opposed to the actual parent which
      49             :   // is the shadow root).
      50        9541 :   if (aNode->HasFlag(NODE_MAY_BE_IN_BINDING_MNGR | NODE_IS_IN_SHADOW_TREE)) {
      51        4363 :     return false;
      52             :   }
      53             : 
      54             :   // Check if we want the flattened parent for style, and the node is the root
      55             :   // of a native anonymous content subtree parented to the document's root element.
      56        5178 :   if (Type == nsIContent::eForStyle && aNode->HasFlag(NODE_IS_NATIVE_ANONYMOUS_ROOT) &&
      57           0 :       aNode->OwnerDoc()->GetRootElement() == aNode->GetParentNode())
      58             :   {
      59           0 :     return false;
      60             :   }
      61             : 
      62             :   // Check if the node is an explicit child of an element with a shadow root,
      63             :   // re-bound to an insertion point.
      64        5178 :   nsIContent* parent = aNode->GetParent();
      65        5178 :   if (parent && parent->GetShadowRoot()) {
      66           0 :     return false;
      67             :   }
      68             : 
      69             :   // Common case.
      70        5178 :   return true;
      71             : }
      72             : 
      73             : template<nsIContent::FlattenedParentType Type>
      74             : static inline nsINode*
      75        9541 : GetFlattenedTreeParentNode(const nsINode* aNode)
      76             : {
      77        9541 :   if (MOZ_LIKELY(FlattenedTreeParentIsParent<Type>(aNode))) {
      78        5178 :     return aNode->GetParentNode();
      79             :   }
      80             : 
      81        4363 :   MOZ_ASSERT(aNode->IsContent());
      82        4363 :   return aNode->AsContent()->GetFlattenedTreeParentNodeInternal(Type);
      83             : }
      84             : 
      85             : inline nsINode*
      86        9541 : nsINode::GetFlattenedTreeParentNode() const
      87             : {
      88        9541 :   return ::GetFlattenedTreeParentNode<nsIContent::eNotForStyle>(this);
      89             : }
      90             : 
      91             : inline nsIContent*
      92        9541 : nsIContent::GetFlattenedTreeParent() const
      93             : {
      94        9541 :   nsINode* parent = GetFlattenedTreeParentNode();
      95        9541 :   return (parent && parent->IsContent()) ? parent->AsContent() : nullptr;
      96             : }
      97             : 
      98             : inline bool
      99         503 : nsIContent::IsEventAttributeName(nsIAtom* aName)
     100             : {
     101         503 :   const char16_t* name = aName->GetUTF16String();
     102         503 :   if (name[0] != 'o' || name[1] != 'n') {
     103         502 :     return false;
     104             :   }
     105             : 
     106           1 :   return IsEventAttributeNameInternal(aName);
     107             : }
     108             : 
     109             : inline nsINode*
     110           0 : nsINode::GetFlattenedTreeParentNodeForStyle() const
     111             : {
     112           0 :   return ::GetFlattenedTreeParentNode<nsIContent::eForStyle>(this);
     113             : }
     114             : 
     115             : inline bool
     116         149 : nsINode::NodeOrAncestorHasDirAuto() const
     117             : {
     118         149 :   return AncestorHasDirAuto() || (IsElement() && AsElement()->HasDirAuto());
     119             : }
     120             : 
     121             : #endif // nsIContentInlines_h

Generated by: LCOV version 1.13