From cc6b0f11e7ea4b8192aa7b2a85140cc6dd3f6709 Mon Sep 17 00:00:00 2001 From: Job Bautista Date: Thu, 9 Feb 2023 20:51:34 +0800 Subject: [PATCH 1/4] Issue #2107 - Clean up caret when destroying editor. Editor changes caret visibility during drag and drop. But when destroying editor, we don't restore caret state. So we should restore it when destroying editor. Co-authored-by: Makoto Kato --- editor/libeditor/EditorEventListener.cpp | 2 + layout/base/tests/bug1496118-ref.html | 24 ++++++++++++ layout/base/tests/bug1496118.html | 37 +++++++++++++++++++ layout/base/tests/mochitest.ini | 2 + .../base/tests/test_reftests_with_caret.html | 1 + 5 files changed, 66 insertions(+) create mode 100644 layout/base/tests/bug1496118-ref.html create mode 100644 layout/base/tests/bug1496118.html diff --git a/editor/libeditor/EditorEventListener.cpp b/editor/libeditor/EditorEventListener.cpp index 1a3beca6e6..32f3585288 100644 --- a/editor/libeditor/EditorEventListener.cpp +++ b/editor/libeditor/EditorEventListener.cpp @@ -238,6 +238,8 @@ EditorEventListener::Disconnect() void EditorEventListener::UninstallFromEditor() { + CleanupDragDropCaret(); + nsCOMPtr piTarget = mEditorBase->GetDOMEventTarget(); if (!piTarget) { return; diff --git a/layout/base/tests/bug1496118-ref.html b/layout/base/tests/bug1496118-ref.html new file mode 100644 index 0000000000..feaf31476b --- /dev/null +++ b/layout/base/tests/bug1496118-ref.html @@ -0,0 +1,24 @@ + + + + + + + + + +
+ +
+ + + diff --git a/layout/base/tests/bug1496118.html b/layout/base/tests/bug1496118.html new file mode 100644 index 0000000000..7656e010ba --- /dev/null +++ b/layout/base/tests/bug1496118.html @@ -0,0 +1,37 @@ + + + + + + + + + +
+ +
+ + + diff --git a/layout/base/tests/mochitest.ini b/layout/base/tests/mochitest.ini index fc616b1ef8..846ab52813 100644 --- a/layout/base/tests/mochitest.ini +++ b/layout/base/tests/mochitest.ini @@ -179,6 +179,8 @@ support-files = bug1263357-4-ref.html bug1263357-5.html bug1263357-5-ref.html + bug1496118.html + bug1496118-ref.html input-maxlength-valid-before-change.html input-maxlength-valid-change.html input-maxlength-invalid-change.html diff --git a/layout/base/tests/test_reftests_with_caret.html b/layout/base/tests/test_reftests_with_caret.html index 062c605b98..d39dd737ad 100644 --- a/layout/base/tests/test_reftests_with_caret.html +++ b/layout/base/tests/test_reftests_with_caret.html @@ -186,6 +186,7 @@ var tests = [ [ 'bug1263357-3.html' , 'bug1263357-3-ref.html'] , [ 'bug1263357-4.html' , 'bug1263357-4-ref.html'] , [ 'bug1263357-5.html' , 'bug1263357-5-ref.html'] , + [ 'bug1496118.html' , 'bug1496118-ref.html' ] , function() {SpecialPowers.pushPrefEnv({'clear': [['layout.accessiblecaret.enabled']]}, nextTest);} , ]; From bca689b4838f3d516c9a35ab7afe8a94c47d3691 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Sun, 19 Feb 2023 12:08:17 +0100 Subject: [PATCH 2/4] [widget] Properly test for and handle errors in target-surface creation and mapping. --- widget/windows/TaskbarPreview.cpp | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/widget/windows/TaskbarPreview.cpp b/widget/windows/TaskbarPreview.cpp index 502b47964d..ec182d8ae0 100644 --- a/widget/windows/TaskbarPreview.cpp +++ b/widget/windows/TaskbarPreview.cpp @@ -355,32 +355,38 @@ TaskbarPreviewCallback::Done(nsISupports *aCanvas, bool aDrawBorder) { } RefPtr target = new gfxWindowsSurface(source->GetSize(), gfx::SurfaceFormat::A8R8G8B8_UINT32); - if (!target) { + if (target->CairoStatus() != CAIRO_STATUS_SUCCESS) { return NS_ERROR_FAILURE; } - RefPtr srcSurface = source->GetDataSurface(); + using DataSrcSurf = gfx::DataSourceSurface; + RefPtr srcSurface = source->GetDataSurface(); RefPtr imageSurface = target->GetAsImageSurface(); if (!srcSurface || !imageSurface) { return NS_ERROR_FAILURE; } - gfx::DataSourceSurface::MappedSurface sourceMap; - srcSurface->Map(gfx::DataSourceSurface::READ, &sourceMap); - mozilla::gfx::CopySurfaceDataToPackedArray(sourceMap.mData, - imageSurface->Data(), - srcSurface->GetSize(), - sourceMap.mStride, - BytesPerPixel(srcSurface->GetFormat())); - srcSurface->Unmap(); + DataSrcSurf::ScopedMap const sourceMap(srcSurface, DataSrcSurf::READ); + if (sourceMap.IsMapped()) { + mozilla::gfx::CopySurfaceDataToPackedArray(sourceMap.GetData(), + imageSurface->Data(), + srcSurface->GetSize(), + sourceMap.GetStride(), + BytesPerPixel(srcSurface->GetFormat())); + } else if (source->GetSize().IsEmpty()) { + // A zero-size source-surface probably shouldn't happen, but is harmless + // here. Fall through. + } else { + return NS_ERROR_FAILURE; + } HDC hDC = target->GetDC(); HBITMAP hBitmap = (HBITMAP)GetCurrentObject(hDC, OBJ_BITMAP); DWORD flags = aDrawBorder ? DWM_SIT_DISPLAYFRAME : 0; - POINT pptClient = { 0, 0 }; HRESULT hr; if (!mIsThumbnail) { + POINT pptClient = { 0, 0 }; hr = WinUtils::dwmSetIconicLivePreviewBitmapPtr(mPreview->PreviewWindow(), hBitmap, &pptClient, flags); } else { @@ -388,6 +394,7 @@ TaskbarPreviewCallback::Done(nsISupports *aCanvas, bool aDrawBorder) { hBitmap, flags); } MOZ_ASSERT(SUCCEEDED(hr)); + mozilla::Unused << hr; return NS_OK; } From bc50a7d3c6d8e03f99b64852c58ed8b7cc73a07c Mon Sep 17 00:00:00 2001 From: Moonchild Date: Sun, 19 Feb 2023 13:10:29 +0100 Subject: [PATCH 3/4] [DOM] Check whether module load request was already cancelled when a load fails --- dom/script/ModuleLoadRequest.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dom/script/ModuleLoadRequest.cpp b/dom/script/ModuleLoadRequest.cpp index ec924ea7a4..2abc6236e8 100644 --- a/dom/script/ModuleLoadRequest.cpp +++ b/dom/script/ModuleLoadRequest.cpp @@ -148,6 +148,11 @@ ModuleLoadRequest::LoadFailed() // We failed to load the source text or an error occurred unrelated to the // content of the module (e.g. OOM). + if (IsCanceled()) { + return; + } + + MOZ_ASSERT(!IsReadyToRun()); MOZ_ASSERT(!mModuleScript); Cancel(); From cdda874cffe002b2d335890d4aabc8f91c8b9a43 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Sun, 19 Feb 2023 15:26:44 +0100 Subject: [PATCH 4/4] [NSS] Update NSS to pick up fixes. --- security/nss/coreconf/coreconf.dep | 1 - security/nss/lib/pkcs12/p12d.c | 19 +++++++++++++++---- security/nss/lib/pkcs12/p12t.h | 1 + security/nss/lib/pkcs12/p12tmpl.c | 4 ++-- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/security/nss/coreconf/coreconf.dep b/security/nss/coreconf/coreconf.dep index 590d1bfaee..5182f75552 100644 --- a/security/nss/coreconf/coreconf.dep +++ b/security/nss/coreconf/coreconf.dep @@ -10,4 +10,3 @@ */ #error "Do not include this header file." - diff --git a/security/nss/lib/pkcs12/p12d.c b/security/nss/lib/pkcs12/p12d.c index 34362db2de..d148d48d5f 100644 --- a/security/nss/lib/pkcs12/p12d.c +++ b/security/nss/lib/pkcs12/p12d.c @@ -341,27 +341,38 @@ sec_pkcs12_decoder_safe_bag_update(void *arg, const char *data, * and that there are no errors. If so, just return rather * than continuing to process. */ - if (!safeContentsCtx || !safeContentsCtx->p12dcx || - safeContentsCtx->p12dcx->error || safeContentsCtx->skipCurrentSafeBag) { + if (!safeContentsCtx || !safeContentsCtx->p12dcx || safeContentsCtx->skipCurrentSafeBag) { return; } p12dcx = safeContentsCtx->p12dcx; + /* make sure that there are no errors and we are not skipping the current safeBag */ + if (p12dcx->error || safeContentsCtx->skipCurrentSafeBag) { + goto loser; + } + rv = SEC_ASN1DecoderUpdate(safeContentsCtx->currentSafeBagA1Dcx, data, len); if (rv != SECSuccess) { p12dcx->errorValue = PORT_GetError(); + p12dcx->error = PR_TRUE; + goto loser; + } + + /* The update may have set safeContentsCtx->skipCurrentSafeBag, and we + * may not get another opportunity to clean up the decoder context. + */ + if (safeContentsCtx->skipCurrentSafeBag) { goto loser; } return; loser: - /* set the error, and finish the decoder context. because there + /* Finish the decoder context. Because there * is not a way of returning an error message, it may be worth * while to do a check higher up and finish any decoding contexts * that are still open. */ - p12dcx->error = PR_TRUE; SEC_ASN1DecoderFinish(safeContentsCtx->currentSafeBagA1Dcx); safeContentsCtx->currentSafeBagA1Dcx = NULL; return; diff --git a/security/nss/lib/pkcs12/p12t.h b/security/nss/lib/pkcs12/p12t.h index b22f0dd823..d449afdd89 100644 --- a/security/nss/lib/pkcs12/p12t.h +++ b/security/nss/lib/pkcs12/p12t.h @@ -73,6 +73,7 @@ struct sec_PKCS12SafeBagStr { sec_PKCS12CRLBag *crlBag; sec_PKCS12SecretBag *secretBag; sec_PKCS12SafeContents *safeContents; + SECItem *unknownBag; } safeBagContent; sec_PKCS12Attribute **attribs; diff --git a/security/nss/lib/pkcs12/p12tmpl.c b/security/nss/lib/pkcs12/p12tmpl.c index 7437cbcc60..b08384f66a 100644 --- a/security/nss/lib/pkcs12/p12tmpl.c +++ b/security/nss/lib/pkcs12/p12tmpl.c @@ -30,12 +30,12 @@ sec_pkcs12_choose_safe_bag_type(void *src_or_dest, PRBool encoding) oiddata = SECOID_FindOID(&safeBag->safeBagType); if (oiddata == NULL) { - return SEC_ASN1_GET(SEC_AnyTemplate); + return SEC_ASN1_GET(SEC_PointerToAnyTemplate); } switch (oiddata->offset) { default: - theTemplate = SEC_ASN1_GET(SEC_AnyTemplate); + theTemplate = SEC_ASN1_GET(SEC_PointerToAnyTemplate); break; case SEC_OID_PKCS12_V1_KEY_BAG_ID: theTemplate = SEC_ASN1_GET(SECKEY_PointerToPrivateKeyInfoTemplate);