Bug 1355168 - Ensure mTarget in CanvasRendering2D::DrawWindow; r?mats
MozReview-Commit-ID: 3xmzJc5Mq7J
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -5575,25 +5575,28 @@ CanvasRenderingContext2D::DrawWindow(nsG
// protect against too-large surfaces that will cause allocation
// or overflow issues
if (!Factory::CheckSurfaceSize(IntSize(int32_t(aW), int32_t(aH)), 0xffff)) {
aError.Throw(NS_ERROR_FAILURE);
return;
}
+ // Flush layout updates
+ if (!(aFlags & nsIDOMCanvasRenderingContext2D::DRAWWINDOW_DO_NOT_FLUSH)) {
+ nsContentUtils::FlushLayoutForTree(aWindow.AsInner()->GetOuterWindow());
+ }
+
CompositionOp op = UsedOperation();
bool discardContent = GlobalAlpha() == 1.0f
&& (op == CompositionOp::OP_OVER || op == CompositionOp::OP_SOURCE);
const gfx::Rect drawRect(aX, aY, aW, aH);
EnsureTarget(discardContent ? &drawRect : nullptr);
-
- // Flush layout updates
- if (!(aFlags & nsIDOMCanvasRenderingContext2D::DRAWWINDOW_DO_NOT_FLUSH)) {
- nsContentUtils::FlushLayoutForTree(aWindow.AsInner()->GetOuterWindow());
+ if (!IsTargetValid()) {
+ return;
}
RefPtr<nsPresContext> presContext;
nsIDocShell* docshell = aWindow.GetDocShell();
if (docshell) {
docshell->GetPresContext(getter_AddRefs(presContext));
}
if (!presContext) {