2010-07-23 11:00:21 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07: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 11:00:21 -07:00
|
|
|
|
|
|
|
#include "nsRuleData.h"
|
|
|
|
#include "nsCSSProps.h"
|
2011-03-17 20:14:31 -07:00
|
|
|
#include "nsPresArena.h"
|
|
|
|
|
2012-04-11 17:17:44 -07:00
|
|
|
#include "mozilla/StandardInteger.h"
|
|
|
|
|
2011-03-17 20:14:31 -07: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.
|
2012-04-11 17:17:44 -07:00
|
|
|
MOZ_STATIC_ASSERT(sizeof(uintptr_t) == sizeof(size_t),
|
|
|
|
"expect uintptr_t and size_t to be the same size");
|
|
|
|
MOZ_STATIC_ASSERT(uintptr_t(-1) > uintptr_t(0),
|
|
|
|
"expect uintptr_t to be unsigned");
|
2012-02-23 08:19:00 -08:00
|
|
|
MOZ_STATIC_ASSERT(size_t(-1) > size_t(0),
|
|
|
|
"expect size_t to be unsigned");
|
2012-04-11 17:17:44 -07:00
|
|
|
uintptr_t framePoisonValue = nsPresArena::GetPoisonValue();
|
|
|
|
return size_t(framePoisonValue - uintptr_t(mValueStorage)) /
|
2011-03-17 20:14:31 -07:00
|
|
|
sizeof(nsCSSValue);
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
nsRuleData::nsRuleData(uint32_t aSIDs, nsCSSValue* aValueStorage,
|
2011-03-17 20:14:31 -07:00
|
|
|
nsPresContext* aContext, nsStyleContext* aStyleContext)
|
|
|
|
: mSIDs(aSIDs),
|
2011-10-17 07:59:28 -07:00
|
|
|
mCanStoreInRuleTree(true),
|
2011-03-17 20:14:31 -07:00
|
|
|
mPresContext(aContext),
|
|
|
|
mStyleContext(aStyleContext),
|
2012-07-30 07:20:58 -07:00
|
|
|
mPostResolveCallback(nullptr),
|
2011-03-17 20:14:31 -07:00
|
|
|
mValueStorage(aValueStorage)
|
|
|
|
{
|
2011-04-04 04:41:02 -07:00
|
|
|
#ifndef MOZ_VALGRIND
|
2011-03-17 20:14:31 -07:00
|
|
|
size_t framePoisonOffset = GetPoisonOffset();
|
|
|
|
for (size_t i = 0; i < nsStyleStructID_Length; ++i) {
|
|
|
|
mValueOffsets[i] = framePoisonOffset;
|
|
|
|
}
|
2011-04-04 04:41:02 -07:00
|
|
|
#endif
|
2011-03-17 20:14:31 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
nsRuleData::~nsRuleData()
|
|
|
|
{
|
2011-04-04 04:41:02 -07:00
|
|
|
#ifndef MOZ_VALGRIND
|
2011-03-17 20:14:31 -07: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 04:41:02 -07:00
|
|
|
#endif
|
2011-03-17 20:14:31 -07:00
|
|
|
}
|
|
|
|
#endif
|