diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-11-10 11:39:27 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-11-10 11:39:27 +0100 |
commit | 974a481d12bf430891725bd3662876358e57e11a (patch) | |
tree | cad011151456251fef2f1b8d02ef4b4e45fad61a /dom/html/HTMLCanvasElement.cpp | |
parent | 6bd66b1728eeddb058066edda740aaeb2ceaec23 (diff) | |
parent | 736d25cbec4541186ed46c935c117ce4d1c7f3bb (diff) | |
download | UXP-974a481d12bf430891725bd3662876358e57e11a.tar UXP-974a481d12bf430891725bd3662876358e57e11a.tar.gz UXP-974a481d12bf430891725bd3662876358e57e11a.tar.lz UXP-974a481d12bf430891725bd3662876358e57e11a.tar.xz UXP-974a481d12bf430891725bd3662876358e57e11a.zip |
Merge branch 'master' into js-modules
# Conflicts:
# modules/libpref/init/all.js
Diffstat (limited to 'dom/html/HTMLCanvasElement.cpp')
-rw-r--r-- | dom/html/HTMLCanvasElement.cpp | 71 |
1 files changed, 19 insertions, 52 deletions
diff --git a/dom/html/HTMLCanvasElement.cpp b/dom/html/HTMLCanvasElement.cpp index 88b41bce0..4b5deab18 100644 --- a/dom/html/HTMLCanvasElement.cpp +++ b/dom/html/HTMLCanvasElement.cpp @@ -42,7 +42,6 @@ #include "nsRefreshDriver.h" #include "nsStreamUtils.h" #include "ActiveLayerTracker.h" -#include "VRManagerChild.h" #include "WebGL1Context.h" #include "WebGL2Context.h" @@ -358,7 +357,6 @@ NS_IMPL_ISUPPORTS(HTMLCanvasElementObserver, nsIObserver) HTMLCanvasElement::HTMLCanvasElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo) : nsGenericHTMLElement(aNodeInfo), mResetLayer(true) , - mVRPresentationActive(false), mWriteOnly(false) {} @@ -554,17 +552,23 @@ HTMLCanvasElement::CopyInnerTo(Element* aDest) HTMLCanvasElement* dest = static_cast<HTMLCanvasElement*>(aDest); dest->mOriginalCanvas = this; - nsCOMPtr<nsISupports> cxt; - dest->GetContext(NS_LITERAL_STRING("2d"), getter_AddRefs(cxt)); - RefPtr<CanvasRenderingContext2D> context2d = - static_cast<CanvasRenderingContext2D*>(cxt.get()); - if (context2d && !mPrintCallback) { - CanvasImageSource source; - source.SetAsHTMLCanvasElement() = this; - ErrorResult err; - context2d->DrawImage(source, - 0.0, 0.0, err); - rv = err.StealNSResult(); + // We make sure that the canvas is not zero sized since that would cause + // the DrawImage call below to return an error, which would cause printing + // to fail. + nsIntSize size = GetWidthHeight(); + if (size.height > 0 && size.width > 0) { + nsCOMPtr<nsISupports> cxt; + dest->GetContext(NS_LITERAL_STRING("2d"), getter_AddRefs(cxt)); + RefPtr<CanvasRenderingContext2D> context2d = + static_cast<CanvasRenderingContext2D*>(cxt.get()); + if (context2d && !mPrintCallback) { + CanvasImageSource source; + source.SetAsHTMLCanvasElement() = this; + ErrorResult err; + context2d->DrawImage(source, + 0.0, 0.0, err); + rv = err.StealNSResult(); + } } } return rv; @@ -1002,7 +1006,7 @@ HTMLCanvasElement::GetSize() } bool -HTMLCanvasElement::IsWriteOnly() +HTMLCanvasElement::IsWriteOnly() const { return mWriteOnly; } @@ -1111,7 +1115,7 @@ HTMLCanvasElement::GetCanvasLayer(nsDisplayListBuilder* aBuilder, static uint8_t sOffscreenCanvasLayerUserDataDummy = 0; if (mCurrentContext) { - return mCurrentContext->GetCanvasLayer(aBuilder, aOldLayer, aManager, mVRPresentationActive); + return mCurrentContext->GetCanvasLayer(aBuilder, aOldLayer, aManager); } if (mOffscreenCanvas) { @@ -1441,42 +1445,5 @@ HTMLCanvasElement::InvalidateFromAsyncCanvasRenderer(AsyncCanvasRenderer *aRende element->InvalidateCanvasContent(nullptr); } -void -HTMLCanvasElement::StartVRPresentation() -{ - WebGLContext* webgl = static_cast<WebGLContext*>(GetContextAtIndex(0)); - if (!webgl) { - return; - } - - if (!webgl->StartVRPresentation()) { - return; - } - - mVRPresentationActive = true; -} - -void -HTMLCanvasElement::StopVRPresentation() -{ - mVRPresentationActive = false; -} - -already_AddRefed<layers::SharedSurfaceTextureClient> -HTMLCanvasElement::GetVRFrame() -{ - if (GetCurrentContextType() != CanvasContextType::WebGL1 && - GetCurrentContextType() != CanvasContextType::WebGL2) { - return nullptr; - } - - WebGLContext* webgl = static_cast<WebGLContext*>(GetContextAtIndex(0)); - if (!webgl) { - return nullptr; - } - - return webgl->GetVRFrame(); -} - } // namespace dom } // namespace mozilla |