diff options
author | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-04 19:34:22 +0000 |
---|---|---|
committer | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-04 19:34:22 +0000 |
commit | 64cd3c333c5524da0cf4620035797500f6d42655 (patch) | |
tree | da9de7e8b8285da8a8e8a7903ce88deb97820a64 /webkit/port | |
parent | 13637d5d74d5ac18b218ac8f0ba8506eef2417b6 (diff) | |
download | chromium_src-64cd3c333c5524da0cf4620035797500f6d42655.zip chromium_src-64cd3c333c5524da0cf4620035797500f6d42655.tar.gz chromium_src-64cd3c333c5524da0cf4620035797500f6d42655.tar.bz2 |
Fix a crasher when printing.
Review URL: http://codereview.chromium.org/8218
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4628 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/port')
-rw-r--r-- | webkit/port/platform/graphics/GraphicsContextSkia.cpp | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/webkit/port/platform/graphics/GraphicsContextSkia.cpp b/webkit/port/platform/graphics/GraphicsContextSkia.cpp index b14839e..314e8dd 100644 --- a/webkit/port/platform/graphics/GraphicsContextSkia.cpp +++ b/webkit/port/platform/graphics/GraphicsContextSkia.cpp @@ -193,12 +193,18 @@ GraphicsContext::~GraphicsContext() void GraphicsContext::savePlatformState() { + if (paintingDisabled()) + return; + // Save our private State. platformContext()->save(); } void GraphicsContext::restorePlatformState() { + if (paintingDisabled()) + return; + // Restore our private State. platformContext()->restore(); } @@ -589,7 +595,11 @@ FloatRect GraphicsContext::getBoundingBoxForCurrentPath(bool includeStroke) cons bool GraphicsContext::strokeContains(const Path& path, const FloatPoint& point) const { SkPaint paint; - platformContext()->setupPaintForStroking(&paint, 0, 0); + // The SkPaint state is not kept since platformContext() is NULL. + // If there is a non-identity matrix setup, the path won't be transformed + // correctly which may result in inconsistencies. + if (!paintingDisabled()) + platformContext()->setupPaintForStroking(&paint, 0, 0); SkPath strokePath; paint.getFillPath(*path.platformPath(), &strokePath); @@ -760,6 +770,8 @@ void GraphicsContext::endTransparencyLayer() void GraphicsContext::setPlatformStrokeStyle(const StrokeStyle& stroke) { + if (paintingDisabled()) + return; platformContext()->setStrokeStyle(stroke); } @@ -788,6 +800,8 @@ void GraphicsContext::setPlatformShadow(const IntSize& size, int blur, const Col void GraphicsContext::clearPlatformShadow() { + if (paintingDisabled()) + return; platformContext()->setDrawLooper(0); } @@ -828,16 +842,22 @@ PlatformGraphicsContext* GraphicsContext::platformContext() const void GraphicsContext::setMiterLimit(float limit) { + if (paintingDisabled()) + return; platformContext()->setMiterLimit(limit); } void GraphicsContext::setAlpha(float alpha) { + if (paintingDisabled()) + return; platformContext()->setAlpha(alpha); } void GraphicsContext::setCompositeOperation(CompositeOperator op) { + if (paintingDisabled()) + return; platformContext()->setPorterDuffMode(WebCoreCompositeToSkiaComposite(op)); } @@ -858,6 +878,8 @@ void GraphicsContext::clearRect(const FloatRect& rect) void GraphicsContext::setLineCap(LineCap cap) { + if (paintingDisabled()) + return; switch (cap) { case ButtCap: platformContext()->setLineCap(SkPaint::kButt_Cap); @@ -876,6 +898,8 @@ void GraphicsContext::setLineCap(LineCap cap) void GraphicsContext::setLineDash(const DashArray& dashes, float dashOffset) { + if (paintingDisabled()) + return; // TODO(dglazkov): This is lifted directly off SkiaSupport, lines 49-74 // so it is not guaranteed to work correctly. I made some minor cosmetic // refactoring, but not much else. Please fix this? @@ -897,6 +921,8 @@ void GraphicsContext::setLineDash(const DashArray& dashes, float dashOffset) void GraphicsContext::setLineJoin(LineJoin join) { + if (paintingDisabled()) + return; switch (join) { case MiterJoin: platformContext()->setLineJoin(SkPaint::kMiter_Join); @@ -936,6 +962,8 @@ void GraphicsContext::translate(float w, float h) void GraphicsContext::concatCTM(const AffineTransform& xform) { + if (paintingDisabled()) + return; platformContext()->canvas()->concat(xform); } @@ -1024,11 +1052,15 @@ void GraphicsContext::setPlatformTextDrawingMode(int mode) void GraphicsContext::addPath(const Path& path) { + if (paintingDisabled()) + return; platformContext()->addPath(*path.platformPath()); } void GraphicsContext::beginPath() { + if (paintingDisabled()) + return; platformContext()->beginPath(); } |