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"
}

View File

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

View File

@ -528,7 +528,7 @@ public:
mFileList.AppendElement(domFile);
mFileListLength = mFileList.Length();
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
// guarantee that we'll be destroyed there).
return NS_OK;

View File

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

View File

@ -97,6 +97,7 @@ support-files =
[test_oscillatorNode.html]
[test_oscillatorNode2.html]
[test_oscillatorNodeStart.html]
[test_oscillatorTypeChange.html]
[test_pannerNode.html]
[test_pannerNodeAbove.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 =
path.GetDistancesFromOriginToEndsOfVisibleSegments(&mPathVertices);
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();
mPathSourceType = ePathSourceType_PathAttr;
// Generate gfxFlattenedPath from |path| attr
// Generate gfxPath from |path| attr
SVGPathData path;
nsSVGPathDataParserToInternal pathParser(&path);
@ -252,7 +252,7 @@ SVGMotionSMILAnimationFunction::RebuildPathAndVerticesFromPathAttr()
return;
}
mPath = path.ToFlattenedPath(gfxMatrix());
mPath = path.ToPath(gfxMatrix());
bool ok = path.GetDistancesFromOriginToEndsOfVisibleSegments(&mPathVertices);
if (!ok || !mPathVertices.Length()) {
mPath = nullptr;
@ -292,7 +292,7 @@ SVGMotionSMILAnimationFunction::
bool
SVGMotionSMILAnimationFunction::
GenerateValuesForPathAndPoints(gfxFlattenedPath* aPath,
GenerateValuesForPathAndPoints(gfxPath* aPath,
bool aIsKeyPoints,
nsTArray<double>& aPointDistances,
nsTArray<nsSMILValue>& aResult)

View File

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

View File

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

View File

@ -17,7 +17,7 @@
#include "nsSMILParserUtils.h"
#include "nsTArray.h"
class gfxFlattenedPath;
class gfxPath;
class nsAString;
class nsSVGElement;
@ -25,7 +25,7 @@ namespace mozilla {
class SVGMotionSMILPathUtils {
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.
class PathGenerator {
public:
@ -50,7 +50,7 @@ public:
// Accessor to let clients check if we've received any commands yet.
inline bool HaveReceivedCommands() { return mHaveReceivedCommands; }
// Accessor to get the finalized path
already_AddRefed<gfxFlattenedPath> GetResultingPath();
already_AddRefed<gfxPath> GetResultingPath();
protected:
// Helper methods
@ -64,7 +64,7 @@ public:
};
// 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
{
public:

View File

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

View File

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

View File

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

View File

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

View File

@ -53,7 +53,7 @@ SVGPathElement::PathLength()
float
SVGPathElement::GetTotalLength(ErrorResult& rv)
{
nsRefPtr<gfxFlattenedPath> flat = GetFlattenedPath(gfxMatrix());
nsRefPtr<gfxPath> flat = GetPath(gfxMatrix());
if (!flat) {
rv.Throw(NS_ERROR_FAILURE);
@ -66,7 +66,7 @@ SVGPathElement::GetTotalLength(ErrorResult& rv)
already_AddRefed<nsISVGPoint>
SVGPathElement::GetPointAtLength(float distance, ErrorResult& rv)
{
nsRefPtr<gfxFlattenedPath> flat = GetFlattenedPath(gfxMatrix());
nsRefPtr<gfxPath> flat = GetPath(gfxMatrix());
if (!flat) {
rv.Throw(NS_ERROR_FAILURE);
return nullptr;
@ -292,10 +292,10 @@ SVGPathElement::IsAttributeMapped(const nsIAtom* name) const
SVGPathElementBase::IsAttributeMapped(name);
}
already_AddRefed<gfxFlattenedPath>
SVGPathElement::GetFlattenedPath(const gfxMatrix &aMatrix)
already_AddRefed<gfxPath>
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.
matrix = PrependLocalTransformsTo(matrix);
}
nsRefPtr<gfxFlattenedPath> path = GetFlattenedPath(matrix);
nsRefPtr<gfxPath> path = GetPath(matrix);
if (path) {
return path->GetLength() / authorsPathLengthEstimate;
}

View File

@ -48,7 +48,7 @@ public:
virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks) 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
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;

View File

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

View File

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

View File

@ -114,7 +114,16 @@ Throw(JSContext* aCx, nsresult aRv, const char* aMessage)
nsresult nr;
if (NS_SUCCEEDED(existingException->GetResult(&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;
}
}

View File

@ -448,6 +448,11 @@ public:
* mutable.
*/
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
@ -638,6 +643,19 @@ public:
const IntRect &aSourceRect,
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.
*

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
PatternIsCompatible(const Pattern& aPattern)
{
@ -636,6 +655,23 @@ DrawTargetCairo::FillRect(const Rect &aRect,
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
DrawTargetCairo::CopySurface(SourceSurface *aSurface,
const IntRect &aSource,
@ -651,16 +687,40 @@ DrawTargetCairo::CopySurface(SourceSurface *aSurface,
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);
cairo_set_operator(mContext, CAIRO_OPERATOR_SOURCE);
cairo_set_antialias(mContext, CAIRO_ANTIALIAS_NONE);
void
DrawTargetCairo::CopyRect(const IntRect &aSource,
const IntPoint &aDest)
{
AutoPrepareForDrawing prep(this, mContext);
cairo_reset_clip(mContext);
cairo_new_path(mContext);
cairo_rectangle(mContext, aDest.x, aDest.y, aSource.width, aSource.height);
cairo_fill(mContext);
IntRect source = aSource;
cairo_surface_t* surf = mSurface;
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

View File

@ -78,6 +78,8 @@ public:
virtual void CopySurface(SourceSurface *aSurface,
const IntRect &aSourceRect,
const IntPoint &aDestination);
virtual void CopyRect(const IntRect &aSourceRect,
const IntPoint &aDestination);
virtual void FillRect(const Rect &aRect,
const Pattern &aPattern,
@ -161,6 +163,10 @@ private: // methods
const DrawOptions& aOptions,
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
// context is associated. Pass the path you're going to be using if you have
// one.

View File

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

View File

@ -115,6 +115,20 @@ BasicContainerLayer::ChildrenPartitionVisibleRegion(const nsIntRect& aInRect)
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>
BasicLayerManager::CreateContainerLayer()
{

View File

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

View File

@ -73,6 +73,9 @@ public:
void* aCallbackData,
ReadbackProcessor* aReadback) {}
virtual void Validate(LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData) {}
/**
* Layers will get this call when their layer manager is destroyed, this
* 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");
mPhase = PHASE_DRAWING;
Layer* aLayer = GetRoot();
RenderTraceLayers(aLayer, "FF00");
RenderTraceLayers(mRoot, "FF00");
mTransactionIncomplete = false;
if (aFlags & END_NO_COMPOSITE) {
if (!mDummyTarget) {
// XXX: We should really just set mTarget to null and make sure we can handle that further down the call chain
// Creating this temporary surface can be expensive on some platforms (d2d in particular), so cache it between paints.
nsRefPtr<gfxASurface> surf = gfxPlatform::GetPlatform()->CreateOffscreenSurface(gfxIntSize(1, 1), GFX_CONTENT_COLOR);
mDummyTarget = new gfxContext(surf);
}
mTarget = mDummyTarget;
}
if (mRoot) {
// Need to do this before we call ApplyDoubleBuffering,
// which depends on correct effective transforms
mSnapEffectiveTransforms =
mTarget ? !(mTarget->GetFlags() & gfxContext::FLAG_DISABLE_SNAPPING) : true;
mRoot->ComputeEffectiveTransforms(mTarget ? gfx3DMatrix::From2D(mTarget->CurrentMatrix()) : gfx3DMatrix());
if (mTarget && mRoot && !(aFlags & END_NO_IMMEDIATE_REDRAW)) {
nsIntRect clipRect;
if (HasShadowManager()) {
// 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());
ToData(mRoot)->Validate(aCallback, aCallbackData);
if (mRoot->GetMaskLayer()) {
ToData(mRoot->GetMaskLayer())->Validate(aCallback, aCallbackData);
}
if (aFlags & END_NO_COMPOSITE) {
// Apply pending tree updates before recomputing effective
// properties.
aLayer->ApplyPendingUpdatesToSubtree();
mRoot->ApplyPendingUpdatesToSubtree();
}
}
// Need to do this before we call ApplyDoubleBuffering,
// which depends on correct effective transforms
mSnapEffectiveTransforms =
!(mTarget->GetFlags() & gfxContext::FLAG_DISABLE_SNAPPING);
mRoot->ComputeEffectiveTransforms(gfx3DMatrix::From2D(mTarget->CurrentMatrix()));
if (mTarget && mRoot &&
!(aFlags & END_NO_IMMEDIATE_REDRAW) &&
!(aFlags & END_NO_COMPOSITE)) {
nsIntRect clipRect;
{
gfxContextMatrixAutoSaveRestore save(mTarget);
mTarget->SetMatrix(gfxMatrix());
clipRect = ToOutsideIntRect(mTarget->GetClipExtents());
}
if (IsRetained()) {
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);
if (mWidget) {
FlashWidgetUpdateArea(mTarget);
}
RenderDebugOverlay();
LayerManager::PostPresent();
PaintLayer(mTarget, mRoot, aCallback, aCallbackData, nullptr);
if (mWidget) {
FlashWidgetUpdateArea(mTarget);
}
RenderDebugOverlay();
LayerManager::PostPresent();
if (!mTransactionIncomplete) {
// Clear out target if we have a complete transaction.
@ -854,14 +836,6 @@ BasicLayerManager::PaintSelfOrChildren(PaintLayerContext& aPaintContext,
{
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! */
Layer* child = aPaintContext.mLayer->GetFirstChild();
if (!child) {
@ -910,7 +884,7 @@ BasicLayerManager::FlushGroup(PaintLayerContext& aPaintContext, bool aNeedsClipT
BasicContainerLayer* container = static_cast<BasicContainerLayer*>(aPaintContext.mLayer);
AutoSetOperator setOperator(aPaintContext.mTarget, container->GetOperator());
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,
void* aCallbackData,
EndTransactionFlags aFlags = END_DEFAULT);
virtual bool AreComponentAlphaLayersEnabled() { return HasShadowManager() || !IsWidgetLayerManager(); }
virtual bool AreComponentAlphaLayersEnabled() { return !IsWidgetLayerManager(); }
void AbortTransaction();
@ -145,7 +145,6 @@ public:
virtual bool IsCompositingCheap() { return false; }
virtual int32_t GetMaxTextureSize() const { return INT32_MAX; }
bool CompositorMightResample() { return mCompositorMightResample; }
bool HasShadowTarget() { return !!mShadowTarget; }
protected:
enum TransactionPhase {
@ -187,16 +186,6 @@ protected:
nsRefPtr<gfxContext> mDefaultTarget;
// The context to draw into.
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.
nsRefPtr<ImageFactory> mFactory;

View File

@ -90,25 +90,11 @@ BasicThebesLayer::PaintThebes(gfxContext* aContext,
NS_ASSERTION(BasicManager()->InDrawing(),
"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;
if (aReadback && UsedForReadback()) {
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();
gfxContext::GraphicsOperator mixBlendMode = GetEffectiveMixBlendMode();
@ -162,54 +148,6 @@ BasicThebesLayer::PaintThebes(gfxContext* aContext,
return;
}
{
uint32_t flags = 0;
#ifndef MOZ_WIDGET_ANDROID
if (BasicManager()->CompositorMightResample()) {
flags |= ThebesLayerBuffer::PAINT_WILL_RESAMPLE;
}
if (!(flags & ThebesLayerBuffer::PAINT_WILL_RESAMPLE)) {
if (MayResample()) {
flags |= ThebesLayerBuffer::PAINT_WILL_RESAMPLE;
}
}
#endif
if (mDrawAtomically) {
flags |= ThebesLayerBuffer::PAINT_NO_ROTATION;
}
PaintState state =
mContentClient->BeginPaintBuffer(this, contentType, flags);
mValidRegion.Sub(mValidRegion, state.mRegionToInvalidate);
if (state.mContext) {
// The area that became invalid and is visible needs to be repainted
// (this could be the whole visible area if our buffer switched
// from RGB to RGBA, because we might need to repaint with
// subpixel AA)
state.mRegionToInvalidate.And(state.mRegionToInvalidate,
GetEffectiveVisibleRegion());
nsIntRegion extendedDrawRegion = state.mRegionToDraw;
SetAntialiasingFlags(this, state.mContext);
RenderTraceInvalidateStart(this, "FFFF00", state.mRegionToDraw.GetBounds());
PaintBuffer(state.mContext,
state.mRegionToDraw, extendedDrawRegion, state.mRegionToInvalidate,
state.mDidSelfCopy,
aCallback, aCallbackData);
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) PaintThebes", this));
Mutated();
RenderTraceInvalidateEnd(this, "FFFF00");
} else {
// It's possible that state.mRegionToInvalidate is nonempty here,
// if we are shrinking the valid region to nothing. So use mRegionToDraw
// instead.
NS_WARN_IF_FALSE(state.mRegionToDraw.IsEmpty(),
"No context when we have something to draw, resource exhaustion?");
}
}
if (BasicManager()->IsTransactionIncomplete())
return;
@ -246,6 +184,72 @@ BasicThebesLayer::PaintThebes(gfxContext* aContext,
}
}
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;
#ifndef MOZ_WIDGET_ANDROID
if (BasicManager()->CompositorMightResample()) {
flags |= ThebesLayerBuffer::PAINT_WILL_RESAMPLE;
}
if (!(flags & ThebesLayerBuffer::PAINT_WILL_RESAMPLE)) {
if (MayResample()) {
flags |= ThebesLayerBuffer::PAINT_WILL_RESAMPLE;
}
}
#endif
if (mDrawAtomically) {
flags |= ThebesLayerBuffer::PAINT_NO_ROTATION;
}
PaintState state =
mContentClient->BeginPaintBuffer(this, contentType, flags);
mValidRegion.Sub(mValidRegion, state.mRegionToInvalidate);
if (state.mContext) {
// The area that became invalid and is visible needs to be repainted
// (this could be the whole visible area if our buffer switched
// from RGB to RGBA, because we might need to repaint with
// subpixel AA)
state.mRegionToInvalidate.And(state.mRegionToInvalidate,
GetEffectiveVisibleRegion());
nsIntRegion extendedDrawRegion = state.mRegionToDraw;
SetAntialiasingFlags(this, state.mContext);
RenderTraceInvalidateStart(this, "FFFF00", state.mRegionToDraw.GetBounds());
PaintBuffer(state.mContext,
state.mRegionToDraw, extendedDrawRegion, state.mRegionToInvalidate,
state.mDidSelfCopy,
aCallback, aCallbackData);
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) PaintThebes", this));
Mutated();
RenderTraceInvalidateEnd(this, "FFFF00");
} else {
// It's possible that state.mRegionToInvalidate is nonempty here,
// if we are shrinking the valid region to nothing. So use mRegionToDraw
// instead.
NS_WARN_IF_FALSE(state.mRegionToDraw.IsEmpty(),
"No context when we have something to draw, resource exhaustion?");
}
}
already_AddRefed<ThebesLayer>
BasicLayerManager::CreateThebesLayer()
{

View File

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

View File

@ -38,7 +38,7 @@ load 393822-1.html
load 394384-1.html
load 394246-1.html
load 394246-2.html
load 394751.xhtml
skip-if(Android&&AndroidVersion<15) load 394751.xhtml # bug 922976
load 395335-1.xhtml
load 395458-1.html
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) {
nsRefPtr<gfxPath> path = new gfxPath(cairo_copy_path(mCairo));
return path.forget();
path = new gfxPath(cairo_copy_path(mCairo));
} else {
// XXX - This is not yet supported for Azure.
return nullptr;
EnsurePath();
path = new gfxPath(mPath);
}
return path.forget();
}
void gfxContext::AppendPath(gfxPath* path)
void gfxContext::SetPath(gfxPath* path)
{
if (mCairo) {
cairo_new_path(mCairo);
if (path->mPath->status == CAIRO_STATUS_SUCCESS && path->mPath->num_data != 0)
cairo_append_path(mCairo, path->mPath);
} else {
// XXX - This is not yet supported for Azure.
return;
MOZ_ASSERT(path->mMoz2DPath, "Can't mix cairo and azure paths!");
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
gfxContext::HasError()
{

View File

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

View File

@ -5,24 +5,45 @@
#include "gfxPath.h"
#include "gfxPoint.h"
#include "gfxPlatform.h"
#include "gfxASurface.h"
#include "mozilla/gfx/2D.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()
{
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
@ -62,33 +83,55 @@ CalcSubLengthAndAdvance(cairo_path_data_t *aData,
}
gfxFloat
gfxFlattenedPath::GetLength()
gfxPath::GetLength()
{
if (mMoz2DPath) {
return mMoz2DPath->ComputeLength();
}
EnsureFlattenedPath();
gfxPoint start(0, 0); // start of current subpath
gfxPoint current(0, 0); // current point
gfxFloat length = 0; // current summed length
for (int32_t i = 0;
i < mPath->num_data;
i += mPath->data[i].header.length) {
length += CalcSubLengthAndAdvance(&mPath->data[i], start, current);
i < mFlattenedPath->num_data;
i += mFlattenedPath->data[i].header.length) {
length += CalcSubLengthAndAdvance(&mFlattenedPath->data[i], start, current);
}
return length;
}
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 current(0, 0); // current point
gfxFloat length = 0; // current summed length
for (int32_t i = 0;
i < mPath->num_data;
i += mPath->data[i].header.length) {
i < mFlattenedPath->num_data;
i += mFlattenedPath->data[i].header.length) {
gfxPoint prev = current;
gfxFloat sublength = CalcSubLengthAndAdvance(&mPath->data[i],
gfxFloat sublength = CalcSubLengthAndAdvance(&mFlattenedPath->data[i],
start, current);
gfxPoint diff = current - prev;

View File

@ -8,11 +8,18 @@
#include "gfxTypes.h"
#include "nsISupportsImpl.h"
#include "mozilla/RefPtr.h"
class gfxContext;
struct gfxPoint;
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
* of a gfxContext.
@ -24,27 +31,13 @@ class gfxPath {
protected:
gfxPath(cairo_path_t* aPath);
gfxPath(mozilla::gfx::Path* aPath);
void EnsureFlattenedPath();
public:
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
*/
@ -59,6 +52,11 @@ public:
*/
gfxPoint FindPoint(gfxPoint aOffset,
gfxFloat* aAngle = nullptr);
protected:
cairo_path_t* mPath;
cairo_path_t* mFlattenedPath;
mozilla::RefPtr<mozilla::gfx::Path> mMoz2DPath;
};
#endif

View File

@ -241,8 +241,6 @@ ifdef ENABLE_INTL_API
ifndef MOZ_NATIVE_ICU
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
# and debug libraries.
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;)
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
# because it doesn't support order only dependencies.
# - Force ICU to use the standard suffix for object files because expandlibs
# will discard all files with a non-standard suffix (bug 857450).
# - Options for genrb: -k strict parsing; -R omit collation tailoring rules.
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)
distclean clean::

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -133,7 +133,7 @@ NS_IMETHODIMP nsZipHeader::GetPermissions(uint32_t *aPermissions)
NS_ASSERTION(mInited, "Not initalised");
// 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;
}

View File

@ -42,13 +42,13 @@ CalculateMD5(const char *data, DWORD dataSize,
HCRYPTPROV hProv = 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()) {
return FALSE;
}
// 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)) {
return FALSE;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -36,7 +36,7 @@ struct AutoLoadSystemDependencies
if (systemDirectory[systemDirLen - 1] != L'\\' && systemDirLen) {
systemDirectory[systemDirLen] = L'\\';
++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

View File

@ -86,7 +86,7 @@ ShowProgressUI()
snprintf(icon_path, sizeof(icon_path), "%s.png", sProgramPath);
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_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_decorated(GTK_WINDOW(sWin), TRUE);
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);
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), 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_add(GTK_CONTAINER(sWin), vbox);

View File

@ -47,7 +47,7 @@ static StringTable sUIStrings;
static BOOL
GetStringsFile(WCHAR filename[MAX_PATH])
{
if (!GetModuleFileNameW(nullptr, filename, MAX_PATH))
if (!GetModuleFileNameW(NULL, filename, MAX_PATH))
return FALSE;
WCHAR *dot = wcsrchr(filename, '.');
@ -115,8 +115,7 @@ InitDialog(HWND hDlg)
SetWindowTextW(GetDlgItem(hDlg, IDC_INFO), szwInfo);
// Set dialog icon
HICON hIcon = LoadIcon(GetModuleHandle(nullptr),
MAKEINTRESOURCE(IDI_DIALOG));
HICON hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_DIALOG));
if (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
SetTimer(hDlg, TIMER_ID, TIMER_INTERVAL, nullptr);
SetTimer(hDlg, TIMER_ID, TIMER_INTERVAL, NULL);
}
// Message handler for update dialog.
@ -255,8 +254,8 @@ ShowProgressUI(bool indeterminate, bool initUIStrings)
};
InitCommonControlsEx(&icc);
DialogBox(GetModuleHandle(nullptr),
MAKEINTRESOURCE(IDD_DIALOG), nullptr,
DialogBox(GetModuleHandle(NULL),
MAKEINTRESOURCE(IDD_DIALOG), NULL,
(DLGPROC) DialogProc);
return 0;

View File

@ -161,12 +161,12 @@ crc32(const unsigned char *buf, unsigned int len)
class AutoFile
{
public:
AutoFile(FILE* file = nullptr)
AutoFile(FILE* file = NULL)
: mFile(file) {
}
~AutoFile() {
if (mFile != nullptr)
if (mFile != NULL)
fclose(mFile);
}
@ -215,8 +215,7 @@ public:
unsigned int threadID;
mThread = (HANDLE) _beginthreadex(nullptr, 0, ThreadMain, this, 0,
&threadID);
mThread = (HANDLE) _beginthreadex(NULL, 0, ThreadMain, this, 0, &threadID);
return mThread ? 0 : -1;
}
@ -246,7 +245,7 @@ class Thread
public:
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()
{
@ -267,7 +266,7 @@ public:
mThreadFunc = func;
mThreadParam = param;
mThread = _beginthread(ThreadMain, nullptr, 16384, (void *)this);
mThread = _beginthread(ThreadMain, NULL, 16384, (void *)this);
return mThread ? 0 : -1;
}
@ -324,7 +323,7 @@ static NS_tchar*
mstrtok(const NS_tchar *delims, NS_tchar **str)
{
if (!*str || !**str)
return nullptr;
return NULL;
// skip leading "whitespace"
NS_tchar *ret = *str;
@ -340,7 +339,7 @@ mstrtok(const NS_tchar *delims, NS_tchar **str)
if (!*ret) {
*str = ret;
return nullptr;
return NULL;
}
NS_tchar *i = ret;
@ -355,7 +354,7 @@ mstrtok(const NS_tchar *delims, NS_tchar **str)
++i;
} while (*i);
*str = nullptr;
*str = NULL;
return ret;
}
@ -365,7 +364,7 @@ mstrtok(const NS_tchar *delims, NS_tchar **str)
*
* @param relpath
* 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*
get_full_path(const NS_tchar *relpath)
@ -374,7 +373,7 @@ get_full_path(const NS_tchar *relpath)
size_t lenrelpath = NS_tstrlen(relpath);
NS_tchar *s = (NS_tchar *) malloc((lendestpath + lenrelpath + 1) * sizeof(NS_tchar));
if (!s)
return nullptr;
return NULL;
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
* the path checks don't pass nullptr will be returned.
* the path checks don't pass NULL will be returned.
*
* @param line
* The line from the manifest that contains the path.
* @param isdir
* 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*
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);
if (!path) {
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
if (path[0] == NS_T('/')) {
LOG(("get_valid_path: path must be relative: " LOG_S, path));
return nullptr;
return NULL;
}
#ifdef XP_WIN
// All paths must be relative from the current working directory
if (path[0] == NS_T('\\') || path[1] == NS_T(':')) {
LOG(("get_valid_path: path must be relative: " LOG_S, path));
return nullptr;
return NULL;
}
#endif
@ -426,7 +425,7 @@ get_valid_path(NS_tchar **line, bool isdir = false)
if (path[NS_tstrlen(path) - 1] != NS_T('/')) {
LOG(("get_valid_path: directory paths must have a trailing forward " \
"slash: " LOG_S, path));
return nullptr;
return NULL;
}
// 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.
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));
return nullptr;
return NULL;
}
return path;
@ -452,7 +451,7 @@ get_quoted_path(const NS_tchar *path)
NS_tchar *s = (NS_tchar *) malloc(len * sizeof(NS_tchar));
if (!s)
return nullptr;
return NULL;
NS_tchar *c = s;
NS_tstrcpy(c, kQuote);
@ -570,17 +569,17 @@ static FILE* ensure_open(const NS_tchar *path, const NS_tchar *flags, unsigned i
return f;
}
if (NS_tchmod(path, options) != 0) {
if (f != nullptr) {
if (f != NULL) {
fclose(f);
}
return nullptr;
return NULL;
}
struct stat ss;
if (NS_tstat(path, &ss) != 0 || ss.st_mode != options) {
if (f != nullptr) {
if (f != NULL) {
fclose(f);
}
return nullptr;
return NULL;
}
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
// directory containing the file along with its contents after an update is
// 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 " \
"reboot: " LOG_S, path));
} else {
@ -952,7 +951,7 @@ static int DoUpdate();
class Action
{
public:
Action() : mProgressCost(1), mNext(nullptr) { }
Action() : mProgressCost(1), mNext(NULL) { }
virtual ~Action() { }
virtual int Parse(NS_tchar *line) = 0;
@ -980,7 +979,7 @@ private:
class RemoveFile : public Action
{
public:
RemoveFile() : mFile(nullptr), mSkip(0) { }
RemoveFile() : mFile(NULL), mSkip(0) { }
int Parse(NS_tchar *line);
int Prepare();
@ -1089,7 +1088,7 @@ RemoveFile::Finish(int status)
class RemoveDir : public Action
{
public:
RemoveDir() : mDir(nullptr), mSkip(0) { }
RemoveDir() : mDir(NULL), mSkip(0) { }
virtual int Parse(NS_tchar *line);
virtual int Prepare(); // check that the source dir exists
@ -1196,7 +1195,7 @@ RemoveDir::Finish(int status)
class AddFile : public Action
{
public:
AddFile() : mFile(nullptr)
AddFile() : mFile(NULL)
, mAdded(false)
{ }
@ -1252,7 +1251,7 @@ AddFile::Execute()
#ifdef XP_WIN
char sourcefile[MAXPATHLEN];
if (!WideCharToMultiByte(CP_UTF8, 0, mFile, -1, sourcefile, MAXPATHLEN,
nullptr, nullptr)) {
NULL, NULL)) {
LOG(("error converting wchar to utf8: %d", GetLastError()));
return STRING_CONVERSION_ERROR;
}
@ -1281,7 +1280,7 @@ AddFile::Finish(int status)
class PatchFile : public Action
{
public:
PatchFile() : mPatchIndex(-1), buf(nullptr) { }
PatchFile() : mPatchIndex(-1), buf(NULL) { }
virtual ~PatchFile();
@ -1406,7 +1405,7 @@ PatchFile::Prepare()
#ifdef XP_WIN
char sourcefile[MAXPATHLEN];
if (!WideCharToMultiByte(CP_UTF8, 0, mPatchFile, -1, sourcefile, MAXPATHLEN,
nullptr, nullptr)) {
NULL, NULL)) {
LOG(("error converting wchar to utf8: %d", GetLastError()));
return STRING_CONVERSION_ERROR;
}
@ -1425,14 +1424,14 @@ PatchFile::Execute()
LOG(("EXECUTE PATCH " LOG_S, mFile));
AutoFile pfile = NS_tfopen(spath, NS_T("rb"));
if (pfile == nullptr)
if (pfile == NULL)
return READ_ERROR;
int rv = MBS_ReadHeader(pfile, &header);
if (rv)
return rv;
FILE *origfile = nullptr;
FILE *origfile = NULL;
#ifdef XP_WIN
if (NS_tstrcmp(mFile, gCallbackRelPath) == 0) {
// Read from the copy of the callback when patching since the callback can't
@ -1487,14 +1486,13 @@ PatchFile::Execute()
HANDLE hfile = CreateFileW(mFile,
GENERIC_WRITE,
0,
nullptr,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
nullptr);
NULL);
if (hfile != INVALID_HANDLE_VALUE) {
if (SetFilePointer(hfile, header.dlen,
nullptr, FILE_BEGIN) != INVALID_SET_FILE_POINTER &&
if (SetFilePointer(hfile, header.dlen, NULL, FILE_BEGIN) != INVALID_SET_FILE_POINTER &&
SetEndOfFile(hfile) != 0) {
shouldTruncate = false;
}
@ -1521,7 +1519,7 @@ PatchFile::Execute()
AutoFile ofile = ensure_open(mFile, NS_T("wb+"), ss.st_mode);
#endif
if (ofile == nullptr) {
if (ofile == NULL) {
LOG(("unable to create new file: " LOG_S ", err: %d", mFile, errno));
return WRITE_ERROR;
}
@ -1535,13 +1533,13 @@ PatchFile::Execute()
rv = MBS_ApplyPatch(&header, pfile, buf, ofile);
// 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
// on Windows.
pfile = nullptr;
// Set pfile to NULL to make AutoFile close the file so it can be deleted on
// Windows.
pfile = NULL;
NS_tremove(spath);
spath[0] = NS_T('\0');
free(buf);
buf = nullptr;
buf = NULL;
return rv;
}
@ -1557,7 +1555,7 @@ PatchFile::Finish(int status)
class AddIfFile : public AddFile
{
public:
AddIfFile() : mTestFile(nullptr) { }
AddIfFile() : mTestFile(NULL) { }
virtual int Parse(NS_tchar *line);
virtual int Prepare();
@ -1590,7 +1588,7 @@ AddIfFile::Prepare()
{
// If the test file does not exist, then skip this action.
if (NS_taccess(mTestFile, F_OK)) {
mTestFile = nullptr;
mTestFile = NULL;
return OK;
}
@ -1618,7 +1616,7 @@ AddIfFile::Finish(int status)
class PatchIfFile : public PatchFile
{
public:
PatchIfFile() : mTestFile(nullptr) { }
PatchIfFile() : mTestFile(NULL) { }
virtual int Parse(NS_tchar *line);
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 (NS_taccess(mTestFile, F_OK)) {
mTestFile = nullptr;
mTestFile = NULL;
return OK;
}
@ -1734,7 +1732,7 @@ LaunchCallbackApp(const NS_tchar *workingDir,
return;
}
#endif
WinLaunchChild(argv[0], argc, argv, nullptr);
WinLaunchChild(argv[0], argc, argv, NULL);
}
#else
# warning "Need implementaton of LaunchCallbackApp"
@ -1753,7 +1751,7 @@ WriteStatusFile(const char* aStatus)
return false;
AutoFile file = NS_tfopen(filename, NS_T("wb+"));
if (file == nullptr)
if (file == NULL)
return false;
if (fwrite(aStatus, strlen(aStatus), 1, file) != 1)
@ -1800,7 +1798,7 @@ IsUpdateStatusPendingService()
NS_T("%s/update.status"), gSourcePath);
AutoFile file = NS_tfopen(filename, NS_T("rb"));
if (file == nullptr)
if (file == NULL)
return false;
char buf[32] = { 0 };
@ -1834,7 +1832,7 @@ IsUpdateStatusSucceeded(bool &isSucceeded)
NS_T("%s/update.status"), gSourcePath);
AutoFile file = NS_tfopen(filename, NS_T("rb"));
if (file == nullptr)
if (file == NULL)
return false;
char buf[32] = { 0 };
@ -2013,7 +2011,7 @@ ProcessReplaceRequest()
if (rv) {
LOG(("Removing tmpDir failed, err: %d", rv));
#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));
} else {
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_T("%s/update.link"), gSourcePath);
AutoFile linkFile = NS_tfopen(linkFileName, NS_T("rb"));
if (linkFile == nullptr) {
if (linkFile == NULL) {
NS_tsnprintf(fileName, maxChars,
NS_T("%s/update.mar"), gSourcePath);
return OK;
@ -2277,9 +2275,9 @@ UpdateThreadFunc(void *param)
// 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
// the current working directory is the top-level bundle directory.
char* cwd = getcwd(nullptr, 0);
char* cwd = getcwd(NULL, 0);
if (cwd) {
if (utimes(cwd, nullptr) != 0) {
if (utimes(cwd, NULL) != 0) {
LOG(("Couldn't set access/modification time on application bundle."));
}
free(cwd);
@ -2353,7 +2351,7 @@ int NS_main(int argc, NS_tchar **argv)
#ifdef XP_WIN
bool useService = 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="));
// 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;
RegCreateKeyExW(HKEY_CURRENT_USER, L"Software\\Classes\\Applications",
0, nullptr, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, nullptr,
&hkApp, nullptr);
0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL,
&hkApp, NULL);
RegCloseKey(hkApp);
if (RegCreateKeyExW(HKEY_CURRENT_USER,
L"Software\\Classes\\Applications\\updater.exe",
0, nullptr, REG_OPTION_VOLATILE, KEY_SET_VALUE, nullptr,
&hkApp, nullptr) == ERROR_SUCCESS) {
0, NULL, REG_OPTION_VOLATILE, KEY_SET_VALUE, NULL,
&hkApp, NULL) == ERROR_SUCCESS) {
RegSetValueExW(hkApp, L"IsHostApp", 0, REG_NONE, 0, 0);
RegSetValueExW(hkApp, L"NoOpenWith", 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
if (pid > 0) {
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
// update.
if (parent) {
@ -2501,7 +2499,7 @@ int NS_main(int argc, NS_tchar **argv)
}
#else
if (pid > 0)
waitpid(pid, nullptr, 0);
waitpid(pid, NULL, 0);
#endif
if (sReplaceRequest) {
@ -2521,7 +2519,7 @@ int NS_main(int argc, NS_tchar **argv)
const int callbackIndex = 5;
#if defined(XP_WIN)
sUsingService = getenv("MOZ_USING_SERVICE") != nullptr;
sUsingService = getenv("MOZ_USING_SERVICE") != NULL;
putenv(const_cast<char*>("MOZ_USING_SERVICE="));
// 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
@ -2582,10 +2580,10 @@ int NS_main(int argc, NS_tchar **argv)
updateLockFileHandle = CreateFileW(updateLockFilePath,
GENERIC_READ | GENERIC_WRITE,
0,
nullptr,
NULL,
OPEN_ALWAYS,
FILE_FLAG_DELETE_ON_CLOSE,
nullptr);
NULL);
NS_tsnprintf(elevatedLockFilePath,
sizeof(elevatedLockFilePath)/sizeof(elevatedLockFilePath[0]),
@ -2605,7 +2603,7 @@ int NS_main(int argc, NS_tchar **argv)
if(startedFromUnelevatedUpdater) {
// Disable every privilege we don't need. Processes started using
// CreateProcess will use the same token as this process.
UACHelper::DisablePrivileges(nullptr);
UACHelper::DisablePrivileges(NULL);
}
if (updateLockFileHandle == INVALID_HANDLE_VALUE ||
@ -2620,10 +2618,10 @@ int NS_main(int argc, NS_tchar **argv)
elevatedFileHandle = CreateFileW(elevatedLockFilePath,
GENERIC_READ | GENERIC_WRITE,
0,
nullptr,
NULL,
OPEN_ALWAYS,
FILE_FLAG_DELETE_ON_CLOSE,
nullptr);
NULL);
if (elevatedFileHandle == INVALID_HANDLE_VALUE) {
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);
if (lastState != SERVICE_STOPPED) {
Thread t1;
if (t1.Run(WaitForServiceFinishThread, nullptr) == 0 &&
if (t1.Run(WaitForServiceFinishThread, NULL) == 0 &&
showProgressUI) {
ShowProgressUI(true, false);
}
@ -2757,7 +2755,7 @@ int NS_main(int argc, NS_tchar **argv)
bool updateStatusSucceeded = false;
if (IsUpdateStatusSucceeded(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"
" 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 |
SEE_MASK_FLAG_DDEWAIT |
SEE_MASK_NOCLOSEPROCESS;
sinfo.hwnd = nullptr;
sinfo.hwnd = NULL;
sinfo.lpFile = argv[0];
sinfo.lpParameters = cmdLine;
sinfo.lpVerb = L"runas";
@ -2927,9 +2925,7 @@ int NS_main(int argc, NS_tchar **argv)
if (sReplaceRequest) {
// In case of replace requests, we should look for the callback file in
// the destination directory.
size_t commonPrefixLength = PathCommonPrefixW(argv[callbackIndex],
gDestinationPath,
nullptr);
size_t commonPrefixLength = PathCommonPrefixW(argv[callbackIndex], gDestinationPath, NULL);
NS_tchar *p = buffer;
NS_tstrncpy(p, argv[callbackIndex], commonPrefixLength);
p += commonPrefixLength;
@ -2946,9 +2942,7 @@ int NS_main(int argc, NS_tchar **argv)
NS_tchar installDir[MAXPATHLEN];
if (!GetInstallationDir(installDir))
return 1;
size_t callbackPrefixLength = PathCommonPrefixW(argv[callbackIndex],
installDir,
nullptr);
size_t callbackPrefixLength = PathCommonPrefixW(argv[callbackIndex], installDir, NULL);
NS_tstrncpy(p, argv[callbackIndex] + max(callbackPrefixLength, commonPrefixLength), bufferLeft);
targetPath = buffer;
}
@ -3013,7 +3007,7 @@ int NS_main(int argc, NS_tchar **argv)
DELETE | GENERIC_WRITE,
// allow delete, rename, and write
FILE_SHARE_DELETE | FILE_SHARE_WRITE,
nullptr, OPEN_EXISTING, 0, nullptr);
NULL, OPEN_EXISTING, 0, NULL);
if (callbackFile != INVALID_HANDLE_VALUE)
break;
@ -3068,7 +3062,7 @@ int NS_main(int argc, NS_tchar **argv)
// before QuitProgressUI has been called, so wait for UpdateThreadFunc to
// terminate. Avoid showing the progress UI for background updates.
Thread t;
if (t.Run(UpdateThreadFunc, nullptr) == 0) {
if (t.Run(UpdateThreadFunc, NULL) == 0) {
if (!sBackgroundUpdate && !sReplaceRequest) {
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
// installer / uninstaller will delete the directory along with its contents
// 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,
DELETE_DIR));
} else {
@ -3125,7 +3119,7 @@ int NS_main(int argc, NS_tchar **argv)
if (!sUsingService) {
NS_tchar installDir[MAXPATHLEN];
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."));
}
@ -3153,7 +3147,7 @@ int NS_main(int argc, NS_tchar **argv)
class ActionList
{
public:
ActionList() : mFirst(nullptr), mLast(nullptr), mCount(0) { }
ActionList() : mFirst(NULL), mLast(NULL), mCount(0) { }
~ActionList();
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
// existence of the slash has already been checked in DoUpdate.
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
// returned.
if (!(ftsdir = fts_open(pathargv,
FTS_PHYSICAL | FTS_NOSTAT | FTS_XDEV | FTS_NOCHDIR,
nullptr)))
NULL)))
return UNEXPECTED_FILE_OPERATION_ERROR;
while ((ftsdirEntry = fts_read(ftsdir)) != nullptr) {
while ((ftsdirEntry = fts_read(ftsdir)) != NULL) {
NS_tchar foundpath[MAXPATHLEN];
NS_tchar *quotedpath;
Action *action = nullptr;
Action *action = NULL;
switch (ftsdirEntry->fts_info) {
// Filesystem objects that shouldn't be in the application's directories
@ -3539,21 +3533,21 @@ static NS_tchar*
GetManifestContents(const NS_tchar *manifest)
{
AutoFile mfile = NS_tfopen(manifest, NS_T("rb"));
if (mfile == nullptr) {
if (mfile == NULL) {
LOG(("GetManifestContents: error opening manifest file: " LOG_S, manifest));
return nullptr;
return NULL;
}
struct stat ms;
int rv = fstat(fileno((FILE *)mfile), &ms);
if (rv) {
LOG(("GetManifestContents: error stating manifest file: " LOG_S, manifest));
return nullptr;
return NULL;
}
char *mbuf = (char *) malloc(ms.st_size + 1);
if (!mbuf)
return nullptr;
return NULL;
size_t r = ms.st_size;
char *rb = mbuf;
@ -3562,7 +3556,7 @@ GetManifestContents(const NS_tchar *manifest)
size_t c = fread(rb, 1, count, mfile);
if (c != count) {
LOG(("GetManifestContents: error reading manifest file: " LOG_S, manifest));
return nullptr;
return NULL;
}
r -= c;
@ -3576,14 +3570,14 @@ GetManifestContents(const NS_tchar *manifest)
#else
NS_tchar *wrb = (NS_tchar *) malloc((ms.st_size + 1) * sizeof(NS_tchar));
if (!wrb)
return nullptr;
return NULL;
if (!MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, rb, -1, wrb,
ms.st_size + 1)) {
LOG(("GetManifestContents: error converting utf8 to utf16le: %d", GetLastError()));
free(mbuf);
free(wrb);
return nullptr;
return NULL;
}
free(mbuf);
@ -3598,7 +3592,7 @@ int AddPreCompleteActions(ActionList *list)
}
NS_tchar *rb = GetManifestContents(NS_T("precomplete"));
if (rb == nullptr) {
if (rb == NULL) {
LOG(("AddPreCompleteActions: error getting contents of precomplete " \
"manifest"));
// Applications aren't required to have a precomplete manifest yet.
@ -3618,7 +3612,7 @@ int AddPreCompleteActions(ActionList *list)
return PARSE_ERROR;
}
Action *action = nullptr;
Action *action = NULL;
if (NS_tstrcmp(token, NS_T("remove")) == 0) { // rm file
action = new RemoveFile();
}
@ -3663,7 +3657,7 @@ int DoUpdate()
}
NS_tchar *rb = GetManifestContents(manifest);
if (rb == nullptr) {
if (rb == NULL) {
LOG(("DoUpdate: error opening manifest file: " LOG_S, manifest));
return READ_ERROR;
}
@ -3698,7 +3692,7 @@ int DoUpdate()
isFirstAction = false;
Action *action = nullptr;
Action *action = NULL;
if (NS_tstrcmp(token, NS_T("remove")) == 0) { // rm file
action = new RemoveFile();
}

View File

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

View File

@ -25,7 +25,9 @@
#include "nsIThreadManager.h"
#include "mozilla/dom/mobilemessage/PSms.h"
#include "gfxImageSurface.h"
#include "gfxPlatform.h"
#include "gfxContext.h"
#include "mozilla/gfx/2D.h"
#include "gfxUtils.h"
#include "nsPresContext.h"
#include "nsIDocShell.h"
@ -44,6 +46,7 @@
#endif
using namespace mozilla;
using namespace mozilla::gfx;
NS_IMPL_ISUPPORTS0(nsFilePickerCallback)
@ -1848,7 +1851,20 @@ nsresult AndroidBridge::CaptureThumbnail(nsIDOMWindow *window, int32_t bufW, int
ALOG_BRIDGE("Error creating gfxImageSurface");
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);
context->Translate(pt);
context->Scale(scale * bufW / srcW, scale * bufH / srcH);

View File

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