LCOV - code coverage report
Current view: top level - layout/style - nsRuleData.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 16 36 44.4 %
Date: 2017-07-14 16:53:18 Functions: 3 6 50.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             : #include "nsRuleData.h"
       7             : 
       8             : #include "nsAttrValueInlines.h"
       9             : #include "nsCSSParser.h"
      10             : #include "mozilla/Poison.h"
      11             : #include <stdint.h>
      12             : 
      13             : using namespace mozilla;
      14             : 
      15             : inline size_t
      16       23716 : nsRuleData::GetPoisonOffset()
      17             : {
      18             :   // Fill in mValueOffsets such that mValueStorage + mValueOffsets[i]
      19             :   // will yield the frame poison value for all uninitialized value
      20             :   // offsets.
      21             :   static_assert(sizeof(uintptr_t) == sizeof(size_t),
      22             :                 "expect uintptr_t and size_t to be the same size");
      23             :   static_assert(uintptr_t(-1) > uintptr_t(0),
      24             :                 "expect uintptr_t to be unsigned");
      25             :   static_assert(size_t(-1) > size_t(0), "expect size_t to be unsigned");
      26       23716 :   uintptr_t framePoisonValue = mozPoisonValue();
      27       23716 :   return size_t(framePoisonValue - uintptr_t(mValueStorage)) /
      28       23716 :          sizeof(nsCSSValue);
      29             : }
      30             : 
      31       11858 : nsRuleData::nsRuleData(uint32_t aSIDs,
      32             :                        nsCSSValue* aValueStorage,
      33             :                        nsPresContext* aContext,
      34       11858 :                        nsStyleContext* aStyleContext)
      35             :   : GenericSpecifiedValues(StyleBackendType::Gecko, aContext, aSIDs)
      36             :   , mStyleContext(aStyleContext)
      37       11858 :   , mValueStorage(aValueStorage)
      38             : {
      39             : #ifndef MOZ_VALGRIND
      40       11858 :   size_t framePoisonOffset = GetPoisonOffset();
      41      296450 :   for (size_t i = 0; i < nsStyleStructID_Length; ++i) {
      42      284592 :     mValueOffsets[i] = framePoisonOffset;
      43             :   }
      44             : #endif
      45       11858 : }
      46             : 
      47             : void
      48           0 : nsRuleData::SetFontFamily(const nsString& aValue)
      49             : {
      50           0 :   nsCSSValue* family = ValueForFontFamily();
      51           0 :   nsCSSParser parser;
      52           0 :   parser.ParseFontFamilyListString(aValue, nullptr, 0, *family);
      53           0 : }
      54             : 
      55             : void
      56           0 : nsRuleData::SetTextDecorationColorOverride()
      57             : {
      58           0 :   nsCSSValue* decoration = ValueForTextDecorationLine();
      59           0 :   int32_t newValue = NS_STYLE_TEXT_DECORATION_LINE_OVERRIDE_ALL;
      60           0 :   if (decoration->GetUnit() == eCSSUnit_Enumerated) {
      61           0 :     newValue |= decoration->GetIntValue();
      62             :   }
      63           0 :   decoration->SetIntValue(newValue, eCSSUnit_Enumerated);
      64           0 : }
      65             : 
      66             : void
      67           0 : nsRuleData::SetBackgroundImage(nsAttrValue& aValue)
      68             : {
      69           0 :   nsCSSValue* backImage = ValueForBackgroundImage();
      70             :   // If the value is an image, or it is a URL and we attempted a load,
      71             :   // put it in the style tree.
      72           0 :   if (aValue.Type() == nsAttrValue::eURL) {
      73           0 :     aValue.LoadImage(mPresContext->Document());
      74             :   }
      75           0 :   if (aValue.Type() == nsAttrValue::eImage) {
      76           0 :     nsCSSValueList* list = backImage->SetListValue();
      77           0 :     list->mValue.SetImageValue(aValue.GetImageValue());
      78             :   }
      79           0 : }
      80             : 
      81             : #ifdef DEBUG
      82       23716 : nsRuleData::~nsRuleData()
      83             : {
      84             : #ifndef MOZ_VALGRIND
      85             :   // assert nothing in mSIDs has poison value
      86       11858 :   size_t framePoisonOffset = GetPoisonOffset();
      87      296450 :   for (size_t i = 0; i < nsStyleStructID_Length; ++i) {
      88      284592 :     MOZ_ASSERT(!(mSIDs & (1 << i)) || mValueOffsets[i] != framePoisonOffset,
      89             :                "value in SIDs was left with poison offset");
      90             :   }
      91             : #endif
      92       11858 : }
      93             : #endif

Generated by: LCOV version 1.13