mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 989337 - 2/3 - Convert Canvas2D to typed enums and EnumeratedArray, auto regex changes - r=Bas
This commit is contained in:
parent
4e5ff7d4c1
commit
35e401452f
@ -231,7 +231,7 @@ public:
|
||||
if (state.StyleIsColor(aStyle)) {
|
||||
mPattern = new (mColorPattern.addr()) ColorPattern(Color::FromABGR(state.colorStyles[aStyle]));
|
||||
} else if (state.gradientStyles[aStyle] &&
|
||||
state.gradientStyles[aStyle]->GetType() == CanvasGradient::LINEAR) {
|
||||
state.gradientStyles[aStyle]->GetType() == CanvasGradient::Type::LINEAR) {
|
||||
CanvasLinearGradient *gradient =
|
||||
static_cast<CanvasLinearGradient*>(state.gradientStyles[aStyle].get());
|
||||
|
||||
@ -239,7 +239,7 @@ public:
|
||||
LinearGradientPattern(gradient->mBegin, gradient->mEnd,
|
||||
gradient->GetGradientStopsForTarget(aRT));
|
||||
} else if (state.gradientStyles[aStyle] &&
|
||||
state.gradientStyles[aStyle]->GetType() == CanvasGradient::RADIAL) {
|
||||
state.gradientStyles[aStyle]->GetType() == CanvasGradient::Type::RADIAL) {
|
||||
CanvasRadialGradient *gradient =
|
||||
static_cast<CanvasRadialGradient*>(state.gradientStyles[aStyle].get());
|
||||
|
||||
@ -255,7 +255,7 @@ public:
|
||||
}
|
||||
|
||||
ExtendMode mode;
|
||||
if (state.patternStyles[aStyle]->mRepeat == CanvasPattern::NOREPEAT) {
|
||||
if (state.patternStyles[aStyle]->mRepeat == CanvasPattern::RepeatMode::NOREPEAT) {
|
||||
mode = ExtendMode::CLAMP;
|
||||
} else {
|
||||
mode = ExtendMode::REPEAT;
|
||||
@ -478,10 +478,10 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(CanvasRenderingContext2D)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(CanvasRenderingContext2D)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCanvasElement)
|
||||
for (uint32_t i = 0; i < tmp->mStyleStack.Length(); i++) {
|
||||
ImplCycleCollectionUnlink(tmp->mStyleStack[i].patternStyles[STYLE_STROKE]);
|
||||
ImplCycleCollectionUnlink(tmp->mStyleStack[i].patternStyles[STYLE_FILL]);
|
||||
ImplCycleCollectionUnlink(tmp->mStyleStack[i].gradientStyles[STYLE_STROKE]);
|
||||
ImplCycleCollectionUnlink(tmp->mStyleStack[i].gradientStyles[STYLE_FILL]);
|
||||
ImplCycleCollectionUnlink(tmp->mStyleStack[i].patternStyles[Style::STROKE]);
|
||||
ImplCycleCollectionUnlink(tmp->mStyleStack[i].patternStyles[Style::FILL]);
|
||||
ImplCycleCollectionUnlink(tmp->mStyleStack[i].gradientStyles[Style::STROKE]);
|
||||
ImplCycleCollectionUnlink(tmp->mStyleStack[i].gradientStyles[Style::FILL]);
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
@ -489,10 +489,10 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(CanvasRenderingContext2D)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCanvasElement)
|
||||
for (uint32_t i = 0; i < tmp->mStyleStack.Length(); i++) {
|
||||
ImplCycleCollectionTraverse(cb, tmp->mStyleStack[i].patternStyles[STYLE_STROKE], "Stroke CanvasPattern");
|
||||
ImplCycleCollectionTraverse(cb, tmp->mStyleStack[i].patternStyles[STYLE_FILL], "Fill CanvasPattern");
|
||||
ImplCycleCollectionTraverse(cb, tmp->mStyleStack[i].gradientStyles[STYLE_STROKE], "Stroke CanvasGradient");
|
||||
ImplCycleCollectionTraverse(cb, tmp->mStyleStack[i].gradientStyles[STYLE_FILL], "Fill CanvasGradient");
|
||||
ImplCycleCollectionTraverse(cb, tmp->mStyleStack[i].patternStyles[Style::STROKE], "Stroke CanvasPattern");
|
||||
ImplCycleCollectionTraverse(cb, tmp->mStyleStack[i].patternStyles[Style::FILL], "Fill CanvasPattern");
|
||||
ImplCycleCollectionTraverse(cb, tmp->mStyleStack[i].gradientStyles[Style::STROKE], "Stroke CanvasGradient");
|
||||
ImplCycleCollectionTraverse(cb, tmp->mStyleStack[i].gradientStyles[Style::FILL], "Fill CanvasGradient");
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
@ -1002,8 +1002,8 @@ CanvasRenderingContext2D::ClearTarget()
|
||||
ContextState *state = mStyleStack.AppendElement();
|
||||
state->globalAlpha = 1.0;
|
||||
|
||||
state->colorStyles[STYLE_FILL] = NS_RGB(0,0,0);
|
||||
state->colorStyles[STYLE_STROKE] = NS_RGB(0,0,0);
|
||||
state->colorStyles[Style::FILL] = NS_RGB(0,0,0);
|
||||
state->colorStyles[Style::STROKE] = NS_RGB(0,0,0);
|
||||
state->shadowColor = NS_RGBA(0,0,0,0);
|
||||
}
|
||||
|
||||
@ -1427,16 +1427,16 @@ CanvasRenderingContext2D::CreatePattern(const HTMLImageOrCanvasOrVideoElement& e
|
||||
ErrorResult& error)
|
||||
{
|
||||
CanvasPattern::RepeatMode repeatMode =
|
||||
CanvasPattern::NOREPEAT;
|
||||
CanvasPattern::RepeatMode::NOREPEAT;
|
||||
|
||||
if (repeat.IsEmpty() || repeat.EqualsLiteral("repeat")) {
|
||||
repeatMode = CanvasPattern::REPEAT;
|
||||
repeatMode = CanvasPattern::RepeatMode::REPEAT;
|
||||
} else if (repeat.EqualsLiteral("repeat-x")) {
|
||||
repeatMode = CanvasPattern::REPEATX;
|
||||
repeatMode = CanvasPattern::RepeatMode::REPEATX;
|
||||
} else if (repeat.EqualsLiteral("repeat-y")) {
|
||||
repeatMode = CanvasPattern::REPEATY;
|
||||
repeatMode = CanvasPattern::RepeatMode::REPEATY;
|
||||
} else if (repeat.EqualsLiteral("no-repeat")) {
|
||||
repeatMode = CanvasPattern::NOREPEAT;
|
||||
repeatMode = CanvasPattern::RepeatMode::NOREPEAT;
|
||||
} else {
|
||||
error.Throw(NS_ERROR_DOM_SYNTAX_ERR);
|
||||
return nullptr;
|
||||
@ -1527,15 +1527,15 @@ CanvasRenderingContext2D::FillRect(double x, double y, double w,
|
||||
{
|
||||
const ContextState &state = CurrentState();
|
||||
|
||||
if (state.patternStyles[STYLE_FILL]) {
|
||||
if (state.patternStyles[Style::FILL]) {
|
||||
CanvasPattern::RepeatMode repeat =
|
||||
state.patternStyles[STYLE_FILL]->mRepeat;
|
||||
state.patternStyles[Style::FILL]->mRepeat;
|
||||
// In the FillRect case repeat modes are easy to deal with.
|
||||
bool limitx = repeat == CanvasPattern::NOREPEAT || repeat == CanvasPattern::REPEATY;
|
||||
bool limity = repeat == CanvasPattern::NOREPEAT || repeat == CanvasPattern::REPEATX;
|
||||
bool limitx = repeat == CanvasPattern::RepeatMode::NOREPEAT || repeat == CanvasPattern::RepeatMode::REPEATY;
|
||||
bool limity = repeat == CanvasPattern::RepeatMode::NOREPEAT || repeat == CanvasPattern::RepeatMode::REPEATX;
|
||||
|
||||
IntSize patternSize =
|
||||
state.patternStyles[STYLE_FILL]->mSurface->GetSize();
|
||||
state.patternStyles[Style::FILL]->mSurface->GetSize();
|
||||
|
||||
// We always need to execute painting for non-over operators, even if
|
||||
// we end up with w/h = 0.
|
||||
@ -1583,7 +1583,7 @@ CanvasRenderingContext2D::FillRect(double x, double y, double w,
|
||||
|
||||
AdjustedTarget(this, bounds.IsEmpty() ? nullptr : &bounds)->
|
||||
FillRect(mgfx::Rect(x, y, w, h),
|
||||
CanvasGeneralPattern().ForStyle(this, STYLE_FILL, mTarget),
|
||||
CanvasGeneralPattern().ForStyle(this, Style::FILL, mTarget),
|
||||
DrawOptions(state.globalAlpha, UsedOperation()));
|
||||
|
||||
RedrawUser(gfxRect(x, y, w, h));
|
||||
@ -1619,7 +1619,7 @@ CanvasRenderingContext2D::StrokeRect(double x, double y, double w,
|
||||
}
|
||||
AdjustedTarget(this, bounds.IsEmpty() ? nullptr : &bounds)->
|
||||
StrokeLine(Point(x, y), Point(x + w, y),
|
||||
CanvasGeneralPattern().ForStyle(this, STYLE_STROKE, mTarget),
|
||||
CanvasGeneralPattern().ForStyle(this, Style::STROKE, mTarget),
|
||||
StrokeOptions(state.lineWidth, state.lineJoin,
|
||||
cap, state.miterLimit,
|
||||
state.dash.Length(),
|
||||
@ -1636,7 +1636,7 @@ CanvasRenderingContext2D::StrokeRect(double x, double y, double w,
|
||||
}
|
||||
AdjustedTarget(this, bounds.IsEmpty() ? nullptr : &bounds)->
|
||||
StrokeLine(Point(x, y), Point(x, y + h),
|
||||
CanvasGeneralPattern().ForStyle(this, STYLE_STROKE, mTarget),
|
||||
CanvasGeneralPattern().ForStyle(this, Style::STROKE, mTarget),
|
||||
StrokeOptions(state.lineWidth, state.lineJoin,
|
||||
cap, state.miterLimit,
|
||||
state.dash.Length(),
|
||||
@ -1648,7 +1648,7 @@ CanvasRenderingContext2D::StrokeRect(double x, double y, double w,
|
||||
|
||||
AdjustedTarget(this, bounds.IsEmpty() ? nullptr : &bounds)->
|
||||
StrokeRect(mgfx::Rect(x, y, w, h),
|
||||
CanvasGeneralPattern().ForStyle(this, STYLE_STROKE, mTarget),
|
||||
CanvasGeneralPattern().ForStyle(this, Style::STROKE, mTarget),
|
||||
StrokeOptions(state.lineWidth, state.lineJoin,
|
||||
state.lineCap, state.miterLimit,
|
||||
state.dash.Length(),
|
||||
@ -1688,7 +1688,7 @@ CanvasRenderingContext2D::Fill(const CanvasWindingRule& winding)
|
||||
}
|
||||
|
||||
AdjustedTarget(this, bounds.IsEmpty() ? nullptr : &bounds)->
|
||||
Fill(mPath, CanvasGeneralPattern().ForStyle(this, STYLE_FILL, mTarget),
|
||||
Fill(mPath, CanvasGeneralPattern().ForStyle(this, Style::FILL, mTarget),
|
||||
DrawOptions(CurrentState().globalAlpha, UsedOperation()));
|
||||
|
||||
Redraw();
|
||||
@ -1711,7 +1711,7 @@ void CanvasRenderingContext2D::Fill(const CanvasPath& path, const CanvasWindingR
|
||||
}
|
||||
|
||||
AdjustedTarget(this, bounds.IsEmpty() ? nullptr : &bounds)->
|
||||
Fill(gfxpath, CanvasGeneralPattern().ForStyle(this, STYLE_FILL, mTarget),
|
||||
Fill(gfxpath, CanvasGeneralPattern().ForStyle(this, Style::FILL, mTarget),
|
||||
DrawOptions(CurrentState().globalAlpha, UsedOperation()));
|
||||
|
||||
Redraw();
|
||||
@ -1740,7 +1740,7 @@ CanvasRenderingContext2D::Stroke()
|
||||
}
|
||||
|
||||
AdjustedTarget(this, bounds.IsEmpty() ? nullptr : &bounds)->
|
||||
Stroke(mPath, CanvasGeneralPattern().ForStyle(this, STYLE_STROKE, mTarget),
|
||||
Stroke(mPath, CanvasGeneralPattern().ForStyle(this, Style::STROKE, mTarget),
|
||||
strokeOptions, DrawOptions(state.globalAlpha, UsedOperation()));
|
||||
|
||||
Redraw();
|
||||
@ -1771,7 +1771,7 @@ CanvasRenderingContext2D::Stroke(const CanvasPath& path)
|
||||
}
|
||||
|
||||
AdjustedTarget(this, bounds.IsEmpty() ? nullptr : &bounds)->
|
||||
Stroke(gfxpath, CanvasGeneralPattern().ForStyle(this, STYLE_STROKE, mTarget),
|
||||
Stroke(gfxpath, CanvasGeneralPattern().ForStyle(this, Style::STROKE, mTarget),
|
||||
strokeOptions, DrawOptions(state.globalAlpha, UsedOperation()));
|
||||
|
||||
Redraw();
|
||||
@ -1803,7 +1803,7 @@ void CanvasRenderingContext2D::DrawFocusIfNeeded(mozilla::dom::Element& aElement
|
||||
|
||||
// color and style of the rings is the same as for image maps
|
||||
// set the background focus color
|
||||
CurrentState().SetColorStyle(STYLE_STROKE, NS_RGBA(255, 255, 255, 255));
|
||||
CurrentState().SetColorStyle(Style::STROKE, NS_RGBA(255, 255, 255, 255));
|
||||
// draw the focus ring
|
||||
Stroke();
|
||||
|
||||
@ -1813,7 +1813,7 @@ void CanvasRenderingContext2D::DrawFocusIfNeeded(mozilla::dom::Element& aElement
|
||||
dash.AppendElement(1);
|
||||
|
||||
// set the foreground focus color
|
||||
CurrentState().SetColorStyle(STYLE_STROKE, NS_RGBA(0,0,0, 255));
|
||||
CurrentState().SetColorStyle(Style::STROKE, NS_RGBA(0,0,0, 255));
|
||||
// draw the focus ring
|
||||
Stroke();
|
||||
|
||||
@ -2291,15 +2291,15 @@ void
|
||||
CanvasRenderingContext2D::SetTextAlign(const nsAString& ta)
|
||||
{
|
||||
if (ta.EqualsLiteral("start"))
|
||||
CurrentState().textAlign = TEXT_ALIGN_START;
|
||||
CurrentState().textAlign = TextAlign::START;
|
||||
else if (ta.EqualsLiteral("end"))
|
||||
CurrentState().textAlign = TEXT_ALIGN_END;
|
||||
CurrentState().textAlign = TextAlign::END;
|
||||
else if (ta.EqualsLiteral("left"))
|
||||
CurrentState().textAlign = TEXT_ALIGN_LEFT;
|
||||
CurrentState().textAlign = TextAlign::LEFT;
|
||||
else if (ta.EqualsLiteral("right"))
|
||||
CurrentState().textAlign = TEXT_ALIGN_RIGHT;
|
||||
CurrentState().textAlign = TextAlign::RIGHT;
|
||||
else if (ta.EqualsLiteral("center"))
|
||||
CurrentState().textAlign = TEXT_ALIGN_CENTER;
|
||||
CurrentState().textAlign = TextAlign::CENTER;
|
||||
}
|
||||
|
||||
void
|
||||
@ -2307,19 +2307,19 @@ CanvasRenderingContext2D::GetTextAlign(nsAString& ta)
|
||||
{
|
||||
switch (CurrentState().textAlign)
|
||||
{
|
||||
case TEXT_ALIGN_START:
|
||||
case TextAlign::START:
|
||||
ta.AssignLiteral("start");
|
||||
break;
|
||||
case TEXT_ALIGN_END:
|
||||
case TextAlign::END:
|
||||
ta.AssignLiteral("end");
|
||||
break;
|
||||
case TEXT_ALIGN_LEFT:
|
||||
case TextAlign::LEFT:
|
||||
ta.AssignLiteral("left");
|
||||
break;
|
||||
case TEXT_ALIGN_RIGHT:
|
||||
case TextAlign::RIGHT:
|
||||
ta.AssignLiteral("right");
|
||||
break;
|
||||
case TEXT_ALIGN_CENTER:
|
||||
case TextAlign::CENTER:
|
||||
ta.AssignLiteral("center");
|
||||
break;
|
||||
}
|
||||
@ -2329,17 +2329,17 @@ void
|
||||
CanvasRenderingContext2D::SetTextBaseline(const nsAString& tb)
|
||||
{
|
||||
if (tb.EqualsLiteral("top"))
|
||||
CurrentState().textBaseline = TEXT_BASELINE_TOP;
|
||||
CurrentState().textBaseline = TextBaseline::TOP;
|
||||
else if (tb.EqualsLiteral("hanging"))
|
||||
CurrentState().textBaseline = TEXT_BASELINE_HANGING;
|
||||
CurrentState().textBaseline = TextBaseline::HANGING;
|
||||
else if (tb.EqualsLiteral("middle"))
|
||||
CurrentState().textBaseline = TEXT_BASELINE_MIDDLE;
|
||||
CurrentState().textBaseline = TextBaseline::MIDDLE;
|
||||
else if (tb.EqualsLiteral("alphabetic"))
|
||||
CurrentState().textBaseline = TEXT_BASELINE_ALPHABETIC;
|
||||
CurrentState().textBaseline = TextBaseline::ALPHABETIC;
|
||||
else if (tb.EqualsLiteral("ideographic"))
|
||||
CurrentState().textBaseline = TEXT_BASELINE_IDEOGRAPHIC;
|
||||
CurrentState().textBaseline = TextBaseline::IDEOGRAPHIC;
|
||||
else if (tb.EqualsLiteral("bottom"))
|
||||
CurrentState().textBaseline = TEXT_BASELINE_BOTTOM;
|
||||
CurrentState().textBaseline = TextBaseline::BOTTOM;
|
||||
}
|
||||
|
||||
void
|
||||
@ -2347,22 +2347,22 @@ CanvasRenderingContext2D::GetTextBaseline(nsAString& tb)
|
||||
{
|
||||
switch (CurrentState().textBaseline)
|
||||
{
|
||||
case TEXT_BASELINE_TOP:
|
||||
case TextBaseline::TOP:
|
||||
tb.AssignLiteral("top");
|
||||
break;
|
||||
case TEXT_BASELINE_HANGING:
|
||||
case TextBaseline::HANGING:
|
||||
tb.AssignLiteral("hanging");
|
||||
break;
|
||||
case TEXT_BASELINE_MIDDLE:
|
||||
case TextBaseline::MIDDLE:
|
||||
tb.AssignLiteral("middle");
|
||||
break;
|
||||
case TEXT_BASELINE_ALPHABETIC:
|
||||
case TextBaseline::ALPHABETIC:
|
||||
tb.AssignLiteral("alphabetic");
|
||||
break;
|
||||
case TEXT_BASELINE_IDEOGRAPHIC:
|
||||
case TextBaseline::IDEOGRAPHIC:
|
||||
tb.AssignLiteral("ideographic");
|
||||
break;
|
||||
case TEXT_BASELINE_BOTTOM:
|
||||
case TextBaseline::BOTTOM:
|
||||
tb.AssignLiteral("bottom");
|
||||
break;
|
||||
}
|
||||
@ -2387,7 +2387,7 @@ CanvasRenderingContext2D::FillText(const nsAString& text, double x,
|
||||
const Optional<double>& maxWidth,
|
||||
ErrorResult& error)
|
||||
{
|
||||
error = DrawOrMeasureText(text, x, y, maxWidth, TEXT_DRAW_OPERATION_FILL, nullptr);
|
||||
error = DrawOrMeasureText(text, x, y, maxWidth, TextDrawOperation::FILL, nullptr);
|
||||
}
|
||||
|
||||
void
|
||||
@ -2396,7 +2396,7 @@ CanvasRenderingContext2D::StrokeText(const nsAString& text, double x,
|
||||
const Optional<double>& maxWidth,
|
||||
ErrorResult& error)
|
||||
{
|
||||
error = DrawOrMeasureText(text, x, y, maxWidth, TEXT_DRAW_OPERATION_STROKE, nullptr);
|
||||
error = DrawOrMeasureText(text, x, y, maxWidth, TextDrawOperation::STROKE, nullptr);
|
||||
}
|
||||
|
||||
TextMetrics*
|
||||
@ -2405,7 +2405,7 @@ CanvasRenderingContext2D::MeasureText(const nsAString& rawText,
|
||||
{
|
||||
float width;
|
||||
Optional<double> maxWidth;
|
||||
error = DrawOrMeasureText(rawText, 0, 0, maxWidth, TEXT_DRAW_OPERATION_MEASURE, &width);
|
||||
error = DrawOrMeasureText(rawText, 0, 0, maxWidth, TextDrawOperation::MEASURE, &width);
|
||||
if (error.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -2639,14 +2639,14 @@ struct MOZ_STACK_CLASS CanvasBidiProcessor : public nsBidiPresUtils::BidiProcess
|
||||
Rect bounds = mCtx->mTarget->GetTransform().
|
||||
TransformBounds(Rect(mBoundingBox.x, mBoundingBox.y,
|
||||
mBoundingBox.width, mBoundingBox.height));
|
||||
if (mOp == CanvasRenderingContext2D::TEXT_DRAW_OPERATION_FILL) {
|
||||
if (mOp == CanvasRenderingContext2D::TextDrawOperation::FILL) {
|
||||
AdjustedTarget(mCtx, &bounds)->
|
||||
FillGlyphs(scaledFont, buffer,
|
||||
CanvasGeneralPattern().
|
||||
ForStyle(mCtx, CanvasRenderingContext2D::STYLE_FILL, mCtx->mTarget),
|
||||
ForStyle(mCtx, CanvasRenderingContext2D::Style::FILL, mCtx->mTarget),
|
||||
DrawOptions(mState->globalAlpha, mCtx->UsedOperation()),
|
||||
renderingOptions);
|
||||
} else if (mOp == CanvasRenderingContext2D::TEXT_DRAW_OPERATION_STROKE) {
|
||||
} else if (mOp == CanvasRenderingContext2D::TextDrawOperation::STROKE) {
|
||||
// stroke glyphs one at a time to avoid poor CoreGraphics performance
|
||||
// when stroking a path with a very large number of points
|
||||
buffer.mGlyphs = &glyphBuf.front();
|
||||
@ -2660,7 +2660,7 @@ struct MOZ_STACK_CLASS CanvasBidiProcessor : public nsBidiPresUtils::BidiProcess
|
||||
state.dashOffset);
|
||||
CanvasGeneralPattern cgp;
|
||||
const Pattern& patForStyle
|
||||
(cgp.ForStyle(mCtx, CanvasRenderingContext2D::STYLE_STROKE, mCtx->mTarget));
|
||||
(cgp.ForStyle(mCtx, CanvasRenderingContext2D::Style::STROKE, mCtx->mTarget));
|
||||
const DrawOptions drawOpts(state.globalAlpha, mCtx->UsedOperation());
|
||||
|
||||
for (unsigned i = glyphBuf.size(); i > 0; --i) {
|
||||
@ -2819,18 +2819,18 @@ CanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
|
||||
}
|
||||
|
||||
// if only measuring, don't need to do any more work
|
||||
if (aOp==TEXT_DRAW_OPERATION_MEASURE) {
|
||||
if (aOp==TextDrawOperation::MEASURE) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// offset pt.x based on text align
|
||||
gfxFloat anchorX;
|
||||
|
||||
if (state.textAlign == TEXT_ALIGN_CENTER) {
|
||||
if (state.textAlign == TextAlign::CENTER) {
|
||||
anchorX = .5;
|
||||
} else if (state.textAlign == TEXT_ALIGN_LEFT ||
|
||||
(!isRTL && state.textAlign == TEXT_ALIGN_START) ||
|
||||
(isRTL && state.textAlign == TEXT_ALIGN_END)) {
|
||||
} else if (state.textAlign == TextAlign::LEFT ||
|
||||
(!isRTL && state.textAlign == TextAlign::START) ||
|
||||
(isRTL && state.textAlign == TextAlign::END)) {
|
||||
anchorX = 0;
|
||||
} else {
|
||||
anchorX = 1;
|
||||
@ -2847,20 +2847,20 @@ CanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
|
||||
|
||||
switch (state.textBaseline)
|
||||
{
|
||||
case TEXT_BASELINE_HANGING:
|
||||
case TextBaseline::HANGING:
|
||||
// fall through; best we can do with the information available
|
||||
case TEXT_BASELINE_TOP:
|
||||
case TextBaseline::TOP:
|
||||
anchorY = fontMetrics.emAscent;
|
||||
break;
|
||||
case TEXT_BASELINE_MIDDLE:
|
||||
case TextBaseline::MIDDLE:
|
||||
anchorY = (fontMetrics.emAscent - fontMetrics.emDescent) * .5f;
|
||||
break;
|
||||
case TEXT_BASELINE_IDEOGRAPHIC:
|
||||
case TextBaseline::IDEOGRAPHIC:
|
||||
// fall through; best we can do with the information available
|
||||
case TEXT_BASELINE_ALPHABETIC:
|
||||
case TextBaseline::ALPHABETIC:
|
||||
anchorY = 0;
|
||||
break;
|
||||
case TEXT_BASELINE_BOTTOM:
|
||||
case TextBaseline::BOTTOM:
|
||||
anchorY = -fontMetrics.emDescent;
|
||||
break;
|
||||
default:
|
||||
@ -2914,7 +2914,7 @@ CanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText,
|
||||
|
||||
mTarget->SetTransform(oldTransform);
|
||||
|
||||
if (aOp == CanvasRenderingContext2D::TEXT_DRAW_OPERATION_FILL &&
|
||||
if (aOp == CanvasRenderingContext2D::TextDrawOperation::FILL &&
|
||||
!doDrawShadow) {
|
||||
RedrawUser(boundingBox);
|
||||
return NS_OK;
|
||||
|
@ -158,22 +158,22 @@ public:
|
||||
|
||||
void GetStrokeStyle(OwningStringOrCanvasGradientOrCanvasPattern& value)
|
||||
{
|
||||
GetStyleAsUnion(value, STYLE_STROKE);
|
||||
GetStyleAsUnion(value, Style::STROKE);
|
||||
}
|
||||
|
||||
void SetStrokeStyle(const StringOrCanvasGradientOrCanvasPattern& value)
|
||||
{
|
||||
SetStyleFromUnion(value, STYLE_STROKE);
|
||||
SetStyleFromUnion(value, Style::STROKE);
|
||||
}
|
||||
|
||||
void GetFillStyle(OwningStringOrCanvasGradientOrCanvasPattern& value)
|
||||
{
|
||||
GetStyleAsUnion(value, STYLE_FILL);
|
||||
GetStyleAsUnion(value, Style::FILL);
|
||||
}
|
||||
|
||||
void SetFillStyle(const StringOrCanvasGradientOrCanvasPattern& value)
|
||||
{
|
||||
SetStyleFromUnion(value, STYLE_FILL);
|
||||
SetStyleFromUnion(value, Style::FILL);
|
||||
}
|
||||
|
||||
already_AddRefed<CanvasGradient>
|
||||
@ -854,8 +854,8 @@ protected:
|
||||
// state stack handling
|
||||
class ContextState {
|
||||
public:
|
||||
ContextState() : textAlign(TEXT_ALIGN_START),
|
||||
textBaseline(TEXT_BASELINE_ALPHABETIC),
|
||||
ContextState() : textAlign(TextAlign::START),
|
||||
textBaseline(TextBaseline::ALPHABETIC),
|
||||
lineWidth(1.0f),
|
||||
miterLimit(10.0f),
|
||||
globalAlpha(1.0f),
|
||||
@ -888,7 +888,7 @@ protected:
|
||||
lineJoin(other.lineJoin),
|
||||
imageSmoothingEnabled(other.imageSmoothingEnabled)
|
||||
{
|
||||
for (int i = 0; i < STYLE_MAX; i++) {
|
||||
for (int i = 0; i < Style::MAX; i++) {
|
||||
colorStyles[i] = other.colorStyles[i];
|
||||
gradientStyles[i] = other.gradientStyles[i];
|
||||
patternStyles[i] = other.patternStyles[i];
|
||||
@ -926,14 +926,14 @@ protected:
|
||||
std::vector<mozilla::RefPtr<mozilla::gfx::Path> > clipsPushed;
|
||||
|
||||
nsRefPtr<gfxFontGroup> fontGroup;
|
||||
nsRefPtr<CanvasGradient> gradientStyles[STYLE_MAX];
|
||||
nsRefPtr<CanvasPattern> patternStyles[STYLE_MAX];
|
||||
nsRefPtr<CanvasGradient> gradientStyles[Style::MAX];
|
||||
nsRefPtr<CanvasPattern> patternStyles[Style::MAX];
|
||||
|
||||
nsString font;
|
||||
TextAlign textAlign;
|
||||
TextBaseline textBaseline;
|
||||
|
||||
nscolor colorStyles[STYLE_MAX];
|
||||
nscolor colorStyles[Style::MAX];
|
||||
nscolor shadowColor;
|
||||
|
||||
mozilla::gfx::Matrix transform;
|
||||
|
Loading…
Reference in New Issue
Block a user