Merge inbound to m-c.

This commit is contained in:
Ryan VanderMeulen 2013-06-04 15:01:10 -04:00
commit 9f97ebd7ad
59 changed files with 939 additions and 116 deletions

View File

@ -226,7 +226,7 @@ nsMathMLElement::IsAttributeMapped(const nsIAtom* aAttribute) const
nsIAtom* tag = Tag();
if (tag == nsGkAtoms::ms_ || tag == nsGkAtoms::mi_ ||
tag == nsGkAtoms::mn_ || tag == nsGkAtoms::mo_ ||
tag == nsGkAtoms::mtext_)
tag == nsGkAtoms::mtext_ || tag == nsGkAtoms::mspace_)
return FindAttributeDependence(aAttribute, tokenMap);
if (tag == nsGkAtoms::mstyle_ ||
tag == nsGkAtoms::math)

View File

@ -1,8 +0,0 @@
<html xmlns="http://www.w3.org/1999/xhtml"><body style="display: -moz-box;">
<font style="display: table; float: left;">
<span style="display: table;">
text text
</span>
</font>
</body>
</html>

View File

@ -401,7 +401,6 @@ load 770381-1.html
load 772306.html
load 788360.html
load 793848.html
test-pref(font.size.inflation.minTwips,120) load 794693.html
load 795646.html
load 802902.html
skip-if(!gtk2Widget) load 813372-1.html # bug 873083

View File

