Merge mozilla-central and mozilla-inbound

This commit is contained in:
Matt Brubeck 2011-08-12 07:08:33 -07:00
Родитель 76db8b9306 16091a1e43
Коммит 539e6ce545
41 изменённых файлов: 230 добавлений и 269 удалений

Просмотреть файл

@ -7593,6 +7593,18 @@ if test -n "$JS_GC_ZEAL"; then
AC_DEFINE(JS_GC_ZEAL) AC_DEFINE(JS_GC_ZEAL)
fi fi
dnl ========================================================
dnl JS opt-mode assertions and minidump instrumentation
dnl ========================================================
MOZ_ARG_ENABLE_BOOL(js-diagnostics,
[ --enable-js-diagnostics
Enable JS diagnostic assertions and breakpad data],
JS_CRASH_DIAGNOSTICS=1,
JS_CRASH_DIAGNOSTICS= )
if test -n "$JS_CRASH_DIAGNOSTICS"; then
AC_DEFINE(JS_CRASH_DIAGNOSTICS)
fi
dnl ====================================================== dnl ======================================================
dnl = Enable compiling with ccache dnl = Enable compiling with ccache
dnl ====================================================== dnl ======================================================

Просмотреть файл

@ -44,7 +44,7 @@ struct {
{ HB_TAG('c','u','r','s'), DEFAULT_PRIORITY }, { HB_TAG('c','u','r','s'), DEFAULT_PRIORITY },
{ HB_TAG('k','e','r','n'), DEFAULT_PRIORITY }, { HB_TAG('k','e','r','n'), DEFAULT_PRIORITY },
{ HB_TAG('l','i','g','a'), DEFAULT_PRIORITY }, { HB_TAG('l','i','g','a'), DEFAULT_PRIORITY },
{ HB_TAG('l','o','c','l'), DEFAULT_PRIORITY }, { HB_TAG('l','o','c','l'), FIRST_PRIORITY },
{ HB_TAG('m','a','r','k'), DEFAULT_PRIORITY }, { HB_TAG('m','a','r','k'), DEFAULT_PRIORITY },
{ HB_TAG('m','k','m','k'), DEFAULT_PRIORITY }, { HB_TAG('m','k','m','k'), DEFAULT_PRIORITY },
{ HB_TAG('r','l','i','g'), DEFAULT_PRIORITY } { HB_TAG('r','l','i','g'), DEFAULT_PRIORITY }

Просмотреть файл

@ -94,7 +94,7 @@ inline nscoord NSToCoordRound(float aValue)
#if defined(XP_WIN32) && defined(_M_IX86) && !defined(__GNUC__) #if defined(XP_WIN32) && defined(_M_IX86) && !defined(__GNUC__)
return NS_lroundup30(aValue); return NS_lroundup30(aValue);
#else #else
return nscoord(NS_floorf(aValue + 0.5f)); return nscoord(floorf(aValue + 0.5f));
#endif /* XP_WIN32 && _M_IX86 && !__GNUC__ */ #endif /* XP_WIN32 && _M_IX86 && !__GNUC__ */
} }
@ -103,7 +103,7 @@ inline nscoord NSToCoordRound(double aValue)
#if defined(XP_WIN32) && defined(_M_IX86) && !defined(__GNUC__) #if defined(XP_WIN32) && defined(_M_IX86) && !defined(__GNUC__)
return NS_lroundup30((float)aValue); return NS_lroundup30((float)aValue);
#else #else
return nscoord(NS_floor(aValue + 0.5f)); return nscoord(floor(aValue + 0.5f));
#endif /* XP_WIN32 && _M_IX86 && !__GNUC__ */ #endif /* XP_WIN32 && _M_IX86 && !__GNUC__ */
} }
@ -360,12 +360,12 @@ inline float NSCoordToFloat(nscoord aCoord) {
*/ */
inline nscoord NSToCoordFloor(float aValue) inline nscoord NSToCoordFloor(float aValue)
{ {
return nscoord(NS_floorf(aValue)); return nscoord(floorf(aValue));
} }
inline nscoord NSToCoordFloor(double aValue) inline nscoord NSToCoordFloor(double aValue)
{ {
return nscoord(NS_floor(aValue)); return nscoord(floor(aValue));
} }
inline nscoord NSToCoordFloorClamped(float aValue) inline nscoord NSToCoordFloorClamped(float aValue)
@ -388,12 +388,12 @@ inline nscoord NSToCoordFloorClamped(float aValue)
inline nscoord NSToCoordCeil(float aValue) inline nscoord NSToCoordCeil(float aValue)
{ {
return nscoord(NS_ceilf(aValue)); return nscoord(ceilf(aValue));
} }
inline nscoord NSToCoordCeil(double aValue) inline nscoord NSToCoordCeil(double aValue)
{ {
return nscoord(NS_ceil(aValue)); return nscoord(ceil(aValue));
} }
inline nscoord NSToCoordCeilClamped(float aValue) inline nscoord NSToCoordCeilClamped(float aValue)
@ -437,12 +437,12 @@ inline nscoord NSToCoordCeilClamped(double aValue)
*/ */
inline PRInt32 NSToIntFloor(float aValue) inline PRInt32 NSToIntFloor(float aValue)
{ {
return PRInt32(NS_floorf(aValue)); return PRInt32(floorf(aValue));
} }
inline PRInt32 NSToIntCeil(float aValue) inline PRInt32 NSToIntCeil(float aValue)
{ {
return PRInt32(NS_ceilf(aValue)); return PRInt32(ceilf(aValue));
} }
inline PRInt32 NSToIntRound(float aValue) inline PRInt32 NSToIntRound(float aValue)
@ -457,12 +457,12 @@ inline PRInt32 NSToIntRound(double aValue)
inline PRInt32 NSToIntRoundUp(float aValue) inline PRInt32 NSToIntRoundUp(float aValue)
{ {
return PRInt32(NS_floorf(aValue + 0.5f)); return PRInt32(floorf(aValue + 0.5f));
} }
inline PRInt32 NSToIntRoundUp(double aValue) inline PRInt32 NSToIntRoundUp(double aValue)
{ {
return PRInt32(NS_floor(aValue + 0.5)); return PRInt32(floor(aValue + 0.5));
} }
/* /*

Просмотреть файл

@ -147,7 +147,7 @@ nsFontMetrics::Destroy()
// XXXTODO get rid of this macro // XXXTODO get rid of this macro
#define ROUND_TO_TWIPS(x) (nscoord)floor(((x) * mP2A) + 0.5) #define ROUND_TO_TWIPS(x) (nscoord)floor(((x) * mP2A) + 0.5)
#define CEIL_TO_TWIPS(x) (nscoord)NS_ceil((x) * mP2A) #define CEIL_TO_TWIPS(x) (nscoord)ceil((x) * mP2A)
const gfxFont::Metrics& nsFontMetrics::GetMetrics() const const gfxFont::Metrics& nsFontMetrics::GetMetrics() const
{ {
@ -194,15 +194,15 @@ nsFontMetrics::GetUnderline(nscoord& aOffset, nscoord& aSize)
static gfxFloat ComputeMaxDescent(const gfxFont::Metrics& aMetrics, static gfxFloat ComputeMaxDescent(const gfxFont::Metrics& aMetrics,
gfxFontGroup* aFontGroup) gfxFontGroup* aFontGroup)
{ {
gfxFloat offset = NS_floor(-aFontGroup->GetUnderlineOffset() + 0.5); gfxFloat offset = floor(-aFontGroup->GetUnderlineOffset() + 0.5);
gfxFloat size = NS_round(aMetrics.underlineSize); gfxFloat size = NS_round(aMetrics.underlineSize);
gfxFloat minDescent = NS_floor(offset + size + 0.5); gfxFloat minDescent = floor(offset + size + 0.5);
return NS_MAX(minDescent, aMetrics.maxDescent); return NS_MAX(minDescent, aMetrics.maxDescent);
} }
static gfxFloat ComputeMaxAscent(const gfxFont::Metrics& aMetrics) static gfxFloat ComputeMaxAscent(const gfxFont::Metrics& aMetrics)
{ {
return NS_floor(aMetrics.maxAscent + 0.5); return floor(aMetrics.maxAscent + 0.5);
} }
nscoord nscoord

Просмотреть файл

@ -114,7 +114,7 @@ gfxCachedTempSurface::Get(gfxASurface::gfxContentType aContentType,
PRBool cleared = PR_FALSE; PRBool cleared = PR_FALSE;
if (!mSurface) { if (!mSurface) {
mSize = gfxIntSize(PRInt32(NS_ceil(aRect.width)), PRInt32(NS_ceil(aRect.height))); mSize = gfxIntSize(PRInt32(ceil(aRect.width)), PRInt32(ceil(aRect.height)));
mSurface = aSimilarTo->CreateSimilarSurface(aContentType, mSize); mSurface = aSimilarTo->CreateSimilarSurface(aContentType, mSize);
if (!mSurface) if (!mSurface)
return nsnull; return nsnull;

Просмотреть файл

@ -70,11 +70,11 @@ ScaleRoundDesignUnits(FT_Short aDesignMetric, FT_Fixed aScale)
static void static void
SnapLineToPixels(gfxFloat& aOffset, gfxFloat& aSize) SnapLineToPixels(gfxFloat& aOffset, gfxFloat& aSize)
{ {
gfxFloat snappedSize = NS_MAX(NS_floor(aSize + 0.5), 1.0); gfxFloat snappedSize = NS_MAX(floor(aSize + 0.5), 1.0);
// Correct offset for change in size // Correct offset for change in size
gfxFloat offset = aOffset - 0.5 * (aSize - snappedSize); gfxFloat offset = aOffset - 0.5 * (aSize - snappedSize);
// Snap offset // Snap offset
aOffset = NS_floor(offset + 0.5); aOffset = floor(offset + 0.5);
aSize = snappedSize; aSize = snappedSize;
} }
@ -281,16 +281,16 @@ gfxFT2LockedFace::GetMetrics(gfxFont::Metrics* aMetrics,
// internalLeading + externalLeading, but first each of these is rounded // internalLeading + externalLeading, but first each of these is rounded
// to layout units. To ensure that the result is an integer number of // to layout units. To ensure that the result is an integer number of
// pixels, round each of the components to pixels. // pixels, round each of the components to pixels.
aMetrics->emHeight = NS_floor(emHeight + 0.5); aMetrics->emHeight = floor(emHeight + 0.5);
// maxHeight will normally be an integer, but round anyway in case // maxHeight will normally be an integer, but round anyway in case
// FreeType is configured differently. // FreeType is configured differently.
aMetrics->internalLeading = aMetrics->internalLeading =
NS_floor(aMetrics->maxHeight - aMetrics->emHeight + 0.5); floor(aMetrics->maxHeight - aMetrics->emHeight + 0.5);
// Text input boxes currently don't work well with lineHeight // Text input boxes currently don't work well with lineHeight
// significantly less than maxHeight (with Verdana, for example). // significantly less than maxHeight (with Verdana, for example).
lineHeight = NS_floor(NS_MAX(lineHeight, aMetrics->maxHeight) + 0.5); lineHeight = floor(NS_MAX(lineHeight, aMetrics->maxHeight) + 0.5);
aMetrics->externalLeading = aMetrics->externalLeading =
lineHeight - aMetrics->internalLeading - aMetrics->emHeight; lineHeight - aMetrics->internalLeading - aMetrics->emHeight;

Просмотреть файл

@ -1594,7 +1594,7 @@ gfxFont::SetupGlyphExtents(gfxContext *aContext, PRUint32 aGlyphID, PRBool aNeed
extents.y_bearing >= -fontMetrics.maxAscent && extents.y_bearing >= -fontMetrics.maxAscent &&
extents.height + extents.y_bearing <= fontMetrics.maxDescent) { extents.height + extents.y_bearing <= fontMetrics.maxDescent) {
PRUint32 appUnitsWidth = PRUint32 appUnitsWidth =
PRUint32(NS_ceil((extents.x_bearing + extents.width)*appUnitsPerDevUnit)); PRUint32(ceil((extents.x_bearing + extents.width)*appUnitsPerDevUnit));
if (appUnitsWidth < gfxGlyphExtents::INVALID_WIDTH) { if (appUnitsWidth < gfxGlyphExtents::INVALID_WIDTH) {
aExtents->SetContainedGlyphWidthAppUnits(aGlyphID, PRUint16(appUnitsWidth)); aExtents->SetContainedGlyphWidthAppUnits(aGlyphID, PRUint16(appUnitsWidth));
return; return;
@ -1713,9 +1713,9 @@ RoundToNearestMultiple(double aValue, double aFraction)
void gfxFont::CalculateDerivedMetrics(Metrics& aMetrics) void gfxFont::CalculateDerivedMetrics(Metrics& aMetrics)
{ {
aMetrics.maxAscent = aMetrics.maxAscent =
NS_ceil(RoundToNearestMultiple(aMetrics.maxAscent, 1/1024.0)); ceil(RoundToNearestMultiple(aMetrics.maxAscent, 1/1024.0));
aMetrics.maxDescent = aMetrics.maxDescent =
NS_ceil(RoundToNearestMultiple(aMetrics.maxDescent, 1/1024.0)); ceil(RoundToNearestMultiple(aMetrics.maxDescent, 1/1024.0));
if (aMetrics.xHeight <= 0) { if (aMetrics.xHeight <= 0) {
// only happens if we couldn't find either font metrics // only happens if we couldn't find either font metrics
@ -1828,13 +1828,13 @@ gfxFont::SanitizeMetrics(gfxFont::Metrics *aMetrics, PRBool aIsBadUnderlineFont)
// If strikeout line is overflowed from the ascent, the line should be resized and moved for // If strikeout line is overflowed from the ascent, the line should be resized and moved for
// that being in the ascent space. // that being in the ascent space.
// Note that the strikeoutOffset is *middle* of the strikeout line position. // Note that the strikeoutOffset is *middle* of the strikeout line position.
gfxFloat halfOfStrikeoutSize = NS_floor(aMetrics->strikeoutSize / 2.0 + 0.5); gfxFloat halfOfStrikeoutSize = floor(aMetrics->strikeoutSize / 2.0 + 0.5);
if (halfOfStrikeoutSize + aMetrics->strikeoutOffset > aMetrics->maxAscent) { if (halfOfStrikeoutSize + aMetrics->strikeoutOffset > aMetrics->maxAscent) {
if (aMetrics->strikeoutSize > aMetrics->maxAscent) { if (aMetrics->strikeoutSize > aMetrics->maxAscent) {
aMetrics->strikeoutSize = NS_MAX(aMetrics->maxAscent, 1.0); aMetrics->strikeoutSize = NS_MAX(aMetrics->maxAscent, 1.0);
halfOfStrikeoutSize = NS_floor(aMetrics->strikeoutSize / 2.0 + 0.5); halfOfStrikeoutSize = floor(aMetrics->strikeoutSize / 2.0 + 0.5);
} }
gfxFloat ascent = NS_floor(aMetrics->maxAscent + 0.5); gfxFloat ascent = floor(aMetrics->maxAscent + 0.5);
aMetrics->strikeoutOffset = NS_MAX(halfOfStrikeoutSize, ascent / 2.0); aMetrics->strikeoutOffset = NS_MAX(halfOfStrikeoutSize, ascent / 2.0);
} }
@ -2544,7 +2544,7 @@ gfxFontGroup::InitScriptRun(gfxContext *aContext,
gfxFloat wid = mainFont->SynthesizeSpaceWidth(ch); gfxFloat wid = mainFont->SynthesizeSpaceWidth(ch);
if (wid >= 0.0) { if (wid >= 0.0) {
nscoord advance = nscoord advance =
aTextRun->GetAppUnitsPerDevUnit() * NS_floor(wid + 0.5); aTextRun->GetAppUnitsPerDevUnit() * floor(wid + 0.5);
gfxTextRun::CompressedGlyph g; gfxTextRun::CompressedGlyph g;
if (gfxTextRun::CompressedGlyph::IsSimpleAdvance(advance)) { if (gfxTextRun::CompressedGlyph::IsSimpleAdvance(advance)) {
aTextRun->SetSimpleGlyph(index, aTextRun->SetSimpleGlyph(index,

Просмотреть файл

@ -1128,7 +1128,7 @@ gfxHarfBuzzShaper::SetGlyphsFromRun(gfxContext *aContext,
hb_position_t x_advance = posInfo[glyphStart].x_advance; hb_position_t x_advance = posInfo[glyphStart].x_advance;
nscoord advance = nscoord advance =
roundX ? dev2appUnits * FixedToIntRound(x_advance) roundX ? dev2appUnits * FixedToIntRound(x_advance)
: NS_floor(hb2appUnits * x_advance + 0.5); : floor(hb2appUnits * x_advance + 0.5);
if (glyphsInClump == 1 && if (glyphsInClump == 1 &&
gfxTextRun::CompressedGlyph::IsSimpleGlyphID(ginfo[glyphStart].codepoint) && gfxTextRun::CompressedGlyph::IsSimpleGlyphID(ginfo[glyphStart].codepoint) &&
@ -1158,18 +1158,18 @@ gfxHarfBuzzShaper::SetGlyphsFromRun(gfxContext *aContext,
hb_position_t x_offset = posInfo[glyphStart].x_offset; hb_position_t x_offset = posInfo[glyphStart].x_offset;
details->mXOffset = details->mXOffset =
roundX ? dev2appUnits * FixedToIntRound(x_offset) roundX ? dev2appUnits * FixedToIntRound(x_offset)
: NS_floor(hb2appUnits * x_offset + 0.5); : floor(hb2appUnits * x_offset + 0.5);
hb_position_t y_offset = posInfo[glyphStart].y_offset; hb_position_t y_offset = posInfo[glyphStart].y_offset;
details->mYOffset = yPos - details->mYOffset = yPos -
(roundY ? dev2appUnits * FixedToIntRound(y_offset) (roundY ? dev2appUnits * FixedToIntRound(y_offset)
: NS_floor(hb2appUnits * y_offset + 0.5)); : floor(hb2appUnits * y_offset + 0.5));
details->mAdvance = advance; details->mAdvance = advance;
hb_position_t y_advance = posInfo[glyphStart].y_advance; hb_position_t y_advance = posInfo[glyphStart].y_advance;
if (y_advance != 0) { if (y_advance != 0) {
yPos -= yPos -=
roundY ? dev2appUnits * FixedToIntRound(y_advance) roundY ? dev2appUnits * FixedToIntRound(y_advance)
: NS_floor(hb2appUnits * y_advance + 0.5); : floor(hb2appUnits * y_advance + 0.5);
} }
if (++glyphStart >= glyphEnd) { if (++glyphStart >= glyphEnd) {
break; break;
@ -1177,7 +1177,7 @@ gfxHarfBuzzShaper::SetGlyphsFromRun(gfxContext *aContext,
x_advance = posInfo[glyphStart].x_advance; x_advance = posInfo[glyphStart].x_advance;
advance = advance =
roundX ? dev2appUnits * FixedToIntRound(x_advance) roundX ? dev2appUnits * FixedToIntRound(x_advance)
: NS_floor(hb2appUnits * x_advance + 0.5); : floor(hb2appUnits * x_advance + 0.5);
} }
gfxTextRun::CompressedGlyph g; gfxTextRun::CompressedGlyph g;

Просмотреть файл

@ -194,8 +194,8 @@ public:
*/ */
PRBool HasNonIntegerTranslation() const { PRBool HasNonIntegerTranslation() const {
return HasNonTranslation() || return HasNonTranslation() ||
!FuzzyEqual(x0, NS_floor(x0 + 0.5)) || !FuzzyEqual(x0, floor(x0 + 0.5)) ||
!FuzzyEqual(y0, NS_floor(y0 + 0.5)); !FuzzyEqual(y0, floor(y0 + 0.5));
} }
/** /**
@ -291,8 +291,8 @@ public:
* Returns true if the matrix has non-integer scale * Returns true if the matrix has non-integer scale
*/ */
PRBool HasNonIntegerScale() const { PRBool HasNonIntegerScale() const {
return !FuzzyEqual(xx, NS_floor(xx + 0.5)) || return !FuzzyEqual(xx, floor(xx + 0.5)) ||
!FuzzyEqual(yy, NS_floor(yy + 0.5)); !FuzzyEqual(yy, floor(yy + 0.5));
} }
private: private:

Просмотреть файл

@ -127,11 +127,11 @@ static void FillMetricsDefaults(gfxFont::Metrics *aMetrics)
// line as close to the original position as possible. // line as close to the original position as possible.
static void SnapLineToPixels(gfxFloat& aOffset, gfxFloat& aSize) static void SnapLineToPixels(gfxFloat& aOffset, gfxFloat& aSize)
{ {
gfxFloat snappedSize = NS_MAX(NS_floor(aSize + 0.5), 1.0); gfxFloat snappedSize = NS_MAX(floor(aSize + 0.5), 1.0);
// Correct offset for change in size // Correct offset for change in size
gfxFloat offset = aOffset - 0.5 * (aSize - snappedSize); gfxFloat offset = aOffset - 0.5 * (aSize - snappedSize);
// Snap offset // Snap offset
aOffset = NS_floor(offset + 0.5); aOffset = floor(offset + 0.5);
aSize = snappedSize; aSize = snappedSize;
} }
@ -155,7 +155,7 @@ const gfxFont::Metrics& gfxOS2Font::GetMetrics()
// round size to integer pixels, this is to get full pixels for layout // round size to integer pixels, this is to get full pixels for layout
// together with internal/external leading (see below) // together with internal/external leading (see below)
mMetrics->emHeight = NS_floor(GetStyle()->size + 0.5); mMetrics->emHeight = floor(GetStyle()->size + 0.5);
cairo_scaled_font_t* scaledFont = CairoScaledFont(); cairo_scaled_font_t* scaledFont = CairoScaledFont();
if (!scaledFont) { if (!scaledFont) {
@ -274,9 +274,9 @@ const gfxFont::Metrics& gfxOS2Font::GetMetrics()
// leadings are not available directly (only for WinFNTs); // leadings are not available directly (only for WinFNTs);
// better compute them on our own, to get integer values and make // better compute them on our own, to get integer values and make
// layout happy (see // LockedFTFace::GetMetrics in gfxPangoFonts.cpp) // layout happy (see // LockedFTFace::GetMetrics in gfxPangoFonts.cpp)
mMetrics->internalLeading = NS_floor(mMetrics->maxHeight mMetrics->internalLeading = floor(mMetrics->maxHeight
- mMetrics->emHeight + 0.5); - mMetrics->emHeight + 0.5);
gfxFloat lineHeight = NS_floor(mMetrics->maxHeight + 0.5); gfxFloat lineHeight = floor(mMetrics->maxHeight + 0.5);
mMetrics->externalLeading = lineHeight mMetrics->externalLeading = lineHeight
- mMetrics->internalLeading - mMetrics->emHeight; - mMetrics->internalLeading - mMetrics->emHeight;

Просмотреть файл

@ -69,8 +69,8 @@ struct THEBES_API gfxPoint : public mozilla::gfx::BasePoint<gfxFloat, gfxPoint>
// And if you need similar method which is using NS_round(), you should // And if you need similar method which is using NS_round(), you should
// create new |RoundAwayFromZero()| method. // create new |RoundAwayFromZero()| method.
gfxPoint& Round() { gfxPoint& Round() {
x = NS_floor(x + 0.5); x = floor(x + 0.5);
y = NS_floor(y + 0.5); y = floor(y + 0.5);
return *this; return *this;
} }
}; };

Просмотреть файл

@ -59,10 +59,10 @@ void
gfxRect::Round() gfxRect::Round()
{ {
// Note that don't use NS_round here. See the comment for this method in gfxRect.h // Note that don't use NS_round here. See the comment for this method in gfxRect.h
gfxFloat x0 = NS_floor(X() + 0.5); gfxFloat x0 = floor(X() + 0.5);
gfxFloat y0 = NS_floor(Y() + 0.5); gfxFloat y0 = floor(Y() + 0.5);
gfxFloat x1 = NS_floor(XMost() + 0.5); gfxFloat x1 = floor(XMost() + 0.5);
gfxFloat y1 = NS_floor(YMost() + 0.5); gfxFloat y1 = floor(YMost() + 0.5);
x = x0; x = x0;
y = y0; y = y0;
@ -74,10 +74,10 @@ gfxRect::Round()
void void
gfxRect::RoundIn() gfxRect::RoundIn()
{ {
gfxFloat x0 = NS_ceil(X()); gfxFloat x0 = ceil(X());
gfxFloat y0 = NS_ceil(Y()); gfxFloat y0 = ceil(Y());
gfxFloat x1 = NS_floor(XMost()); gfxFloat x1 = floor(XMost());
gfxFloat y1 = NS_floor(YMost()); gfxFloat y1 = floor(YMost());
x = x0; x = x0;
y = y0; y = y0;
@ -89,10 +89,10 @@ gfxRect::RoundIn()
void void
gfxRect::RoundOut() gfxRect::RoundOut()
{ {
gfxFloat x0 = NS_floor(X()); gfxFloat x0 = floor(X());
gfxFloat y0 = NS_floor(Y()); gfxFloat y0 = floor(Y());
gfxFloat x1 = NS_ceil(XMost()); gfxFloat x1 = ceil(XMost());
gfxFloat y1 = NS_ceil(YMost()); gfxFloat y1 = ceil(YMost());
x = x0; x = x0;
y = y0; y = y0;

Просмотреть файл

@ -489,7 +489,7 @@ gfxUtils::ClampToScaleFactor(gfxFloat aVal)
if (fabs(power - NS_round(power)) < 1e-6) { if (fabs(power - NS_round(power)) < 1e-6) {
power = NS_round(power); power = NS_round(power);
} else { } else {
power = NS_ceil(power); power = ceil(power);
} }
return pow(kScaleResolution, power); return pow(kScaleResolution, power);

Просмотреть файл

@ -138,8 +138,8 @@ gfxWindowsNativeDrawing::BeginNativeDrawing()
// There's probably a better fix, but I haven't figured out // There's probably a better fix, but I haven't figured out
// the root cause of the problem. // the root cause of the problem.
mTempSurfaceSize = mTempSurfaceSize =
gfxIntSize((PRInt32) NS_ceil(mNativeRect.Width() + 1), gfxIntSize((PRInt32) ceil(mNativeRect.Width() + 1),
(PRInt32) NS_ceil(mNativeRect.Height() + 1)); (PRInt32) ceil(mNativeRect.Height() + 1));
} else { } else {
// figure out the scale factors // figure out the scale factors
mScale = m.ScaleFactors(PR_TRUE); mScale = m.ScaleFactors(PR_TRUE);
@ -153,8 +153,8 @@ gfxWindowsNativeDrawing::BeginNativeDrawing()
// See comment above about "+1" // See comment above about "+1"
mTempSurfaceSize = mTempSurfaceSize =
gfxIntSize((PRInt32) NS_ceil(mNativeRect.Width() * mScale.width + 1), gfxIntSize((PRInt32) ceil(mNativeRect.Width() * mScale.width + 1),
(PRInt32) NS_ceil(mNativeRect.Height() * mScale.height + 1)); (PRInt32) ceil(mNativeRect.Height() * mScale.height + 1));
} }
} }
} }

Просмотреть файл

@ -5022,6 +5022,18 @@ if test -n "$JS_GC_ZEAL"; then
AC_DEFINE(JS_GC_ZEAL) AC_DEFINE(JS_GC_ZEAL)
fi fi
dnl ========================================================
dnl JS opt-mode assertions and minidump instrumentation
dnl ========================================================
MOZ_ARG_ENABLE_BOOL(js-diagnostics,
[ --enable-js-diagnostics
Enable JS diagnostic assertions and breakpad data],
JS_CRASH_DIAGNOSTICS=1,
JS_CRASH_DIAGNOSTICS= )
if test -n "$JS_CRASH_DIAGNOSTICS"; then
AC_DEFINE(JS_CRASH_DIAGNOSTICS)
fi
dnl ====================================================== dnl ======================================================
dnl = Enable compiling with ccache dnl = Enable compiling with ccache
dnl ====================================================== dnl ======================================================

Просмотреть файл

@ -0,0 +1,3 @@
var g = newGlobal('new-compartment');
g.eval("function f(n) { for (var i = 0; i < n; i++) f(0); }");
g.f(RUNLOOP + 1);

Просмотреть файл

@ -562,8 +562,6 @@ JSCompartment::purge(JSContext *cx)
#endif #endif
#ifdef JS_METHODJIT #ifdef JS_METHODJIT
js::CheckCompartmentScripts(this);
for (JSScript *script = (JSScript *)scripts.next; for (JSScript *script = (JSScript *)scripts.next;
&script->links != &scripts; &script->links != &scripts;
script = (JSScript *)script->links.next) { script = (JSScript *)script->links.next) {

Просмотреть файл

@ -245,37 +245,37 @@ static Stack gGCStack(JS_CRASH_STACK_GC);
static Stack gErrorStack(JS_CRASH_STACK_ERROR); static Stack gErrorStack(JS_CRASH_STACK_ERROR);
static Ring gRingBuffer(JS_CRASH_RING); static Ring gRingBuffer(JS_CRASH_RING);
void
SnapshotGCStack()
{
if (gInitialized)
gGCStack.snapshot();
}
void
SnapshotErrorStack()
{
if (gInitialized)
gErrorStack.snapshot();
}
void
SaveCrashData(uint64 tag, void *ptr, size_t size)
{
if (gInitialized)
gRingBuffer.push(tag, ptr, size);
}
} /* namespace crash */ } /* namespace crash */
} /* namespace js */ } /* namespace js */
using namespace js; using namespace js;
using namespace js::crash; using namespace js::crash;
JS_FRIEND_API(void)
js_SnapshotGCStack()
{
if (gInitialized)
gGCStack.snapshot();
}
JS_FRIEND_API(void)
js_SnapshotErrorStack()
{
if (gInitialized)
gErrorStack.snapshot();
}
JS_FRIEND_API(void)
js_SaveCrashData(uint64 tag, void *ptr, size_t size)
{
if (gInitialized)
gRingBuffer.push(tag, ptr, size);
}
JS_PUBLIC_API(void) JS_PUBLIC_API(void)
JS_EnumerateDiagnosticMemoryRegions(JSEnumerateDiagnosticMemoryCallback callback) JS_EnumerateDiagnosticMemoryRegions(JSEnumerateDiagnosticMemoryCallback callback)
{ {
#if 1 #ifdef JS_CRASH_DIAGNOSTICS
if (!gInitialized) { if (!gInitialized) {
gInitialized = true; gInitialized = true;
(*callback)(&gGCStack, sizeof(gGCStack)); (*callback)(&gGCStack, sizeof(gGCStack));

Просмотреть файл

@ -42,18 +42,46 @@
#define jscrashreport_h___ #define jscrashreport_h___
#include "jstypes.h" #include "jstypes.h"
#include "jsutil.h"
JS_BEGIN_EXTERN_C namespace js {
namespace crash {
JS_FRIEND_API(void) void
js_SnapshotGCStack(); SnapshotGCStack();
JS_FRIEND_API(void) void
js_SnapshotErrorStack(); SnapshotErrorStack();
JS_FRIEND_API(void) void
js_SaveCrashData(uint64 tag, void *ptr, size_t size); SaveCrashData(uint64 tag, void *ptr, size_t size);
JS_END_EXTERN_C template<size_t size, char marker>
class StackBuffer {
private:
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
volatile char buffer[size + 4];
public:
StackBuffer(void *data JS_GUARD_OBJECT_NOTIFIER_PARAM) {
JS_GUARD_OBJECT_NOTIFIER_INIT;
buffer[0] = marker;
buffer[1] = '[';
for (size_t i = 0; i < size; i++) {
if (data)
buffer[i + 2] = ((char *)data)[i];
else
buffer[i + 2] = 0;
}
buffer[size - 2] = ']';
buffer[size - 1] = marker;
}
};
} /* namespace crash */
} /* namespace js */
#endif /* jscrashreport_h___ */ #endif /* jscrashreport_h___ */

Просмотреть файл

@ -241,7 +241,7 @@ Arena::finalize(JSContext *cx)
if (!newFreeSpanStart) if (!newFreeSpanStart)
newFreeSpanStart = thing; newFreeSpanStart = thing;
t->finalize(cx); t->finalize(cx);
memset(t, JS_FREE_PATTERN, sizeof(T)); JS_POISON(t, JS_FREE_PATTERN, sizeof(T));
} }
} }
} }
@ -2399,9 +2399,6 @@ MarkAndSweep(JSContext *cx, JSCompartment *comp, JSGCInvocationKind gckind GCTIM
printf("GC HEAP SIZE %lu\n", (unsigned long)rt->gcBytes); printf("GC HEAP SIZE %lu\n", (unsigned long)rt->gcBytes);
} }
#endif #endif
for (JSCompartment **c = rt->compartments.begin(); c != rt->compartments.end(); c++)
js::CheckCompartmentScripts(*c);
} }
#ifdef JS_THREADSAFE #ifdef JS_THREADSAFE
@ -2693,7 +2690,7 @@ js_GC(JSContext *cx, JSCompartment *comp, JSGCInvocationKind gckind)
GCCrashData crashData; GCCrashData crashData;
crashData.isRegen = rt->shapeGen & SHAPE_OVERFLOW_BIT; crashData.isRegen = rt->shapeGen & SHAPE_OVERFLOW_BIT;
crashData.isCompartment = !!comp; crashData.isCompartment = !!comp;
js_SaveCrashData(crash::JS_CRASH_TAG_GC, &crashData, sizeof(crashData)); crash::SaveCrashData(crash::JS_CRASH_TAG_GC, &crashData, sizeof(crashData));
GCTIMER_BEGIN(rt, comp); GCTIMER_BEGIN(rt, comp);
@ -2744,7 +2741,7 @@ js_GC(JSContext *cx, JSCompartment *comp, JSGCInvocationKind gckind)
rt->gcChunkAllocationSinceLastGC = false; rt->gcChunkAllocationSinceLastGC = false;
GCTIMER_END(gckind == GC_LAST_CONTEXT); GCTIMER_END(gckind == GC_LAST_CONTEXT);
js_SnapshotGCStack(); crash::SnapshotGCStack();
} }
namespace js { namespace js {

Просмотреть файл

@ -100,13 +100,6 @@ PushMarkStack(GCMarker *gcmarker, JSShortString *thing);
static inline void static inline void
PushMarkStack(GCMarker *gcmarker, JSString *thing); PushMarkStack(GCMarker *gcmarker, JSString *thing);
static void
volatile_memcpy(volatile unsigned char *dst, const void *src, size_t n)
{
for (size_t i = 0; i < n; i++)
dst[i] = ((char *)src)[i];
}
template<typename T> template<typename T>
void void
Mark(JSTracer *trc, T *thing) Mark(JSTracer *trc, T *thing)
@ -122,15 +115,9 @@ Mark(JSTracer *trc, T *thing)
JS_ASSERT(thing->compartment()); JS_ASSERT(thing->compartment());
JS_ASSERT(thing->compartment()->rt == rt); JS_ASSERT(thing->compartment()->rt == rt);
if (rt->gcCheckCompartment && thing->compartment() != rt->gcCheckCompartment && JS_OPT_ASSERT_IF(rt->gcCheckCompartment,
thing->compartment() != rt->atomsCompartment) thing->compartment() == rt->gcCheckCompartment ||
{ thing->compartment() == rt->atomsCompartment);
volatile unsigned char dbg[sizeof(T) + 2];
dbg[0] = 0xab;
dbg[1] = 0xcd;
volatile_memcpy(dbg + 2, thing, sizeof(T));
JS_Assert("compartment mismatch in GC", __FILE__, __LINE__);
}
/* /*
* Don't mark things outside a compartment if we are in a per-compartment * Don't mark things outside a compartment if we are in a per-compartment

Просмотреть файл

@ -3417,24 +3417,6 @@ CopySlots(JSContext *cx, JSObject *from, JSObject *to)
return true; return true;
} }
static void
CheckProxy(JSObject *obj)
{
if (!obj->isProxy())
return;
JSProxyHandler *handler = obj->getProxyHandler();
if (handler->isCrossCompartment())
return;
Value priv = obj->getProxyPrivate();
if (!priv.isObject())
return;
if (priv.toObject().compartment() != obj->compartment())
JS_Assert("compartment mismatch in proxy object", __FILE__, __LINE__);
}
JSObject * JSObject *
JSObject::clone(JSContext *cx, JSObject *proto, JSObject *parent) JSObject::clone(JSContext *cx, JSObject *proto, JSObject *parent)
{ {
@ -3472,8 +3454,6 @@ JSObject::clone(JSContext *cx, JSObject *proto, JSObject *parent)
return NULL; return NULL;
} }
CheckProxy(clone);
return clone; return clone;
} }
@ -3586,11 +3566,6 @@ JSObject::swap(JSContext *cx, JSObject *other)
TradeGuts(this, otherClone); TradeGuts(this, otherClone);
TradeGuts(other, thisClone); TradeGuts(other, thisClone);
CheckProxy(this);
CheckProxy(other);
CheckProxy(thisClone);
CheckProxy(otherClone);
return true; return true;
} }

Просмотреть файл

@ -1184,11 +1184,6 @@ NewProxyObject(JSContext *cx, JSProxyHandler *handler, const Value &priv, JSObje
else else
clasp = handler->isOuterWindow() ? &OuterWindowProxyClass : &ObjectProxyClass; clasp = handler->isOuterWindow() ? &OuterWindowProxyClass : &ObjectProxyClass;
if (!handler->isCrossCompartment() && priv.isObject()) {
if (priv.toObject().compartment() != cx->compartment)
JS_Assert("compartment mismatch in proxy object", __FILE__, __LINE__);
}
JSObject *obj = NewNonFunction<WithProto::Given>(cx, clasp, proto, parent); JSObject *obj = NewNonFunction<WithProto::Given>(cx, clasp, proto, parent);
if (!obj || !obj->ensureInstanceReservedSlots(cx, 0)) if (!obj || !obj->ensureInstanceReservedSlots(cx, 0))
return NULL; return NULL;

Просмотреть файл

@ -92,10 +92,6 @@ class JS_FRIEND_API(JSProxyHandler) {
return false; return false;
} }
virtual bool isCrossCompartment() {
return false;
}
inline void *family() { inline void *family() {
return mFamily; return mFamily;
} }

Просмотреть файл

@ -46,6 +46,7 @@
#include "jstypes.h" #include "jstypes.h"
#include "jsstdint.h" #include "jsstdint.h"
#include "jsutil.h" #include "jsutil.h"
#include "jscrashreport.h"
#include "jsprf.h" #include "jsprf.h"
#include "jsapi.h" #include "jsapi.h"
#include "jsatom.h" #include "jsatom.h"
@ -287,44 +288,26 @@ Bindings::trace(JSTracer *trc)
} /* namespace js */ } /* namespace js */
static void
volatile_memcpy(volatile char *dst, void *src, size_t n)
{
for (size_t i = 0; i < n; i++)
dst[i] = ((char *)src)[i];
}
static void static void
CheckScript(JSScript *script, JSScript *prev) CheckScript(JSScript *script, JSScript *prev)
{ {
volatile char dbg1[sizeof(JSScript)], dbg2[sizeof(JSScript)]; #ifdef JS_CRASH_DIAGNOSTICS
if (script->cookie1 != JS_SCRIPT_COOKIE || script->cookie2 != JS_SCRIPT_COOKIE) { if (script->cookie1 != JS_SCRIPT_COOKIE || script->cookie2 != JS_SCRIPT_COOKIE) {
volatile_memcpy(dbg1, script, sizeof(JSScript)); crash::StackBuffer<sizeof(JSScript), 0x87> buf1(script);
if (prev) crash::StackBuffer<sizeof(JSScript), 0x88> buf2(prev);
volatile_memcpy(dbg2, prev, sizeof(JSScript)); JS_OPT_ASSERT(false);
} }
JS_OPT_ASSERT(script->cookie1 == JS_SCRIPT_COOKIE && script->cookie2 == JS_SCRIPT_COOKIE); #endif
} }
static void static void
CheckScriptOwner(JSScript *script, JSObject *owner) CheckScriptOwner(JSScript *script, JSObject *owner)
{ {
if (script->ownerObject != owner) { #ifdef JS_CRASH_DIAGNOSTICS
volatile char scriptData[sizeof(JSScript)];
volatile char owner1Data[sizeof(JSObject)], owner2Data[sizeof(JSObject)];
volatile char savedOwner[sizeof(JSObject *)];
volatile_memcpy(scriptData, script, sizeof(JSScript));
volatile_memcpy(savedOwner, &owner, sizeof(JSObject *));
if (script->ownerObject != JS_NEW_SCRIPT && script->ownerObject != JS_CACHED_SCRIPT)
volatile_memcpy(owner1Data, script->ownerObject, sizeof(JSObject));
if (owner != JS_NEW_SCRIPT && owner != JS_CACHED_SCRIPT)
volatile_memcpy(owner2Data, owner, sizeof(JSObject));
}
JS_OPT_ASSERT(script->ownerObject == owner); JS_OPT_ASSERT(script->ownerObject == owner);
if (owner != JS_NEW_SCRIPT && owner != JS_CACHED_SCRIPT) if (owner != JS_NEW_SCRIPT && owner != JS_CACHED_SCRIPT)
JS_OPT_ASSERT(script->compartment == owner->compartment()); JS_OPT_ASSERT(script->compartment == owner->compartment());
#endif
} }
#if JS_HAS_XDR #if JS_HAS_XDR
@ -981,8 +964,10 @@ JSScript::NewScript(JSContext *cx, uint32 length, uint32 nsrcnotes, uint32 natom
return NULL; return NULL;
PodZero(script); PodZero(script);
#ifdef JS_CRASH_DIAGNOSTICS
script->cookie1 = script->cookie2 = JS_SCRIPT_COOKIE; script->cookie1 = script->cookie2 = JS_SCRIPT_COOKIE;
script->ownerObject = JS_NEW_SCRIPT; script->ownerObject = JS_NEW_SCRIPT;
#endif
script->length = length; script->length = length;
script->version = version; script->version = version;
new (&script->bindings) Bindings(cx, emptyCallShape); new (&script->bindings) Bindings(cx, emptyCallShape);
@ -1286,8 +1271,10 @@ JSScript::totalSize()
void void
JSScript::setOwnerObject(JSObject *owner) JSScript::setOwnerObject(JSObject *owner)
{ {
#ifdef JS_CRASH_DIAGNOSTICS
CheckScriptOwner(this, JS_NEW_SCRIPT); CheckScriptOwner(this, JS_NEW_SCRIPT);
ownerObject = owner; ownerObject = owner;
#endif
} }
/* /*
@ -1328,22 +1315,6 @@ js_CallDestroyScriptHook(JSContext *cx, JSScript *script)
JS_ClearScriptTraps(cx, script); JS_ClearScriptTraps(cx, script);
} }
namespace js {
void
CheckCompartmentScripts(JSCompartment *comp)
{
JSScript *prev = NULL;
for (JSScript *script = (JSScript *)comp->scripts.next;
&script->links != &comp->scripts;
prev = script, script = (JSScript *)script->links.next)
{
CheckScript(script, prev);
}
}
} /* namespace js */
static void static void
DestroyScript(JSContext *cx, JSScript *script, JSObject *owner, uint32 caller) DestroyScript(JSContext *cx, JSScript *script, JSObject *owner, uint32 caller)
{ {
@ -1408,7 +1379,7 @@ DestroyScript(JSContext *cx, JSScript *script, JSObject *owner, uint32 caller)
if (script->sourceMap) if (script->sourceMap)
cx->free_(script->sourceMap); cx->free_(script->sourceMap);
memset(script, 0xdb, script->totalSize()); JS_POISON(script, 0xdb, sizeof(JSScript));
*(uint32 *)script = caller; *(uint32 *)script = caller;
cx->free_(script); cx->free_(script);
} }
@ -1443,9 +1414,8 @@ js_TraceScript(JSTracer *trc, JSScript *script, JSObject *owner)
if (owner) if (owner)
CheckScriptOwner(script, owner); CheckScriptOwner(script, owner);
JSRuntime *rt = trc->context->runtime; DebugOnly<JSRuntime *> rt = trc->context->runtime;
if (rt->gcCheckCompartment && script->compartment != rt->gcCheckCompartment) JS_OPT_ASSERT_IF(rt->gcCheckCompartment, script->compartment == rt->gcCheckCompartment);
JS_Assert("compartment mismatch in GC", __FILE__, __LINE__);
JSAtomMap *map = &script->atomMap; JSAtomMap *map = &script->atomMap;
MarkAtomRange(trc, map->length, map->vector, "atomMap"); MarkAtomRange(trc, map->length, map->vector, "atomMap");

Просмотреть файл

@ -449,7 +449,9 @@ struct JSScript {
jsbytecode *code; /* bytecodes and their immediate operands */ jsbytecode *code; /* bytecodes and their immediate operands */
uint32 length; /* length of code vector */ uint32 length; /* length of code vector */
#ifdef JS_CRASH_DIAGNOSTICS
uint32 cookie1; uint32 cookie1;
#endif
private: private:
uint16 version; /* JS version under which script was compiled */ uint16 version; /* JS version under which script was compiled */
@ -507,7 +509,9 @@ struct JSScript {
JSPrincipals *principals;/* principals for this script */ JSPrincipals *principals;/* principals for this script */
jschar *sourceMap; /* source map file or null */ jschar *sourceMap; /* source map file or null */
#ifdef JS_CRASH_DIAGNOSTICS
JSObject *ownerObject; JSObject *ownerObject;
#endif
void setOwnerObject(JSObject *owner); void setOwnerObject(JSObject *owner);
@ -541,7 +545,9 @@ struct JSScript {
/* array of execution counters for every JSOp in the script, by runmode */ /* array of execution counters for every JSOp in the script, by runmode */
JSPCCounters pcCounters; JSPCCounters pcCounters;
#ifdef JS_CRASH_DIAGNOSTICS
uint32 cookie2; uint32 cookie2;
#endif
public: public:
#ifdef JS_METHODJIT #ifdef JS_METHODJIT
@ -747,19 +753,6 @@ js_DestroyScriptFromGC(JSContext *cx, JSScript *script, JSObject *owner);
extern void extern void
js_DestroyCachedScript(JSContext *cx, JSScript *script); js_DestroyCachedScript(JSContext *cx, JSScript *script);
namespace js {
/*
* This diagnostic function checks that a compartment's list of scripts
* contains only valid scripts. It also searches for the target script
* in the list. If expected is true, it asserts that the target script
* is found. If expected is false, it asserts that it's not found.
*/
void
CheckCompartmentScripts(JSCompartment *comp);
} /* namespace js */
extern void extern void
js_TraceScript(JSTracer *trc, JSScript *script, JSObject *owner); js_TraceScript(JSTracer *trc, JSScript *script, JSObject *owner);

Просмотреть файл

@ -10467,7 +10467,10 @@ TraceRecorder::record_EnterFrame()
/* Try inlining one level in case this recursion doesn't go too deep. */ /* Try inlining one level in case this recursion doesn't go too deep. */
if (fp->script() == fp->prev()->script() && if (fp->script() == fp->prev()->script() &&
fp->prev()->prev() && fp->prev()->prev()->script() == fp->script()) { fp->prev()->prev() &&
fp->prev()->prev()->isScriptFrame() &&
fp->prev()->prev()->script() == fp->script())
{
RETURN_STOP_A("recursion started inlining"); RETURN_STOP_A("recursion started inlining");
} }

Просмотреть файл

@ -45,7 +45,6 @@
#define jsutil_h___ #define jsutil_h___
#include "jstypes.h" #include "jstypes.h"
#include "jscrashreport.h"
#include "mozilla/Util.h" #include "mozilla/Util.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -62,12 +61,24 @@ JS_BEGIN_EXTERN_C
#define JS_FREE_PATTERN 0xDA #define JS_FREE_PATTERN 0xDA
#ifdef JS_CRASH_DIAGNOSTICS
#define JS_POISON(p, val, size) memset((p), (val), (size))
#define JS_OPT_ASSERT(expr) \ #define JS_OPT_ASSERT(expr) \
((expr) ? (void)0 : JS_Assert(#expr, __FILE__, __LINE__)) ((expr) ? (void)0 : JS_Assert(#expr, __FILE__, __LINE__))
#define JS_OPT_ASSERT_IF(cond, expr) \ #define JS_OPT_ASSERT_IF(cond, expr) \
((!(cond) || (expr)) ? (void)0 : JS_Assert(#expr, __FILE__, __LINE__)) ((!(cond) || (expr)) ? (void)0 : JS_Assert(#expr, __FILE__, __LINE__))
#else
#define JS_POISON(p, val, size) ((void) 0)
#define JS_OPT_ASSERT(expr) ((void) 0)
#define JS_OPT_ASSERT_IF(cond, expr) ((void) 0)
#endif /* JS_CRASH_DIAGNOSTICS */
#ifdef DEBUG #ifdef DEBUG
#define JS_ASSERT(expr) \ #define JS_ASSERT(expr) \
@ -227,12 +238,6 @@ extern JS_PUBLIC_DATA(JSUint32) OOM_counter; /* data race, who cares. */
#define JS_OOM_POSSIBLY_FAIL() do {} while(0) #define JS_OOM_POSSIBLY_FAIL() do {} while(0)
#endif #endif
static JS_INLINE void *js_record_oom(void *p) {
if (!p)
js_SnapshotErrorStack();
return p;
}
/* /*
* SpiderMonkey code should not be calling these allocation functions directly. * SpiderMonkey code should not be calling these allocation functions directly.
* Instead, all calls should go through JSRuntime, JSContext or OffTheBooks. * Instead, all calls should go through JSRuntime, JSContext or OffTheBooks.
@ -240,17 +245,17 @@ static JS_INLINE void *js_record_oom(void *p) {
*/ */
static JS_INLINE void* js_malloc(size_t bytes) { static JS_INLINE void* js_malloc(size_t bytes) {
JS_OOM_POSSIBLY_FAIL(); JS_OOM_POSSIBLY_FAIL();
return js_record_oom(malloc(bytes)); return malloc(bytes);
} }
static JS_INLINE void* js_calloc(size_t bytes) { static JS_INLINE void* js_calloc(size_t bytes) {
JS_OOM_POSSIBLY_FAIL(); JS_OOM_POSSIBLY_FAIL();
return js_record_oom(calloc(bytes, 1)); return calloc(bytes, 1);
} }
static JS_INLINE void* js_realloc(void* p, size_t bytes) { static JS_INLINE void* js_realloc(void* p, size_t bytes) {
JS_OOM_POSSIBLY_FAIL(); JS_OOM_POSSIBLY_FAIL();
return js_record_oom(realloc(p, bytes)); return realloc(p, bytes);
} }
static JS_INLINE void js_free(void* p) { static JS_INLINE void js_free(void* p) {

Просмотреть файл

@ -155,10 +155,6 @@ class JS_FRIEND_API(JSCrossCompartmentWrapper) : public JSWrapper {
virtual void trace(JSTracer *trc, JSObject *wrapper); virtual void trace(JSTracer *trc, JSObject *wrapper);
virtual bool isCrossCompartment() {
return true;
}
static JSCrossCompartmentWrapper singleton; static JSCrossCompartmentWrapper singleton;
}; };

Просмотреть файл

@ -1943,7 +1943,7 @@ static nscoord
FindTileStart(nscoord aDirtyCoord, nscoord aTilePos, nscoord aTileDim) FindTileStart(nscoord aDirtyCoord, nscoord aTilePos, nscoord aTileDim)
{ {
NS_ASSERTION(aTileDim > 0, "Non-positive tile dimension"); NS_ASSERTION(aTileDim > 0, "Non-positive tile dimension");
double multiples = NS_floor(double(aDirtyCoord - aTilePos)/aTileDim); double multiples = floor(double(aDirtyCoord - aTilePos)/aTileDim);
return NSToCoordRound(multiples*aTileDim + aTilePos); return NSToCoordRound(multiples*aTileDim + aTilePos);
} }
@ -2050,7 +2050,7 @@ nsCSSRendering::PaintGradient(nsPresContext* aPresContext,
// try to do anything in that case. We certainly need to avoid // try to do anything in that case. We certainly need to avoid
// dividing by zero. // dividing by zero.
if (stopDelta >= 1e-6) { if (stopDelta >= 1e-6) {
double instanceCount = NS_ceil(-firstStop/stopDelta); double instanceCount = ceil(-firstStop/stopDelta);
// Advance stops by instanceCount multiples of the period of the // Advance stops by instanceCount multiples of the period of the
// repeating gradient. // repeating gradient.
double offset = instanceCount*stopDelta; double offset = instanceCount*stopDelta;
@ -3607,15 +3607,15 @@ nsCSSRendering::GetTextDecorationRectInternal(const gfxPoint& aPt,
PRBool canLiftUnderline = aDescentLimit >= 0.0; PRBool canLiftUnderline = aDescentLimit >= 0.0;
const gfxFloat left = NS_floor(aPt.x + 0.5), const gfxFloat left = floor(aPt.x + 0.5),
right = NS_floor(aPt.x + aLineSize.width + 0.5); right = floor(aPt.x + aLineSize.width + 0.5);
gfxRect r(left, 0, right - left, 0); gfxRect r(left, 0, right - left, 0);
gfxFloat lineHeight = NS_round(aLineSize.height); gfxFloat lineHeight = NS_round(aLineSize.height);
lineHeight = NS_MAX(lineHeight, 1.0); lineHeight = NS_MAX(lineHeight, 1.0);
gfxFloat ascent = NS_round(aAscent); gfxFloat ascent = NS_round(aAscent);
gfxFloat descentLimit = NS_floor(aDescentLimit); gfxFloat descentLimit = floor(aDescentLimit);
gfxFloat suggestedMaxRectHeight = NS_MAX(NS_MIN(ascent, descentLimit), 1.0); gfxFloat suggestedMaxRectHeight = NS_MAX(NS_MIN(ascent, descentLimit), 1.0);
r.height = lineHeight; r.height = lineHeight;
@ -3671,7 +3671,7 @@ nsCSSRendering::GetTextDecorationRectInternal(const gfxPoint& aPt,
} }
} }
gfxFloat baseline = NS_floor(aPt.y + aAscent + 0.5); gfxFloat baseline = floor(aPt.y + aAscent + 0.5);
gfxFloat offset = 0.0; gfxFloat offset = 0.0;
switch (aDecoration) { switch (aDecoration) {
case NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE: case NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE:
@ -3692,7 +3692,7 @@ nsCSSRendering::GetTextDecorationRectInternal(const gfxPoint& aPt,
offset = aOffset - lineHeight + r.Height(); offset = aOffset - lineHeight + r.Height();
break; break;
case NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH: { case NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH: {
gfxFloat extra = NS_floor(r.Height() / 2.0 + 0.5); gfxFloat extra = floor(r.Height() / 2.0 + 0.5);
extra = NS_MAX(extra, lineHeight); extra = NS_MAX(extra, lineHeight);
offset = aOffset - lineHeight + extra; offset = aOffset - lineHeight + extra;
break; break;
@ -3700,7 +3700,7 @@ nsCSSRendering::GetTextDecorationRectInternal(const gfxPoint& aPt,
default: default:
NS_ERROR("Invalid decoration value!"); NS_ERROR("Invalid decoration value!");
} }
r.y = baseline - NS_floor(offset + 0.5); r.y = baseline - floor(offset + 0.5);
return r; return r;
} }

Просмотреть файл

@ -2766,7 +2766,7 @@ AdvanceToNextTab(gfxFloat aX, nsIFrame* aFrame,
// Advance aX to the next multiple of *aCachedTabWidth. We must advance // Advance aX to the next multiple of *aCachedTabWidth. We must advance
// by at least 1 appunit. // by at least 1 appunit.
// XXX should we make this 1 CSS pixel? // XXX should we make this 1 CSS pixel?
return NS_ceil((aX + 1)/(*aCachedTabWidth))*(*aCachedTabWidth); return ceil((aX + 1)/(*aCachedTabWidth))*(*aCachedTabWidth);
} }
void void
@ -4517,7 +4517,7 @@ ComputeSelectionUnderlineHeight(nsPresContext* aPresContext,
gfxFloat fontSize = NS_MIN(gfxFloat(defaultFontSize), gfxFloat fontSize = NS_MIN(gfxFloat(defaultFontSize),
aFontMetrics.emHeight); aFontMetrics.emHeight);
fontSize = NS_MAX(fontSize, 1.0); fontSize = NS_MAX(fontSize, 1.0);
return NS_ceil(fontSize / 20); return ceil(fontSize / 20);
} }
default: default:
NS_WARNING("Requested underline style is not valid"); NS_WARNING("Requested underline style is not valid");

Просмотреть файл

@ -319,8 +319,8 @@ static nscoord CalcLengthWith(const nsCSSValue& aValue,
gfxFloat zeroWidth = (fm->GetThebesFontGroup()->GetFontAt(0) gfxFloat zeroWidth = (fm->GetThebesFontGroup()->GetFontAt(0)
->GetMetrics().zeroOrAveCharWidth); ->GetMetrics().zeroOrAveCharWidth);
return ScaleCoord(aValue, NS_ceil(aPresContext->AppUnitsPerDevPixel() * return ScaleCoord(aValue, ceil(aPresContext->AppUnitsPerDevPixel() *
zeroWidth)); zeroWidth));
} }
// For properties for which lengths are the *only* units accepted in // For properties for which lengths are the *only* units accepted in
// calc(), we can handle calc() here and just compute a final // calc(), we can handle calc() here and just compute a final

Просмотреть файл

@ -1384,8 +1384,8 @@ nsStyleAnimation::AddWeighted(nsCSSProperty aProperty,
switch (aProperty) { switch (aProperty) {
case eCSSProperty_font_stretch: { case eCSSProperty_font_stretch: {
// Animate just like eUnit_Integer. // Animate just like eUnit_Integer.
PRInt32 result = NS_floor(aCoeff1 * double(aValue1.GetIntValue()) + PRInt32 result = floor(aCoeff1 * double(aValue1.GetIntValue()) +
aCoeff2 * double(aValue2.GetIntValue())); aCoeff2 * double(aValue2.GetIntValue()));
if (result < NS_STYLE_FONT_STRETCH_ULTRA_CONDENSED) { if (result < NS_STYLE_FONT_STRETCH_ULTRA_CONDENSED) {
result = NS_STYLE_FONT_STRETCH_ULTRA_CONDENSED; result = NS_STYLE_FONT_STRETCH_ULTRA_CONDENSED;
} else if (result > NS_STYLE_FONT_STRETCH_ULTRA_EXPANDED) { } else if (result > NS_STYLE_FONT_STRETCH_ULTRA_EXPANDED) {
@ -1409,8 +1409,8 @@ nsStyleAnimation::AddWeighted(nsCSSProperty aProperty,
case eUnit_Integer: { case eUnit_Integer: {
// http://dev.w3.org/csswg/css3-transitions/#animation-of-property-types- // http://dev.w3.org/csswg/css3-transitions/#animation-of-property-types-
// says we should use floor // says we should use floor
PRInt32 result = NS_floor(aCoeff1 * double(aValue1.GetIntValue()) + PRInt32 result = floor(aCoeff1 * double(aValue1.GetIntValue()) +
aCoeff2 * double(aValue2.GetIntValue())); aCoeff2 * double(aValue2.GetIntValue()));
if (aProperty == eCSSProperty_font_weight) { if (aProperty == eCSSProperty_font_weight) {
if (result < 100) { if (result < 100) {
result = 100; result = 100;

Просмотреть файл

@ -29,6 +29,13 @@ var ContextCommands = {
} }
}, },
pasteAndGo: function cc_pasteAndGo() {
let target = ContextHelper.popupState.target;
target.editor.selectAll();
target.editor.paste(Ci.nsIClipboard.kGlobalClipboard);
BrowserUI.goToURI();
},
selectAll: function cc_selectAll() { selectAll: function cc_selectAll() {
let target = ContextHelper.popupState.target; let target = ContextHelper.popupState.target;
if (target.localName == "browser") { if (target.localName == "browser") {

Просмотреть файл

@ -1820,8 +1820,12 @@
let flavors = ["text/unicode"]; let flavors = ["text/unicode"];
let hasData = clipboard.hasDataMatchingFlavors(flavors, flavors.length, Ci.nsIClipboard.kGlobalClipboard); let hasData = clipboard.hasDataMatchingFlavors(flavors, flavors.length, Ci.nsIClipboard.kGlobalClipboard);
if (hasData && (!aTextbox.readOnly || aIgnoreReadOnly)) if (hasData && (!aTextbox.readOnly || aIgnoreReadOnly)) {
json.types.push("paste"); json.types.push("paste");
if (aTextbox.type == "url") {
json.types.push("paste-url");
}
}
ContextHelper.showPopup({ target: aTextbox, json: json }); ContextHelper.showPopup({ target: aTextbox, json: json });
]]></body> ]]></body>

Просмотреть файл

@ -626,6 +626,9 @@
<richlistitem class="context-command" id="context-paste" type="paste" onclick="ContextCommands.paste();"> <richlistitem class="context-command" id="context-paste" type="paste" onclick="ContextCommands.paste();">
<label value="&paste.label;"/> <label value="&paste.label;"/>
</richlistitem> </richlistitem>
<richlistitem class="context-command" id="context-paste-n-go" type="paste-url" onclick="ContextCommands.pasteAndGo();">
<label value="&pasteAndGo.label;"/>
</richlistitem>
<richlistitem class="context-command" id="context-select-all" type="select-all" onclick="ContextCommands.selectAll();"> <richlistitem class="context-command" id="context-select-all" type="select-all" onclick="ContextCommands.selectAll();">
<label value="&selectAll.label;"/> <label value="&selectAll.label;"/>
</richlistitem> </richlistitem>

Просмотреть файл

@ -16,6 +16,7 @@
<!ENTITY copyAll.label "Copy All"> <!ENTITY copyAll.label "Copy All">
<!ENTITY copylink.label "Copy Link Location"> <!ENTITY copylink.label "Copy Link Location">
<!ENTITY paste.label "Paste"> <!ENTITY paste.label "Paste">
<!ENTITY pasteAndGo.label "Paste &amp; Go">
<!ENTITY delete.label "Delete"> <!ENTITY delete.label "Delete">
<!ENTITY selectAll.label "Select All"> <!ENTITY selectAll.label "Select All">
<!ENTITY noSuggestions.label "(No suggestions)"> <!ENTITY noSuggestions.label "(No suggestions)">

Просмотреть файл

@ -590,9 +590,9 @@ namespace places {
} }
else { else {
// Estimate frecency using the last few visits. // Estimate frecency using the last few visits.
// Use NS_ceilf() so that we don't round down to 0, which // Use ceilf() so that we don't round down to 0, which
// would cause us to completely ignore the place during autocomplete. // would cause us to completely ignore the place during autocomplete.
NS_ADDREF(*_result = new IntegerVariant((PRInt32) NS_ceilf(fullVisitCount * NS_ceilf(pointsForSampledVisits) / numSampledVisits))); NS_ADDREF(*_result = new IntegerVariant((PRInt32) ceilf(fullVisitCount * ceilf(pointsForSampledVisits) / numSampledVisits)));
} }
return NS_OK; return NS_OK;
@ -625,9 +625,9 @@ namespace places {
// Assume "now" as our ageInDays, so use the first bucket. // Assume "now" as our ageInDays, so use the first bucket.
pointsForSampledVisits = history->GetFrecencyBucketWeight(1) * (bonus / (float)100.0); pointsForSampledVisits = history->GetFrecencyBucketWeight(1) * (bonus / (float)100.0);
// use NS_ceilf() so that we don't round down to 0, which // use ceilf() so that we don't round down to 0, which
// would cause us to completely ignore the place during autocomplete // would cause us to completely ignore the place during autocomplete
NS_ADDREF(*_result = new IntegerVariant((PRInt32) NS_ceilf(fullVisitCount * NS_ceilf(pointsForSampledVisits)))); NS_ADDREF(*_result = new IntegerVariant((PRInt32) ceilf(fullVisitCount * ceilf(pointsForSampledVisits))));
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -177,7 +177,7 @@ static const PRInt64 USECS_PER_DAY = LL_INIT(20, 500654080);
// long, but we split only the last 6 months. // long, but we split only the last 6 months.
#define HISTORY_DATE_CONT_NUM(_daysFromOldestVisit) \ #define HISTORY_DATE_CONT_NUM(_daysFromOldestVisit) \
(HISTORY_ADDITIONAL_DATE_CONT_NUM + \ (HISTORY_ADDITIONAL_DATE_CONT_NUM + \
NS_MIN(6, (PRInt32)NS_ceilf((float)_daysFromOldestVisit/30))) NS_MIN(6, (PRInt32)ceilf((float)_daysFromOldestVisit/30)))
// Max number of containers, used to initialize the params hash. // Max number of containers, used to initialize the params hash.
#define HISTORY_DATE_CONT_MAX 10 #define HISTORY_DATE_CONT_MAX 10

Просмотреть файл

@ -6359,7 +6359,7 @@ nsWindow::ResetRemainingWheelDelta()
static PRInt32 RoundDelta(double aDelta) static PRInt32 RoundDelta(double aDelta)
{ {
return aDelta >= 0 ? (PRInt32)NS_floor(aDelta) : (PRInt32)NS_ceil(aDelta); return aDelta >= 0 ? (PRInt32)floor(aDelta) : (PRInt32)ceil(aDelta);
} }
/** /**

Просмотреть файл

@ -105,30 +105,6 @@ inline NS_HIDDEN_(PRInt32) NS_lroundf(float x)
return x >= 0.0f ? PRInt32(x + 0.5f) : PRInt32(x - 0.5f); return x >= 0.0f ? PRInt32(x + 0.5f) : PRInt32(x - 0.5f);
} }
/*
* ceil
*/
inline NS_HIDDEN_(double) NS_ceil(double x)
{
return ceil(x);
}
inline NS_HIDDEN_(float) NS_ceilf(float x)
{
return ceilf(x);
}
/*
* floor
*/
inline NS_HIDDEN_(double) NS_floor(double x)
{
return floor(x);
}
inline NS_HIDDEN_(float) NS_floorf(float x)
{
return floorf(x);
}
/* /*
* hypot. We don't need a super accurate version of this, if a platform * hypot. We don't need a super accurate version of this, if a platform
* turns up with none of the possibilities below it would be okay to fall * turns up with none of the possibilities below it would be okay to fall