static void ParseTime(PRTime tm, PRInt32& secs, PRInt32& msecs) { PRTime llsecs, llmsecs, tmp; LL_DIV(llsecs, tm, 1000000); LL_MOD(tmp, tm, 1000000); LL_DIV(llmsecs, tmp, 1000); LL_L2I(secs, llsecs); LL_L2I(msecs, llmsecs); }
/* PRBool getProperty (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in JSVal id, in JSValPtr vp); */ NS_IMETHODIMP calDateTime::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext * cx, JSObject * obj_, jsval id, jsval * vp, PRBool *_retval) { NS_ENSURE_ARG_POINTER(vp); NS_ENSURE_ARG_POINTER(_retval); if (JSVAL_IS_STRING(id)) { nsDependentString const jsid( reinterpret_cast<PRUnichar const*>( JS_GetStringChars(JSVAL_TO_STRING(id))), JS_GetStringLength(JSVAL_TO_STRING(id))); if (jsid.EqualsLiteral("jsDate")) { PRTime tmp, thousand; jsdouble msec; LL_I2L(thousand, 1000); LL_DIV(tmp, mNativeTime, thousand); LL_L2D(msec, tmp); JSObject *obj; PRBool b; if (NS_SUCCEEDED(mTimezone->GetIsFloating(&b)) && b) obj = js_NewDateObject(cx, mYear, mMonth, mDay, mHour, mMinute, mSecond); else obj = js_NewDateObjectMsec(cx, msec); *vp = OBJECT_TO_JSVAL(obj); *_retval = PR_TRUE; return NS_SUCCESS_I_DID_SOMETHING; } } *_retval = PR_TRUE; return NS_OK; }
static void TestIntervals(void) { PRStatus rv; PRUint32 delta; PRInt32 seconds; PRUint64 elapsed, thousand; PRTime timein, timeout; PRLock *ml = PR_NewLock(); PRCondVar *cv = PR_NewCondVar(ml); for (seconds = 0; seconds < 10; ++seconds) { PRIntervalTime ticks = PR_SecondsToInterval(seconds); PR_Lock(ml); timein = PR_Now(); rv = PR_WaitCondVar(cv, ticks); timeout = PR_Now(); PR_Unlock(ml); LL_SUB(elapsed, timeout, timein); LL_I2L(thousand, 1000); LL_DIV(elapsed, elapsed, thousand); LL_L2UI(delta, elapsed); if (debug_mode) PR_fprintf(output, "TestIntervals: %swaiting %ld seconds took %ld msecs\n", ((rv == PR_SUCCESS) ? "" : "FAILED "), seconds, delta); } PR_DestroyCondVar(cv); PR_DestroyLock(ml); if (debug_mode) PR_fprintf(output, "\n"); } /* TestIntervals */
PRMJ_NowS(void) { PRInt64 us, us2s; us = PRMJ_Now(); LL_UI2L(us2s, PRMJ_USEC_PER_SEC); LL_DIV(us, us, us2s); return us; }
static void testParseTimeString(PRTime t) { PRExplodedTime et; PRTime t2; char timeString[128]; char buf[128]; PRInt32 totalOffset; PRInt32 hourOffset, minOffset; const char *sign; PRInt64 usec_per_sec; /* Truncate the microsecond part of PRTime */ LL_I2L(usec_per_sec, PR_USEC_PER_SEC); LL_DIV(t, t, usec_per_sec); LL_MUL(t, t, usec_per_sec); PR_ExplodeTime(t, PR_LocalTimeParameters, &et); /* Print day of the week, month, day, hour, minute, and second */ PR_snprintf(timeString, 128, "%s %s %ld %02ld:%02ld:%02ld ", dayOfWeek[et.tm_wday], month[et.tm_month], et.tm_mday, et.tm_hour, et.tm_min, et.tm_sec); /* Print time zone */ totalOffset = et.tm_params.tp_gmt_offset + et.tm_params.tp_dst_offset; if (totalOffset == 0) { strcat(timeString, "GMT "); /* I wanted to use "UTC" here, but * PR_ParseTimeString doesn't * understand "UTC". */ } else { sign = "+"; if (totalOffset < 0) { totalOffset = -totalOffset; sign = "-"; } hourOffset = totalOffset / 3600; minOffset = (totalOffset % 3600) / 60; PR_snprintf(buf, 128, "%s%02ld%02ld ", sign, hourOffset, minOffset); strcat(timeString, buf); } /* Print year */ PR_snprintf(buf, 128, "%hd", et.tm_year); strcat(timeString, buf); if (PR_ParseTimeString(timeString, PR_FALSE, &t2) == PR_FAILURE) { fprintf(stderr, "PR_ParseTimeString() failed\n"); exit(1); } if (LL_NE(t, t2)) { fprintf(stderr, "PR_ParseTimeString() incorrect\n"); PR_snprintf(buf, 128, "t is %lld, t2 is %lld, time string is %s\n", t, t2, timeString); fprintf(stderr, "%s\n", buf); exit(1); } }
PRMJ_NowMS(void) { PRInt64 us, us2ms; us = PRMJ_Now(); LL_UI2L(us2ms, PRMJ_USEC_PER_MSEC); LL_DIV(us, us, us2ms); return us; }
static inline PRUint32 PRTimeToSeconds(PRTime t_usec) { PRTime usec_per_sec; PRUint32 t_sec; LL_I2L(usec_per_sec, PR_USEC_PER_SEC); LL_DIV(t_usec, t_usec, usec_per_sec); LL_L2I(t_sec, t_usec); return t_sec; }
static PRUint32 NowInMinutes() { PRTime now = PR_Now(), minutes, factor; LL_I2L(factor, 60 * PR_USEC_PER_SEC); LL_DIV(minutes, now, factor); PRUint32 result; LL_L2UI(result, minutes); return result; }
PRInt64 StatsManagerUtil::getSeconds(PRInt64 time) { PRInt64 temp = 0; PRInt64 dividend = 0; PRInt64 divisor = 0; LL_UI2L(temp, PR_USEC_PER_SEC/2); LL_ADD(dividend, time, temp); LL_UI2L(divisor, PR_USEC_PER_SEC); LL_DIV(temp, dividend, divisor); return temp; }
static void timePRTime32(void) { PRInt32 index = count; PRInt32 rv32; PRTime q; PRTime rv; LL_I2L(q, 1000000); for (;index--;) { rv = PR_Now(); LL_DIV(rv, rv, q); LL_L2I(rv32, rv); } }
/* returns an unsigned int containing the number of seconds in PR_Now() */ PRUint32 ssl_Time(void) { PRUint32 myTime; #if (defined(XP_UNIX) || defined(XP_WIN) || defined(_WINDOWS) || defined(XP_BEOS)) && !defined(_WIN32_WCE) myTime = time(NULL); /* accurate until the year 2038. */ #else /* portable, but possibly slower */ PRTime now; PRInt64 ll; now = PR_Now(); LL_I2L(ll, 1000000L); LL_DIV(now, now, ll); LL_L2UI(myTime, now); #endif return myTime; }
PRUint32 nsMailDatabase::GetMailboxModDate() { PRUint32 retModTime = 0; PRInt64 lastModTime; if (m_folderFile) { nsresult rv = m_folderFile->GetLastModifiedTime(&lastModTime); if (NS_SUCCEEDED(rv)) { PRTime temp64; PRInt64 thousand; LL_I2L(thousand, PR_MSEC_PER_SEC); LL_DIV(temp64, lastModTime, thousand); LL_L2UI(retModTime, temp64); } } return retModTime; }
PRUint32 ticks2xsec(tmreader* aReader, PRUint32 aTicks, PRUint32 aResolution) /* ** Convert platform specific ticks to second units ** Returns 0 on success. */ { PRUint32 retval = 0; PRUint64 bigone; PRUint64 tmp64; LL_UI2L(bigone, aResolution); LL_UI2L(tmp64, aTicks); LL_MUL(bigone, bigone, tmp64); LL_UI2L(tmp64, aReader->ticksPerSec); LL_DIV(bigone, bigone, tmp64); LL_L2UI(retval, bigone); return retval; }
static void TestNowOverhead(void) { PRTime timeout, timein; PRInt32 overhead, loops = 1000000; PRInt64 elapsed, per_call, ten23rd, ten26th; LL_I2L(ten23rd, 1000); LL_I2L(ten26th, 1000000); timein = PR_Now(); while (--loops > 0) timeout = PR_Now(); LL_SUB(elapsed, timeout, timein); LL_MUL(elapsed, elapsed, ten23rd); LL_DIV(per_call, elapsed, ten26th); LL_L2I(overhead, per_call); PR_fprintf( output, "Overhead of 'PR_Now()' is %u nsecs\n\n", overhead); } /* TestNowOverhead */
PRMJ_DSTOffset(PRInt64 time) { PRInt64 us2s; #ifdef XP_MAC MachineLocation machineLocation; PRInt64 dlsOffset; /* Get the information about the local machine, including * its GMT offset and its daylight savings time info. * Convert each into wides that we can add to * startupTimeMicroSeconds. */ MyReadLocation(&machineLocation); /* Is Daylight Savings On? If so, we need to add an hour to the offset. */ if (machineLocation.u.dlsDelta != 0) { LL_UI2L(us2s, PRMJ_USEC_PER_SEC); /* seconds in a microseconds */ LL_UI2L(dlsOffset, PRMJ_HOUR_SECONDS); /* seconds in one hour */ LL_MUL(dlsOffset, dlsOffset, us2s); } else LL_I2L(dlsOffset, 0); return(dlsOffset); #else time_t local; PRInt32 diff; PRInt64 maxtimet; struct tm tm; #if defined( XP_PC ) || defined( FREEBSD ) struct tm *ptm; #endif PRMJTime prtm; LL_UI2L(us2s, PRMJ_USEC_PER_SEC); LL_DIV(time, time, us2s); /* get the maximum of time_t value */ LL_UI2L(maxtimet,PRMJ_MAX_UNIX_TIMET); if(LL_CMP(time,>,maxtimet)){ LL_UI2L(time,PRMJ_MAX_UNIX_TIMET); } else if(!LL_GE_ZERO(time)){
void nsNetscapeProfileMigratorBase::CopyNextFolder() { if (mFileCopyTransactionIndex < mFileCopyTransactions.Length()) { PRUint32 percentage = 0; fileTransactionEntry fileTransaction = mFileCopyTransactions.ElementAt(mFileCopyTransactionIndex++); // copy the file fileTransaction.srcFile->CopyTo(fileTransaction.destFile, fileTransaction.newName); // add to our current progress PRInt64 fileSize; fileTransaction.srcFile->GetFileSize(&fileSize); LL_ADD(mCurrentProgress, mCurrentProgress, fileSize); PRInt64 percentDone; LL_MUL(percentDone, mCurrentProgress, 100); LL_DIV(percentDone, percentDone, mMaxProgress); LL_L2UI(percentage, percentDone); nsAutoString index; index.AppendInt(percentage); NOTIFY_OBSERVERS(MIGRATION_PROGRESS, index.get()); // fire a timer to handle the next one. mFileIOTimer = do_CreateInstance("@mozilla.org/timer;1"); if (mFileIOTimer) mFileIOTimer->InitWithCallback(static_cast<nsITimerCallback *>(this), percentage == 100 ? 500 : 0, nsITimer::TYPE_ONE_SHOT); } else EndCopyFolders(); return; }
/* bool getProperty (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in jsid id, in JSValPtr vp); */ NS_IMETHODIMP calDateTime::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext * cx, JSObject * obj_, jsid id, jsval * vp, bool *_retval) { NS_ENSURE_ARG_POINTER(vp); NS_ENSURE_ARG_POINTER(_retval); if (JSID_IS_STRING(id)) { size_t length; JSString *idString = JSID_TO_STRING(id); const jschar *str = JS_GetStringCharsAndLength(cx, idString, &length); nsDependentString const val(reinterpret_cast<PRUnichar const*>(str), length); if (val.EqualsLiteral("jsDate")) { PRTime tmp, thousand; jsdouble msec; LL_I2L(thousand, 1000); LL_DIV(tmp, mNativeTime, thousand); LL_L2D(msec, tmp); ensureTimezone(); JSObject *obj; bool b; if (NS_SUCCEEDED(mTimezone->GetIsFloating(&b)) && b) { obj = js_NewDateObject(cx, mYear, mMonth, mDay, mHour, mMinute, mSecond); } else { obj = js_NewDateObjectMsec(cx, msec); } *vp = OBJECT_TO_JSVAL(obj); *_retval = PR_TRUE; return NS_SUCCESS_I_DID_SOMETHING; } } *_retval = PR_TRUE; return NS_OK; }
int main(int argc, char** argv) { FILE* fp = fopen("words.txt", "r"); if (nsnull == fp) { printf("can't open words.txt\n"); return -1; } PRInt32 count = 0; PRUnichar** strings = new PRUnichar*[60000]; nsIAtom** ids = new nsIAtom*[60000]; nsAutoString s1, s2; PRTime start = PR_Now(); PRInt32 i; for (i = 0; i < 60000; i++) { char buf[1000]; char* s = fgets(buf, sizeof(buf), fp); if (nsnull == s) { break; } nsCAutoString sb; sb.Assign(buf); strings[count++] = ToNewUnicode(sb); ToUpperCase(sb); strings[count++] = ToNewUnicode(sb); } PRTime end0 = PR_Now(); // Find and create idents for (i = 0; i < count; i++) { ids[i] = NS_NewAtom(strings[i]); } PRUnichar qqs[1]; qqs[0] = 0; nsIAtom* qq = NS_NewAtom(qqs); PRTime end1 = PR_Now(); // Now make sure we can find all the idents we just made for (i = 0; i < count; i++) { const char *utf8String; ids[i]->GetUTF8String(&utf8String); nsIAtom* id = NS_NewAtom(utf8String); if (id != ids[i]) { id->ToString(s1); ids[i]->ToString(s2); printf("find failed: id='%s' ids[%d]='%s'\n", NS_LossyConvertUTF16toASCII(s1).get(), i, NS_LossyConvertUTF16toASCII(s2).get()); return -1; } NS_RELEASE(id); } PRTime end2 = PR_Now(); // Destroy all the atoms we just made NS_RELEASE(qq); for (i = 0; i < count; i++) { NS_RELEASE(ids[i]); } // Print out timings PRTime end3 = PR_Now(); PRTime creates, finds, lookups, dtor, ustoms; LL_I2L(ustoms, 1000); LL_SUB(creates, end0, start); LL_DIV(creates, creates, ustoms); LL_SUB(finds, end1, end0); LL_DIV(finds, finds, ustoms); LL_SUB(lookups, end2, end1); LL_DIV(lookups, lookups, ustoms); LL_SUB(dtor, end3, end2); char buf[500]; PR_snprintf(buf, sizeof(buf), "making %d ident strings took %lldms", count, creates); puts(buf); PR_snprintf(buf, sizeof(buf), "%d new idents took %lldms", count, finds); puts(buf); PR_snprintf(buf, sizeof(buf), "%d ident lookups took %lldms", count, lookups); puts(buf); PR_snprintf(buf, sizeof(buf), "dtor took %lldusec", dtor); puts(buf); printf("%d live atoms\n", NS_GetNumberOfAtoms()); NS_POSTCONDITION(0 == NS_GetNumberOfAtoms(), "dangling atoms"); return 0; }
NS_IMETHODIMP CVE_2013_1732_firefox12_0_nsBlockFrame::Reflow(nsPresContext* aPresContext, nsHTMLReflowMetrics& aMetrics, const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus) { DO_GLOBAL_REFLOW_COUNT("nsBlockFrame"); DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aStatus); #ifdef DEBUG if (gNoisyReflow) { IndentBy(stdout, gNoiseIndent); ListTag(stdout); printf(": begin reflow availSize=%d,%d computedSize=%d,%d\n", aReflowState.availableWidth, aReflowState.availableHeight, aReflowState.ComputedWidth(), aReflowState.ComputedHeight()); } AutoNoisyIndenter indent(gNoisy); PRTime start = LL_ZERO; // Initialize these variablies to silence the compiler. PRInt32 ctc = 0; // We only use these if they are set (gLameReflowMetrics). if (gLameReflowMetrics) { start = PR_Now(); ctc = nsLineBox::GetCtorCount(); } #endif const nsHTMLReflowState *reflowState = &aReflowState; nsAutoPtr<nsHTMLReflowState> mutableReflowState; // If we have non-auto height, we're clipping our kids and we fit, // make sure our kids fit too. if (aReflowState.availableHeight != NS_UNCONSTRAINEDSIZE && aReflowState.ComputedHeight() != NS_AUTOHEIGHT && ApplyOverflowClipping(this, aReflowState.mStyleDisplay)) { nsMargin heightExtras = aReflowState.mComputedBorderPadding; if (GetSkipSides() & NS_SIDE_TOP) { heightExtras.top = 0; } else { // Bottom margin never causes us to create continuations, so we // don't need to worry about whether it fits in its entirety. heightExtras.top += aReflowState.mComputedMargin.top; } if (GetEffectiveComputedHeight(aReflowState) + heightExtras.TopBottom() <= aReflowState.availableHeight) { mutableReflowState = new nsHTMLReflowState(aReflowState); mutableReflowState->availableHeight = NS_UNCONSTRAINEDSIZE; reflowState = mutableReflowState; } } // See comment below about oldSize. Use *only* for the // abs-pos-containing-block-size-change optimization! nsSize oldSize = GetSize(); // Should we create a float manager? nsAutoFloatManager autoFloatManager(const_cast<nsHTMLReflowState&>(*reflowState)); // XXXldb If we start storing the float manager in the frame rather // than keeping it around only during reflow then we should create it // only when there are actually floats to manage. Otherwise things // like tables will gain significant bloat. bool needFloatManager = nsBlockFrame::BlockNeedsFloatManager(this); if (needFloatManager) autoFloatManager.CreateFloatManager(aPresContext); // OK, some lines may be reflowed. Blow away any saved line cursor // because we may invalidate the nondecreasing // overflowArea.VisualOverflow().y/yMost invariant, and we may even // delete the line with the line cursor. ClearLineCursor(); if (IsFrameTreeTooDeep(*reflowState, aMetrics, aStatus)) { return NS_OK; } bool marginRoot = BlockIsMarginRoot(this); nsBlockReflowState state(*reflowState, aPresContext, this, aMetrics, marginRoot, marginRoot, needFloatManager); #ifdef IBMBIDI if (GetStateBits() & NS_BLOCK_NEEDS_BIDI_RESOLUTION) static_cast<nsBlockFrame*>(GetFirstContinuation())->ResolveBidi(); #endif // IBMBIDI if (RenumberLists(aPresContext)) { AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN); } nsresult rv = NS_OK; // ALWAYS drain overflow. We never want to leave the previnflow's // overflow lines hanging around; block reflow depends on the // overflow line lists being cleared out between reflow passes. DrainOverflowLines(); // Handle paginated overflow (see nsContainerFrame.h) nsOverflowAreas ocBounds; nsReflowStatus ocStatus = NS_FRAME_COMPLETE; if (GetPrevInFlow()) { ReflowOverflowContainerChildren(aPresContext, *reflowState, ocBounds, 0, ocStatus); } // Now that we're done cleaning up our overflow container lists, we can // give |state| its nsOverflowContinuationTracker. nsOverflowContinuationTracker tracker(aPresContext, this, false); state.mOverflowTracker = &tracker; // Drain & handle pushed floats DrainPushedFloats(state); nsOverflowAreas fcBounds; nsReflowStatus fcStatus = NS_FRAME_COMPLETE; rv = ReflowPushedFloats(state, fcBounds, fcStatus); NS_ENSURE_SUCCESS(rv, rv); // If we're not dirty (which means we'll mark everything dirty later) // and our width has changed, mark the lines dirty that we need to // mark dirty for a resize reflow. if (reflowState->mFlags.mHResize) PrepareResizeReflow(state); mState &= ~NS_FRAME_FIRST_REFLOW; // Now reflow... rv = ReflowDirtyLines(state); NS_ASSERTION(NS_SUCCEEDED(rv), "reflow dirty lines failed"); if (NS_FAILED(rv)) return rv; NS_MergeReflowStatusInto(&state.mReflowStatus, ocStatus); NS_MergeReflowStatusInto(&state.mReflowStatus, fcStatus); // If we end in a BR with clear and affected floats continue, // we need to continue, too. if (NS_UNCONSTRAINEDSIZE != reflowState->availableHeight && NS_FRAME_IS_COMPLETE(state.mReflowStatus) && state.mFloatManager->ClearContinues(FindTrailingClear())) { NS_FRAME_SET_INCOMPLETE(state.mReflowStatus); } if (!NS_FRAME_IS_FULLY_COMPLETE(state.mReflowStatus)) { if (GetOverflowLines() || GetPushedFloats()) { state.mReflowStatus |= NS_FRAME_REFLOW_NEXTINFLOW; } #ifdef DEBUG_kipp ListTag(stdout); printf(": block is not fully complete\n"); #endif } CheckFloats(state); // Place the "marker" (bullet) frame if it is placed next to a block // child. // // According to the CSS2 spec, section 12.6.1, the "marker" box // participates in the height calculation of the list-item box's // first line box. // // There are exactly two places a bullet can be placed: near the // first or second line. It's only placed on the second line in a // rare case: an empty first line followed by a second line that // contains a block (example: <LI>\n<P>... ). This is where // the second case can happen. if (mBullet && HaveOutsideBullet() && !mLines.empty() && (mLines.front()->IsBlock() || (0 == mLines.front()->mBounds.height && mLines.front() != mLines.back() && mLines.begin().next()->IsBlock()))) { // Reflow the bullet nsHTMLReflowMetrics metrics; // XXX Use the entire line when we fix bug 25888. nsLayoutUtils::LinePosition position; bool havePosition = nsLayoutUtils::GetFirstLinePosition(this, &position); nscoord lineTop = havePosition ? position.mTop : reflowState->mComputedBorderPadding.top; ReflowBullet(state, metrics, lineTop); NS_ASSERTION(!BulletIsEmpty() || metrics.height == 0, "empty bullet took up space"); if (havePosition && !BulletIsEmpty()) { // We have some lines to align the bullet with. // Doing the alignment using the baseline will also cater for // bullets that are placed next to a child block (bug 92896) // Tall bullets won't look particularly nice here... nsRect bbox = mBullet->GetRect(); bbox.y = position.mBaseline - metrics.ascent; mBullet->SetRect(bbox); } // Otherwise just leave the bullet where it is, up against our top padding. } // Compute our final size nscoord bottomEdgeOfChildren; ComputeFinalSize(*reflowState, state, aMetrics, &bottomEdgeOfChildren); nsRect areaBounds = nsRect(0, 0, aMetrics.width, aMetrics.height); ComputeOverflowAreas(areaBounds, reflowState->mStyleDisplay, bottomEdgeOfChildren, aMetrics.mOverflowAreas); // Factor overflow container child bounds into the overflow area aMetrics.mOverflowAreas.UnionWith(ocBounds); // Factor pushed float child bounds into the overflow area aMetrics.mOverflowAreas.UnionWith(fcBounds); // Let the absolutely positioned container reflow any absolutely positioned // child frames that need to be reflowed, e.g., elements with a percentage // based width/height // We want to do this under either of two conditions: // 1. If we didn't do the incremental reflow above. // 2. If our size changed. // Even though it's the padding edge that's the containing block, we // can use our rect (the border edge) since if the border style // changed, the reflow would have been targeted at us so we'd satisfy // condition 1. // XXX checking oldSize is bogus, there are various reasons we might have // reflowed but our size might not have been changed to what we // asked for (e.g., we ended up being pushed to a new page) // When WillReflowAgainForClearance is true, we will reflow again without // resetting the size. Because of this, we must not reflow our abs-pos children // in that situation --- what we think is our "new size" // will not be our real new size. This also happens to be more efficient. if (HasAbsolutelyPositionedChildren()) { nsAbsoluteContainingBlock* absoluteContainer = GetAbsoluteContainingBlock(); bool haveInterrupt = aPresContext->HasPendingInterrupt(); if (reflowState->WillReflowAgainForClearance() || haveInterrupt) { // Make sure that when we reflow again we'll actually reflow all the abs // pos frames that might conceivably depend on our size (or all of them, // if we're dirty right now and interrupted; in that case we also need // to mark them all with NS_FRAME_IS_DIRTY). Sadly, we can't do much // better than that, because we don't really know what our size will be, // and it might in fact not change on the followup reflow! if (haveInterrupt && (GetStateBits() & NS_FRAME_IS_DIRTY)) { absoluteContainer->MarkAllFramesDirty(); } else { absoluteContainer->MarkSizeDependentFramesDirty(); } } else { nsSize containingBlockSize = CalculateContainingBlockSizeForAbsolutes(*reflowState, nsSize(aMetrics.width, aMetrics.height)); // Mark frames that depend on changes we just made to this frame as dirty: // Now we can assume that the padding edge hasn't moved. // We need to reflow the absolutes if one of them depends on // its placeholder position, or the containing block size in a // direction in which the containing block size might have // changed. bool cbWidthChanged = aMetrics.width != oldSize.width; bool isRoot = !GetContent()->GetParent(); // If isRoot and we have auto height, then we are the initial // containing block and the containing block height is the // viewport height, which can't change during incremental // reflow. bool cbHeightChanged = !(isRoot && NS_UNCONSTRAINEDSIZE == reflowState->ComputedHeight()) && aMetrics.height != oldSize.height; absoluteContainer->Reflow(this, aPresContext, *reflowState, state.mReflowStatus, containingBlockSize.width, containingBlockSize.height, true, cbWidthChanged, cbHeightChanged, &aMetrics.mOverflowAreas); //XXXfr Why isn't this rv (and others in this file) checked/returned? } } // Determine if we need to repaint our border, background or outline CheckInvalidateSizeChange(aMetrics); FinishAndStoreOverflow(&aMetrics); // Clear the float manager pointer in the block reflow state so we // don't waste time translating the coordinate system back on a dead // float manager. if (needFloatManager) state.mFloatManager = nsnull; aStatus = state.mReflowStatus; #ifdef DEBUG // Between when we drain pushed floats and when we complete reflow, // we're allowed to have multiple continuations of the same float on // our floats list, since a first-in-flow might get pushed to a later // continuation of its containing block. But it's not permitted // outside that time. nsLayoutUtils::AssertNoDuplicateContinuations(this, mFloats); if (gNoisyReflow) { IndentBy(stdout, gNoiseIndent); ListTag(stdout); printf(": status=%x (%scomplete) metrics=%d,%d carriedMargin=%d", aStatus, NS_FRAME_IS_COMPLETE(aStatus) ? "" : "not ", aMetrics.width, aMetrics.height, aMetrics.mCarriedOutBottomMargin.get()); if (HasOverflowAreas()) { printf(" overflow-vis={%d,%d,%d,%d}", aMetrics.VisualOverflow().x, aMetrics.VisualOverflow().y, aMetrics.VisualOverflow().width, aMetrics.VisualOverflow().height); printf(" overflow-scr={%d,%d,%d,%d}", aMetrics.ScrollableOverflow().x, aMetrics.ScrollableOverflow().y, aMetrics.ScrollableOverflow().width, aMetrics.ScrollableOverflow().height); } printf("\n"); } if (gLameReflowMetrics) { PRTime end = PR_Now(); PRInt32 ectc = nsLineBox::GetCtorCount(); PRInt32 numLines = mLines.size(); if (!numLines) numLines = 1; PRTime delta, perLineDelta, lines; LL_I2L(lines, numLines); LL_SUB(delta, end, start); LL_DIV(perLineDelta, delta, lines); ListTag(stdout); char buf[400]; PR_snprintf(buf, sizeof(buf), ": %lld elapsed (%lld per line) (%d lines; %d new lines)", delta, perLineDelta, numLines, ectc - ctc); printf("%s\n", buf); } #endif NS_FRAME_SET_TRUNCATION(aStatus, (*reflowState), aMetrics); return rv; }
int main(int argc, char** argv) { if (3 != argc) { printf("usage: CvtURL url utf8\n"); return -1; } char* characterSetName = argv[2]; nsString* cset = ConvertCharacterSetName(characterSetName); if (NS_PTR_TO_INT32(cset) < 0) { printf("illegal character set name: '%s'\n", characterSetName); return -1; } // Create url object char* urlName = argv[1]; nsIURI* url; nsresult rv; rv = NS_NewURI(&url, urlName); if (NS_OK != rv) { printf("invalid URL: '%s'\n", urlName); return -1; } // Get an input stream from the url nsresult ec; nsIInputStream* in; ec = NS_OpenURI(&in, url); if (nsnull == in) { printf("open of url('%s') failed: error=%x\n", urlName, ec); return -1; } // Translate the input using the argument character set id into // unicode nsCOMPtr<nsIConverterInputStream> uin = do_CreateInstance("@mozilla.org/intl/converter-input-stream;1", &rv); if (NS_SUCCEEDED(rv)) rv = uin->Init(in, cset->get(), 4096); if (NS_FAILED(rv)) { printf("can't create converter input stream: %d\n", rv); return -1; } // Read the input and write some output PRTime start = PR_Now(); PRInt32 count = 0; for (;;) { PRUnichar buf[1000]; PRUint32 nb; ec = uin->Read(buf, 0, 1000, &nb); if (NS_FAILED(ec)) { printf("i/o error: %d\n", ec); break; } if (nb == 0) break; // EOF count += nb; } PRTime end = PR_Now(); PRTime conversion, ustoms; LL_I2L(ustoms, 1000); LL_SUB(conversion, end, start); LL_DIV(conversion, conversion, ustoms); char buf[500]; PR_snprintf(buf, sizeof(buf), "converting and discarding %d bytes took %lldms", count, conversion); puts(buf); // Release the objects in->Release(); url->Release(); return 0; }