本文整理汇总了C++中NS_ABORT_IF_FALSE函数的典型用法代码示例。如果您正苦于以下问题:C++ NS_ABORT_IF_FALSE函数的具体用法?C++ NS_ABORT_IF_FALSE怎么用?C++ NS_ABORT_IF_FALSE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NS_ABORT_IF_FALSE函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ComputeSize
void
nsCSSExpandedDataBlock::Compress(nsCSSCompressedDataBlock **aNormalBlock,
nsCSSCompressedDataBlock **aImportantBlock)
{
nsAutoPtr<nsCSSCompressedDataBlock> result_normal, result_important;
char *cursor_normal, *cursor_important;
ComputeSizeResult size = ComputeSize();
result_normal = new(size.normal) nsCSSCompressedDataBlock();
cursor_normal = result_normal->Block();
if (size.important != 0) {
result_important = new(size.important) nsCSSCompressedDataBlock();
cursor_important = result_important->Block();
} else {
result_important = nsnull;
cursor_important = nsnull;
}
/*
* Save needless copying and allocation by copying the memory
* corresponding to the stored data in the expanded block, and then
* clearing the data in the expanded block.
*/
for (size_t iHigh = 0; iHigh < nsCSSPropertySet::kChunkCount; ++iHigh) {
if (!mPropertiesSet.HasPropertyInChunk(iHigh))
continue;
for (size_t iLow = 0; iLow < nsCSSPropertySet::kBitsInChunk; ++iLow) {
if (!mPropertiesSet.HasPropertyAt(iHigh, iLow))
continue;
nsCSSProperty iProp = nsCSSPropertySet::CSSPropertyAt(iHigh, iLow);
NS_ABORT_IF_FALSE(!nsCSSProps::IsShorthand(iProp), "out of range");
PRBool important =
mPropertiesImportant.HasPropertyAt(iHigh, iLow);
char *&cursor = important ? cursor_important : cursor_normal;
nsCSSCompressedDataBlock *result =
important ? result_important : result_normal;
nsCSSValue* val = PropertyAt(iProp);
NS_ABORT_IF_FALSE(val->GetUnit() != eCSSUnit_Null,
"Null value while compressing");
CDBValueStorage *storage =
reinterpret_cast<CDBValueStorage*>(cursor);
storage->property = iProp;
memcpy(&storage->value, val, sizeof(nsCSSValue));
new (val) nsCSSValue();
cursor += CDBValueStorage_advance;
result->mStyleBits |=
nsCachedStyleData::GetBitForSID(nsCSSProps::kSIDTable[iProp]);
}
}
result_normal->mBlockEnd = cursor_normal;
NS_ABORT_IF_FALSE(result_normal->DataSize() == ptrdiff_t(size.normal),
"size miscalculation");
if (result_important) {
result_important->mBlockEnd = cursor_important;
NS_ABORT_IF_FALSE(result_important->DataSize() ==
ptrdiff_t(size.important),
"size miscalculation");
}
ClearSets();
AssertInitialState();
*aNormalBlock = result_normal.forget();
*aImportantBlock = result_important.forget();
}
开发者ID:Akin-Net,项目名称:mozilla-central,代码行数:68,代码来源:nsCSSDataBlock.cpp
示例2: NS_ABORT_IF_FALSE
int64_t
WaveReader::TimeToBytes(double aTime) const
{
NS_ABORT_IF_FALSE(aTime >= 0.0f, "Must be >= 0");
return RoundDownToFrame(int64_t(aTime * mSampleRate * mFrameSize));
}
开发者ID:b10n1k,项目名称:mozilla-central,代码行数:6,代码来源:WaveReader.cpp
示例3: NS_ABORT_IF_FALSE
double
TimeDuration::ToSeconds() const
{
NS_ABORT_IF_FALSE(gInitialized, "calling TimeDuration too early");
return (mValue * sNsPerTick) / kNsPerSecd;
}
开发者ID:FunkyVerb,项目名称:devtools-window,代码行数:6,代码来源:TimeStamp_darwin.cpp
示例4: mon
// aTime is the time in ms the samples were inserted into MediaStreamGraph
nsresult
AudioStream::Write(const AudioDataValue* aBuf, uint32_t aFrames, TimeStamp *aTime)
{
MonitorAutoLock mon(mMonitor);
if (!mCubebStream || mState == ERRORED) {
return NS_ERROR_FAILURE;
}
NS_ASSERTION(mState == INITIALIZED || mState == STARTED,
"Stream write in unexpected state.");
// Downmix to Stereo.
if (mChannels > 2 && mChannels <= 8) {
DownmixAudioToStereo(const_cast<AudioDataValue*> (aBuf), mChannels, aFrames);
}
else if (mChannels > 8) {
return NS_ERROR_FAILURE;
}
const uint8_t* src = reinterpret_cast<const uint8_t*>(aBuf);
uint32_t bytesToCopy = FramesToBytes(aFrames);
// XXX this will need to change if we want to enable this on-the-fly!
if (PR_LOG_TEST(GetLatencyLog(), PR_LOG_DEBUG)) {
// Record the position and time this data was inserted
int64_t timeMs;
if (aTime && !aTime->IsNull()) {
if (mStartTime.IsNull()) {
AsyncLatencyLogger::Get(true)->GetStartTime(mStartTime);
}
timeMs = (*aTime - mStartTime).ToMilliseconds();
} else {
timeMs = 0;
}
struct Inserts insert = { timeMs, aFrames};
mInserts.AppendElement(insert);
}
while (bytesToCopy > 0) {
uint32_t available = std::min(bytesToCopy, mBuffer.Available());
NS_ABORT_IF_FALSE(available % mBytesPerFrame == 0,
"Must copy complete frames.");
mBuffer.AppendElements(src, available);
src += available;
bytesToCopy -= available;
if (bytesToCopy > 0) {
// If we are not playing, but our buffer is full, start playing to make
// room for soon-to-be-decoded data.
if (mState != STARTED) {
StartUnlocked();
if (mState != STARTED) {
return NS_ERROR_FAILURE;
}
}
mon.Wait();
}
}
mWritten += aFrames;
return NS_OK;
}
开发者ID:JCROM-FxOS,项目名称:b2jc_gecko,代码行数:63,代码来源:AudioStream.cpp
示例5: LOG_SCOPE_WITH_PARAM
nsresult imgRequest::RemoveProxy(imgRequestProxy *proxy, nsresult aStatus, PRBool aNotify)
{
LOG_SCOPE_WITH_PARAM(gImgLog, "imgRequest::RemoveProxy", "proxy", proxy);
mObservers.RemoveElement(proxy);
/* Check mState below before we potentially call Cancel() below. Since
Cancel() may result in OnStopRequest being called back before Cancel()
returns, leaving mState in a different state then the one it was in at
this point.
*/
if (aNotify) {
// make sure that observer gets an OnStopDecode message sent to it
if (!(mState & onStopDecode)) {
proxy->OnStopDecode(aStatus, nsnull);
}
}
// make sure that observer gets an OnStopRequest message sent to it
if (!(mState & onStopRequest)) {
proxy->OnStopRequest(nsnull, nsnull, NS_BINDING_ABORTED, PR_TRUE);
}
if (mImage && !HaveProxyWithObserver(nsnull)) {
LOG_MSG(gImgLog, "imgRequest::RemoveProxy", "stopping animation");
mImage->StopAnimation();
}
if (mObservers.IsEmpty()) {
// If we have no observers, there's nothing holding us alive. If we haven't
// been cancelled and thus removed from the cache, tell the image loader so
// we can be evicted from the cache.
if (mCacheEntry) {
NS_ABORT_IF_FALSE(mKeyURI, "Removing last observer without key uri.");
imgLoader::SetHasNoProxies(mKeyURI, mCacheEntry);
}
#if defined(PR_LOGGING)
else {
nsCAutoString spec;
mKeyURI->GetSpec(spec);
LOG_MSG_WITH_PARAM(gImgLog, "imgRequest::RemoveProxy no cache entry", "uri", spec.get());
}
#endif
/* If |aStatus| is a failure code, then cancel the load if it is still in progress.
Otherwise, let the load continue, keeping 'this' in the cache with no observers.
This way, if a proxy is destroyed without calling cancel on it, it won't leak
and won't leave a bad pointer in mObservers.
*/
if (mRequest && mLoading && NS_FAILED(aStatus)) {
LOG_MSG(gImgLog, "imgRequest::RemoveProxy", "load in progress. canceling");
mImageStatus |= imgIRequest::STATUS_LOAD_PARTIAL;
this->Cancel(NS_BINDING_ABORTED);
}
/* break the cycle from the cache entry. */
mCacheEntry = nsnull;
}
// If a proxy is removed for a reason other than its owner being
// changed, remove the proxy from the loadgroup.
if (aStatus != NS_IMAGELIB_CHANGING_OWNER)
proxy->RemoveFromLoadGroup(PR_TRUE);
return NS_OK;
}
开发者ID:amyvmiwei,项目名称:firefox,代码行数:72,代码来源:imgRequest.cpp
示例6: LOG3
nsresult
SpdyStream2::ReadSegments(nsAHttpSegmentReader *reader,
uint32_t count,
uint32_t *countRead)
{
LOG3(("SpdyStream2 %p ReadSegments reader=%p count=%d state=%x",
this, reader, count, mUpstreamState));
NS_ABORT_IF_FALSE(PR_GetCurrentThread() == gSocketThread, "wrong thread");
nsresult rv = NS_ERROR_UNEXPECTED;
mRequestBlockedOnRead = 0;
switch (mUpstreamState) {
case GENERATING_SYN_STREAM:
case GENERATING_REQUEST_BODY:
case SENDING_REQUEST_BODY:
// Call into the HTTP Transaction to generate the HTTP request
// stream. That stream will show up in OnReadSegment().
mSegmentReader = reader;
rv = mTransaction->ReadSegments(this, count, countRead);
mSegmentReader = nullptr;
// Check to see if the transaction's request could be written out now.
// If not, mark the stream for callback when writing can proceed.
if (NS_SUCCEEDED(rv) &&
mUpstreamState == GENERATING_SYN_STREAM &&
!mSynFrameComplete)
mSession->TransactionHasDataToWrite(this);
// mTxinlineFrameUsed represents any queued un-sent frame. It might
// be 0 if there is no such frame, which is not a gurantee that we
// don't have more request body to send - just that any data that was
// sent comprised a complete SPDY frame. Likewise, a non 0 value is
// a queued, but complete, spdy frame length.
// Mark that we are blocked on read if the http transaction needs to
// provide more of the request message body and there is nothing queued
// for writing
if (rv == NS_BASE_STREAM_WOULD_BLOCK && !mTxInlineFrameUsed)
mRequestBlockedOnRead = 1;
if (!mTxInlineFrameUsed && NS_SUCCEEDED(rv) && (!*countRead)) {
LOG3(("ReadSegments %p: Sending request data complete, mUpstreamState=%x",
this, mUpstreamState));
if (mSentFinOnData) {
ChangeState(UPSTREAM_COMPLETE);
}
else {
GenerateDataFrameHeader(0, true);
ChangeState(SENDING_FIN_STREAM);
mSession->TransactionHasDataToWrite(this);
rv = NS_BASE_STREAM_WOULD_BLOCK;
}
}
break;
case SENDING_FIN_STREAM:
// We were trying to send the FIN-STREAM but were blocked from
// sending it out - try again.
if (!mSentFinOnData) {
mSegmentReader = reader;
rv = TransmitFrame(nullptr, nullptr, false);
mSegmentReader = nullptr;
NS_ABORT_IF_FALSE(NS_FAILED(rv) || !mTxInlineFrameUsed,
"Transmit Frame should be all or nothing");
if (NS_SUCCEEDED(rv))
ChangeState(UPSTREAM_COMPLETE);
}
else {
rv = NS_OK;
mTxInlineFrameUsed = 0; // cancel fin data packet
ChangeState(UPSTREAM_COMPLETE);
}
*countRead = 0;
// don't change OK to WOULD BLOCK. we are really done sending if OK
break;
case UPSTREAM_COMPLETE:
*countRead = 0;
rv = NS_OK;
break;
default:
NS_ABORT_IF_FALSE(false, "SpdyStream2::ReadSegments unknown state");
break;
}
return rv;
}
开发者ID:Tripleman,项目名称:mozilla-central,代码行数:93,代码来源:SpdyStream2.cpp
示例7: NS_ABORT_IF_FALSE
nsresult
SpdyStream2::ParseHttpRequestHeaders(const char *buf,
uint32_t avail,
uint32_t *countUsed)
{
// Returns NS_OK even if the headers are incomplete
// set mSynFrameComplete flag if they are complete
NS_ABORT_IF_FALSE(PR_GetCurrentThread() == gSocketThread, "wrong thread");
NS_ABORT_IF_FALSE(mUpstreamState == GENERATING_SYN_STREAM, "wrong state");
LOG3(("SpdyStream2::ParseHttpRequestHeaders %p avail=%d state=%x",
this, avail, mUpstreamState));
mFlatHttpRequestHeaders.Append(buf, avail);
// We can use the simple double crlf because firefox is the
// only client we are parsing
int32_t endHeader = mFlatHttpRequestHeaders.Find("\r\n\r\n");
if (endHeader == kNotFound) {
// We don't have all the headers yet
LOG3(("SpdyStream2::ParseHttpRequestHeaders %p "
"Need more header bytes. Len = %d",
this, mFlatHttpRequestHeaders.Length()));
*countUsed = avail;
return NS_OK;
}
// We have recvd all the headers, trim the local
// buffer of the final empty line, and set countUsed to reflect
// the whole header has been consumed.
uint32_t oldLen = mFlatHttpRequestHeaders.Length();
mFlatHttpRequestHeaders.SetLength(endHeader + 2);
*countUsed = avail - (oldLen - endHeader) + 4;
mSynFrameComplete = 1;
// It is now OK to assign a streamID that we are assured will
// be monotonically increasing amongst syn-streams on this
// session
mStreamID = mSession->RegisterStreamID(this);
NS_ABORT_IF_FALSE(mStreamID & 1,
"Spdy Stream Channel ID must be odd");
if (mStreamID >= 0x80000000) {
// streamID must fit in 31 bits. This is theoretically possible
// because stream ID assignment is asynchronous to stream creation
// because of the protocol requirement that the ID in syn-stream
// be monotonically increasing. In reality this is really not possible
// because new streams stop being added to a session with 0x10000000 / 2
// IDs still available and no race condition is going to bridge that gap,
// so we can be comfortable on just erroring out for correctness in that
// case.
LOG3(("Stream assigned out of range ID: 0x%X", mStreamID));
return NS_ERROR_UNEXPECTED;
}
// Now we need to convert the flat http headers into a set
// of SPDY headers.. writing to mTxInlineFrame{sz}
mTxInlineFrame[0] = SpdySession2::kFlag_Control;
mTxInlineFrame[1] = 2; /* version */
mTxInlineFrame[2] = 0;
mTxInlineFrame[3] = SpdySession2::CONTROL_TYPE_SYN_STREAM;
// 4 to 7 are length and flags, we'll fill that in later
uint32_t networkOrderID = PR_htonl(mStreamID);
memcpy(mTxInlineFrame + 8, &networkOrderID, 4);
// this is the associated-to field, which is not used sending
// from the client in the http binding
memset (mTxInlineFrame + 12, 0, 4);
// Priority flags are the C0 mask of byte 16.
//
// The other 6 bits of 16 are unused. Spdy/3 will expand
// priority to 3 bits.
//
// When Spdy/3 implements WINDOW_UPDATE the lowest priority
// streams over a threshold (32?) should be given tiny
// receive windows, separate from their spdy priority
//
if (mPriority >= nsISupportsPriority::PRIORITY_LOW)
mTxInlineFrame[16] = SpdySession2::kPri03;
else if (mPriority >= nsISupportsPriority::PRIORITY_NORMAL)
mTxInlineFrame[16] = SpdySession2::kPri02;
else if (mPriority >= nsISupportsPriority::PRIORITY_HIGH)
mTxInlineFrame[16] = SpdySession2::kPri01;
else
mTxInlineFrame[16] = SpdySession2::kPri00;
mTxInlineFrame[17] = 0; /* unused */
const char *methodHeader = mTransaction->RequestHead()->Method().get();
nsCString hostHeader;
mTransaction->RequestHead()->GetHeader(nsHttp::Host, hostHeader);
nsCString versionHeader;
if (mTransaction->RequestHead()->Version() == NS_HTTP_VERSION_1_1)
//.........这里部分代码省略.........
开发者ID:Tripleman,项目名称:mozilla-central,代码行数:101,代码来源:SpdyStream2.cpp
示例8: NS_ABORT_IF_FALSE
void
nsGIFDecoder2::WriteInternal(const char *aBuffer, uint32_t aCount)
{
NS_ABORT_IF_FALSE(!HasError(), "Shouldn't call WriteInternal after error!");
// These variables changed names, and renaming would make a much bigger patch :(
const uint8_t *buf = (const uint8_t *)aBuffer;
uint32_t len = aCount;
const uint8_t *q = buf;
// Add what we have sofar to the block
// If previous call to me left something in the hold first complete current block
// Or if we are filling the colormaps, first complete the colormap
uint8_t* p = (mGIFStruct.state == gif_global_colormap) ? (uint8_t*)mGIFStruct.global_colormap :
(mGIFStruct.state == gif_image_colormap) ? (uint8_t*)mColormap :
(mGIFStruct.bytes_in_hold) ? mGIFStruct.hold : nullptr;
if (p) {
// Add what we have sofar to the block
uint32_t l = NS_MIN(len, mGIFStruct.bytes_to_consume);
memcpy(p+mGIFStruct.bytes_in_hold, buf, l);
if (l < mGIFStruct.bytes_to_consume) {
// Not enough in 'buf' to complete current block, get more
mGIFStruct.bytes_in_hold += l;
mGIFStruct.bytes_to_consume -= l;
return;
}
// Reset hold buffer count
mGIFStruct.bytes_in_hold = 0;
// Point 'q' to complete block in hold (or in colormap)
q = p;
}
// Invariant:
// 'q' is start of current to be processed block (hold, colormap or buf)
// 'bytes_to_consume' is number of bytes to consume from 'buf'
// 'buf' points to the bytes to be consumed from the input buffer
// 'len' is number of bytes left in input buffer from position 'buf'.
// At entrance of the for loop will 'buf' will be moved 'bytes_to_consume'
// to point to next buffer, 'len' is adjusted accordingly.
// So that next round in for loop, q gets pointed to the next buffer.
for (;len >= mGIFStruct.bytes_to_consume; q=buf) {
// Eat the current block from the buffer, q keeps pointed at current block
buf += mGIFStruct.bytes_to_consume;
len -= mGIFStruct.bytes_to_consume;
switch (mGIFStruct.state)
{
case gif_lzw:
if (!DoLzw(q)) {
mGIFStruct.state = gif_error;
break;
}
GETN(1, gif_sub_block);
break;
case gif_lzw_start:
{
// Make sure the transparent pixel is transparent in the colormap
if (mGIFStruct.is_transparent) {
// Save old value so we can restore it later
if (mColormap == mGIFStruct.global_colormap)
mOldColor = mColormap[mGIFStruct.tpixel];
mColormap[mGIFStruct.tpixel] = 0;
}
/* Initialize LZW parser/decoder */
mGIFStruct.datasize = *q;
const int clear_code = ClearCode();
if (mGIFStruct.datasize > MAX_LZW_BITS ||
clear_code >= MAX_BITS) {
mGIFStruct.state = gif_error;
break;
}
mGIFStruct.avail = clear_code + 2;
mGIFStruct.oldcode = -1;
mGIFStruct.codesize = mGIFStruct.datasize + 1;
mGIFStruct.codemask = (1 << mGIFStruct.codesize) - 1;
mGIFStruct.datum = mGIFStruct.bits = 0;
/* init the tables */
for (int i = 0; i < clear_code; i++)
mGIFStruct.suffix[i] = i;
mGIFStruct.stackp = mGIFStruct.stack;
GETN(1, gif_sub_block);
}
break;
/* All GIF files begin with "GIF87a" or "GIF89a" */
case gif_type:
if (!strncmp((char*)q, "GIF89a", 6)) {
mGIFStruct.version = 89;
} else if (!strncmp((char*)q, "GIF87a", 6)) {
mGIFStruct.version = 87;
} else {
//.........这里部分代码省略.........
开发者ID:Lynart,项目名称:mozilla-central,代码行数:101,代码来源:nsGIFDecoder2.cpp
示例9: NS_ABORT_IF_FALSE
NS_IMETHODIMP
nsSVGForeignObjectFrame::PaintSVG(nsSVGRenderState *aContext,
const nsIntRect *aDirtyRect)
{
NS_ABORT_IF_FALSE(aDirtyRect, "We expect aDirtyRect to be non-null");
if (IsDisabled())
return NS_OK;
nsIFrame* kid = GetFirstPrincipalChild();
if (!kid)
return NS_OK;
gfxMatrix matrixForChildren = GetCanvasTMForChildren();
gfxMatrix matrix = GetCanvasTM();
nsRenderingContext *ctx = aContext->GetRenderingContext(this);
if (!ctx || matrixForChildren.IsSingular()) {
NS_WARNING("Can't render foreignObject element!");
return NS_ERROR_FAILURE;
}
/* Check if we need to draw anything. */
PRInt32 appUnitsPerDevPx = PresContext()->AppUnitsPerDevPixel();
if (!mRect.ToOutsidePixels(appUnitsPerDevPx).Intersects(*aDirtyRect))
return NS_OK;
gfxContext *gfx = aContext->GetGfxContext();
gfx->Save();
if (GetStyleDisplay()->IsScrollableOverflow()) {
float x, y, width, height;
static_cast<nsSVGElement*>(mContent)->
GetAnimatedLengthValues(&x, &y, &width, &height, nsnull);
gfxRect clipRect =
nsSVGUtils::GetClipRectForFrame(this, 0.0f, 0.0f, width, height);
nsSVGUtils::SetClipRect(gfx, matrix, clipRect);
}
gfx->Multiply(matrixForChildren);
// Transform the dirty rect into the rectangle containing the
// transformed dirty rect.
gfxMatrix invmatrix = matrix.Invert();
NS_ASSERTION(!invmatrix.IsSingular(),
"inverse of non-singular matrix should be non-singular");
gfxRect transDirtyRect = gfxRect(aDirtyRect->x, aDirtyRect->y,
aDirtyRect->width, aDirtyRect->height);
transDirtyRect = invmatrix.TransformBounds(transDirtyRect);
transDirtyRect.Scale(nsPresContext::AppUnitsPerCSSPixel());
nsPoint tl(NSToCoordFloor(transDirtyRect.X()),
NSToCoordFloor(transDirtyRect.Y()));
nsPoint br(NSToCoordCeil(transDirtyRect.XMost()),
NSToCoordCeil(transDirtyRect.YMost()));
nsRect kidDirtyRect(tl.x, tl.y, br.x - tl.x, br.y - tl.y);
kidDirtyRect.IntersectRect(kidDirtyRect, kid->GetRect());
PRUint32 flags = nsLayoutUtils::PAINT_IN_TRANSFORM;
if (aContext->IsPaintingToWindow()) {
flags |= nsLayoutUtils::PAINT_TO_WINDOW;
}
nsresult rv = nsLayoutUtils::PaintFrame(ctx, kid, nsRegion(kidDirtyRect),
NS_RGBA(0,0,0,0), flags);
gfx->Restore();
return rv;
}
开发者ID:moussa1,项目名称:mozilla-central,代码行数:74,代码来源:nsSVGForeignObjectFrame.cpp
示例10: RebuildPathAndVerticesFromBasicAttrs
void
SVGMotionSMILAnimationFunction::
RebuildPathAndVerticesFromBasicAttrs(const nsIContent* aContextElem)
{
NS_ABORT_IF_FALSE(!HasAttr(nsGkAtoms::path),
"Should be using |path| attr if we have it");
NS_ABORT_IF_FALSE(!mPath, "regenerating when we aleady have path");
NS_ABORT_IF_FALSE(mPathVertices.IsEmpty(),
"regenerating when we already have vertices");
if (!aContextElem->IsSVG()) {
NS_ERROR("Uh oh, SVG animateMotion element targeting a non-SVG node");
return;
}
SVGMotionSMILPathUtils::PathGenerator
pathGenerator(static_cast<const nsSVGElement*>(aContextElem));
bool success = false;
if (HasAttr(nsGkAtoms::values)) {
// Generate path based on our values array
mPathSourceType = ePathSourceType_ValuesAttr;
const nsAString& valuesStr = GetAttr(nsGkAtoms::values)->GetStringValue();
SVGMotionSMILPathUtils::MotionValueParser parser(&pathGenerator,
&mPathVertices);
success =
NS_SUCCEEDED(nsSMILParserUtils::ParseValuesGeneric(valuesStr, parser));
} else if (HasAttr(nsGkAtoms::to) || HasAttr(nsGkAtoms::by)) {
// Apply 'from' value (or a dummy 0,0 'from' value)
if (HasAttr(nsGkAtoms::from)) {
const nsAString& fromStr = GetAttr(nsGkAtoms::from)->GetStringValue();
success = pathGenerator.MoveToAbsolute(fromStr);
mPathVertices.AppendElement(0.0);
} else {
// Create dummy 'from' value at 0,0, if we're doing by-animation.
// (NOTE: We don't add the dummy 0-point to our list for *to-animation*,
// because the nsSMILAnimationFunction logic for to-animation doesn't
// expect a dummy value. It only expects one value: the final 'to' value.)
pathGenerator.MoveToOrigin();
if (!HasAttr(nsGkAtoms::to)) {
mPathVertices.AppendElement(0.0);
}
success = true;
}
// Apply 'to' or 'by' value
if (success) {
double dist;
if (HasAttr(nsGkAtoms::to)) {
mPathSourceType = ePathSourceType_ToAttr;
const nsAString& toStr = GetAttr(nsGkAtoms::to)->GetStringValue();
success = pathGenerator.LineToAbsolute(toStr, dist);
} else { // HasAttr(nsGkAtoms::by)
mPathSourceType = ePathSourceType_ByAttr;
const nsAString& byStr = GetAttr(nsGkAtoms::by)->GetStringValue();
success = pathGenerator.LineToRelative(byStr, dist);
}
if (success) {
mPathVertices.AppendElement(dist);
}
}
}
if (success) {
mPath = pathGenerator.GetResultingPath();
} else {
// Parse failure. Leave path as null, and clear path-related member data.
mPathVertices.Clear();
}
}
开发者ID:cabelitos,项目名称:mozilla-central,代码行数:69,代码来源:SVGMotionSMILAnimationFunction.cpp
示例11: NS_ENSURE_ARG_POINTER
NS_IMETHODIMP nsDeviceContextSpecQt::GetSurfaceForPrinter(
gfxASurface** aSurface)
{
NS_ENSURE_ARG_POINTER(aSurface);
*aSurface = nullptr;
double width, height;
mPrintSettings->GetEffectivePageSize(&width, &height);
// If we're in landscape mode, we'll be rotating the output --
// need to swap width & height.
int32_t orientation;
mPrintSettings->GetOrientation(&orientation);
if (nsIPrintSettings::kLandscapeOrientation == orientation) {
double tmp = width;
width = height;
height = tmp;
}
// convert twips to points
width /= TWIPS_PER_POINT_FLOAT;
height /= TWIPS_PER_POINT_FLOAT;
DO_PR_DEBUG_LOG(("\"%s\", %f, %f\n", mPath, width, height));
QTemporaryFile file;
if(!file.open()) {
return NS_ERROR_GFX_PRINTER_COULD_NOT_OPEN_FILE;
}
file.setAutoRemove(false);
nsresult rv = NS_NewNativeLocalFile(
nsDependentCString(file.fileName().toUtf8().constData()),
false,
getter_AddRefs(mSpoolFile));
if (NS_FAILED(rv)) {
file.remove();
return NS_ERROR_GFX_PRINTER_COULD_NOT_OPEN_FILE;
}
mSpoolName = file.fileName().toUtf8().constData();
mSpoolFile->SetPermissions(0600);
nsCOMPtr<nsIFileOutputStream> stream =
do_CreateInstance("@mozilla.org/network/file-output-stream;1");
rv = stream->Init(mSpoolFile, -1, -1, 0);
if (NS_FAILED(rv))
return rv;
int16_t format;
mPrintSettings->GetOutputFormat(&format);
nsRefPtr<gfxASurface> surface;
gfxSize surfaceSize(width, height);
if (format == nsIPrintSettings::kOutputFormatNative) {
if (mIsPPreview) {
// There is nothing to detect on Print Preview, use PS.
// TODO: implement for Qt?
//format = nsIPrintSettings::kOutputFormatPS;
return NS_ERROR_NOT_IMPLEMENTED;
}
format = nsIPrintSettings::kOutputFormatPDF;
}
if (format == nsIPrintSettings::kOutputFormatPDF) {
surface = new gfxPDFSurface(stream, surfaceSize);
} else {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_ABORT_IF_FALSE(surface, "valid address expected");
surface.swap(*aSurface);
return NS_OK;
}
开发者ID:Andrel322,项目名称:gecko-dev,代码行数:77,代码来源:nsDeviceContextSpecQt.cpp
示例12: GetCubebContext
nsresult
AudioStream::Init(int32_t aNumChannels, int32_t aRate,
const dom::AudioChannelType aAudioChannelType,
LatencyRequest aLatencyRequest)
{
cubeb* cubebContext = GetCubebContext();
if (!cubebContext || aNumChannels < 0 || aRate < 0) {
return NS_ERROR_FAILURE;
}
PR_LOG(gAudioStreamLog, PR_LOG_DEBUG,
("%s channels: %d, rate: %d", __FUNCTION__, aNumChannels, aRate));
mInRate = mOutRate = aRate;
mChannels = aNumChannels;
mOutChannels = (aNumChannels > 2) ? 2 : aNumChannels;
mLatencyRequest = aLatencyRequest;
mDumpFile = OpenDumpFile(this);
cubeb_stream_params params;
params.rate = aRate;
params.channels = mOutChannels;
#if defined(__ANDROID__)
#if defined(MOZ_B2G)
params.stream_type = ConvertChannelToCubebType(aAudioChannelType);
#else
params.stream_type = CUBEB_STREAM_TYPE_MUSIC;
#endif
if (params.stream_type == CUBEB_STREAM_TYPE_MAX) {
return NS_ERROR_INVALID_ARG;
}
#endif
if (AUDIO_OUTPUT_FORMAT == AUDIO_FORMAT_S16) {
params.format = CUBEB_SAMPLE_S16NE;
} else {
params.format = CUBEB_SAMPLE_FLOAT32NE;
}
mBytesPerFrame = sizeof(AudioDataValue) * mOutChannels;
mAudioClock.Init();
// If the latency pref is set, use it. Otherwise, if this stream is intended
// for low latency playback, try to get the lowest latency possible.
// Otherwise, for normal streams, use 100ms.
uint32_t latency;
if (aLatencyRequest == LowLatency && !CubebLatencyPrefSet()) {
if (cubeb_get_min_latency(cubebContext, params, &latency) != CUBEB_OK) {
latency = GetCubebLatency();
}
} else {
latency = GetCubebLatency();
}
{
cubeb_stream* stream;
if (cubeb_stream_init(cubebContext, &stream, "AudioStream", params,
latency, DataCallback_S, StateCallback_S, this) == CUBEB_OK) {
mCubebStream.own(stream);
}
}
if (!mCubebStream) {
return NS_ERROR_FAILURE;
}
// Size mBuffer for one second of audio. This value is arbitrary, and was
// selected based on the observed behaviour of the existing AudioStream
// implementations.
uint32_t bufferLimit = FramesToBytes(aRate);
NS_ABORT_IF_FALSE(bufferLimit % mBytesPerFrame == 0, "Must buffer complete frames");
mBuffer.SetCapacity(bufferLimit);
// Start the stream right away when low latency has been requested. This means
// that the DataCallback will feed silence to cubeb, until the first frames
// are writtent to this AudioStream.
if (mLatencyRequest == LowLatency) {
Start();
}
return NS_OK;
}
开发者ID:JCROM-FxOS,项目名称:b2jc_gecko,代码行数:83,代码来源:AudioStream.cpp
示例13: mUnit
nsCSSValue::nsCSSValue(const nsCSSValue& aCopy)
: mUnit(aCopy.mUnit)
{
if (mUnit <= eCSSUnit_DummyInherit) {
// nothing to do, but put this important case first
}
else if (eCSSUnit_Percent <= mUnit) {
mValue.mFloat = aCopy.mValue.mFloat;
}
else if (UnitHasStringValue()) {
mValue.mString = aCopy.mValue.mString;
mValue.mString->AddRef();
}
else if (eCSSUnit_Integer <= mUnit && mUnit <= eCSSUnit_EnumColor) {
mValue.mInt = aCopy.mValue.mInt;
}
else if (eCSSUnit_Color == mUnit) {
mValue.mColor = aCopy.mValue.mColor;
}
else if (UnitHasArrayValue()) {
mValue.mArray = aCopy.mValue.mArray;
mValue.mArray->AddRef();
}
else if (eCSSUnit_URL == mUnit) {
mValue.mURL = aCopy.mValue.mURL;
mValue.mURL->AddRef();
}
else if (eCSSUnit_Image == mUnit) {
mValue.mImage = aCopy.mValue.mImage;
mValue.mImage->AddRef();
}
else if (eCSSUnit_Gradient == mUnit) {
mValue.mGradient = aCopy.mValue.mGradient;
mValue.mGradient->AddRef();
}
else if (eCSSUnit_Pair == mUnit) {
mValue.mPair = aCopy.mValue.mPair;
mValue.mPair->AddRef();
}
else if (eCSSUnit_Triplet == mUnit) {
mValue.mTriplet = aCopy.mValue.mTriplet;
mValue.mTriplet->AddRef();
}
else if (eCSSUnit_Rect == mUnit) {
mValue.mRect = aCopy.mValue.mRect;
mValue.mRect->AddRef();
}
else if (eCSSUnit_List == mUnit) {
mValue.mList = aCopy.mValue.mList;
mValue.mList->AddRef();
}
else if (eCSSUnit_ListDep == mUnit) {
mValue.mListDependent = aCopy.mValue.mListDependent;
}
else if (eCSSUnit_PairList == mUnit) {
mValue.mPairList = aCopy.mValue.mPairList;
mValue.mPairList->AddRef();
}
else if (eCSSUnit_PairListDep == mUnit) {
mValue.mPairListDependent = aCopy.mValue.mPairListDependent;
}
else {
NS_ABORT_IF_FALSE(false, "unknown unit");
}
}
开发者ID:mozilla,项目名称:mozilla-history,代码行数:65,代码来源:nsCSSValue.cpp
示例14: NS_ABORT_IF_FALSE
imgIRequest* nsCSSValue::GetImageValue() const
{
NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Image, "not an Image value");
return mValue.mImage->mRequest;
}
开发者ID:mozilla,项目名称:mozilla-history,代码行数:5,代码来源:nsCSSValue.cpp
示例15: NS_ABORT_IF_FALSE
already_AddRefed<Layer>
RenderFrameParent::BuildLayer(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame,
LayerManager* aManager,
const nsIntRect& aVisibleRect)
{
NS_ABORT_IF_FALSE(aFrame,
"makes no sense to have a shadow tree without a frame");
NS_ABORT_IF_FALSE(!mContainer ||
IsTempLayerManager(aManager) ||
mContainer->Manager() == aManager,
"retaining manager changed out from under us ... HELP!");
if (mContainer && mContainer->Manager() != aManager) {
// This can happen if aManager is a "temporary" manager, or if the
// widget's layer manager changed out from under us. We need to
// FIXME handle the former case somehow, probably with an API to
// draw a manager's subtree. The latter is bad bad bad, but the
// the NS_ABORT_IF_FALSE() above will flag it. Returning NULL
// here will just cause the shadow subtree not to be rendered.
return nsnull;
}
if (mContainer) {
ClearContainer(mContainer);
}
ContainerLayer* shadowRoot = GetRootLayer();
if (!shadowRoot) {
mContainer = nsnull;
return nsnull;
}
NS_ABORT_IF_FALSE(!shadowRoot || shadowRoot->Manager() == aManager,
"retaining manager changed out from under us ... HELP!");
// Wrap the shadow layer tree in mContainer.
if (!mContainer) {
mContainer = aManager->CreateContainerLayer();
}
NS_ABORT_IF_FALSE(!mContainer->GetFirstChild(),
"container of shadow tree shouldn't have a 'root' here");
mContainer->InsertAfter(shadowRoot, nsnull);
AssertInTopLevelChromeDoc(mContainer, aFrame);
ViewTransform transform;
TransformShadowTree(aBuilder, mFrameLoader, aFrame, shadowRoot, transform);
mContainer->SetClipRect(nsnull);
if (mFrameLoader->AsyncScrollEnabled()) {
const nsContentView* view = GetContentView(FrameMetrics::ROOT_SCROLL_ID);
BuildBackgroundPatternFor(mContainer,
shadowRoot,
view->GetViewConfig(),
mBackgroundColor,
aManager, aFrame);
}
mContainer->SetVisibleRegion(aVisibleRect);
return nsRefPtr<Layer>(mContainer).forget();
}
开发者ID:krad-radio,项目名称:mozilla-krad,代码行数:62,代码来源:RenderFrameParent.cpp
示例16: while
void
DOMSVGPathSegList::InternalListWillChangeTo(const SVGPathData& aNewValue)
{
// When the number of items in our internal counterpart changes, we MUST stay
// in sync. Everything in the scary comment in
// DOMSVGLengthList::InternalBaseValListWillChangeTo applies here just as
// much, but we have the additional issue that failing to stay in sync would
// mean that - assuming we aren't reading bad memory - we would likely end up
// decoding command types from argument floats when looking in our
// SVGPathData's data array! Either way, we'll likely then go down
// NS_NOTREACHED code paths, or end up reading/setting more bad memory!!
// The only time that our other DOM list type implementations remove items is
// if those items become surplus items due to an attribute change or SMIL
// animation sample shortening the list. In general though, they try to keep
// their existing DOM items, even when things change. To be consistent, we'd
// really like to do the same thing. However, because different types of path
// segment correspond to different DOMSVGPathSeg subclasses, the type of
// items in our list are generally not the same, which makes this harder for
// us. We have to remove DOM segments if their type is not the same as the
// type of the new internal segment at their index.
//
// We also need to sync up mInternalDataIndex, but since we need to loop over
// all the items in the new list checking types anyway, that's almost
// insignificant in terms of overhead.
//
// Note that this method is called on every single SMIL animation resample
// and we have no way to short circuit the overhead since we don't have a
// way to tell if the call is due to a new animation, or a resample of an
// existing animation (when the number and type of items would be the same).
// (Note that a new animation could start overriding an existing animation at
// any time, so checking IsAnimating() wouldn't work.) Because we get called
// on every sample, it would not be acceptable alternative to throw away all
// our items and let them be recreated lazily, since that would break what
// script sees!
PRUint32 length = mItems.Length();
PRUint32 index = 0;
PRUint32 dataLength = aNewValue.mData.Length();
PRUint32 dataIndex = 0; // index into aNewValue's raw data array
PRUint32 newSegType;
while (index < length && dataIndex < dataLength) {
newSegType = SVGPathSegUtils::DecodeType(aNewValue.mData[dataIndex]);
if (ItemAt(index) && ItemAt(index)->Type() != newSegType) {
ItemAt(index)->RemovingFromList();
ItemAt(index) = nsnull;
}
// Only after the RemovingFromList() can we touch mInternalDataIndex!
mItems[index].mInternalDataIndex = dataIndex;
++index;
dataIndex += 1 + SVGPathSegUtils::ArgCountForType(newSegType);
}
NS_ABORT_IF_FALSE((index == length && dataIndex <= dataLength) ||
(index <= length && dataIndex == dataLength),
"very bad - list corruption?");
if (index < length) {
// aNewValue has fewer items than our previous internal counterpart
PRUint32 newLength = index;
// Remove excess items from the list:
for (; index < length; ++index) {
if (ItemAt(index)) {
ItemAt(index)->RemovingFromList();
ItemAt(index) = nsnull;
}
}
// Only now may we truncate mItems
mItems.SetLength(newLength);
} else if (dataIndex < dataLength) {
// aNewValue has more items than our previous internal counterpart
// Sync mItems:
while (dataIndex < dataLength) {
if (mItems.Length() &&
mItems.Length() - 1 > DOMSVGPathSeg::MaxListIndex()) {
// It's safe to get out of sync with our internal list as long as we
// have FEWER items than it does.
return;
}
if (!mItems.AppendElement(ItemProxy(nsnull, dataIndex))) {
// OOM
Clear();
return;
}
dataIndex += 1 + SVGPathSegUtils::ArgCountForType(SVGPathSegUtils::DecodeType(aNewValue.mData[dataIndex]));
}
}
NS_ABORT_IF_FALSE(dataIndex == dataLength, "Serious processing error");
NS_ABORT_IF_FALSE(index == length, "Serious counting error");
}
开发者ID:h4ck3rm1k3,项目名称:v8monkey,代码行数:99,代码来源:DOMSVGPathSegList.cpp
注:本文中的NS_ABORT_IF_FALSE函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论