@ -432,14 +432,12 @@ nsHTMLReflowState::InitResizeFlags(nsPresContext* aPresContext, nsIAtom* aFrameT
nsLayoutUtils::FontSizeInflationEnabled(aPresContext)) {
// Create our font inflation data if we don't have it already, and
// give it our current width information.
bool dirty = nsFontInflationData::UpdateFontInflationDataWidthFor(*this) &&
// Avoid running this at the box-to-block interface
// (where we shouldn't be inflating anyway, and where
// reflow state construction is probably to construct a
// dummy parent reflow state anyway).
bool dirty = !mFlags.mDummyParentReflowState &&
nsFontInflationData::UpdateFontInflationDataWidthFor(*this);
!mFlags.mDummyParentReflowState;
if (dirty || (!frame->GetParent() && isHResize)) {
// When font size inflation is enabled, a change in either:

View File

@ -111,7 +111,7 @@ operator.\u003B.infix = lspace:0 rspace:3 separator # ;
operator.\u003C.infix = lspace:5 rspace:5 # &lt;
operator.\u003C\u003D.infix = lspace:5 rspace:5 # &lt;=
operator.\u003C\u003E.infix = lspace:1 rspace:1 # &lt;>
operator.\u003D.infix = lspace:5 rspace:5 # =
operator.\u003D.infix = lspace:5 rspace:5 direction:horizontal # =
operator.\u003D\u003D.infix = lspace:4 rspace:4 # ==
operator.\u003E.infix = lspace:5 rspace:5 # >
operator.\u003E\u003D.infix = lspace:5 rspace:5 # >=

View File

@ -23,6 +23,7 @@
\u203E = \uFFFD\uFFFD\uFFFD\u0305\u00AF # overline
\u0332 = \uFFFD\uFFFD\uFFFD\u0332\u0332 # COMBINING LOW LINE, UnderBar
\u005F = \uFFFD\uFFFD\uFFFD\u0332\u0332 # _ low line
\u003D = \uFFFD\uFFFD\uFFFD\u003D\u003D # = equal sign
\u2016 = \uFFFD\uFFFD\uFFFD\u2016\u2016 # DOUBLE VERTICAL LINE, Vert, Verbar

View File

@ -29,6 +29,9 @@ static const PRUnichar kLongDivChar = ')';
// radical: 'SQUARE ROOT'
static const PRUnichar kRadicalChar = 0x221A;
// updiagonalstrike
static const uint8_t kArrowHeadSize = 10;
nsIFrame*
NS_NewMathMLmencloseFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
{
@ -115,6 +118,8 @@ nsresult nsMathMLmencloseFrame::AddNotation(const nsAString& aNotation)
mNotationsToDraw |= NOTATION_BOTTOM;
} else if (aNotation.EqualsLiteral("updiagonalstrike")) {
mNotationsToDraw |= NOTATION_UPDIAGONALSTRIKE;
} else if (aNotation.EqualsLiteral("updiagonalarrow")) {
mNotationsToDraw |= NOTATION_UPDIAGONALARROW;
} else if (aNotation.EqualsLiteral("downdiagonalstrike")) {
mNotationsToDraw |= NOTATION_DOWNDIAGONALSTRIKE;
} else if (aNotation.EqualsLiteral("verticalstrike")) {
@ -146,6 +151,14 @@ void nsMathMLmencloseFrame::InitNotations()
while (tokenizer.hasMoreTokens())
AddNotation(tokenizer.nextToken());
if (IsToDraw(NOTATION_UPDIAGONALARROW)) {
// For <menclose notation="updiagonalstrike updiagonalarrow">, if
// the two notations are drawn then the strike line may cause the point of
// the arrow to be too wide. Hence we will only draw the updiagonalarrow
// and the arrow shaft may be thought to be the updiagonalstrike.
mNotationsToDraw &= ~NOTATION_UPDIAGONALSTRIKE;
}
} else {
// default: longdiv
if (NS_FAILED(AllocateMathMLChar(NOTATION_LONGDIV)))
@ -251,6 +264,11 @@ nsMathMLmencloseFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
mRuleThickness, NOTATION_UPDIAGONALSTRIKE);
}
if (IsToDraw(NOTATION_UPDIAGONALARROW)) {
DisplayNotation(aBuilder, this, mencloseRect, aLists,
mRuleThickness, NOTATION_UPDIAGONALARROW);
}
if (IsToDraw(NOTATION_DOWNDIAGONALSTRIKE)) {
DisplayNotation(aBuilder, this, mencloseRect, aLists,
mRuleThickness, NOTATION_DOWNDIAGONALSTRIKE);
@ -370,6 +388,7 @@ nsMathMLmencloseFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
if (IsToDraw(NOTATION_RIGHT) ||
IsToDraw(NOTATION_LEFT) ||
IsToDraw(NOTATION_UPDIAGONALSTRIKE) ||
IsToDraw(NOTATION_UPDIAGONALARROW) ||
IsToDraw(NOTATION_DOWNDIAGONALSTRIKE) ||
IsToDraw(NOTATION_VERTICALSTRIKE) ||
IsToDraw(NOTATION_CIRCLE) ||
@ -398,6 +417,21 @@ nsMathMLmencloseFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
IsToDraw(NOTATION_CIRCLE))
mBoundingMetrics.descent += padding;
///////////////
// updiagonal arrow notation. We need enough space at the top right corner to
// draw the arrow head.
if (IsToDraw(NOTATION_UPDIAGONALARROW)) {
// This is an estimate, see nsDisplayNotation::Paint for the exact head size
nscoord arrowHeadSize = kArrowHeadSize * mRuleThickness;
// We want that the arrow shaft strikes the menclose content and that the
// arrow head does not overlap with that content. Hence we add some space
// on the right. We don't add space on the top but only ensure that the
// ascent is large enough.
dx_right = std::max(dx_right, arrowHeadSize);
mBoundingMetrics.ascent = std::max(mBoundingMetrics.ascent, arrowHeadSize);
}
///////////////
// circle notation: we don't want the ellipse to overlap the enclosed
// content. Hence, we need to increase the size of the bounding box by a
@ -568,6 +602,7 @@ nsMathMLmencloseFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
IsToDraw(NOTATION_RIGHT) ||
IsToDraw(NOTATION_LEFT) ||
IsToDraw(NOTATION_UPDIAGONALSTRIKE) ||
IsToDraw(NOTATION_UPDIAGONALARROW) ||
IsToDraw(NOTATION_DOWNDIAGONALSTRIKE) ||
IsToDraw(NOTATION_VERTICALSTRIKE) ||
IsToDraw(NOTATION_CIRCLE) ||
@ -578,6 +613,7 @@ nsMathMLmencloseFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
IsToDraw(NOTATION_RIGHT) ||
IsToDraw(NOTATION_LEFT) ||
IsToDraw(NOTATION_UPDIAGONALSTRIKE) ||
IsToDraw(NOTATION_UPDIAGONALARROW) ||
IsToDraw(NOTATION_DOWNDIAGONALSTRIKE) ||
IsToDraw(NOTATION_VERTICALSTRIKE) ||
IsToDraw(NOTATION_CIRCLE) ||
@ -714,30 +750,63 @@ void nsDisplayNotation::Paint(nsDisplayListBuilder* aBuilder,
// change line width to mThickness
gfxContext *gfxCtx = aCtx->ThebesContext();
gfxFloat currentLineWidth = gfxCtx->CurrentLineWidth();
gfxFloat e = presContext->AppUnitsToGfxUnits(mThickness);
gfxCtx->Save();
gfxCtx->SetLineWidth(e);
rect.Deflate(e / 2.0);
gfxCtx->NewPath();
switch(mType)
{
case NOTATION_CIRCLE:
gfxCtx->NewPath();
gfxCtx->Ellipse(rect.Center(), rect.Size());
gfxCtx->Stroke();
break;
case NOTATION_ROUNDEDBOX:
gfxCtx->NewPath();
gfxCtx->RoundedRectangle(rect, gfxCornerSizes(3 * e), true);
gfxCtx->Stroke();
break;
case NOTATION_UPDIAGONALSTRIKE:
gfxCtx->NewPath();
gfxCtx->Line(rect.BottomLeft(), rect.TopRight());
gfxCtx->Stroke();
break;
case NOTATION_DOWNDIAGONALSTRIKE:
gfxCtx->NewPath();
gfxCtx->Line(rect.TopLeft(), rect.BottomRight());
gfxCtx->Stroke();
break;
case NOTATION_UPDIAGONALARROW: {
// Compute some parameters to draw the updiagonalarrow. The values below
// are taken from MathJax's HTML-CSS output.
gfxFloat W = rect.Width(); gfxFloat H = rect.Height();
gfxFloat l = sqrt(W*W + H*H);
gfxFloat f = gfxFloat(kArrowHeadSize) * e / l;
gfxFloat w = W * f; gfxFloat h = H * f;
// Draw the arrow shaft
gfxCtx->NewPath();
gfxCtx->Line(rect.BottomLeft(), rect.TopRight() + gfxPoint(-.7*w, .7*h));
gfxCtx->Stroke();
// Draw the arrow head
gfxCtx->NewPath();
gfxPoint p[] = {
rect.TopRight(),
rect.TopRight() + gfxPoint(-w -.4*h, std::max(-e / 2.0, h - .4*w)),
rect.TopRight() + gfxPoint(-.7*w, .7*h),
rect.TopRight() + gfxPoint(std::min(e / 2.0, -w + .4*h), h + .4*w),
rect.TopRight()
};
gfxCtx->Polygon(p, sizeof(p));
gfxCtx->Fill();
}
break;
default:
@ -745,10 +814,7 @@ void nsDisplayNotation::Paint(nsDisplayListBuilder* aBuilder,
break;
}
gfxCtx->Stroke();
// restore previous line width
gfxCtx->SetLineWidth(currentLineWidth);
gfxCtx->Restore();
}
void

View File

@ -38,7 +38,8 @@ enum nsMencloseNotation
NOTATION_UPDIAGONALSTRIKE = 0x100,
NOTATION_DOWNDIAGONALSTRIKE = 0x200,
NOTATION_VERTICALSTRIKE = 0x400,
NOTATION_HORIZONTALSTRIKE = 0x800
NOTATION_HORIZONTALSTRIKE = 0x800,
NOTATION_UPDIAGONALARROW = 0x1000
};
class nsMathMLmencloseFrame : public nsMathMLContainerFrame {

View File

@ -167,12 +167,6 @@ nsMathMLmoFrame::ProcessTextData()
mFlags |= allFlags & NS_MATHML_OPERATOR_ACCENT;
mFlags |= allFlags & NS_MATHML_OPERATOR_MOVABLELIMITS;
bool isMutable =
NS_MATHML_OPERATOR_IS_STRETCHY(allFlags) ||
NS_MATHML_OPERATOR_IS_LARGEOP(allFlags);
if (isMutable)
mFlags |= NS_MATHML_OPERATOR_MUTABLE;
// see if this is an operator that should be centered to cater for
// fonts that are not math-aware
if (1 == length) {
@ -187,12 +181,19 @@ nsMathMLmoFrame::ProcessTextData()
// cache the operator
mMathMLChar.SetData(presContext, data);
ResolveMathMLCharStyle(presContext, mContent, mStyleContext, &mMathMLChar, isMutable);
// cache the native direction -- beware of bug 133429...
// mEmbellishData.direction must always retain our native direction, whereas
// mMathMLChar.GetStretchDirection() may change later, when Stretch() is called
mEmbellishData.direction = mMathMLChar.GetStretchDirection();
bool isMutable =
NS_MATHML_OPERATOR_IS_LARGEOP(allFlags) ||
(mEmbellishData.direction != NS_STRETCH_DIRECTION_UNSUPPORTED);
if (isMutable)
mFlags |= NS_MATHML_OPERATOR_MUTABLE;
ResolveMathMLCharStyle(presContext, mContent, mStyleContext, &mMathMLChar, isMutable);
}
// get our 'form' and lookup in the Operator Dictionary to fetch

View File

@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head><title>Updiagonalarrow</title></head>
<body>
<p><math><menclose notation="updiagonalstrike"><mspace width="50px" height="50px"/></menclose></math></p>
</body>
</html>

View File

@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head><title>Updiagonalarrow</title></head>
<body>
<p><math><menclose><mspace width="50px" height="50px"/></menclose></math></p>
</body>
</html>

View File

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html>
<head>
<title>mspace</title>
</head>
<body>
<div style="position: absolute;
top: 0; left: 0;
width: 50px; height: 6em;
background: red;"></div>
<div style="position: absolute;
top: 2em; left: 50px;
width: 40px; height: 3em;
background: green;"></div>
<div style="position: absolute;
top: 1em; left: 90px;
width: 30px; height: 3em;
background: blue;"></div>
</body>
</html>

View File

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<title>mspace</title>
</head>
<body>
<math style="position: absolute; top: 0; left: 0; margin: 0; padding: 0;">
<mspace width="50px" height="3em" depth="3em" mathbackground="red"/>
<mspace width="40px" height="1em" depth="2em" mathbackground="green"/>
<mspace width="30px" height="2em" depth="1em" mathbackground="blue"/>
</math>
</body>
</html>

View File

@ -82,7 +82,9 @@ fails == mstyle-5.xhtml mstyle-5-ref.xhtml # Bug 787215
== scale-stretchy-3.xhtml scale-stretchy-3-ref.xhtml
!= scale-stretchy-4.xhtml scale-stretchy-4-ref.xhtml
!= scale-stretchy-5.xhtml scale-stretchy-5-ref.xhtml
!= stretchy-1.html stretchy-1-ref.html
== math-as-mstyle-1.xhtml math-as-mstyle-1-ref.xhtml
== mspace-1.html mspace-1-ref.html
== mpadded-1.html mpadded-1-ref.html
== mpadded-2.html mpadded-2-ref.html
== mpadded-3.html mpadded-3-ref.html
@ -122,3 +124,4 @@ fails == whitespace-trim-4.html whitespace-trim-4-ref.html # Bug 787215
== number-size-1.xhtml number-size-1-ref.xhtml
== mathml-mmultiscript-base.html mathml-mmultiscript-base-ref.html
== mathml-mmultiscript-mprescript.html mathml-mmultiscript-mprescript-ref.html
!= menclose-1.html menclose-1-ref.html

View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head><title>Test stretchy equal (bug 854339)</title></head>
<body>
<math>
<munder>
<mi>AVERYLONGBASE</mi>
<mo stretchy="false">=</mo>
</munder>
</math>
</body>
</html>

View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head><title>Test stretchy equal (bug 854339)</title></head>
<body>
<math>
<munder>
<mi>AVERYLONGBASE</mi>
<mo stretchy="true">=</mo>
</munder>
</math>
</body>
</html>

View File

@ -13,7 +13,7 @@ LIBRARY_NAME = kiss_fft
ifeq (WINNT,$(OS_TARGET))
VISIBILITY_FLAGS =
endif
CSRCS = kiss_fft.c kiss_fftr.c
DISABLED_CSRCS = kiss_fft.c kiss_fftr.c
include $(topsrcdir)/config/rules.mk

View File

@ -1,3 +1,4 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
@ -10,3 +11,7 @@ EXPORTS.kiss_fft += [
'kiss_fftr.h',
]
CSRCS += [
'kiss_fft.c',
'kiss_fftr.c',
]

View File

@ -16,12 +16,12 @@ ifeq ($(OS_TARGET),WINNT)
VISIBILITY_FLAGS =
endif
CSRCS = \
DISABLED_CSRCS = \
cubeb.c \
$(NULL)
ifeq ($(OS_TARGET),WINNT)
CSRCS += \
DISABLED_CSRCS += \
cubeb_winmm.c \
$(NULL)
DEFINES += -DUSE_WINMM
@ -29,40 +29,40 @@ endif
ifeq ($(OS_TARGET),Android)
ifneq ($(MOZ_WIDGET_TOOLKIT),gonk)
CSRCS += \
DISABLED_CSRCS += \
cubeb_audiotrack.c \
$(NULL)
DEFINES += -DUSE_AUDIOTRACK
endif
CSRCS += \
DISABLED_CSRCS += \
cubeb_opensl.c \
$(NULL)
DEFINES += -DUSE_OPENSL
endif
ifeq ($(OS_TARGET),Darwin)
CSRCS += \
DISABLED_CSRCS += \
cubeb_audiounit.c \
$(NULL)
DEFINES += -DUSE_AUDIOUNIT
endif
ifeq ($(OS_ARCH),OpenBSD)
CSRCS += \
DISABLED_CSRCS += \
cubeb_sndio.c \
$(NULL)
DEFINES += -DUSE_SNDIO
endif
ifdef MOZ_ALSA
CSRCS += \
DISABLED_CSRCS += \
cubeb_alsa.c \
$(NULL)
DEFINES += -DUSE_ALSA
endif
ifdef MOZ_PULSEAUDIO
CSRCS += \
DISABLED_CSRCS += \
cubeb_pulse.c \
$(NULL)
DEFINES += -DUSE_PULSE

View File

@ -6,3 +6,40 @@
MODULE = 'cubeb'
CSRCS += [
'cubeb.c',
]
if CONFIG['MOZ_ALSA']:
CSRCS += [
'cubeb_alsa.c',
]
if CONFIG['MOZ_PULSEAUDIO']:
CSRCS += [
'cubeb_pulse.c',
]
if CONFIG['OS_ARCH'] == 'OpenBSD':
CSRCS += [
'cubeb_sndio.c',
]
if CONFIG['OS_TARGET'] == 'Darwin':
CSRCS += [
'cubeb_audiounit.c',
]
if CONFIG['OS_TARGET'] == 'WINNT':
CSRCS += [
'cubeb_winmm.c',
]
if CONFIG['OS_TARGET'] == 'Android':
CSRCS += [
'cubeb_opensl.c',
]
if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
CSRCS += [
'cubeb_audiotrack.c',
]

View File

@ -17,7 +17,7 @@ ifeq ($(OS_ARCH),WINNT)
VISIBILITY_FLAGS =
endif
CSRCS = \
DISABLED_CSRCS = \
jcomapi.c \
jdapimin.c \
jdapistd.c \
@ -52,7 +52,7 @@ CSRCS = \
$(NULL)
# These files enable support for writing JPEGs
CSRCS += \
DISABLED_CSRCS += \
jcapimin.c \
jcapistd.c \
jccoefct.c \
@ -81,16 +81,16 @@ endif
# No SIMD support?
ifeq (,$(LIBJPEG_TURBO_X86_ASM)$(LIBJPEG_TURBO_X64_ASM)$(LIBJPEG_TURBO_ARM_ASM))
CSRCS += jsimd_none.c
DISABLED_CSRCS += jsimd_none.c
endif
ifeq (1,$(LIBJPEG_TURBO_ARM_ASM))
CSRCS += simd/jsimd_arm.c
DISABLED_CSRCS += simd/jsimd_arm.c
SSRCS += simd/jsimd_arm_neon.S
endif
ifeq (1,$(LIBJPEG_TURBO_X64_ASM))
CSRCS += simd/jsimd_x86_64.c
DISABLED_CSRCS += simd/jsimd_x86_64.c
DISABLED_ASFILES += \
simd/jccolss2-64.asm \
simd/jcgrass2-64.asm \
@ -111,7 +111,7 @@ ifeq (1,$(LIBJPEG_TURBO_X64_ASM))
endif
ifeq (1,$(LIBJPEG_TURBO_X86_ASM))
CSRCS +=simd/jsimd_i386.c
DISABLED_CSRCS +=simd/jsimd_i386.c
DISABLED_ASFILES += \
simd/jccolmmx.asm \
simd/jccolss2.asm \

View File

@ -73,3 +73,74 @@ if CONFIG['LIBJPEG_TURBO_X86_ASM']:
'simd/jisseflt.asm',
'simd/jsimdcpu.asm',
]
CSRCS += [
'jcomapi.c',
'jdapimin.c',
'jdapistd.c',
'jdatadst.c',
'jdatasrc.c',
'jdcoefct.c',
'jdcolor.c',
'jddctmgr.c',
'jdhuff.c',
'jdinput.c',
'jdmainct.c',
'jdmarker.c',
'jdmaster.c',
'jdmerge.c',
'jdphuff.c',
'jdpostct.c',
'jdsample.c',
'jdtrans.c',
'jerror.c',
'jfdctflt.c',
'jfdctfst.c',
'jfdctint.c',
'jidctflt.c',
'jidctfst.c',
'jidctint.c',
'jidctred.c',
'jmemmgr.c',
'jmemnobs.c',
'jquant1.c',
'jquant2.c',
'jutils.c',
]
# These files enable support for writing JPEGs
CSRCS += [
'jcapimin.c',
'jcapistd.c',
'jccoefct.c',
'jccolor.c',
'jcdctmgr.c',
'jchuff.c',
'jcinit.c',
'jcmainct.c',
'jcmarker.c',
'jcmaster.c',
'jcparam.c',
'jcphuff.c',
'jcprepct.c',
'jcsample.c',
'jctrans.c',
]
if CONFIG['LIBJPEG_TURBO_ARM_ASM']:
CSRCS += [
'simd/jsimd_arm.c',
]
elif CONFIG['LIBJPEG_TURBO_X64_ASM']:
CSRCS += [
'simd/jsimd_x86_64.c',
]
elif CONFIG['LIBJPEG_TURBO_X86_ASM']:
CSRCS += [
'simd/jsimd_i386.c',
]
else: # No SIMD support?
CSRCS += [
'jsimd_none.c',
]

View File

@ -16,7 +16,7 @@ ifeq (WINNT,$(OS_TARGET))
VISIBILITY_FLAGS =
endif
CSRCS = \
DISABLED_CSRCS = \
nestegg.c \
halloc.c \
$(NULL)

View File

@ -6,3 +6,7 @@
MODULE = 'nestegg'
CSRCS += [
'halloc.c',
'nestegg.c',
]

View File

@ -16,7 +16,7 @@ ifeq (WINNT,$(OS_TARGET))
VISIBILITY_FLAGS =
endif
CSRCS = \
DISABLED_CSRCS = \
ogg_bitwise.c \
ogg_framing.c \
$(NULL)

View File

@ -6,3 +6,7 @@
MODULE = 'ogg'
CSRCS += [
'ogg_bitwise.c',
'ogg_framing.c',
]

View File

@ -18,7 +18,7 @@ VISIBILITY_FLAGS=
endif
CSRCS = \
DISABLED_CSRCS = \
png.c \
pngerror.c \
pngget.c \
@ -28,7 +28,7 @@ CSRCS = \
$(NULL)
# These files enable support for reading/writing PNGs
CSRCS += \
DISABLED_CSRCS += \
pngpread.c \
pngread.c \
pngrio.c \

View File

@ -12,3 +12,24 @@ EXPORTS += [
'pngconf.h',
]
CSRCS += [
'png.c',
'pngerror.c',
'pngget.c',
'pngmem.c',
'pngset.c',
'pngtrans.c',
]
# These files enable support for reading/writing PNGs
CSRCS += [
'pngpread.c',
'pngread.c',
'pngrio.c',
'pngrtran.c',
'pngrutil.c',
'pngwio.c',
'pngwrite.c',
'pngwtran.c',
'pngwutil.c',
]

View File

@ -503,27 +503,6 @@ PeerConnectionImpl::Initialize(IPeerConnectionObserver* aObserver,
{
nsresult res;
// Generate a random handle
unsigned char handle_bin[8];
SECStatus rv;
rv = PK11_GenerateRandom(handle_bin, sizeof(handle_bin));
if (rv != SECSuccess) {
return NS_ERROR_UNEXPECTED;
}
char hex[17];
PR_snprintf(hex,sizeof(hex),"%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x",
handle_bin[0],
handle_bin[1],
handle_bin[2],
handle_bin[3],
handle_bin[4],
handle_bin[5],
handle_bin[6],
handle_bin[7]);
mHandle = hex;
// Invariant: we receive configuration one way or the other but not both (XOR)
MOZ_ASSERT(!aConfiguration != !aRTCConfiguration);
#ifdef MOZILLA_INTERNAL_API
@ -551,6 +530,28 @@ PeerConnectionImpl::Initialize(IPeerConnectionObserver* aObserver,
NS_ENSURE_STATE(mWindow);
#endif
// Generate a random handle
unsigned char handle_bin[8];
SECStatus rv;
rv = PK11_GenerateRandom(handle_bin, sizeof(handle_bin));
if (rv != SECSuccess) {
MOZ_CRASH();
return NS_ERROR_UNEXPECTED;
}
char hex[17];
PR_snprintf(hex,sizeof(hex),"%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x",
handle_bin[0],
handle_bin[1],
handle_bin[2],
handle_bin[3],
handle_bin[4],
handle_bin[5],
handle_bin[6],
handle_bin[7]);
mHandle = hex;
res = PeerConnectionCtx::InitializeGlobal(mThread);
NS_ENSURE_SUCCESS(res, res);

View File

@ -19,13 +19,13 @@ endif
DEFINES += -DMOZ_MEMORY_IMPL
CSRCS = \
DISABLED_CSRCS = \
mozmemory_wrap.c \
jemalloc_config.c \
$(NULL)
ifdef MOZ_JEMALLOC3
CSRCS += mozjemalloc_compat.c
DISABLED_CSRCS += mozjemalloc_compat.c
LOCAL_INCLUDES += -I../jemalloc/src/include
ifdef _MSC_VER
LOCAL_INCLUDES += -I$(topsrcdir)/memory/jemalloc/src/include/msvc_compat
@ -40,7 +40,7 @@ endif
ifdef MOZ_REPLACE_MALLOC
DEFINES += -DMOZ_REPLACE_MALLOC
CSRCS += replace_malloc.c
DISABLED_CSRCS += replace_malloc.c
# The zone allocator for OSX needs some jemalloc internal functions
ifeq (Darwin,$(OS_TARGET))

View File

@ -16,3 +16,17 @@ if CONFIG['MOZ_REPLACE_MALLOC']:
'malloc_decls.h',
'replace_malloc.h',
]
CSRCS += [
'jemalloc_config.c',
'mozmemory_wrap.c',
]
if CONFIG['MOZ_JEMALLOC3']:
CSRCS += [
'mozjemalloc_compat.c',
]
if CONFIG['MOZ_REPLACE_MALLOC']:
CSRCS += [
'replace_malloc.c',
]

View File

@ -18,11 +18,11 @@ SDK_LIBRARY = $(REAL_LIBRARY)
DIST_INSTALL = 1
endif
CSRCS := $(notdir $(wildcard $(srcdir)/src/src/*.c))
DISABLED_CSRCS := $(notdir $(wildcard $(srcdir)/src/src/*.c))
# Only OSX needs the zone allocation implementation, but only if
# replace-malloc is not enabled.
ifneq ($(OS_TARGET)$(MOZ_REPLACE_MALLOC),Darwin)
CSRCS := $(filter-out zone.c,$(CSRCS))
DISABLED_CSRCS := $(filter-out zone.c,$(CSRCS))
endif
include $(topsrcdir)/config/rules.mk

View File

@ -6,3 +6,34 @@
MODULE = 'jemalloc'
CSRCS += [
'arena.c',
'atomic.c',
'base.c',
'bitmap.c',
'chunk.c',
'chunk_dss.c',
'chunk_mmap.c',
'ckh.c',
'ctl.c',
'extent.c',
'hash.c',
'huge.c',
'jemalloc.c',
'mb.c',
'mutex.c',
'prof.c',
'quarantine.c',
'rtree.c',
'stats.c',
'tcache.c',
'tsd.c',
'util.c',
]
# Only OSX needs the zone allocation implementation,
# but only if replace-malloc is not enabled.
if CONFIG['OS_TARGET'] == 'Darwin' and not CONFIG['MOZ_REPLACE_MALLOC']:
CSRCS += [
'zone.c',
]

View File

@ -11,7 +11,7 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
ifndef MOZ_JEMALLOC3
CSRCS = jemalloc.c
DISABLED_CSRCS = jemalloc.c
LIBRARY_NAME = jemalloc
FORCE_STATIC_LIB= 1

View File

@ -10,3 +10,7 @@ EXPORTS += [
'jemalloc_types.h',
]
if not CONFIG['MOZ_JEMALLOC3']:
CSRCS += [
'jemalloc.c',
]

View File

@ -17,7 +17,7 @@ DEFINES += -DMOZ_NO_MOZALLOC
VPATH += $(topsrcdir)/xpcom/base
VPATH += $(topsrcdir)/nsprpub/lib/libc/src
CSRCS += strcpy.c
DISABLED_CSRCS += strcpy.c
VPATH += $(topsrcdir)/mfbt

View File

@ -16,3 +16,6 @@ CPP_SOURCES += [
'nsStackWalk.cpp',
]
CSRCS += [
'strcpy.c',
]

View File

@ -13,6 +13,6 @@ LIBRARY_NAME = replace_malloc
FORCE_SHARED_LIB = 1
NO_DIST_INSTALL = 1
CSRCS = dummy_replace_malloc.c
DISABLED_CSRCS = dummy_replace_malloc.c
include $(topsrcdir)/config/rules.mk

View File

@ -6,3 +6,6 @@
MODULE = 'memory'
CSRCS += [
'dummy_replace_malloc.c',
]

View File

@ -22,7 +22,7 @@ endif
VPATH += $(topsrcdir)/memory/build
CSRCS = \
DISABLED_CSRCS = \
mozjemalloc_compat.c \
jemalloc_config.c \
$(NULL)
@ -34,7 +34,7 @@ WRAP_LDFLAGS = # Never wrap malloc function calls with -Wl,--wrap
# It shouldn't make much problem, as the use of fork is pretty limited on
# Android.
ifeq ($(MOZ_WIDGET_TOOLKIT),android)
CSRCS += pthread_atfork.c
DISABLED_CSRCS += pthread_atfork.c
endif
include $(topsrcdir)/config/rules.mk

View File

@ -6,3 +6,15 @@
MODULE = 'memory'
CSRCS += [
'jemalloc_config.c',
'mozjemalloc_compat.c',
]
# Android doesn't have pthread_atfork, so just implement a dummy function.
# It shouldn't make much problem, as the use of fork is pretty limited on
# Android.
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
CSRCS += [
'pthread_atfork.c',
]

View File

@ -15,6 +15,8 @@
#include ../services/manifests/AnnouncementsAndroidManifest_permissions.xml.in
#include ../services/manifests/SyncAndroidManifest_permissions.xml.in
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>

View File

@ -139,6 +139,12 @@ public class Favicons {
}
public Bitmap getFaviconFromMemCache(String pageUrl) {
// If for some reason the key is null, simply return null
// and avoid an exception on the mem cache (see bug 813546)
if (pageUrl == null) {
return null;
}
return mFaviconsCache.get(pageUrl);
}

View File

@ -49,12 +49,23 @@ import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.location.Location;
import android.location.LocationListener;
import android.net.wifi.ScanResult;
import android.net.Uri;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.PowerManager;
import android.os.StrictMode;
import android.telephony.CellLocation;
import android.telephony.NeighboringCellInfo;
import android.telephony.SignalStrength;
import android.telephony.TelephonyManager;
import android.telephony.PhoneStateListener;
import android.telephony.SignalStrength;
import android.telephony.gsm.GsmCellLocation;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Base64;
@ -84,15 +95,26 @@ import android.widget.TextView;
import android.widget.Toast;
import java.io.BufferedReader;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@ -133,6 +155,8 @@ abstract public class GeckoApp
static public final int RESTORE_OOM = 1;
static public final int RESTORE_CRASH = 2;
static private final String LOCATION_URL = "https://location.services.mozilla.com/v1/submit";
protected RelativeLayout mMainLayout;
protected RelativeLayout mGeckoLayout;
public View getView() { return mGeckoLayout; }
@ -171,6 +195,10 @@ abstract public class GeckoApp
private volatile BrowserHealthRecorder mHealthRecorder = null;
private int mSignalStrenth;
private PhoneStateListener mPhoneStateListener = null;
private boolean mShouldReportGeoData = false;
abstract public int getLayout();
abstract public boolean hasTabsSideBar();
abstract protected String getDefaultProfileName();
@ -202,6 +230,15 @@ abstract public class GeckoApp
}
public LocationListener getLocationListener() {
if (mShouldReportGeoData && mPhoneStateListener == null) {
mPhoneStateListener = new PhoneStateListener() {
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
setCurrentSignalStrenth(signalStrength);
}
};
TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
}
return this;
}
@ -1414,6 +1451,15 @@ abstract public class GeckoApp
}
});
PrefsHelper.getPref("app.geo.reportdata", new PrefsHelper.PrefHandlerBase() {
@Override public void prefValue(String pref, int value) {
if (value == 1)
mShouldReportGeoData = true;
else
mShouldReportGeoData = false;
}
});
// End of the startup of our Java App
mJavaUiStartupTimer.stop();
@ -2152,6 +2198,186 @@ abstract public class GeckoApp
public void onLocationChanged(Location location) {
// No logging here: user-identifying information.
GeckoAppShell.sendEventToGecko(GeckoEvent.createLocationEvent(location));
if (mShouldReportGeoData)
collectAndReportLocInfo(location);
}
public void setCurrentSignalStrenth(SignalStrength ss) {
if (ss.isGsm())
mSignalStrenth = ss.getGsmSignalStrength();
}
private int getCellInfo(JSONArray cellInfo) {
TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
if (tm == null)
return TelephonyManager.PHONE_TYPE_NONE;
List<NeighboringCellInfo> cells = tm.getNeighboringCellInfo();
CellLocation cl = tm.getCellLocation();
String mcc = "", mnc = "";
if (cl instanceof GsmCellLocation) {
JSONObject obj = new JSONObject();
GsmCellLocation gcl = (GsmCellLocation)cl;
try {
obj.put("lac", gcl.getLac());
obj.put("cid", gcl.getCid());
obj.put("psc", gcl.getPsc());
switch(tm.getNetworkType()) {
case TelephonyManager.NETWORK_TYPE_GPRS:
case TelephonyManager.NETWORK_TYPE_EDGE:
obj.put("radio", "gsm");
break;
case TelephonyManager.NETWORK_TYPE_UMTS:
case TelephonyManager.NETWORK_TYPE_HSDPA:
case TelephonyManager.NETWORK_TYPE_HSUPA:
case TelephonyManager.NETWORK_TYPE_HSPA:
case TelephonyManager.NETWORK_TYPE_HSPAP:
obj.put("radio", "umts");
break;
}
String mcc_mnc = tm.getNetworkOperator();
mcc = mcc_mnc.substring(0, 3);
mnc = mcc_mnc.substring(3);
obj.put("mcc", mcc);
obj.put("mnc", mnc);
obj.put("asu", mSignalStrenth);
} catch(JSONException jsonex) {}
cellInfo.put(obj);
}
if (cells != null) {
for (NeighboringCellInfo nci : cells) {
try {
JSONObject obj = new JSONObject();
obj.put("lac", nci.getLac());
obj.put("cid", nci.getCid());
obj.put("psc", nci.getPsc());
obj.put("mcc", mcc);
obj.put("mnc", mnc);
int dbm;
switch(nci.getNetworkType()) {
case TelephonyManager.NETWORK_TYPE_GPRS:
case TelephonyManager.NETWORK_TYPE_EDGE:
obj.put("radio", "gsm");
break;
case TelephonyManager.NETWORK_TYPE_UMTS:
case TelephonyManager.NETWORK_TYPE_HSDPA:
case TelephonyManager.NETWORK_TYPE_HSUPA:
case TelephonyManager.NETWORK_TYPE_HSPA:
case TelephonyManager.NETWORK_TYPE_HSPAP:
obj.put("radio", "umts");
break;
}
obj.put("asu", nci.getRssi());
cellInfo.put(obj);
} catch(JSONException jsonex) {}
}
}
return tm.getPhoneType();
}
// copied from http://code.google.com/p/sensor-data-collection-library/source/browse/src/main/java/TextFileSensorLog.java#223,
// which is apache licensed
private static final Set<Character> AD_HOC_HEX_VALUES =
new HashSet<Character>(Arrays.asList('2','6', 'a', 'e', 'A', 'E'));
private static final String OPTOUT_SSID_SUFFIX = "_nomap";
private static boolean shouldLog(final ScanResult sr) {
// We filter out any ad-hoc devices. Ad-hoc devices are identified by having a
// 2,6,a or e in the second nybble.
// See http://en.wikipedia.org/wiki/MAC_address -- ad hoc networks
// have the last two bits of the second nybble set to 10.
// Only apply this test if we have exactly 17 character long BSSID which should
// be the case.
final char secondNybble = sr.BSSID.length() == 17 ? sr.BSSID.charAt(1) : ' ';
if(AD_HOC_HEX_VALUES.contains(secondNybble)) {
return false;
} else if (sr.SSID != null && sr.SSID.endsWith(OPTOUT_SSID_SUFFIX)) {
return false;
} else {
return true;
}
}
private void collectAndReportLocInfo(Location location) {
final JSONObject locInfo = new JSONObject();
WifiManager wm = (WifiManager)getSystemService(Context.WIFI_SERVICE);
wm.startScan();
try {
JSONArray cellInfo = new JSONArray();
int radioType = getCellInfo(cellInfo);
if (radioType == TelephonyManager.PHONE_TYPE_GSM)
locInfo.put("radio", "gsm");
else
return; // we don't care about other radio types for now
locInfo.put("lon", location.getLongitude());
locInfo.put("lat", location.getLatitude());
locInfo.put("accuracy", (int)location.getAccuracy());
locInfo.put("altitude", (int)location.getAltitude());
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'");
locInfo.put("time", df.format(new Date(location.getTime())));
locInfo.put("cell", cellInfo);
MessageDigest digest = MessageDigest.getInstance("SHA-1");
JSONArray wifiInfo = new JSONArray();
List<ScanResult> aps = wm.getScanResults();
for (ScanResult ap : aps) {
if (!shouldLog(ap))
continue;
StringBuilder sb = new StringBuilder();
try {
byte[] result = digest.digest((ap.BSSID + ap.SSID).getBytes("UTF-8"));
for (byte b : result) sb.append(String.format("%02X", b));
JSONObject obj = new JSONObject();
obj.put("key", sb.toString());
obj.put("frequency", ap.frequency);
obj.put("signal", ap.level);
wifiInfo.put(obj);
} catch (UnsupportedEncodingException uee) {
Log.w(LOGTAG, "can't encode the key", uee);
}
}
locInfo.put("wifi", wifiInfo);
} catch (JSONException jsonex) {
Log.w(LOGTAG, "json exception", jsonex);
} catch (NoSuchAlgorithmException nsae) {
Log.w(LOGTAG, "can't creat a SHA1", nsae);
}
ThreadUtils.postToBackgroundThread(new Runnable() {
public void run() {
try {
URL url = new URL(LOCATION_URL);
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
try {
urlConnection.setDoOutput(true);
JSONArray batch = new JSONArray();
batch.put(locInfo);
JSONObject wrapper = new JSONObject();
wrapper.put("items", batch);
byte[] bytes = wrapper.toString().getBytes();
urlConnection.setFixedLengthStreamingMode(bytes.length);
OutputStream out = new BufferedOutputStream(urlConnection.getOutputStream());
out.write(bytes);
out.flush();
} catch (JSONException jsonex) {
Log.e(LOGTAG, "error wrapping data as a batch", jsonex);
} catch (IOException ioex) {
Log.e(LOGTAG, "error submitting data", ioex);
} finally {
urlConnection.disconnect();
}
} catch (IOException ioex) {
Log.e(LOGTAG, "error submitting data", ioex);
}
}
});
}
@Override

View File

@ -29,8 +29,12 @@
#include "nsICrashReporter.h"
#endif
#include "nsIConsoleService.h"
// 1 MB should be enough for everyone.
static const uint32_t MAX_PREF_LENGTH = 1 * 1024 * 1024;
// Actually, 4kb should be enough for everyone.
static const uint32_t MAX_ADVISABLE_PREF_LENGTH = 4 * 1024;
// Definitions
struct EnumerateData {
@ -168,6 +172,16 @@ NS_IMETHODIMP nsPrefBranch::GetCharPref(const char *aPrefName, char **_retval)
}
NS_IMETHODIMP nsPrefBranch::SetCharPref(const char *aPrefName, const char *aValue)
{
nsresult rv = CheckSanityOfStringLength(aPrefName, aValue);
if (NS_FAILED(rv)) {
return rv;
}
return SetCharPrefInternal(aPrefName, aValue);
}
nsresult nsPrefBranch::SetCharPrefInternal(const char *aPrefName, const char *aValue)
{
if (GetContentChild()) {
NS_ERROR("cannot set pref from content process");
@ -342,6 +356,40 @@ NS_IMETHODIMP nsPrefBranch::GetComplexValue(const char *aPrefName, const nsIID &
return NS_NOINTERFACE;
}
nsresult nsPrefBranch::CheckSanityOfStringLength(const char* aPrefName, const char* aValue) {
if (!aValue) {
return NS_OK;
}
return CheckSanityOfStringLength(aPrefName, strlen(aValue));
}
nsresult nsPrefBranch::CheckSanityOfStringLength(const char* aPrefName, const nsAString& aValue) {
return CheckSanityOfStringLength(aPrefName, aValue.Length());
}
nsresult nsPrefBranch::CheckSanityOfStringLength(const char* aPrefName, const uint32_t aLength) {
if (aLength > MAX_PREF_LENGTH) {
return NS_ERROR_OUT_OF_MEMORY;
}
if (aLength <= MAX_ADVISABLE_PREF_LENGTH) {
return NS_OK;
}
nsresult rv;
nsCOMPtr<nsIConsoleService> console = do_GetService("@mozilla.org/consoleservice;1", &rv);
if (NS_FAILED(rv)) {
return rv;
}
nsAutoCString message(nsPrintfCString("Warning: attempting to write %d bytes to preference %s. This is bad for general performance and memory usage. Such an amount of data should rather be written to an external file.",
aLength,
aPrefName));
rv = console->LogStringMessage(NS_ConvertUTF8toUTF16(message).get());
if (NS_FAILED(rv)) {
return rv;
}
return NS_OK;
}
NS_IMETHODIMP nsPrefBranch::SetComplexValue(const char *aPrefName, const nsIID & aType, nsISupports *aValue)
{
if (GetContentChild()) {
@ -362,7 +410,7 @@ NS_IMETHODIMP nsPrefBranch::SetComplexValue(const char *aPrefName, const nsIID &
rv = file->GetPersistentDescriptor(descriptorString);
if (NS_SUCCEEDED(rv)) {
rv = SetCharPref(aPrefName, descriptorString.get());
rv = SetCharPrefInternal(aPrefName, descriptorString.get());
}
return rv;
}
@ -397,7 +445,7 @@ NS_IMETHODIMP nsPrefBranch::SetComplexValue(const char *aPrefName, const nsIID &
descriptorString.Append(relativeToKey);
descriptorString.Append(']');
descriptorString.Append(relDescriptor);
return SetCharPref(aPrefName, descriptorString.get());
return SetCharPrefInternal(aPrefName, descriptorString.get());
}
if (aType.Equals(NS_GET_IID(nsISupportsString))) {
@ -408,10 +456,12 @@ NS_IMETHODIMP nsPrefBranch::SetComplexValue(const char *aPrefName, const nsIID &
rv = theString->GetData(wideString);
if (NS_SUCCEEDED(rv)) {
if (wideString.Length() > MAX_PREF_LENGTH) {
return NS_ERROR_OUT_OF_MEMORY;
// Check sanity of string length before any lengthy conversion
rv = CheckSanityOfStringLength(aPrefName, wideString);
if (NS_FAILED(rv)) {
return rv;
}
rv = SetCharPref(aPrefName, NS_ConvertUTF16toUTF8(wideString).get());
rv = SetCharPrefInternal(aPrefName, NS_ConvertUTF16toUTF8(wideString).get());
}
}
return rv;
@ -425,10 +475,12 @@ NS_IMETHODIMP nsPrefBranch::SetComplexValue(const char *aPrefName, const nsIID &
rv = theString->GetData(getter_Copies(wideString));
if (NS_SUCCEEDED(rv)) {
if (wideString.Length() > MAX_PREF_LENGTH) {
return NS_ERROR_OUT_OF_MEMORY;
// Check sanity of string length before any lengthy conversion
rv = CheckSanityOfStringLength(aPrefName, wideString);
if (NS_FAILED(rv)) {
return rv;
}
rv = SetCharPref(aPrefName, NS_ConvertUTF16toUTF8(wideString).get());
rv = SetCharPrefInternal(aPrefName, NS_ConvertUTF16toUTF8(wideString).get());
}
}
return rv;

View File

@ -194,6 +194,12 @@ protected:
{ }
nsresult GetDefaultFromPropertiesFile(const char *aPrefName, PRUnichar **return_buf);
// As SetCharPref, but without any check on the length of |aValue|
nsresult SetCharPrefInternal(const char *aPrefName, const char *aValue);
// Reject strings that are more than 1Mb, warn if strings are more than 16kb
nsresult CheckSanityOfStringLength(const char* aPrefName, const nsAString& aValue);
nsresult CheckSanityOfStringLength(const char* aPrefName, const char* aValue);
nsresult CheckSanityOfStringLength(const char* aPrefName, const uint32_t aLength);
void RemoveExpiredCallback(PrefCallback *aCallback);
const char *getPrefName(const char *aPrefName);
void freeObserverList(void);

View File

@ -7,6 +7,7 @@ const NS_APP_USER_PROFILE_50_DIR = "ProfD";
const Ci = Components.interfaces;
const Cc = Components.classes;
const Cr = Components.results;
const Cu = Components.utils;
function do_check_throws(f, result, stack)
{

View File

@ -0,0 +1,89 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js");
let cs = Cc["@mozilla.org/consoleservice;1"].
getService(Ci.nsIConsoleService);
let ps = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefService);
function makeBuffer(length) {
let string = "x";
while (string.length < length) {
string = string + string;
}
if (string.length > length) {
string = string.substring(length - string.length);
}
return string;
}
/**
* @resolves |true| if execution proceeded without warning,
* |false| if there was a warning.
*/
function checkWarning(pref, buffer) {
let deferred = Promise.defer();
let complete = false;
let listener = {
observe: function(event) {
let message = event.message;
if (!(message.startsWith("Warning: attempting to write")
&& message.contains(pref))) {
return;
}
if (complete) {
return;
}
complete = true;
do_print("Warning while setting " + pref);
cs.unregisterListener(listener);
deferred.resolve(true);
}
};
do_timeout(1000, function() {
if (complete) {
return;
}
complete = true;
do_print("No warning while setting " + pref);
cs.unregisterListener(listener);
deferred.resolve(false);
});
cs.registerListener(listener);
ps.setCharPref(pref, buffer);
return deferred.promise;
}
function run_test() {
run_next_test();
}
add_task(function() {
// Very large change, should fail
try {
ps.setCharPref("string.fail", makeBuffer(16 * 1024 * 1024));
do_print("Writing to string.fail should have failed");
do_check_true(false); // We should have failed
} catch (ex if ex.result == Cr.NS_ERROR_OUT_OF_MEMORY) {
do_print("Writing to string.fail failed for the right reasons");
do_check_true(true); // Failed for the right reason
} catch (ex) {
do_print("Writing to string.fail failed for bad reasons");
do_check_true(false); // Failed for the wrong reason
}
// Simple change, shouldn't cause a warning
do_print("Checking that a simple change doesn't cause a warning");
let buf = makeBuffer(100);
let warned = yield checkWarning("string.accept", buf);
do_check_false(warned);
// Large change, should cause a warning
do_print("Checking that a large change causes a warning");
buf = makeBuffer(32 * 1024);
warned = yield checkWarning("string.warn", buf);
do_check_true(warned);
});

View File

@ -2,6 +2,7 @@
head = head_libPrefs.js
tail =
[test_warnings.js]
[test_bug345529.js]
[test_bug506224.js]
[test_bug577950.js]

View File

@ -17,6 +17,8 @@ const CU = Components.utils;
CU.import("resource://tps/logger.jsm");
CU.import("resource://gre/modules/Services.jsm");
CU.import("resource://gre/modules/PlacesUtils.jsm");
Cu.import("resource://gre/modules/BookmarkJSONUtils.jsm");
Cu.import("resource://gre/modules/Task.jsm");
CU.import("resource://services-common/async.js");
var DumpBookmarks = function TPS_Bookmarks__DumpBookmarks() {
@ -33,9 +35,14 @@ var DumpBookmarks = function TPS_Bookmarks__DumpBookmarks() {
query.setFolders([PlacesUtils.placesRootId], 1);
let root = PlacesUtils.history.executeQuery(query, options).root;
root.containerOpen = true;
PlacesUtils.serializeNodeAsJSONToOutputStream(root, writer, true, false);
let cb = Async.makeSpinningCallback();
Task.spawn(function() {
yield BookmarkJSONUtils.serializeNodeAsJSONToOutputStream(root, writer, true, false);
let value = JSON.parse(writer.value);
Logger.logInfo("dumping bookmarks\n\n" + JSON.stringify(value, null, ' ') + "\n\n");
cb();
});
cb.wait();
};
/**

View File

@ -94,6 +94,42 @@ this.BookmarkJSONUtils = Object.freeze({
}
}, Ci.nsIThread.DISPATCH_NORMAL);
return deferred.promise;
},
/**
* Serializes the given node (and all its descendents) as JSON
* and writes the serialization to the given output stream.
*
* @param aNode
* An nsINavHistoryResultNode
* @param aStream
* An nsIOutputStream. NOTE: it only uses the write(str, len)
* method of nsIOutputStream. The caller is responsible for
* closing the stream.
* @param aIsUICommand
* Boolean - If true, modifies serialization so that each node self-contained.
* For Example, tags are serialized inline with each bookmark.
* @param aResolveShortcuts
* Converts folder shortcuts into actual folders.
* @param aExcludeItems
* An array of item ids that should not be written to the backup.
* @return {Promise}
* @resolves When node have been serialized and wrote to output stream.
* @rejects JavaScript exception.
*/
serializeNodeAsJSONToOutputStream: function BJU_serializeNodeAsJSONToOutputStream(
aNode, aStream, aIsUICommand, aResolveShortcuts, aExcludeItems) {
let deferred = Promise.defer();
Services.tm.mainThread.dispatch(function() {
try {
BookmarkNode.serializeAsJSONToOutputStream(
aNode, aStream, aIsUICommand, aResolveShortcuts, aExcludeItems);
deferred.resolve();
} catch (ex) {
deferred.reject(ex);
}
}, Ci.nsIThread.DISPATCH_NORMAL);
return deferred.promise;
}
});

View File

@ -559,7 +559,7 @@ this.PlacesUtils = {
};
let [node, shouldClose] = convertNode(aNode);
this.serializeNodeAsJSONToOutputStream(node, writer, true, aForceCopy);
this._serializeNodeAsJSONToOutputStream(node, writer, true, aForceCopy);
if (shouldClose)
node.containerOpen = false;
@ -1326,8 +1326,8 @@ this.PlacesUtils = {
* @param aExcludeItems
* An array of item ids that should not be written to the backup.
*/
serializeNodeAsJSONToOutputStream:
function PU_serializeNodeAsJSONToOutputStream(aNode, aStream, aIsUICommand,
_serializeNodeAsJSONToOutputStream:
function PU__serializeNodeAsJSONToOutputStream(aNode, aStream, aIsUICommand,
aResolveShortcuts,
aExcludeItems) {
function addGenericProperties(aPlacesNode, aJSNode) {
@ -1520,6 +1520,36 @@ this.PlacesUtils = {
}
},
/**
* Serializes the given node (and all its descendents) as JSON
* and writes the serialization to the given output stream.
*
* @param aNode
* An nsINavHistoryResultNode
* @param aStream
* An nsIOutputStream. NOTE: it only uses the write(str, len)
* method of nsIOutputStream. The caller is responsible for
* closing the stream.
* @param aIsUICommand
* Boolean - If true, modifies serialization so that each node self-contained.
* For Example, tags are serialized inline with each bookmark.
* @param aResolveShortcuts
* Converts folder shortcuts into actual folders.
* @param aExcludeItems
* An array of item ids that should not be written to the backup.
*/
serializeNodeAsJSONToOutputStream:
function PU_serializeNodeAsJSONToOutputStream(aNode, aStream, aIsUICommand,
aResolveShortcuts,
aExcludeItems) {
Deprecated.warning(
"serializeNodeAsJSONToOutputStream is deprecated and will be removed in a future version",
"https://bugzilla.mozilla.org/show_bug.cgi?id=854761");
this._serializeNodeAsJSONToOutputStream(aNode, aStream, aIsUICommand,
aResolveShortcuts, aExcludeItems);
},
/**
* Restores bookmarks and tags from a JSON file.
* WARNING: This method *removes* any bookmarks in the collection before

View File

@ -83,14 +83,14 @@ add_task(function test_force_copy() {
this._str += aData;
}
};
PlacesUtils.serializeNodeAsJSONToOutputStream(queryNode, stream, false, true);
Cu.import("resource://gre/modules/BookmarkJSONUtils.jsm");
yield BookmarkJSONUtils.serializeNodeAsJSONToOutputStream(queryNode, stream, false, true);
LOG("SERIALIZED: " + stream._str);
PlacesUtils.bookmarks.removeItem(queryId);
// import
Cu.import("resource://gre/modules/BookmarkJSONUtils.jsm");
yield BookmarkJSONUtils.importJSONNode(stream._str, PlacesUtils.toolbarFolderId, -1);
// query for node

View File

@ -3078,7 +3078,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType widget, cairo_t *cr,
flags, direction);
break;
case MOZ_GTK_TREE_HEADER_SORTARROW:
return moz_gtk_tree_header_sort_arrow_paint(cr, rect, cliprect,
return moz_gtk_tree_header_sort_arrow_paint(cr, rect,
state,
(GtkArrowType) flags,
direction);
@ -3101,7 +3101,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType widget, cairo_t *cr,
(gboolean) flags, direction);
break;
case MOZ_GTK_DROPDOWN_ARROW:
return moz_gtk_combo_box_entry_button_paint(cr, rect, cliprect,
return moz_gtk_combo_box_entry_button_paint(cr, rect,
state, flags, direction);
break;
case MOZ_GTK_DROPDOWN_ENTRY:
@ -3125,7 +3125,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType widget, cairo_t *cr,
return moz_gtk_toolbar_paint(cr, rect, direction);
break;
case MOZ_GTK_TOOLBAR_SEPARATOR:
return moz_gtk_toolbar_separator_paint(cr, rect, cliprect,
return moz_gtk_toolbar_separator_paint(cr, rect,
direction);
break;
case MOZ_GTK_TOOLTIP:
@ -3144,7 +3144,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType widget, cairo_t *cr,
case MOZ_GTK_PROGRESS_CHUNK:
case MOZ_GTK_PROGRESS_CHUNK_INDETERMINATE:
case MOZ_GTK_PROGRESS_CHUNK_VERTICAL_INDETERMINATE:
return moz_gtk_progress_chunk_paint(cr, rect, cliprect,
return moz_gtk_progress_chunk_paint(cr, rect,
direction, widget);
break;
case MOZ_GTK_TAB:
@ -3165,7 +3165,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType widget, cairo_t *cr,
return moz_gtk_menu_popup_paint(cr, rect, direction);
break;
case MOZ_GTK_MENUSEPARATOR:
return moz_gtk_menu_separator_paint(cr, rect, cliprect,
return moz_gtk_menu_separator_paint(cr, rect,
direction);
break;
case MOZ_GTK_MENUITEM:

View File

@ -990,7 +990,7 @@ nsLookAndFeel::Init()
g_object_unref(menu);
#else
GdkRGBA color;
GtkStyleContext *style
GtkStyleContext *style;
GtkWidgetPath *path = gtk_widget_path_new();
gtk_widget_path_append_type(path, GTK_TYPE_WINDOW);
@ -1016,7 +1016,7 @@ nsLookAndFeel::Init()
GtkWidget *textView = gtk_text_view_new();
style = gtk_widget_get_style_context(textView);
gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
sMozFieldBackground = GDK_RGBA_TO_NS_RGB(color);
sMozFieldBackground = GDK_RGBA_TO_NS_RGBA(color);
gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
sMozFieldText = GDK_RGBA_TO_NS_RGBA(color);
gtk_widget_destroy(textView);

View File

@ -3713,8 +3713,10 @@ nsWindow::Create(nsIWidget *aParent,
}
if (eventWidget) {
#if defined(MOZ_WIDGET_GTK2)
// Don't let GTK mess with the shapes of our GdkWindows
GTK_PRIVATE_SET_FLAG(eventWidget, GTK_HAS_SHAPE_MASK);
#endif
// These events are sent to the owning widget of the relevant window
// and propagate up to the first widget that handles the events, so we

View File

@ -9,6 +9,9 @@
#define __GTK_XTBIN_H__
#include <gtk/gtk.h>
#if (MOZ_WIDGET_GTK == 3)
#include <gtk/gtkx.h>
#endif
#include <X11/Intrinsic.h>
#include <X11/Xutil.h>
#include <X11/Xlib.h>

View File

@ -4,7 +4,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#if defined(MOZ_WIDGET_GTK2) || defined(MOZ_WIDGET_GTK3)
#if defined(MOZ_WIDGET_GTK)
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#elif defined(MOZ_WIDGET_QT)
@ -57,7 +57,7 @@ nsShmImage::Create(const gfxIntSize& aSize,
shm->mInfo.readOnly = False;
int xerror = 0;
#if defined(MOZ_WIDGET_GTK2) || defined(MOZ_WIDGET_GTK3)
#if defined(MOZ_WIDGET_GTK)
gdk_error_trap_push();
Status attachOk = XShmAttach(dpy, &shm->mInfo);
XSync(dpy, False);
@ -107,7 +107,7 @@ nsShmImage::AsSurface()
).forget();
}
#if defined(MOZ_WIDGET_GTK2)
#if (MOZ_WIDGET_GTK == 2)
void
nsShmImage::Put(GdkWindow* aWindow, GdkRectangle* aRects, GdkRectangle* aEnd)
{
@ -137,7 +137,7 @@ nsShmImage::Put(GdkWindow* aWindow, GdkRectangle* aRects, GdkRectangle* aEnd)
XSync(dpy, False);
}
#elif defined(MOZ_WIDGET_GTK3)
#elif (MOZ_WIDGET_GTK == 3)
void
nsShmImage::Put(GdkWindow* aWindow, cairo_rectangle_list_t* aRects)
{

View File

@ -23,7 +23,7 @@
#include <X11/Xutil.h>
#include <X11/extensions/XShm.h>
#if defined(MOZ_WIDGET_GTK2) || defined(MOZ_WIDGET_GTK3)
#if defined(MOZ_WIDGET_GTK)
#define DISPLAY gdk_x11_get_default_xdisplay
#elif defined(MOZ_WIDGET_QT)
#define DISPLAY mozilla::DefaultXDisplay
@ -59,9 +59,9 @@ public:
already_AddRefed<gfxASurface> AsSurface();
#if defined(MOZ_WIDGET_GTK2)
#if (MOZ_WIDGET_GTK == 2)
void Put(GdkWindow* aWindow, GdkRectangle* aRects, GdkRectangle* aEnd);
#elif defined(MOZ_WIDGET_GTK3)
#elif (MOZ_WIDGET_GTK == 3)
void Put(GdkWindow* aWindow, cairo_rectangle_list_t* aRects);
#elif defined(MOZ_WIDGET_QT)
void Put(QWidget* aWindow, QRect& aRect);