Merge inbound to mozilla-central. a=merge

This commit is contained in:
Brindusan Cristian 2019-06-10 00:43:09 +03:00
Родитель 36994eb6d0 a83ea6ffbc
Коммит 1d5124f5f9
8 изменённых файлов: 46 добавлений и 110 удалений

Просмотреть файл

@ -17030,7 +17030,8 @@ nsresult Maintenance::DirectoryWork() {
for (const PersistenceType persistenceType : kPersistenceTypes) {
// Loop over "<persistence>" directories.
if (IsAborted()) {
if (NS_WARN_IF(QuotaClient::IsShuttingDownOnNonBackgroundThread()) ||
IsAborted()) {
return NS_ERROR_ABORT;
}
@ -17084,7 +17085,8 @@ nsresult Maintenance::DirectoryWork() {
while (true) {
// Loop over "<origin>/idb" directories.
if (IsAborted()) {
if (NS_WARN_IF(QuotaClient::IsShuttingDownOnNonBackgroundThread()) ||
IsAborted()) {
return NS_ERROR_ABORT;
}
@ -17160,7 +17162,8 @@ nsresult Maintenance::DirectoryWork() {
while (true) {
// Loop over files in the "idb" directory.
if (IsAborted()) {
if (NS_WARN_IF(QuotaClient::IsShuttingDownOnNonBackgroundThread()) ||
IsAborted()) {
return NS_ERROR_ABORT;
}
@ -18004,7 +18007,8 @@ DatabaseMaintenance::AutoProgressHandler::OnProgress(
MOZ_ASSERT(mConnection == aConnection);
MOZ_ASSERT(_retval);
*_retval = mMaintenance->IsAborted();
*_retval = QuotaClient::IsShuttingDownOnNonBackgroundThread() ||
mMaintenance->IsAborted();
return NS_OK;
}

Просмотреть файл

@ -3747,6 +3747,15 @@ nsDocumentViewer::GetCurrentPrintSettings(
return NS_OK;
}
NS_IMETHODIMP
nsDocumentViewer::GetDocumentName(nsAString& aDocName) {
# ifdef NS_PRINTING
return mPrintJob->GetDocumentName(aDocName);
# else
return NS_ERROR_FAILURE;
# endif
}
NS_IMETHODIMP
nsDocumentViewer::Cancel() {
NS_ENSURE_TRUE(mPrintJob, NS_ERROR_FAILURE);
@ -3764,22 +3773,6 @@ nsDocumentViewer::ExitPrintPreview() {
return NS_OK;
}
//----------------------------------------------------------------------------------
// Enumerate all the documents for their titles
NS_IMETHODIMP
nsDocumentViewer::EnumerateDocumentNames(uint32_t* aCount,
char16_t*** aResult) {
# ifdef NS_PRINTING
NS_ENSURE_ARG(aCount);
NS_ENSURE_ARG_POINTER(aResult);
NS_ENSURE_TRUE(mPrintJob, NS_ERROR_FAILURE);
return mPrintJob->EnumerateDocumentNames(aCount, aResult);
# else
return NS_ERROR_FAILURE;
# endif
}
NS_IMETHODIMP
nsDocumentViewer::GetPrintPreviewNumPages(int32_t* aPrintPreviewNumPages) {
# ifdef NS_PRINTING

Просмотреть файл

@ -1106,35 +1106,12 @@ int32_t nsPrintJob::GetPrintPreviewNumPages() {
return numPages;
}
//----------------------------------------------------------------------------------
// Enumerate all the documents for their titles
nsresult nsPrintJob::EnumerateDocumentNames(uint32_t* aCount,
char16_t*** aResult) {
NS_ENSURE_ARG(aCount);
NS_ENSURE_ARG_POINTER(aResult);
*aCount = 0;
*aResult = nullptr;
int32_t numDocs = mPrt->mPrintDocList.Length();
char16_t** array = (char16_t**)moz_xmalloc(numDocs * sizeof(char16_t*));
for (int32_t i = 0; i < numDocs; i++) {
nsPrintObject* po = mPrt->mPrintDocList.ElementAt(i);
NS_ASSERTION(po, "nsPrintObject can't be null!");
nsAutoString docTitleStr;
nsAutoString docURLStr;
GetDocumentTitleAndURL(po->mDocument, docTitleStr, docURLStr);
// Use the URL if the doc is empty
if (docTitleStr.IsEmpty() && !docURLStr.IsEmpty()) {
docTitleStr = docURLStr;
}
array[i] = ToNewUnicode(docTitleStr);
nsresult nsPrintJob::GetDocumentName(nsAString& aDocName) {
nsAutoString docURLStr;
GetDocumentTitleAndURL(mPrt->mPrintObject->mDocument, aDocName, docURLStr);
if (aDocName.IsEmpty() && !docURLStr.IsEmpty()) {
aDocName = docURLStr;
}
*aCount = numDocs;
*aResult = array;
return NS_OK;
}

Просмотреть файл

@ -117,8 +117,7 @@ class nsPrintJob final : public nsIObserver,
bool IsRangeSelection();
/// If the returned value is not greater than zero, an error occurred.
int32_t GetPrintPreviewNumPages();
/// Callers are responsible for free'ing aResult.
nsresult EnumerateDocumentNames(uint32_t* aCount, char16_t*** aResult);
nsresult GetDocumentName(nsAString& aDocName);
already_AddRefed<nsIPrintSettings> GetCurrentPrintSettings();
// This enum tells indicates what the default should be for the title

Просмотреть файл

@ -45,6 +45,13 @@ interface nsIWebBrowserPrint : nsISupports
*/
readonly attribute nsIPrintSettings currentPrintSettings;
/**
* The "name" of the document that is to be printed. This is the document's
* title, unless that's empty, in which case it is a sanitized version of the
* document's URL.
*/
readonly attribute AString documentName;
/**
* Returns whether it is in Print mode
*/
@ -109,17 +116,6 @@ interface nsIWebBrowserPrint : nsISupports
*/
void cancel();
/**
* Returns an array of the names of all documents names (Title or URL)
* and sub-documents. This will return a single item if the attr "isFramesetDocument" is false
* and may return any number of items is "isFramesetDocument" is true
*
* @param aCount - returns number of printers returned
* @param aResult - returns array of names
* @return void
*/
void enumerateDocumentNames(out uint32_t aCount,[retval, array, size_is(aCount)] out wstring aResult);
/**
* This exists PrintPreview mode and returns browser window to galley mode
* @return void

Просмотреть файл

@ -38,6 +38,13 @@ MockWebBrowserPrint::GetCurrentPrintSettings(
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
MockWebBrowserPrint::GetDocumentName(nsAString& aDocName) {
// The only consumer that cares about this is the OS X printing dialog.
aDocName = mData.printJobName();
return NS_OK;
}
NS_IMETHODIMP
MockWebBrowserPrint::GetDoingPrint(bool* aDoingPrint) {
return NS_ERROR_NOT_IMPLEMENTED;
@ -86,28 +93,6 @@ MockWebBrowserPrint::PrintPreviewNavigate(int16_t aNavType, int32_t aPageNum) {
NS_IMETHODIMP
MockWebBrowserPrint::Cancel() { return NS_ERROR_NOT_IMPLEMENTED; }
NS_IMETHODIMP
MockWebBrowserPrint::EnumerateDocumentNames(uint32_t* aCount,
char16_t*** aResult) {
*aCount = 0;
*aResult = nullptr;
if (mData.printJobName().IsEmpty()) {
return NS_OK;
}
// The only consumer that cares about this is the OS X printing
// dialog, and even then, it only cares about the first document
// name. That's why we only send a single document name through
// PrintData.
char16_t** array = (char16_t**)moz_xmalloc(sizeof(char16_t*));
array[0] = ToNewUnicode(mData.printJobName());
*aCount = 1;
*aResult = array;
return NS_OK;
}
NS_IMETHODIMP
MockWebBrowserPrint::ExitPrintPreview() { return NS_ERROR_NOT_IMPLEMENTED; }

Просмотреть файл

@ -53,15 +53,14 @@ nsPrintDialogServiceX::Show(nsPIDOMWindowOuter* aParent, nsIPrintSettings* aSett
settingsX->SetPrinterNameFromPrintInfo();
printSettingsSvc->InitPrintSettingsFromPrefs(settingsX, true, nsIPrintSettings::kInitSaveAll);
// Set the print job title
char16_t** docTitles;
uint32_t titleCount;
nsresult rv = aWebBrowserPrint->EnumerateDocumentNames(&titleCount, &docTitles);
if (NS_SUCCEEDED(rv) && titleCount > 0) {
nsAutoString docName;
nsresult rv = aWebBrowserPrint->GetDocumentName(docName);
if (NS_SUCCEEDED(rv)) {
// Print Core of Application Service sent print job with names exceeding
// 255 bytes. This is a workaround until fix it.
// (https://openradar.appspot.com/34428043)
nsAutoString adjustedTitle;
PrintTarget::AdjustPrintJobNameForIPP(nsDependentString(docTitles[0]), adjustedTitle);
PrintTarget::AdjustPrintJobNameForIPP(docName, adjustedTitle);
CFStringRef cfTitleString = CFStringCreateWithCharacters(
NULL, reinterpret_cast<const UniChar*>(adjustedTitle.BeginReading()),
adjustedTitle.Length());
@ -69,12 +68,6 @@ nsPrintDialogServiceX::Show(nsPIDOMWindowOuter* aParent, nsIPrintSettings* aSett
::PMPrintSettingsSetJobName(settingsX->GetPMPrintSettings(), cfTitleString);
CFRelease(cfTitleString);
}
for (int32_t i = titleCount - 1; i >= 0; i--) {
free(docTitles[i]);
}
free(docTitles);
docTitles = NULL;
titleCount = 0;
}
NSPrintInfo* printInfo = settingsX->GetCocoaPrintInfo();

Просмотреть файл

@ -48,23 +48,12 @@ nsresult nsPrintSettingsServiceX::SerializeToPrintDataChild(nsIPrintSettings* aS
// printer/printing settings from the OS causes a connection to the
// printer to be made which is blocked by sandboxing and results in hangs.
if (aWBP) {
// When serializing an nsIWebBrowserPrint, we need to pass up the first
// document name. We could pass up the entire collection of document
// names, but the OS X printing prompt code only really cares about
// the first one, so we just send the first to save IPC traffic.
char16_t** docTitles;
uint32_t titleCount;
nsresult rv = aWBP->EnumerateDocumentNames(&titleCount, &docTitles);
// When serializing an nsIWebBrowserPrint, we need to pass up the
// document name.
nsAutoString docName;
nsresult rv = aWBP->GetDocumentName(docName);
if (NS_SUCCEEDED(rv)) {
if (titleCount > 0) {
data->printJobName().Assign(docTitles[0]);
}
for (int32_t i = titleCount - 1; i >= 0; i--) {
free(docTitles[i]);
}
free(docTitles);
docTitles = nullptr;
data->printJobName().Assign(docName.get());
}
}