diff --git a/dom/events/EventStateManager.cpp b/dom/events/EventStateManager.cpp index 8c5bf1932..846601b06 100644 --- a/dom/events/EventStateManager.cpp +++ b/dom/events/EventStateManager.cpp @@ -4109,9 +4109,10 @@ EventStateManager::NotifyMouseOver(WidgetMouseEvent* aMouseEvent, // content associated with our subdocument. EnsureDocument(mPresContext); if (nsIDocument *parentDoc = mDocument->GetParentDocument()) { - if (nsIContent *docContent = parentDoc->FindContentForSubDocument(mDocument)) { + if (nsCOMPtr docContent = + parentDoc->FindContentForSubDocument(mDocument)) { if (nsIPresShell *parentShell = parentDoc->GetShell()) { - EventStateManager* parentESM = + RefPtr parentESM = parentShell->GetPresContext()->EventStateManager(); parentESM->NotifyMouseOver(aMouseEvent, docContent); } diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index 075dd3d41..f9b47f5bb 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -517,6 +517,12 @@ nsDocumentViewer::~nsDocumentViewer() mDocument->Destroy(); } + if (mPrintEngine) { + mPrintEngine->Destroy(); + mPrintEngine = nullptr; + } + + MOZ_RELEASE_ASSERT(mDestroyRefCount == 0); NS_ASSERTION(!mPresShell && !mPresContext, "User did not call nsIContentViewer::Destroy"); if (mPresShell || mPresContext) { @@ -1564,7 +1570,6 @@ nsDocumentViewer::Destroy() // We also keep the viewer from being cached in session history, since // we require all documents there to be sanitized. if (mDestroyRefCount != 0) { - --mDestroyRefCount; return NS_OK; } @@ -4209,6 +4214,12 @@ nsDocumentViewer::IncrementDestroyRefCount() ++mDestroyRefCount; } +void +nsDocumentViewer::DecrementDestroyRefCount() +{ + --mDestroyRefCount; +} + //------------------------------------------------------------ #if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW) diff --git a/layout/base/nsIDocumentViewerPrint.h b/layout/base/nsIDocumentViewerPrint.h index 842771b4a..2c753c993 100644 --- a/layout/base/nsIDocumentViewerPrint.h +++ b/layout/base/nsIDocumentViewerPrint.h @@ -39,6 +39,7 @@ public: virtual nsresult CreateStyleSet(nsIDocument* aDocument, nsStyleSet** aStyleSet) = 0; virtual void IncrementDestroyRefCount() = 0; + virtual void DecrementDestroyRefCount() = 0; virtual void ReturnToGalleyPresentation() = 0; @@ -73,6 +74,7 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumentViewerPrint, virtual bool GetIsPrintPreview() override; \ virtual nsresult CreateStyleSet(nsIDocument* aDocument, nsStyleSet** aStyleSet) override; \ virtual void IncrementDestroyRefCount() override; \ + virtual void DecrementDestroyRefCount() override; \ virtual void ReturnToGalleyPresentation() override; \ virtual void OnDonePrinting() override; \ virtual bool IsInitializedForPrintPreview() override; \ diff --git a/layout/printing/nsPagePrintTimer.cpp b/layout/printing/nsPagePrintTimer.cpp index 01d44d86d..7ea77e92d 100644 --- a/layout/printing/nsPagePrintTimer.cpp +++ b/layout/printing/nsPagePrintTimer.cpp @@ -12,14 +12,8 @@ NS_IMPL_ISUPPORTS_INHERITED(nsPagePrintTimer, nsRunnable, nsITimerCallback) nsPagePrintTimer::~nsPagePrintTimer() { - // "Destroy" the document viewer; this normally doesn't actually - // destroy it because of the IncrementDestroyRefCount call below - // XXX This is messy; the document viewer should use a single approach - // to keep itself alive during printing - nsCOMPtr cv(do_QueryInterface(mDocViewerPrint)); - if (cv) { - cv->Destroy(); - } + // This matches the IncrementDestroyRefCount call in the constructor. + mDocViewerPrint->DecrementDestroyRefCount(); } nsresult diff --git a/media/libvpx/vpx/src/vpx_encoder.c b/media/libvpx/vpx/src/vpx_encoder.c index cd10c411c..88b1da481 100644 --- a/media/libvpx/vpx/src/vpx_encoder.c +++ b/media/libvpx/vpx/src/vpx_encoder.c @@ -13,8 +13,11 @@ * \brief Provides the high level interface to wrap encoder algorithms. * */ +#include #include +#include #include +#include "vp8/common/blockd.h" #include "vpx_config.h" #include "vpx/internal/vpx_codec_internal.h" @@ -89,6 +92,8 @@ vpx_codec_err_t vpx_codec_enc_init_multi_ver(vpx_codec_ctx_t *ctx, int i; void *mem_loc = NULL; + if (iface->enc.mr_get_mem_loc == NULL) return VPX_CODEC_INCAPABLE; + if (!(res = iface->enc.mr_get_mem_loc(cfg, &mem_loc))) { for (i = 0; i < num_enc; i++) { vpx_codec_priv_enc_mr_cfg_t mr_cfg; @@ -98,28 +103,29 @@ vpx_codec_err_t vpx_codec_enc_init_multi_ver(vpx_codec_ctx_t *ctx, dsf->den > dsf->num) { res = VPX_CODEC_INVALID_PARAM; break; + } else { + + mr_cfg.mr_low_res_mode_info = mem_loc; + mr_cfg.mr_total_resolutions = num_enc; + mr_cfg.mr_encoder_id = num_enc - 1 - i; + mr_cfg.mr_down_sampling_factor.num = dsf->num; + mr_cfg.mr_down_sampling_factor.den = dsf->den; + + /* Force Key-frame synchronization. Namely, encoder at higher + * resolution always use the same frame_type chosen by the + * lowest-resolution encoder. + */ + if (mr_cfg.mr_encoder_id) + cfg->kf_mode = VPX_KF_DISABLED; + + ctx->iface = iface; + ctx->name = iface->name; + ctx->priv = NULL; + ctx->init_flags = flags; + ctx->config.enc = cfg; + res = ctx->iface->init(ctx, &mr_cfg); } - mr_cfg.mr_low_res_mode_info = mem_loc; - mr_cfg.mr_total_resolutions = num_enc; - mr_cfg.mr_encoder_id = num_enc - 1 - i; - mr_cfg.mr_down_sampling_factor.num = dsf->num; - mr_cfg.mr_down_sampling_factor.den = dsf->den; - - /* Force Key-frame synchronization. Namely, encoder at higher - * resolution always use the same frame_type chosen by the - * lowest-resolution encoder. - */ - if (mr_cfg.mr_encoder_id) - cfg->kf_mode = VPX_KF_DISABLED; - - ctx->iface = iface; - ctx->name = iface->name; - ctx->priv = NULL; - ctx->init_flags = flags; - ctx->config.enc = cfg; - res = ctx->iface->init(ctx, &mr_cfg); - if (res) { const char *error_detail = ctx->priv ? ctx->priv->err_detail : NULL; @@ -134,11 +140,14 @@ vpx_codec_err_t vpx_codec_enc_init_multi_ver(vpx_codec_ctx_t *ctx, vpx_codec_destroy(ctx); i--; } +#if CONFIG_MULTI_RES_ENCODING + assert(mem_loc); + free(((LOWER_RES_FRAME_INFO *)mem_loc)->mb_info); + free(mem_loc); +#endif + return SAVE_STATUS(ctx, res); } - if (res) - break; - ctx++; cfg++; dsf++;