Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
merge mozilla-inbound to mozilla-central a=merge
Browse files Browse the repository at this point in the history
  • Loading branch information
BavarianTomcat committed Jul 7, 2014
2 parents 51565a2 + baa3409 commit 4ede204
Show file tree
Hide file tree
Showing 102 changed files with 1,076 additions and 697 deletions.
2 changes: 1 addition & 1 deletion browser/components/shell/src/nsMacShellService.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ class nsMacShellService : public nsIMacShellService,
{
public:
nsMacShellService() : mCheckedThisSession(false) {};
virtual ~nsMacShellService() {};

NS_DECL_ISUPPORTS
NS_DECL_NSISHELLSERVICE
NS_DECL_NSIMACSHELLSERVICE
NS_DECL_NSIWEBPROGRESSLISTENER

protected:
virtual ~nsMacShellService() {};

private:
nsCOMPtr<nsIFile> mBackgroundFile;
Expand Down
10 changes: 6 additions & 4 deletions content/base/src/DOMMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ class DOMMatrixReadOnly : public nsWrapperCache
SetIsDOMBinding();
}

~DOMMatrixReadOnly()
{
}

#define GetMatrixMember(entry2D, entry3D, default) \
{ \
if (mMatrix3D) { \
Expand Down Expand Up @@ -135,6 +131,10 @@ class DOMMatrixReadOnly : public nsWrapperCache
nsCOMPtr<nsISupports> mParent;
nsAutoPtr<gfx::Matrix> mMatrix2D;
nsAutoPtr<gfx::Matrix4x4> mMatrix3D;

~DOMMatrixReadOnly()
{
}
private:
DOMMatrixReadOnly() MOZ_DELETE;
DOMMatrixReadOnly(const DOMMatrixReadOnly&) MOZ_DELETE;
Expand Down Expand Up @@ -248,6 +248,8 @@ class DOMMatrix MOZ_FINAL : public DOMMatrixReadOnly
DOMMatrix* SetMatrixValue(const nsAString& aTransformList, ErrorResult& aRv);
private:
void Ensure3DMatrix();

~DOMMatrix() {}
};

}
Expand Down
3 changes: 2 additions & 1 deletion content/canvas/src/WebGLContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -1385,7 +1385,6 @@ class WebGLObserver MOZ_FINAL
NS_DECL_NSIDOMEVENTLISTENER

WebGLObserver(WebGLContext* aContext);
~WebGLObserver();

void Destroy();

Expand All @@ -1396,6 +1395,8 @@ class WebGLObserver MOZ_FINAL
void UnregisterMemoryPressureEvent();

private:
~WebGLObserver();

WebGLContext* mContext;
};

Expand Down
4 changes: 2 additions & 2 deletions content/svg/content/src/SVGCircleElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ SVGCircleElement::ConstructPath(gfxContext *aCtx)
}

TemporaryRef<Path>
SVGCircleElement::BuildPath()
SVGCircleElement::BuildPath(PathBuilder* aBuilder)
{
float x, y, r;
GetAnimatedLengthValues(&x, &y, &r, nullptr);
Expand All @@ -103,7 +103,7 @@ SVGCircleElement::BuildPath()
return nullptr;
}

RefPtr<PathBuilder> pathBuilder = CreatePathBuilder();
RefPtr<PathBuilder> pathBuilder = aBuilder ? aBuilder : CreatePathBuilder();

pathBuilder->Arc(Point(x, y), r, 0, Float(2*M_PI));

Expand Down
2 changes: 1 addition & 1 deletion content/svg/content/src/SVGCircleElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class SVGCircleElement MOZ_FINAL : public SVGCircleElementBase

// nsSVGPathGeometryElement methods:
virtual void ConstructPath(gfxContext *aCtx) MOZ_OVERRIDE;
virtual TemporaryRef<Path> BuildPath() MOZ_OVERRIDE;
virtual TemporaryRef<Path> BuildPath(PathBuilder* aBuilder = nullptr) MOZ_OVERRIDE;

virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;

