Merge mozilla-central to fx-team

This commit is contained in:
Carsten "Tomcat" Book 2013-10-15 10:49:42 +02:00
commit a5236dd3f3
59 changed files with 684 additions and 486 deletions

View File

@ -1,4 +1,4 @@
{ {
"revision": "4a8dcbcad9433e7cb0b619d80b041219e5946130", "revision": "8c2ad9ad3192687c13efe1eb0cd986d6214b4b5d",
"repo_path": "/integration/gaia-central" "repo_path": "/integration/gaia-central"
} }

View File

@ -3265,10 +3265,22 @@ CanvasRenderingContext2D::DrawWindow(nsIDOMWindow* window, double x,
double sh = matrix._22 * h; double sh = matrix._22 * h;
nsRefPtr<gfxContext> thebes; nsRefPtr<gfxContext> thebes;
nsRefPtr<gfxASurface> drawSurf; nsRefPtr<gfxASurface> drawSurf;
RefPtr<DrawTarget> drawDT;
if (gfxPlatform::GetPlatform()->SupportsAzureContentForDrawTarget(mTarget)) { if (gfxPlatform::GetPlatform()->SupportsAzureContentForDrawTarget(mTarget)) {
thebes = new gfxContext(mTarget); thebes = new gfxContext(mTarget);
thebes->SetMatrix(gfxMatrix(matrix._11, matrix._12, matrix._21, thebes->SetMatrix(gfxMatrix(matrix._11, matrix._12, matrix._21,
matrix._22, matrix._31, matrix._32)); matrix._22, matrix._31, matrix._32));
} else if (gfxPlatform::GetPlatform()->SupportsAzureContent()) {
drawDT =
gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(IntSize(ceil(sw), ceil(sh)),
FORMAT_B8G8R8A8);
if (!drawDT) {
error.Throw(NS_ERROR_FAILURE);
return;
}
thebes = new gfxContext(drawDT);
thebes->Scale(matrix._11, matrix._22);
} else { } else {
drawSurf = drawSurf =
gfxPlatform::GetPlatform()->CreateOffscreenSurface(gfxIntSize(ceil(sw), ceil(sh)), gfxPlatform::GetPlatform()->CreateOffscreenSurface(gfxIntSize(ceil(sw), ceil(sh)),
@ -3278,14 +3290,15 @@ CanvasRenderingContext2D::DrawWindow(nsIDOMWindow* window, double x,
return; return;
} }
drawSurf->SetDeviceOffset(gfxPoint(-floor(x), -floor(y)));
thebes = new gfxContext(drawSurf); thebes = new gfxContext(drawSurf);
thebes->Translate(gfxPoint(floor(x), floor(y)));
thebes->Scale(matrix._11, matrix._22); thebes->Scale(matrix._11, matrix._22);
} }
nsCOMPtr<nsIPresShell> shell = presContext->PresShell(); nsCOMPtr<nsIPresShell> shell = presContext->PresShell();
unused << shell->RenderDocument(r, renderDocFlags, backgroundColor, thebes); unused << shell->RenderDocument(r, renderDocFlags, backgroundColor, thebes);
if (drawSurf || drawDT) {
RefPtr<SourceSurface> source;
if (drawSurf) { if (drawSurf) {
gfxIntSize size = drawSurf->GetSize(); gfxIntSize size = drawSurf->GetSize();
@ -3296,14 +3309,25 @@ CanvasRenderingContext2D::DrawWindow(nsIDOMWindow* window, double x,
return; return;
} }
RefPtr<SourceSurface> data = source =
mTarget->CreateSourceSurfaceFromData(img->Data(), mTarget->CreateSourceSurfaceFromData(img->Data(),
IntSize(size.width, size.height), IntSize(size.width, size.height),
img->Stride(), img->Stride(),
FORMAT_B8G8R8A8); FORMAT_B8G8R8A8);
} else {
RefPtr<SourceSurface> snapshot = drawDT->Snapshot();
RefPtr<DataSourceSurface> data = snapshot->GetDataSurface();
source =
mTarget->CreateSourceSurfaceFromData(data->GetData(),
data->GetSize(),
data->Stride(),
data->GetFormat());
}
mgfx::Rect destRect(0, 0, w, h); mgfx::Rect destRect(0, 0, w, h);
mgfx::Rect sourceRect(0, 0, sw, sh); mgfx::Rect sourceRect(0, 0, sw, sh);
mTarget->DrawSurface(data, destRect, sourceRect, mTarget->DrawSurface(source, destRect, sourceRect,
DrawSurfaceOptions(mgfx::FILTER_POINT), DrawSurfaceOptions(mgfx::FILTER_POINT),
DrawOptions(1.0f, OP_SOURCE, AA_NONE)); DrawOptions(1.0f, OP_SOURCE, AA_NONE));
mTarget->Flush(); mTarget->Flush();

View File

@ -528,7 +528,7 @@ public:
mFileList.AppendElement(domFile); mFileList.AppendElement(domFile);
mFileListLength = mFileList.Length(); mFileListLength = mFileList.Length();
if (mCanceled) { if (mCanceled) {
NS_ASSERTION(!mInput, "This is bad - how did this happen?"); MOZ_ASSERT(!mInput, "This is bad - how did this happen?");
// There's no point dispatching to the main thread (that doesn't // There's no point dispatching to the main thread (that doesn't
// guarantee that we'll be destroyed there). // guarantee that we'll be destroyed there).
return NS_OK; return NS_OK;

View File

@ -70,16 +70,13 @@ public:
, mDetune(0.f) , mDetune(0.f)
, mType(OscillatorType::Sine) , mType(OscillatorType::Sine)
, mPhase(0.) , mPhase(0.)
, mFinalFrequency(0.0) // mSquare, mTriangle, and mSaw are not used for default type "sine".
, mNumberOfHarmonics(0) // They are initialized if and when switching to the OscillatorTypes that
, mSignalPeriod(0.0) // use them.
, mAmplitudeAtZero(0.0) // mFinalFrequency, mNumberOfHarmonics, mSignalPeriod, mAmplitudeAtZero,
, mPhaseIncrement(0.0) // mPhaseIncrement, and mPhaseWrap are initialized in
, mSquare(0.0) // UpdateParametersIfNeeded() when mRecomputeParameters is set.
, mTriangle(0.0) , mRecomputeParameters(true)
, mSaw(0.0)
, mPhaseWrap(0.0)
, mRecomputeFrequency(true)
, mCustomLength(0) , mCustomLength(0)
{ {
} }
@ -101,7 +98,7 @@ public:
const AudioParamTimeline& aValue, const AudioParamTimeline& aValue,
TrackRate aSampleRate) MOZ_OVERRIDE TrackRate aSampleRate) MOZ_OVERRIDE
{ {
mRecomputeFrequency = true; mRecomputeParameters = true;
switch (aIndex) { switch (aIndex) {
case FREQUENCY: case FREQUENCY:
MOZ_ASSERT(mSource && mDestination); MOZ_ASSERT(mSource && mDestination);
@ -139,6 +136,7 @@ public:
mCustomLength = 0; mCustomLength = 0;
mCustom = nullptr; mCustom = nullptr;
mPeriodicWave = nullptr; mPeriodicWave = nullptr;
mRecomputeParameters = true;
} }
// Update BLIT integrators with the new initial conditions. // Update BLIT integrators with the new initial conditions.
switch (mType) { switch (mType) {
@ -208,7 +206,7 @@ public:
return mType == OscillatorType::Square || mType == OscillatorType::Triangle; return mType == OscillatorType::Square || mType == OscillatorType::Triangle;
} }
void UpdateFrequencyIfNeeded(TrackTicks ticks, size_t count) void UpdateParametersIfNeeded(TrackTicks ticks, size_t count)
{ {
double frequency, detune; double frequency, detune;
@ -217,7 +215,7 @@ public:
// Shortcut if frequency-related AudioParam are not automated, and we // Shortcut if frequency-related AudioParam are not automated, and we
// already have computed the frequency information and related parameters. // already have computed the frequency information and related parameters.
if (simpleFrequency && simpleDetune && !mRecomputeFrequency) { if (simpleFrequency && simpleDetune && !mRecomputeParameters) {
return; return;
} }
@ -233,7 +231,7 @@ public:
} }
mFinalFrequency = frequency * pow(2., detune / 1200.); mFinalFrequency = frequency * pow(2., detune / 1200.);
mRecomputeFrequency = false; mRecomputeParameters = false;
// When using bipolar BLIT, we divide the signal period by two, because we // When using bipolar BLIT, we divide the signal period by two, because we
// are using two BLIT out of phase. // are using two BLIT out of phase.
@ -308,7 +306,7 @@ public:
void ComputeSine(float * aOutput, TrackTicks ticks, uint32_t aStart, uint32_t aEnd) void ComputeSine(float * aOutput, TrackTicks ticks, uint32_t aStart, uint32_t aEnd)
{ {
for (uint32_t i = aStart; i < aEnd; ++i) { for (uint32_t i = aStart; i < aEnd; ++i) {
UpdateFrequencyIfNeeded(ticks, i); UpdateParametersIfNeeded(ticks, i);
aOutput[i] = sin(mPhase); aOutput[i] = sin(mPhase);
@ -319,7 +317,7 @@ public:
void ComputeSquare(float * aOutput, TrackTicks ticks, uint32_t aStart, uint32_t aEnd) void ComputeSquare(float * aOutput, TrackTicks ticks, uint32_t aStart, uint32_t aEnd)
{ {
for (uint32_t i = aStart; i < aEnd; ++i) { for (uint32_t i = aStart; i < aEnd; ++i) {
UpdateFrequencyIfNeeded(ticks, i); UpdateParametersIfNeeded(ticks, i);
// Integration to get us a square. It turns out we can have a // Integration to get us a square. It turns out we can have a
// pure integrator here. // pure integrator here.
mSquare += BipolarBLIT(); mSquare += BipolarBLIT();
@ -334,7 +332,7 @@ public:
{ {
float dcoffset; float dcoffset;
for (uint32_t i = aStart; i < aEnd; ++i) { for (uint32_t i = aStart; i < aEnd; ++i) {
UpdateFrequencyIfNeeded(ticks, i); UpdateParametersIfNeeded(ticks, i);
// DC offset so the Saw does not ramp up to infinity when integrating. // DC offset so the Saw does not ramp up to infinity when integrating.
dcoffset = mFinalFrequency / mSource->SampleRate(); dcoffset = mFinalFrequency / mSource->SampleRate();
// Integrate and offset so we get mAmplitudeAtZero sawtooth. We have a // Integrate and offset so we get mAmplitudeAtZero sawtooth. We have a
@ -350,7 +348,7 @@ public:
void ComputeTriangle(float * aOutput, TrackTicks ticks, uint32_t aStart, uint32_t aEnd) void ComputeTriangle(float * aOutput, TrackTicks ticks, uint32_t aStart, uint32_t aEnd)
{ {
for (uint32_t i = aStart; i < aEnd; ++i) { for (uint32_t i = aStart; i < aEnd; ++i) {
UpdateFrequencyIfNeeded(ticks, i); UpdateParametersIfNeeded(ticks, i);
// Integrate to get a square // Integrate to get a square
mSquare += BipolarBLIT(); mSquare += BipolarBLIT();
// Leaky integrate to get a triangle. We get too much dc offset if we don't // Leaky integrate to get a triangle. We get too much dc offset if we don't
@ -380,7 +378,7 @@ public:
float rate = 1.0 / mSource->SampleRate(); float rate = 1.0 / mSource->SampleRate();
for (uint32_t i = aStart; i < aEnd; ++i) { for (uint32_t i = aStart; i < aEnd; ++i) {
UpdateFrequencyIfNeeded(ticks, i); UpdateParametersIfNeeded(ticks, i);
mPeriodicWave->waveDataForFundamentalFrequency(mFinalFrequency, mPeriodicWave->waveDataForFundamentalFrequency(mFinalFrequency,
lowerWaveData, lowerWaveData,
higherWaveData, higherWaveData,
@ -484,7 +482,7 @@ public:
float mTriangle; float mTriangle;
float mSaw; float mSaw;
float mPhaseWrap; float mPhaseWrap;
bool mRecomputeFrequency; bool mRecomputeParameters;
nsRefPtr<ThreadSharedFloatArrayBufferList> mCustom; nsRefPtr<ThreadSharedFloatArrayBufferList> mCustom;
uint32_t mCustomLength; uint32_t mCustomLength;
nsAutoPtr<WebCore::PeriodicWave> mPeriodicWave; nsAutoPtr<WebCore::PeriodicWave> mPeriodicWave;

View File

@ -97,6 +97,7 @@ support-files =
[test_oscillatorNode.html] [test_oscillatorNode.html]
[test_oscillatorNode2.html] [test_oscillatorNode2.html]
[test_oscillatorNodeStart.html] [test_oscillatorNodeStart.html]
[test_oscillatorTypeChange.html]
[test_pannerNode.html] [test_pannerNode.html]
[test_pannerNodeAbove.html] [test_pannerNodeAbove.html]
[test_pannerNodeChannelCount.html] [test_pannerNodeChannelCount.html]

View File

@ -0,0 +1,58 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test OscillatorNode type change after it has started and triangle phase</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="webaudio.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
const bufferSize = 1024;
function startTest() {
var ctx = new AudioContext();
var oscillator1 = ctx.createOscillator();
oscillator1.connect(ctx.destination);
oscillator1.start(0);
// Assuming the above Web Audio operations have already scheduled an event
// to run in stable state and start the graph thread, schedule a subsequent
// event to change the type of oscillator1.
SimpleTest.executeSoon(function() {
oscillator1.type = "triangle";
// Another triangle wave with -1 gain should cancel the first. This is
// starting at the same time as the type change, assuming that the phase
// is reset on type change. A negative frequency should achieve the same
// as the -1 gain but for bug 916285.
var oscillator2 = ctx.createOscillator();
oscillator2.type = "triangle";
oscillator2.start(0);
var processor = ctx.createScriptProcessor(bufferSize, 1, 0);
oscillator1.connect(processor);
var gain = ctx.createGain();
gain.gain.value = -1;
gain.connect(processor);
oscillator2.connect(gain);
processor.onaudioprocess = function(e) {
compareBuffers(e.inputBuffer.getChannelData(0),
new Float32Array(bufferSize));
e.target.onaudioprocess = null;
SimpleTest.finish();
}
});
};
startTest();
</script>
</pre>
</body>
</html>

View File

@ -227,7 +227,7 @@ SVGMotionSMILAnimationFunction::
bool ok = bool ok =
path.GetDistancesFromOriginToEndsOfVisibleSegments(&mPathVertices); path.GetDistancesFromOriginToEndsOfVisibleSegments(&mPathVertices);
if (ok && mPathVertices.Length()) { if (ok && mPathVertices.Length()) {
mPath = pathElem->GetFlattenedPath(gfxMatrix()); mPath = pathElem->GetPath(gfxMatrix());
} }
} }
} }
@ -239,7 +239,7 @@ SVGMotionSMILAnimationFunction::RebuildPathAndVerticesFromPathAttr()
const nsAString& pathSpec = GetAttr(nsGkAtoms::path)->GetStringValue(); const nsAString& pathSpec = GetAttr(nsGkAtoms::path)->GetStringValue();
mPathSourceType = ePathSourceType_PathAttr; mPathSourceType = ePathSourceType_PathAttr;
// Generate gfxFlattenedPath from |path| attr // Generate gfxPath from |path| attr
SVGPathData path; SVGPathData path;
nsSVGPathDataParserToInternal pathParser(&path); nsSVGPathDataParserToInternal pathParser(&path);
@ -252,7 +252,7 @@ SVGMotionSMILAnimationFunction::RebuildPathAndVerticesFromPathAttr()
return; return;
} }
mPath = path.ToFlattenedPath(gfxMatrix()); mPath = path.ToPath(gfxMatrix());
bool ok = path.GetDistancesFromOriginToEndsOfVisibleSegments(&mPathVertices); bool ok = path.GetDistancesFromOriginToEndsOfVisibleSegments(&mPathVertices);
if (!ok || !mPathVertices.Length()) { if (!ok || !mPathVertices.Length()) {
mPath = nullptr; mPath = nullptr;
@ -292,7 +292,7 @@ SVGMotionSMILAnimationFunction::
bool bool
SVGMotionSMILAnimationFunction:: SVGMotionSMILAnimationFunction::
GenerateValuesForPathAndPoints(gfxFlattenedPath* aPath, GenerateValuesForPathAndPoints(gfxPath* aPath,
bool aIsKeyPoints, bool aIsKeyPoints,
nsTArray<double>& aPointDistances, nsTArray<double>& aPointDistances,
nsTArray<nsSMILValue>& aResult) nsTArray<nsSMILValue>& aResult)

View File

@ -6,7 +6,7 @@
#ifndef MOZILLA_SVGMOTIONSMILANIMATIONFUNCTION_H_ #ifndef MOZILLA_SVGMOTIONSMILANIMATIONFUNCTION_H_
#define MOZILLA_SVGMOTIONSMILANIMATIONFUNCTION_H_ #define MOZILLA_SVGMOTIONSMILANIMATIONFUNCTION_H_
#include "gfxPath.h" // for gfxFlattenedPath #include "gfxPath.h" // for gfxPath
#include "nsAutoPtr.h" #include "nsAutoPtr.h"
#include "nsSMILAnimationFunction.h" #include "nsSMILAnimationFunction.h"
#include "nsTArray.h" #include "nsTArray.h"
@ -78,7 +78,7 @@ protected:
void RebuildPathAndVerticesFromMpathElem(dom::SVGMPathElement* aMpathElem); void RebuildPathAndVerticesFromMpathElem(dom::SVGMPathElement* aMpathElem);
void RebuildPathAndVerticesFromPathAttr(); void RebuildPathAndVerticesFromPathAttr();
void RebuildPathAndVerticesFromBasicAttrs(const nsIContent* aContextElem); void RebuildPathAndVerticesFromBasicAttrs(const nsIContent* aContextElem);
bool GenerateValuesForPathAndPoints(gfxFlattenedPath* aPath, bool GenerateValuesForPathAndPoints(gfxPath* aPath,
bool aIsKeyPoints, bool aIsKeyPoints,
nsTArray<double>& aPointDistances, nsTArray<double>& aPointDistances,
nsTArray<nsSMILValue>& aResult); nsTArray<nsSMILValue>& aResult);
@ -90,8 +90,8 @@ protected:
RotateType mRotateType; // auto, auto-reverse, or explicit. RotateType mRotateType; // auto, auto-reverse, or explicit.
float mRotateAngle; // the angle value, if explicit. float mRotateAngle; // the angle value, if explicit.
PathSourceType mPathSourceType; // source of our gfxFlattenedPath. PathSourceType mPathSourceType; // source of our gfxPath.
nsRefPtr<gfxFlattenedPath> mPath; // representation of motion path. nsRefPtr<gfxPath> mPath; // representation of motion path.
nsTArray<double> mPathVertices; // distances of vertices along path. nsTArray<double> mPathVertices; // distances of vertices along path.
bool mIsPathStale; bool mIsPathStale;

View File

@ -76,10 +76,10 @@ SVGMotionSMILPathUtils::PathGenerator::
return true; return true;
} }
already_AddRefed<gfxFlattenedPath> already_AddRefed<gfxPath>
SVGMotionSMILPathUtils::PathGenerator::GetResultingPath() SVGMotionSMILPathUtils::PathGenerator::GetResultingPath()
{ {
return mGfxContext.GetFlattenedPath(); return mGfxContext.CopyPath();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -17,7 +17,7 @@
#include "nsSMILParserUtils.h" #include "nsSMILParserUtils.h"
#include "nsTArray.h" #include "nsTArray.h"
class gfxFlattenedPath; class gfxPath;
class nsAString; class nsAString;
class nsSVGElement; class nsSVGElement;
@ -25,7 +25,7 @@ namespace mozilla {
class SVGMotionSMILPathUtils { class SVGMotionSMILPathUtils {
public: public:
// Class to assist in generating a gfxFlattenedPath, based on // Class to assist in generating a gfxPath, based on
// coordinates in the <animateMotion> from/by/to/values attributes. // coordinates in the <animateMotion> from/by/to/values attributes.
class PathGenerator { class PathGenerator {
public: public:
@ -50,7 +50,7 @@ public:
// Accessor to let clients check if we've received any commands yet. // Accessor to let clients check if we've received any commands yet.
inline bool HaveReceivedCommands() { return mHaveReceivedCommands; } inline bool HaveReceivedCommands() { return mHaveReceivedCommands; }
// Accessor to get the finalized path // Accessor to get the finalized path
already_AddRefed<gfxFlattenedPath> GetResultingPath(); already_AddRefed<gfxPath> GetResultingPath();
protected: protected:
// Helper methods // Helper methods
@ -64,7 +64,7 @@ public:
}; };
// Class to assist in passing each subcomponent of a |values| attribute to // Class to assist in passing each subcomponent of a |values| attribute to
// a PathGenerator, for generating a corresponding gfxFlattenedPath. // a PathGenerator, for generating a corresponding gfxPath.
class MotionValueParser : public nsSMILParserUtils::GenericValueParser class MotionValueParser : public nsSMILParserUtils::GenericValueParser
{ {
public: public:

View File

@ -32,7 +32,7 @@ struct TranslationParams { // Simple translation
float mY; float mY;
}; };
struct PathPointParams { // Point along a path struct PathPointParams { // Point along a path
gfxFlattenedPath* mPath; // NOTE: Refcounted; need to AddRef/Release. gfxPath* mPath; // NOTE: Refcounted; need to AddRef/Release.
float mDistToPoint; // Distance from path start to the point on the path that float mDistToPoint; // Distance from path start to the point on the path that
// we're interested in. // we're interested in.
}; };
@ -70,7 +70,7 @@ struct MotionSegment
} }
// Constructor for a point on a path (NOTE: AddRef's) // Constructor for a point on a path (NOTE: AddRef's)
MotionSegment(gfxFlattenedPath* aPath, float aDistToPoint, MotionSegment(gfxPath* aPath, float aDistToPoint,
RotateType aRotateType, float aRotateAngle) RotateType aRotateType, float aRotateAngle)
: mRotateType(aRotateType), mRotateAngle(aRotateAngle), : mRotateType(aRotateType), mRotateAngle(aRotateAngle),
mSegmentType(eSegmentType_PathPoint) mSegmentType(eSegmentType_PathPoint)
@ -228,7 +228,7 @@ SVGMotionSMILType::IsEqual(const nsSMILValue& aLeft,
// Helper method for Add & CreateMatrix // Helper method for Add & CreateMatrix
inline static void inline static void
GetAngleAndPointAtDistance(gfxFlattenedPath* aPath, float aDistance, GetAngleAndPointAtDistance(gfxPath* aPath, float aDistance,
RotateType aRotateType, RotateType aRotateType,
gfxFloat& aRotateAngle, // in & out-param. gfxFloat& aRotateAngle, // in & out-param.
gfxPoint& aPoint) // out-param. gfxPoint& aPoint) // out-param.
@ -287,7 +287,7 @@ SVGMotionSMILType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd,
"unexpected angle mismatch"); "unexpected angle mismatch");
NS_ABORT_IF_FALSE(srcParams.mPath == dstParams.mPath, NS_ABORT_IF_FALSE(srcParams.mPath == dstParams.mPath,
"unexpected path mismatch"); "unexpected path mismatch");
gfxFlattenedPath* path = srcParams.mPath; gfxPath* path = srcParams.mPath;
// Use destination to get our rotate angle. // Use destination to get our rotate angle.
gfxFloat rotateAngle = dstSeg.mRotateAngle; gfxFloat rotateAngle = dstSeg.mRotateAngle;
@ -411,7 +411,7 @@ SVGMotionSMILType::Interpolate(const nsSMILValue& aStartVal,
// NOTE: path & angle should match between start & end (since presumably // NOTE: path & angle should match between start & end (since presumably
// start & end came from the same <animateMotion> element), unless start is // start & end came from the same <animateMotion> element), unless start is
// empty. (as it would be for pure 'to' animation) // empty. (as it would be for pure 'to' animation)
gfxFlattenedPath* path = endParams.mPath; gfxPath* path = endParams.mPath;
RotateType rotateType = endSeg.mRotateType; RotateType rotateType = endSeg.mRotateType;
float rotateAngle = endSeg.mRotateAngle; float rotateAngle = endSeg.mRotateAngle;
@ -471,7 +471,7 @@ SVGMotionSMILType::CreateMatrix(const nsSMILValue& aSMILVal)
} }
/* static */ nsSMILValue /* static */ nsSMILValue
SVGMotionSMILType::ConstructSMILValue(gfxFlattenedPath* aPath, SVGMotionSMILType::ConstructSMILValue(gfxPath* aPath,
float aDist, float aDist,
RotateType aRotateType, RotateType aRotateType,
float aRotateAngle) float aRotateAngle)

View File

@ -12,7 +12,7 @@
#include "gfxMatrix.h" #include "gfxMatrix.h"
#include "nsISMILType.h" #include "nsISMILType.h"
class gfxFlattenedPath; class gfxPath;
class nsSMILValue; class nsSMILValue;
namespace mozilla { namespace mozilla {
@ -65,7 +65,7 @@ public:
// Used to generate a nsSMILValue for the point at the given distance along // Used to generate a nsSMILValue for the point at the given distance along
// the given path. // the given path.
static nsSMILValue ConstructSMILValue(gfxFlattenedPath* aPath, static nsSMILValue ConstructSMILValue(gfxPath* aPath,
float aDist, float aDist,
RotateType aRotateType, RotateType aRotateType,
float aRotateAngle); float aRotateAngle);

View File

@ -492,8 +492,8 @@ SVGPathData::ConstructPath(gfxContext *aCtx) const
MAYBE_APPROXIMATE_ZERO_LENGTH_SUBPATH_SQUARE_CAPS; MAYBE_APPROXIMATE_ZERO_LENGTH_SUBPATH_SQUARE_CAPS;
} }
already_AddRefed<gfxFlattenedPath> already_AddRefed<gfxPath>
SVGPathData::ToFlattenedPath(const gfxMatrix& aMatrix) const SVGPathData::ToPath(const gfxMatrix& aMatrix) const
{ {
nsRefPtr<gfxContext> tmpCtx = nsRefPtr<gfxContext> tmpCtx =
new gfxContext(gfxPlatform::GetPlatform()->ScreenReferenceSurface()); new gfxContext(gfxPlatform::GetPlatform()->ScreenReferenceSurface());
@ -502,7 +502,7 @@ SVGPathData::ToFlattenedPath(const gfxMatrix& aMatrix) const
ConstructPath(tmpCtx); ConstructPath(tmpCtx);
tmpCtx->IdentityMatrix(); tmpCtx->IdentityMatrix();
return tmpCtx->GetFlattenedPath(); return tmpCtx->CopyPath();
} }
static double static double

View File

@ -17,7 +17,7 @@
#include <string.h> #include <string.h>
class gfxContext; class gfxContext;
class gfxFlattenedPath; class gfxPath;
class nsSVGPathDataParserToInternal; // IWYU pragma: keep class nsSVGPathDataParserToInternal; // IWYU pragma: keep
struct gfxMatrix; struct gfxMatrix;
@ -150,8 +150,8 @@ public:
*/ */
bool GetDistancesFromOriginToEndsOfVisibleSegments(nsTArray<double> *aArray) const; bool GetDistancesFromOriginToEndsOfVisibleSegments(nsTArray<double> *aArray) const;
already_AddRefed<gfxFlattenedPath> already_AddRefed<gfxPath>
ToFlattenedPath(const gfxMatrix& aMatrix) const; ToPath(const gfxMatrix& aMatrix) const;
void ConstructPath(gfxContext *aCtx) const; void ConstructPath(gfxContext *aCtx) const;

View File

@ -53,7 +53,7 @@ SVGPathElement::PathLength()
float float
SVGPathElement::GetTotalLength(ErrorResult& rv) SVGPathElement::GetTotalLength(ErrorResult& rv)
{ {
nsRefPtr<gfxFlattenedPath> flat = GetFlattenedPath(gfxMatrix()); nsRefPtr<gfxPath> flat = GetPath(gfxMatrix());
if (!flat) { if (!flat) {
rv.Throw(NS_ERROR_FAILURE); rv.Throw(NS_ERROR_FAILURE);
@ -66,7 +66,7 @@ SVGPathElement::GetTotalLength(ErrorResult& rv)
already_AddRefed<nsISVGPoint> already_AddRefed<nsISVGPoint>
SVGPathElement::GetPointAtLength(float distance, ErrorResult& rv) SVGPathElement::GetPointAtLength(float distance, ErrorResult& rv)
{ {
nsRefPtr<gfxFlattenedPath> flat = GetFlattenedPath(gfxMatrix()); nsRefPtr<gfxPath> flat = GetPath(gfxMatrix());
if (!flat) { if (!flat) {
rv.Throw(NS_ERROR_FAILURE); rv.Throw(NS_ERROR_FAILURE);
return nullptr; return nullptr;
@ -292,10 +292,10 @@ SVGPathElement::IsAttributeMapped(const nsIAtom* name) const
SVGPathElementBase::IsAttributeMapped(name); SVGPathElementBase::IsAttributeMapped(name);
} }
already_AddRefed<gfxFlattenedPath> already_AddRefed<gfxPath>
SVGPathElement::GetFlattenedPath(const gfxMatrix &aMatrix) SVGPathElement::GetPath(const gfxMatrix &aMatrix)
{ {
return mD.GetAnimValue().ToFlattenedPath(aMatrix); return mD.GetAnimValue().ToPath(aMatrix);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -341,7 +341,7 @@ SVGPathElement::GetPathLengthScale(PathLengthScaleForType aFor)
// we need to take that into account. // we need to take that into account.
matrix = PrependLocalTransformsTo(matrix); matrix = PrependLocalTransformsTo(matrix);
} }
nsRefPtr<gfxFlattenedPath> path = GetFlattenedPath(matrix); nsRefPtr<gfxPath> path = GetPath(matrix);
if (path) { if (path) {
return path->GetLength() / authorsPathLengthEstimate; return path->GetLength() / authorsPathLengthEstimate;
} }

View File

@ -48,7 +48,7 @@ public:
virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks) MOZ_OVERRIDE; virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks) MOZ_OVERRIDE;
virtual void ConstructPath(gfxContext *aCtx) MOZ_OVERRIDE; virtual void ConstructPath(gfxContext *aCtx) MOZ_OVERRIDE;
virtual already_AddRefed<gfxFlattenedPath> GetFlattenedPath(const gfxMatrix &aMatrix) MOZ_OVERRIDE; virtual already_AddRefed<gfxPath> GetPath(const gfxMatrix &aMatrix) MOZ_OVERRIDE;
// nsIContent interface // nsIContent interface
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE; virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;

View File

@ -52,8 +52,8 @@ nsSVGPathGeometryElement::GetMarkPoints(nsTArray<nsSVGMark> *aMarks)
{ {
} }
already_AddRefed<gfxFlattenedPath> already_AddRefed<gfxPath>
nsSVGPathGeometryElement::GetFlattenedPath(const gfxMatrix &aMatrix) nsSVGPathGeometryElement::GetPath(const gfxMatrix &aMatrix)
{ {
return nullptr; return nullptr;
} }

View File

@ -8,7 +8,7 @@
#include "SVGGraphicsElement.h" #include "SVGGraphicsElement.h"
class gfxFlattenedPath; class gfxPath;
struct gfxMatrix; struct gfxMatrix;
template <class E> class nsTArray; template <class E> class nsTArray;
@ -52,7 +52,7 @@ public:
virtual bool IsMarkable(); virtual bool IsMarkable();
virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks); virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks);
virtual void ConstructPath(gfxContext *aCtx) = 0; virtual void ConstructPath(gfxContext *aCtx) = 0;
virtual already_AddRefed<gfxFlattenedPath> GetFlattenedPath(const gfxMatrix &aMatrix); virtual already_AddRefed<gfxPath> GetPath(const gfxMatrix &aMatrix);
}; };
#endif #endif

View File

@ -114,7 +114,16 @@ Throw(JSContext* aCx, nsresult aRv, const char* aMessage)
nsresult nr; nsresult nr;
if (NS_SUCCEEDED(existingException->GetResult(&nr)) && if (NS_SUCCEEDED(existingException->GetResult(&nr)) &&
aRv == nr) { aRv == nr) {
// Just reuse the existing exception. // Reuse the existing exception.
// Clear pending exception
runtime->SetPendingException(nullptr);
if (!ThrowExceptionObject(aCx, existingException)) {
// If we weren't able to throw an exception we're
// most likely out of memory
JS_ReportOutOfMemory(aCx);
}
return false; return false;
} }
} }

View File

@ -448,6 +448,11 @@ public:
* mutable. * mutable.
*/ */
virtual FillRule GetFillRule() const = 0; virtual FillRule GetFillRule() const = 0;
virtual Float ComputeLength() { return 0; }
virtual Point ComputePointAtLength(Float aLength,
Point* aTangent) { return Point(); }
}; };
/* The PathBuilder class allows path creation. Once finish is called on the /* The PathBuilder class allows path creation. Once finish is called on the
@ -638,6 +643,19 @@ public:
const IntRect &aSourceRect, const IntRect &aSourceRect,
const IntPoint &aDestination) = 0; const IntPoint &aDestination) = 0;
/*
* Same as CopySurface, except uses itself as the source.
*
* Some backends may be able to optimize this better
* than just taking a snapshot and using CopySurface.
*/
virtual void CopyRect(const IntRect &aSourceRect,
const IntPoint &aDestination)
{
RefPtr<SourceSurface> source = Snapshot();
CopySurface(source, aSourceRect, aDestination);
}
/* /*
* Fill a rectangle on the DrawTarget with a certain source pattern. * Fill a rectangle on the DrawTarget with a certain source pattern.
* *

View File

@ -128,6 +128,25 @@ GetCairoSurfaceSize(cairo_surface_t* surface, IntSize& size)
} }
} }
static bool
SupportsSelfCopy(cairo_surface_t* surface)
{
switch (cairo_surface_get_type(surface))
{
#ifdef CAIRO_HAS_QUARTZ_SURFACE
case CAIRO_SURFACE_TYPE_QUARTZ:
return true;
#endif
#ifdef CAIRO_HAS_WIN32_SURFACE
case CAIRO_SURFACE_TYPE_WIN32:
case CAIRO_SURFACE_TYPE_WIN32_PRINTING:
return true;
#endif
default:
return false;
}
}
static bool static bool
PatternIsCompatible(const Pattern& aPattern) PatternIsCompatible(const Pattern& aPattern)
{ {
@ -636,6 +655,23 @@ DrawTargetCairo::FillRect(const Rect &aRect,
DrawPattern(aPattern, StrokeOptions(), aOptions, DRAW_FILL); DrawPattern(aPattern, StrokeOptions(), aOptions, DRAW_FILL);
} }
void
DrawTargetCairo::CopySurfaceInternal(cairo_surface_t* aSurface,
const IntRect &aSource,
const IntPoint &aDest)
{
cairo_identity_matrix(mContext);
cairo_set_source_surface(mContext, aSurface, aDest.x - aSource.x, aDest.y - aSource.y);
cairo_set_operator(mContext, CAIRO_OPERATOR_SOURCE);
cairo_set_antialias(mContext, CAIRO_ANTIALIAS_NONE);
cairo_reset_clip(mContext);
cairo_new_path(mContext);
cairo_rectangle(mContext, aDest.x, aDest.y, aSource.width, aSource.height);
cairo_fill(mContext);
}
void void
DrawTargetCairo::CopySurface(SourceSurface *aSurface, DrawTargetCairo::CopySurface(SourceSurface *aSurface,
const IntRect &aSource, const IntRect &aSource,
@ -651,16 +687,40 @@ DrawTargetCairo::CopySurface(SourceSurface *aSurface,
cairo_surface_t* surf = static_cast<SourceSurfaceCairo*>(aSurface)->GetSurface(); cairo_surface_t* surf = static_cast<SourceSurfaceCairo*>(aSurface)->GetSurface();
cairo_identity_matrix(mContext); CopySurfaceInternal(surf, aSource, aDest);
}
cairo_set_source_surface(mContext, surf, aDest.x - aSource.x, aDest.y - aSource.y); void
cairo_set_operator(mContext, CAIRO_OPERATOR_SOURCE); DrawTargetCairo::CopyRect(const IntRect &aSource,
cairo_set_antialias(mContext, CAIRO_ANTIALIAS_NONE); const IntPoint &aDest)
{
AutoPrepareForDrawing prep(this, mContext);
cairo_reset_clip(mContext); IntRect source = aSource;
cairo_new_path(mContext); cairo_surface_t* surf = mSurface;
cairo_rectangle(mContext, aDest.x, aDest.y, aSource.width, aSource.height);
cairo_fill(mContext); if (!SupportsSelfCopy(mSurface) &&
aDest.y >= aSource.y &&
aDest.y < aSource.YMost()) {
cairo_surface_t* similar = cairo_surface_create_similar(mSurface,
GfxFormatToCairoContent(GetFormat()),
aSource.width, aSource.height);
cairo_t* ctx = cairo_create(similar);
cairo_set_operator(ctx, CAIRO_OPERATOR_SOURCE);
cairo_set_source_surface(ctx, surf, -aSource.x, -aSource.y);
cairo_paint(ctx);
cairo_destroy(ctx);
source.x = 0;
source.y = 0;
surf = similar;
}
CopySurfaceInternal(surf, source, aDest);
if (surf != mSurface) {
cairo_surface_destroy(surf);
}
} }
void void

View File

@ -78,6 +78,8 @@ public:
virtual void CopySurface(SourceSurface *aSurface, virtual void CopySurface(SourceSurface *aSurface,
const IntRect &aSourceRect, const IntRect &aSourceRect,
const IntPoint &aDestination); const IntPoint &aDestination);
virtual void CopyRect(const IntRect &aSourceRect,
const IntPoint &aDestination);
virtual void FillRect(const Rect &aRect, virtual void FillRect(const Rect &aRect,
const Pattern &aPattern, const Pattern &aPattern,
@ -161,6 +163,10 @@ private: // methods
const DrawOptions& aOptions, const DrawOptions& aOptions,
DrawPatternType aDrawType); DrawPatternType aDrawType);
void CopySurfaceInternal(cairo_surface_t* aSurface,
const IntRect& aSource,
const IntPoint& aDest);
// Call before you make any changes to the backing surface with which this // Call before you make any changes to the backing surface with which this
// context is associated. Pass the path you're going to be using if you have // context is associated. Pass the path you're going to be using if you have
// one. // one.

View File

@ -657,16 +657,12 @@ ThebesLayerBuffer::BeginPaint(ThebesLayer* aLayer, ContentType aContentType,
nsIntPoint dest = mBufferRect.TopLeft() - destBufferRect.TopLeft(); nsIntPoint dest = mBufferRect.TopLeft() - destBufferRect.TopLeft();
if (IsAzureBuffer()) { if (IsAzureBuffer()) {
MOZ_ASSERT(mDTBuffer); MOZ_ASSERT(mDTBuffer);
RefPtr<SourceSurface> source = mDTBuffer->Snapshot(); mDTBuffer->CopyRect(IntRect(srcRect.x, srcRect.y, srcRect.width, srcRect.height),
mDTBuffer->CopySurface(source,
IntRect(srcRect.x, srcRect.y, srcRect.width, srcRect.height),
IntPoint(dest.x, dest.y)); IntPoint(dest.x, dest.y));
if (mode == Layer::SURFACE_COMPONENT_ALPHA) { if (mode == Layer::SURFACE_COMPONENT_ALPHA) {
EnsureBufferOnWhite(); EnsureBufferOnWhite();
MOZ_ASSERT(mDTBufferOnWhite); MOZ_ASSERT(mDTBufferOnWhite);
RefPtr<SourceSurface> sourceOnWhite = mDTBufferOnWhite->Snapshot(); mDTBufferOnWhite->CopyRect(IntRect(srcRect.x, srcRect.y, srcRect.width, srcRect.height),
mDTBufferOnWhite->CopySurface(sourceOnWhite,
IntRect(srcRect.x, srcRect.y, srcRect.width, srcRect.height),
IntPoint(dest.x, dest.y)); IntPoint(dest.x, dest.y));
} }
} else { } else {

View File

@ -115,6 +115,20 @@ BasicContainerLayer::ChildrenPartitionVisibleRegion(const nsIntRect& aInRect)
return covered.Contains(rect); return covered.Contains(rect);
} }
void
BasicContainerLayer::Validate(LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData)
{
for (Layer* l = mFirstChild; l; l = l->GetNextSibling()) {
BasicImplData* data = ToData(l);
data->Validate(aCallback, aCallbackData);
if (l->GetMaskLayer()) {
data = ToData(l->GetMaskLayer());
data->Validate(aCallback, aCallbackData);
}
}
}
already_AddRefed<ContainerLayer> already_AddRefed<ContainerLayer>
BasicLayerManager::CreateContainerLayer() BasicLayerManager::CreateContainerLayer()
{ {

View File

@ -76,6 +76,9 @@ public:
void SetSupportsComponentAlphaChildren(bool aSupports) { mSupportsComponentAlphaChildren = aSupports; } void SetSupportsComponentAlphaChildren(bool aSupports) { mSupportsComponentAlphaChildren = aSupports; }
virtual void Validate(LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData) MOZ_OVERRIDE;
protected: protected:
BasicLayerManager* BasicManager() BasicLayerManager* BasicManager()
{ {

View File

@ -73,6 +73,9 @@ public:
void* aCallbackData, void* aCallbackData,
ReadbackProcessor* aReadback) {} ReadbackProcessor* aReadback) {}
virtual void Validate(LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData) {}
/** /**
* Layers will get this call when their layer manager is destroyed, this * Layers will get this call when their layer manager is destroyed, this
* indicates they should clear resources they don't really need after their * indicates they should clear resources they don't really need after their

View File

@ -581,47 +581,39 @@ BasicLayerManager::EndTransactionInternal(DrawThebesLayerCallback aCallback,
NS_ASSERTION(InConstruction(), "Should be in construction phase"); NS_ASSERTION(InConstruction(), "Should be in construction phase");
mPhase = PHASE_DRAWING; mPhase = PHASE_DRAWING;
Layer* aLayer = GetRoot(); RenderTraceLayers(mRoot, "FF00");
RenderTraceLayers(aLayer, "FF00");
mTransactionIncomplete = false; mTransactionIncomplete = false;
if (aFlags & END_NO_COMPOSITE) { if (mRoot) {
if (!mDummyTarget) { // Need to do this before we call ApplyDoubleBuffering,
// XXX: We should really just set mTarget to null and make sure we can handle that further down the call chain // which depends on correct effective transforms
// Creating this temporary surface can be expensive on some platforms (d2d in particular), so cache it between paints. mSnapEffectiveTransforms =
nsRefPtr<gfxASurface> surf = gfxPlatform::GetPlatform()->CreateOffscreenSurface(gfxIntSize(1, 1), GFX_CONTENT_COLOR); mTarget ? !(mTarget->GetFlags() & gfxContext::FLAG_DISABLE_SNAPPING) : true;
mDummyTarget = new gfxContext(surf); mRoot->ComputeEffectiveTransforms(mTarget ? gfx3DMatrix::From2D(mTarget->CurrentMatrix()) : gfx3DMatrix());
}
mTarget = mDummyTarget;
}
if (mTarget && mRoot && !(aFlags & END_NO_IMMEDIATE_REDRAW)) { ToData(mRoot)->Validate(aCallback, aCallbackData);
nsIntRect clipRect; if (mRoot->GetMaskLayer()) {
if (HasShadowManager()) { ToData(mRoot->GetMaskLayer())->Validate(aCallback, aCallbackData);
// If this has a shadow manager, the clip extents of mTarget are meaningless.
// So instead just use the root layer's visible region bounds.
const nsIntRect& bounds = mRoot->GetVisibleRegion().GetBounds();
gfxRect deviceRect =
mTarget->UserToDevice(gfxRect(bounds.x, bounds.y, bounds.width, bounds.height));
clipRect = ToOutsideIntRect(deviceRect);
} else {
gfxContextMatrixAutoSaveRestore save(mTarget);
mTarget->SetMatrix(gfxMatrix());
clipRect = ToOutsideIntRect(mTarget->GetClipExtents());
} }
if (aFlags & END_NO_COMPOSITE) { if (aFlags & END_NO_COMPOSITE) {
// Apply pending tree updates before recomputing effective // Apply pending tree updates before recomputing effective
// properties. // properties.
aLayer->ApplyPendingUpdatesToSubtree(); mRoot->ApplyPendingUpdatesToSubtree();
}
} }
// Need to do this before we call ApplyDoubleBuffering, if (mTarget && mRoot &&
// which depends on correct effective transforms !(aFlags & END_NO_IMMEDIATE_REDRAW) &&
mSnapEffectiveTransforms = !(aFlags & END_NO_COMPOSITE)) {
!(mTarget->GetFlags() & gfxContext::FLAG_DISABLE_SNAPPING); nsIntRect clipRect;
mRoot->ComputeEffectiveTransforms(gfx3DMatrix::From2D(mTarget->CurrentMatrix()));
{
gfxContextMatrixAutoSaveRestore save(mTarget);
mTarget->SetMatrix(gfxMatrix());
clipRect = ToOutsideIntRect(mTarget->GetClipExtents());
}
if (IsRetained()) { if (IsRetained()) {
nsIntRegion region; nsIntRegion region;
@ -631,22 +623,12 @@ BasicLayerManager::EndTransactionInternal(DrawThebesLayerCallback aCallback,
} }
} }
if (aFlags & END_NO_COMPOSITE) {
if (IsRetained()) {
// Clip the destination out so that we don't draw to it, and
// only end up validating ThebesLayers.
mTarget->Clip(gfxRect(0, 0, 0, 0));
PaintLayer(mTarget, mRoot, aCallback, aCallbackData, nullptr);
}
// If we're not retained, then don't composite means do nothing at all.
} else {
PaintLayer(mTarget, mRoot, aCallback, aCallbackData, nullptr); PaintLayer(mTarget, mRoot, aCallback, aCallbackData, nullptr);
if (mWidget) { if (mWidget) {
FlashWidgetUpdateArea(mTarget); FlashWidgetUpdateArea(mTarget);
} }
RenderDebugOverlay(); RenderDebugOverlay();
LayerManager::PostPresent(); LayerManager::PostPresent();
}
if (!mTransactionIncomplete) { if (!mTransactionIncomplete) {
// Clear out target if we have a complete transaction. // Clear out target if we have a complete transaction.
@ -854,14 +836,6 @@ BasicLayerManager::PaintSelfOrChildren(PaintLayerContext& aPaintContext,
{ {
BasicImplData* data = ToData(aPaintContext.mLayer); BasicImplData* data = ToData(aPaintContext.mLayer);
if (aPaintContext.mLayer->GetFirstChild() &&
aPaintContext.mLayer->GetMaskLayer() &&
HasShadowManager()) {
// 'paint' the mask so that it gets sent to the shadow layer tree
static_cast<BasicImplData*>(aPaintContext.mLayer->GetMaskLayer()->ImplData())
->Paint(nullptr, nullptr);
}
/* Only paint ourself, or our children - This optimization relies on this! */ /* Only paint ourself, or our children - This optimization relies on this! */
Layer* child = aPaintContext.mLayer->GetFirstChild(); Layer* child = aPaintContext.mLayer->GetFirstChild();
if (!child) { if (!child) {
@ -910,7 +884,7 @@ BasicLayerManager::FlushGroup(PaintLayerContext& aPaintContext, bool aNeedsClipT
BasicContainerLayer* container = static_cast<BasicContainerLayer*>(aPaintContext.mLayer); BasicContainerLayer* container = static_cast<BasicContainerLayer*>(aPaintContext.mLayer);
AutoSetOperator setOperator(aPaintContext.mTarget, container->GetOperator()); AutoSetOperator setOperator(aPaintContext.mTarget, container->GetOperator());
PaintWithMask(aPaintContext.mTarget, aPaintContext.mLayer->GetEffectiveOpacity(), PaintWithMask(aPaintContext.mTarget, aPaintContext.mLayer->GetEffectiveOpacity(),
HasShadowManager() ? nullptr : aPaintContext.mLayer->GetMaskLayer()); aPaintContext.mLayer->GetMaskLayer());
} }
} }

View File

@ -97,7 +97,7 @@ public:
virtual void EndTransaction(DrawThebesLayerCallback aCallback, virtual void EndTransaction(DrawThebesLayerCallback aCallback,
void* aCallbackData, void* aCallbackData,
EndTransactionFlags aFlags = END_DEFAULT); EndTransactionFlags aFlags = END_DEFAULT);
virtual bool AreComponentAlphaLayersEnabled() { return HasShadowManager() || !IsWidgetLayerManager(); } virtual bool AreComponentAlphaLayersEnabled() { return !IsWidgetLayerManager(); }
void AbortTransaction(); void AbortTransaction();
@ -145,7 +145,6 @@ public:
virtual bool IsCompositingCheap() { return false; } virtual bool IsCompositingCheap() { return false; }
virtual int32_t GetMaxTextureSize() const { return INT32_MAX; } virtual int32_t GetMaxTextureSize() const { return INT32_MAX; }
bool CompositorMightResample() { return mCompositorMightResample; } bool CompositorMightResample() { return mCompositorMightResample; }
bool HasShadowTarget() { return !!mShadowTarget; }
protected: protected:
enum TransactionPhase { enum TransactionPhase {
@ -187,16 +186,6 @@ protected:
nsRefPtr<gfxContext> mDefaultTarget; nsRefPtr<gfxContext> mDefaultTarget;
// The context to draw into. // The context to draw into.
nsRefPtr<gfxContext> mTarget; nsRefPtr<gfxContext> mTarget;
// When we're doing a transaction in order to draw to a non-default
// target, the layers transaction is only performed in order to send
// a PLayerTransaction:Update. We save the original non-default target to
// mShadowTarget, and then perform the transaction using
// mDummyTarget as the render target. After the transaction ends,
// we send a message to our remote side to capture the actual pixels
// being drawn to the default target, and then copy those pixels
// back to mShadowTarget.
nsRefPtr<gfxContext> mShadowTarget;
nsRefPtr<gfxContext> mDummyTarget;
// Image factory we use. // Image factory we use.
nsRefPtr<ImageFactory> mFactory; nsRefPtr<ImageFactory> mFactory;

View File

@ -90,25 +90,11 @@ BasicThebesLayer::PaintThebes(gfxContext* aContext,
NS_ASSERTION(BasicManager()->InDrawing(), NS_ASSERTION(BasicManager()->InDrawing(),
"Can only draw in drawing phase"); "Can only draw in drawing phase");
if (!mContentClient) {
// we pass a null pointer for the Forwarder argument, which means
// this will not have a ContentHost on the other side.
mContentClient = new ContentClientBasic(nullptr, BasicManager());
}
nsTArray<ReadbackProcessor::Update> readbackUpdates; nsTArray<ReadbackProcessor::Update> readbackUpdates;
if (aReadback && UsedForReadback()) { if (aReadback && UsedForReadback()) {
aReadback->GetThebesLayerUpdates(this, &readbackUpdates); aReadback->GetThebesLayerUpdates(this, &readbackUpdates);
} }
//TODO: This is going to copy back pixels that we might end up
// drawing over anyway. It would be nice if we could avoid
// this duplication.
mContentClient->SyncFrontBufferToBackBuffer();
bool canUseOpaqueSurface = CanUseOpaqueSurface();
ContentType contentType =
canUseOpaqueSurface ? GFX_CONTENT_COLOR :
GFX_CONTENT_COLOR_ALPHA;
float opacity = GetEffectiveOpacity(); float opacity = GetEffectiveOpacity();
gfxContext::GraphicsOperator mixBlendMode = GetEffectiveMixBlendMode(); gfxContext::GraphicsOperator mixBlendMode = GetEffectiveMixBlendMode();
@ -162,7 +148,61 @@ BasicThebesLayer::PaintThebes(gfxContext* aContext,
return; return;
} }
if (BasicManager()->IsTransactionIncomplete())
return;
gfxRect clipExtents;
clipExtents = aContext->GetClipExtents();
// Pull out the mask surface and transform here, because the mask
// is internal to basic layers
AutoMaskData mask;
gfxASurface* maskSurface = nullptr;
const gfxMatrix* maskTransform = nullptr;
if (GetMaskData(aMaskLayer, &mask)) {
maskSurface = mask.GetSurface();
maskTransform = &mask.GetTransform();
}
if (!IsHidden() && !clipExtents.IsEmpty()) {
AutoSetOperator setOperator(aContext, GetOperator());
mContentClient->DrawTo(this, aContext, opacity, maskSurface, maskTransform);
}
for (uint32_t i = 0; i < readbackUpdates.Length(); ++i) {
ReadbackProcessor::Update& update = readbackUpdates[i];
nsIntPoint offset = update.mLayer->GetBackgroundLayerOffset();
nsRefPtr<gfxContext> ctx =
update.mLayer->GetSink()->BeginUpdate(update.mUpdateRect + offset,
update.mSequenceCounter);
if (ctx) {
NS_ASSERTION(opacity == 1.0, "Should only read back opaque layers");
ctx->Translate(gfxPoint(offset.x, offset.y));
mContentClient->DrawTo(this, ctx, 1.0, maskSurface, maskTransform);
update.mLayer->GetSink()->EndUpdate(ctx, update.mUpdateRect + offset);
}
}
}
void
BasicThebesLayer::Validate(LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData)
{ {
if (!mContentClient) {
// we pass a null pointer for the Forwarder argument, which means
// this will not have a ContentHost on the other side.
mContentClient = new ContentClientBasic(nullptr, BasicManager());
}
if (!BasicManager()->IsRetained()) {
return;
}
bool canUseOpaqueSurface = CanUseOpaqueSurface();
ContentType contentType =
canUseOpaqueSurface ? GFX_CONTENT_COLOR :
GFX_CONTENT_COLOR_ALPHA;
uint32_t flags = 0; uint32_t flags = 0;
#ifndef MOZ_WIDGET_ANDROID #ifndef MOZ_WIDGET_ANDROID
if (BasicManager()->CompositorMightResample()) { if (BasicManager()->CompositorMightResample()) {
@ -210,42 +250,6 @@ BasicThebesLayer::PaintThebes(gfxContext* aContext,
} }
} }
if (BasicManager()->IsTransactionIncomplete())
return;
gfxRect clipExtents;
clipExtents = aContext->GetClipExtents();
// Pull out the mask surface and transform here, because the mask
// is internal to basic layers
AutoMaskData mask;
gfxASurface* maskSurface = nullptr;
const gfxMatrix* maskTransform = nullptr;
if (GetMaskData(aMaskLayer, &mask)) {
maskSurface = mask.GetSurface();
maskTransform = &mask.GetTransform();
}
if (!IsHidden() && !clipExtents.IsEmpty()) {
AutoSetOperator setOperator(aContext, GetOperator());
mContentClient->DrawTo(this, aContext, opacity, maskSurface, maskTransform);
}
for (uint32_t i = 0; i < readbackUpdates.Length(); ++i) {
ReadbackProcessor::Update& update = readbackUpdates[i];
nsIntPoint offset = update.mLayer->GetBackgroundLayerOffset();
nsRefPtr<gfxContext> ctx =
update.mLayer->GetSink()->BeginUpdate(update.mUpdateRect + offset,
update.mSequenceCounter);
if (ctx) {
NS_ASSERTION(opacity == 1.0, "Should only read back opaque layers");
ctx->Translate(gfxPoint(offset.x, offset.y));
mContentClient->DrawTo(this, ctx, 1.0, maskSurface, maskTransform);
update.mLayer->GetSink()->EndUpdate(ctx, update.mUpdateRect + offset);
}
}
}
already_AddRefed<ThebesLayer> already_AddRefed<ThebesLayer>
BasicLayerManager::CreateThebesLayer() BasicLayerManager::CreateThebesLayer()
{ {

View File

@ -64,6 +64,9 @@ public:
void* aCallbackData, void* aCallbackData,
ReadbackProcessor* aReadback); ReadbackProcessor* aReadback);
virtual void Validate(LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData) MOZ_OVERRIDE;
virtual void ClearCachedResources() virtual void ClearCachedResources()
{ {
if (mContentClient) { if (mContentClient) {

View File

@ -38,7 +38,7 @@ load 393822-1.html
load 394384-1.html load 394384-1.html
load 394246-1.html load 394246-1.html
load 394246-2.html load 394246-2.html
load 394751.xhtml skip-if(Android&&AndroidVersion<15) load 394751.xhtml # bug 922976
load 395335-1.xhtml load 395335-1.xhtml
load 395458-1.html load 395458-1.html
load 396321-1.svg load 396321-1.svg

View File

@ -275,25 +275,31 @@ gfxContext::ClosePath()
} }
} }
already_AddRefed<gfxPath> gfxContext::CopyPath() const already_AddRefed<gfxPath> gfxContext::CopyPath()
{ {
nsRefPtr<gfxPath> path;
if (mCairo) { if (mCairo) {
nsRefPtr<gfxPath> path = new gfxPath(cairo_copy_path(mCairo)); path = new gfxPath(cairo_copy_path(mCairo));
return path.forget();
} else { } else {
// XXX - This is not yet supported for Azure. EnsurePath();
return nullptr; path = new gfxPath(mPath);
} }
return path.forget();
} }
void gfxContext::AppendPath(gfxPath* path) void gfxContext::SetPath(gfxPath* path)
{ {
if (mCairo) { if (mCairo) {
cairo_new_path(mCairo);
if (path->mPath->status == CAIRO_STATUS_SUCCESS && path->mPath->num_data != 0) if (path->mPath->status == CAIRO_STATUS_SUCCESS && path->mPath->num_data != 0)
cairo_append_path(mCairo, path->mPath); cairo_append_path(mCairo, path->mPath);
} else { } else {
// XXX - This is not yet supported for Azure. MOZ_ASSERT(path->mMoz2DPath, "Can't mix cairo and azure paths!");
return; MOZ_ASSERT(path->mMoz2DPath->GetBackendType() == mDT->GetType());
mPath = path->mMoz2DPath;
mPathBuilder = nullptr;
mPathIsRect = false;
mTransformChanged = false;
} }
} }
@ -1751,19 +1757,6 @@ gfxContext::GetUserStrokeExtent()
} }
} }
already_AddRefed<gfxFlattenedPath>
gfxContext::GetFlattenedPath()
{
if (mCairo) {
nsRefPtr<gfxFlattenedPath> path =
new gfxFlattenedPath(cairo_copy_path_flat(mCairo));
return path.forget();
} else {
// XXX - Used by SVG, needs fixing.
return nullptr;
}
}
bool bool
gfxContext::HasError() gfxContext::HasError()
{ {

View File

@ -131,12 +131,12 @@ public:
/** /**
* Copies the current path and returns the copy. * Copies the current path and returns the copy.
*/ */
already_AddRefed<gfxPath> CopyPath() const; already_AddRefed<gfxPath> CopyPath();
/** /**
* Appends the given path to the current path. * Appends the given path to the current path.
*/ */
void AppendPath(gfxPath* path); void SetPath(gfxPath* path);
/** /**
* Moves the pen to a new point without drawing a line. * Moves the pen to a new point without drawing a line.
@ -645,11 +645,6 @@ public:
gfxRect GetUserFillExtent(); gfxRect GetUserFillExtent();
gfxRect GetUserStrokeExtent(); gfxRect GetUserStrokeExtent();
/**
** Obtaining a "flattened" path - path converted to all line segments
**/
already_AddRefed<gfxFlattenedPath> GetFlattenedPath();
/** /**
** Flags ** Flags
**/ **/
@ -886,8 +881,7 @@ public:
void Restore() void Restore()
{ {
if (mPath) { if (mPath) {
mContext->NewPath(); mContext->SetPath(mPath);
mContext->AppendPath(mPath);
mPath = nullptr; mPath = nullptr;
} }
} }

View File

@ -5,24 +5,45 @@
#include "gfxPath.h" #include "gfxPath.h"
#include "gfxPoint.h" #include "gfxPoint.h"
#include "gfxPlatform.h"
#include "gfxASurface.h"
#include "mozilla/gfx/2D.h"
#include "cairo.h" #include "cairo.h"
gfxPath::gfxPath(cairo_path_t* aPath) : mPath(aPath) using namespace mozilla::gfx;
gfxPath::gfxPath(cairo_path_t* aPath)
: mPath(aPath)
, mFlattenedPath(nullptr)
{
}
gfxPath::gfxPath(Path* aPath)
: mPath(nullptr)
, mFlattenedPath(nullptr)
, mMoz2DPath(aPath)
{ {
} }
gfxPath::~gfxPath() gfxPath::~gfxPath()
{ {
cairo_path_destroy(mPath); cairo_path_destroy(mPath);
cairo_path_destroy(mFlattenedPath);
} }
gfxFlattenedPath::gfxFlattenedPath(cairo_path_t* aPath) : gfxPath(aPath) void
gfxPath::EnsureFlattenedPath()
{ {
if (mFlattenedPath) {
return;
} }
gfxFlattenedPath::~gfxFlattenedPath() gfxASurface* surf = gfxPlatform::GetPlatform()->ScreenReferenceSurface();
{ cairo_t* cr = cairo_create(surf->CairoSurface());
cairo_append_path(cr, mPath);
mFlattenedPath = cairo_copy_path_flat(cr);
cairo_destroy(cr);
} }
static gfxFloat static gfxFloat
@ -62,33 +83,55 @@ CalcSubLengthAndAdvance(cairo_path_data_t *aData,
} }
gfxFloat gfxFloat
gfxFlattenedPath::GetLength() gfxPath::GetLength()
{ {
if (mMoz2DPath) {
return mMoz2DPath->ComputeLength();
}
EnsureFlattenedPath();
gfxPoint start(0, 0); // start of current subpath gfxPoint start(0, 0); // start of current subpath
gfxPoint current(0, 0); // current point gfxPoint current(0, 0); // current point
gfxFloat length = 0; // current summed length gfxFloat length = 0; // current summed length
for (int32_t i = 0; for (int32_t i = 0;
i < mPath->num_data; i < mFlattenedPath->num_data;
i += mPath->data[i].header.length) { i += mFlattenedPath->data[i].header.length) {
length += CalcSubLengthAndAdvance(&mPath->data[i], start, current); length += CalcSubLengthAndAdvance(&mFlattenedPath->data[i], start, current);
} }
return length; return length;
} }
gfxPoint gfxPoint
gfxFlattenedPath::FindPoint(gfxPoint aOffset, gfxFloat *aAngle) gfxPath::FindPoint(gfxPoint aOffset, gfxFloat *aAngle)
{ {
if (mMoz2DPath) {
Point tangent; // Unit vector tangent to the point we find.
Point result = mMoz2DPath->ComputePointAtLength(aOffset.x, &tangent);
// The y value of aOffset is the offset along the normal vector to apply
Point normal(-tangent.y, tangent.x);
result += normal * aOffset.y;
if (aAngle)
*aAngle = atan2(tangent.y, tangent.x);
return gfxPoint(result.x, result.y);
}
EnsureFlattenedPath();
gfxPoint start(0, 0); // start of current subpath gfxPoint start(0, 0); // start of current subpath
gfxPoint current(0, 0); // current point gfxPoint current(0, 0); // current point
gfxFloat length = 0; // current summed length gfxFloat length = 0; // current summed length
for (int32_t i = 0; for (int32_t i = 0;
i < mPath->num_data; i < mFlattenedPath->num_data;
i += mPath->data[i].header.length) { i += mFlattenedPath->data[i].header.length) {
gfxPoint prev = current; gfxPoint prev = current;
gfxFloat sublength = CalcSubLengthAndAdvance(&mPath->data[i], gfxFloat sublength = CalcSubLengthAndAdvance(&mFlattenedPath->data[i],
start, current); start, current);
gfxPoint diff = current - prev; gfxPoint diff = current - prev;

View File

@ -8,11 +8,18 @@
#include "gfxTypes.h" #include "gfxTypes.h"
#include "nsISupportsImpl.h" #include "nsISupportsImpl.h"
#include "mozilla/RefPtr.h"
class gfxContext; class gfxContext;
struct gfxPoint; struct gfxPoint;
typedef struct cairo_path cairo_path_t; typedef struct cairo_path cairo_path_t;
namespace mozilla {
namespace gfx {
class Path;
}
}
/** /**
* Class representing a path. Can be created by copying the current path * Class representing a path. Can be created by copying the current path
* of a gfxContext. * of a gfxContext.
@ -24,27 +31,13 @@ class gfxPath {
protected: protected:
gfxPath(cairo_path_t* aPath); gfxPath(cairo_path_t* aPath);
gfxPath(mozilla::gfx::Path* aPath);
void EnsureFlattenedPath();
public: public:
virtual ~gfxPath(); virtual ~gfxPath();
protected:
cairo_path_t* mPath;
};
/**
* Specialization of a path that only contains linear pieces. Can be created
* from the existing path of a gfxContext.
*/
class gfxFlattenedPath : public gfxPath {
friend class gfxContext;
protected:
gfxFlattenedPath(cairo_path_t* aPath);
public:
virtual ~gfxFlattenedPath();
/** /**
* Returns calculated total length of path * Returns calculated total length of path
*/ */
@ -59,6 +52,11 @@ public:
*/ */
gfxPoint FindPoint(gfxPoint aOffset, gfxPoint FindPoint(gfxPoint aOffset,
gfxFloat* aAngle = nullptr); gfxFloat* aAngle = nullptr);
protected:
cairo_path_t* mPath;
cairo_path_t* mFlattenedPath;
mozilla::RefPtr<mozilla::gfx::Path> mMoz2DPath;
}; };
#endif #endif

View File

@ -241,8 +241,6 @@ ifdef ENABLE_INTL_API
ifndef MOZ_NATIVE_ICU ifndef MOZ_NATIVE_ICU
ifeq ($(OS_ARCH),WINNT) ifeq ($(OS_ARCH),WINNT)
# Parallel gmake is buggy on Windows
ICU_GMAKE_OPTIONS="-j1"
# Library names: On Windows, ICU uses modified library names for static # Library names: On Windows, ICU uses modified library names for static
# and debug libraries. # and debug libraries.
ifdef MOZ_DEBUG ifdef MOZ_DEBUG
@ -252,13 +250,20 @@ ifeq ($(OS_ARCH),WINNT)
cp -p intl/icu/lib/s$(libname)$(ICU_LIB_SUFFIX).lib intl/icu/lib/$(libname).lib;) cp -p intl/icu/lib/s$(libname)$(ICU_LIB_SUFFIX).lib intl/icu/lib/$(libname).lib;)
endif endif
ifdef .PYMAKE
ICU_MAKE = $(GMAKE)
else
ICU_MAKE = $(MAKE)
endif
# - ICU requires GNU make according to its readme.html. pymake can't be used # - ICU requires GNU make according to its readme.html. pymake can't be used
# because it doesn't support order only dependencies. # because it doesn't support order only dependencies.
# - Force ICU to use the standard suffix for object files because expandlibs # - Force ICU to use the standard suffix for object files because expandlibs
# will discard all files with a non-standard suffix (bug 857450). # will discard all files with a non-standard suffix (bug 857450).
# - Options for genrb: -k strict parsing; -R omit collation tailoring rules. # - Options for genrb: -k strict parsing; -R omit collation tailoring rules.
buildicu: buildicu:
$(GMAKE) $(ICU_GMAKE_OPTIONS) -C intl/icu STATIC_O=$(OBJ_SUFFIX) GENRBOPTS='-k -R' # ICU's build system is full of races, so force non-parallel build.
+$(ICU_MAKE) -j1 -C intl/icu STATIC_O=$(OBJ_SUFFIX) GENRBOPTS='-k -R'
$(ICU_LIB_RENAME) $(ICU_LIB_RENAME)
distclean clean:: distclean clean::

View File

@ -738,7 +738,7 @@ nsSVGGlyphFrame::GetCharacterPositions(nsTArray<CharacterPosition>* aCharacterPo
nsSVGTextPathFrame *textPath = FindTextPathParent(); nsSVGTextPathFrame *textPath = FindTextPathParent();
if (textPath) { if (textPath) {
nsRefPtr<gfxFlattenedPath> data = textPath->GetFlattenedPath(); nsRefPtr<gfxPath> data = textPath->GetPath();
// textPath frame, but invalid target // textPath frame, but invalid target
if (!data) if (!data)

View File

@ -4637,8 +4637,8 @@ nsSVGTextFrame2::GetTextPathPathFrame(nsIFrame* aTextPathFrame)
return property->GetReferencedFrame(nsGkAtoms::svgPathGeometryFrame, nullptr); return property->GetReferencedFrame(nsGkAtoms::svgPathGeometryFrame, nullptr);
} }
already_AddRefed<gfxFlattenedPath> already_AddRefed<gfxPath>
nsSVGTextFrame2::GetFlattenedTextPath(nsIFrame* aTextPathFrame) nsSVGTextFrame2::GetTextPath(nsIFrame* aTextPathFrame)
{ {
nsIFrame *path = GetTextPathPathFrame(aTextPathFrame); nsIFrame *path = GetTextPathPathFrame(aTextPathFrame);
@ -4646,7 +4646,7 @@ nsSVGTextFrame2::GetFlattenedTextPath(nsIFrame* aTextPathFrame)
nsSVGPathGeometryElement *element = nsSVGPathGeometryElement *element =
static_cast<nsSVGPathGeometryElement*>(path->GetContent()); static_cast<nsSVGPathGeometryElement*>(path->GetContent());
return element->GetFlattenedPath(element->PrependLocalTransformsTo(gfxMatrix())); return element->GetPath(element->PrependLocalTransformsTo(gfxMatrix()));
} }
return nullptr; return nullptr;
} }
@ -4671,7 +4671,7 @@ nsSVGTextFrame2::GetStartOffset(nsIFrame* aTextPathFrame)
&tp->mLengthAttributes[dom::SVGTextPathElement::STARTOFFSET]; &tp->mLengthAttributes[dom::SVGTextPathElement::STARTOFFSET];
if (length->IsPercentage()) { if (length->IsPercentage()) {
nsRefPtr<gfxFlattenedPath> data = GetFlattenedTextPath(aTextPathFrame); nsRefPtr<gfxPath> data = GetTextPath(aTextPathFrame);
return data ? return data ?
length->GetAnimValInSpecifiedUnits() * data->GetLength() / 100.0 : length->GetAnimValInSpecifiedUnits() * data->GetLength() / 100.0 :
0.0; 0.0;
@ -4694,7 +4694,7 @@ nsSVGTextFrame2::DoTextPathLayout()
} }
// Get the path itself. // Get the path itself.
nsRefPtr<gfxFlattenedPath> data = GetFlattenedTextPath(textPathFrame); nsRefPtr<gfxPath> data = GetTextPath(textPathFrame);
if (!data) { if (!data) {
it.AdvancePastCurrentTextPathFrame(); it.AdvancePastCurrentTextPathFrame();
continue; continue;

View File

@ -18,7 +18,7 @@ class nsDisplaySVGText;
class nsRenderingContext; class nsRenderingContext;
class nsSVGTextFrame2; class nsSVGTextFrame2;
class nsTextFrame; class nsTextFrame;
class gfxFlattenedPath; class gfxPath;
typedef nsSVGDisplayContainerFrame nsSVGTextFrame2Base; typedef nsSVGDisplayContainerFrame nsSVGTextFrame2Base;
@ -517,7 +517,7 @@ private:
// Methods to get information for a <textPath> frame. // Methods to get information for a <textPath> frame.
nsIFrame* GetTextPathPathFrame(nsIFrame* aTextPathFrame); nsIFrame* GetTextPathPathFrame(nsIFrame* aTextPathFrame);
already_AddRefed<gfxFlattenedPath> GetFlattenedTextPath(nsIFrame* aTextPathFrame); already_AddRefed<gfxPath> GetTextPath(nsIFrame* aTextPathFrame);
gfxFloat GetOffsetScale(nsIFrame* aTextPathFrame); gfxFloat GetOffsetScale(nsIFrame* aTextPathFrame);
gfxFloat GetStartOffset(nsIFrame* aTextPathFrame); gfxFloat GetStartOffset(nsIFrame* aTextPathFrame);

View File

@ -111,8 +111,8 @@ nsSVGTextPathFrame::GetPathFrame()
return frame && frame->GetContent()->Tag() == nsGkAtoms::path ? frame : nullptr; return frame && frame->GetContent()->Tag() == nsGkAtoms::path ? frame : nullptr;
} }
already_AddRefed<gfxFlattenedPath> already_AddRefed<gfxPath>
nsSVGTextPathFrame::GetFlattenedPath() nsSVGTextPathFrame::GetPath()
{ {
nsIFrame *path = GetPathFrame(); nsIFrame *path = GetPathFrame();
@ -120,7 +120,7 @@ nsSVGTextPathFrame::GetFlattenedPath()
nsSVGPathGeometryElement *element = nsSVGPathGeometryElement *element =
static_cast<nsSVGPathGeometryElement*>(path->GetContent()); static_cast<nsSVGPathGeometryElement*>(path->GetContent());
return element->GetFlattenedPath(element->PrependLocalTransformsTo(gfxMatrix())); return element->GetPath(element->PrependLocalTransformsTo(gfxMatrix()));
} }
return nullptr; return nullptr;
} }
@ -132,7 +132,7 @@ nsSVGTextPathFrame::GetStartOffset()
nsSVGLength2 *length = &tp->mLengthAttributes[SVGTextPathElement::STARTOFFSET]; nsSVGLength2 *length = &tp->mLengthAttributes[SVGTextPathElement::STARTOFFSET];
if (length->IsPercentage()) { if (length->IsPercentage()) {
nsRefPtr<gfxFlattenedPath> data = GetFlattenedPath(); nsRefPtr<gfxPath> data = GetPath();
return data ? (length->GetAnimValInSpecifiedUnits() * data->GetLength() / 100.0) : 0.0; return data ? (length->GetAnimValInSpecifiedUnits() * data->GetLength() / 100.0) : 0.0;
} }
return length->GetAnimValue(tp) * GetOffsetScale(); return length->GetAnimValue(tp) * GetOffsetScale();

View File

@ -15,7 +15,7 @@
#include "nsQueryFrame.h" #include "nsQueryFrame.h"
#include "nsSVGTSpanFrame.h" #include "nsSVGTSpanFrame.h"
class gfxFlattenedPath; class gfxPath;
class nsIAtom; class nsIAtom;
class nsIContent; class nsIContent;
class nsIFrame; class nsIFrame;
@ -65,7 +65,7 @@ public:
#endif #endif
// nsSVGTextPathFrame methods: // nsSVGTextPathFrame methods:
already_AddRefed<gfxFlattenedPath> GetFlattenedPath(); already_AddRefed<gfxPath> GetPath();
nsIFrame *GetPathFrame(); nsIFrame *GetPathFrame();
/** /**

View File

@ -133,7 +133,7 @@ NS_IMETHODIMP nsZipHeader::GetPermissions(uint32_t *aPermissions)
NS_ASSERTION(mInited, "Not initalised"); NS_ASSERTION(mInited, "Not initalised");
// Always give user read access at least, this matches nsIZipReader's behaviour // Always give user read access at least, this matches nsIZipReader's behaviour
*aPermissions = ((mEAttr >> 16) & 0xfff | 0x100); *aPermissions = ((mEAttr >> 16) & 0xfff) | 0x100;
return NS_OK; return NS_OK;
} }

View File

@ -42,13 +42,13 @@ CalculateMD5(const char *data, DWORD dataSize,
HCRYPTPROV hProv = 0; HCRYPTPROV hProv = 0;
HCRYPTHASH hHash = 0; HCRYPTHASH hHash = 0;
if (!CryptAcquireContext(&hProv, nullptr, nullptr, PROV_RSA_FULL, 0)) { if (!CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL, 0)) {
if (NTE_BAD_KEYSET != GetLastError()) { if (NTE_BAD_KEYSET != GetLastError()) {
return FALSE; return FALSE;
} }
// Maybe it doesn't exist, try to create it. // Maybe it doesn't exist, try to create it.
if (!CryptAcquireContext(&hProv, nullptr, nullptr, PROV_RSA_FULL, if (!CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL,
CRYPT_NEWKEYSET)) { CRYPT_NEWKEYSET)) {
return FALSE; return FALSE;
} }

View File

@ -62,13 +62,13 @@ static char*
NS_strtok(const char *delims, char **str) NS_strtok(const char *delims, char **str)
{ {
if (!*str) if (!*str)
return nullptr; return NULL;
char *ret = (char*) NS_strspnp(delims, *str); char *ret = (char*) NS_strspnp(delims, *str);
if (!*ret) { if (!*ret) {
*str = ret; *str = ret;
return nullptr; return NULL;
} }
char *i = ret; char *i = ret;
@ -83,7 +83,7 @@ NS_strtok(const char *delims, char **str)
++i; ++i;
} while (*i); } while (*i);
*str = nullptr; *str = NULL;
return ret; return ret;
} }

View File

@ -7,8 +7,6 @@
#ifndef READSTRINGS_H__ #ifndef READSTRINGS_H__
#define READSTRINGS_H__ #define READSTRINGS_H__
#include "mozilla/NullPtr.h"
#define MAX_TEXT_LEN 600 #define MAX_TEXT_LEN 600
#ifdef XP_WIN #ifdef XP_WIN
@ -40,6 +38,6 @@ int ReadStrings(const NS_tchar *path,
const char *keyList, const char *keyList,
unsigned int numStrings, unsigned int numStrings,
char results[][MAX_TEXT_LEN], char results[][MAX_TEXT_LEN],
const char *section = nullptr); const char *section = NULL);
#endif // READSTRINGS_H__ #endif // READSTRINGS_H__

View File

@ -80,7 +80,7 @@ HANDLE
UACHelper::OpenUserToken(DWORD sessionID) UACHelper::OpenUserToken(DWORD sessionID)
{ {
HMODULE module = LoadLibraryW(L"wtsapi32.dll"); HMODULE module = LoadLibraryW(L"wtsapi32.dll");
HANDLE token = nullptr; HANDLE token = NULL;
LPWTSQueryUserToken wtsQueryUserToken = LPWTSQueryUserToken wtsQueryUserToken =
(LPWTSQueryUserToken)GetProcAddress(module, "WTSQueryUserToken"); (LPWTSQueryUserToken)GetProcAddress(module, "WTSQueryUserToken");
if (wtsQueryUserToken) { if (wtsQueryUserToken) {
@ -94,7 +94,7 @@ UACHelper::OpenUserToken(DWORD sessionID)
* Opens a linked token for the specified token. * Opens a linked token for the specified token.
* *
* @param token The token to get the linked token from * @param token The token to get the linked token from
* @return A linked token or nullptr if one does not exist. * @return A linked token or NULL if one does not exist.
* Caller should close the handle. * Caller should close the handle.
*/ */
HANDLE HANDLE
@ -105,7 +105,7 @@ UACHelper::OpenLinkedToken(HANDLE token)
// the other is the UAC elevated one. Since we are running as a service // the other is the UAC elevated one. Since we are running as a service
// as the system account we have access to both. // as the system account we have access to both.
TOKEN_LINKED_TOKEN tlt; TOKEN_LINKED_TOKEN tlt;
HANDLE hNewLinkedToken = nullptr; HANDLE hNewLinkedToken = NULL;
DWORD len; DWORD len;
if (GetTokenInformation(token, (TOKEN_INFORMATION_CLASS)TokenLinkedToken, if (GetTokenInformation(token, (TOKEN_INFORMATION_CLASS)TokenLinkedToken,
&tlt, sizeof(TOKEN_LINKED_TOKEN), &len)) { &tlt, sizeof(TOKEN_LINKED_TOKEN), &len)) {
@ -128,7 +128,7 @@ BOOL
UACHelper::SetPrivilege(HANDLE token, LPCTSTR priv, BOOL enable) UACHelper::SetPrivilege(HANDLE token, LPCTSTR priv, BOOL enable)
{ {
LUID luidOfPriv; LUID luidOfPriv;
if (!LookupPrivilegeValue(nullptr, priv, &luidOfPriv)) { if (!LookupPrivilegeValue(NULL, priv, &luidOfPriv)) {
return FALSE; return FALSE;
} }
@ -139,7 +139,7 @@ UACHelper::SetPrivilege(HANDLE token, LPCTSTR priv, BOOL enable)
SetLastError(ERROR_SUCCESS); SetLastError(ERROR_SUCCESS);
if (!AdjustTokenPrivileges(token, false, &tokenPriv, if (!AdjustTokenPrivileges(token, false, &tokenPriv,
sizeof(tokenPriv), nullptr, nullptr)) { sizeof(tokenPriv), NULL, NULL)) {
return FALSE; return FALSE;
} }
@ -151,7 +151,7 @@ UACHelper::SetPrivilege(HANDLE token, LPCTSTR priv, BOOL enable)
* drop the privilege. * drop the privilege.
* *
* @param token The token to adjust the privilege on. * @param token The token to adjust the privilege on.
* Pass nullptr for current token. * Pass NULL for current token.
* @param unneededPrivs An array of unneeded privileges. * @param unneededPrivs An array of unneeded privileges.
* @param count The size of the array * @param count The size of the array
* @return TRUE if there were no errors * @return TRUE if there were no errors
@ -161,7 +161,7 @@ UACHelper::DisableUnneededPrivileges(HANDLE token,
LPCTSTR *unneededPrivs, LPCTSTR *unneededPrivs,
size_t count) size_t count)
{ {
HANDLE obtainedToken = nullptr; HANDLE obtainedToken = NULL;
if (!token) { if (!token) {
// Note: This handle is a pseudo-handle and need not be closed // Note: This handle is a pseudo-handle and need not be closed
HANDLE process = GetCurrentProcess(); HANDLE process = GetCurrentProcess();
@ -198,7 +198,7 @@ UACHelper::DisableUnneededPrivileges(HANDLE token,
* explicitly disable these or not. * explicitly disable these or not.
* *
* @param token The token to drop the privilege on. * @param token The token to drop the privilege on.
* Pass nullptr for current token. * Pass NULL for current token.
* @return TRUE if there were no errors * @return TRUE if there were no errors
*/ */
BOOL BOOL

View File

@ -70,8 +70,8 @@ PathGetSiblingFilePath(LPWSTR destinationBuffer,
* @param updateInfoDir The directory where update info is stored. * @param updateInfoDir The directory where update info is stored.
* @param forceSync If true even if the ini file specifies async, the * @param forceSync If true even if the ini file specifies async, the
* process will wait for termination of PostUpdate. * process will wait for termination of PostUpdate.
* @param userToken The user token to run as, if nullptr the current * @param userToken The user token to run as, if NULL the current user
* user will be used. * will be used.
* @return TRUE if there was no error starting the process. * @return TRUE if there was no error starting the process.
*/ */
BOOL BOOL
@ -95,12 +95,12 @@ LaunchWinPostProcess(const WCHAR *installationDir,
WCHAR exearg[MAX_PATH + 1]; WCHAR exearg[MAX_PATH + 1];
WCHAR exeasync[10]; WCHAR exeasync[10];
bool async = true; bool async = true;
if (!GetPrivateProfileStringW(L"PostUpdateWin", L"ExeRelPath", nullptr, if (!GetPrivateProfileStringW(L"PostUpdateWin", L"ExeRelPath", NULL, exefile,
exefile, MAX_PATH + 1, inifile)) { MAX_PATH + 1, inifile)) {
return FALSE; return FALSE;
} }
if (!GetPrivateProfileStringW(L"PostUpdateWin", L"ExeArg", nullptr, exearg, if (!GetPrivateProfileStringW(L"PostUpdateWin", L"ExeArg", NULL, exearg,
MAX_PATH + 1, inifile)) { MAX_PATH + 1, inifile)) {
return FALSE; return FALSE;
} }
@ -161,22 +161,22 @@ LaunchWinPostProcess(const WCHAR *installationDir,
ok = CreateProcessAsUserW(userToken, ok = CreateProcessAsUserW(userToken,
exefullpath, exefullpath,
cmdline, cmdline,
nullptr, // no special security attributes NULL, // no special security attributes
nullptr, // no special thread attributes NULL, // no special thread attributes
false, // don't inherit filehandles false, // don't inherit filehandles
0, // No special process creation flags 0, // No special process creation flags
nullptr, // inherit my environment NULL, // inherit my environment
workingDirectory, workingDirectory,
&si, &si,
&pi); &pi);
} else { } else {
ok = CreateProcessW(exefullpath, ok = CreateProcessW(exefullpath,
cmdline, cmdline,
nullptr, // no special security attributes NULL, // no special security attributes
nullptr, // no special thread attributes NULL, // no special thread attributes
false, // don't inherit filehandles false, // don't inherit filehandles
0, // No special process creation flags 0, // No special process creation flags
nullptr, // inherit my environment NULL, // inherit my environment
workingDirectory, workingDirectory,
&si, &si,
&pi); &pi);
@ -203,7 +203,7 @@ BOOL
StartServiceUpdate(LPCWSTR installDir) StartServiceUpdate(LPCWSTR installDir)
{ {
// Get a handle to the local computer SCM database // Get a handle to the local computer SCM database
SC_HANDLE manager = OpenSCManager(nullptr, nullptr, SC_HANDLE manager = OpenSCManager(NULL, NULL,
SC_MANAGER_ALL_ACCESS); SC_MANAGER_ALL_ACCESS);
if (!manager) { if (!manager) {
return FALSE; return FALSE;
@ -237,9 +237,9 @@ StartServiceUpdate(LPCWSTR installDir)
sizeof(cmdLine) / sizeof(cmdLine[0]) - 1); sizeof(cmdLine) / sizeof(cmdLine[0]) - 1);
BOOL svcUpdateProcessStarted = CreateProcessW(maintserviceInstallerPath, BOOL svcUpdateProcessStarted = CreateProcessW(maintserviceInstallerPath,
cmdLine, cmdLine,
nullptr, nullptr, FALSE, NULL, NULL, FALSE,
0, 0,
nullptr, installDir, &si, &pi); NULL, installDir, &si, &pi);
if (svcUpdateProcessStarted) { if (svcUpdateProcessStarted) {
CloseHandle(pi.hProcess); CloseHandle(pi.hProcess);
CloseHandle(pi.hThread); CloseHandle(pi.hThread);
@ -270,7 +270,7 @@ StartServiceCommand(int argc, LPCWSTR* argv)
} }
// Get a handle to the SCM database. // Get a handle to the SCM database.
SC_HANDLE serviceManager = OpenSCManager(nullptr, nullptr, SC_HANDLE serviceManager = OpenSCManager(NULL, NULL,
SC_MANAGER_CONNECT | SC_MANAGER_CONNECT |
SC_MANAGER_ENUMERATE_SERVICE); SC_MANAGER_ENUMERATE_SERVICE);
if (!serviceManager) { if (!serviceManager) {
@ -375,14 +375,14 @@ WriteStatusPending(LPCWSTR updateDirPath)
const char pending[] = "pending"; const char pending[] = "pending";
HANDLE statusFile = CreateFileW(updateStatusFilePath, GENERIC_WRITE, 0, HANDLE statusFile = CreateFileW(updateStatusFilePath, GENERIC_WRITE, 0,
nullptr, CREATE_ALWAYS, 0, nullptr); NULL, CREATE_ALWAYS, 0, NULL);
if (statusFile == INVALID_HANDLE_VALUE) { if (statusFile == INVALID_HANDLE_VALUE) {
return FALSE; return FALSE;
} }
DWORD wrote; DWORD wrote;
BOOL ok = WriteFile(statusFile, pending, BOOL ok = WriteFile(statusFile, pending,
sizeof(pending) - 1, &wrote, nullptr); sizeof(pending) - 1, &wrote, NULL);
CloseHandle(statusFile); CloseHandle(statusFile);
return ok && (wrote == sizeof(pending) - 1); return ok && (wrote == sizeof(pending) - 1);
} }
@ -403,7 +403,7 @@ WriteStatusFailure(LPCWSTR updateDirPath, int errorCode)
} }
HANDLE statusFile = CreateFileW(updateStatusFilePath, GENERIC_WRITE, 0, HANDLE statusFile = CreateFileW(updateStatusFilePath, GENERIC_WRITE, 0,
nullptr, CREATE_ALWAYS, 0, nullptr); NULL, CREATE_ALWAYS, 0, NULL);
if (statusFile == INVALID_HANDLE_VALUE) { if (statusFile == INVALID_HANDLE_VALUE) {
return FALSE; return FALSE;
} }
@ -413,7 +413,7 @@ WriteStatusFailure(LPCWSTR updateDirPath, int errorCode)
DWORD toWrite = strlen(failure); DWORD toWrite = strlen(failure);
DWORD wrote; DWORD wrote;
BOOL ok = WriteFile(statusFile, failure, BOOL ok = WriteFile(statusFile, failure,
toWrite, &wrote, nullptr); toWrite, &wrote, NULL);
CloseHandle(statusFile); CloseHandle(statusFile);
return ok && wrote == toWrite; return ok && wrote == toWrite;
} }
@ -459,7 +459,7 @@ WaitForServiceStop(LPCWSTR serviceName, DWORD maxWaitSeconds)
DWORD lastServiceState = 0x000000CF; DWORD lastServiceState = 0x000000CF;
// Get a handle to the SCM database. // Get a handle to the SCM database.
SC_HANDLE serviceManager = OpenSCManager(nullptr, nullptr, SC_HANDLE serviceManager = OpenSCManager(NULL, NULL,
SC_MANAGER_CONNECT | SC_MANAGER_CONNECT |
SC_MANAGER_ENUMERATE_SERVICE); SC_MANAGER_ENUMERATE_SERVICE);
if (!serviceManager) { if (!serviceManager) {
@ -674,7 +674,7 @@ static BOOL
GetDWORDValue(HKEY key, LPCWSTR valueName, DWORD &retValue) GetDWORDValue(HKEY key, LPCWSTR valueName, DWORD &retValue)
{ {
DWORD regDWORDValueSize = sizeof(DWORD); DWORD regDWORDValueSize = sizeof(DWORD);
LONG retCode = RegQueryValueExW(key, valueName, 0, nullptr, LONG retCode = RegQueryValueExW(key, valueName, 0, NULL,
reinterpret_cast<LPBYTE>(&retValue), reinterpret_cast<LPBYTE>(&retValue),
&regDWORDValueSize); &regDWORDValueSize);
return ERROR_SUCCESS == retCode; return ERROR_SUCCESS == retCode;
@ -736,7 +736,7 @@ IsUnpromptedElevation(BOOL &isUnpromptedElevation)
} }
DWORD len = aCharLength * sizeof(WCHAR); DWORD len = aCharLength * sizeof(WCHAR);
memset(aIDBuffer, 0, len); memset(aIDBuffer, 0, len);
if (RegQueryValueExW(key, L"AppUserModelID", nullptr, nullptr, if (RegQueryValueExW(key, L"AppUserModelID", NULL, NULL,
(LPBYTE)aIDBuffer, &len) != ERROR_SUCCESS || !len) { (LPBYTE)aIDBuffer, &len) != ERROR_SUCCESS || !len) {
RegCloseKey(key); RegCloseKey(key);
return false; return false;
@ -748,12 +748,12 @@ IsUnpromptedElevation(BOOL &isUnpromptedElevation)
HRESULT HRESULT
LaunchDefaultMetroBrowser() LaunchDefaultMetroBrowser()
{ {
CoInitialize(nullptr); CoInitialize(NULL);
HRESULT hr = E_FAIL; HRESULT hr = E_FAIL;
// The interface that allows us to activate the browser // The interface that allows us to activate the browser
IApplicationActivationManager *activateMgr; IApplicationActivationManager *activateMgr;
if (FAILED(hr = CoCreateInstance(CLSID_ApplicationActivationManager, if (FAILED(hr = CoCreateInstance(CLSID_ApplicationActivationManager, NULL,
nullptr, CLSCTX_LOCAL_SERVER, CLSCTX_LOCAL_SERVER,
IID_IApplicationActivationManager, IID_IApplicationActivationManager,
(void**)&activateMgr))) { (void**)&activateMgr))) {
CoUninitialize(); CoUninitialize();
@ -770,7 +770,7 @@ IsUnpromptedElevation(BOOL &isUnpromptedElevation)
// Hand off focus rights to the out-of-process activation server. Without // Hand off focus rights to the out-of-process activation server. Without
// this the metro interface won't launch. // this the metro interface won't launch.
CoAllowSetForegroundWindow(activateMgr, nullptr); CoAllowSetForegroundWindow(activateMgr, NULL);
// Launch default browser in Metro // Launch default browser in Metro
DWORD processID; DWORD processID;

View File

@ -14,7 +14,7 @@
#include "updatelogging.h" #include "updatelogging.h"
UpdateLog::UpdateLog() : logFP(nullptr) UpdateLog::UpdateLog() : logFP(NULL)
{ {
} }
@ -45,7 +45,7 @@ void UpdateLog::Finish()
return; return;
fclose(logFP); fclose(logFP);
logFP = nullptr; logFP = NULL;
} }
void UpdateLog::Flush() void UpdateLog::Flush()

View File

@ -52,7 +52,6 @@
# define LOG_S "%s" # define LOG_S "%s"
#endif #endif
#include "mozilla/NullPtr.h"
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -82,7 +81,7 @@ WriteMsg(const NS_tchar *path, const char *status)
fprintf(outFP, "%s\n", status); fprintf(outFP, "%s\n", status);
fclose(outFP); fclose(outFP);
outFP = nullptr; outFP = NULL;
} }
static bool static bool
@ -119,7 +118,7 @@ CheckMsg(const NS_tchar *path, const char *expected)
rb = mbuf; rb = mbuf;
fclose(inFP); fclose(inFP);
inFP = nullptr; inFP = NULL;
return strcmp(rb, expected) == 0; return strcmp(rb, expected) == 0;
} }
@ -143,21 +142,21 @@ VerifyCertificateTrustForFile(LPCWSTR filePath)
WINTRUST_DATA trustData; WINTRUST_DATA trustData;
ZeroMemory(&trustData, sizeof(trustData)); ZeroMemory(&trustData, sizeof(trustData));
trustData.cbStruct = sizeof(trustData); trustData.cbStruct = sizeof(trustData);
trustData.pPolicyCallbackData = nullptr; trustData.pPolicyCallbackData = NULL;
trustData.pSIPClientData = nullptr; trustData.pSIPClientData = NULL;
trustData.dwUIChoice = WTD_UI_NONE; trustData.dwUIChoice = WTD_UI_NONE;
trustData.fdwRevocationChecks = WTD_REVOKE_NONE; trustData.fdwRevocationChecks = WTD_REVOKE_NONE;
trustData.dwUnionChoice = WTD_CHOICE_FILE; trustData.dwUnionChoice = WTD_CHOICE_FILE;
trustData.dwStateAction = 0; trustData.dwStateAction = 0;
trustData.hWVTStateData = nullptr; trustData.hWVTStateData = NULL;
trustData.pwszURLReference = nullptr; trustData.pwszURLReference = NULL;
// no UI // no UI
trustData.dwUIContext = 0; trustData.dwUIContext = 0;
trustData.pFile = &fileToCheck; trustData.pFile = &fileToCheck;
GUID policyGUID = WINTRUST_ACTION_GENERIC_VERIFY_V2; GUID policyGUID = WINTRUST_ACTION_GENERIC_VERIFY_V2;
// Check if the file is signed by something that is trusted. // Check if the file is signed by something that is trusted.
return WinVerifyTrust(nullptr, &policyGUID, &trustData); return WinVerifyTrust(NULL, &policyGUID, &trustData);
} }
#endif #endif
@ -314,7 +313,7 @@ int NS_main(int argc, NS_tchar **argv)
// File in use test helper section // File in use test helper section
if (!NS_tstrcmp(argv[4], NS_T("-s"))) { if (!NS_tstrcmp(argv[4], NS_T("-s"))) {
NS_tchar *cwd = NS_tgetcwd(nullptr, 0); NS_tchar *cwd = NS_tgetcwd(NULL, 0);
NS_tchar inFilePath[MAXPATHLEN]; NS_tchar inFilePath[MAXPATHLEN];
NS_tsnprintf(inFilePath, sizeof(inFilePath)/sizeof(inFilePath[0]), NS_tsnprintf(inFilePath, sizeof(inFilePath)/sizeof(inFilePath[0]),
NS_T("%s/%s"), cwd, argv[2]); NS_T("%s/%s"), cwd, argv[2]);
@ -328,7 +327,7 @@ int NS_main(int argc, NS_tchar **argv)
if (argc == 7) { if (argc == 7) {
hFile = CreateFileW(argv[6], hFile = CreateFileW(argv[6],
DELETE | GENERIC_WRITE, 0, DELETE | GENERIC_WRITE, 0,
nullptr, OPEN_EXISTING, 0, nullptr); NULL, OPEN_EXISTING, 0, NULL);
if (hFile == INVALID_HANDLE_VALUE) { if (hFile == INVALID_HANDLE_VALUE) {
WriteMsg(outFilePath, "error_locking"); WriteMsg(outFilePath, "error_locking");
return 1; return 1;
@ -364,7 +363,7 @@ int NS_main(int argc, NS_tchar **argv)
} }
fclose(logFP); fclose(logFP);
logFP = nullptr; logFP = NULL;
return 0; return 0;
} }

View File

@ -27,8 +27,8 @@
static int inbuf_size = 262144; static int inbuf_size = 262144;
static int outbuf_size = 262144; static int outbuf_size = 262144;
static char *inbuf = nullptr; static char *inbuf = NULL;
static char *outbuf = nullptr; static char *outbuf = NULL;
#ifdef XP_WIN #ifdef XP_WIN
#include "resource.h" #include "resource.h"
@ -46,7 +46,7 @@ static char *outbuf = nullptr;
BOOL BOOL
LoadFileInResource(int name, int type, const uint8_t *&data, uint32_t& size) LoadFileInResource(int name, int type, const uint8_t *&data, uint32_t& size)
{ {
HMODULE handle = GetModuleHandle(nullptr); HMODULE handle = GetModuleHandle(NULL);
if (!handle) { if (!handle) {
return FALSE; return FALSE;
} }
@ -84,7 +84,7 @@ int
VerifyLoadedCert(MarFile *archive, int name, int type) VerifyLoadedCert(MarFile *archive, int name, int type)
{ {
uint32_t size = 0; uint32_t size = 0;
const uint8_t *data = nullptr; const uint8_t *data = NULL;
if (!LoadFileInResource(name, type, data, size) || !data || !size) { if (!LoadFileInResource(name, type, data, size) || !data || !size) {
return CERT_LOAD_ERROR; return CERT_LOAD_ERROR;
} }
@ -183,7 +183,7 @@ ArchiveReader::VerifyProductInformation(const char *MARChannelID,
rv = OK; rv = OK;
break; break;
} }
channel = strtok(nullptr, delimiter); channel = strtok(NULL, delimiter);
} }
} }
@ -253,17 +253,17 @@ ArchiveReader::Close()
{ {
if (mArchive) { if (mArchive) {
mar_close(mArchive); mar_close(mArchive);
mArchive = nullptr; mArchive = NULL;
} }
if (inbuf) { if (inbuf) {
free(inbuf); free(inbuf);
inbuf = nullptr; inbuf = NULL;
} }
if (outbuf) { if (outbuf) {
free(outbuf); free(outbuf);
outbuf = nullptr; outbuf = NULL;
} }
} }

View File

@ -7,7 +7,6 @@
#ifndef ArchiveReader_h__ #ifndef ArchiveReader_h__
#define ArchiveReader_h__ #define ArchiveReader_h__
#include "mozilla/NullPtr.h"
#include <stdio.h> #include <stdio.h>
#include "mar.h" #include "mar.h"
@ -21,7 +20,7 @@
class ArchiveReader class ArchiveReader
{ {
public: public:
ArchiveReader() : mArchive(nullptr) {} ArchiveReader() : mArchive(NULL) {}
~ArchiveReader() { Close(); } ~ArchiveReader() { Close(); }
int Open(const NS_tchar *path); int Open(const NS_tchar *path);

View File

@ -29,7 +29,7 @@
const char *kGonkMountsPath = "/proc/mounts"; const char *kGonkMountsPath = "/proc/mounts";
const char *kGonkSystemPath = "/system"; const char *kGonkSystemPath = "/system";
GonkAutoMounter::GonkAutoMounter() : mDevice(nullptr), mAccess(Unknown) GonkAutoMounter::GonkAutoMounter() : mDevice(NULL), mAccess(Unknown)
{ {
if (!RemountSystem(ReadWrite)) { if (!RemountSystem(ReadWrite)) {
LOGE("Could not remount %s as read-write.", kGonkSystemPath); LOGE("Could not remount %s as read-write.", kGonkSystemPath);
@ -58,7 +58,7 @@ GonkAutoMounter::Reboot()
kGonkSystemPath); kGonkSystemPath);
LogFlush(); LogFlush();
if (android_reboot(ANDROID_RB_RESTART, 0, nullptr) != 0) { if (android_reboot(ANDROID_RB_RESTART, 0, NULL) != 0) {
LOGE("Safe system reboot failed, attempting to force"); LOGE("Safe system reboot failed, attempting to force");
LogFlush(); LogFlush();
@ -120,7 +120,7 @@ GonkAutoMounter::UpdateMountStatus()
{ {
FILE *mountsFile = NS_tfopen(kGonkMountsPath, "r"); FILE *mountsFile = NS_tfopen(kGonkMountsPath, "r");
if (mountsFile == nullptr) { if (mountsFile == NULL) {
LOGE("Error opening %s: %s", kGonkMountsPath, strerror(errno)); LOGE("Error opening %s: %s", kGonkMountsPath, strerror(errno));
return false; return false;
} }
@ -143,7 +143,7 @@ GonkAutoMounter::UpdateMountStatus()
for (token = strtok_r(mountData, "\n", &tokenContext); for (token = strtok_r(mountData, "\n", &tokenContext);
token; token;
token = strtok_r(nullptr, "\n", &tokenContext)) token = strtok_r(NULL, "\n", &tokenContext))
{ {
if (ProcessMount(token)) { if (ProcessMount(token)) {
foundSystem = true; foundSystem = true;
@ -188,7 +188,7 @@ GonkAutoMounter::ProcessMount(const char *mount)
char *option, *optionContext; char *option, *optionContext;
for (option = strtok_r(mountAccess, ",", &optionContext); for (option = strtok_r(mountAccess, ",", &optionContext);
option; option;
option = strtok_r(nullptr, ",", &optionContext)) option = strtok_r(NULL, ",", &optionContext))
{ {
if (strcmp("ro", option) == 0) { if (strcmp("ro", option) == 0) {
mAccess = ReadOnly; mAccess = ReadOnly;
@ -211,7 +211,7 @@ GonkAutoMounter::MountSystem(unsigned long flags)
} }
const char *readOnly = flags & MS_RDONLY ? "read-only" : "read-write"; const char *readOnly = flags & MS_RDONLY ? "read-only" : "read-write";
int result = mount(mDevice, kGonkSystemPath, "none", flags, nullptr); int result = mount(mDevice, kGonkSystemPath, "none", flags, NULL);
if (result != 0) { if (result != 0) {
LOGE("Error mounting %s as %s: %s", kGonkSystemPath, readOnly, LOGE("Error mounting %s as %s: %s", kGonkSystemPath, readOnly,

View File

@ -36,7 +36,7 @@ struct AutoLoadSystemDependencies
if (systemDirectory[systemDirLen - 1] != L'\\' && systemDirLen) { if (systemDirectory[systemDirLen - 1] != L'\\' && systemDirLen) {
systemDirectory[systemDirLen] = L'\\'; systemDirectory[systemDirLen] = L'\\';
++systemDirLen; ++systemDirLen;
// No need to re-null terminate // No need to re-NULL terminate
} }
// For each known DLL ensure it is loaded from the system32 directory // For each known DLL ensure it is loaded from the system32 directory

View File

@ -86,7 +86,7 @@ ShowProgressUI()
snprintf(icon_path, sizeof(icon_path), "%s.png", sProgramPath); snprintf(icon_path, sizeof(icon_path), "%s.png", sProgramPath);
g_signal_connect(G_OBJECT(sWin), "delete_event", g_signal_connect(G_OBJECT(sWin), "delete_event",
G_CALLBACK(OnDeleteEvent), nullptr); G_CALLBACK(OnDeleteEvent), NULL);
gtk_window_set_title(GTK_WINDOW(sWin), strings.title); gtk_window_set_title(GTK_WINDOW(sWin), strings.title);
gtk_window_set_type_hint(GTK_WINDOW(sWin), GDK_WINDOW_TYPE_HINT_DIALOG); gtk_window_set_type_hint(GTK_WINDOW(sWin), GDK_WINDOW_TYPE_HINT_DIALOG);
@ -94,7 +94,7 @@ ShowProgressUI()
gtk_window_set_resizable(GTK_WINDOW(sWin), FALSE); gtk_window_set_resizable(GTK_WINDOW(sWin), FALSE);
gtk_window_set_decorated(GTK_WINDOW(sWin), TRUE); gtk_window_set_decorated(GTK_WINDOW(sWin), TRUE);
gtk_window_set_deletable(GTK_WINDOW(sWin),FALSE); gtk_window_set_deletable(GTK_WINDOW(sWin),FALSE);
pixbuf = gdk_pixbuf_new_from_file (icon_path, nullptr); pixbuf = gdk_pixbuf_new_from_file (icon_path, NULL);
gtk_window_set_icon(GTK_WINDOW(sWin), pixbuf); gtk_window_set_icon(GTK_WINDOW(sWin), pixbuf);
g_object_unref(pixbuf); g_object_unref(pixbuf);
@ -106,7 +106,7 @@ ShowProgressUI()
gtk_box_pack_start(GTK_BOX(vbox), sLabel, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), sLabel, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), sProgressBar, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox), sProgressBar, TRUE, TRUE, 0);
sTimerID = g_timeout_add(TIMER_INTERVAL, UpdateDialog, nullptr); sTimerID = g_timeout_add(TIMER_INTERVAL, UpdateDialog, NULL);
gtk_container_set_border_width(GTK_CONTAINER(sWin), 10); gtk_container_set_border_width(GTK_CONTAINER(sWin), 10);
gtk_container_add(GTK_CONTAINER(sWin), vbox); gtk_container_add(GTK_CONTAINER(sWin), vbox);

View File

@ -47,7 +47,7 @@ static StringTable sUIStrings;
static BOOL static BOOL
GetStringsFile(WCHAR filename[MAX_PATH]) GetStringsFile(WCHAR filename[MAX_PATH])
{ {
if (!GetModuleFileNameW(nullptr, filename, MAX_PATH)) if (!GetModuleFileNameW(NULL, filename, MAX_PATH))
return FALSE; return FALSE;
WCHAR *dot = wcsrchr(filename, '.'); WCHAR *dot = wcsrchr(filename, '.');
@ -115,8 +115,7 @@ InitDialog(HWND hDlg)
SetWindowTextW(GetDlgItem(hDlg, IDC_INFO), szwInfo); SetWindowTextW(GetDlgItem(hDlg, IDC_INFO), szwInfo);
// Set dialog icon // Set dialog icon
HICON hIcon = LoadIcon(GetModuleHandle(nullptr), HICON hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_DIALOG));
MAKEINTRESOURCE(IDI_DIALOG));
if (hIcon) if (hIcon)
SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM) hIcon); SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM) hIcon);
@ -172,7 +171,7 @@ InitDialog(HWND hDlg)
CenterDialog(hDlg); // make dialog appear in the center of the screen CenterDialog(hDlg); // make dialog appear in the center of the screen
SetTimer(hDlg, TIMER_ID, TIMER_INTERVAL, nullptr); SetTimer(hDlg, TIMER_ID, TIMER_INTERVAL, NULL);
} }
// Message handler for update dialog. // Message handler for update dialog.
@ -255,8 +254,8 @@ ShowProgressUI(bool indeterminate, bool initUIStrings)
}; };
InitCommonControlsEx(&icc); InitCommonControlsEx(&icc);
DialogBox(GetModuleHandle(nullptr), DialogBox(GetModuleHandle(NULL),
MAKEINTRESOURCE(IDD_DIALOG), nullptr, MAKEINTRESOURCE(IDD_DIALOG), NULL,
(DLGPROC) DialogProc); (DLGPROC) DialogProc);
return 0; return 0;

View File

@ -161,12 +161,12 @@ crc32(const unsigned char *buf, unsigned int len)
class AutoFile class AutoFile
{ {
public: public:
AutoFile(FILE* file = nullptr) AutoFile(FILE* file = NULL)
: mFile(file) { : mFile(file) {
} }
~AutoFile() { ~AutoFile() {
if (mFile != nullptr) if (mFile != NULL)
fclose(mFile); fclose(mFile);
} }
@ -215,8 +215,7 @@ public:
unsigned int threadID; unsigned int threadID;
mThread = (HANDLE) _beginthreadex(nullptr, 0, ThreadMain, this, 0, mThread = (HANDLE) _beginthreadex(NULL, 0, ThreadMain, this, 0, &threadID);
&threadID);
return mThread ? 0 : -1; return mThread ? 0 : -1;
} }
@ -246,7 +245,7 @@ class Thread
public: public:
int Run(ThreadFunc func, void *param) int Run(ThreadFunc func, void *param)
{ {
return pthread_create(&thr, nullptr, (void* (*)(void *)) func, param); return pthread_create(&thr, NULL, (void* (*)(void *)) func, param);
} }
int Join() int Join()
{ {
@ -267,7 +266,7 @@ public:
mThreadFunc = func; mThreadFunc = func;
mThreadParam = param; mThreadParam = param;
mThread = _beginthread(ThreadMain, nullptr, 16384, (void *)this); mThread = _beginthread(ThreadMain, NULL, 16384, (void *)this);
return mThread ? 0 : -1; return mThread ? 0 : -1;
} }
@ -324,7 +323,7 @@ static NS_tchar*
mstrtok(const NS_tchar *delims, NS_tchar **str) mstrtok(const NS_tchar *delims, NS_tchar **str)
{ {
if (!*str || !**str) if (!*str || !**str)
return nullptr; return NULL;
// skip leading "whitespace" // skip leading "whitespace"
NS_tchar *ret = *str; NS_tchar *ret = *str;
@ -340,7 +339,7 @@ mstrtok(const NS_tchar *delims, NS_tchar **str)
if (!*ret) { if (!*ret) {
*str = ret; *str = ret;
return nullptr; return NULL;
} }
NS_tchar *i = ret; NS_tchar *i = ret;
@ -355,7 +354,7 @@ mstrtok(const NS_tchar *delims, NS_tchar **str)
++i; ++i;
} while (*i); } while (*i);
*str = nullptr; *str = NULL;
return ret; return ret;
} }
@ -365,7 +364,7 @@ mstrtok(const NS_tchar *delims, NS_tchar **str)
* *
* @param relpath * @param relpath
* The relative path to convert to a full path. * The relative path to convert to a full path.
* @return valid filesystem full path or nullptr if memory allocation fails. * @return valid filesystem full path or NULL memory allocation fails.
*/ */
static NS_tchar* static NS_tchar*
get_full_path(const NS_tchar *relpath) get_full_path(const NS_tchar *relpath)
@ -374,7 +373,7 @@ get_full_path(const NS_tchar *relpath)
size_t lenrelpath = NS_tstrlen(relpath); size_t lenrelpath = NS_tstrlen(relpath);
NS_tchar *s = (NS_tchar *) malloc((lendestpath + lenrelpath + 1) * sizeof(NS_tchar)); NS_tchar *s = (NS_tchar *) malloc((lendestpath + lenrelpath + 1) * sizeof(NS_tchar));
if (!s) if (!s)
return nullptr; return NULL;
NS_tchar *c = s; NS_tchar *c = s;
@ -390,13 +389,13 @@ get_full_path(const NS_tchar *relpath)
/** /**
* Gets the platform specific path and performs simple checks to the path. If * Gets the platform specific path and performs simple checks to the path. If
* the path checks don't pass nullptr will be returned. * the path checks don't pass NULL will be returned.
* *
* @param line * @param line
* The line from the manifest that contains the path. * The line from the manifest that contains the path.
* @param isdir * @param isdir
* Whether the path is a directory path. Defaults to false. * Whether the path is a directory path. Defaults to false.
* @return valid filesystem path or nullptr if the path checks fail. * @return valid filesystem path or NULL if the path checks fail.
*/ */
static NS_tchar* static NS_tchar*
get_valid_path(NS_tchar **line, bool isdir = false) get_valid_path(NS_tchar **line, bool isdir = false)
@ -404,20 +403,20 @@ get_valid_path(NS_tchar **line, bool isdir = false)
NS_tchar *path = mstrtok(kQuote, line); NS_tchar *path = mstrtok(kQuote, line);
if (!path) { if (!path) {
LOG(("get_valid_path: unable to determine path: " LOG_S, line)); LOG(("get_valid_path: unable to determine path: " LOG_S, line));
return nullptr; return NULL;
} }
// All paths must be relative from the current working directory // All paths must be relative from the current working directory
if (path[0] == NS_T('/')) { if (path[0] == NS_T('/')) {
LOG(("get_valid_path: path must be relative: " LOG_S, path)); LOG(("get_valid_path: path must be relative: " LOG_S, path));
return nullptr; return NULL;
} }
#ifdef XP_WIN #ifdef XP_WIN
// All paths must be relative from the current working directory // All paths must be relative from the current working directory
if (path[0] == NS_T('\\') || path[1] == NS_T(':')) { if (path[0] == NS_T('\\') || path[1] == NS_T(':')) {
LOG(("get_valid_path: path must be relative: " LOG_S, path)); LOG(("get_valid_path: path must be relative: " LOG_S, path));
return nullptr; return NULL;
} }
#endif #endif
@ -426,7 +425,7 @@ get_valid_path(NS_tchar **line, bool isdir = false)
if (path[NS_tstrlen(path) - 1] != NS_T('/')) { if (path[NS_tstrlen(path) - 1] != NS_T('/')) {
LOG(("get_valid_path: directory paths must have a trailing forward " \ LOG(("get_valid_path: directory paths must have a trailing forward " \
"slash: " LOG_S, path)); "slash: " LOG_S, path));
return nullptr; return NULL;
} }
// Remove the trailing forward slash because stat on Windows will return // Remove the trailing forward slash because stat on Windows will return
@ -435,9 +434,9 @@ get_valid_path(NS_tchar **line, bool isdir = false)
} }
// Don't allow relative paths that resolve to a parent directory. // Don't allow relative paths that resolve to a parent directory.
if (NS_tstrstr(path, NS_T("..")) != nullptr) { if (NS_tstrstr(path, NS_T("..")) != NULL) {
LOG(("get_valid_path: paths must not contain '..': " LOG_S, path)); LOG(("get_valid_path: paths must not contain '..': " LOG_S, path));
return nullptr; return NULL;
} }
return path; return path;
@ -452,7 +451,7 @@ get_quoted_path(const NS_tchar *path)
NS_tchar *s = (NS_tchar *) malloc(len * sizeof(NS_tchar)); NS_tchar *s = (NS_tchar *) malloc(len * sizeof(NS_tchar));
if (!s) if (!s)
return nullptr; return NULL;
NS_tchar *c = s; NS_tchar *c = s;
NS_tstrcpy(c, kQuote); NS_tstrcpy(c, kQuote);
@ -570,17 +569,17 @@ static FILE* ensure_open(const NS_tchar *path, const NS_tchar *flags, unsigned i
return f; return f;
} }
if (NS_tchmod(path, options) != 0) { if (NS_tchmod(path, options) != 0) {
if (f != nullptr) { if (f != NULL) {
fclose(f); fclose(f);
} }
return nullptr; return NULL;
} }
struct stat ss; struct stat ss;
if (NS_tstat(path, &ss) != 0 || ss.st_mode != options) { if (NS_tstat(path, &ss) != 0 || ss.st_mode != options) {
if (f != nullptr) { if (f != NULL) {
fclose(f); fclose(f);
} }
return nullptr; return NULL;
} }
return f; return f;
} }
@ -920,7 +919,7 @@ static int backup_discard(const NS_tchar *path)
// but this is ok since the installer / uninstaller will delete the // but this is ok since the installer / uninstaller will delete the
// directory containing the file along with its contents after an update is // directory containing the file along with its contents after an update is
// applied, on reinstall, and on uninstall. // applied, on reinstall, and on uninstall.
if (MoveFileEx(path, nullptr, MOVEFILE_DELAY_UNTIL_REBOOT)) { if (MoveFileEx(path, NULL, MOVEFILE_DELAY_UNTIL_REBOOT)) {
LOG(("backup_discard: file renamed and will be removed on OS " \ LOG(("backup_discard: file renamed and will be removed on OS " \
"reboot: " LOG_S, path)); "reboot: " LOG_S, path));
} else { } else {
@ -952,7 +951,7 @@ static int DoUpdate();
class Action class Action
{ {
public: public:
Action() : mProgressCost(1), mNext(nullptr) { } Action() : mProgressCost(1), mNext(NULL) { }
virtual ~Action() { } virtual ~Action() { }
virtual int Parse(NS_tchar *line) = 0; virtual int Parse(NS_tchar *line) = 0;
@ -980,7 +979,7 @@ private:
class RemoveFile : public Action class RemoveFile : public Action
{ {
public: public:
RemoveFile() : mFile(nullptr), mSkip(0) { } RemoveFile() : mFile(NULL), mSkip(0) { }
int Parse(NS_tchar *line); int Parse(NS_tchar *line);
int Prepare(); int Prepare();
@ -1089,7 +1088,7 @@ RemoveFile::Finish(int status)
class RemoveDir : public Action class RemoveDir : public Action
{ {
public: public:
RemoveDir() : mDir(nullptr), mSkip(0) { } RemoveDir() : mDir(NULL), mSkip(0) { }
virtual int Parse(NS_tchar *line); virtual int Parse(NS_tchar *line);
virtual int Prepare(); // check that the source dir exists virtual int Prepare(); // check that the source dir exists
@ -1196,7 +1195,7 @@ RemoveDir::Finish(int status)
class AddFile : public Action class AddFile : public Action
{ {
public: public:
AddFile() : mFile(nullptr) AddFile() : mFile(NULL)
, mAdded(false) , mAdded(false)
{ } { }
@ -1252,7 +1251,7 @@ AddFile::Execute()
#ifdef XP_WIN #ifdef XP_WIN
char sourcefile[MAXPATHLEN]; char sourcefile[MAXPATHLEN];
if (!WideCharToMultiByte(CP_UTF8, 0, mFile, -1, sourcefile, MAXPATHLEN, if (!WideCharToMultiByte(CP_UTF8, 0, mFile, -1, sourcefile, MAXPATHLEN,
nullptr, nullptr)) { NULL, NULL)) {
LOG(("error converting wchar to utf8: %d", GetLastError())); LOG(("error converting wchar to utf8: %d", GetLastError()));
return STRING_CONVERSION_ERROR; return STRING_CONVERSION_ERROR;
} }
@ -1281,7 +1280,7 @@ AddFile::Finish(int status)
class PatchFile : public Action class PatchFile : public Action
{ {
public: public:
PatchFile() : mPatchIndex(-1), buf(nullptr) { } PatchFile() : mPatchIndex(-1), buf(NULL) { }
virtual ~PatchFile(); virtual ~PatchFile();
@ -1406,7 +1405,7 @@ PatchFile::Prepare()
#ifdef XP_WIN #ifdef XP_WIN
char sourcefile[MAXPATHLEN]; char sourcefile[MAXPATHLEN];
if (!WideCharToMultiByte(CP_UTF8, 0, mPatchFile, -1, sourcefile, MAXPATHLEN, if (!WideCharToMultiByte(CP_UTF8, 0, mPatchFile, -1, sourcefile, MAXPATHLEN,
nullptr, nullptr)) { NULL, NULL)) {
LOG(("error converting wchar to utf8: %d", GetLastError())); LOG(("error converting wchar to utf8: %d", GetLastError()));
return STRING_CONVERSION_ERROR; return STRING_CONVERSION_ERROR;
} }
@ -1425,14 +1424,14 @@ PatchFile::Execute()
LOG(("EXECUTE PATCH " LOG_S, mFile)); LOG(("EXECUTE PATCH " LOG_S, mFile));
AutoFile pfile = NS_tfopen(spath, NS_T("rb")); AutoFile pfile = NS_tfopen(spath, NS_T("rb"));
if (pfile == nullptr) if (pfile == NULL)
return READ_ERROR; return READ_ERROR;
int rv = MBS_ReadHeader(pfile, &header); int rv = MBS_ReadHeader(pfile, &header);
if (rv) if (rv)
return rv; return rv;
FILE *origfile = nullptr; FILE *origfile = NULL;
#ifdef XP_WIN #ifdef XP_WIN
if (NS_tstrcmp(mFile, gCallbackRelPath) == 0) { if (NS_tstrcmp(mFile, gCallbackRelPath) == 0) {
// Read from the copy of the callback when patching since the callback can't // Read from the copy of the callback when patching since the callback can't
@ -1487,14 +1486,13 @@ PatchFile::Execute()
HANDLE hfile = CreateFileW(mFile, HANDLE hfile = CreateFileW(mFile,
GENERIC_WRITE, GENERIC_WRITE,
0, 0,
nullptr, NULL,
CREATE_ALWAYS, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, FILE_ATTRIBUTE_NORMAL,
nullptr); NULL);
if (hfile != INVALID_HANDLE_VALUE) { if (hfile != INVALID_HANDLE_VALUE) {
if (SetFilePointer(hfile, header.dlen, if (SetFilePointer(hfile, header.dlen, NULL, FILE_BEGIN) != INVALID_SET_FILE_POINTER &&
nullptr, FILE_BEGIN) != INVALID_SET_FILE_POINTER &&
SetEndOfFile(hfile) != 0) { SetEndOfFile(hfile) != 0) {
shouldTruncate = false; shouldTruncate = false;
} }
@ -1521,7 +1519,7 @@ PatchFile::Execute()
AutoFile ofile = ensure_open(mFile, NS_T("wb+"), ss.st_mode); AutoFile ofile = ensure_open(mFile, NS_T("wb+"), ss.st_mode);
#endif #endif
if (ofile == nullptr) { if (ofile == NULL) {
LOG(("unable to create new file: " LOG_S ", err: %d", mFile, errno)); LOG(("unable to create new file: " LOG_S ", err: %d", mFile, errno));
return WRITE_ERROR; return WRITE_ERROR;
} }
@ -1535,13 +1533,13 @@ PatchFile::Execute()
rv = MBS_ApplyPatch(&header, pfile, buf, ofile); rv = MBS_ApplyPatch(&header, pfile, buf, ofile);
// Go ahead and do a bit of cleanup now to minimize runtime overhead. // Go ahead and do a bit of cleanup now to minimize runtime overhead.
// Set pfile to nullptr to make AutoFile close the file so it can be deleted // Set pfile to NULL to make AutoFile close the file so it can be deleted on
// on Windows. // Windows.
pfile = nullptr; pfile = NULL;
NS_tremove(spath); NS_tremove(spath);
spath[0] = NS_T('\0'); spath[0] = NS_T('\0');
free(buf); free(buf);
buf = nullptr; buf = NULL;
return rv; return rv;
} }
@ -1557,7 +1555,7 @@ PatchFile::Finish(int status)
class AddIfFile : public AddFile class AddIfFile : public AddFile
{ {
public: public:
AddIfFile() : mTestFile(nullptr) { } AddIfFile() : mTestFile(NULL) { }
virtual int Parse(NS_tchar *line); virtual int Parse(NS_tchar *line);
virtual int Prepare(); virtual int Prepare();
@ -1590,7 +1588,7 @@ AddIfFile::Prepare()
{ {
// If the test file does not exist, then skip this action. // If the test file does not exist, then skip this action.
if (NS_taccess(mTestFile, F_OK)) { if (NS_taccess(mTestFile, F_OK)) {
mTestFile = nullptr; mTestFile = NULL;
return OK; return OK;
} }
@ -1618,7 +1616,7 @@ AddIfFile::Finish(int status)
class PatchIfFile : public PatchFile class PatchIfFile : public PatchFile
{ {
public: public:
PatchIfFile() : mTestFile(nullptr) { } PatchIfFile() : mTestFile(NULL) { }
virtual int Parse(NS_tchar *line); virtual int Parse(NS_tchar *line);
virtual int Prepare(); // should check for patch file and for checksum here virtual int Prepare(); // should check for patch file and for checksum here
@ -1651,7 +1649,7 @@ PatchIfFile::Prepare()
{ {
// If the test file does not exist, then skip this action. // If the test file does not exist, then skip this action.
if (NS_taccess(mTestFile, F_OK)) { if (NS_taccess(mTestFile, F_OK)) {
mTestFile = nullptr; mTestFile = NULL;
return OK; return OK;
} }
@ -1734,7 +1732,7 @@ LaunchCallbackApp(const NS_tchar *workingDir,
return; return;
} }
#endif #endif
WinLaunchChild(argv[0], argc, argv, nullptr); WinLaunchChild(argv[0], argc, argv, NULL);
} }
#else #else
# warning "Need implementaton of LaunchCallbackApp" # warning "Need implementaton of LaunchCallbackApp"
@ -1753,7 +1751,7 @@ WriteStatusFile(const char* aStatus)
return false; return false;
AutoFile file = NS_tfopen(filename, NS_T("wb+")); AutoFile file = NS_tfopen(filename, NS_T("wb+"));
if (file == nullptr) if (file == NULL)
return false; return false;
if (fwrite(aStatus, strlen(aStatus), 1, file) != 1) if (fwrite(aStatus, strlen(aStatus), 1, file) != 1)
@ -1800,7 +1798,7 @@ IsUpdateStatusPendingService()
NS_T("%s/update.status"), gSourcePath); NS_T("%s/update.status"), gSourcePath);
AutoFile file = NS_tfopen(filename, NS_T("rb")); AutoFile file = NS_tfopen(filename, NS_T("rb"));
if (file == nullptr) if (file == NULL)
return false; return false;
char buf[32] = { 0 }; char buf[32] = { 0 };
@ -1834,7 +1832,7 @@ IsUpdateStatusSucceeded(bool &isSucceeded)
NS_T("%s/update.status"), gSourcePath); NS_T("%s/update.status"), gSourcePath);
AutoFile file = NS_tfopen(filename, NS_T("rb")); AutoFile file = NS_tfopen(filename, NS_T("rb"));
if (file == nullptr) if (file == NULL)
return false; return false;
char buf[32] = { 0 }; char buf[32] = { 0 };
@ -2013,7 +2011,7 @@ ProcessReplaceRequest()
if (rv) { if (rv) {
LOG(("Removing tmpDir failed, err: %d", rv)); LOG(("Removing tmpDir failed, err: %d", rv));
#ifdef XP_WIN #ifdef XP_WIN
if (MoveFileExW(tmpDir, nullptr, MOVEFILE_DELAY_UNTIL_REBOOT)) { if (MoveFileExW(tmpDir, NULL, MOVEFILE_DELAY_UNTIL_REBOOT)) {
LOG(("tmpDir will be removed on OS reboot: " LOG_S, tmpDir)); LOG(("tmpDir will be removed on OS reboot: " LOG_S, tmpDir));
} else { } else {
LOG(("Failed to schedule OS reboot removal of directory: " LOG_S, LOG(("Failed to schedule OS reboot removal of directory: " LOG_S,
@ -2146,7 +2144,7 @@ GetUpdateFileName(NS_tchar *fileName, int maxChars)
NS_tsnprintf(linkFileName, sizeof(linkFileName)/sizeof(linkFileName[0]), NS_tsnprintf(linkFileName, sizeof(linkFileName)/sizeof(linkFileName[0]),
NS_T("%s/update.link"), gSourcePath); NS_T("%s/update.link"), gSourcePath);
AutoFile linkFile = NS_tfopen(linkFileName, NS_T("rb")); AutoFile linkFile = NS_tfopen(linkFileName, NS_T("rb"));
if (linkFile == nullptr) { if (linkFile == NULL) {
NS_tsnprintf(fileName, maxChars, NS_tsnprintf(fileName, maxChars,
NS_T("%s/update.mar"), gSourcePath); NS_T("%s/update.mar"), gSourcePath);
return OK; return OK;
@ -2277,9 +2275,9 @@ UpdateThreadFunc(void *param)
// on the top-level Mac OS X bundle directory so that Mac OS X's // on the top-level Mac OS X bundle directory so that Mac OS X's
// Launch Services picks up any major changes. Here we assume that // Launch Services picks up any major changes. Here we assume that
// the current working directory is the top-level bundle directory. // the current working directory is the top-level bundle directory.
char* cwd = getcwd(nullptr, 0); char* cwd = getcwd(NULL, 0);
if (cwd) { if (cwd) {
if (utimes(cwd, nullptr) != 0) { if (utimes(cwd, NULL) != 0) {
LOG(("Couldn't set access/modification time on application bundle.")); LOG(("Couldn't set access/modification time on application bundle."));
} }
free(cwd); free(cwd);
@ -2353,7 +2351,7 @@ int NS_main(int argc, NS_tchar **argv)
#ifdef XP_WIN #ifdef XP_WIN
bool useService = false; bool useService = false;
bool testOnlyFallbackKeyExists = false; bool testOnlyFallbackKeyExists = false;
bool noServiceFallback = getenv("MOZ_NO_SERVICE_FALLBACK") != nullptr; bool noServiceFallback = getenv("MOZ_NO_SERVICE_FALLBACK") != NULL;
putenv(const_cast<char*>("MOZ_NO_SERVICE_FALLBACK=")); putenv(const_cast<char*>("MOZ_NO_SERVICE_FALLBACK="));
// We never want the service to be used unless we build with // We never want the service to be used unless we build with
@ -2370,13 +2368,13 @@ int NS_main(int argc, NS_tchar **argv)
{ {
HKEY hkApp; HKEY hkApp;
RegCreateKeyExW(HKEY_CURRENT_USER, L"Software\\Classes\\Applications", RegCreateKeyExW(HKEY_CURRENT_USER, L"Software\\Classes\\Applications",
0, nullptr, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, nullptr, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL,
&hkApp, nullptr); &hkApp, NULL);
RegCloseKey(hkApp); RegCloseKey(hkApp);
if (RegCreateKeyExW(HKEY_CURRENT_USER, if (RegCreateKeyExW(HKEY_CURRENT_USER,
L"Software\\Classes\\Applications\\updater.exe", L"Software\\Classes\\Applications\\updater.exe",
0, nullptr, REG_OPTION_VOLATILE, KEY_SET_VALUE, nullptr, 0, NULL, REG_OPTION_VOLATILE, KEY_SET_VALUE, NULL,
&hkApp, nullptr) == ERROR_SUCCESS) { &hkApp, NULL) == ERROR_SUCCESS) {
RegSetValueExW(hkApp, L"IsHostApp", 0, REG_NONE, 0, 0); RegSetValueExW(hkApp, L"IsHostApp", 0, REG_NONE, 0, 0);
RegSetValueExW(hkApp, L"NoOpenWith", 0, REG_NONE, 0, 0); RegSetValueExW(hkApp, L"NoOpenWith", 0, REG_NONE, 0, 0);
RegSetValueExW(hkApp, L"NoStartPage", 0, REG_NONE, 0, 0); RegSetValueExW(hkApp, L"NoStartPage", 0, REG_NONE, 0, 0);
@ -2483,7 +2481,7 @@ int NS_main(int argc, NS_tchar **argv)
#ifdef XP_WIN #ifdef XP_WIN
if (pid > 0) { if (pid > 0) {
HANDLE parent = OpenProcess(SYNCHRONIZE, false, (DWORD) pid); HANDLE parent = OpenProcess(SYNCHRONIZE, false, (DWORD) pid);
// May return nullptr if the parent process has already gone away. // May return NULL if the parent process has already gone away.
// Otherwise, wait for the parent process to exit before starting the // Otherwise, wait for the parent process to exit before starting the
// update. // update.
if (parent) { if (parent) {
@ -2501,7 +2499,7 @@ int NS_main(int argc, NS_tchar **argv)
} }
#else #else
if (pid > 0) if (pid > 0)
waitpid(pid, nullptr, 0); waitpid(pid, NULL, 0);
#endif #endif
if (sReplaceRequest) { if (sReplaceRequest) {
@ -2521,7 +2519,7 @@ int NS_main(int argc, NS_tchar **argv)
const int callbackIndex = 5; const int callbackIndex = 5;
#if defined(XP_WIN) #if defined(XP_WIN)
sUsingService = getenv("MOZ_USING_SERVICE") != nullptr; sUsingService = getenv("MOZ_USING_SERVICE") != NULL;
putenv(const_cast<char*>("MOZ_USING_SERVICE=")); putenv(const_cast<char*>("MOZ_USING_SERVICE="));
// lastFallbackError keeps track of the last error for the service not being // lastFallbackError keeps track of the last error for the service not being
// used, in case of an error when fallback is not enabled we write the // used, in case of an error when fallback is not enabled we write the
@ -2582,10 +2580,10 @@ int NS_main(int argc, NS_tchar **argv)
updateLockFileHandle = CreateFileW(updateLockFilePath, updateLockFileHandle = CreateFileW(updateLockFilePath,
GENERIC_READ | GENERIC_WRITE, GENERIC_READ | GENERIC_WRITE,
0, 0,
nullptr, NULL,
OPEN_ALWAYS, OPEN_ALWAYS,
FILE_FLAG_DELETE_ON_CLOSE, FILE_FLAG_DELETE_ON_CLOSE,
nullptr); NULL);
NS_tsnprintf(elevatedLockFilePath, NS_tsnprintf(elevatedLockFilePath,
sizeof(elevatedLockFilePath)/sizeof(elevatedLockFilePath[0]), sizeof(elevatedLockFilePath)/sizeof(elevatedLockFilePath[0]),
@ -2605,7 +2603,7 @@ int NS_main(int argc, NS_tchar **argv)
if(startedFromUnelevatedUpdater) { if(startedFromUnelevatedUpdater) {
// Disable every privilege we don't need. Processes started using // Disable every privilege we don't need. Processes started using
// CreateProcess will use the same token as this process. // CreateProcess will use the same token as this process.
UACHelper::DisablePrivileges(nullptr); UACHelper::DisablePrivileges(NULL);
} }
if (updateLockFileHandle == INVALID_HANDLE_VALUE || if (updateLockFileHandle == INVALID_HANDLE_VALUE ||
@ -2620,10 +2618,10 @@ int NS_main(int argc, NS_tchar **argv)
elevatedFileHandle = CreateFileW(elevatedLockFilePath, elevatedFileHandle = CreateFileW(elevatedLockFilePath,
GENERIC_READ | GENERIC_WRITE, GENERIC_READ | GENERIC_WRITE,
0, 0,
nullptr, NULL,
OPEN_ALWAYS, OPEN_ALWAYS,
FILE_FLAG_DELETE_ON_CLOSE, FILE_FLAG_DELETE_ON_CLOSE,
nullptr); NULL);
if (elevatedFileHandle == INVALID_HANDLE_VALUE) { if (elevatedFileHandle == INVALID_HANDLE_VALUE) {
LOG(("Unable to create elevated lock file! Exiting")); LOG(("Unable to create elevated lock file! Exiting"));
@ -2714,7 +2712,7 @@ int NS_main(int argc, NS_tchar **argv)
DWORD lastState = WaitForServiceStop(SVC_NAME, 5); DWORD lastState = WaitForServiceStop(SVC_NAME, 5);
if (lastState != SERVICE_STOPPED) { if (lastState != SERVICE_STOPPED) {
Thread t1; Thread t1;
if (t1.Run(WaitForServiceFinishThread, nullptr) == 0 && if (t1.Run(WaitForServiceFinishThread, NULL) == 0 &&
showProgressUI) { showProgressUI) {
ShowProgressUI(true, false); ShowProgressUI(true, false);
} }
@ -2757,7 +2755,7 @@ int NS_main(int argc, NS_tchar **argv)
bool updateStatusSucceeded = false; bool updateStatusSucceeded = false;
if (IsUpdateStatusSucceeded(updateStatusSucceeded) && if (IsUpdateStatusSucceeded(updateStatusSucceeded) &&
updateStatusSucceeded) { updateStatusSucceeded) {
if (!LaunchWinPostProcess(installDir, gSourcePath, false, nullptr)) { if (!LaunchWinPostProcess(installDir, gSourcePath, false, NULL)) {
fprintf(stderr, "The post update process which runs as the user" fprintf(stderr, "The post update process which runs as the user"
" for service update could not be launched."); " for service update could not be launched.");
} }
@ -2778,7 +2776,7 @@ int NS_main(int argc, NS_tchar **argv)
sinfo.fMask = SEE_MASK_FLAG_NO_UI | sinfo.fMask = SEE_MASK_FLAG_NO_UI |
SEE_MASK_FLAG_DDEWAIT | SEE_MASK_FLAG_DDEWAIT |
SEE_MASK_NOCLOSEPROCESS; SEE_MASK_NOCLOSEPROCESS;
sinfo.hwnd = nullptr; sinfo.hwnd = NULL;
sinfo.lpFile = argv[0]; sinfo.lpFile = argv[0];
sinfo.lpParameters = cmdLine; sinfo.lpParameters = cmdLine;
sinfo.lpVerb = L"runas"; sinfo.lpVerb = L"runas";
@ -2927,9 +2925,7 @@ int NS_main(int argc, NS_tchar **argv)
if (sReplaceRequest) { if (sReplaceRequest) {
// In case of replace requests, we should look for the callback file in // In case of replace requests, we should look for the callback file in
// the destination directory. // the destination directory.
size_t commonPrefixLength = PathCommonPrefixW(argv[callbackIndex], size_t commonPrefixLength = PathCommonPrefixW(argv[callbackIndex], gDestinationPath, NULL);
gDestinationPath,
nullptr);
NS_tchar *p = buffer; NS_tchar *p = buffer;
NS_tstrncpy(p, argv[callbackIndex], commonPrefixLength); NS_tstrncpy(p, argv[callbackIndex], commonPrefixLength);
p += commonPrefixLength; p += commonPrefixLength;
@ -2946,9 +2942,7 @@ int NS_main(int argc, NS_tchar **argv)
NS_tchar installDir[MAXPATHLEN]; NS_tchar installDir[MAXPATHLEN];
if (!GetInstallationDir(installDir)) if (!GetInstallationDir(installDir))
return 1; return 1;
size_t callbackPrefixLength = PathCommonPrefixW(argv[callbackIndex], size_t callbackPrefixLength = PathCommonPrefixW(argv[callbackIndex], installDir, NULL);
installDir,
nullptr);
NS_tstrncpy(p, argv[callbackIndex] + max(callbackPrefixLength, commonPrefixLength), bufferLeft); NS_tstrncpy(p, argv[callbackIndex] + max(callbackPrefixLength, commonPrefixLength), bufferLeft);
targetPath = buffer; targetPath = buffer;
} }
@ -3013,7 +3007,7 @@ int NS_main(int argc, NS_tchar **argv)
DELETE | GENERIC_WRITE, DELETE | GENERIC_WRITE,
// allow delete, rename, and write // allow delete, rename, and write
FILE_SHARE_DELETE | FILE_SHARE_WRITE, FILE_SHARE_DELETE | FILE_SHARE_WRITE,
nullptr, OPEN_EXISTING, 0, nullptr); NULL, OPEN_EXISTING, 0, NULL);
if (callbackFile != INVALID_HANDLE_VALUE) if (callbackFile != INVALID_HANDLE_VALUE)
break; break;
@ -3068,7 +3062,7 @@ int NS_main(int argc, NS_tchar **argv)
// before QuitProgressUI has been called, so wait for UpdateThreadFunc to // before QuitProgressUI has been called, so wait for UpdateThreadFunc to
// terminate. Avoid showing the progress UI for background updates. // terminate. Avoid showing the progress UI for background updates.
Thread t; Thread t;
if (t.Run(UpdateThreadFunc, nullptr) == 0) { if (t.Run(UpdateThreadFunc, NULL) == 0) {
if (!sBackgroundUpdate && !sReplaceRequest) { if (!sBackgroundUpdate && !sReplaceRequest) {
ShowProgressUI(); ShowProgressUI();
} }
@ -3096,7 +3090,7 @@ int NS_main(int argc, NS_tchar **argv)
// access to the HKEY_LOCAL_MACHINE registry key but this is ok since the // access to the HKEY_LOCAL_MACHINE registry key but this is ok since the
// installer / uninstaller will delete the directory along with its contents // installer / uninstaller will delete the directory along with its contents
// after an update is applied, on reinstall, and on uninstall. // after an update is applied, on reinstall, and on uninstall.
if (MoveFileEx(DELETE_DIR, nullptr, MOVEFILE_DELAY_UNTIL_REBOOT)) { if (MoveFileEx(DELETE_DIR, NULL, MOVEFILE_DELAY_UNTIL_REBOOT)) {
LOG(("NS_main: directory will be removed on OS reboot: " LOG_S, LOG(("NS_main: directory will be removed on OS reboot: " LOG_S,
DELETE_DIR)); DELETE_DIR));
} else { } else {
@ -3125,7 +3119,7 @@ int NS_main(int argc, NS_tchar **argv)
if (!sUsingService) { if (!sUsingService) {
NS_tchar installDir[MAXPATHLEN]; NS_tchar installDir[MAXPATHLEN];
if (GetInstallationDir(installDir)) { if (GetInstallationDir(installDir)) {
if (!LaunchWinPostProcess(installDir, gSourcePath, false, nullptr)) { if (!LaunchWinPostProcess(installDir, gSourcePath, false, NULL)) {
LOG(("NS_main: The post update process could not be launched.")); LOG(("NS_main: The post update process could not be launched."));
} }
@ -3153,7 +3147,7 @@ int NS_main(int argc, NS_tchar **argv)
class ActionList class ActionList
{ {
public: public:
ActionList() : mFirst(nullptr), mLast(nullptr), mCount(0) { } ActionList() : mFirst(NULL), mLast(NULL), mCount(0) { }
~ActionList(); ~ActionList();
void Append(Action* action); void Append(Action* action);
@ -3437,19 +3431,19 @@ int add_dir_entries(const NS_tchar *dirpath, ActionList *list)
// Remove the trailing slash so the paths don't contain double slashes. The // Remove the trailing slash so the paths don't contain double slashes. The
// existence of the slash has already been checked in DoUpdate. // existence of the slash has already been checked in DoUpdate.
searchpath[NS_tstrlen(searchpath) - 1] = NS_T('\0'); searchpath[NS_tstrlen(searchpath) - 1] = NS_T('\0');
char* const pathargv[] = {searchpath, nullptr}; char* const pathargv[] = {searchpath, NULL};
// FTS_NOCHDIR is used so relative paths from the destination directory are // FTS_NOCHDIR is used so relative paths from the destination directory are
// returned. // returned.
if (!(ftsdir = fts_open(pathargv, if (!(ftsdir = fts_open(pathargv,
FTS_PHYSICAL | FTS_NOSTAT | FTS_XDEV | FTS_NOCHDIR, FTS_PHYSICAL | FTS_NOSTAT | FTS_XDEV | FTS_NOCHDIR,
nullptr))) NULL)))
return UNEXPECTED_FILE_OPERATION_ERROR; return UNEXPECTED_FILE_OPERATION_ERROR;
while ((ftsdirEntry = fts_read(ftsdir)) != nullptr) { while ((ftsdirEntry = fts_read(ftsdir)) != NULL) {
NS_tchar foundpath[MAXPATHLEN]; NS_tchar foundpath[MAXPATHLEN];
NS_tchar *quotedpath; NS_tchar *quotedpath;
Action *action = nullptr; Action *action = NULL;
switch (ftsdirEntry->fts_info) { switch (ftsdirEntry->fts_info) {
// Filesystem objects that shouldn't be in the application's directories // Filesystem objects that shouldn't be in the application's directories
@ -3539,21 +3533,21 @@ static NS_tchar*
GetManifestContents(const NS_tchar *manifest) GetManifestContents(const NS_tchar *manifest)
{ {
AutoFile mfile = NS_tfopen(manifest, NS_T("rb")); AutoFile mfile = NS_tfopen(manifest, NS_T("rb"));
if (mfile == nullptr) { if (mfile == NULL) {
LOG(("GetManifestContents: error opening manifest file: " LOG_S, manifest)); LOG(("GetManifestContents: error opening manifest file: " LOG_S, manifest));
return nullptr; return NULL;
} }
struct stat ms; struct stat ms;
int rv = fstat(fileno((FILE *)mfile), &ms); int rv = fstat(fileno((FILE *)mfile), &ms);
if (rv) { if (rv) {
LOG(("GetManifestContents: error stating manifest file: " LOG_S, manifest)); LOG(("GetManifestContents: error stating manifest file: " LOG_S, manifest));
return nullptr; return NULL;
} }
char *mbuf = (char *) malloc(ms.st_size + 1); char *mbuf = (char *) malloc(ms.st_size + 1);
if (!mbuf) if (!mbuf)
return nullptr; return NULL;
size_t r = ms.st_size; size_t r = ms.st_size;
char *rb = mbuf; char *rb = mbuf;
@ -3562,7 +3556,7 @@ GetManifestContents(const NS_tchar *manifest)
size_t c = fread(rb, 1, count, mfile); size_t c = fread(rb, 1, count, mfile);
if (c != count) { if (c != count) {
LOG(("GetManifestContents: error reading manifest file: " LOG_S, manifest)); LOG(("GetManifestContents: error reading manifest file: " LOG_S, manifest));
return nullptr; return NULL;
} }
r -= c; r -= c;
@ -3576,14 +3570,14 @@ GetManifestContents(const NS_tchar *manifest)
#else #else
NS_tchar *wrb = (NS_tchar *) malloc((ms.st_size + 1) * sizeof(NS_tchar)); NS_tchar *wrb = (NS_tchar *) malloc((ms.st_size + 1) * sizeof(NS_tchar));
if (!wrb) if (!wrb)
return nullptr; return NULL;
if (!MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, rb, -1, wrb, if (!MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, rb, -1, wrb,
ms.st_size + 1)) { ms.st_size + 1)) {
LOG(("GetManifestContents: error converting utf8 to utf16le: %d", GetLastError())); LOG(("GetManifestContents: error converting utf8 to utf16le: %d", GetLastError()));
free(mbuf); free(mbuf);
free(wrb); free(wrb);
return nullptr; return NULL;
} }
free(mbuf); free(mbuf);
@ -3598,7 +3592,7 @@ int AddPreCompleteActions(ActionList *list)
} }
NS_tchar *rb = GetManifestContents(NS_T("precomplete")); NS_tchar *rb = GetManifestContents(NS_T("precomplete"));
if (rb == nullptr) { if (rb == NULL) {
LOG(("AddPreCompleteActions: error getting contents of precomplete " \ LOG(("AddPreCompleteActions: error getting contents of precomplete " \
"manifest")); "manifest"));
// Applications aren't required to have a precomplete manifest yet. // Applications aren't required to have a precomplete manifest yet.
@ -3618,7 +3612,7 @@ int AddPreCompleteActions(ActionList *list)
return PARSE_ERROR; return PARSE_ERROR;
} }
Action *action = nullptr; Action *action = NULL;
if (NS_tstrcmp(token, NS_T("remove")) == 0) { // rm file if (NS_tstrcmp(token, NS_T("remove")) == 0) { // rm file
action = new RemoveFile(); action = new RemoveFile();
} }
@ -3663,7 +3657,7 @@ int DoUpdate()
} }
NS_tchar *rb = GetManifestContents(manifest); NS_tchar *rb = GetManifestContents(manifest);
if (rb == nullptr) { if (rb == NULL) {
LOG(("DoUpdate: error opening manifest file: " LOG_S, manifest)); LOG(("DoUpdate: error opening manifest file: " LOG_S, manifest));
return READ_ERROR; return READ_ERROR;
} }
@ -3698,7 +3692,7 @@ int DoUpdate()
isFirstAction = false; isFirstAction = false;
Action *action = nullptr; Action *action = NULL;
if (NS_tstrcmp(token, NS_T("remove")) == 0) { // rm file if (NS_tstrcmp(token, NS_T("remove")) == 0) { // rm file
action = new RemoveFile(); action = new RemoveFile();
} }

View File

@ -1026,7 +1026,7 @@ XRE_GetFileFromPath(const char *aPath, nsIFile* *aResult)
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
CFURLRef fullPath = CFURLRef fullPath =
CFURLCreateFromFileSystemRepresentation(nullptr, (const UInt8 *) aPath, CFURLCreateFromFileSystemRepresentation(NULL, (const UInt8 *) aPath,
pathLen, true); pathLen, true);
if (!fullPath) if (!fullPath)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;

View File

@ -25,7 +25,9 @@
#include "nsIThreadManager.h" #include "nsIThreadManager.h"
#include "mozilla/dom/mobilemessage/PSms.h" #include "mozilla/dom/mobilemessage/PSms.h"
#include "gfxImageSurface.h" #include "gfxImageSurface.h"
#include "gfxPlatform.h"
#include "gfxContext.h" #include "gfxContext.h"
#include "mozilla/gfx/2D.h"
#include "gfxUtils.h" #include "gfxUtils.h"
#include "nsPresContext.h" #include "nsPresContext.h"
#include "nsIDocShell.h" #include "nsIDocShell.h"
@ -44,6 +46,7 @@
#endif #endif
using namespace mozilla; using namespace mozilla;
using namespace mozilla::gfx;
NS_IMPL_ISUPPORTS0(nsFilePickerCallback) NS_IMPL_ISUPPORTS0(nsFilePickerCallback)
@ -1848,7 +1851,20 @@ nsresult AndroidBridge::CaptureThumbnail(nsIDOMWindow *window, int32_t bufW, int
ALOG_BRIDGE("Error creating gfxImageSurface"); ALOG_BRIDGE("Error creating gfxImageSurface");
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
nsRefPtr<gfxContext> context = new gfxContext(surf);
nsRefPtr<gfxContext> context;
if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(BACKEND_CAIRO)) {
RefPtr<DrawTarget> dt =
gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(surf, IntSize(bufW, bufH));
if (!dt) {
ALOG_BRIDGE("Error creating DrawTarget");
return NS_ERROR_FAILURE;
}
context = new gfxContext(dt);
} else {
context = new gfxContext(surf);
}
gfxPoint pt(0, 0); gfxPoint pt(0, 0);
context->Translate(pt); context->Translate(pt);
context->Scale(scale * bufW / srcW, scale * bufH / srcH); context->Scale(scale * bufW / srcW, scale * bufH / srcH);

View File

@ -2267,7 +2267,7 @@ nsWindow::UpdateAlpha(gfxPattern* aPattern, nsIntRect aBoundsRect)
stride, FORMAT_A8); stride, FORMAT_A8);
if (drawTarget) { if (drawTarget) {
drawTarget->FillRect(ToRect(aBoundsRect), drawTarget->FillRect(Rect(0, 0, aBoundsRect.width, aBoundsRect.height),
*aPattern->GetPattern(drawTarget), *aPattern->GetPattern(drawTarget),
DrawOptions(1.0, OP_SOURCE)); DrawOptions(1.0, OP_SOURCE));
} }