| Index: third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp
|
| diff --git a/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp b/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp
|
| index da219d684678b699d63a30c8cc7aee96d2a5c4fe..2ca83edc07e15bbf6d2d287ac1c8e13b44fc3106 100644
|
| --- a/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp
|
| +++ b/third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp
|
| @@ -82,7 +82,7 @@ static const char rtl[] = "rtl";
|
| static const char ltr[] = "ltr";
|
| static const double TryRestoreContextInterval = 0.5;
|
| static const unsigned MaxTryRestoreContextAttempts = 4;
|
| -static const float cDeviceScaleFactor = 1.0f; // Canvas is device independent
|
| +static const double cDeviceScaleFactor = 1.0; // Canvas is device independent
|
|
|
| static bool contextLostRestoredEventsEnabled()
|
| {
|
| @@ -448,12 +448,12 @@ void CanvasRenderingContext2D::setFillStyle(const StringOrCanvasGradientOrCanvas
|
| modifiableState().setUnparsedFillColor(colorString);
|
| }
|
|
|
| -float CanvasRenderingContext2D::lineWidth() const
|
| +double CanvasRenderingContext2D::lineWidth() const
|
| {
|
| return state().lineWidth();
|
| }
|
|
|
| -void CanvasRenderingContext2D::setLineWidth(float width)
|
| +void CanvasRenderingContext2D::setLineWidth(double width)
|
| {
|
| if (!std::isfinite(width) || width <= 0)
|
| return;
|
| @@ -492,12 +492,12 @@ void CanvasRenderingContext2D::setLineJoin(const String& s)
|
| modifiableState().setLineJoin(join);
|
| }
|
|
|
| -float CanvasRenderingContext2D::miterLimit() const
|
| +double CanvasRenderingContext2D::miterLimit() const
|
| {
|
| return state().miterLimit();
|
| }
|
|
|
| -void CanvasRenderingContext2D::setMiterLimit(float limit)
|
| +void CanvasRenderingContext2D::setMiterLimit(double limit)
|
| {
|
| if (!std::isfinite(limit) || limit <= 0)
|
| return;
|
| @@ -506,12 +506,12 @@ void CanvasRenderingContext2D::setMiterLimit(float limit)
|
| modifiableState().setMiterLimit(limit);
|
| }
|
|
|
| -float CanvasRenderingContext2D::shadowOffsetX() const
|
| +double CanvasRenderingContext2D::shadowOffsetX() const
|
| {
|
| return state().shadowOffset().width();
|
| }
|
|
|
| -void CanvasRenderingContext2D::setShadowOffsetX(float x)
|
| +void CanvasRenderingContext2D::setShadowOffsetX(double x)
|
| {
|
| if (!std::isfinite(x))
|
| return;
|
| @@ -520,12 +520,12 @@ void CanvasRenderingContext2D::setShadowOffsetX(float x)
|
| modifiableState().setShadowOffsetX(x);
|
| }
|
|
|
| -float CanvasRenderingContext2D::shadowOffsetY() const
|
| +double CanvasRenderingContext2D::shadowOffsetY() const
|
| {
|
| return state().shadowOffset().height();
|
| }
|
|
|
| -void CanvasRenderingContext2D::setShadowOffsetY(float y)
|
| +void CanvasRenderingContext2D::setShadowOffsetY(double y)
|
| {
|
| if (!std::isfinite(y))
|
| return;
|
| @@ -534,12 +534,12 @@ void CanvasRenderingContext2D::setShadowOffsetY(float y)
|
| modifiableState().setShadowOffsetY(y);
|
| }
|
|
|
| -float CanvasRenderingContext2D::shadowBlur() const
|
| +double CanvasRenderingContext2D::shadowBlur() const
|
| {
|
| return state().shadowBlur();
|
| }
|
|
|
| -void CanvasRenderingContext2D::setShadowBlur(float blur)
|
| +void CanvasRenderingContext2D::setShadowBlur(double blur)
|
| {
|
| if (!std::isfinite(blur) || blur < 0)
|
| return;
|
| @@ -584,24 +584,24 @@ void CanvasRenderingContext2D::setLineDash(const Vector<float>& dash)
|
| modifiableState().setLineDash(dash);
|
| }
|
|
|
| -float CanvasRenderingContext2D::lineDashOffset() const
|
| +double CanvasRenderingContext2D::lineDashOffset() const
|
| {
|
| return state().lineDashOffset();
|
| }
|
|
|
| -void CanvasRenderingContext2D::setLineDashOffset(float offset)
|
| +void CanvasRenderingContext2D::setLineDashOffset(double offset)
|
| {
|
| if (!std::isfinite(offset) || state().lineDashOffset() == offset)
|
| return;
|
| modifiableState().setLineDashOffset(offset);
|
| }
|
|
|
| -float CanvasRenderingContext2D::globalAlpha() const
|
| +double CanvasRenderingContext2D::globalAlpha() const
|
| {
|
| return state().globalAlpha();
|
| }
|
|
|
| -void CanvasRenderingContext2D::setGlobalAlpha(float alpha)
|
| +void CanvasRenderingContext2D::setGlobalAlpha(double alpha)
|
| {
|
| if (!(alpha >= 0 && alpha <= 1))
|
| return;
|
| @@ -668,7 +668,7 @@ void CanvasRenderingContext2D::setCurrentTransform(PassRefPtrWillBeRawPtr<SVGMat
|
| setTransform(transform.a(), transform.b(), transform.c(), transform.d(), transform.e(), transform.f());
|
| }
|
|
|
| -void CanvasRenderingContext2D::scale(float sx, float sy)
|
| +void CanvasRenderingContext2D::scale(double sx, double sy)
|
| {
|
| SkCanvas* c = drawingCanvas();
|
| if (!c)
|
| @@ -690,7 +690,7 @@ void CanvasRenderingContext2D::scale(float sx, float sy)
|
| m_path.transform(AffineTransform().scaleNonUniform(1.0 / sx, 1.0 / sy));
|
| }
|
|
|
| -void CanvasRenderingContext2D::rotate(float angleInRadians)
|
| +void CanvasRenderingContext2D::rotate(double angleInRadians)
|
| {
|
| SkCanvas* c = drawingCanvas();
|
| if (!c)
|
| @@ -707,11 +707,11 @@ void CanvasRenderingContext2D::rotate(float angleInRadians)
|
| modifiableState().setTransform(newTransform);
|
| if (!state().isTransformInvertible())
|
| return;
|
| - c->rotate(angleInRadians * (180.0f / piFloat));
|
| + c->rotate(angleInRadians * (180.0 / piFloat));
|
| m_path.transform(AffineTransform().rotateRadians(-angleInRadians));
|
| }
|
|
|
| -void CanvasRenderingContext2D::translate(float tx, float ty)
|
| +void CanvasRenderingContext2D::translate(double tx, double ty)
|
| {
|
| SkCanvas* c = drawingCanvas();
|
| if (!c)
|
| @@ -734,7 +734,7 @@ void CanvasRenderingContext2D::translate(float tx, float ty)
|
| m_path.transform(AffineTransform().translate(-tx, -ty));
|
| }
|
|
|
| -void CanvasRenderingContext2D::transform(float m11, float m12, float m21, float m22, float dx, float dy)
|
| +void CanvasRenderingContext2D::transform(double m11, double m12, double m21, double m22, double dx, double dy)
|
| {
|
| SkCanvas* c = drawingCanvas();
|
| if (!c)
|
| @@ -779,7 +779,7 @@ void CanvasRenderingContext2D::resetTransform()
|
| // It means that resetTransform() restores m_path just before CTM became non-invertible.
|
| }
|
|
|
| -void CanvasRenderingContext2D::setTransform(float m11, float m12, float m21, float m22, float dx, float dy)
|
| +void CanvasRenderingContext2D::setTransform(double m11, double m12, double m21, double m22, double dx, double dy)
|
| {
|
| SkCanvas* c = drawingCanvas();
|
| if (!c)
|
| @@ -797,7 +797,7 @@ void CanvasRenderingContext2D::beginPath()
|
| m_path.clear();
|
| }
|
|
|
| -static bool validateRectForCanvas(float& x, float& y, float& width, float& height)
|
| +static bool validateRectForCanvas(double& x, double& y, double& width, double& height)
|
| {
|
| if (!std::isfinite(x) || !std::isfinite(y) || !std::isfinite(width) || !std::isfinite(height))
|
| return false;
|
| @@ -985,7 +985,7 @@ void CanvasRenderingContext2D::stroke(Path2D* domPath)
|
| drawPathInternal(domPath->path(), CanvasRenderingContext2DState::StrokePaintType);
|
| }
|
|
|
| -void CanvasRenderingContext2D::fillRect(float x, float y, float width, float height)
|
| +void CanvasRenderingContext2D::fillRect(double x, double y, double width, double height)
|
| {
|
| if (!validateRectForCanvas(x, y, width, height))
|
| return;
|
| @@ -1020,7 +1020,7 @@ static void strokeRectOnCanvas(const FloatRect& rect, SkCanvas* canvas, const Sk
|
| canvas->drawRect(rect, *paint);
|
| }
|
|
|
| -void CanvasRenderingContext2D::strokeRect(float x, float y, float width, float height)
|
| +void CanvasRenderingContext2D::strokeRect(double x, double y, double width, double height)
|
| {
|
| if (!validateRectForCanvas(x, y, width, height))
|
| return;
|
| @@ -1071,17 +1071,17 @@ void CanvasRenderingContext2D::clip(Path2D* domPath, const String& windingRuleSt
|
| clipInternal(domPath->path(), windingRuleString);
|
| }
|
|
|
| -bool CanvasRenderingContext2D::isPointInPath(const float x, const float y, const String& windingRuleString)
|
| +bool CanvasRenderingContext2D::isPointInPath(const double x, const double y, const String& windingRuleString)
|
| {
|
| return isPointInPathInternal(m_path, x, y, windingRuleString);
|
| }
|
|
|
| -bool CanvasRenderingContext2D::isPointInPath(Path2D* domPath, const float x, const float y, const String& windingRuleString)
|
| +bool CanvasRenderingContext2D::isPointInPath(Path2D* domPath, const double x, const double y, const String& windingRuleString)
|
| {
|
| return isPointInPathInternal(domPath->path(), x, y, windingRuleString);
|
| }
|
|
|
| -bool CanvasRenderingContext2D::isPointInPathInternal(const Path& path, const float x, const float y, const String& windingRuleString)
|
| +bool CanvasRenderingContext2D::isPointInPathInternal(const Path& path, const double x, const double y, const String& windingRuleString)
|
| {
|
| SkCanvas* c = drawingCanvas();
|
| if (!c)
|
| @@ -1098,17 +1098,17 @@ bool CanvasRenderingContext2D::isPointInPathInternal(const Path& path, const flo
|
| return path.contains(transformedPoint, SkFillTypeToWindRule(parseWinding(windingRuleString)));
|
| }
|
|
|
| -bool CanvasRenderingContext2D::isPointInStroke(const float x, const float y)
|
| +bool CanvasRenderingContext2D::isPointInStroke(const double x, const double y)
|
| {
|
| return isPointInStrokeInternal(m_path, x, y);
|
| }
|
|
|
| -bool CanvasRenderingContext2D::isPointInStroke(Path2D* domPath, const float x, const float y)
|
| +bool CanvasRenderingContext2D::isPointInStroke(Path2D* domPath, const double x, const double y)
|
| {
|
| return isPointInStrokeInternal(domPath->path(), x, y);
|
| }
|
|
|
| -bool CanvasRenderingContext2D::isPointInStrokeInternal(const Path& path, const float x, const float y)
|
| +bool CanvasRenderingContext2D::isPointInStrokeInternal(const Path& path, const double x, const double y)
|
| {
|
| SkCanvas* c = drawingCanvas();
|
| if (!c)
|
| @@ -1170,7 +1170,7 @@ void CanvasRenderingContext2D::scrollPathIntoViewInternal(const Path& path)
|
| // selection the specified rectangle of the canvas. See http://crbug.com/357987
|
| }
|
|
|
| -void CanvasRenderingContext2D::clearRect(float x, float y, float width, float height)
|
| +void CanvasRenderingContext2D::clearRect(double x, double y, double width, double height)
|
| {
|
| if (!validateRectForCanvas(x, y, width, height))
|
| return;
|
| @@ -1249,7 +1249,7 @@ static inline CanvasImageSource* toImageSourceInternal(const CanvasImageSourceUn
|
| return nullptr;
|
| }
|
|
|
| -void CanvasRenderingContext2D::drawImage(const CanvasImageSourceUnion& imageSource, float x, float y, ExceptionState& exceptionState)
|
| +void CanvasRenderingContext2D::drawImage(const CanvasImageSourceUnion& imageSource, double x, double y, ExceptionState& exceptionState)
|
| {
|
| CanvasImageSource* imageSourceInternal = toImageSourceInternal(imageSource);
|
| FloatSize sourceRectSize = imageSourceInternal->elementSize();
|
| @@ -1258,7 +1258,7 @@ void CanvasRenderingContext2D::drawImage(const CanvasImageSourceUnion& imageSour
|
| }
|
|
|
| void CanvasRenderingContext2D::drawImage(const CanvasImageSourceUnion& imageSource,
|
| - float x, float y, float width, float height, ExceptionState& exceptionState)
|
| + double x, double y, double width, double height, ExceptionState& exceptionState)
|
| {
|
| CanvasImageSource* imageSourceInternal = toImageSourceInternal(imageSource);
|
| FloatSize sourceRectSize = imageSourceInternal->elementSize();
|
| @@ -1266,8 +1266,8 @@ void CanvasRenderingContext2D::drawImage(const CanvasImageSourceUnion& imageSour
|
| }
|
|
|
| void CanvasRenderingContext2D::drawImage(const CanvasImageSourceUnion& imageSource,
|
| - float sx, float sy, float sw, float sh,
|
| - float dx, float dy, float dw, float dh, ExceptionState& exceptionState)
|
| + double sx, double sy, double sw, double sh,
|
| + double dx, double dy, double dw, double dh, ExceptionState& exceptionState)
|
| {
|
| CanvasImageSource* imageSourceInternal = toImageSourceInternal(imageSource);
|
| drawImage(imageSourceInternal, sx, sy, sw, sh, dx, dy, dw, dh, exceptionState);
|
| @@ -1359,8 +1359,8 @@ bool shouldDisableDeferral(CanvasImageSource* imageSource)
|
| }
|
|
|
| void CanvasRenderingContext2D::drawImage(CanvasImageSource* imageSource,
|
| - float sx, float sy, float sw, float sh,
|
| - float dx, float dy, float dw, float dh, ExceptionState& exceptionState)
|
| + double sx, double sy, double sw, double sh,
|
| + double dx, double dy, double dw, double dh, ExceptionState& exceptionState)
|
| {
|
| if (!drawingCanvas())
|
| return;
|
| @@ -1452,13 +1452,13 @@ bool CanvasRenderingContext2D::rectContainsTransformedRect(const FloatRect& rect
|
| return state().transform().mapQuad(quad).containsQuad(transformedQuad);
|
| }
|
|
|
| -CanvasGradient* CanvasRenderingContext2D::createLinearGradient(float x0, float y0, float x1, float y1)
|
| +CanvasGradient* CanvasRenderingContext2D::createLinearGradient(double x0, double y0, double x1, double y1)
|
| {
|
| CanvasGradient* gradient = CanvasGradient::create(FloatPoint(x0, y0), FloatPoint(x1, y1));
|
| return gradient;
|
| }
|
|
|
| -CanvasGradient* CanvasRenderingContext2D::createRadialGradient(float x0, float y0, float r0, float x1, float y1, float r1, ExceptionState& exceptionState)
|
| +CanvasGradient* CanvasRenderingContext2D::createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1, ExceptionState& exceptionState)
|
| {
|
| if (r0 < 0 || r1 < 0) {
|
| exceptionState.throwDOMException(IndexSizeError, String::format("The %s provided is less than 0.", r0 < 0 ? "r0" : "r1"));
|
| @@ -1560,7 +1560,7 @@ ImageData* CanvasRenderingContext2D::createImageData(ImageData* imageData) const
|
| return ImageData::create(imageData->size());
|
| }
|
|
|
| -ImageData* CanvasRenderingContext2D::createImageData(float sw, float sh, ExceptionState& exceptionState) const
|
| +ImageData* CanvasRenderingContext2D::createImageData(double sw, double sh, ExceptionState& exceptionState) const
|
| {
|
| if (!sw || !sh) {
|
| exceptionState.throwDOMException(IndexSizeError, String::format("The source %s is 0.", sw ? "height" : "width"));
|
| @@ -1580,7 +1580,7 @@ ImageData* CanvasRenderingContext2D::createImageData(float sw, float sh, Excepti
|
| return ImageData::create(size);
|
| }
|
|
|
| -ImageData* CanvasRenderingContext2D::getImageData(float sx, float sy, float sw, float sh, ExceptionState& exceptionState) const
|
| +ImageData* CanvasRenderingContext2D::getImageData(double sx, double sy, double sw, double sh, ExceptionState& exceptionState) const
|
| {
|
| if (!canvas()->originClean())
|
| exceptionState.throwSecurityError("The canvas has been tainted by cross-origin data.");
|
| @@ -1622,12 +1622,12 @@ ImageData* CanvasRenderingContext2D::getImageData(float sx, float sy, float sw,
|
| DOMUint8ClampedArray::create(arrayBuffer, 0, arrayBuffer->byteLength()));
|
| }
|
|
|
| -void CanvasRenderingContext2D::putImageData(ImageData* data, float dx, float dy, ExceptionState& exceptionState)
|
| +void CanvasRenderingContext2D::putImageData(ImageData* data, double dx, double dy, ExceptionState& exceptionState)
|
| {
|
| putImageData(data, dx, dy, 0, 0, data->width(), data->height(), exceptionState);
|
| }
|
|
|
| -void CanvasRenderingContext2D::putImageData(ImageData* data, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight, ExceptionState& exceptionState)
|
| +void CanvasRenderingContext2D::putImageData(ImageData* data, double dx, double dy, double dirtyX, double dirtyY, double dirtyWidth, double dirtyHeight, ExceptionState& exceptionState)
|
| {
|
| if (data->data()->bufferBase()->isNeutered()) {
|
| exceptionState.throwDOMException(InvalidStateError, "The source data has been neutered.");
|
| @@ -1873,22 +1873,22 @@ void CanvasRenderingContext2D::setDirection(const String& directionString)
|
| modifiableState().setDirection(direction);
|
| }
|
|
|
| -void CanvasRenderingContext2D::fillText(const String& text, float x, float y)
|
| +void CanvasRenderingContext2D::fillText(const String& text, double x, double y)
|
| {
|
| drawTextInternal(text, x, y, CanvasRenderingContext2DState::FillPaintType);
|
| }
|
|
|
| -void CanvasRenderingContext2D::fillText(const String& text, float x, float y, float maxWidth)
|
| +void CanvasRenderingContext2D::fillText(const String& text, double x, double y, double maxWidth)
|
| {
|
| drawTextInternal(text, x, y, CanvasRenderingContext2DState::FillPaintType, &maxWidth);
|
| }
|
|
|
| -void CanvasRenderingContext2D::strokeText(const String& text, float x, float y)
|
| +void CanvasRenderingContext2D::strokeText(const String& text, double x, double y)
|
| {
|
| drawTextInternal(text, x, y, CanvasRenderingContext2DState::StrokePaintType);
|
| }
|
|
|
| -void CanvasRenderingContext2D::strokeText(const String& text, float x, float y, float maxWidth)
|
| +void CanvasRenderingContext2D::strokeText(const String& text, double x, double y, double maxWidth)
|
| {
|
| drawTextInternal(text, x, y, CanvasRenderingContext2DState::StrokePaintType, &maxWidth);
|
| }
|
| @@ -1920,9 +1920,9 @@ TextMetrics* CanvasRenderingContext2D::measureText(const String& text)
|
|
|
| // y direction
|
| const FontMetrics& fontMetrics = font.fontMetrics();
|
| - const float ascent = fontMetrics.floatAscent();
|
| - const float descent = fontMetrics.floatDescent();
|
| - const float baselineY = getFontBaseline(fontMetrics);
|
| + const double ascent = fontMetrics.floatAscent();
|
| + const double descent = fontMetrics.floatDescent();
|
| + const double baselineY = getFontBaseline(fontMetrics);
|
|
|
| metrics->setFontBoundingBoxAscent(ascent - baselineY);
|
| metrics->setFontBoundingBoxDescent(descent + baselineY);
|
| @@ -1940,7 +1940,7 @@ TextMetrics* CanvasRenderingContext2D::measureText(const String& text)
|
| return metrics;
|
| }
|
|
|
| -void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, float y, CanvasRenderingContext2DState::PaintType paintType, float* maxWidth)
|
| +void CanvasRenderingContext2D::drawTextInternal(const String& text, double x, double y, CanvasRenderingContext2DState::PaintType paintType, double* maxWidth)
|
| {
|
| // The style resolution required for rendering text is not available in frame-less documents.
|
| if (!canvas()->document().frame())
|
| @@ -1974,10 +1974,10 @@ void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, flo
|
| textRun.setNormalizeSpace(true);
|
| // Draw the item text at the correct point.
|
| FloatPoint location(x, y + getFontBaseline(fontMetrics));
|
| - float fontWidth = font.width(textRun);
|
| + double fontWidth = font.width(textRun);
|
|
|
| bool useMaxWidth = (maxWidth && *maxWidth < fontWidth);
|
| - float width = useMaxWidth ? *maxWidth : fontWidth;
|
| + double width = useMaxWidth ? *maxWidth : fontWidth;
|
|
|
| TextAlign align = state().textAlign();
|
| if (align == StartTextAlign)
|
| @@ -2031,8 +2031,8 @@ void CanvasRenderingContext2D::inflateStrokeRect(FloatRect& rect) const
|
| // Fast approximation of the stroke's bounding rect.
|
| // This yields a slightly oversized rect but is very fast
|
| // compared to Path::strokeBoundingRect().
|
| - static const float root2 = sqrtf(2);
|
| - float delta = state().lineWidth() / 2;
|
| + static const double root2 = sqrtf(2);
|
| + double delta = state().lineWidth() / 2;
|
| if (state().lineJoin() == MiterJoin)
|
| delta *= state().miterLimit();
|
| else if (state().lineCap() == SquareCap)
|
|
|