Expand Down
189 changes: 187 additions & 2 deletions content/svg/content/src/SVGContentUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@
#include "SVGContentUtils.h"

// Keep others in (case-insensitive) order:
#include "gfx2DGlue.h"
#include "gfxMatrix.h"
#include "gfxPlatform.h"
#include "gfxSVGGlyphs.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/dom/SVGSVGElement.h"
#include "mozilla/RefPtr.h"
#include "nsComputedDOMStyle.h"
#include "nsFontMetrics.h"
#include "nsIFrame.h"
Expand All @@ -20,12 +25,14 @@
#include "nsContentUtils.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/Types.h"
#include "gfx2DGlue.h"
#include "nsStyleContext.h"
#include "nsSVGPathDataParser.h"
#include "SVGPathData.h"
#include "SVGPathElement.h"

using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::gfx;

SVGSVGElement*
SVGContentUtils::GetOuterSVGElement(nsSVGElement *aSVGElement)
Expand Down Expand Up @@ -54,6 +61,179 @@ SVGContentUtils::ActivateByHyperlink(nsIContent *aContent)
static_cast<SVGAnimationElement*>(aContent)->ActivateByHyperlink();
}

enum DashState {
eDashedStroke,
eContinuousStroke, //< all dashes, no gaps
eNoStroke //< all gaps, no dashes
};

static DashState
GetStrokeDashData(SVGContentUtils::AutoStrokeOptions* aStrokeOptions,
nsSVGElement* aElement,
const nsStyleSVG* aStyleSVG,
gfxTextContextPaint *aContextPaint)
{
size_t dashArrayLength;
Float totalLengthOfDashes = 0.0, totalLengthOfGaps = 0.0;

if (aContextPaint && aStyleSVG->mStrokeDasharrayFromObject) {
const FallibleTArray<gfxFloat>& dashSrc = aContextPaint->GetStrokeDashArray();
dashArrayLength = dashSrc.Length();
if (dashArrayLength <= 0) {
return eContinuousStroke;
}
Float* dashPattern = aStrokeOptions->InitDashPattern(dashArrayLength);
if (!dashPattern) {
return eContinuousStroke;
}
for (size_t i = 0; i < dashArrayLength; i++) {
if (dashSrc[i] < 0.0) {
return eContinuousStroke; // invalid
}
dashPattern[i] = Float(dashSrc[i]);
(i % 2 ? totalLengthOfGaps : totalLengthOfDashes) += dashSrc[i];
}
} else {
const nsStyleCoord *dasharray = aStyleSVG->mStrokeDasharray;
dashArrayLength = aStyleSVG->mStrokeDasharrayLength;
if (dashArrayLength <= 0) {
return eContinuousStroke;
}
Float pathScale = 1.0;
if (aElement->Tag() == nsGkAtoms::path) {
pathScale = static_cast<SVGPathElement*>(aElement)->
GetPathLengthScale(SVGPathElement::eForStroking);
if (pathScale <= 0) {
return eContinuousStroke;
}
}
Float* dashPattern = aStrokeOptions->InitDashPattern(dashArrayLength);
if (!dashPattern) {
return eContinuousStroke;
}
for (uint32_t i = 0; i < dashArrayLength; i++) {
Float dashLength =
SVGContentUtils::CoordToFloat(aElement, dasharray[i]) * pathScale;
if (dashLength < 0.0) {
return eContinuousStroke; // invalid
}
dashPattern[i] = dashLength;
(i % 2 ? totalLengthOfGaps : totalLengthOfDashes) += dashLength;
}
}

// Now that aStrokeOptions.mDashPattern is fully initialized we can safely
// set mDashLength:
aStrokeOptions->mDashLength = dashArrayLength;

if (totalLengthOfDashes <= 0 || totalLengthOfGaps <= 0) {
if (totalLengthOfGaps > 0 && totalLengthOfDashes <= 0) {
return eNoStroke;
}
return eContinuousStroke;
}

if (aContextPaint && aStyleSVG->mStrokeDashoffsetFromObject) {
aStrokeOptions->mDashOffset = Float(aContextPaint->GetStrokeDashOffset());
} else {
aStrokeOptions->mDashOffset =
SVGContentUtils::CoordToFloat(aElement, aStyleSVG->mStrokeDashoffset);
}

return eDashedStroke;
}

