2010-07-23 18:00:21 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-07-23 18:00:21 +00:00
|
|
|
|
|
|
|
#include "nsRuleData.h"
|
2011-03-18 03:14:31 +00:00
|
|
|
|
2013-05-07 18:48:59 +00:00
|
|
|
#include "mozilla/Poison.h"
|
2013-07-30 14:25:31 +00:00
|
|
|
#include <stdint.h>
|
2012-04-12 00:17:44 +00:00
|
|
|
|
2011-03-18 03:14:31 +00:00
|
|
|
inline size_t
|
|
|
|
nsRuleData::GetPoisonOffset()
|
|
|
|
{
|
|
|
|
// Fill in mValueOffsets such that mValueStorage + mValueOffsets[i]
|
|
|
|
// will yield the frame poison value for all uninitialized value
|
|
|
|
// offsets.
|
2013-07-18 17:59:53 +00:00
|
|
|
static_assert(sizeof(uintptr_t) == sizeof(size_t),
|
|
|
|
"expect uintptr_t and size_t to be the same size");
|
|
|
|
static_assert(uintptr_t(-1) > uintptr_t(0),
|
|
|
|
"expect uintptr_t to be unsigned");
|
|
|
|
static_assert(size_t(-1) > size_t(0),
|
|
|
|
"expect size_t to be unsigned");
|
2013-05-07 18:48:59 +00:00
|
|
|
uintptr_t framePoisonValue = mozPoisonValue();
|
2012-04-12 00:17:44 +00:00
|
|
|
return size_t(framePoisonValue - uintptr_t(mValueStorage)) /
|
2011-03-18 03:14:31 +00:00
|
|
|
sizeof(nsCSSValue);
|
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
nsRuleData::nsRuleData(uint32_t aSIDs, nsCSSValue* aValueStorage,
|
2011-03-18 03:14:31 +00:00
|
|
|
nsPresContext* aContext, nsStyleContext* aStyleContext)
|
|
|
|
: mSIDs(aSIDs),
|
2011-10-17 14:59:28 +00:00
|
|
|
mCanStoreInRuleTree(true),
|
2011-03-18 03:14:31 +00:00
|
|
|
mPresContext(aContext),
|
|
|
|
mStyleContext(aStyleContext),
|
|
|
|
mValueStorage(aValueStorage)
|
|
|
|
{
|
2011-04-04 11:41:02 +00:00
|
|
|
#ifndef MOZ_VALGRIND
|
2011-03-18 03:14:31 +00:00
|
|
|
size_t framePoisonOffset = GetPoisonOffset();
|
|
|
|
for (size_t i = 0; i < nsStyleStructID_Length; ++i) {
|
|
|
|
mValueOffsets[i] = framePoisonOffset;
|
|
|
|
}
|
2011-04-04 11:41:02 +00:00
|
|
|
#endif
|
2011-03-18 03:14:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
nsRuleData::~nsRuleData()
|
|
|
|
{
|
2011-04-04 11:41:02 +00:00
|
|
|
#ifndef MOZ_VALGRIND
|
2011-03-18 03:14:31 +00:00
|
|
|
// assert nothing in mSIDs has poison value
|
|
|
|
size_t framePoisonOffset = GetPoisonOffset();
|
|
|
|
for (size_t i = 0; i < nsStyleStructID_Length; ++i) {
|
|
|
|
NS_ABORT_IF_FALSE(!(mSIDs & (1 << i)) ||
|
|
|
|
mValueOffsets[i] != framePoisonOffset,
|
|
|
|
"value in SIDs was left with poison offset");
|
|
|
|
}
|
2011-04-04 11:41:02 +00:00
|
|
|
#endif
|
2011-03-18 03:14:31 +00:00
|
|
|
}
|
|
|
|
#endif
|