LCOV - code coverage report
Current view: top level - layout/base - nsStyleChangeList.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 16 18 88.9 %
Date: 2017-07-14 16:53:18 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : /*
       7             :  * a list of the recomputation that needs to be done in response to a
       8             :  * style change
       9             :  */
      10             : 
      11             : #include "nsStyleChangeList.h"
      12             : #include "nsIContent.h"
      13             : #include "nsIFrame.h"
      14             : #include "nsFrameManager.h"
      15             : 
      16             : void
      17         108 : nsStyleChangeList::AppendChange(nsIFrame* aFrame, nsIContent* aContent, nsChangeHint aHint)
      18             : {
      19         108 :   MOZ_ASSERT(aFrame || (aHint & nsChangeHint_ReconstructFrame),
      20             :              "must have frame");
      21         108 :   MOZ_ASSERT(aHint, "No hint to process?");
      22         108 :   MOZ_ASSERT(!(aHint & nsChangeHint_NeutralChange),
      23             :              "Neutral changes do not need extra processing, "
      24             :              "and should be stripped out");
      25         108 :   MOZ_ASSERT(aContent || !(aHint & nsChangeHint_ReconstructFrame),
      26             :              "must have content");
      27             :   // XXXbz we should make this take Element instead of nsIContent
      28         108 :   MOZ_ASSERT(!aContent || aContent->IsElement() ||
      29             :              // display:contents elements posts the changes for their children:
      30             :              (aFrame && aContent->GetParent() &&
      31             :              aFrame->PresContext()->FrameManager()->
      32             :                GetDisplayContentsStyleFor(aContent->GetParent())) ||
      33             :              (aContent->IsNodeOfType(nsINode::eTEXT) &&
      34             :               aContent->IsStyledByServo() &&
      35             :               aContent->HasFlag(NODE_NEEDS_FRAME) &&
      36             :               aHint & nsChangeHint_ReconstructFrame),
      37             :              "Shouldn't be trying to restyle non-elements directly, "
      38             :              "except if it's a display:contents child or a text node "
      39             :              "doing lazy frame construction");
      40         108 :   MOZ_ASSERT(!(aHint & nsChangeHint_AllReflowHints) ||
      41             :              (aHint & nsChangeHint_NeedReflow),
      42             :              "Reflow hint bits set without actually asking for a reflow");
      43             : 
      44             :   // If Servo fires reconstruct at a node, it is the only change hint fired at
      45             :   // that node.
      46         108 :   if (IsServo()) {
      47           0 :     for (size_t i = 0; i < Length(); ++i) {
      48           0 :       MOZ_ASSERT(!aContent || !((aHint | (*this)[i].mHint) & nsChangeHint_ReconstructFrame) ||
      49             :                  (*this)[i].mContent != aContent);
      50             :     }
      51             :   } else {
      52             :     // Filter out all other changes for same content for Gecko (Servo asserts against this
      53             :     // case above).
      54         108 :     if (aContent && (aHint & nsChangeHint_ReconstructFrame)) {
      55             :       // NOTE: This is captured by reference to please static analysis.
      56             :       // Capturing it by value as a pointer should be fine in this case.
      57          18 :       RemoveElementsBy([&](const nsStyleChangeData& aData) {
      58           5 :         return aData.mContent == aContent;
      59          31 :       });
      60             :     }
      61             :   }
      62             : 
      63         108 :   if (!IsEmpty() && aFrame && aFrame == LastElement().mFrame) {
      64          12 :     LastElement().mHint |= aHint;
      65          12 :     return;
      66             :   }
      67             : 
      68          96 :   AppendElement(nsStyleChangeData { aFrame, aContent, aHint });
      69             : }

Generated by: LCOV version 1.13