mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-04 14:58:37 +09:00
Improve origin-clean algorithm
This commit is contained in:
parent
21eef2bff9
commit
85e68b684f
5 changed files with 41 additions and 39 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue