summaryrefslogtreecommitdiffstats
path: root/dom/canvas/ImageBitmap.cpp
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-05-27 19:19:27 +0200
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-05-27 19:19:27 +0200
commitfb1b45e5fcb82e76e303665fbb9d04fb2a800b31 (patch)
tree97baa867e3534b1bd5153067d2bd853462a4b12b /dom/canvas/ImageBitmap.cpp
parent47c52f2dc2cc4eb4f5582a7ca50b682548b1708c (diff)
downloadUXP-fb1b45e5fcb82e76e303665fbb9d04fb2a800b31.tar
UXP-fb1b45e5fcb82e76e303665fbb9d04fb2a800b31.tar.gz
UXP-fb1b45e5fcb82e76e303665fbb9d04fb2a800b31.tar.lz
UXP-fb1b45e5fcb82e76e303665fbb9d04fb2a800b31.tar.xz
UXP-fb1b45e5fcb82e76e303665fbb9d04fb2a800b31.zip
Improve origin-clean algorithm
Diffstat (limited to 'dom/canvas/ImageBitmap.cpp')
-rw-r--r--dom/canvas/ImageBitmap.cpp34
1 files changed, 2 insertions, 32 deletions
diff --git a/dom/canvas/ImageBitmap.cpp b/dom/canvas/ImageBitmap.cpp
index 6efe1b318..4a1b6e3c2 100644
--- a/dom/canvas/ImageBitmap.cpp
+++ b/dom/canvas/ImageBitmap.cpp
@@ -315,36 +315,6 @@ private:
const Maybe<IntRect>& mCropRect;
};
-static bool
-CheckSecurityForHTMLElements(bool aIsWriteOnly, bool aCORSUsed, nsIPrincipal* aPrincipal)
-{
- MOZ_ASSERT(aPrincipal);
-
- if (aIsWriteOnly) {
- return false;
- }
-
- if (!aCORSUsed) {
- nsIGlobalObject* incumbentSettingsObject = GetIncumbentGlobal();
- if (NS_WARN_IF(!incumbentSettingsObject)) {
- return false;
- }
-
- nsIPrincipal* principal = incumbentSettingsObject->PrincipalOrNull();
- if (NS_WARN_IF(!principal) || !(principal->Subsumes(aPrincipal))) {
- return false;
- }
- }
-
- return true;
-}
-
-static bool
-CheckSecurityForHTMLElements(const nsLayoutUtils::SurfaceFromElementResult& aRes)
-{
- return CheckSecurityForHTMLElements(aRes.mIsWriteOnly, aRes.mCORSUsed, aRes.mPrincipal);
-}
-
/*
* A wrapper to the nsLayoutUtils::SurfaceFromElement() function followed by the
* security checking.
@@ -365,7 +335,7 @@ GetSurfaceFromElement(nsIGlobalObject* aGlobal, HTMLElementType& aElement,
}
// Check origin-clean and pass back
- *aWriteOnly = !CheckSecurityForHTMLElements(res);
+ *aWriteOnly = res.mIsWriteOnly;
return surface.forget();
}
@@ -818,7 +788,7 @@ ImageBitmap::CreateInternal(nsIGlobalObject* aGlobal, HTMLVideoElement& aVideoEl
nsCOMPtr<nsIPrincipal> principal = aVideoEl.GetCurrentVideoPrincipal();
bool CORSUsed = aVideoEl.GetCORSMode() != CORS_NONE;
- writeOnly = !CheckSecurityForHTMLElements(false, CORSUsed, principal);
+ writeOnly = CheckWriteOnlySecurity(CORSUsed, principal);
// Create ImageBitmap.
ImageContainer *container = aVideoEl.GetImageContainer();