本文整理汇总了C++中NS_MAX函数的典型用法代码示例。如果您正苦于以下问题:C++ NS_MAX函数的具体用法?C++ NS_MAX怎么用?C++ NS_MAX使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NS_MAX函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: AdjustRangeForSelection
static void AdjustRangeForSelection(nsIContent* aRoot,
nsINode** aNode,
PRInt32* aOffset)
{
nsINode* node = *aNode;
PRInt32 offset = *aOffset;
if (aRoot != node && node->GetParent() &&
!node->IsNodeOfType(nsINode::eTEXT)) {
node = node->GetParent();
offset = node->IndexOf(*aNode) + (offset ? 1 : 0);
}
nsIContent* brContent = node->GetChildAt(offset - 1);
while (brContent && brContent->IsHTML()) {
if (brContent->Tag() != nsGkAtoms::br || IsContentBR(brContent))
break;
brContent = node->GetChildAt(--offset - 1);
}
*aNode = node;
*aOffset = NS_MAX(offset, 0);
}
开发者ID:FunkyVerb,项目名称:devtools-window,代码行数:21,代码来源:nsContentEventHandler.cpp
示例2: NS_PRECONDITION
PRBool
nsAttrValue::ParseIntWithBounds(const nsAString& aString,
PRInt32 aMin, PRInt32 aMax)
{
NS_PRECONDITION(aMin < aMax, "bad boundaries");
ResetIfSet();
PRInt32 ec;
PRBool strict;
PRInt32 originalVal = StringToInteger(aString, &strict, &ec);
if (NS_FAILED(ec)) {
return PR_FALSE;
}
PRInt32 val = NS_MAX(originalVal, aMin);
val = NS_MIN(val, aMax);
strict = strict && (originalVal == val);
SetIntValueAndType(val, eInteger, strict ? nsnull : &aString);
return PR_TRUE;
}
开发者ID:Egyptghost1,项目名称:DOMinator,代码行数:22,代码来源:nsAttrValue.cpp
示例3: NS_ASSERTION
nsresult
FileManager::Load(mozIStorageConnection* aConnection)
{
NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!");
nsCOMPtr<mozIStorageStatement> stmt;
nsresult rv = aConnection->CreateStatement(NS_LITERAL_CSTRING(
"SELECT id, refcount "
"FROM file"
), getter_AddRefs(stmt));
NS_ENSURE_SUCCESS(rv, rv);
bool hasResult;
while (NS_SUCCEEDED(stmt->ExecuteStep(&hasResult)) && hasResult) {
PRInt64 id;
rv = stmt->GetInt64(0, &id);
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 refcount;
rv = stmt->GetInt32(1, &refcount);
NS_ENSURE_SUCCESS(rv, rv);
NS_ASSERTION(refcount, "This shouldn't happen!");
nsRefPtr<FileInfo> fileInfo = FileInfo::Create(this, id);
fileInfo->mDBRefCnt = refcount;
if (!mFileInfos.Put(id, fileInfo)) {
NS_WARNING("Out of memory?");
return NS_ERROR_OUT_OF_MEMORY;
}
mLastFileId = NS_MAX(id, mLastFileId);
}
mLoaded = true;
return NS_OK;
}
开发者ID:AntonSilviu,项目名称:v8monkey,代码行数:39,代码来源:FileManager.cpp
示例4: rect
NS_IMETHODIMP
nsListBoxBodyFrame::DoLayout(nsBoxLayoutState& aBoxLayoutState)
{
if (mScrolling)
aBoxLayoutState.SetPaintingDisabled(true);
nsresult rv = nsBoxFrame::DoLayout(aBoxLayoutState);
// determine the real height for the scrollable area from the total number
// of rows, since non-visible rows don't yet have frames
nsRect rect(nsPoint(0, 0), GetSize());
nsOverflowAreas overflow(rect, rect);
if (mLayoutManager) {
nsIFrame* childFrame = mFrames.FirstChild();
while (childFrame) {
ConsiderChildOverflow(overflow, childFrame);
childFrame = childFrame->GetNextSibling();
}
nsSize prefSize = mLayoutManager->GetPrefSize(this, aBoxLayoutState);
NS_FOR_FRAME_OVERFLOW_TYPES(otype) {
nsRect& o = overflow.Overflow(otype);
o.height = NS_MAX(o.height, prefSize.height);
}
}
FinishAndStoreOverflow(overflow, GetSize());
if (mScrolling)
aBoxLayoutState.SetPaintingDisabled(false);
// if we are scrolled and the row height changed
// make sure we are scrolled to a correct index.
if (mAdjustScroll)
PostReflowCallback();
return rv;
}
开发者ID:Anachid,项目名称:mozilla-central,代码行数:37,代码来源:nsListBoxBodyFrame.cpp
示例5: lock
void
nsDOMWorkerTimeout::Suspend()
{
AutoSpinlock lock(this);
NS_ASSERTION(!IsSuspendedNoLock(), "Bad state!");
mIsSuspended = PR_TRUE;
mSuspendedRef = this;
if (!mStarted) {
mSuspendedBeforeStart = PR_TRUE;
return;
}
mTimer->Cancel();
mSuspendInterval = NS_MAX(0, PRInt32(mTargetTime - PR_Now())) /
(PRTime)PR_USEC_PER_MSEC;
LOG(("Worker [0x%p] suspending timeout [0x%p] with id %u (interval = %u)",
static_cast<void*>(mWorker.get()), static_cast<void*>(this), mId,
mSuspendInterval));
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:24,代码来源:nsDOMWorkerTimeout.cpp
示例6: NS_MAX
// exported routine that both munder and msub share.
// munder uses this when movablelimits is set.
nsresult
nsMathMLmsubFrame::PlaceSubScript (nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
bool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize,
nsMathMLContainerFrame* aFrame,
nscoord aUserSubScriptShift,
nscoord aScriptSpace)
{
// force the scriptSpace to be atleast 1 pixel
aScriptSpace = NS_MAX(nsPresContext::CSSPixelsToAppUnits(1), aScriptSpace);
////////////////////////////////////
// Get the children's desired sizes
nsBoundingMetrics bmBase, bmSubScript;
nsHTMLReflowMetrics baseSize;
nsHTMLReflowMetrics subScriptSize;
nsIFrame* baseFrame = aFrame->GetFirstPrincipalChild();
nsIFrame* subScriptFrame = nullptr;
if (baseFrame)
subScriptFrame = baseFrame->GetNextSibling();
if (!baseFrame || !subScriptFrame || subScriptFrame->GetNextSibling()) {
// report an error, encourage people to get their markups in order
if (aPlaceOrigin) {
aFrame->ReportChildCountError();
}
return aFrame->ReflowError(aRenderingContext, aDesiredSize);
}
GetReflowAndBoundingMetricsFor(baseFrame, baseSize, bmBase);
GetReflowAndBoundingMetricsFor(subScriptFrame, subScriptSize, bmSubScript);
// get the subdrop from the subscript font
nscoord subDrop;
GetSubDropFromChild(subScriptFrame, subDrop);
// parameter v, Rule 18a, App. G, TeXbook
nscoord minSubScriptShift = bmBase.descent + subDrop;
//////////////////
// Place Children
// get min subscript shift limit from x-height
// = h(x) - 4/5 * sigma_5, Rule 18b, App. G, TeXbook
nscoord xHeight = 0;
nsRefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(baseFrame, getter_AddRefs(fm));
xHeight = fm->XHeight();
nscoord minShiftFromXHeight = (nscoord)
(bmSubScript.ascent - (4.0f/5.0f) * xHeight);
// subScriptShift
// = minimum amount to shift the subscript down set by user or from the font
// = sub1 in TeX
// = subscriptshift attribute * x-height
nscoord subScriptShift, dummy;
// get subScriptShift default from font
GetSubScriptShifts (fm, subScriptShift, dummy);
subScriptShift =
NS_MAX(subScriptShift, aUserSubScriptShift);
// get actual subscriptshift to be used
// Rule 18b, App. G, TeXbook
nscoord actualSubScriptShift =
NS_MAX(minSubScriptShift,NS_MAX(subScriptShift,minShiftFromXHeight));
// get bounding box for base + subscript
nsBoundingMetrics boundingMetrics;
boundingMetrics.ascent =
NS_MAX(bmBase.ascent, bmSubScript.ascent - actualSubScriptShift);
boundingMetrics.descent =
NS_MAX(bmBase.descent, bmSubScript.descent + actualSubScriptShift);
// add aScriptSpace to the subscript's width
boundingMetrics.width = bmBase.width + bmSubScript.width + aScriptSpace;
boundingMetrics.leftBearing = bmBase.leftBearing;
boundingMetrics.rightBearing = NS_MAX(bmBase.rightBearing, bmBase.width +
NS_MAX(bmSubScript.width + aScriptSpace, bmSubScript.rightBearing));
aFrame->SetBoundingMetrics (boundingMetrics);
// reflow metrics
aDesiredSize.ascent =
NS_MAX(baseSize.ascent, subScriptSize.ascent - actualSubScriptShift);
aDesiredSize.height = aDesiredSize.ascent +
NS_MAX(baseSize.height - baseSize.ascent,
subScriptSize.height - subScriptSize.ascent + actualSubScriptShift);
aDesiredSize.width = boundingMetrics.width;
aDesiredSize.mBoundingMetrics = boundingMetrics;
aFrame->SetReference(nsPoint(0, aDesiredSize.ascent));
if (aPlaceOrigin) {
nscoord dx, dy;
// now place the base ...
dx = aFrame->MirrorIfRTL(aDesiredSize.width, baseSize.width, 0);
dy = aDesiredSize.ascent - baseSize.ascent;
FinishReflowChild (baseFrame, aPresContext, nullptr, baseSize, dx, dy, 0);
// ... and subscript
//.........这里部分代码省略.........
开发者ID:jraff,项目名称:mozilla-central,代码行数:101,代码来源:nsMathMLmsubFrame.cpp
示例7: powf
float Axis::GetAccelerationFactor() {
return powf(ACCELERATION_MULTIPLIER, NS_MAX(0, (mAcceleration - 4) * 3));
}
开发者ID:LyeSS,项目名称:mozilla-central,代码行数:3,代码来源:Axis.cpp
示例8: availSize
//.........这里部分代码省略.........
psi += bmOne.ascent - bmBase.ascent;
// make sure that the rule appears on on screen
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
if (ruleThickness < onePixel) {
ruleThickness = onePixel;
}
// adjust clearance psi to get an exact number of pixels -- this
// gives a nicer & uniform look on stacked radicals (bug 130282)
nscoord delta = psi % onePixel;
if (delta)
psi += onePixel - delta; // round up
// Stretch the radical symbol to the appropriate height if it is not big enough.
nsBoundingMetrics contSize = bmBase;
contSize.descent = bmBase.ascent + bmBase.descent + psi;
contSize.ascent = ruleThickness;
// height(radical) should be >= height(base) + psi + ruleThickness
nsBoundingMetrics radicalSize;
mSqrChar.Stretch(aPresContext, renderingContext,
NS_STRETCH_DIRECTION_VERTICAL,
contSize, radicalSize,
NS_STRETCH_LARGER);
// radicalSize have changed at this point, and should match with
// the bounding metrics of the char
mSqrChar.GetBoundingMetrics(bmSqr);
// Update the desired size for the container (like msqrt, index is not yet included)
// the baseline will be that of the base.
mBoundingMetrics.ascent = bmBase.ascent + psi + ruleThickness;
mBoundingMetrics.descent =
NS_MAX(bmBase.descent,
(bmSqr.ascent + bmSqr.descent - mBoundingMetrics.ascent));
mBoundingMetrics.width = bmSqr.width + bmBase.width;
mBoundingMetrics.leftBearing = bmSqr.leftBearing;
mBoundingMetrics.rightBearing = bmSqr.width +
NS_MAX(bmBase.width, bmBase.rightBearing); // take also care of the rule
aDesiredSize.ascent = mBoundingMetrics.ascent + leading;
aDesiredSize.height = aDesiredSize.ascent +
NS_MAX(baseSize.height - baseSize.ascent,
mBoundingMetrics.descent + ruleThickness);
aDesiredSize.width = mBoundingMetrics.width;
/////////////
// Re-adjust the desired size to include the index.
// the index is raised by some fraction of the height
// of the radical, see \mroot macro in App. B, TexBook
nscoord raiseIndexDelta = NSToCoordRound(0.6f * (bmSqr.ascent + bmSqr.descent));
nscoord indexRaisedAscent = mBoundingMetrics.ascent // top of radical
- (bmSqr.ascent + bmSqr.descent) // to bottom of radical
+ raiseIndexDelta + bmIndex.ascent + bmIndex.descent; // to top of raised index
nscoord indexClearance = 0;
if (mBoundingMetrics.ascent < indexRaisedAscent) {
indexClearance =
indexRaisedAscent - mBoundingMetrics.ascent; // excess gap introduced by a tall index
mBoundingMetrics.ascent = indexRaisedAscent;
nscoord descent = aDesiredSize.height - aDesiredSize.ascent;
aDesiredSize.ascent = mBoundingMetrics.ascent + leading;
aDesiredSize.height = aDesiredSize.ascent + descent;
}
开发者ID:Akin-Net,项目名称:mozilla-central,代码行数:66,代码来源:nsMathMLmrootFrame.cpp
示例9: nsSize
nsSize
nsBox::BoundsCheckMinMax(const nsSize& aMinSize, const nsSize& aMaxSize)
{
return nsSize(NS_MAX(aMaxSize.width, aMinSize.width),
NS_MAX(aMaxSize.height, aMinSize.height));
}
开发者ID:MozillaOnline,项目名称:gecko-dev,代码行数:6,代码来源:nsBox.cpp
示例10: NS_PRECONDITION
//.........这里部分代码省略.........
}
aMetrics->zeroOrAveCharWidth = 0.0;
if (GetCharExtents('0', &extents)) {
aMetrics->zeroOrAveCharWidth = extents.x_advance;
}
// Prefering a measured x over sxHeight because sxHeight doesn't consider
// hinting, but maybe the x extents are not quite right in some fancy
// script fonts. CSS 2.1 suggests possibly using the height of an "o",
// which would have a more consistent glyph across fonts.
if (GetCharExtents('x', &extents) && extents.y_bearing < 0.0) {
aMetrics->xHeight = -extents.y_bearing;
aMetrics->aveCharWidth = extents.x_advance;
} else {
if (os2 && os2->sxHeight) {
aMetrics->xHeight = os2->sxHeight * yScale;
} else {
// CSS 2.1, section 4.3.2 Lengths: "In the cases where it is
// impossible or impractical to determine the x-height, a value of
// 0.5em should be used."
aMetrics->xHeight = 0.5 * emHeight;
}
aMetrics->aveCharWidth = 0.0; // updated below
}
// aveCharWidth is used for the width of text input elements so be
// liberal rather than conservative in the estimate.
if (os2 && os2->xAvgCharWidth) {
// Round to pixels as this is compared with maxAdvance to guess
// whether this is a fixed width font.
gfxFloat avgCharWidth =
ScaleRoundDesignUnits(os2->xAvgCharWidth, ftMetrics.x_scale);
aMetrics->aveCharWidth =
NS_MAX(aMetrics->aveCharWidth, avgCharWidth);
}
aMetrics->aveCharWidth =
NS_MAX(aMetrics->aveCharWidth, aMetrics->zeroOrAveCharWidth);
if (aMetrics->aveCharWidth == 0.0) {
aMetrics->aveCharWidth = aMetrics->spaceWidth;
}
if (aMetrics->zeroOrAveCharWidth == 0.0) {
aMetrics->zeroOrAveCharWidth = aMetrics->aveCharWidth;
}
// Apparently hinting can mean that max_advance is not always accurate.
aMetrics->maxAdvance =
NS_MAX(aMetrics->maxAdvance, aMetrics->aveCharWidth);
// gfxFont::Metrics::underlineOffset is the position of the top of the
// underline.
//
// FT_FaceRec documentation describes underline_position as "the
// center of the underlining stem". This was the original definition
// of the PostScript metric, but in the PostScript table of OpenType
// fonts the metric is "the top of the underline"
// (http://www.microsoft.com/typography/otspec/post.htm), and FreeType
// (up to version 2.3.7) doesn't make any adjustment.
//
// Therefore get the underline position directly from the table
// ourselves when this table exists. Use FreeType's metrics for
// other (including older PostScript) fonts.
if (mFace->underline_position && mFace->underline_thickness) {
aMetrics->underlineSize = mFace->underline_thickness * yScale;
TT_Postscript *post = static_cast<TT_Postscript*>
(FT_Get_Sfnt_Table(mFace, ft_sfnt_post));
if (post && post->underlinePosition) {
aMetrics->underlineOffset = post->underlinePosition * yScale;
开发者ID:Akin-Net,项目名称:mozilla-central,代码行数:67,代码来源:gfxFT2Utils.cpp
示例11: nsBoundingMetrics
//.........这里部分代码省略.........
while (childFrame) {
nsIMathMLFrame* mathmlChild = do_QueryFrame(childFrame);
if (mathmlChild) {
nsHTMLReflowMetrics childDesiredSize;
// retrieve the metrics that was stored at the previous pass
GetReflowAndBoundingMetricsFor(childFrame, childDesiredSize,
childDesiredSize.mBoundingMetrics);
mathmlChild->Stretch(*aReflowState.rendContext,
stretchDir, containerSize, childDesiredSize);
// store the updated metrics
SaveReflowAndBoundingMetricsFor(childFrame, childDesiredSize,
childDesiredSize.mBoundingMetrics);
nscoord childDescent = childDesiredSize.height - childDesiredSize.ascent;
if (descent < childDescent)
descent = childDescent;
if (ascent < childDesiredSize.ascent)
ascent = childDesiredSize.ascent;
}
childFrame = childFrame->GetNextSibling();
}
// bug 121748: for surrounding fences & separators, use a size that covers everything
GetPreferredStretchSize(*aReflowState.rendContext,
STRETCH_CONSIDER_EMBELLISHMENTS,
stretchDir, containerSize);
//////////////////////////////////////////
// Prepare the opening fence, separators, and closing fence, and
// adjust the origin of children.
// we need to center around the axis
nscoord delta = NS_MAX(containerSize.ascent - axisHeight,
containerSize.descent + axisHeight);
containerSize.ascent = delta + axisHeight;
containerSize.descent = delta - axisHeight;
/////////////////
// opening fence ...
ReflowChar(aPresContext, *aReflowState.rendContext, mOpenChar,
NS_MATHML_OPERATOR_FORM_PREFIX, font->mScriptLevel,
axisHeight, leading, em, containerSize, ascent, descent);
/////////////////
// separators ...
for (i = 0; i < mSeparatorsCount; i++) {
ReflowChar(aPresContext, *aReflowState.rendContext, &mSeparatorsChar[i],
NS_MATHML_OPERATOR_FORM_INFIX, font->mScriptLevel,
axisHeight, leading, em, containerSize, ascent, descent);
}
/////////////////
// closing fence ...
ReflowChar(aPresContext, *aReflowState.rendContext, mCloseChar,
NS_MATHML_OPERATOR_FORM_POSTFIX, font->mScriptLevel,
axisHeight, leading, em, containerSize, ascent, descent);
//////////////////
// Adjust the origins of each child.
// and update our bounding metrics
i = 0;
nscoord dx = 0;
nsBoundingMetrics bm;
PRBool firstTime = PR_TRUE;
if (mOpenChar) {
PlaceChar(mOpenChar, ascent, bm, dx);
开发者ID:mozilla,项目名称:mozilla-history,代码行数:67,代码来源:nsMathMLmfencedFrame.cpp
示例12: printf
//.........这里部分代码省略.........
//XXX we don't handle splitting frames for inline absolute containing blocks yet
&& (aKidFrame->GetRect().y <= aReflowState.availableHeight);
// Don't split things below the fold. (Ideally we shouldn't *have*
// anything totally below the fold, but we can't position frames
// across next-in-flow breaks yet.
if (constrainHeight) {
kidReflowState.availableHeight = aReflowState.availableHeight - border.top
- kidReflowState.mComputedMargin.top;
if (NS_AUTOOFFSET != kidReflowState.mComputedOffsets.top)
kidReflowState.availableHeight -= kidReflowState.mComputedOffsets.top;
}
// Do the reflow
rv = aKidFrame->Reflow(aPresContext, kidDesiredSize, kidReflowState, aStatus);
// If we're solving for 'left' or 'top', then compute it now that we know the
// width/height
if ((NS_AUTOOFFSET == kidReflowState.mComputedOffsets.left) ||
(NS_AUTOOFFSET == kidReflowState.mComputedOffsets.top)) {
if (-1 == aContainingBlockWidth) {
// Get the containing block width/height
kidReflowState.ComputeContainingBlockRectangle(aPresContext,
&aReflowState,
aContainingBlockWidth,
aContainingBlockHeight);
}
if (NS_AUTOOFFSET == kidReflowState.mComputedOffsets.left) {
NS_ASSERTION(NS_AUTOOFFSET != kidReflowState.mComputedOffsets.right,
"Can't solve for both left and right");
kidReflowState.mComputedOffsets.left = aContainingBlockWidth -
kidReflowState.mComputedOffsets.right -
kidReflowState.mComputedMargin.right -
kidDesiredSize.width -
kidReflowState.mComputedMargin.left;
}
if (NS_AUTOOFFSET == kidReflowState.mComputedOffsets.top) {
kidReflowState.mComputedOffsets.top = aContainingBlockHeight -
kidReflowState.mComputedOffsets.bottom -
kidReflowState.mComputedMargin.bottom -
kidDesiredSize.height -
kidReflowState.mComputedMargin.top;
}
}
// Position the child relative to our padding edge
nsRect rect(border.left + kidReflowState.mComputedOffsets.left + kidReflowState.mComputedMargin.left,
border.top + kidReflowState.mComputedOffsets.top + kidReflowState.mComputedMargin.top,
kidDesiredSize.width, kidDesiredSize.height);
aKidFrame->SetRect(rect);
nsIView* view = aKidFrame->GetView();
if (view) {
// Size and position the view and set its opacity, visibility, content
// transparency, and clip
nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, aKidFrame, view,
kidDesiredSize.VisualOverflow());
} else {
nsContainerFrame::PositionChildViews(aKidFrame);
}
if (oldRect.TopLeft() != rect.TopLeft() ||
(aDelegatingFrame->GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
// The frame moved
aKidFrame->GetParent()->Invalidate(oldOverflowRect);
aKidFrame->InvalidateFrameSubtree();
} else if (oldRect.Size() != rect.Size()) {
// Invalidate the area where the frame changed size.
nscoord innerWidth = NS_MIN(oldRect.width, rect.width);
nscoord innerHeight = NS_MIN(oldRect.height, rect.height);
nscoord outerWidth = NS_MAX(oldRect.width, rect.width);
nscoord outerHeight = NS_MAX(oldRect.height, rect.height);
aKidFrame->GetParent()->Invalidate(
nsRect(rect.x + innerWidth, rect.y, outerWidth - innerWidth, outerHeight));
// Invalidate the horizontal strip
aKidFrame->GetParent()->Invalidate(
nsRect(rect.x, rect.y + innerHeight, outerWidth, outerHeight - innerHeight));
}
aKidFrame->DidReflow(aPresContext, &kidReflowState, NS_FRAME_REFLOW_FINISHED);
#ifdef DEBUG
if (nsBlockFrame::gNoisyReflow) {
nsFrame::IndentBy(stdout,nsBlockFrame::gNoiseIndent - 1);
printf("abs pos ");
if (aKidFrame) {
nsAutoString name;
aKidFrame->GetFrameName(name);
printf("%s ", NS_LossyConvertUTF16toASCII(name).get());
}
printf("%p rect=%d,%d,%d,%d\n", static_cast<void*>(aKidFrame),
rect.x, rect.y, rect.width, rect.height);
}
#endif
if (aOverflowAreas) {
aOverflowAreas->UnionWith(kidDesiredSize.mOverflowAreas + rect.TopLeft());
}
return rv;
}
开发者ID:mbrubeck,项目名称:mozilla-central,代码行数:101,代码来源:nsAbsoluteContainingBlock.cpp
示例13: ReflowError
/* virtual */ nsresult
nsMathMLmoverFrame::Place(nsIRenderingContext& aRenderingContext,
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize)
{
if ( NS_MATHML_EMBELLISH_IS_MOVABLELIMITS(mEmbellishData.flags) &&
!NS_MATHML_IS_DISPLAYSTYLE(mPresentationData.flags)) {
// place like superscript
return nsMathMLmsupFrame::PlaceSuperScript(PresContext(),
aRenderingContext,
aPlaceOrigin,
aDesiredSize,
this, 0, nsPresContext::CSSPointsToAppUnits(0.5f));
}
////////////////////////////////////
// Get the children's desired sizes
nsBoundingMetrics bmBase, bmOver;
nsHTMLReflowMetrics baseSize;
nsHTMLReflowMetrics overSize;
nsIFrame* overFrame = nsnull;
nsIFrame* baseFrame = mFrames.FirstChild();
if (baseFrame)
overFrame = baseFrame->GetNextSibling();
if (!baseFrame || !overFrame || overFrame->GetNextSibling()) {
// report an error, encourage people to get their markups in order
return ReflowError(aRenderingContext, aDesiredSize);
}
GetReflowAndBoundingMetricsFor(baseFrame, baseSize, bmBase);
GetReflowAndBoundingMetricsFor(overFrame, overSize, bmOver);
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
////////////////////
// Place Children
aRenderingContext.SetFont(GetStyleFont()->mFont,
PresContext()->GetUserFontSet());
nsCOMPtr<nsIFontMetrics> fm;
aRenderingContext.GetFontMetrics(*getter_AddRefs(fm));
nscoord xHeight = 0;
fm->GetXHeight (xHeight);
nscoord ruleThickness;
GetRuleThickness (aRenderingContext, fm, ruleThickness);
// there are 2 different types of placement depending on
// whether we want an accented overscript or not
nscoord correction = 0;
GetItalicCorrection (bmBase, correction);
nscoord delta1 = 0; // gap between base and overscript
nscoord delta2 = 0; // extra space above overscript
if (!NS_MATHML_EMBELLISH_IS_ACCENTOVER(mEmbellishData.flags)) {
// Rule 13a, App. G, TeXbook
nscoord bigOpSpacing1, bigOpSpacing3, bigOpSpacing5, dummy;
GetBigOpSpacings (fm,
bigOpSpacing1, dummy,
bigOpSpacing3, dummy,
bigOpSpacing5);
delta1 = NS_MAX(bigOpSpacing1, (bigOpSpacing3 - bmOver.descent));
delta2 = bigOpSpacing5;
// XXX This is not a TeX rule...
// delta1 (as computed above) can become really big when bmOver.descent is
// negative, e.g., if the content is &OverBar. In such case, we use the height
if (bmOver.descent < 0)
delta1 = NS_MAX(bigOpSpacing1, (bigOpSpacing3 - (bmOver.ascent + bmOver.descent)));
}
else {
// Rule 12, App. G, TeXbook
// We are going to modify this rule to make it more general.
// The idea behind Rule 12 in the TeXBook is to keep the accent
// as close to the base as possible, while ensuring that the
// distance between the *baseline* of the accent char and
// the *baseline* of the base is atleast x-height.
// The idea is that for normal use, we would like all the accents
// on a line to line up atleast x-height above the baseline
// if possible.
// When the ascent of the base is >= x-height,
// the baseline of the accent char is placed just above the base
// (specifically, the baseline of the accent char is placed
// above the baseline of the base by the ascent of the base).
// For ease of implementation,
// this assumes that the font-designer designs accents
// in such a way that the bottom of the accent is atleast x-height
// above its baseline, otherwise there will be collisions
// with the base. Also there should be proper padding between
// the bottom of the accent char and its baseline.
// The above rule may not be obvious from a first
// reading of rule 12 in the TeXBook !!!
// The mathml <mover> tag can use accent chars that
// do not follow this convention. So we modify TeX's rule
// so that TeX's rule gets subsumed for accents that follow
// TeX's convention,
// while also allowing accents that do not follow the convention :
// we try to keep the *bottom* of the accent char atleast x-height
//.........这里部分代码省略.........
开发者ID:LittleForker,项目名称:mozilla-central,代码行数:101,代码来源:nsMathMLmoverFrame.cpp
示例14: NS_ASSERTION
nsresult
FileManager::Init(nsIFile* aDirectory,
mozIStorageConnection* aConnection)
{
NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!");
NS_ASSERTION(aDirectory, "Null directory!");
NS_ASSERTION(aConnection, "Null connection!");
mFileInfos.Init();
bool exists;
nsresult rv = aDirectory->Exists(&exists);
NS_ENSURE_SUCCESS(rv, rv);
if (exists) {
bool isDirectory;
rv = aDirectory->IsDirectory(&isDirectory);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(isDirectory, NS_ERROR_FAILURE);
}
else {
rv = aDirectory->Create(nsIFile::DIRECTORY_TYPE, 0755);
NS_ENSURE_SUCCESS(rv, rv);
}
rv = aDirectory->GetPath(mDirectoryPath);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIFile> journalDirectory;
rv = aDirectory->Clone(getter_AddRefs(journalDirectory));
NS_ENSURE_SUCCESS(rv, rv);
rv = journalDirectory->Append(NS_LITERAL_STRING(JOURNAL_DIRECTORY_NAME));
NS_ENSURE_SUCCESS(rv, rv);
rv = journalDirectory->Exists(&exists);
NS_ENSURE_SUCCESS(rv, rv);
if (exists) {
bool isDirectory;
rv = journalDirectory->IsDirectory(&isDirectory);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(isDirectory, NS_ERROR_FAILURE);
}
rv = journalDirectory->GetPath(mJournalDirectoryPath);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<mozIStorageStatement> stmt;
rv = aConnection->CreateStatement(NS_LITERAL_CSTRING(
"SELECT id, refcount "
"FROM file"
), getter_AddRefs(stmt));
NS_ENSURE_SUCCESS(rv, rv);
bool hasResult;
while (NS_SUCCEEDED(stmt->ExecuteStep(&hasResult)) && hasResult) {
int64_t id;
rv = stmt->GetInt64(0, &id);
NS_ENSURE_SUCCESS(rv, rv);
int32_t refcount;
rv = stmt->GetInt32(1, &refcount);
NS_ENSURE_SUCCESS(rv, rv);
NS_ASSERTION(refcount, "This shouldn't happen!");
nsRefPtr<FileInfo> fileInfo = FileInfo::Create(this, id);
fileInfo->mDBRefCnt = refcount;
mFileInfos.Put(id, fileInfo);
mLastFileId = NS_MAX(id, mLastFileId);
}
return NS_OK;
}
开发者ID:Ajunboys,项目名称:mozilla-os2,代码行数:77,代码来源:FileManager.cpp
示例15: InflateRight
static void
InflateRight(nsRect* aRect, nscoord aDelta)
{
aRect->width = NS_MAX(aRect->width + aDelta, 0);
}
开发者ID:marshall,项目名称:mozilla-central,代码行数:5,代码来源:TextOverflow.cpp
示例16: powf
float Axis::GetAccelerationFactor() {
return powf(gAccelerationMultiplier, NS_MAX(0, (mAcceleration - 4) * 3));
}
开发者ID:jraff,项目名称:mozilla-central,代码行数:3,代码来源:Axis.cpp
示例17: NS_MAX
// exported routine that both munderover and msubsup share.
// munderover uses this when movablelimits is set.
nsresult
nsMathMLmsubsupFrame::PlaceSubSupScript(nsPresContext* aPresContext,
nsRenderingContext& aRenderingContext,
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize,
nsMathMLContainerFrame* aFrame,
nscoord aUserSubScriptShift,
nscoord aUserSupScriptShift,
nscoord aScriptSpace)
{
// force the scriptSpace to be atleast 1 pixel
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
aScriptSpace = NS_MAX(onePixel, aScriptSpace);
////////////////////////////////////
// Get the children's desired sizes
nsHTMLReflowMetrics baseSize;
nsHTMLReflowMetrics subScriptSize;
nsHTMLReflowMetrics supScriptSize;
nsBoundingMetrics bmBase, bmSubScript, bmSupScript;
nsIFrame* subScriptFrame = nsnull;
nsIFrame* supScriptFrame = nsnull;
nsIFrame* baseFrame = aFrame->GetFirstPrincipalChild();
if (baseFrame)
subScriptFrame = baseFrame->GetNextSibling();
if (subScriptFrame)
supScriptFrame = subScriptFrame->GetNextSibling();
if (!baseFrame || !subScriptFrame || !supScriptFrame ||
supScriptFrame->GetNextSibling()) {
// report an error, encourage people to get their markups in order
return aFrame->ReflowError(aRenderingContext, aDesiredSize);
}
GetReflowAndBoundingMetricsFor(baseFrame, baseSize, bmBase);
GetReflowAndBoundingMetricsFor(subScriptFrame, subScriptSize, bmSubScript);
GetReflowAndBoundingMetricsFor(supScriptFrame, supScriptSize, bmSupScript);
// get the subdrop from the subscript font
nscoord subDrop;
GetSubDropFromChild(subScriptFrame, subDrop);
// parameter v, Rule 18a, App. G, TeXbook
nscoord minSubScriptShift = bmBase.descent + subDrop;
// get the supdrop from the supscript font
nscoord supDrop;
GetSupDropFromChild(supScriptFrame, supDrop);
// parameter u, Rule 18a, App. G, TeXbook
nscoord minSupScriptShift = bmBase.ascent - supDrop;
//////////////////
// Place Children
//////////////////
//////////////////////////////////////////////////
// Get subscript shift
// slightly different from nsMathMLmsubFrame.cpp
//////////////////////////////////////////////////
// subScriptShift{1,2}
// = minimum amount to shift the subscript down
// = sub{1,2} in TeXbook
// subScriptShift1 = subscriptshift attribute * x-height
nscoord subScriptShift1, subScriptShift2;
nsRefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(baseFrame, getter_AddRefs(fm));
aRenderingContext.SetFont(fm);
// get x-height (an ex)
nscoord xHeight = fm->XHeight();
nscoord ruleSize;
GetRuleThickness (aRenderingContext, fm, ruleSize);
// Get subScriptShift{1,2} default from font
GetSubScriptShifts (fm, subScriptShift1, subScriptShift2);
if (0 < aUserSubScriptShift) {
// the user has set the subscriptshift attribute
float scaler = ((float) subScriptShift2) / subScriptShift1;
subScriptShift1 = NS_MAX(subScriptShift1, aUserSubScriptShift);
subScriptShift2 = NSToCoordRound(scaler * subScriptShift1);
}
// get a tentative value for subscriptshift
// Rule 18d, App. G, TeXbook
nscoord subScriptShift =
NS_MAX(minSubScriptShift,NS_MAX(subScriptShift1,subScriptShift2));
//////////////////////////////////////////////////
// Get supscript shift
// same code from nsMathMLmsupFrame.cpp
//////////////////////////////////////////////////
// get min supscript shift limit from x-height
// = d(x) + 1/4 * sigma_5, Rule 18c, App. G, TeXbook
nscoord minShiftFromXHeight = (nscoord)
(bmSupScript.descent + (1.0f/4.0f) * xHeight);
//.........这里部分代码省略.........
开发者ID:mbrubeck,项目名称:mozilla-central,代码行数:101,代码来源:nsMathMLmsubsupFrame.cpp
示例18: BoxBlurHorizontal
/**
* Box blur involves looking at one pixel, and setting its value to the average
* of its neighbouring pixels.
* @param aInput The input buffer.
* @param aOutput The output buffer.
* @param aLeftLobe The number of pixels to blend on the left.
* @param aRightLobe The number of pixels to blend on the right.
* @param aWidth The number of columns in the buffers.
* @param aRows The number of rows in the buffers.
* @param aSkipRect An area to skip blurring in.
* XXX shouldn't we pass stride in separately here?
*/
static void
BoxBlurHorizontal(unsigned char* aInput,
unsigned char* aOutput,
PRInt32 aLeftLobe,
PRInt32 aRightLobe,
PRInt32 aWidth,
PRInt32 aRows,
const nsIntRect& aSkipRect)
{
NS_ASSERTION(aWidth > 0, "Can't handle zero width here");
PRInt32 boxSize = aLeftLobe + aRightLobe + 1;
PRBool skipRectCoversWholeRow = 0 >= aSkipRect.x &&
aWidth <= aSkipRect.XMost();
for (PRInt32 y = 0; y < aRows; y++) {
// Check whether the skip rect intersects this row. If the skip
// rect covers the whole surface in this row, we can avoid
// this row entirely (and any others along the skip rect).
PRBool inSkipRectY = y >= aSkipRect.y &&
y < aSkipRect.YMost();
if (inSkipRectY && skipRectCoversWholeRow) {
y = aSkipRect.YMost() - 1;
continue;
}
PRInt32 alphaSum = 0;
for (PRInt32 i = 0; i < boxSize; i++) {
PRInt32 pos = i - aLeftLobe;
// See assertion above; if aWidth is zero, then we would have no
// valid position to clamp to.
pos = NS_MAX(pos, 0);
pos = NS_MIN(pos, aWidth - 1);
alphaSum += aInput[aWidth * y + pos];
}
for (PRInt32 x = 0; x < aWidth; x++) {
// Check whether we are within the skip rect. If so, go
// to the next point outside the skip rect.
if (inSkipRectY && x >= aSkipRect.x &&
x < aSkipRect.XMost()) {
x = aSkipRect.XMost();
if (x >= aWidth)
break;
// Recalculate the neighbouring alpha values for
// our new point on the surface.
alphaSum = 0;
for (PRInt32 i = 0; i < boxSize; i++) {
PRInt32 pos = x + i - aLeftLobe;
// See assertion above; if aWidth is zero, then we would have no
// valid position to clamp to.
pos = NS_MAX(pos, 0);
pos = NS_MIN(pos, aWidth - 1);
alphaSum += aInput[aWidth * y + pos];
}
}
PRInt32 tmp = x - aLeftLobe;
PRInt32 last = NS_MAX(tmp, 0);
PRInt32 next = NS_MIN(tmp + boxSize, aWidth - 1);
aOutput[aWidth * y + x] = alphaSum/boxSize;
alphaSum += aInput[aWidth * y + next] -
aInput[aWidth * y + last];
}
}
}
开发者ID:Akin-Net,项目名称:mozilla-central,代码行数:79,代码来源:gfxBlur.cpp
示例19: NS_ASSERTION
nsresult
nsTableOuterFrame::GetCaptionOrigin(PRUint32 aCaptionSide,
const nsSize& aContainBlockSize,
const nsSize& aInnerSize,
const nsMargin& aInnerMargin,
const nsSize& aCaptionSize,
nsMargin& aCaptionMargin,
nsPoint& aOrigin)
{
aOrigin.x = aOrigin.y = 0;
if ((NS_UNCONSTRAINEDSIZE == aInnerSize.width) || (NS_UNCONSTRAINEDSIZE == aInnerSize.height) ||
(NS_UNCONSTRAINEDSIZE == aCaptionSize.width) || (NS_UNCONSTRAINEDSIZE == aCaptionSize.height)) {
return NS_OK;
}
if (mCaptionFrames.IsEmpty()) return NS_OK;
NS_ASSERTION(NS_AUTOMARGIN != aCaptionMargin.left, "The computed caption margin is auto?");
NS_ASSERTION(NS_AUTOMARGIN != aCaptionMargin.top, "The computed caption margin is auto?");
NS_ASSERTION(NS_AUTOMARGIN != aCaptionMargin.bottom, "The computed caption margin is auto?");
// horizontal computation
switch(aCaptionSide) {
case NS_STYLE_CAPTION_SIDE_BOTTOM:
case NS_STYLE_CAPTION_SIDE_BOTTOM_OUTSIDE: {
// FIXME: Position relative to right edge for RTL. (Based on table
// direction or table parent direction?)
aOrigin.x = aCaptionMargin.left;
if (aCaptionSide == NS_STYLE_CAPTION_SIDE_BOTTOM) {
// We placed the caption using only the table's width as available
// width, and we should position it this way as well.
aOrigin.x
|
请发表评论