void
SVGContentUtils::GetStrokeOptions(AutoStrokeOptions* aStrokeOptions,
nsSVGElement* aElement,
nsStyleContext* aStyleContext,
gfxTextContextPaint *aContextPaint)
{
nsRefPtr<nsStyleContext> styleContext;
if (aStyleContext) {
styleContext = aStyleContext;
} else {
styleContext =
nsComputedDOMStyle::GetStyleContextForElementNoFlush(aElement, nullptr,
nullptr);
}

if (!styleContext) {
return;
}

const nsStyleSVG* styleSVG = styleContext->StyleSVG();

DashState dashState =
GetStrokeDashData(aStrokeOptions, aElement, styleSVG, aContextPaint);

if (dashState == eNoStroke) {
// Hopefully this will shortcircuit any stroke operations:
aStrokeOptions->mLineWidth = 0;
return;
}
if (dashState == eContinuousStroke) {
// Prevent our caller from wasting time looking at the dash array:
aStrokeOptions->mDashLength = 0;
}

aStrokeOptions->mLineWidth =
GetStrokeWidth(aElement, styleContext, aContextPaint);

aStrokeOptions->mMiterLimit = Float(styleSVG->mStrokeMiterlimit);

switch (styleSVG->mStrokeLinejoin) {
case NS_STYLE_STROKE_LINEJOIN_MITER:
aStrokeOptions->mLineJoin = JoinStyle::MITER;
break;
case NS_STYLE_STROKE_LINEJOIN_ROUND:
aStrokeOptions->mLineJoin = JoinStyle::ROUND;
break;
case NS_STYLE_STROKE_LINEJOIN_BEVEL:
aStrokeOptions->mLineJoin = JoinStyle::BEVEL;
break;
}

switch (styleSVG->mStrokeLinecap) {
case NS_STYLE_STROKE_LINECAP_BUTT:
aStrokeOptions->mLineCap = CapStyle::BUTT;
break;
case NS_STYLE_STROKE_LINECAP_ROUND:
aStrokeOptions->mLineCap = CapStyle::ROUND;
break;
case NS_STYLE_STROKE_LINECAP_SQUARE:
aStrokeOptions->mLineCap = CapStyle::SQUARE;
break;
}
}

Float
SVGContentUtils::GetStrokeWidth(nsSVGElement* aElement,
nsStyleContext* aStyleContext,
gfxTextContextPaint *aContextPaint)
{
nsRefPtr<nsStyleContext> styleContext;
if (aStyleContext) {
styleContext = aStyleContext;
} else {
styleContext =
nsComputedDOMStyle::GetStyleContextForElementNoFlush(aElement, nullptr,
nullptr);
}

if (!styleContext) {
return 0.0f;
}

const nsStyleSVG* styleSVG = styleContext->StyleSVG();

if (aContextPaint && styleSVG->mStrokeWidthFromObject) {
return aContextPaint->GetStrokeWidth();
}

return SVGContentUtils::CoordToFloat(aElement, styleSVG->mStrokeWidth);
}

float
SVGContentUtils::GetFontSize(Element *aElement)
{
Expand Down Expand Up @@ -596,5 +776,10 @@ SVGContentUtils::GetPath(const nsAString& aPathString)
return NULL;
}

return pathData.BuildPath(mozilla::gfx::FillRule::FILL_WINDING, NS_STYLE_STROKE_LINECAP_BUTT, 1);
RefPtr<DrawTarget> drawTarget =
gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget();
RefPtr<PathBuilder> builder =
drawTarget->CreatePathBuilder(FillRule::FILL_WINDING);

return pathData.BuildPath(builder, NS_STYLE_STROKE_LINECAP_BUTT, 1);
}
Loading

0 comments on commit 4ede204

Please sign in to comment.