LCOV - code coverage report
Current view: top level - layout/generic - nsIFrameInlines.h (source / functions) Hit Total Coverage
Test: output.info Lines: 42 71 59.2 %
Date: 2017-07-14 16:53:18 Functions: 13 17 76.5 %
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             : #ifndef nsIFrameInlines_h___
       8             : #define nsIFrameInlines_h___
       9             : 
      10             : #include "nsContainerFrame.h"
      11             : #include "nsPlaceholderFrame.h"
      12             : #include "nsStyleStructInlines.h"
      13             : #include "nsCSSAnonBoxes.h"
      14             : #include "nsFrameManager.h"
      15             : 
      16             : bool
      17           0 : nsIFrame::IsFlexItem() const
      18             : {
      19           0 :   return GetParent() && GetParent()->IsFlexContainerFrame() &&
      20           0 :          !(GetStateBits() & NS_FRAME_OUT_OF_FLOW);
      21             : }
      22             : 
      23             : bool
      24        1085 : nsIFrame::IsFlexOrGridContainer() const
      25             : {
      26        1085 :   return IsFlexContainerFrame() || IsGridContainerFrame();
      27             : }
      28             : 
      29             : bool
      30         242 : nsIFrame::IsFlexOrGridItem() const
      31             : {
      32         484 :   return !(GetStateBits() & NS_FRAME_OUT_OF_FLOW) &&
      33         484 :          GetParent() &&
      34         484 :          GetParent()->IsFlexOrGridContainer();
      35             : }
      36             : 
      37             : bool
      38        1899 : nsIFrame::IsTableCaption() const
      39             : {
      40        1899 :   return StyleDisplay()->mDisplay == mozilla::StyleDisplay::TableCaption &&
      41        1899 :     GetParent()->StyleContext()->GetPseudo() == nsCSSAnonBoxes::tableWrapper;
      42             : }
      43             : 
      44             : bool
      45         545 : nsIFrame::IsFloating() const
      46             : {
      47         545 :   return StyleDisplay()->IsFloating(this);
      48             : }
      49             : 
      50             : bool
      51        1506 : nsIFrame::IsAbsPosContainingBlock() const
      52             : {
      53        1506 :   return StyleDisplay()->IsAbsPosContainingBlock(this);
      54             : }
      55             : 
      56             : bool
      57          68 : nsIFrame::IsFixedPosContainingBlock() const
      58             : {
      59          68 :   return StyleDisplay()->IsFixedPosContainingBlock(this);
      60             : }
      61             : 
      62             : bool
      63          57 : nsIFrame::IsRelativelyPositioned() const
      64             : {
      65          57 :   return StyleDisplay()->IsRelativelyPositioned(this);
      66             : }
      67             : 
      68             : bool
      69         788 : nsIFrame::IsAbsolutelyPositioned(const nsStyleDisplay* aStyleDisplay) const
      70             : {
      71         788 :   const nsStyleDisplay* disp = StyleDisplayWithOptionalParam(aStyleDisplay);
      72         788 :   return disp->IsAbsolutelyPositioned(this);
      73             : }
      74             : 
      75             : bool
      76             : nsIFrame::IsBlockInside() const
      77             : {
      78             :   return StyleDisplay()->IsBlockInside(this);
      79             : }
      80             : 
      81             : bool
      82          66 : nsIFrame::IsBlockOutside() const
      83             : {
      84          66 :   return StyleDisplay()->IsBlockOutside(this);
      85             : }
      86             : 
      87             : bool
      88           0 : nsIFrame::IsInlineOutside() const
      89             : {
      90           0 :   return StyleDisplay()->IsInlineOutside(this);
      91             : }
      92             : 
      93             : mozilla::StyleDisplay
      94         685 : nsIFrame::GetDisplay() const
      95             : {
      96         685 :   return StyleDisplay()->GetDisplay(this);
      97             : }
      98             : 
      99             : nscoord
     100          30 : nsIFrame::SynthesizeBaselineBOffsetFromMarginBox(
     101             :             mozilla::WritingMode aWM,
     102             :             BaselineSharingGroup aGroup) const
     103             : {
     104          30 :   MOZ_ASSERT(!aWM.IsOrthogonalTo(GetWritingMode()));
     105          30 :   auto margin = GetLogicalUsedMargin(aWM);
     106          30 :   if (aGroup == BaselineSharingGroup::eFirst) {
     107           0 :     if (aWM.IsAlphabeticalBaseline()) {
     108             :       // First baseline for inverted-line content is the block-start margin edge,
     109             :       // as the frame is in effect "flipped" for alignment purposes.
     110           0 :       return MOZ_UNLIKELY(aWM.IsLineInverted()) ? -margin.BStart(aWM)
     111           0 :                                                 : BSize(aWM) + margin.BEnd(aWM);
     112             :     }
     113           0 :     nscoord marginBoxCenter = (BSize(aWM) + margin.BStartEnd(aWM)) / 2;
     114           0 :     return marginBoxCenter - margin.BStart(aWM);
     115             :   }
     116          30 :   MOZ_ASSERT(aGroup == BaselineSharingGroup::eLast);
     117          30 :   if (aWM.IsAlphabeticalBaseline()) {
     118             :     // Last baseline for inverted-line content is the block-start margin edge,
     119             :     // as the frame is in effect "flipped" for alignment purposes.
     120          60 :     return MOZ_UNLIKELY(aWM.IsLineInverted()) ? BSize(aWM) + margin.BStart(aWM)
     121          60 :                                               : -margin.BEnd(aWM);
     122             :   }
     123             :   // Round up for central baseline offset, to be consistent with eFirst.
     124           0 :   nscoord marginBoxSize = BSize(aWM) + margin.BStartEnd(aWM);
     125           0 :   nscoord marginBoxCenter = (marginBoxSize / 2) + (marginBoxSize % 2);
     126           0 :   return marginBoxCenter - margin.BEnd(aWM);
     127             : }
     128             : 
     129             : nscoord
     130           0 : nsIFrame::SynthesizeBaselineBOffsetFromBorderBox(
     131             :             mozilla::WritingMode aWM,
     132             :             BaselineSharingGroup aGroup) const
     133             : {
     134           0 :   MOZ_ASSERT(!aWM.IsOrthogonalTo(GetWritingMode()));
     135           0 :   nscoord borderBoxSize = BSize(aWM);
     136           0 :   if (aGroup == BaselineSharingGroup::eFirst) {
     137           0 :     return MOZ_LIKELY(aWM.IsAlphabeticalBaseline()) ? borderBoxSize
     138           0 :                                                     : borderBoxSize / 2;
     139             :   }
     140           0 :   MOZ_ASSERT(aGroup == BaselineSharingGroup::eLast);
     141             :   // Round up for central baseline offset, to be consistent with eFirst.
     142           0 :   auto borderBoxCenter = (borderBoxSize / 2) + (borderBoxSize % 2);
     143           0 :   return MOZ_LIKELY(aWM.IsAlphabeticalBaseline()) ? 0 : borderBoxCenter;
     144             : }
     145             : 
     146             : nscoord
     147          30 : nsIFrame::BaselineBOffset(mozilla::WritingMode aWM,
     148             :                           BaselineSharingGroup aBaselineGroup,
     149             :                           AlignmentContext     aAlignmentContext) const
     150             : {
     151          30 :   MOZ_ASSERT(!aWM.IsOrthogonalTo(GetWritingMode()));
     152             :   nscoord baseline;
     153          30 :   if (GetNaturalBaselineBOffset(aWM, aBaselineGroup, &baseline)) {
     154           0 :     return baseline;
     155             :   }
     156          30 :   if (aAlignmentContext == AlignmentContext::eInline) {
     157          30 :     return SynthesizeBaselineBOffsetFromMarginBox(aWM, aBaselineGroup);
     158             :   }
     159             :   // XXX AlignmentContext::eTable should use content box?
     160           0 :   return SynthesizeBaselineBOffsetFromBorderBox(aWM, aBaselineGroup);
     161             : }
     162             : 
     163             : void
     164          46 : nsIFrame::PropagateRootElementWritingMode(mozilla::WritingMode aRootElemWM)
     165             : {
     166          46 :   MOZ_ASSERT(IsCanvasFrame());
     167         184 :   for (auto f = this; f; f = f->GetParent()) {
     168         138 :     f->mWritingMode = aRootElemWM;
     169             :   }
     170          46 : }
     171             : 
     172             : nsContainerFrame*
     173           0 : nsIFrame::GetInFlowParent()
     174             : {
     175           0 :   if (GetStateBits() & NS_FRAME_OUT_OF_FLOW) {
     176           0 :     nsIFrame* ph = FirstContinuation()->GetProperty(nsIFrame::PlaceholderFrameProperty());
     177           0 :     return ph->GetParent();
     178             :   }
     179             : 
     180           0 :   return GetParent();
     181             : }
     182             : 
     183             : #endif

Generated by: LCOV version 1.13