-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
…M1773717; mark clobber; fix zlib warning; now officially on 102ESR
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5229,6 +5229,16 @@ CanvasRenderingContext2D::GetImageData(JSContext* aCx, double aSx, | |
return imageData.forget(); | ||
} | ||
|
||
static IntRect ClipImageDataTransfer(IntRect& aSrc, const IntPoint& aDestOffset, | ||
const IntSize& aDestBounds) { | ||
IntRect dest = aSrc; | ||
dest.SafeMoveBy(aDestOffset); | ||
dest = IntRect(IntPoint(0, 0), aDestBounds).SafeIntersect(dest); | ||
|
||
aSrc = aSrc.SafeIntersect(dest - aDestOffset); | ||
return aSrc + aDestOffset; | ||
} | ||
|
||
nsresult | ||
CanvasRenderingContext2D::GetImageDataArray(JSContext* aCx, | ||
int32_t aX, | ||
|
@@ -5266,8 +5276,9 @@ CanvasRenderingContext2D::GetImageDataArray(JSContext* aCx, | |
} | ||
|
||
IntRect srcRect(0, 0, mWidth, mHeight); | ||
IntRect destRect(aX, aY, aWidth, aHeight); | ||
IntRect srcReadRect = srcRect.Intersect(destRect); | ||
IntRect dstWriteRect(0, 0, aWidth, aHeight); | ||
IntRect srcReadRect = ClipImageDataTransfer(dstWriteRect, IntPoint(aX, aY), | ||
IntSize(mWidth, mHeight)); | ||
RefPtr<DataSourceSurface> readback; | ||
DataSourceSurface::MappedSurface rawData; | ||
if (!srcReadRect.IsEmpty()) { | ||
|
@@ -5280,9 +5291,6 @@ CanvasRenderingContext2D::GetImageDataArray(JSContext* aCx, | |
} | ||
} | ||
|
||
IntRect dstWriteRect = srcReadRect; | ||
dstWriteRect.MoveBy(-aX, -aY); | ||
|
||
uint8_t* src; | ||
uint32_t srcStride; | ||
|
||
|
@@ -5467,10 +5475,10 @@ CanvasRenderingContext2D::PutImageData_explicit(int32_t x, int32_t y, uint32_t w | |
dirtyRect = imageDataRect; | ||
} | ||
|
||
dirtyRect.MoveBy(IntPoint(x, y)); | ||
dirtyRect = IntRect(0, 0, mWidth, mHeight).Intersect(dirtyRect); | ||
|
||
if (dirtyRect.Width() <= 0 || dirtyRect.Height() <= 0) { | ||
IntRect srcRect = dirtyRect; | ||
dirtyRect = ClipImageDataTransfer(srcRect, IntPoint(x, y), | ||
IntSize(mWidth, mHeight)); | ||
if (dirtyRect.IsEmpty()) { | ||
return NS_OK; | ||
} | ||
|
||
|
@@ -5492,8 +5500,8 @@ CanvasRenderingContext2D::PutImageData_explicit(int32_t x, int32_t y, uint32_t w | |
return NS_ERROR_FAILURE; | ||
} | ||
|
||
uint32_t copyX = dirtyRect.x - x; | ||
uint32_t copyY = dirtyRect.y - y; | ||
uint32_t copyX = dirtyRect.x; | ||
uint32_t copyY = dirtyRect.y; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
classilla
Author
Owner
|
||
//uint8_t *src = aArray->Data(); | ||
uint8_t *dst = imgsurf->Data(); | ||
uint8_t* srcLine = aArray->Data() + copyY * (w * 4) + copyX * 4; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
#include "nsINetworkInterceptController.h" | ||
#include "InterceptedJARChannel.h" | ||
#include "nsInputStreamPump.h" | ||
#include "nsStandardURL.h" | ||
|
||
using namespace mozilla; | ||
using namespace mozilla::net; | ||
|
@@ -83,6 +84,24 @@ class nsJARInputThunk : public nsIInputStream | |
fullJarURI->GetAsciiSpec(mJarDirSpec); | ||
NS_ASSERTION(NS_SUCCEEDED(rv), "this shouldn't fail"); | ||
} | ||
/* implement bug 1771774 without NS_MutateURI: use asciispec above */ | ||
if (ENTRY_IS_DIRECTORY(mJarEntry) && fullJarURI) { | ||
RefPtr<nsStandardURL> cleanuri = new nsStandardURL(); | ||
|
||
if (NS_SUCCEEDED(cleanuri->Init( | ||
nsIStandardURL::URLTYPE_NO_AUTHORITY, -1, | ||
mJarDirSpec, nullptr, nullptr))) { | ||
cleanuri->SetQuery(NS_LITERAL_CSTRING("")); | ||
cleanuri->SetRef(NS_LITERAL_CSTRING("")); | ||
#ifdef DEBUG | ||
nsresult rv = | ||
#endif | ||
cleanuri->GetAsciiSpec(mJarDirSpec); | ||
NS_ASSERTION(NS_SUCCEEDED(rv), "this shouldn't fail either"); | ||
} else { | ||
MOZ_CRASH("failed to clean jar URI"); | ||
} | ||
} | ||
} | ||
|
||
int64_t GetContentLength() | ||
|
@@ -696,47 +715,49 @@ nsJARChannel::GetSecurityInfo(nsISupports **aSecurityInfo) | |
} | ||
|
||
NS_IMETHODIMP | ||
nsJARChannel::GetContentType(nsACString &result) | ||
nsJARChannel::SetContentTypeGuess() { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
roytam1
|
||
// | ||
// generate content type and set it | ||
// | ||
const char *ext = nullptr, *fileName = mJarEntry.get(); | ||
int32_t len = mJarEntry.Length(); | ||
|
||
// check if we're displaying a directory | ||
// mJarEntry will be empty if we're trying to display | ||
// the topmost directory in a zip, e.g. jar:foo.zip!/ | ||
if (ENTRY_IS_DIRECTORY(mJarEntry)) { | ||
mContentType.AssignLiteral(APPLICATION_HTTP_INDEX_FORMAT); | ||
} else { | ||
// not a directory, take a guess by its extension | ||
for (int32_t i = len-1; i >= 0; i--) { | ||
if (fileName[i] == '.') { | ||
ext = &fileName[i + 1]; | ||
break; | ||
} | ||
} | ||
if (ext) { | ||
nsIMIMEService *mimeServ = gJarHandler->MimeService(); | ||
if (mimeServ) | ||
mimeServ->GetTypeFromExtension(nsDependentCString(ext), mContentType); | ||
} | ||
if (mContentType.IsEmpty()) | ||
mContentType.AssignLiteral(UNKNOWN_CONTENT_TYPE); | ||
} | ||
|
||
return NS_OK; | ||
} | ||
|
||
NS_IMETHODIMP | ||
nsJARChannel::GetContentType(nsACString &aResult) | ||
{ | ||
// If the Jar file has not been open yet, | ||
// We return application/x-unknown-content-type | ||
if (!mOpened) { | ||
result.Assign(UNKNOWN_CONTENT_TYPE); | ||
if (!mOpened || mContentType.IsEmpty()) { | ||
aResult.Assign(UNKNOWN_CONTENT_TYPE); | ||
return NS_OK; | ||
} | ||
|
||
if (mContentType.IsEmpty()) { | ||
|
||
// | ||
// generate content type and set it | ||
// | ||
const char *ext = nullptr, *fileName = mJarEntry.get(); | ||
int32_t len = mJarEntry.Length(); | ||
|
||
// check if we're displaying a directory | ||
// mJarEntry will be empty if we're trying to display | ||
// the topmost directory in a zip, e.g. jar:foo.zip!/ | ||
if (ENTRY_IS_DIRECTORY(mJarEntry)) { | ||
mContentType.AssignLiteral(APPLICATION_HTTP_INDEX_FORMAT); | ||
} | ||
else { | ||
// not a directory, take a guess by its extension | ||
for (int32_t i = len-1; i >= 0; i--) { | ||
if (fileName[i] == '.') { | ||
ext = &fileName[i + 1]; | ||
break; | ||
} | ||
} | ||
if (ext) { | ||
nsIMIMEService *mimeServ = gJarHandler->MimeService(); | ||
if (mimeServ) | ||
mimeServ->GetTypeFromExtension(nsDependentCString(ext), mContentType); | ||
} | ||
if (mContentType.IsEmpty()) | ||
mContentType.AssignLiteral(UNKNOWN_CONTENT_TYPE); | ||
} | ||
} | ||
result = mContentType; | ||
aResult = mContentType; | ||
return NS_OK; | ||
} | ||
|
||
|
@@ -847,7 +868,7 @@ nsJARChannel::Open(nsIInputStream **stream) | |
return rv; | ||
|
||
input.forget(stream); | ||
mOpened = true; | ||
SetOpened(); | ||
// local files are always considered safe | ||
mIsUnsafe = false; | ||
return NS_OK; | ||
|
@@ -934,6 +955,14 @@ nsJARChannel::OverrideWithSynthesizedResponse(nsIInputStream* aSynthesizedInput, | |
NS_ENSURE_SUCCESS_VOID(rv); | ||
} | ||
|
||
void | ||
nsJARChannel::SetOpened() { | ||
MOZ_ASSERT(!mOpened, "Opening channel twice?"); | ||
mOpened = true; | ||
// Compute the content type now. | ||
NS_ASSERTION(NS_SUCCEEDED(SetContentTypeGuess()), "content type guess failure"); | ||
} | ||
|
||
NS_IMETHODIMP | ||
nsJARChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctx) | ||
{ | ||
|
@@ -1068,7 +1097,7 @@ nsJARChannel::FinishAsyncOpen() | |
if (mLoadGroup) | ||
mLoadGroup->AddRequest(this, nullptr); | ||
|
||
mOpened = true; | ||
SetOpened(); | ||
} | ||
|
||
//----------------------------------------------------------------------------- | ||
|
this part of change should be reverted(i.e. adding back "- x" and "- y" here) as it breaks overlay in https://www.ventusky.com/?w=off