2010-07-23 22:00:21 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04: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 22:00:21 +04:00
|
|
|
|
|
|
|
#include "nsRuleData.h"
|
2011-03-18 06:14:31 +03:00
|
|
|
|
2013-05-07 22:48:59 +04:00
|
|
|
#include "mozilla/Poison.h"
|
2013-07-30 18:25:31 +04:00
|
|
|
#include <stdint.h>
|
2012-04-12 04:17:44 +04:00
|
|
|
|
2011-03-18 06:14:31 +03: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 21:59:53 +04: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 22:48:59 +04:00
|
|
|
uintptr_t framePoisonValue = mozPoisonValue();
|
2012-04-12 04:17:44 +04:00
|
|
|
return size_t(framePoisonValue - uintptr_t(mValueStorage)) /
|
2011-03-18 06:14:31 +03:00
|
|
|
sizeof(nsCSSValue);
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
nsRuleData::nsRuleData(uint32_t aSIDs, nsCSSValue* aValueStorage,
|
2011-03-18 06:14:31 +03:00
|
|
|
nsPresContext* aContext, nsStyleContext* aStyleContext)
|
|
|
|
: mSIDs(aSIDs),
|
|
|
|
mPresContext(aContext),
|
|
|
|
mStyleContext(aStyleContext),
|
|
|
|
mValueStorage(aValueStorage)
|
|
|
|
{
|
2011-04-04 15:41:02 +04:00
|
|
|
#ifndef MOZ_VALGRIND
|
2011-03-18 06:14:31 +03:00
|
|
|
size_t framePoisonOffset = GetPoisonOffset();
|
|
|
|
for (size_t i = 0; i < nsStyleStructID_Length; ++i) {
|
|
|
|
mValueOffsets[i] = framePoisonOffset;
|
|
|
|
}
|
2011-04-04 15:41:02 +04:00
|
|
|
#endif
|
2011-03-18 06:14:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
nsRuleData::~nsRuleData()
|
|
|
|
{
|
2011-04-04 15:41:02 +04:00
|
|
|
#ifndef MOZ_VALGRIND
|
2011-03-18 06:14:31 +03:00
|
|
|
// assert nothing in mSIDs has poison value
|
|
|
|
size_t framePoisonOffset = GetPoisonOffset();
|
|
|
|
for (size_t i = 0; i < nsStyleStructID_Length; ++i) {
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!(mSIDs & (1 << i)) || mValueOffsets[i] != framePoisonOffset,
|
|
|
|
"value in SIDs was left with poison offset");
|
2011-03-18 06:14:31 +03:00
|
|
|
}
|
2011-04-04 15:41:02 +04:00
|
|
|
#endif
|
2011-03-18 06:14:31 +03:00
|
|
|
}
|
|
|
|
#endif
|