Bumping manifests a=b2g-bump
[gecko.git] / layout / style / nsRuleData.cpp
blobdac610a17dec5793e70044371572e6b48383425d
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/. */
6 #include "nsRuleData.h"
8 #include "mozilla/Poison.h"
9 #include <stdint.h>
11 inline size_t
12 nsRuleData::GetPoisonOffset()
14 // Fill in mValueOffsets such that mValueStorage + mValueOffsets[i]
15 // will yield the frame poison value for all uninitialized value
16 // offsets.
17 static_assert(sizeof(uintptr_t) == sizeof(size_t),
18 "expect uintptr_t and size_t to be the same size");
19 static_assert(uintptr_t(-1) > uintptr_t(0),
20 "expect uintptr_t to be unsigned");
21 static_assert(size_t(-1) > size_t(0),
22 "expect size_t to be unsigned");
23 uintptr_t framePoisonValue = mozPoisonValue();
24 return size_t(framePoisonValue - uintptr_t(mValueStorage)) /
25 sizeof(nsCSSValue);
28 nsRuleData::nsRuleData(uint32_t aSIDs, nsCSSValue* aValueStorage,
29 nsPresContext* aContext, nsStyleContext* aStyleContext)
30 : mSIDs(aSIDs),
31 mCanStoreInRuleTree(true),
32 mPresContext(aContext),
33 mStyleContext(aStyleContext),
34 mValueStorage(aValueStorage)
36 #ifndef MOZ_VALGRIND
37 size_t framePoisonOffset = GetPoisonOffset();
38 for (size_t i = 0; i < nsStyleStructID_Length; ++i) {
39 mValueOffsets[i] = framePoisonOffset;
41 #endif
44 #ifdef DEBUG
45 nsRuleData::~nsRuleData()
47 #ifndef MOZ_VALGRIND
48 // assert nothing in mSIDs has poison value
49 size_t framePoisonOffset = GetPoisonOffset();
50 for (size_t i = 0; i < nsStyleStructID_Length; ++i) {
51 NS_ABORT_IF_FALSE(!(mSIDs & (1 << i)) ||
52 mValueOffsets[i] != framePoisonOffset,
53 "value in SIDs was left with poison offset");
55 #endif
57 #endif